Flutter-permission-handler: Android Camera permission: Permission.camera.status returns undetermined when it should be permanentlyDenied

Created on 24 Jun 2020  ·  24Comments  ·  Source: Baseflow/flutter-permission-handler

🐛 Bug Report

Permission.camera.status returns undetermined if called immediately after the user permanentlyDenies the access.
In older android versions, keeps returning undetermined for longer whiles than in android 10 when the user clicks on permanentlyDenied option.

Reproduction steps

  1. Request user for permission
  2. Permanently deny the permission from the user's end
  3. Ask for permission status

Actual behavior

The permission status is returned as undetermined once.
Requesting the permission status again returns it as permanentlyDenied.

Expected behaviour

The permission status should be returned as permanentlyDenied.

Configuration

Version: ^5.0.0+hotfix.3

[✓] Flutter (Channel stable, v1.17.1, on Mac OS X 10.15.5 19F101, locale en-IN)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.2.1)
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.46.1)
[✓] Connected device (1 available)

• No issues found!

Platform:

  • [ ] :iphone: iOS
  • [x] :robot: Android
android bug

Most helpful comment

I also get undetermined for Permission.storage.status after I've denied access with "deny and never ask me again" button on android. I'm on version 5.0.1+1. I think the same thing happens for all permissions and not just camera?

All 24 comments

I am also facing the same issues @viplavrawal have you find any solution or workaround for the same?

@viplavrawal can you reproduce this bug with the latest version (5.0.1+1)? Maybe you can also check out the example App, does the problem occur there as well?

One option I am thinking is that we store information if permissions are requested before using the SharedPreferences API on Android. To do this we use the key GENERIC_PREFERENCES, does your App also save data to Android SharedPreferences and by change use the same key?

GENERIC_PREFERENCES

@mvanbeusekom yes, I am facing this issue with the latest version (5.0.1+1). And No we are not using GENERIC_PREFERENCES for storing any value in the shared preferences.

Also with version 4.0.0, it is working fine and the library returns me the perfect status of the permission as in case of denied and if I denied with never ask again then it returns me PermissionStatus.neverAskAgain. So may b the issues with the latest version only or something else I'm not sure about that.

i just add 5.0.1+1 to my app and this is still happening i'm always receiving. PermissionStatus.undetermined any updates?

@mvanbeusekom Is there any update on this?

  _checkForCameraPermission() async {
    var cameraPermission = await Permission.camera.status;
    print("camera permissions is $cameraPermission");
    final permissionStatus = await Permission.camera.request();

    if (permissionStatus == PermissionStatus.granted) {
  // navigate to Xyz screen.
    } else {
      _opneSetting();
    }
  }

First time await Permission.camera.request() worked properly with PermissionStatus.undetermined.But after that when I deny the permission getting same permission status as PermissionStatus.undetermined and await Permission.camera.status give me below exception.

E/flutter (14582): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(PermissionHandler.PermissionManager, A request for permissions is already running, please wait for it to finish before doing another request (note that you can request multiple permissions at the same time)., null)
E/flutter (14582): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
E/flutter (14582): #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:321:33)
E/flutter (14582): <asynchronous suspension>
E/flutter (14582): #2      MethodChannelPermissionHandler.requestPermissions (package:permission_handler_platform_interface/src/method_channel/method_channel_permission_handler.dart:66:30)
E/flutter (14582): #3      PermissionListActions.request (package:permission_handler/permission_handler.dart:97:16)
E/flutter (14582): #4      PermissionActions.request (package:permission_handler/permission_handler.dart:37:26)
E/flutter (14582): #5      FacilityDashboardState._checkForCameraPermission (package:my_doses/src/facility_dashboard/ui/facility_dashboard_ui.dart:396:54)
E/flutter (14582): <asynchronous suspension>
E/flutter (14582): #6      FacilityDashboardState.getOptionsView.<anonymous closure> (package:my_doses/src/facility_dashboard/ui/facility_dashboard_ui.dart:361:29)
E/flutter (14582): #7      getCardItemWithText.<anonymous closure> (package:my_doses/src/utils/common_utils.dart:112:21)
E/flutter (14582): #8      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:706:14)
E/flutter (14582): #9      _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:789:36)
E/flutter (14582): #10     GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter (14582): #11     TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:486:11)
E/flutter (14582): #12     BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:264:5)
E/flutter (14582): #13     BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:236:7)
E/flutter (14582): #14     GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
E/flutter (14582): #15     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:222:20)
E/flutter (14582): #16     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
E/flutter (14582): #17     GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
E/flutter (14582): #18     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
E/flutter (14582): #19     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
E/flutter (14582): #20     _rootRunUnary (dart:async/zone.dart:1138:13)
E/flutter (14582): #21     _CustomZone.runUnary (dart:async/zone.dart:1031:19)
E/flutter (14582): #22     _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7)
E/flutter (14582): #23     _invoke1 (dart:ui/hooks.dart:273:10)
E/flutter (14582): #24     _dispatchPointerDataPacket (dart:ui/hooks.dart:182:5)
E/flutter (14582): 


I also get undetermined for Permission.storage.status after I've denied access with "deny and never ask me again" button on android. I'm on version 5.0.1+1. I think the same thing happens for all permissions and not just camera?

Any news? Any workaround? This is a real pain.

Hi
I was not able to reproduce, but it seems a lot of people have this issue.
Maybe this solution helps.

@Sempakonka This happens on every device I've tested and on every app I've tested it in. It's extremely weird if you are not able to reproduce this.

@Sempakonka 's suggestion also runs permission request, resulting in the same exception.

I'm also facing this issue, while using add-to-app in Flutter. One thing I'd like to share is that Flutter shared_preferences also doesn't work with add-to-app, maybe there is something with using Android's shared preferences via channel.

Update, I'm encountering this issue with Android API level 30, on fully Flutter app (not add-to-app)

Update, I'm encountering this issue with Android API level 30, on fully Flutter app (not add-to-app)

same here.
I was already on permission_handler 5.x for some time. Today a pub upgrade brakes my storage permission status (always undetermined although it is granted).

logcat says:
No permissions found in manifest for: 15
(15 is the enum for storage group)

of cause permission is defined in manifest.

I tried to downgrade back to an old 5.x version but no success. Now I am using
permission_handler: 4.4.0+hotfix.4
and it works again (with PermissionHandler().checkPermissionStatus(..) )

edit: only testet on android 11

I was already on permission_handler 5.x for some time. Today a pub upgrade breaks my storage permission status

Same issue here. Please, fix this bug asap

Same issue here.
Something is wrong with the "platform_interface" project in version 2.0.2 ...

I put this in my pubspec.yaml and worked:

 permission_handler: 5.0.1+1
 permission_handler_platform_interface: 2.0.1

@moodstubos, @RomanKapshuk, @claudiowagner, a fix is on its way should be uploaded in 30 minutes.

@moodstubos, @RomanKapshuk, @claudiowagner, I have just released hotfix 5.1.0+2 which should fix this problem. Someone from the community added a new permission to iOS and updated the constants but forgot to do the same on Android. I also completely overlooked it, causing this problem.

@mvanbeusekom thanks a lot for your explanation. I will try the fix.

Edit: Update to 5.1.0+2 fixed the issue. Thanks again!

@moodstubos Hmm I tried 5.1.0+2 but I'm still seeing the same issue. Are you using flutter channel stable?

Edit: also checked on channel beta but no luck.

I also tried 5.1.0+2 but I'm still seeing the same issue.
I use with shared_preferences package. I think problems caused by using with shared_preferences package is still remaining. It is related #380 .
My work around is to use with request() ( ex. Permission.storage.request().isPermanentlyDenied ). It seems to return correct value without referring shared preferences' storage.

@kikunantoka I am also using shared_preferences, however with or without the package I am getting incorrect PermissionStatus from this package.

By using .request() the future does not finish the first time, and the second time it is called, I get an exception
A request for permissions is already running, please wait for it to finish before doing another request (note that you can request multiple permissions at the same time).

This issue should be opened again

Seems this issue is discussing two different problems. I have solved one but never the original problem.

i am using API 30 AVD ,not able to open camera...

Since the release of version 6.0.1 of the permission_handler the original issue should now also be solved.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jaleelmeemo picture jaleelmeemo  ·  5Comments

lvlrSajjad picture lvlrSajjad  ·  3Comments

yethael picture yethael  ·  3Comments

klaszlo8207 picture klaszlo8207  ·  5Comments

shinriyo picture shinriyo  ·  5Comments