]> glassweightruler.freedombox.rocks Git - waydroid.git/blobdiff - tools/actions/container_manager.py
Add first-launch command
[waydroid.git] / tools / actions / container_manager.py
index 24e410bd83bf6d95787a7178b085262d94df943d..f242b862bbd63de07ef1a6d8074cecdca2ecc2d0 100644 (file)
@@ -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
@@ -69,6 +70,8 @@ def start(args):
                 # Graphics
                 "/dev/dri",
                 "/dev/graphics",
+                "/dev/pvr_sync",
+                "/dev/ion",
             ]
 
             # Framebuffers
@@ -79,6 +82,33 @@ def start(args):
         for path in perm_list:
             chmod(path, mode)
 
+    def set_aidl_version():
+        cfg = tools.config.load(args)
+        android_api = 0
+        try:
+            android_api = int(helpers.props.file_get(args,
+                    tools.config.defaults["rootfs"] + "/system/build.prop",
+                    "ro.build.version.sdk"))
+        except:
+            logging.error("Failed to parse android version from system.img")
+
+        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)
@@ -129,6 +159,8 @@ def start(args):
         # Mount rootfs
         helpers.images.mount_rootfs(args, cfg["waydroid"]["images_path"])
 
+        set_aidl_version()
+
         # Mount data
         helpers.mount.bind(args, session_cfg["session"]["waydroid_data"],
                            tools.config.defaults["data"])
@@ -137,7 +169,9 @@ 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")
+        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"):
@@ -203,7 +237,7 @@ 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)