From d5ed2f9a40007b225e3d8e2da36806c222f2dfe1 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();