Skip to content

Fix USB OTG storage discovery and library refresh - #2005

Open
anilbeesetti wants to merge 2 commits into
mainfrom
fix/2002-usb-otg-discovery
Open

anilbeesetti wants to merge 2 commits into
mainfrom
fix/2002-usb-otg-discovery

Conversation

@anilbeesetti

Copy link
Copy Markdown
Owner

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 StorageManager volume 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's ignoreFailures setting.
  • ./gradlew ktlintCheck: passed across the repository.
  • ./gradlew assembleDebug test ktlintCheck --continue: blocked while resolving the app runtime dependencies by HTTP 503 from Google Maven for androidx.compose.material:material-ripple-android:1.12.1; retry and an alternate official URL failed too.
  • Disposable Pixel 2 emulator, Android 15/API 35: launched with software emulation because KVM is unavailable. ADB became available, but activity/storage services had not started before the workspace connection dropped. The full app flow and physical USB OTG behavior on the reported Xiaomi device remain unverified.

Keeping this PR in draft until the full build/test and device validation can complete.

@anilbeesetti
anilbeesetti marked this pull request as ready for review October 11, 2026 03:14
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.

[BUG] Next player 0.19.0 does not read the USB drive via OTG

1 participant