From 9ac978190e25a5ec44d4f66a4883d3ef707e46f0 Mon Sep 17 00:00:00 2001 From: Fredia Huya-Kouadio Date: Mon, 20 Mar 2023 08:56:04 -0700 Subject: Fix directory access when the running app has the `All files access` permission (cherry picked from commit f02e4e4091ccabe05e3eb114b888c2ede86ab189) --- .../java/lib/src/org/godotengine/godot/io/StorageScope.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'platform') diff --git a/platform/android/java/lib/src/org/godotengine/godot/io/StorageScope.kt b/platform/android/java/lib/src/org/godotengine/godot/io/StorageScope.kt index 833ab40af0..8ee3d5f48f 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/io/StorageScope.kt +++ b/platform/android/java/lib/src/org/godotengine/godot/io/StorageScope.kt @@ -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 } -- cgit v1.2.3