[Android] Do not trigger onDevicePlugged if ML isn't started
Geoffrey Métais
git at videolan.org
Fri Nov 17 18:25:25 CET 2017
vlc-android | branch: 2.5.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Nov 17 18:20:47 2017 +0100| [26da666cd13922eb98101c22219d7e507b371caf] | committer: Geoffrey Métais
Do not trigger onDevicePlugged if ML isn't started
(cherry picked from commit 8649ca16f991d8e3447b7023873bf6aed37cb91e)
> https://code.videolan.org/videolan/vlc-android/commit/26da666cd13922eb98101c22219d7e507b371caf
---
medialibrary/jni/AndroidMediaLibrary.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/medialibrary/jni/AndroidMediaLibrary.cpp b/medialibrary/jni/AndroidMediaLibrary.cpp
index 22d8c0185..2492481ef 100644
--- a/medialibrary/jni/AndroidMediaLibrary.cpp
+++ b/medialibrary/jni/AndroidMediaLibrary.cpp
@@ -12,6 +12,7 @@
static pthread_key_t jni_env_key;
static JavaVM *myVm;
+static bool m_started = false;
static void jni_detach_thread(void *data)
{
@@ -66,13 +67,14 @@ void
AndroidMediaLibrary::start()
{
p_ml->start();
+ m_started = true;
}
bool
AndroidMediaLibrary::addDevice(const std::string& uuid, const std::string& path, bool removable)
{
p_lister->addDevice(uuid, path, removable);
- return p_DeviceListerCb != nullptr && p_DeviceListerCb->onDevicePlugged(uuid, path);
+ return p_DeviceListerCb != nullptr && (m_started ? p_DeviceListerCb->onDevicePlugged(uuid, path) : !p_DeviceListerCb->isDeviceKnown(uuid));
}
std::vector<std::tuple<std::string, std::string, bool>>
More information about the Android
mailing list