Fix SecurityException when importing from exposed volume

This commit is contained in:
Matéo Duparc 2024-06-07 16:07:20 +02:00
parent 7c72c4e829
commit 4b002c7b24
Signed by: hardcoresushi
GPG Key ID: AFE384344A45E13A

View File

@ -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)