Skip to content

Commit

Permalink
perf:Optimize the status of READ_MEDIA_VISUAL_USER_SELECTED permission (
Browse files Browse the repository at this point in the history
#1359)

* perf:Optimize the status of READ_MEDIA_VISUAL_USER_SELECTED permission

* updata version to 12.0.9  added CHANGELOG

* Deal with other situations

* Remove non-essential check restricted states

---------

Co-authored-by: inTao <[email protected]>
Co-authored-by: inTao <[email protected]>
  • Loading branch information
3 people authored Aug 16, 2024
1 parent f141b9b commit b8d3182
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
2 changes: 2 additions & 0 deletions permission_handler_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## 12.0.9
* Added Make the status return of the READ_MEDIA_VISUAL_USER_SELECTED permission more accurate.
## 12.0.8

* Added support for limited photo and video permission on Android.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,15 +538,17 @@ private int determinePermissionStatus(final @PermissionConstants.PermissionGroup
permissionStatuses.add(PermissionConstants.PERMISSION_STATUS_GRANTED);
}
} else if (permission == PermissionConstants.PERMISSION_GROUP_PHOTOS || permission == PermissionConstants.PERMISSION_GROUP_VIDEOS){
final int permissionStatusLimited = ContextCompat.checkSelfPermission(context, Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED);
final int permissionStatus = ContextCompat.checkSelfPermission(context, name);
if (permissionStatusLimited == PackageManager.PERMISSION_GRANTED){
permissionStatuses.add(PermissionConstants.PERMISSION_STATUS_LIMITED);
}
else{
if (permissionStatus != PackageManager.PERMISSION_GRANTED) {
permissionStatuses.add(PermissionUtils.determineDeniedVariant(activity, name));
}
final int permissionStatus = ContextCompat.checkSelfPermission(context, name);
int permissionStatusLimited = permissionStatus;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
permissionStatusLimited = ContextCompat.checkSelfPermission(context, Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED);
}
if (permissionStatusLimited == PackageManager.PERMISSION_GRANTED && permissionStatus == PackageManager.PERMISSION_DENIED) {
permissionStatuses.add(PermissionConstants.PERMISSION_STATUS_LIMITED);
} else if (permissionStatus == PackageManager.PERMISSION_GRANTED) {
permissionStatuses.add(PermissionConstants.PERMISSION_STATUS_GRANTED);
}else {
permissionStatuses.add(PermissionUtils.determineDeniedVariant(activity, name));
}
}else {
final int permissionStatus = ContextCompat.checkSelfPermission(context, name);
Expand Down
2 changes: 1 addition & 1 deletion permission_handler_android/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: permission_handler_android
description: Permission plugin for Flutter. This plugin provides the Android API to request and check permissions.
homepage: https://github.com/baseflow/flutter-permission-handler
version: 12.0.8
version: 12.0.9

environment:
sdk: ">=2.15.0 <4.0.0"
Expand Down

0 comments on commit b8d3182

Please sign in to comment.