aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2019-03-06 21:54:12 +0100
committerChristian Schneppe <christian@pix-art.de>2019-03-06 21:54:12 +0100
commit3673ab7784f66b6de2ef0b26539697c1f54527ce (patch)
tree7aaa2c380c3cf91d32eef39b2f385cd16def76d3 /src/main/java
parent0305d355627f880afddae247261c0c29457df6d4 (diff)
fixed security exception when attempting to display image in notification
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/de/pixart/messenger/persistance/FileBackend.java15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/main/java/de/pixart/messenger/persistance/FileBackend.java b/src/main/java/de/pixart/messenger/persistance/FileBackend.java
index 0aac6520a..e255ff225 100644
--- a/src/main/java/de/pixart/messenger/persistance/FileBackend.java
+++ b/src/main/java/de/pixart/messenger/persistance/FileBackend.java
@@ -103,11 +103,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();