[Android] Medialibrary: filter device add on startup
Geoffrey Métais
git at videolan.org
Fri Mar 15 15:10:13 CET 2019
vlc-android | branch: 3.1.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Mar 15 11:42:04 2019 +0100| [cba7229774300b7f8a9bbe6de467a270c9c910ca] | committer: Geoffrey Métais
Medialibrary: filter device add on startup
Specific devices require to detect new storages at device boot
(cherry picked from commit 71b91078ef5ce78fe9f1bd92cb310cf0aa8667f4)
> https://code.videolan.org/videolan/vlc-android/commit/cba7229774300b7f8a9bbe6de467a270c9c910ca
---
vlc-android/src/org/videolan/vlc/MediaParsingService.kt | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/vlc-android/src/org/videolan/vlc/MediaParsingService.kt b/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
index 0b86f4a73..908e62233 100644
--- a/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
+++ b/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
@@ -204,11 +204,12 @@ class MediaParsingService : Service(), DevicesDiscoveryCb, CoroutineScope {
private suspend fun addDevices(context: Context, addExternal: Boolean) {
val devices = mutableListOf<String>()
devices.addAll(DirectoryRepository.getInstance(context).getMediaDirectories())
+ val knownDevices = if (AndroidDevices.watchDevices) medialibrary.devices else null
for (device in devices) {
val isMainStorage = TextUtils.equals(device, AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY)
val uuid = FileUtils.getFileNameFromPath(device)
if (TextUtils.isEmpty(device) || TextUtils.isEmpty(uuid) || !device.scanAllowed()) continue
- val isNew = (isMainStorage || addExternal)
+ val isNew = (isMainStorage || (addExternal && knownDevices?.contains(device) != false))
&& medialibrary.addDevice(if (isMainStorage) "main-storage" else uuid, device, !isMainStorage)
if (!isMainStorage && isNew && preselectedStorages.isEmpty()) showStorageNotification(device)
}
More information about the Android
mailing list