[Android] medialibrary: Handle DeviceRemovedException
Hugo Beauzée-Luyssen
git at videolan.org
Tue Sep 10 15:30:26 CEST 2019
vlc-android | branch: 3.2.x | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Thu Aug 29 14:52:14 2019 +0200| [dd91226044a3d3c29110a92306f9cf0edcd37985] | committer: Geoffrey Métais
medialibrary: Handle DeviceRemovedException
(cherry picked from commit 5bea4295768ece71887dd820bfbcc536ba4e5d21)
> https://code.videolan.org/videolan/vlc-android/commit/dd91226044a3d3c29110a92306f9cf0edcd37985
---
medialibrary/jni/medialibrary.cpp | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/medialibrary/jni/medialibrary.cpp b/medialibrary/jni/medialibrary.cpp
index 943b4b5bf..cd9fc5b7e 100644
--- a/medialibrary/jni/medialibrary.cpp
+++ b/medialibrary/jni/medialibrary.cpp
@@ -5,6 +5,7 @@
#include <jni.h>
#include <medialibrary/IDeviceLister.h>
+#include <medialibrary/filesystem/IDevice.h>
#define LOG_TAG "VLC/JNI/MediaLibrary"
#include "log.h"
#include "utils.h"
@@ -1714,9 +1715,16 @@ folders(JNIEnv* env, jobject thiz, jint type, jint sortingCriteria, jboolean des
jobjectArray foldersRefs = (jobjectArray) env->NewObjectArray(foldersList.size(), ml_fields.Folder.clazz, NULL);
int index = -1;
for(medialibrary::FolderPtr const& folder : foldersList) {
- jobject item = convertFolderObject(env, &ml_fields, folder);
- env->SetObjectArrayElement(foldersRefs, ++index, item);
- env->DeleteLocalRef(item);
+ try
+ {
+ jobject item = convertFolderObject(env, &ml_fields, folder);
+ env->SetObjectArrayElement(foldersRefs, ++index, item);
+ env->DeleteLocalRef(item);
+ }
+ catch( const medialibrary::fs::DeviceRemovedException& )
+ {
+ // Ignore this folder since it's on a removed device.
+ }
}
return foldersRefs;
}
More information about the Android
mailing list