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 { Request.TYPE_MANAGE_ALL_FILES_ACCESS_PERMISSION -> try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
val settingIntent = Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION) kotlin.runCatching {
settingIntent.data = Uri.parse("package:$packageName") val settingIntent = Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION)
settingActivityResult.launch(settingIntent) settingIntent.data = Uri.parse("package:$packageName")
settingActivityResult.launch(settingIntent)
}.onFailure {
val settingIntent = Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION)
settingActivityResult.launch(settingIntent)
}
} else { } else {
throw NoStackTraceException("no MANAGE_ALL_FILES_ACCESS_PERMISSION") throw NoStackTraceException("no MANAGE_ALL_FILES_ACCESS_PERMISSION")
} }

@ -1,5 +1,7 @@
package io.legado.app.lib.permission package io.legado.app.lib.permission
import android.os.Build
@Suppress("unused") @Suppress("unused")
object Permissions { object Permissions {
@ -40,8 +42,11 @@ object Permissions {
const val ACCESS_MEDIA_LOCATION = "android.permission.ACCESS_MEDIA_LOCATION" const val ACCESS_MEDIA_LOCATION = "android.permission.ACCESS_MEDIA_LOCATION"
object Group { object Group {
val STORAGE = val STORAGE = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
arrayOf(READ_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE, MANAGE_EXTERNAL_STORAGE) arrayOf(READ_EXTERNAL_STORAGE, MANAGE_EXTERNAL_STORAGE)
} else {
arrayOf(READ_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE)
}
val CAMERA = arrayOf(Permissions.CAMERA) val CAMERA = arrayOf(Permissions.CAMERA)

Loading…
Cancel
Save