X-Git-Url: https://glassweightruler.freedombox.rocks/gitweb/waydroid.git/blobdiff_plain/37d108429469d1f2784ccb3756390243823a4454..7814b71d71982a1e2cf460a266fcdb102ce254e8:/tools/actions/container_manager.py diff --git a/tools/actions/container_manager.py b/tools/actions/container_manager.py index 37ab7e7..0588939 100644 --- a/tools/actions/container_manager.py +++ b/tools/actions/container_manager.py @@ -7,6 +7,7 @@ import time import glob import signal import sys +import uuid import tools.config from tools import helpers from tools import services @@ -17,7 +18,8 @@ def start(args): def add_prop(key, cfg_key): value = session_cfg["session"][cfg_key] if value != "None": - props.append(key + "=" + session_cfg["session"][cfg_key]) + value = value.replace("/mnt/", "/mnt_extra/") + props.append(key + "=" + value) if not os.path.isfile(args.work + "/waydroid_base.prop"): raise RuntimeError("waydroid_base.prop Not found") @@ -64,25 +66,59 @@ def start(args): "/dev/MTK_SMI", "/dev/mdp_sync", "/dev/mtk_cmdq", - "/dev/video32", - "/dev/video33", # Graphics "/dev/dri", "/dev/graphics", + "/dev/pvr_sync", + "/dev/ion", ] # Framebuffers perm_list.extend(glob.glob("/dev/fb*")) + # Videos + perm_list.extend(glob.glob("/dev/video*")) for path in perm_list: chmod(path, mode) + def set_aidl_version(): + cfg = tools.config.load(args) + android_api = 0 + try: + mnt = "/tmp/waydroid-" + str(uuid.uuid1()) + helpers.mount.mount(args, cfg["waydroid"]["images_path"] + "/system.img", mnt) + android_api = int(helpers.props.file_get(args, mnt + "/system/build.prop", + "ro.build.version.sdk")) + except: + logging.error("Failed to parse android version from system.img") + finally: + helpers.mount.umount_all(args, mnt); + + if android_api < 28: + binder_protocol = "aidl" + sm_protocol = "aidl" + elif android_api < 30: + binder_protocol = "aidl2" + sm_protocol = "aidl2" + elif android_api < 31: + binder_protocol = "aidl3" + sm_protocol = "aidl3" + else: + binder_protocol = "aidl3" + sm_protocol = "aidl4" + + cfg["waydroid"]["binder_protocol"] = binder_protocol + cfg["waydroid"]["service_manager_protocol"] = sm_protocol + tools.config.save(args, cfg) + def signal_handler(sig, frame): services.hardware_manager.stop(args) stop(args) sys.exit(0) + set_aidl_version() + status = helpers.lxc.status(args) if status == "STOPPED": # Load binder and ashmem drivers @@ -121,8 +157,9 @@ def start(args): tools.helpers.run.user(args, command, check=False) # Sensors - tools.helpers.run.user( - args, ["waydroid-sensord", "/dev/" + args.HWBINDER_DRIVER], output="background") + if which("waydroid-sensord"): + tools.helpers.run.user( + args, ["waydroid-sensord", "/dev/" + args.HWBINDER_DRIVER], output="background") # Mount rootfs helpers.images.mount_rootfs(args, cfg["waydroid"]["images_path"]) @@ -135,7 +172,8 @@ def start(args): if which("start"): command = ["start", "cgroup-lite"] tools.helpers.run.user(args, command, check=False) - helpers.mount.umount_all(args, "/sys/fs/cgroup/schedtune") + command = ["umount", "-l", "/sys/fs/cgroup/schedtune"] + tools.helpers.run.user(args, command, check=False) #TODO: remove NFC hacks if which("stop"): @@ -201,11 +239,17 @@ def stop(args): # Sensors if which("waydroid-sensord"): command = ["pidof", "waydroid-sensord"] - pid = tools.helpers.run.user(args, command, check=False, output_return=True) + pid = tools.helpers.run.user(args, command, check=False, output_return=True).strip() if pid: command = ["kill", "-9", pid] tools.helpers.run.user(args, command, check=False) + # Umount rootfs + helpers.images.umount_rootfs(args) + + # Umount data + helpers.mount.umount_all(args, tools.config.defaults["data"]) + else: logging.error("WayDroid container is {}".format(status))