CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
10.11k stars 4.1k forks source link

Android11 Requires using /media instead of /data folder #49310

Open linonetwo opened 3 years ago

linonetwo commented 3 years ago

Describe the bug

After upgrading to MIUI12.5 (Android 11), I can't easily sync CDDA's mod and save between the mobile and the laptop, because backup app (for example, an opensource one, SyncThing ) can't access other app's folder inside data.

Steps To Reproduce

  1. Run any version of CDDA in an Android11 machine.
  2. Create a new save
  3. The save is in the /storage/emulated/0/Android/data/com.cleverraven.cataclysm.dda/files/save folder
  4. it is not accessible from other apps, even the vanilla file browser.

Expected behavior

I think we could store save to the media folder, and stop using the data folder completely (so an experimental user will notice this change).

Versions and configuration

Additional context

I also sync mods in /storage/emulated/0/Android/data/com.cleverraven.cataclysm.dda/files/mods between mobile and computer, so updating 3rd party mods is easier (auto-sync via WiFi). This experience was pretty good, I can play on the phone when go outside, and play on the computer when I get back home (and wait for 3-10s of syncing).

Workaround

I still hope I can sync between Android and Mac, so currently I use adb to sync manually:

# Mac -> Android
% adb push /Users/linonetwo/Library/Application\ Support/Cataclysm/save /storage/emulated/0/Android/data/com.cleverraven.cataclysmdda.experimental/files/save
# result: /Users/linonetwo/Library/Application Support/Cataclysm/save/: 12440 files pushed, 0 skipped. 19.4 MB/s (109836663 bytes in 5.407s)
% adb push /Users/linonetwo/Library/Application\ Support/Cataclysm/mods /storage/emulated/0/Android/data/com.cleverraven.cataclysmdda.experimental/files/mods
# result: /Users/linonetwo/Library/Application Support/Cataclysm/mods/: 3642 files pushed, 0 skipped. 31.5 MB/s (55721094 bytes in 1.688s)

# Android -> Mac
adb pull /storage/emulated/0/Android/data/com.cleverraven.cataclysmdda.experimental/files/save ~/Desktop/cddatemp
# /storage/emulated/0/Android/data/com.c.... 1.0 MB/s (43881859 bytes in 40.418s)
zyx65536 commented 3 years ago

On Android 11 to access Android/data folder you can use X-Plorer file manager https://play.google.com/store/apps/details?id=com.lonelycatgames.Xplore After first launch give all permissions to access file system and accessing data folder give special permission

linonetwo commented 3 years ago

@zyx65536 What matters is the syncthing app, I use it to allow seamless sync between PC and Mac and Android, so it feels like a Switch game. And it won't work with data folder now, and won't be possible in the near future, because data access is only granted to several file manager app by Google.

linonetwo commented 3 years ago

Anybody knows which file to modify? I'm learning Android, but I coundn't find a file that writes about we are storing save files to /data folder or /media folder.


Thanks to Brettd's guidance, I know I should look at https://github.com/CleverRaven/Cataclysm-DDA/blob/960639e7f83de7ea9e43e6f321b8e1c3388f2cdd/src/main.cpp#L528-L539 and Android side merely use ffi getExternalFilesDir to get the data folder.

And use https://github.com/CleverRaven/Cataclysm-DDA/pull/47977/files to pass path variable from Java to C++

I will try change this later.

kevingranade commented 11 months ago

This issue has been mentioned on Cataclysm: Dark Days Ahead. There might be relevant details there:

https://discourse.cataclysmdda.org/t/best-config-for-multidevice-playing/27223/4