Skip to content

Fix AndroidStorage.TryGetFile/FolderFromPathAsync returning null or throwing - #21628

Merged
MrJul merged 1 commit into
AvaloniaUI:masterfrom
MrJul:fix/android-storage-api33
Jun 22, 2026
Merged

Fix AndroidStorage.TryGetFile/FolderFromPathAsync returning null or throwing#21628
MrJul merged 1 commit into
AvaloniaUI:masterfrom
MrJul:fix/android-storage-api33

Conversation

@MrJul

@MrJul MrJul commented Jun 22, 2026

Copy link
Copy Markdown
Member

What does the pull request do?

This PR fixes AndroidStorage.TryGetFileFromPathAsync and TryGetFolderFromPathAsync not returning results for several reasons.

First, the READ_EXTERNAL_STORAGE permission is always denied since Android API 33, which means the call always failed on such platforms. This PR no longer checks for that permission, as it might not be required at all (e.g., files in the app's folder since API 19, well below our minimum supported level, 24) or might always be denied (API ≥ 33). This is a bit similar to what #18637 was doing.

Second, some code logic was inverted, meaning that existing files and folders would always return null.

Notes

On Android, the objects we return from TryGetFileFromPathAsync, TryGetFolderFromPathAsync and TryGetWellKnownFolderAsync are pretty useless. See #21629.

@avaloniaui-bot

Copy link
Copy Markdown

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

@MrJul
MrJul added this pull request to the merge queue Jun 22, 2026
Merged via the queue into AvaloniaUI:master with commit 7467c0c Jun 22, 2026
12 checks passed
@MrJul
MrJul deleted the fix/android-storage-api33 branch June 22, 2026 19:55
MrJul added a commit to MrJul/Avalonia that referenced this pull request Jun 23, 2026
@MrJul MrJul added backported-12.0.x and removed backport-candidate-12.0.x Consider this PR for backporting to 12.0 branch labels Jun 23, 2026
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.

3 participants