mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 13:20:27 -06:00
Android: Catch SecurityException in ContentHandler
This commit is contained in:
@ -21,6 +21,11 @@ public class ContentHandler
|
|||||||
{
|
{
|
||||||
return getContentResolver().openFileDescriptor(Uri.parse(uri), mode).detachFd();
|
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,
|
// Some content providers throw IllegalArgumentException for invalid modes,
|
||||||
// despite the documentation saying that invalid modes result in a FileNotFoundException
|
// despite the documentation saying that invalid modes result in a FileNotFoundException
|
||||||
catch (FileNotFoundException | IllegalArgumentException | NullPointerException e)
|
catch (FileNotFoundException | IllegalArgumentException | NullPointerException e)
|
||||||
@ -35,6 +40,11 @@ public class ContentHandler
|
|||||||
{
|
{
|
||||||
return DocumentsContract.deleteDocument(getContentResolver(), Uri.parse(uri));
|
return DocumentsContract.deleteDocument(getContentResolver(), Uri.parse(uri));
|
||||||
}
|
}
|
||||||
|
catch (SecurityException e)
|
||||||
|
{
|
||||||
|
Log.error("Tried to delete " + uri + " without permission");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
catch (FileNotFoundException e)
|
catch (FileNotFoundException e)
|
||||||
{
|
{
|
||||||
// Return true because we care about the file not being there, not the actual delete.
|
// 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);
|
return cursor.getString(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (SecurityException e)
|
||||||
|
{
|
||||||
|
Log.error("Tried to get display name of " + uri + " without permission");
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user