flutter-permission-handler
flutter-permission-handler copied to clipboard
[Android] permission request may return wrong result
🐛 Bug Report
Permission request may got wrong result on Android platform.
Let's say two permissions declared in AndroidManifest.xml of a flutter app:
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_NUMBERS" />
Both of them are Permission.phone
on permission_handler dart side.
On devices running Android 11 and after (Samsung Galaxy Note 20 on my hand),grant READ_PHONE_STATE
but deny READ_PHONE_NUMBERS
to the app, then when you request Permission.phone
permission on app dart side by [Permission.phone].request()
, you got the result {Permission.phone: PermissionStatus.granted}
which is incorrect or inaccurate.
Expected behavior
Give caller precise status of every manifest permissions, or give denied status if any of them are denied.
Reproduction steps
as described above
Configuration
Version: 8.2.5
Platform:
- [ ] :iphone: iOS not test
- [x] :robot: Android
The codes produce this issue is in onRequestPermissionsResult
of PermissionManager.java
} else if (!requestResults.containsKey(permission)) {
requestResults.put(
permission,
PermissionUtils.toPermissionStatus(this.activity, permissionName, result));
}
Only the status of the first manifest permission of a PermissionConstants.PermissionGroup
will be recorded in the requestResults
to represent the overall status of the PermissionConstants.PermissionGroup
.
It's an oversight or just by design?
This problem is very frustrating. Does anybody have a patch or a workaround?