]> glassweightruler.freedombox.rocks Git - waydroid.git/commitdiff
Rebuild waydroid.prop after live upgrade
authorAlessandro Astone <ales.astone@gmail.com>
Tue, 6 Sep 2022 16:03:38 +0000 (18:03 +0200)
committerAlessandro Astone <ales.astone@gmail.com>
Fri, 9 Sep 2022 06:19:07 +0000 (08:19 +0200)
On waydroid upgrade waydroid_base.prop might change so we should
rewrite the mountable waydroid.prop file as well.

Do this in mount_rootfs so that:
* Every caller already benefits from this (initializer, upgrader...)
* We can set props based on rootfs contents

tools/actions/container_manager.py
tools/helpers/images.py

index 9539394d90f519e06dd85ac82ff3c63c400e85fb..8b91b451f085b31b99440c96123966e967eee110 100644 (file)
@@ -14,38 +14,6 @@ from tools import services
 
 
 def start(args):
 
 
 def start(args):
-    def make_prop(full_props_path):
-        def add_prop(key, cfg_key):
-            value = session_cfg["session"][cfg_key]
-            if value != "None":
-                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")
-        with open(args.work + "/waydroid_base.prop") as f:
-            props = f.read().splitlines()
-        if not props:
-            raise RuntimeError("waydroid_base.prop is broken!!?")
-
-        add_prop("waydroid.host.user", "user_name")
-        add_prop("waydroid.host.uid", "user_id")
-        add_prop("waydroid.host.gid", "group_id")
-        add_prop("waydroid.xdg_runtime_dir", "xdg_runtime_dir")
-        add_prop("waydroid.pulse_runtime_path", "pulse_runtime_path")
-        add_prop("waydroid.wayland_display", "wayland_display")
-        if which("waydroid-sensord") is None:
-            props.append("waydroid.stub_sensors_hal=1")
-        dpi = session_cfg["session"]["lcd_density"]
-        if dpi != "0":
-            props.append("ro.sf.lcd_density=" + dpi)
-
-        final_props = open(full_props_path, "w")
-        for prop in props:
-            final_props.write(prop + "\n")
-        final_props.close()
-        os.chmod(full_props_path, 0o644)
-
     def set_permissions(perm_list=None, mode="777"):
         def chmod(path, mode):
             if os.path.exists(path):
     def set_permissions(perm_list=None, mode="777"):
         def chmod(path, mode):
             if os.path.exists(path):
@@ -115,9 +83,6 @@ def start(args):
         
         # Load session configs
         session_cfg = tools.config.load_session()
         
         # Load session configs
         session_cfg = tools.config.load_session()
-        
-        # Generate props
-        make_prop(args.work + "/waydroid.prop")
 
         # Networking
         command = [tools.config.tools_src +
 
         # Networking
         command = [tools.config.tools_src +
index b54a30161a21579adc0bd78d39b772810cee0dfd..ac85f4faca001109157047239dc5894256343295 100644 (file)
@@ -7,7 +7,7 @@ import hashlib
 import os
 import tools.config
 from tools import helpers
 import os
 import tools.config
 from tools import helpers
-
+from shutil import which
 
 def sha256sum(filename):
     h = hashlib.sha256()
 
 def sha256sum(filename):
     h = hashlib.sha256()
@@ -93,6 +93,39 @@ def replace(args, system_zip, system_time, vendor_zip, vendor_time):
         cfg["waydroid"]["vendor_datetime"] = str(vendor_time)
         tools.config.save(args, cfg)
 
         cfg["waydroid"]["vendor_datetime"] = str(vendor_time)
         tools.config.save(args, cfg)
 
+def make_prop(args, full_props_path):
+    if not os.path.isfile(args.work + "/waydroid_base.prop"):
+        raise RuntimeError("waydroid_base.prop Not found")
+    with open(args.work + "/waydroid_base.prop") as f:
+        props = f.read().splitlines()
+    if not props:
+        raise RuntimeError("waydroid_base.prop is broken!!?")
+
+    session_cfg = tools.config.load_session()
+
+    def add_prop(key, cfg_key):
+        value = session_cfg["session"][cfg_key]
+        if value != "None":
+            value = value.replace("/mnt/", "/mnt_extra/")
+            props.append(key + "=" + value)
+
+    add_prop("waydroid.host.user", "user_name")
+    add_prop("waydroid.host.uid", "user_id")
+    add_prop("waydroid.host.gid", "group_id")
+    add_prop("waydroid.xdg_runtime_dir", "xdg_runtime_dir")
+    add_prop("waydroid.pulse_runtime_path", "pulse_runtime_path")
+    add_prop("waydroid.wayland_display", "wayland_display")
+    if which("waydroid-sensord") is None:
+        props.append("waydroid.stub_sensors_hal=1")
+    dpi = session_cfg["session"]["lcd_density"]
+    if dpi != "0":
+        props.append("ro.sf.lcd_density=" + dpi)
+
+    final_props = open(full_props_path, "w")
+    for prop in props:
+        final_props.write(prop + "\n")
+    final_props.close()
+    os.chmod(full_props_path, 0o644)
 
 def mount_rootfs(args, images_dir):
     helpers.mount.mount(args, images_dir + "/system.img",
 
 def mount_rootfs(args, images_dir):
     helpers.mount.mount(args, images_dir + "/system.img",
@@ -110,6 +143,8 @@ def mount_rootfs(args, images_dir):
         if os.path.isdir("/vendor/odm"):
             helpers.mount.bind(
                 args, "/vendor/odm", tools.config.defaults["rootfs"] + "/odm_extra")
         if os.path.isdir("/vendor/odm"):
             helpers.mount.bind(
                 args, "/vendor/odm", tools.config.defaults["rootfs"] + "/odm_extra")
+
+    make_prop(args, args.work + "/waydroid.prop")
     helpers.mount.bind_file(args, args.work + "/waydroid.prop",
                             tools.config.defaults["rootfs"] + "/vendor/waydroid.prop")
 
     helpers.mount.bind_file(args, args.work + "/waydroid.prop",
                             tools.config.defaults["rootfs"] + "/vendor/waydroid.prop")