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

permissions-dispatcher:ktx:1.0.5 has bug #729

Closed LZ9 closed 2 years ago

LZ9 commented 3 years ago

in PermissionRequestViewModel.kt this function :

    inline fun observe(
        owner: LifecycleOwner,
        key: String,
        crossinline requiresPermission: Fun,
        noinline onPermissionDenied: Fun?,
        noinline onNeverAskAgain: Fun?
    ) {
        permissionRequestResult.observe(owner, Observer {
            when (it[key]?.getContentIfNotHandled()) {
                PermissionResult.GRANTED -> requiresPermission.invoke()
                PermissionResult.DENIED -> onPermissionDenied?.invoke()
                PermissionResult.DENIED_AND_DISABLED -> onNeverAskAgain?.invoke()
                else -> Unit
            }
        })
    }

the key is [android.permission.READ_PHONE_STATE, android.permission.WRITE_EXTERNAL_STORAGE, android.permission.READ_EXTERNAL_STORAGE]

but it[key] get is null , becasuse Observer`s it the key is [android.permission.READ_EXTERNAL_STORAGE, android.permission.READ_PHONE_STATE, android.permission.WRITE_EXTERNAL_STORAGE] , key is different from it the key.

so can not callback requiresPermission or onPermissionDenied or onNeverAskAgain when multiple permissions apply at the same time

YassKnight commented 3 years ago

I have the same problem

hotchemi commented 2 years ago

Do you mean there're some cases that the order of the permissions could be different? šŸ‘€

LZ9 commented 2 years ago

Do you mean there're some cases that the order of the permissions could be different? šŸ‘€

Yes, The key is different if the order is different. So the result may be null.

hotchemi commented 2 years ago

it should be resolved in 1.1.3, thx for your report!