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]: Permission status can't distinguish denied vs permanently denied when Android "Ask every time" option is used #1206

Open
3 of 5 tasks
jjoelson opened this issue Oct 30, 2023 · 3 comments
Labels
P2 Important issues not at the top of the work list. platform: android Issue is related to the Android platform. type: bug Something isn't working

Comments

@jjoelson
Copy link

jjoelson commented Oct 30, 2023

Please check the following before submitting a new issue.

Please select affected platform(s)

  • Android
  • iOS
  • Windows

Steps to reproduce

This issue is a follow-up to my comment in #1130.

  1. Request permission over and over (e.g. with Permission.camera.request()) and deny each time until the result is "permanently denied".
  2. Open Android system settings and set the permission in question for the app to "Ask every time".
  3. Switch back to the app and check the permission status (e.g. with Permission.camera.status).

Expected results

The status is PermissionStatus.denied.

Actual results

The status is PermissionStatus.permanentlyDenied.

Code sample

Code sample
import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  PermissionStatus? _currentStatus;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(),
        body: Center(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              Text('Permission Status: $_currentStatus'),
              TextButton(
                onPressed: _checkStatus,
                child: const Text('Check Permission Status'),
              ),
              TextButton(
                onPressed: _requestStatus,
                child: const Text('Request Permission'),
              ),
            ],
          ),
        ),
      ),
    );
  }

  void _checkStatus() async {
    final status = await Permission.camera.status;
    setState(() {
      _currentStatus = status;
    });
  }

  void _requestStatus() async {
    final status = await Permission.camera.request();
    setState(() {
      _currentStatus = status;
    });
  }
}

Screenshots or video

No response

Version

11.0.1

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.13.9, on macOS 13.6 22G120 darwin-arm64, locale
    en-US)
    • Flutter version 3.13.9 on channel stable at
      /Users/jonathanjoelson/repos/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision d211f42860 (5 days ago), 2023-10-25 13:42:25 -0700
    • Engine revision 0545f8705d
    • Dart version 3.1.5
    • DevTools version 2.25.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/jonathanjoelson/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • ANDROID_HOME = /Users/jonathanjoelson/Library/Android/sdk
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14A400
    • CocoaPods version 1.12.0

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      11.0.13+0-b1751.21-8125866)

[✓] VS Code (version 1.83.0)
    • VS Code at /Users/jonathanjoelson/Desktop/Visual Studio Code.app/Contents
    • Flutter extension version 3.74.0

[✓] Connected device (4 available)
    • Pixel 4a (mobile)  • 0B201JEC221560                       • android-arm64  •
      Android 13 (API 33)
    • iPhone 13 (mobile) • 120E063D-E34D-44F8-A6C3-7CB0146B4B76 • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-16-0 (simulator)
    • macOS (desktop)    • macos                                • darwin-arm64   •
      macOS 13.6 22G120 darwin-arm64
    • Chrome (web)       • chrome                               • web-javascript •
      Google Chrome 111.0.5563.64

[✓] Network resources
    • All expected network resources are available.

• No issues found!
@JeroenWeener JeroenWeener self-assigned this Nov 1, 2023
@JeroenWeener JeroenWeener added platform: android Issue is related to the Android platform. type: bug Something isn't working P2 Important issues not at the top of the work list. labels Nov 1, 2023
@JeroenWeener
Copy link
Contributor

Thanks for bringing this up @jjoelson. I was able to reproduce this issue.

@MarwanAdel1
Copy link

is there a work around for this issue?

@JeroenWeener
Copy link
Contributor

As far as I know, no one has picked up this issue as of yet. If you feel like you could contribute, feel free to open a PR. The Baseflow team would probably be happy to assist you. @TimHoogstrate @mvanbeusekom.

@JeroenWeener JeroenWeener removed their assignment Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 Important issues not at the top of the work list. platform: android Issue is related to the Android platform. type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants