TIC-80: Some Android devices can't access tic files without rooted phone

The default folder in which tic80 saves is in Android/data/com.nesbox.tic80/, but not all phones have access to those folders without rooting the phone. In my case I have a motorola edge 20 running android 12, and can’t access the files even when using file transfer connected to my PC.

I think this should be a bug because saved files, exports and imports can’t be accessed on some phones.

What do you think? Is there plans on changing this directory? Thanks

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 4
  • Comments: 23 (6 by maintainers)

Commits related to this issue

Most upvoted comments

I fixed access rights here 388074e4584e3f9350dbbfca73cbdf62146448c2 Let’s see if it helps us

After performing a couple of actions, it turned out that the TIC80 folder is not available for reading, and not only for writing. Screenshot_20230720-221500 Screenshot_20230720-221525

I can also confirm that the changed line (0770 instead of 0700) suggested above is working. Without that change, tic80 says “cart test.lua saved” but the folder remains empty.realme c30 android 11

So, at least we can add this change from @bztsrc

        strcpy(appFolder, SDL_AndroidGetExternalStoragePath());
        const char AppFolder[] = "/" TIC_NAME "/";
        strcat(appFolder, AppFolder);
-        mkdir(appFolder, 0700);
+        mkdir(appFolder, 0777);

@bztsrc I’l try changing that line and see if it works in my phone and get back to this issue

Did it work?

@bztsrc I’l try changing that line and see if it works in my phone and get back to this issue

A small correction to my issue, I actually do have access to the folder but I can’t see the files saved in it

Now this is a different issue, and indeed, this might be TIC-80’s fault. I’m thinking maybe main.c:1323 should be

        strcpy(appFolder, SDL_AndroidGetExternalStoragePath());
        const char AppFolder[] = "/" TIC_NAME "/";
        strcat(appFolder, AppFolder);
-        mkdir(appFolder, 0700);
+        mkdir(appFolder, 0777);

Assuming the application runs under a different unix user than the adb server, then this might fix it. But I’m not sure, and it would require a complete reinstall, because it has to remove the directory and re-create it again with different unix permissions.

Going by the table cited above, it seems that the Documents and other files/Storage Access Framework is more suited

I’m guessing you’re referring to getMediaUri from that page? That’s not a bad idea. Unfortunately SDL doesn’t have a function for that (see API, functions starting with SDL_AndroidGet...). There should be a support in SDL first (but after that, should be straightforward to use it from TIC-80).

I tested again on my devices, my motorola implements the behaviour cited in the table ( no access and deletes the files after uninstall ) and my Xiaomi tablet doesn’t ( I can access the files and they are maintained after uninstall ).

Yep, I’m sure that directory supposed to be removed after uninstall. And I believe that’s the expected behaviour, because what are you gonna do with some .tic files in lack of a TIC-80 application?

Cheers. bzt

A small correction to my issue, I actually do have access to the folder but I can’t see the files saved in it (with usb or another app). This is also true for other apps.

But I don’t think it’s a faulty implementation on motorola’s Android, and in some cases it is even more aligned to the android specification. in a lot of places in the documentation the directory used is cited to be “private” for the application. So probably it is a conscious choice to hide these files

Example in Context::getExternalFilesDir:

These files are internal to the applications, and not typically visible to the user as media.

Or in this table it is said that getExternalFilesDir() cannot be accessed by other apps.

Going by the table cited above, it seems that the Documents and other files/Storage Access Framework is more suited, because files are accessible through the system file picker and are not removed after app uninstall.

@sogaiu: Yeah, my phrasing was terrible, sorry about that.

I agree with you, and that’s what I was trying to say: only keep this ticket open if we expect some black-belt Android dev to create a workaround for buggy phones.

Unfortunately I’m not that, using SDL_AndroidGetExternalStoragePath is the best I can think of, so no clue 😦

Cheers, bzt