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 refresh_flag=0 ubports_dirname="/home/phablet/Pictures/com.ubuntu.camera/" android_dirname="/home/phablet/anbox-data/data/media/0/DCIM/" # Copy new images ubports_filenames=os.listdir(ubports_dirname) android_filenames=os.listdir(android_dirname) for ubports_filename in ubports_filenames: try: android_filenames.index(ubports_filename) 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) refresh_flag=1 # Delete deleted images ubports_filenames=os.listdir(ubports_dirname) android_filenames=os.listdir(android_dirname) for android_filename in android_filenames: try: ubports_filenames.index(android_filename) except: # If file is deleted if not stat.S_ISDIR(os.stat(android_dirname+android_filename).st_mode): # Ignore directories os.remove(android_dirname+android_filename) refresh_flag=1 if refresh_flag==1: # If something changed "reboot" the anbox os.popen("anbox-tool disable") os.popen("anbox-tool enable")
Ingo last edited by
IIRC you can use
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.
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.