Skip to content

Conversation

@bhavanesh2001
Copy link
Contributor

Issue Summary

The FilePicker API for Android currently does not properly handle file access when MANAGE_EXTERNAL_STORAGE is granted. This leads to an incorrect behavior where the absolute file path is not resolved, and instead, the FilePicker returns a cached copy.

Root Cause

  • The issue occurs because EnsurePhysicalPath always forces requireExtendedAccess = true , which prevents ResolveDocumentPath from executing when Scoped Storage is enforced on Android 10+ (API 29+).
  • Currently, we do not consider if MANAGE_EXTERNAL_STORAGE is granted, meaning it doesn't attempt to resolve the path even when the permission is granted.

Fix

  • Pass requireExtendedAccess = false when MANAGE_EXTERNAL_STORAGE is granted to allow ResolveDocumentPath to execute.
  • If the path still cannot be resolved, it will automatically fall back to caching the file as we currently do.

Current Behaviour:

current_behaviour.mp4

After Fix

after_fix.mp4

Issues Fixed

Fixes #6015

@bhavanesh2001 bhavanesh2001 requested a review from a team as a code owner February 22, 2025 08:49
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Feb 22, 2025
@dotnet-policy-service
Copy link
Contributor

Hey there @bhavanesh2001! 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
Member

@jfversluis jfversluis left a comment

Choose a reason for hiding this comment

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

See comment

@jfversluis
Copy link
Member

/azp run

@jfversluis jfversluis added this to the .NET 9 SR5 milestone Feb 22, 2025
@jfversluis jfversluis self-assigned this Feb 22, 2025
@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jfversluis jfversluis added area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info area-essentials-filepicker labels Feb 24, 2025
@jfversluis jfversluis merged commit 5041c7c into dotnet:main Feb 24, 2025
124 checks passed
@bhavanesh2001 bhavanesh2001 deleted the fix_6015 branch February 24, 2025 13:46
@KieranDevvs
Copy link

@jfversluis can this be backported to .NET 8?

@jfversluis
Copy link
Member

@KieranDevvs that is highly unlikely since .NET MAUI built against .NET 8 will go out of support in a few months: https://dotnet.microsoft.com/platform/support/policy/maui

@github-actions github-actions bot locked and limited conversation to collaborators Mar 28, 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-filepicker community ✨ Community Contribution

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

FilePicker doesn't take into account IsExternalStorageManager

3 participants