Loading / Saving a file on Android 13 does not work. reasons seems to be unescaped characters in the file path that the fileBrowser returns.
the same code works well on mac and windows.
Reproduction steps
Use the file browser, p.e. via code like this:
using System.IO;
...
//like in the example code
IEnumerator ShowLoadDialogCoroutine()
{
yield return FileBrowser.WaitForLoadDialog(FileBrowser.PickMode.FilesAndFolders, true, null, null, "Load Files and Folders", "Load");
if (FileBrowser.Success){
string path =FileBrowser.Result[0] ;// this will be something like p.e. content://com.android.externalstorage.documents/tree/primary%3ADocuments/document/primary%3ADocuments%2Fdom.chunk
Debug.Log(File.Exists(path)); // logs false into the console.
}
}
i tried to track down the issue in the code, and it seems like the path already contains the unescaped characters in the FileBrowserHelpers.cs, where the string rawURI is extracted from the string resultRaw.
so it might be, that these strings will have to be handled as they are received.
Platform specs
Unity version: e.g. 2021.3.8f1
Platform: Android, 13
Device: Pixel 6, Android 13
How did you download the plugin: Asset Store
Additional info
Logcat (Android) warnings thrown by the file browser:
2022/09/29 20:01:13.180 13691 13716 Warn DocumentFile Failed query: java.lang.SecurityException: Document primary: is not a descendant of primary:Documents
2022/09/29 20:01:13.182 13691 13716 Warn DocumentFile Failed query: java.lang.SecurityException: Document primary: is not a descendant of primary:Documents
2022/09/29 20:01:13.184 13691 13716 Warn DocumentFile Failed query: java.lang.SecurityException: Permission Denial: reading com.android.externalstorage.ExternalStorageProvider uri content://com.android.externalstorage.documents/tree/primary%3A/document/primary%3A from pid=13691, uid=10322 requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
Description of the bug
Loading / Saving a file on Android 13 does not work. reasons seems to be unescaped characters in the file path that the fileBrowser returns. the same code works well on mac and windows.
Reproduction steps
Use the file browser, p.e. via code like this:
i tried to track down the issue in the code, and it seems like the path already contains the unescaped characters in the
FileBrowserHelpers.cs
, where thestring rawURI
is extracted from thestring resultRaw
. so it might be, that these strings will have to be handled as they are received.Platform specs
Additional info
Logcat (Android) warnings thrown by the file browser: