[Android] Always notify ML when a device is plugged
Geoffrey Métais
git at videolan.org
Mon Nov 13 12:14:31 CET 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Nov 13 12:13:29 2017 +0100| [8c3af7545c5d04f40aa8cdedd2ca10862e939039] | committer: Geoffrey Métais
Always notify ML when a device is plugged
> https://code.videolan.org/videolan/vlc-android/commit/8c3af7545c5d04f40aa8cdedd2ca10862e939039
---
medialibrary/jni/AndroidMediaLibrary.cpp | 5 ++---
medialibrary/jni/AndroidMediaLibrary.h | 2 +-
medialibrary/jni/medialibrary.cpp | 6 +++---
medialibrary/src/org/videolan/medialibrary/Medialibrary.java | 6 +++---
vlc-android/src/org/videolan/vlc/ExternalMonitor.java | 4 ++--
vlc-android/src/org/videolan/vlc/MediaParsingService.java | 4 ++--
6 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/medialibrary/jni/AndroidMediaLibrary.cpp b/medialibrary/jni/AndroidMediaLibrary.cpp
index b66fadbfc..8ab5a4158 100644
--- a/medialibrary/jni/AndroidMediaLibrary.cpp
+++ b/medialibrary/jni/AndroidMediaLibrary.cpp
@@ -69,11 +69,10 @@ AndroidMediaLibrary::start()
}
bool
-AndroidMediaLibrary::addDevice(const std::string& uuid, const std::string& path, bool removable, bool notify)
+AndroidMediaLibrary::addDevice(const std::string& uuid, const std::string& path, bool removable)
{
p_lister->addDevice(uuid, path, removable);
- return p_DeviceListerCb != nullptr && notify ? p_DeviceListerCb->onDevicePlugged(uuid, path)
- : !p_DeviceListerCb->isDeviceKnown(uuid);
+ return p_DeviceListerCb != nullptr && p_DeviceListerCb->onDevicePlugged(uuid, path);
}
std::vector<std::tuple<std::string, std::string, bool>>
diff --git a/medialibrary/jni/AndroidMediaLibrary.h b/medialibrary/jni/AndroidMediaLibrary.h
index ef3d4ec94..96b1e0e54 100644
--- a/medialibrary/jni/AndroidMediaLibrary.h
+++ b/medialibrary/jni/AndroidMediaLibrary.h
@@ -30,7 +30,7 @@ public:
bool initML(const std::string& dbPath, const std::string& thumbsPath);
void start();
- bool addDevice(const std::string& uuid, const std::string& path, bool removable, bool notif);
+ bool addDevice(const std::string& uuid, const std::string& path, bool removable);
std::vector<std::tuple<std::string, std::string, bool>> devices();
bool removeDevice(const std::string& uuid);
void banFolder(const std::string& path);
diff --git a/medialibrary/jni/medialibrary.cpp b/medialibrary/jni/medialibrary.cpp
index 657e643cd..7556b46e3 100644
--- a/medialibrary/jni/medialibrary.cpp
+++ b/medialibrary/jni/medialibrary.cpp
@@ -60,12 +60,12 @@ banFolder(JNIEnv* env, jobject thiz, jstring folderPath)
}
jboolean
-addDevice(JNIEnv* env, jobject thiz, jstring uuid, jstring storagePath, jboolean removable, jboolean notify)
+addDevice(JNIEnv* env, jobject thiz, jstring uuid, jstring storagePath, jboolean removable)
{
AndroidMediaLibrary *aml = MediaLibrary_getInstance(env, thiz);
const char *uuidChar = env->GetStringUTFChars(uuid, JNI_FALSE);
const char *path = env->GetStringUTFChars(storagePath, JNI_FALSE);
- jboolean isNew = aml->addDevice(uuidChar, path, removable, notify);
+ jboolean isNew = aml->addDevice(uuidChar, path, removable);
env->ReleaseStringUTFChars(uuid, uuidChar);
env->ReleaseStringUTFChars(storagePath, path);
return isNew;
@@ -759,7 +759,7 @@ static JNINativeMethod methods[] = {
{"nativeInit", "(Ljava/lang/String;Ljava/lang/String;)Z", (void*)init },
{"nativeStart", "()V", (void*)start },
{"nativeRelease", "()V", (void*)release },
- {"nativeAddDevice", "(Ljava/lang/String;Ljava/lang/String;ZZ)Z", (void*)addDevice },
+ {"nativeAddDevice", "(Ljava/lang/String;Ljava/lang/String;Z)Z", (void*)addDevice },
{"nativeDevices", "()[Ljava/lang/String;", (void*)devices },
{"nativeDiscover", "(Ljava/lang/String;)V", (void*)discover },
{"nativeRemoveEntryPoint", "(Ljava/lang/String;)V", (void*)removeEntryPoint },
diff --git a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
index 76c275352..56d5d7d7e 100644
--- a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
+++ b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
@@ -100,8 +100,8 @@ public class Medialibrary {
return mIsInitiated ? nativeDevices() : new String[0];
}
- public boolean addDevice(@NonNull String uuid, @NonNull String path, boolean removable, boolean notify) {
- return nativeAddDevice(VLCUtil.encodeVLCString(uuid), Tools.encodeVLCMrl(path), removable, notify);
+ public boolean addDevice(@NonNull String uuid, @NonNull String path, boolean removable) {
+ return nativeAddDevice(VLCUtil.encodeVLCString(uuid), Tools.encodeVLCMrl(path), removable);
}
public void discover(@NonNull String path) {
@@ -589,7 +589,7 @@ public class Medialibrary {
private native void nativeStart();
private native void nativeRelease();
private native void nativeBanFolder(String path);
- private native boolean nativeAddDevice(String uuid, String path, boolean removable, boolean notify);
+ private native boolean nativeAddDevice(String uuid, String path, boolean removable);
private native String[] nativeDevices();
private native void nativeDiscover(String path);
private native void nativeRemoveEntryPoint(String path);
diff --git a/vlc-android/src/org/videolan/vlc/ExternalMonitor.java b/vlc-android/src/org/videolan/vlc/ExternalMonitor.java
index 5896e1ca0..0a8542168 100644
--- a/vlc-android/src/org/videolan/vlc/ExternalMonitor.java
+++ b/vlc-android/src/org/videolan/vlc/ExternalMonitor.java
@@ -101,7 +101,7 @@ public class ExternalMonitor extends BroadcastReceiver {
if (TextUtils.isEmpty(device) || TextUtils.isEmpty(uuid)
|| containsDevice(knownDevices, device))
continue;
- final boolean isNew = ml.addDevice(uuid, device, true, true);
+ final boolean isNew = ml.addDevice(uuid, device, true);
final boolean isIgnored = sharedPreferences.getBoolean("ignore_"+ uuid, false);
if (isNew && !isIgnored)
LocalBroadcastManager.getInstance(ctx).sendBroadcast(new Intent(ACTION_NEW_STORAGE).putExtra(EXTRA_PATH, device));
@@ -172,7 +172,7 @@ public class ExternalMonitor extends BroadcastReceiver {
removeMessages(ACTION_MEDIA_UNMOUNTED);
if (!TextUtils.isEmpty(uuid)
&& !PreferenceManager.getDefaultSharedPreferences(appCtx).getBoolean("ignore_" + uuid, false)) {
- if (VLCApplication.getMLInstance().addDevice(uuid, path, true, true)) {
+ if (VLCApplication.getMLInstance().addDevice(uuid, path, true)) {
notifyStorageChanges(path);
} else
appCtx.startService(new Intent(MediaParsingService.ACTION_RELOAD, null, appCtx, MediaParsingService.class)
diff --git a/vlc-android/src/org/videolan/vlc/MediaParsingService.java b/vlc-android/src/org/videolan/vlc/MediaParsingService.java
index a97f07019..aa1ee2797 100644
--- a/vlc-android/src/org/videolan/vlc/MediaParsingService.java
+++ b/vlc-android/src/org/videolan/vlc/MediaParsingService.java
@@ -195,7 +195,7 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
exitCommand();
return;
}
- mMedialibrary.addDevice(uuid, path, true, true);
+ mMedialibrary.addDevice(uuid, path, true);
for (String folder : Medialibrary.getBlackList())
mMedialibrary.banFolder(path + folder);
}
@@ -231,7 +231,7 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
final String uuid = FileUtils.getFileNameFromPath(device);
if (TextUtils.isEmpty(device) || TextUtils.isEmpty(uuid))
continue;
- final boolean isNew = mMedialibrary.addDevice(isMainStorage ? "main-storage" : uuid, device, !isMainStorage, false);
+ final boolean isNew = mMedialibrary.addDevice(isMainStorage ? "main-storage" : uuid, device, !isMainStorage);
final boolean isIgnored = sharedPreferences.getBoolean("ignore_"+ uuid, false);
if (!isMainStorage && isNew && !isIgnored)
showStorageNotification(device);
More information about the Android
mailing list