Skip to content

Android - Use BCL storage api for TryGet api - #21641

Merged
MrJul merged 1 commit into
masterfrom
android_storage_provider_bcl
Jun 24, 2026
Merged

MrJul merged 1 commit into
masterfrom
android_storage_provider_bcl

Conversation

@emmauss

@emmauss emmauss commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

What does the pull request do?

Changes IStorageProvider.TryGetFileFromPathAsync, TryGetFolderFromPathAsync and TryGetWellKnownFolderAsync to return BCLStorageItem for paths passed to them.

From Android API 19, which is lower than our minimum supported API 24, apps access storage using the Storage Access Framework (SAF) and do not need permission for read and write access. File managers can still use Java File apis with the older permissions until API 29, from this point, they have to declare a special MANAGE_EXTERNAL_STORAGE permission. Arbitrary File access is no longer available to normal apps.
With these changes, it makes sense to treat direct file URIs as normal Java Files and require the dev to manage permissions and ensure the URI is valid. We return BCLStorageItems for these apis.

What is the current behavior?

IStorageProvider.TryGetFileFromPathAsync, TryGetFolderFromPathAsync and TryGetWellKnownFolderAsync returns AndroidStorageItem which will fail to be read, as these use invalid URIs.

What is the updated/expected behavior with this PR?

How was the solution implemented (if it's not obvious)?

Checklist

Breaking changes

Obsoletions / Deprecations

Fixed issues

Fixes #21629

@emmauss
emmauss requested a review from MrJul June 24, 2026 13:19
@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.1.999-cibuild0066892-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@MrJul MrJul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Tested, works as expected: files in the app's folder can be accessed directly via the 3 APIs.

LGTM!

@MrJul
MrJul added this pull request to the merge queue Jun 24, 2026
Merged via the queue into master with commit 9691b4e Jun 24, 2026
12 checks passed
@MrJul
MrJul deleted the android_storage_provider_bcl branch June 24, 2026 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make Android IStorageProvider APIs work when using file paths

3 participants