Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug report] Huawei Permission #1067

Closed
HenrikH96 opened this issue Dec 28, 2023 · 9 comments
Closed

[Bug report] Huawei Permission #1067

HenrikH96 opened this issue Dec 28, 2023 · 9 comments

Comments

@HenrikH96
Copy link

Version

3.0.0-dev.5

Platforms

dart, Android

Device Model

Huawei p30

flutter info

[√] Flutter (Channel stable, 3.16.5, on Microsoft Windows [Version 10.0.22621.2861], locale en-US)
    • Flutter version 3.16.5 on channel stable at C:\Users\Henrik\fvm\versions\3.16.5
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 78666c8dc5 (9 days ago), 2023-12-19 16:14:14 -0800
    • Engine revision 3f3e560236
    • Dart version 3.2.3
    • DevTools version 2.28.4

How to reproduce?

After requesting permission with PermissionState permisson = await PhotoManager.requestPermissionExtend(); , the permission enum always returns Permission.denied, even though I granted access.

Logs

No response

Example code (optional)

No response

Contact

hh@jourries.com

@HenrikH96
Copy link
Author

Upon further investigation, I discovered that Huawei phones, including the one I have, require storage permission. Although Photomanager.requestPermission grants it, the return value consistently remains PermissionState.denied

@AlexV525
Copy link
Member

What is the issue exactly? We don't know your device info yet.

@HenrikH96
Copy link
Author

@AlexV525
I tested it on a Huawei P30 with EMUI 12. When using Photomanager.requestPermission, the permission prompt is displayed, but it never receives authorization. To work around this issue, I checked for storage permission using permission_handler, which successfully granted storage permission. Consequently, I proceeded even though the Photomanager permission state remained as PermissionState.denied.

All other functionalities appear to work correctly, and I haven't encountered any additional issues. The only concern is that the PermissionState is not reflecting the actual permission status in this particular case.

@AlexV525
Copy link
Member

AlexV525 commented Jan 2, 2024

Can you provide a minimal reproducible example? Or share your usage code about what permissions you've requested using the permission_handler?

@HenrikH96
Copy link
Author

Certainly. Here's my workaround. After implementing this, I handle permission states accordingly.
The performAction boolean is used later to determine whether to navigate to AppSettings or not.

Future<PermissionState> checkPermission({bool performAction = true}) async {
    PermissionState permisson = await PhotoManager.requestPermissionExtend();
    if (permisson == PermissionState.denied) {
      //Huawei extra
      PermissionStatus storageStatus = await Permission.storage.request();
      if (storageStatus.isGranted) {
        permisson = PermissionState.authorized;
      }
    }
    
    [...]
 }

@AlexV525
Copy link
Member

AlexV525 commented Jan 4, 2024

Did you declare the storage permission in your manifest? What Android API level is your Huawei device? Can it be reproduced on other devices that have the same API level?

@jeevareddy
Copy link

@AlexV525,
I believe it is simply reproducible with Android 10 (API 29).

@jeevareddy
Copy link

jeevareddy commented Jan 4, 2024

Adding this permission resolves the permission.denied issue with Android 10
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="29"/>

@HenrikH96
Copy link
Author

@jeevareddy
Thank's that seems to fix the Issue I had with Huawei

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants