From c7dea9dded8ad6e97658430aa0b64baf7fdbaf79 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 3 Mar 2019 08:32:54 +0100 Subject: [PATCH] fixed security exception when attempting to display image in notification --- .../conversations/persistance/FileBackend.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java index 2adec05ae..746854a28 100644 --- a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java @@ -413,11 +413,16 @@ public class FileBackend { public static Uri getMediaUri(Context context, File file) { final String filePath = file.getAbsolutePath(); - final Cursor cursor = context.getContentResolver().query( - MediaStore.Images.Media.EXTERNAL_CONTENT_URI, - new String[] { MediaStore.Images.Media._ID }, - MediaStore.Images.Media.DATA + "=? ", - new String[] { filePath }, null); + final Cursor cursor; + try { + cursor = context.getContentResolver().query( + MediaStore.Images.Media.EXTERNAL_CONTENT_URI, + new String[]{MediaStore.Images.Media._ID}, + MediaStore.Images.Media.DATA + "=? ", + new String[]{filePath}, null); + } catch (SecurityException e) { + return null; + } if (cursor != null && cursor.moveToFirst()) { final int id = cursor.getInt(cursor.getColumnIndex(MediaStore.MediaColumns._ID)); cursor.close();