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

[Permissions] fix(gh-1781): check for Denied(shouldShowRationale=false) in MutableMultiplePermissionsState.shouldShowRationale #1783

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on Jul 12, 2024

  1. fix(googlegh-1781): check for Denied(shouldShowRationale=false) in …

    …`MutableMultiplePermissionsState.shouldShowRationale`
    
    `launchMultiplePermissionRequest` is typically called when
    `shouldShowRationale` returns true. However, what may not be as obvious
    is that `launchMultiplePermissionRequest` appears to result in a noop if
    one or more permissions in `MutableMultiplePermissionsState` are
    `Denied(shouldShowRationale=false)`. This caused issues for us in some
    code similar to this:
    
    ```kotlin
    val permissions =
        rememberMultiplePermissionsState(
            listOf(
                ACCESS_FINE_LOCATION,
                ACCESS_BACKGROUND_LOCATION,
            )
        )
    
    when {
      // Granted
      permissions.allPermissionsGranted -> /* ... */,
      // Denied, but I can ask the user
      permissions.shouldShowRationale ->
        // UNEXPECTED: Does not trigger!
        permissions.launchMultiplePermissionRequest()
      // Denied and I may not ask the user.
      else -> /* ... */
    }
    ```
    
    The fix would seem to be to additionally make sure that there are no
    permissions with the `Denied(shouldShowRationale=false)` status before
    returning a truthy value from `shouldShowRationale`.
    FelixZY committed Jul 12, 2024
    Configuration menu
    Copy the full SHA
    14b037e View commit details
    Browse the repository at this point in the history