Repository navigation
Fix USB OTG storage discovery and library refresh - #2005
Open
anilbeesetti wants to merge 2 commits into
Open
anilbeesetti wants to merge 2 commits into
anilbeesetti wants to merge 2 commits into
Conversation
anilbeesetti
marked this pull request as ready for review
October 11, 2026 03:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Mounted USB OTG drives can be absent from
getExternalFilesDirs(), so library refresh never scans them. The library also relies only on video-table notifications, which can leave it stale after a drive is connected or removed.Use public
StorageManagervolume roots on Android 11+, including mounted read-only storage, and retain the legacy fallback with null-safe directory handling. Scan connected removable volumes when the library opens and newly mounted volumes on connection. Refresh videos and folders after storage removal and scan completion, while preserving observation after scan failures.Fixes #2002.
Reproduced in Robolectric on API 30 and API 35 with a mounted USB volume omitted from app-specific directories and an unindexed video. Before the fix, USB discovery assertions fail and library observers time out after mount events without video-table notifications. The new tests also cover read-only/unmounted volumes, null directory entries, startup scanning, scan failure recovery, and legacy roots on API 24/29.
Validation:
./gradlew :core:common:testDebugUnitTest :core:media:testDebugUnitTest: 87 tests passed, including 14 new test executions across the covered API levels. Local test execution enforced failure reporting despite the repository'signoreFailuressetting../gradlew ktlintCheck: passed across the repository../gradlew assembleDebug test ktlintCheck --continue: blocked while resolving the app runtime dependencies by HTTP 503 from Google Maven forandroidx.compose.material:material-ripple-android:1.12.1; retry and an alternate official URL failed too.Keeping this PR in draft until the full build/test and device validation can complete.