files: survive MediaStore denial in category and recents queries
- Commit
a2083de43535a2bed227f34dfd176d4b5d04fdf4- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-19 02:44 UTC (17 days ago)
- Parents
e41ba64
queryMediaItems swallowed only IllegalArgumentException. On a device where media access is revoked (no all-files access and no media permission), ContentResolver.query against MediaStore throws SecurityException instead. loadHome and openCategory call this from viewModelScope with no handler, so the denial crashed the app on launch or on opening a category. Catch SecurityException and return the empty listing, the same degradation the IllegalArgumentException path already chose. Verified: ./gradlew :files:testDevUnitTest (pass), ./check files (pass).
Diff
files/src/main/java/com/vayunmathur/files/platform/FilesListing.kt
diff --git a/files/src/main/java/com/vayunmathur/files/platform/FilesListing.kt b/files/src/main/java/com/vayunmathur/files/platform/FilesListing.ktindex 4e49d434e9..d8685babc0 100644--- a/files/src/main/java/com/vayunmathur/files/platform/FilesListing.kt+++ b/files/src/main/java/com/vayunmathur/files/platform/FilesListing.kt@@ -92,6 +92,9 @@ internal fun queryMediaItems( } } } catch (_: IllegalArgumentException) {+ } catch (_: SecurityException) {+ // MediaStore denies the query outright when media permission is+ // revoked; an empty category beats crashing the home screen. } return out }