KEMBAR78
[Android][Permissions]Requesting permissions using RequestAsync while the app is in the background - fix by kubaflo · Pull Request #30697 · dotnet/maui · GitHub
Skip to content

Conversation

@kubaflo
Copy link
Contributor

@kubaflo kubaflo commented Jul 17, 2025

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

@Copilot Copilot AI review requested due to automatic review settings July 17, 2025 23:49
@kubaflo kubaflo requested a review from a team as a code owner July 17, 2025 23:49
@kubaflo kubaflo self-assigned this Jul 17, 2025
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Jul 17, 2025
@dotnet-policy-service
Copy link
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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 grantResults array 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))

@kubaflo kubaflo added platform/android area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info area-essentials-permissions community ✨ Community Contribution and removed community ✨ Community Contribution labels Jul 17, 2025
@jfversluis jfversluis changed the title [Android][Permissions]Requesting permissions using RequestAsync while the app is in the backgrkground - fix [Android][Permissions]Requesting permissions using RequestAsync while the app is in the background - fix Aug 7, 2025
@jfversluis jfversluis added this to the .NET 9 SR11 milestone Aug 7, 2025
@PureWeen PureWeen changed the base branch from main to inflight/current August 7, 2025 21:06
@PureWeen PureWeen merged commit fb6b84c into dotnet:inflight/current Aug 7, 2025
1 check passed
PureWeen pushed a commit that referenced this pull request Aug 8, 2025
github-actions bot pushed a commit that referenced this pull request Aug 11, 2025
github-actions bot pushed a commit that referenced this pull request Aug 15, 2025
github-actions bot pushed a commit that referenced this pull request Aug 15, 2025
github-actions bot pushed a commit that referenced this pull request Aug 19, 2025
github-actions bot pushed a commit that referenced this pull request Aug 22, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Sep 7, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info area-essentials-permissions community ✨ Community Contribution platform/android

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Requesting permissions using RequestAsync while the app is in the background always returns granted.

3 participants