From 3690e86312a2e2a3669f5d683685dcd0b070761d Mon Sep 17 00:00:00 2001 From: Conny Duck Date: Sun, 25 Feb 2018 15:46:32 +0100 Subject: [PATCH] fix a crash in MediaUtils --- .../main/java/com/keylesspalace/tusky/util/MediaUtils.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/util/MediaUtils.java b/app/src/main/java/com/keylesspalace/tusky/util/MediaUtils.java index 40cd566a..bcce0da7 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/MediaUtils.java +++ b/app/src/main/java/com/keylesspalace/tusky/util/MediaUtils.java @@ -70,7 +70,12 @@ public class MediaUtils { public static long getMediaSize(@NonNull ContentResolver contentResolver, @Nullable Uri uri) { if(uri == null) return MEDIA_SIZE_UNKNOWN; long mediaSize; - Cursor cursor = contentResolver.query(uri, null, null, null, null); + Cursor cursor; + try { + cursor = contentResolver.query(uri, null, null, null, null); + } catch (SecurityException e) { + return MEDIA_SIZE_UNKNOWN; + } if (cursor != null) { int sizeIndex = cursor.getColumnIndex(OpenableColumns.SIZE); cursor.moveToFirst();