]> glassweightruler.freedombox.rocks Git - waydroid.git/commitdiff
Set aidl version based on the android version
authorAlessandro Astone <ales.astone@gmail.com>
Thu, 9 Jun 2022 22:35:33 +0000 (00:35 +0200)
committerErfan Abdi <erfangplus@gmail.com>
Wed, 6 Jul 2022 16:20:29 +0000 (20:50 +0430)
tools/actions/container_manager.py
tools/helpers/drivers.py
tools/helpers/props.py
tools/interfaces/IClipboard.py
tools/interfaces/IHardware.py
tools/interfaces/IPlatform.py
tools/interfaces/IStatusBarService.py
tools/interfaces/IUserMonitor.py

index ee91c522e423311bd7a33ed448bceb0854e111bd..058893965e595b2d92a6675828d568065a7f973c 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
@@ -81,11 +82,43 @@ def start(args):
         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
index cf708f011dfa4d4af5d4e683c21fb6172a6a87e9..66744b3bc33d833cc4102eea1bfbcdcc139c26e6 100644 (file)
@@ -176,3 +176,5 @@ def loadBinderNodes(args):
     args.BINDER_DRIVER = cfg["waydroid"]["binder"]
     args.VNDBINDER_DRIVER = cfg["waydroid"]["vndbinder"]
     args.HWBINDER_DRIVER = cfg["waydroid"]["hwbinder"]
+    args.BINDER_PROTOCOL = cfg["waydroid"]["binder_protocol"]
+    args.SERVICE_MANAGER_PROTOCOL = cfg["waydroid"]["service_manager_protocol"]
index 46ab268f0c455d78e875716859131344fb195cd9..de3c3a8dcef4cb96b69e82c9b3f1b16c5029fc03 100644 (file)
@@ -49,3 +49,14 @@ def set(args, prop, value):
                 session_cfg["session"]["state"]))
     else:
         logging.error("WayDroid session is stopped")
+
+def file_get(args, file, prop):
+    with open(file) as build_prop:
+        for line in build_prop:
+            line = line.strip()
+            if len(line) == 0 or line[0] == "#":
+                continue
+            k,v = line.partition("=")[::2]
+            if k == prop:
+                return v;
+    return ""
index a1235015fe886a800da1fe65cb8f1e34963ef53e..5bd00b6f9ea5b9748a766b38de024d87d4b5f48f 100644 (file)
@@ -12,7 +12,10 @@ TRANSACTION_getClipboardData = 2
 
 def add_service(args, sendClipboardData, getClipboardData):
     helpers.drivers.loadBinderNodes(args)
-    serviceManager = gbinder.ServiceManager("/dev/" + args.BINDER_DRIVER)
+    try:
+        serviceManager = gbinder.ServiceManager("/dev/" + args.BINDER_DRIVER, args.SERVICE_MANAGER_PROTOCOL, args.BINDER_PROTOCOL)
+    except TypeError:
+        serviceManager = gbinder.ServiceManager("/dev/" + args.BINDER_DRIVER)
 
     def response_handler(req, code, flags):
         logging.debug(
index f7984dba34cafa0e631258eb60fea9f5caef3aee..9e1f2fe58d274e48d41dd93671c13d7265741bf5 100644 (file)
@@ -15,7 +15,10 @@ TRANSACTION_upgrade = 5
 
 def add_service(args, enableNFC, enableBluetooth, suspend, reboot, upgrade):
     helpers.drivers.loadBinderNodes(args)
-    serviceManager = gbinder.ServiceManager("/dev/" + args.BINDER_DRIVER)
+    try:
+        serviceManager = gbinder.ServiceManager("/dev/" + args.BINDER_DRIVER, args.SERVICE_MANAGER_PROTOCOL, args.BINDER_PROTOCOL)
+    except TypeError:
+        serviceManager = gbinder.ServiceManager("/dev/" + args.BINDER_DRIVER)
 
     def response_handler(req, code, flags):
         logging.debug(
index 9887d13713e4e572d3ffe7dacb9fc4a39bc47ab0..a8a5410758b365bcbd6d7e65f4f9641e56372f60 100644 (file)
@@ -275,7 +275,10 @@ class IPlatform:
 
 def get_service(args):
     helpers.drivers.loadBinderNodes(args)
-    serviceManager = gbinder.ServiceManager("/dev/" + args.BINDER_DRIVER)
+    try:
+        serviceManager = gbinder.ServiceManager("/dev/" + args.BINDER_DRIVER, args.SERVICE_MANAGER_PROTOCOL, args.BINDER_PROTOCOL)
+    except TypeError:
+        serviceManager = gbinder.ServiceManager("/dev/" + args.BINDER_DRIVER)
     tries = 1000
 
     remote, status = serviceManager.get_service_sync(SERVICE_NAME)
index 0fe30a76b8e30da0a6621a3613d1ac4374dce6cc..fa5f6f5ea7824fe0abe4eff16aed58e42fbff594 100644 (file)
@@ -42,7 +42,10 @@ class IStatusBarService:
 
 def get_service(args):
     helpers.drivers.loadBinderNodes(args)
-    serviceManager = gbinder.ServiceManager("/dev/" + args.BINDER_DRIVER)
+    try:
+        serviceManager = gbinder.ServiceManager("/dev/" + args.BINDER_DRIVER, args.SERVICE_MANAGER_PROTOCOL, args.BINDER_PROTOCOL)
+    except TypeError:
+        serviceManager = gbinder.ServiceManager("/dev/" + args.BINDER_DRIVER)
     tries = 1000
 
     remote, status = serviceManager.get_service_sync(SERVICE_NAME)
index 0a16031bfc28e16bb8ae807f580d84c165c48445..664fac648cfe9408b7c1dbd76791d6441cb8d181 100644 (file)
@@ -12,7 +12,10 @@ TRANSACTION_packageStateChanged = 2
 
 def add_service(args, userUnlocked, packageStateChanged):
     helpers.drivers.loadBinderNodes(args)
-    serviceManager = gbinder.ServiceManager("/dev/" + args.BINDER_DRIVER)
+    try:
+        serviceManager = gbinder.ServiceManager("/dev/" + args.BINDER_DRIVER, args.SERVICE_MANAGER_PROTOCOL, args.BINDER_PROTOCOL)
+    except TypeError:
+        serviceManager = gbinder.ServiceManager("/dev/" + args.BINDER_DRIVER)
 
     def response_handler(req, code, flags):
         logging.debug(