antipatico / balatromobile

Convert Balatro steam version to a version playable on your mobile device
MIT License
9 stars 3 forks source link

How can I transfer the savefiles ? #4

Closed Enderteck closed 4 months ago

Enderteck commented 5 months ago

I was able to see the files with

adb shell run-as dev.bootkit.balatro ls

As my Tablet runs android 13

But how can I copy them from Documents to that dir ?

Could i also do it from files on my PC directly ?

antipatico commented 5 months ago

To transfer save files you need a little bit of *nix wizardry:

  1. create a tar of your files from your desktop
    tar -cvf balatro.tar.gz files/
  2. push the resulting tar archive to the device
    adb push balatro.tar.gz /data/local/tmp
  3. untar the archive using run-as
    adb shell run-as dev.bootkit.balatro tar -xvf /data/local/tmp/balatro.tar.gz

Once you do this, you can check if the files are correctly in place by opening a shell with run-as, which you can do by first running adb shell and then run-as dev.bootkit.balatro. You may be able to pop a shell with a single adb shell run-as dev.bootkit.balatro sh but I am not sure.

Ideally, I would implement a script to automate this, or find a way to make LoveAndroid work with recent Android.

Enderteck commented 5 months ago

Where are the savefiles stored on Android ?

That could help

Is there no way to mount that direcotry to the devic's storage ? Termux and Pojav Launcher do that

antipatico commented 5 months ago

They are stored in the local data folder of the application, which is accessible only by the application itself. Fortunately, the application is patched to be "debuggable". Thus, you can use run-as to impersonate the application.

You can open a shell with adb shell and inside the adb shell run run-as dev.balatro.bootkit. You should find a files folder, which contains different subfolders and finally the game files.

I do not know if it is possible to mount this directory the way termux / pojav launcher do. Do you have any idea of which API they use to do that?

Enderteck commented 5 months ago

No clue sorry. Here are the repos:

https://github.com/termux/termux-app

https://github.com/PojavLauncherTeam/PojavLauncher

antipatico commented 5 months ago

Can you explain further what feature do Termux and Pojav Launcher have?

Enderteck commented 5 months ago

In the files app you can see the app names on the side as if it was an external drive or a google drive. It allows you to add files or remove them freely. I can add and remove minecraft mods and instances easily for pojav.

antipatico commented 5 months ago

I searched and found about the Storage Access Framework [1][2]

Which file manager are you using to access the files? On my pixel, the stock one does not display my termux files, but opens termux instead. Are you using the default files app?

I am looking into the Storage Access Framework API and considering if it may be worth implementing in Love-Android.

Enderteck commented 5 months ago

Here's a screenshot of what I'm talking about:

Screenshot_20240415_204437_Files.jpg

Enderteck commented 5 months ago

If I just need to access Android/data/dev.balatro.idk I can do that

antipatico commented 5 months ago

If you have root, the path you want to look at is /data/data/dev.bootkit.balatro

Enderteck commented 5 months ago

Can't I just plug my tablet in my computer and go to Android/data/theapp ? Or do I need root ?

Modern versions block u form going to that dir on the device but plugging it in a computer should still work

antipatico commented 5 months ago

You need root, or access the file using the shell using run-as. You cannot browse directly the files. You can try to add the external-storage patch to your build (as explained in the README) and see if you are successful in accessing your files under Android/data/...

On another note, I looked into Termux's implementation of the Storage Access Framework's Document Provider and it is not trivial.

I see it as feasible and something that might also be considered by mainline Love-Android. That being said, I am not going to develop it right now. If you want this change, your best bet is asking it to Love-Android's developers.

I am sorry, but I still think using the terminal is the easiest. Eventually I will script it, but as of today I do not think there is an easier method.

EDIT: you can also look at the balatro-mobile-maker repo and try to replicate the code it is running;

            CommandLine("cd platform-tools && cd platform-tools && adb shell mkdir /data/local/tmp/balatro");
            CommandLine("cd platform-tools && cd platform-tools && adb shell mkdir /data/local/tmp/balatro/files");
            CommandLine("cd platform-tools && cd platform-tools && adb shell mkdir /data/local/tmp/balatro/files/save");
            CommandLine("cd platform-tools && cd platform-tools && adb shell mkdir /data/local/tmp/balatro/files/save/game");
            CommandLine("cd platform-tools && cd platform-tools && adb push \"%AppData%/Balatro/.\" /data/local/tmp/balatro/files/save/game && adb shell am force-stop com.unofficial.balatro && adb shell run-as com.unofficial.balatro cp -r /data/local/tmp/balatro/files . && adb shell rm -r /data/local/tmp/balatro && adb kill-server");

Alternately, you may also just wait for that script to release on Linux, I think it is going to be ready in a matter of days, if not hours!

Enderteck commented 5 months ago

No luck using the external-storage patch. Sad the latest android versions break that. Thx for all the info though !

antipatico commented 4 months ago

@Enderteck I have updates! I noticed that latest version of love-android (version 12.x), has an implementation of SAF. Thus, I decided to port it back to 11.x and see if that worked. I was able to port it successfully and with a little bit of effort, to make it work:

image

The only caveat is that the external-storage patch must be enabled, meaning that it will break support for automated backups and old versions saves must be moved manually.

On the bright side, the game built in this mode will have accessible files under the Android/data folder for older versions of Android, while still being able to access the files on the device itself in newer versions of Android by using FX File Explorer, Material Files or another similar application.

Tomorrow I will publish an update to this project, in the meantime if you are interested you can find the patch for love-android here: https://github.com/antipatico/love-android/commit/26255245f78ce694336563c0c7bd96eba8251d1f

Enderteck commented 4 months ago

Nice, you're a pro !

antipatico commented 4 months ago

Version 0.3.0 is out and should work now, let me know if it works!

P.S. you find a video in the README showing how to access the saves folder