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

Conversation

FelixZY
Copy link

@FelixZY FelixZY commented Jul 12, 2024

Adding the fix I proposed in #1781

Fixes #1781


Additional complication:

I have indications that ACCESS_BACKGROUND_LOCATION may be Denied(shouldShowRationale=false) while ACCESS_FINE_LOCATION is Denied(shouldShowRationale=true). It then seems like ACCESS_BACKGROUND_LOCATION shifts to Denied(shouldShowRationale=true) once ACCESS_FINE_LOCATION is granted.

I have not yet confirmed this but something seems to be acting strange with these two. If the above description is correct, the proposed solution in this PR is insufficient (though covering an unexpected gap that exists today).

I think someone should take a closer look and disprove the above theory before merging this (that'll probably be a few months out on my end - if even then).

…`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`.
@bentrengrove
Copy link
Collaborator

Sorry for the slow response here, I am planning to get to this. Just trying to get the beta release out first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants