Skip to content

fix(import): import files when External Storage lacks file access - #22851

Merged
BrayanDSO merged 1 commit into
ankidroid:mainfrom
criticalAY:fix/import-storage-no-access
Oct 30, 2026
Merged

BrayanDSO merged 1 commit into
ankidroid:mainfrom
criticalAY:fix/import-storage-no-access

Conversation

@criticalAY

Copy link
Copy Markdown
Contributor

Note

Assisted-by: Opus 5.5

Purpose / Description

Importing from the device storage failed with com.android.externalstorage has no access to ... on phones where the system External Storage app has lost "All files access", and each failure was sent to ACRA.

Fixes

Approach

On Android 12+, retry through MediaStore.getMediaUri, which reuses the access we already have to the picked file. If that also fails, the error is reported as before.

How Has This Been Tested?

CI and repro tests

Learning (optional, can help others)

Since Android 12 the storage provider reads files through MediaStore, which needs All files access, so every app fails the same way on these phones.

Checklist

Please, go through these checks before submitting the PR.

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

@david-allison

Copy link
Copy Markdown
Member

Really sorry, could we block this on:

@criticalAY criticalAY added the Blocked by dependency Currently blocked by some other dependent / related change label Oct 28, 2026
@criticalAY
criticalAY force-pushed the fix/import-storage-no-access branch from bc51f48 to f27ed64 Compare October 29, 2026 04:52

@david-allison david-allison 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.

Windows tests failing

@david-allison david-allison added Needs Author Reply Waiting for a reply from the original author and removed Blocked by dependency Currently blocked by some other dependent / related change labels Oct 29, 2026
Importing from the device storage failed on phones where the system
External Storage app has lost "All files access", and each failure was
sent as a crash report. We now read the picked file through MediaStore,
which accepts the access we already have.

Fixes 22822
Assisted-by: Claude Opus 5.5
@criticalAY
criticalAY force-pushed the fix/import-storage-no-access branch from f27ed64 to e333640 Compare October 29, 2026 15:01
@criticalAY criticalAY removed the Needs Author Reply Waiting for a reply from the original author label Oct 29, 2026

@david-allison david-allison 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.

LGTM, thanks!

@david-allison david-allison added Needs Second Approval Has one approval, one more approval to merge and removed Needs Review labels Oct 29, 2026
@BrayanDSO
BrayanDSO added this pull request to the merge queue Oct 29, 2026
@BrayanDSO BrayanDSO added Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) and removed Needs Second Approval Has one approval, one more approval to merge labels Oct 29, 2026
Merged via the queue into ankidroid:main with commit 6acd257 Oct 30, 2026
26 checks passed
@github-actions github-actions Bot added this to the 2.26 release milestone Oct 30, 2026
@github-actions github-actions Bot removed the Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) label Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SecurityException: com.android.externalstorage has no access to content://media/external_primary/file/id

3 participants