Merge pull request #75146 from m4gr3d/fix_directory_access_with_all_files_access_permission_main

Fix directory access when the running app has the `All files access` permission
This commit is contained in:
Yuri Sizov 2023-03-21 14:43:14 +01:00 committed by GitHub
commit 0067578b5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -76,6 +76,13 @@ internal enum class StorageScope {
return UNKNOWN
}
// If we have 'All Files Access' permission, we can access all directories without
// restriction.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R
&& Environment.isExternalStorageManager()) {
return APP
}
val canonicalPathFile = pathFile.canonicalPath
if (internalAppDir != null && canonicalPathFile.startsWith(internalAppDir)) {
@ -90,7 +97,7 @@ internal enum class StorageScope {
return APP
}
var rootDir: String? = System.getenv("ANDROID_ROOT")
val rootDir: String? = System.getenv("ANDROID_ROOT")
if (rootDir != null && canonicalPathFile.startsWith(rootDir)) {
return APP
}