From 4b002c7b242a11ef2f76230d3f535eb52bbd33fe Mon Sep 17 00:00:00 2001 From: Hardcore Sushi Date: Fri, 7 Jun 2024 16:07:20 +0200 Subject: [PATCH] Fix SecurityException when importing from exposed volume --- .../sushi/hardcore/droidfs/explorers/ExplorerActivity.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/sushi/hardcore/droidfs/explorers/ExplorerActivity.kt b/app/src/main/java/sushi/hardcore/droidfs/explorers/ExplorerActivity.kt index abdca09..a552c52 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/explorers/ExplorerActivity.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/explorers/ExplorerActivity.kt @@ -68,7 +68,11 @@ class ExplorerActivity : BaseExplorerActivity() { private val pickFiles = registerForActivityResult(ActivityResultContracts.OpenMultipleDocuments()) { uris -> if (uris != null) { for (uri in uris) { - contentResolver.takePersistableUriPermission(uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION) + try { + contentResolver.takePersistableUriPermission(uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION) + } catch (e: SecurityException) { + e.printStackTrace() + } } importFilesFromUris(uris) { onImportComplete(uris)