[Android] Filter external storage from storages lists

Geoffrey Métais git at videolan.org
Thu Dec 7 14:07:12 CET 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Dec  7 11:57:56 2017 +0100| [a057ca4340bdcf6ee88f8c246655874eb81f3988] | committer: Geoffrey Métais

Filter external storage from storages lists

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

 vlc-android/src/org/videolan/vlc/ExternalMonitor.java     | 1 +
 vlc-android/src/org/videolan/vlc/MediaParsingService.java | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/ExternalMonitor.java b/vlc-android/src/org/videolan/vlc/ExternalMonitor.java
index 6d965da41..04f65a3b9 100644
--- a/vlc-android/src/org/videolan/vlc/ExternalMonitor.java
+++ b/vlc-android/src/org/videolan/vlc/ExternalMonitor.java
@@ -90,6 +90,7 @@ public class ExternalMonitor extends BroadcastReceiver {
             public void run() {
                 final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(ctx);
                 final List<String> devices = AndroidDevices.getExternalStorageDirectories();
+                devices.remove(AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY);
                 final String[] knownDevices = ml.getDevices();
                 final List<String> missingDevices = Util.arrayToArrayList(knownDevices);
                 missingDevices.remove("file://"+AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY);
diff --git a/vlc-android/src/org/videolan/vlc/MediaParsingService.java b/vlc-android/src/org/videolan/vlc/MediaParsingService.java
index 9f18d12c5..b9bbdb1df 100644
--- a/vlc-android/src/org/videolan/vlc/MediaParsingService.java
+++ b/vlc-android/src/org/videolan/vlc/MediaParsingService.java
@@ -226,8 +226,9 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
                     shouldInit |= initCode == Medialibrary.ML_INIT_DB_RESET;
                     if (initCode != Medialibrary.ML_INIT_FAILED) {
                         final List<String> devices = new ArrayList<>();
-                        devices.add(AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY);
                         devices.addAll(AndroidDevices.getExternalStorageDirectories());
+                        if (!devices.contains(AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY))
+                            devices.add(AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY);
                         final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
                         for (final String device : devices) {
                             final boolean isMainStorage = TextUtils.equals(device, AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY);



More information about the Android mailing list