Skip to content

Commit

Permalink
Merge pull request #75146 from m4gr3d/fix_directory_access_with_all_f…
Browse files Browse the repository at this point in the history
…iles_access_permission_main

Fix directory access when the running app has the `All files access` permission
  • Loading branch information
YuriSizov authored Mar 21, 2023
2 parents 2a05522 + f02e4e4 commit 0067578
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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
}
Expand Down

0 comments on commit 0067578

Please sign in to comment.