Merge pull request #109528 from syntaxerror247/drive-selection-issue

Fix drive selection issue on Android
This commit is contained in:
Thaddeus Crews
2025-08-13 18:42:13 -05:00
3 changed files with 8 additions and 3 deletions

View File

@@ -181,7 +181,7 @@
<return type="int" /> <return type="int" />
<description> <description>
On Windows, returns the number of drives (partitions) mounted on the current filesystem. On Windows, returns the number of drives (partitions) mounted on the current filesystem.
On macOS, returns the number of mounted volumes. On macOS and Android, returns the number of mounted volumes.
On Linux, returns the number of mounted volumes and GTK 3 bookmarks. On Linux, returns the number of mounted volumes and GTK 3 bookmarks.
On other platforms, the method returns 0. On other platforms, the method returns 0.
</description> </description>
@@ -193,6 +193,7 @@
On Windows, returns the name of the drive (partition) passed as an argument (e.g. [code]C:[/code]). On Windows, returns the name of the drive (partition) passed as an argument (e.g. [code]C:[/code]).
On macOS, returns the path to the mounted volume passed as an argument. On macOS, returns the path to the mounted volume passed as an argument.
On Linux, returns the path to the mounted volume or GTK 3 bookmark passed as an argument. On Linux, returns the path to the mounted volume or GTK 3 bookmark passed as an argument.
On Android (API level 30+), returns the path to the mounted volume as an argument.
On other platforms, or if the requested drive does not exist, the method returns an empty String. On other platforms, or if the requested drive does not exist, the method returns an empty String.
</description> </description>
</method> </method>

View File

@@ -159,7 +159,11 @@ internal class FilesystemDirectoryAccess(private val context: Context, private v
} }
val storageVolume = storageManager.storageVolumes[drive] val storageVolume = storageManager.storageVolumes[drive]
return storageVolume.getDescription(context) return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
storageVolume.directory?.absolutePath ?: ""
} else {
""
}
} }
override fun makeDir(dir: String): Boolean { override fun makeDir(dir: String): Boolean {

View File

@@ -1362,7 +1362,7 @@ void FileDialog::set_access(Access p_access) {
case ACCESS_FILESYSTEM: { case ACCESS_FILESYSTEM: {
dir_access = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); dir_access = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
#ifdef ANDROID_ENABLED #ifdef ANDROID_ENABLED
set_root_subfolder(OS::get_singleton()->get_system_dir(OS::SYSTEM_DIR_DESKTOP)); set_current_dir(OS::get_singleton()->get_system_dir(OS::SYSTEM_DIR_DESKTOP));
#endif #endif
} break; } break;
case ACCESS_RESOURCES: { case ACCESS_RESOURCES: {