pull/2718/head
kunfei 2 years ago
parent 50849f6a07
commit f64d95d3a2
  1. 11
      app/src/main/java/io/legado/app/lib/permission/PermissionActivity.kt
  2. 9
      app/src/main/java/io/legado/app/lib/permission/Permissions.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")
}

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

Loading…
Cancel
Save