[Android] Ml: fix discovery-failure after onboarding skip

Duncan McNamara git at videolan.org
Wed Sep 28 05:59:05 UTC 2022


vlc-android | branch: 3.5.x | Duncan McNamara <dcn.mcnamara at gmail.com> | Tue Sep 20 18:14:25 2022 +0200| [d24955bd36936d351ceab89ff5b33382eeb0edfa] | committer: Nicolas Pomepuy

Ml: fix discovery-failure after onboarding skip

If storage access isn't granted, the medialibrary init will not add the
internal storage as a medialibrary device. After this, it is only
possible to add external devices. So later discovery of internal storage
will fail, not being registered in the medialibrary database.
To fix this, in the late device addition, a check for internal storage
is added.

Fixes #2689

(cherry picked from commit 2338bd92a00c8e9ce00109cca5f3bb56f37b4e38)

> https://code.videolan.org/videolan/vlc-android/commit/d24955bd36936d351ceab89ff5b33382eeb0edfa
---

 .../vlc-android/src/org/videolan/vlc/MediaParsingService.kt    | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/MediaParsingService.kt b/application/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
index 6d6a6d892..5cb306315 100644
--- a/application/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
+++ b/application/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
@@ -226,9 +226,12 @@ class MediaParsingService : LifecycleService(), DevicesDiscoveryCb {
                 return
             }
         }
-        if (AndroidDevices.externalStorageDirectories.isNotEmpty()) {
+        val isMainStorage = path.removeFileScheme().startsWith(AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY)
+        if (isMainStorage) {
+            medialibrary.addDevice("main-storage", path, false)
+        } else if (AndroidDevices.externalStorageDirectories.isNotEmpty()) {
             for (storagePath in AndroidDevices.externalStorageDirectories) {
-                if (path.startsWith(storagePath)) {
+                if (path.removeFileScheme().startsWith(storagePath)) {
                     val uuid = FileUtils.getFileNameFromPath(path)
                     if (uuid.isEmpty()) {
                         exitCommand()
@@ -240,9 +243,6 @@ class MediaParsingService : LifecycleService(), DevicesDiscoveryCb {
                     }
                 }
             }
-        } else {
-            val uuid = FileUtils.getFileNameFromPath(path)
-            medialibrary.addDevice(uuid, path, false)
         }
     }
 



More information about the Android mailing list