[Android] Sanity check on Uri retrieval
Geoffrey Métais
git at videolan.org
Thu Mar 7 10:55:16 CET 2019
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Mar 7 09:54:26 2019 +0100| [6733a9f17209a6a8d2eb40522b9a93389c09d776] | committer: Geoffrey Métais
Sanity check on Uri retrieval
> https://code.videolan.org/videolan/vlc-android/commit/6733a9f17209a6a8d2eb40522b9a93389c09d776
---
vlc-android/src/org/videolan/vlc/media/MediaUtils.kt | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/media/MediaUtils.kt b/vlc-android/src/org/videolan/vlc/media/MediaUtils.kt
index e7bed6216..3630911fe 100644
--- a/vlc-android/src/org/videolan/vlc/media/MediaUtils.kt
+++ b/vlc-android/src/org/videolan/vlc/media/MediaUtils.kt
@@ -280,13 +280,16 @@ object MediaUtils : CoroutineScope {
fun getMediaTitle(mediaWrapper: MediaWrapper) = mediaWrapper.title ?: FileUtils.getFileNameFromPath(mediaWrapper.location)!!
- fun getContentMediaUri(data: Uri): Uri {
+ fun getContentMediaUri(data: Uri)= try {
VLCApplication.getAppContext().contentResolver.query(data,
arrayOf(MediaStore.Video.Media.DATA), null, null, null)?.use {
val columnIndex = it.getColumnIndexOrThrow(MediaStore.Video.Media.DATA)
- if (it.moveToFirst()) return AndroidUtil.PathToUri(it.getString(columnIndex)) ?: data
+ if (it.moveToFirst()) AndroidUtil.PathToUri(it.getString(columnIndex)) ?: data else data
}
- return data
+ } catch (e: SecurityException) {
+ data
+ } catch (e: IllegalArgumentException) {
+ data
}
private fun getMediaString(ctx: Context?, id: Int): String {
More information about the Android
mailing list