diff --git a/app/src/main/java/io/legado/app/lib/permission/PermissionActivity.kt b/app/src/main/java/io/legado/app/lib/permission/PermissionActivity.kt index 6dc7757b0..e1c615320 100644 --- a/app/src/main/java/io/legado/app/lib/permission/PermissionActivity.kt +++ b/app/src/main/java/io/legado/app/lib/permission/PermissionActivity.kt @@ -47,9 +47,14 @@ class PermissionActivity : AppCompatActivity() { //所有文件所有文件的管理权限 Request.TYPE_MANAGE_ALL_FILES_ACCESS_PERMISSION -> try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - val settingIntent = Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION) - settingIntent.data = Uri.parse("package:$packageName") - settingActivityResult.launch(settingIntent) + kotlin.runCatching { + val settingIntent = Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION) + settingIntent.data = Uri.parse("package:$packageName") + settingActivityResult.launch(settingIntent) + }.onFailure { + val settingIntent = Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION) + settingActivityResult.launch(settingIntent) + } } else { throw NoStackTraceException("no MANAGE_ALL_FILES_ACCESS_PERMISSION") } diff --git a/app/src/main/java/io/legado/app/lib/permission/Permissions.kt b/app/src/main/java/io/legado/app/lib/permission/Permissions.kt index b4d22b914..301cafc6f 100644 --- a/app/src/main/java/io/legado/app/lib/permission/Permissions.kt +++ b/app/src/main/java/io/legado/app/lib/permission/Permissions.kt @@ -1,5 +1,7 @@ package io.legado.app.lib.permission +import android.os.Build + @Suppress("unused") object Permissions { @@ -40,8 +42,11 @@ object Permissions { const val ACCESS_MEDIA_LOCATION = "android.permission.ACCESS_MEDIA_LOCATION" object Group { - val STORAGE = - arrayOf(READ_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE, MANAGE_EXTERNAL_STORAGE) + val STORAGE = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + arrayOf(READ_EXTERNAL_STORAGE, MANAGE_EXTERNAL_STORAGE) + } else { + arrayOf(READ_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE) + } val CAMERA = arrayOf(Permissions.CAMERA)