Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I transfer the savefiles ? #4

Closed
Enderteck opened this issue Apr 15, 2024 · 16 comments
Closed

How can I transfer the savefiles ? #4

Enderteck opened this issue Apr 15, 2024 · 16 comments

Comments

@Enderteck
Copy link

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 ?

@Enderteck Enderteck changed the title Ho can I transfer the savefiles ? How can I transfer the savefiles ? Apr 15, 2024
@antipatico
Copy link
Owner

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/
  1. push the resulting tar archive to the device
adb push balatro.tar.gz /data/local/tmp
  1. 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
Copy link
Author

Enderteck commented Apr 15, 2024

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
Copy link
Owner

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
Copy link
Author

@antipatico
Copy link
Owner

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

@Enderteck
Copy link
Author

Enderteck commented Apr 15, 2024

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
Copy link
Owner

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
Copy link
Author

Enderteck commented Apr 15, 2024

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

Screenshot_20240415_204437_Files.jpg

@Enderteck
Copy link
Author

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

@antipatico
Copy link
Owner

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

@Enderteck
Copy link
Author

Enderteck commented Apr 15, 2024

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
Copy link
Owner

antipatico commented Apr 15, 2024

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
Copy link
Author

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

@antipatico
Copy link
Owner

@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: antipatico/love-android@2625524

@Enderteck
Copy link
Author

Nice, you're a pro !

@antipatico
Copy link
Owner

antipatico commented Apr 27, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants