permissions-dispatcher / PermissionsDispatcher

A declarative API to handle Android runtime permissions.
https://github.com/permissions-dispatcher/PermissionsDispatcher
Apache License 2.0
11.21k stars 1.44k forks source link

Android 12 Update Request - Updating Permission Check from PermissionChecker to ContextCompat #756

Closed jcoona closed 2 years ago

jcoona commented 2 years ago

Overview

private static boolean hasSelfPermission(Context context, String permission) {
        try {
            return ContextCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED;
        } catch (RuntimeException t) {
            return false;
        }
    }

See: Google's documentation on requesting permissions

I am requesting this feature because in my app, I am often checking to see if a permission is granted on app launch, so that if its missing, I can present the user with an instructional page on why they may want to grant the permission. If they have it granted already, we just move on. This check will falsely cause the user to think I am unexpectedly accessing the camera / microphone.

Expected

Actual

Environment

Reproducible steps

hotchemi commented 2 years ago

Thx! kinda interesting only PermissionChecker causes the issue but I don't have any objection to use ContextCompat.

https://github.com/permissions-dispatcher/PermissionsDispatcher/pull/757

hotchemi commented 2 years ago

BTW, maybe we should report to AOSP or androidx team? sounds like a bug or lack of documentationšŸ¤” @jcoona

crimsonwoods commented 2 years ago

Maybe, this issue is a bug of old AndroidX Core library.

See below links:

IMO, this issue is fixed on Android Core 1.7.0 or later, so, updating dependency on it is the first choice to fix this issue.