]> glassweightruler.freedombox.rocks Git - waydroid.git/commitdiff
Add an optional [properties] in waydroid.cfg
authorChristophe Chapuis <chris.chapuis@gmail.com>
Sat, 27 Nov 2021 14:59:13 +0000 (14:59 +0000)
committerErfan Abdi <erfangplus@gmail.com>
Mon, 10 Jan 2022 05:35:17 +0000 (09:05 +0330)
On some platforms, like a VM, we don't have the "getprop" android
utility available. It could be, also, that the default values
for some properties don't match the target device.

With this PR, one can add a [properties] section in waydroid.cfg,
that will act as an override for the values that would have been
put otherwise.

Example, on our LuneOS x86 VM:
[properties]
ro.hardware.gralloc=default
ro.hardware.egl=mesa

A minimal waydroid.cfg could even be shipped with waydroid, and
the rest of the configuration will be filled with "waydroid init".

Signed-off-by: Christophe Chapuis <chris.chapuis@gmail.com>
tools/config/load.py
tools/helpers/lxc.py

index 6826c213876967d5589deed958378102692c8eb6..87a175715590f210361fba7db0b1235f10deee9f 100644 (file)
@@ -26,6 +26,10 @@ def load(args):
                           " default value from config: {}".format(cfg['waydroid'][key]))
             del cfg["waydroid"][key]
 
                           " default value from config: {}".format(cfg['waydroid'][key]))
             del cfg["waydroid"][key]
 
+    if "properties" not in cfg:
+        cfg["properties"] = {}
+    # no default values for property override
+
     return cfg
 
 def load_session():
     return cfg
 
 def load_session():
index d57e63c7f4f9041494e4be213ada614f3ac0e35d..2a9c841d41d46201fcf09bbb45ca2f3be8ec1043 100644 (file)
@@ -240,6 +240,14 @@ def make_base_props(args):
     if prop_fp != "":
         props.append("ro.build.fingerprint=" + prop_fp)
 
     if prop_fp != "":
         props.append("ro.build.fingerprint=" + prop_fp)
 
+    # now append/override with values in [properties] section of waydroid.cfg
+    cfg = tools.config.load(args)
+    for k, v in cfg["properties"].items():
+        for idx, elem in enumerate(props):
+            if (k+"=") in elem:
+                props.pop(idx)
+        props.append(k+"="+v)
+
     base_props = open(args.work + "/waydroid_base.prop", "w")
     for prop in props:
         base_props.write(prop + "\n")
     base_props = open(args.work + "/waydroid_base.prop", "w")
     for prop in props:
         base_props.write(prop + "\n")