Kind of solved: Anbox: How to refresh Android gallery, "reboot" the sandbox?

  • EDIT: Workaround was appended to the script (last three lines)
    Unfortunately WhatsApp is still neccesary to have as most people are totally incapable of grasping the concept of alternative programs. Well, here we go.
    As I'd like to sent a photo from time to time I wrote the script down below and have a cron job running to synchronize the Android DCIM directory with the UBports side every minute.
    This works great, however the Android side completely ignores any change in the DCIM directory. Only after a full reboot of the phone the files are in the gallery.

    So the question is: Do you have any idea how to force anbox to notice the changes? "Rebooting" anbox would be ok for the start. But how?

    import os
    import stat
    import shutil
    # Copy new images
    for ubports_filename in ubports_filenames:
    	except: # If file is not yet in DCIM
    		if not stat.S_ISDIR(os.stat(ubports_dirname+ubports_filename).st_mode): # Ignore directories
    			shutil.copy(ubports_dirname+ubports_filename, android_dirname)
    			os.chown(android_dirname+ubports_filename, 1023, 1023)
    # Delete deleted images
    for android_filename in android_filenames:
    	except: # If file is deleted
    		if not stat.S_ISDIR(os.stat(android_dirname+android_filename).st_mode): # Ignore directories
    if refresh_flag==1: # If something changed "reboot" the anbox
    	os.popen("anbox-tool disable")
    	os.popen("anbox-tool enable")

  • IIRC you can use anbox-tool disable and anbox-tool enable. Haven't tried it myself as I currently have no phone running UT.

  • @BodoW I cannot help you, but I just can thank you, as I wanted to create the same script but did not have time 🙂 I will just copy yours.
    I also had the idea of creating a simple app that would include anbox "hack" features for UT, like this one, decide which android default apps to hide, etc.

  • @ThrillSeeker
    Good to know that someone else considers it useful too. Thank you.

  • Thank you @Ingo. I've added it to the code and it works.
    As this is the reboot approach I'd still leave the issue open as maybe someone might come up with the preferred refresh solution.

Log in to reply