libretro / RetroArch

Cross-platform, sophisticated frontend for the libretro API. Licensed GPLv3.
http://www.libretro.com
GNU General Public License v3.0
10.27k stars 1.83k forks source link

[Android] APP is not Document Provider, cannot interact with configs/shaders/etc #15309

Open Dogway opened 1 year ago

Dogway commented 1 year ago

Description

I opened a thread half a year ago with this same issue but just reading Dolphin's last blog entry I got the proper term.

The retroarch APP by design seems to not be Document Provider, that is; "This means you can use Dolphin to directly copy files into and out of its per-app directory on the latest versions of Android." So after installing Retroarch on GoogleTV I cannot load my configs and settings from the desktop version because I have not access to those folders (Android/data/RetroArch). Or add custom shaders/bezels, etc.

Expected behavior

I expect the APP to be Document Provider like Dolphin, Kodi, etc, and be configurable via a built-in browser.

Actual behavior

Cannot add or remove files (shaders, bezels, core configs, core options, all types of overrides, custom UI, etc) Cannot save default options, retroarch always starts "clean".

Version/Commit

Environment information

hizzlekizzle commented 1 year ago

That's what this is, right? https://github.com/libretro/RetroArch/blob/master/pkg/android/phoenix/src/com/retroarch/browser/provider/RetroDocumentsProvider.java

Dogway commented 1 year ago

I guess so. The problem and as explained in the Dolphin blog entry is that newer Androids limits the access to protected folders so even a file browser with Document Provider support (Files?) won't work. This is explained further here.

hizzlekizzle commented 1 year ago

I'm not an expert on Java, but it looks like Dolphin's doing essentially the same stuff we are: https://github.com/dolphin-emu/dolphin/blob/8fd61d0b54d735d2c7e05dd8a6d241db5d0cc802/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/DocumentProvider.kt#L4

So, are you saying the document provider stuff works for you with dolphin but not for RetroArch?

Dogway commented 1 year ago

Chromecast is not powerful enough for Dolphin so I will install first RA and then Dolphin on my tablet and see if Files has access to it, looks like that's the file browser used in the screenshot for the blog entry.

GoogleTV doesn't support Files I think so a workaround would be needed (like Kodi) to inject the modified files.

Will report back.

Dogway commented 1 year ago

Dolphin

Installed both APPs as latest nightlies. Dolphin stores its "program files" within: /storage/emulated/0/Android/data/org.dolphinemu.dolphinemu

I have three file browsers on the tablet; Google Files, Samsung's own file browser and FileCommander. Files and Samsung's file browser don't have access to Android/data, while FileCommander asks for a special access grant to a protected folder as shown in this screenshot.

Screenshot

After grant is conceded I proceed to access the folder with a following denied access. So something is not right there.

RetroArch

Meanwhile with RetroArch it stores its files in three different locations:

/data/user/0/com.retroarch.aarch64 (default RA "program files" location)
/storage/emulated/0/Android/data/com.retroarch.aarch64 (?)
/storage/emulated/0/Retroarch (user files)

I repeat the FileCommander procedure. /data/user/0/ path cannot be granted any access, so I try with /storage/emulated/0/Android/data path this time without issues, and I can edit the main default retroarch.config.

So while cumbersome and unideal a workaround is possible where I can edit default's retroarch.config to assign all the "program files" folders to /storage/emulated/0/ path and start customizing files. This won't move the files so you will have to repopulate the default files bundled with the APP (about 300Mb), only then you can download resources with the online updater.

Translating this to GoogleTV is not possible as FileCommander for some reason fails to load the option to grant access to special folders. So another file browser (which?) should be used or as in the Kodi example a built-in browser is implemented, my suggestion. I read that Solid File Explorer also works for accessing Android/data path, but the app is not open source and last time I used it didn't give me good vibes, will try again as an alternative for GoogleTV at least.

Dogway commented 1 year ago

I had time to take a deeper look into this from Dolphin's POV. They provide a way to access their Data folder from within Dolphin's APP: /storage/emulated/0/Android/data/org.dolphinemu.dolphinemu via Settings->config->userdata->Open User Data Folder

With this a browser opens Dolphin's config folder.

It happens to be that all Android OS have a built-in file browser usually hidden by the manufacturer, and it's called "Files" or "Archivos" in Spanish and probably different for different languages.

You can either use a third party APP with Document Provider enabled such as ZArchiver, find a mean to open Android's built-in Files APP (not to confuse with Google's Files APP), or as I did download a third party shortcut to Files.

So to sum it up, unless you rely on third party APPs it's very difficult if not impossible to access the config folders for RetroArch. So my suggestion is to at least if not including a file browser within RA (as Kodi does), to provide a "Files" APP shortcut or shortcuts within RA to the different RA config folders similar to what Dolphin does.

*GoogleTV doesn't come with this built-in "Files" APP (probably the reason why File Commander fails to grant access to special folders), so the only alternative for it is for RA to come with a built-in browser. The Dolphin workaround is to export the whole config as a .zip with the "Export" button, edit on PC and then import back with "Import" button.