Skip to content

feat: improve MediaStore URI resolution for file deletions#2123

Merged
theovilardo merged 1 commit into
masterfrom
fix/app-crash-on-delete-daily-mix
May 27, 2026
Merged

feat: improve MediaStore URI resolution for file deletions#2123
theovilardo merged 1 commit into
masterfrom
fix/app-crash-on-delete-daily-mix

Conversation

@theovilardo

Copy link
Copy Markdown
Collaborator

Enhances the reliability of MediaStore.createDeleteRequest on Android 11+ by implementing a robust URI resolution strategy. Instead of relying solely on song IDs, the system now validates candidate URIs against the ContentResolver using IDs, file paths, and existing URI strings to ensure they are valid for system deletion prompts.

  • Added MediaStorePermissionHelper.resolveDeleteRequestUri to verify URI existence via contentResolver.query.
  • Updated PlayerViewModel to perform URI resolution on Dispatchers.IO before triggering deletion intents.
  • Refactored getMediaStoreUri to use MediaStore.Audio.Media.getContentUri with VOLUME_EXTERNAL for Android R+.
  • Added error handling for IllegalArgumentException and SecurityException when creating delete requests.
  • Introduced MediaStorePermissionHelperTest to validate URI string parsing and fallback logic.
  • Cleaned up unused imports and centralized intent sender creation in FileDeletionUtils.

Enhances the reliability of `MediaStore.createDeleteRequest` on Android 11+ by implementing a robust URI resolution strategy. Instead of relying solely on song IDs, the system now validates candidate URIs against the `ContentResolver` using IDs, file paths, and existing URI strings to ensure they are valid for system deletion prompts.

- Added `MediaStorePermissionHelper.resolveDeleteRequestUri` to verify URI existence via `contentResolver.query`.
- Updated `PlayerViewModel` to perform URI resolution on `Dispatchers.IO` before triggering deletion intents.
- Refactored `getMediaStoreUri` to use `MediaStore.Audio.Media.getContentUri` with `VOLUME_EXTERNAL` for Android R+.
- Added error handling for `IllegalArgumentException` and `SecurityException` when creating delete requests.
- Introduced `MediaStorePermissionHelperTest` to validate URI string parsing and fallback logic.
- Cleaned up unused imports and centralized intent sender creation in `FileDeletionUtils`.
@theovilardo theovilardo merged commit 361fa35 into master May 27, 2026
4 checks passed
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