Skip to content

fix(storage): resolve MediaStore URIs before scoped requests#339

Open
sjug wants to merge 2 commits intoFossifyOrg:mainfrom
sjug:fix/scoped-storage-mediastore-uris
Open

fix(storage): resolve MediaStore URIs before scoped requests#339
sjug wants to merge 2 commits intoFossifyOrg:mainfrom
sjug:fix/scoped-storage-mediastore-uris

Conversation

@sjug
Copy link
Copy Markdown

@sjug sjug commented Apr 29, 2026

Type of change(s)

  • Bug fix
  • Feature / enhancement
  • Infrastructure / tooling (CI, build, deps, tests)
  • Documentation

What changed and why

  • Added async MediaStore URI resolution for scoped-storage file operations.
  • Uses public MediaScannerConnection.scanFile(...) and verifies resolved MediaStore IDs before passing URIs to Android R+ write/delete/trash requests.
  • Prevents invalid request URIs like content://media/external/images/media/0.
  • Hardens SDK 30 request helpers so empty URI lists and exceptions invoke callback(false).
  • Deprecates older unsafe helpers and makes FileDirItem.assembleContentUri() nullable instead of fabricating invalid IDs.
  • Fails rename batches when any item cannot be resolved instead of silently skipping unresolved files.

This is a breaking API/behavior change and is intended for the next major commons release, e.g. 7.0.0.

Required by the Gallery scoped-storage overwrite-save fix for FossifyOrg/Gallery#1031.

Tests performed

  • ./gradlew :commons:compileDebugKotlin
  • ./gradlew :commons:publishToMavenLocal
  • Verified with Fossify Gallery debug build using the locally published commons artifact.
  • Runtime-tested Gallery crop overwrite-save flow on Android 16 / Pixel device; no invalid /media/0 URI crash.

Before & after preview

N/A — no UI changes.

Closes the following issue(s)

N/A — prerequisite library fix for FossifyOrg/Gallery#1031.

Checklist

  • I read the contribution guidelines.
  • I manually tested my changes on device/emulator (if applicable).
  • I updated the "Unreleased" section in CHANGELOG.md (if applicable; no CHANGELOG.md exists in this repo).
  • I have self-reviewed my pull request (no typos, formatting errors, etc.).
  • I understand every change in this pull request.

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.

1 participant