[Android][Permissions]Requesting permissions using RequestAsync while the app is in the background - fix#30697
Merged
PureWeen merged 1 commit intodotnet:inflight/currentfrom Aug 7, 2025
Merged
Conversation
Contributor
|
Hey there @@kubaflo! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a critical bug in Android permissions handling where interrupted user interactions could lead to incorrect permission grant assumptions. The change adds a necessary check to handle empty grant results arrays that can occur when permission requests are interrupted (e.g., when the app goes to background).
- Adds validation for empty
grantResultsarray in permission request handling - Ensures interrupted permission requests are properly treated as denied rather than incorrectly assumed as granted
Comments suppressed due to low confidence (1)
src/Essentials/src/Permissions/Permissions.android.cs:89
- This critical security fix that handles interrupted permission requests should have corresponding test cases to verify the behavior when grantResults is empty. Please ensure test cases exist in TestCases.HostApp and TestCases.Shared.Tests to validate this edge case.
if (permissionResult.GrantResults.Length == 0 || permissionResult.GrantResults.Any(g => g == Permission.Denied))
jfversluis
approved these changes
Aug 7, 2025
PureWeen
pushed a commit
that referenced
this pull request
Aug 8, 2025
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Description of Change
This check is necessary because in Android, OnRequestPermissionsResult can be called with an empty grantResults array if the user interaction was interrupted. Ignoring this could lead to incorrect assumptions that permissions were granted.
Issues Fixed
Fixes #30678