[Android] Fix external devices detection

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


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

Fix external devices detection

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

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

diff --git a/vlc-android/src/org/videolan/vlc/MediaParsingService.kt b/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
index 6feb1b182..da3d382e9 100644
--- a/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
+++ b/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
@@ -46,6 +46,7 @@ import kotlinx.coroutines.channels.actor
 import org.videolan.libvlc.util.AndroidUtil
 import org.videolan.medialibrary.Medialibrary
 import org.videolan.medialibrary.interfaces.DevicesDiscoveryCb
+import org.videolan.vlc.extensions.ExtensionManagerService
 import org.videolan.vlc.gui.helpers.NotificationHelper
 import org.videolan.vlc.repository.DirectoryRepository
 import org.videolan.vlc.util.*
@@ -130,7 +131,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 +249,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.externalStorageDirectories
-            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