[Permissions] fix(gh-1781): check for Denied(shouldShowRationale=false) in MutableMultiplePermissionsState.shouldShowRationale#1783
Merged
bentrengrove merged 1 commit intogoogle:mainfrom Nov 25, 2024
Conversation
Collaborator
|
Sorry for the slow response here, I am planning to get to this. Just trying to get the beta release out first |
bentrengrove
approved these changes
Nov 24, 2024
Collaborator
bentrengrove
left a comment
There was a problem hiding this comment.
Thanks for this and sorry for the slow review. Could you please rebase this to main just to kick the CI?
Contributor
Author
|
Sure! It will be a day or two but I'll do so asap. |
…`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`.
Contributor
Author
|
@bentrengrove rebase completed 🚀 |
|
/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adding the fix I proposed in #1781
Fixes #1781
Additional complication:
I have indications that
ACCESS_BACKGROUND_LOCATIONmay beDenied(shouldShowRationale=false)whileACCESS_FINE_LOCATIONisDenied(shouldShowRationale=true). It then seems likeACCESS_BACKGROUND_LOCATIONshifts toDenied(shouldShowRationale=true)onceACCESS_FINE_LOCATIONis 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).