X-Git-Url: https://glassweightruler.freedombox.rocks/gitweb/waydroid.git/blobdiff_plain/bf567ae4e575924983f12353a414d4ce19fe5fa2..1fbcd236d4ff4f13be6d17b016e84de054d075c9:/tools/actions/container_manager.py diff --git a/tools/actions/container_manager.py b/tools/actions/container_manager.py index ce04180..9539394 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") @@ -48,7 +50,7 @@ def start(args): def chmod(path, mode): if os.path.exists(path): command = ["chmod", mode, "-R", path] - tools.helpers.run.root(args, command, check=False) + tools.helpers.run.user(args, command, check=False) # Nodes list if not perm_list: @@ -64,20 +66,18 @@ def start(args): "/dev/MTK_SMI", "/dev/mdp_sync", "/dev/mtk_cmdq", - "/dev/video32", - "/dev/video33", # Graphics "/dev/dri", "/dev/graphics", - - # Wayland and pulse socket permissions - session_cfg["session"]["pulse_runtime_path"], - session_cfg["session"]["xdg_runtime_dir"] + "/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) @@ -122,15 +122,18 @@ def start(args): # Networking command = [tools.config.tools_src + "/data/scripts/waydroid-net.sh", "start"] - tools.helpers.run.root(args, command, check=False) + tools.helpers.run.user(args, command, check=False) # Sensors - tools.helpers.run.root( - 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"]) + helpers.protocol.set_aidl_version(args) + # Mount data helpers.mount.bind(args, session_cfg["session"]["waydroid_data"], tools.config.defaults["data"]) @@ -138,13 +141,15 @@ def start(args): # Cgroup hacks if which("start"): command = ["start", "cgroup-lite"] - tools.helpers.run.root(args, command, check=False) - helpers.mount.umount_all(args, "/sys/fs/cgroup/schedtune") + tools.helpers.run.user(args, command, check=False) + if os.path.ismount("/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"): command = ["stop", "nfcd"] - tools.helpers.run.root(args, command, check=False) + tools.helpers.run.user(args, command, check=False) # Set permissions set_permissions() @@ -162,8 +167,7 @@ def start(args): raise OSError("container failed to start") tools.config.save_session(session_cfg) - if not hasattr(args, 'hardwareLoop'): - services.hardware_manager.start(args) + services.hardware_manager.start(args) signal.signal(signal.SIGINT, signal_handler) while os.path.exists(tools.config.session_defaults["config_path"]): @@ -179,6 +183,7 @@ def start(args): logging.warning("session manager stopped, stopping container and waiting...") stop(args) + services.hardware_manager.stop(args) start(args) else: logging.error("WayDroid container is {}".format(status)) @@ -195,21 +200,35 @@ def stop(args): # Networking command = [tools.config.tools_src + "/data/scripts/waydroid-net.sh", "stop"] - tools.helpers.run.root(args, command, check=False) + tools.helpers.run.user(args, command, check=False) #TODO: remove NFC hacks if which("start"): command = ["start", "nfcd"] - tools.helpers.run.root(args, command, check=False) + tools.helpers.run.user(args, command, check=False) # Sensors if which("waydroid-sensord"): command = ["pidof", "waydroid-sensord"] - pid = tools.helpers.run.root(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.root(args, command, check=False) + 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)) + +def restart(args): + status = helpers.lxc.status(args) + if status == "RUNNING": + helpers.lxc.stop(args) + helpers.lxc.start(args) else: logging.error("WayDroid container is {}".format(status))