Skip to content

fix(android): insert MediaStore rows as pending on Android 10 (Samsung) - #155

Merged
iBotPeaches merged 1 commit into
masterfrom
fix/android10-samsung-pending
Oct 28, 2026
Merged

iBotPeaches merged 1 commit into
masterfrom
fix/android10-samsung-pending

Conversation

@ian-wd

@ian-wd ian-wd commented Oct 28, 2026

Copy link
Copy Markdown

Problem

MediaStore.copyToMediaStore fails every time on Samsung devices running Android 10 (API 29), including 4.0.1 with #146.

The library inserts a normal row, then flips it to pending with a separate IS_PENDING=1 update. On Samsung's Android 10 MediaProvider that update makes the row inaccessible to its own app:

Unexpected error during copyToMediaStore: Failed to write file: java.io.FileNotFoundException: No item at content://media/external_primary/images/media/23?includePending=1
E DatabaseUtils: java.lang.SecurityException: net.xxx.xxx has no access to content://media/external_primary/images/media/23?includePending=1
E RNFS2   : Failed to cleanup MediaStore entry: ...

#146's setIncludePending doesn't restore access: write, query, update, commit and delete all fail with both the plain and the includePending URI. Stock AOSP Android 10 and Android 11+ work with the old flow, which is why it doesn't reproduce on an emulator.

Solution

On Android 10 only, insert the row with IS_PENDING=1 already in the insert ContentValues, then write, commit (IS_PENDING=0) and clean up through the plain URI. The separate pending update is skipped. #146's setIncludePending wrapping is removed.

Android 11+ keeps the existing sequence, createMediaFile still inserts a non-pending row, and the JS API is unchanged.

Verified (Firebase Test Lab)

Device 4.0.0 / 4.0.1 This PR
Galaxy A10 (SM-A105FN), Android 10 3/3 saves fail 3/3 saves OK, stored file byte-identical
Galaxy S9 (SM-G960F), Android 10 3/3 saves fail —
AOSP Android 10 emulator OK OK
Android 11 / 14 (virtual) — OK

@ian-wd
ian-wd marked this pull request as ready for review October 28, 2026 07:18
@iBotPeaches
iBotPeaches merged commit d96b586 into master Oct 28, 2026
2 checks passed
@iBotPeaches
iBotPeaches deleted the fix/android10-samsung-pending branch October 28, 2026 09:56
@iBotPeaches iBotPeaches mentioned this pull request Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants