Skip to content

Commit

Permalink
android: handle Securityexception
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodrigodd committed Sep 13, 2023
1 parent 5c2855e commit 27fdb3c
Showing 1 changed file with 7 additions and 1 deletion.
Expand Up @@ -122,7 +122,13 @@ public String[] listChild(String uriString) {
ContentResolver resolver = getContentResolver();

int takeFlags = Intent.FLAG_GRANT_READ_URI_PERMISSION;
resolver.takePersistableUriPermission(treeUri, takeFlags);

try {
resolver.takePersistableUriPermission(treeUri, takeFlags);
} catch (SecurityException exp) {
Log.e(TAG, "failed to take permission: " + exp.toString());
return null;
}

Uri childrenUri = DocumentsContract.buildChildDocumentsUriUsingTree(
treeUri, DocumentsContract.getTreeDocumentId(treeUri));
Expand Down

0 comments on commit 27fdb3c

Please sign in to comment.