[Android] Fix external devices detection

Geoffrey Métais git at videolan.org
Thu May 23 13:33:03 CEST 2019


vlc-android | branch: 3.1.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu May 23 13:28:43 2019 +0200| [5287e7f992fc36885f18eb15a7b4ab8814dce01a] | committer: Geoffrey Métais

Fix external devices detection

(cherry picked from commit a4163ba89ad299b39628df889a7de9f8e737023b)

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

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

diff --git a/vlc-android/src/org/videolan/vlc/MediaParsingService.kt b/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
index d45600c62..76a2badd7 100644
--- a/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
+++ b/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
@@ -130,7 +130,7 @@ class MediaParsingService : Service(), DevicesDiscoveryCb, CoroutineScope {
             ACTION_FORCE_RELOAD -> actions.offer(ForceReload)
             ACTION_DISCOVER -> discover(intent.getStringExtra(EXTRA_PATH))
             ACTION_DISCOVER_DEVICE -> discoverStorage(intent.getStringExtra(EXTRA_PATH))
-            ACTION_CHECK_STORAGES -> if (scanActivated) actions.offer(UpdateStorages) else exitCommand()
+            ACTION_CHECK_STORAGES -> if (settings.getInt(KEY_MEDIALIBRARY_SCAN, -1) != ML_SCAN_OFF) actions.offer(UpdateStorages) else exitCommand()
             else -> {
                 exitCommand()
                 return Service.START_NOT_STICKY
@@ -248,11 +248,9 @@ class MediaParsingService : Service(), DevicesDiscoveryCb, CoroutineScope {
 
     private suspend fun updateStorages() {
         serviceLock = true
-        val ctx = applicationContext
-        val (sharedPreferences, devices, knownDevices) = withContext(Dispatchers.IO) {
-            val sharedPreferences = Settings.getInstance(ctx)
+        val (devices, knownDevices) = withContext(Dispatchers.IO) {
             val devices = AndroidDevices.getExternalStorageDirectories()
-            Triple(sharedPreferences, devices, medialibrary.devices)
+            Pair(devices, medialibrary.devices)
         }
         val missingDevices = Util.arrayToArrayList(knownDevices)
         missingDevices.remove("file://${AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY}")



More information about the Android mailing list