From 6df543fbc94b1b97c6544a212a8689687713057a Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sun, 8 Nov 2020 12:37:32 +0100 Subject: [PATCH] Android: Catch SecurityException in ContentHandler --- .../dolphinemu/utils/ContentHandler.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/ContentHandler.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/ContentHandler.java index 7cf7c24253..c2fa96999f 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/ContentHandler.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/ContentHandler.java @@ -21,6 +21,11 @@ public class ContentHandler { return getContentResolver().openFileDescriptor(Uri.parse(uri), mode).detachFd(); } + catch (SecurityException e) + { + Log.error("Tried to open " + uri + " without permission"); + return -1; + } // Some content providers throw IllegalArgumentException for invalid modes, // despite the documentation saying that invalid modes result in a FileNotFoundException catch (FileNotFoundException | IllegalArgumentException | NullPointerException e) @@ -35,6 +40,11 @@ public class ContentHandler { return DocumentsContract.deleteDocument(getContentResolver(), Uri.parse(uri)); } + catch (SecurityException e) + { + Log.error("Tried to delete " + uri + " without permission"); + return false; + } catch (FileNotFoundException e) { // Return true because we care about the file not being there, not the actual delete. @@ -53,6 +63,10 @@ public class ContentHandler return cursor.getString(0); } } + catch (SecurityException e) + { + Log.error("Tried to get display name of " + uri + " without permission"); + } return null; }