[Android] MlInit: force add internal device in case of fail

Duncan McNamara git at videolan.org
Fri Jun 17 09:19:11 UTC 2022


vlc-android | branch: master | Duncan McNamara <dcn.mcnamara at gmail.com> | Tue May 31 15:49:27 2022 +0200| [50d0713481e978a8423a35b677bbefbd11c0b073] | committer: Nicolas Pomepuy

MlInit: force add internal device in case of fail

If for some reason, the medialibrary fails it's init / to add the
internal storage device, it's not possible to manually add the internal
storage to the medialibrary paths. By forcing the addition of the
internal device, it becomes possible.

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

 .../src/org/videolan/vlc/MediaParsingService.kt    | 24 ++++++++++++++--------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/MediaParsingService.kt b/application/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
index 6306fe68d..d9ea77036 100644
--- a/application/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
+++ b/application/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
@@ -227,17 +227,23 @@ class MediaParsingService : LifecycleService(), DevicesDiscoveryCb {
                 return
             }
         }
-        for (storagePath in AndroidDevices.externalStorageDirectories) {
-            if (path.startsWith(storagePath)) {
-                val uuid = FileUtils.getFileNameFromPath(path)
-                if (uuid.isEmpty()) {
-                    exitCommand()
-                    return
+        if (AndroidDevices.externalStorageDirectories.isNotEmpty()) {
+            for (storagePath in AndroidDevices.externalStorageDirectories) {
+                if (path.startsWith(storagePath)) {
+                    val uuid = FileUtils.getFileNameFromPath(path)
+                    if (uuid.isEmpty()) {
+                        exitCommand()
+                        return
+                    }
+                    medialibrary.addDevice(uuid, path, true)
+                    for (folder in Medialibrary.getBanList()) {
+                        medialibrary.banFolder(path + folder)
+                    }
                 }
-                medialibrary.addDevice(uuid, path, true)
-                for (folder in Medialibrary.getBanList())
-                    medialibrary.banFolder(path + folder)
             }
+        } else {
+            val uuid = FileUtils.getFileNameFromPath(path)
+            medialibrary.addDevice(uuid, path, false)
         }
     }
 



More information about the Android mailing list