import glob
import signal
import sys
+import uuid
import tools.config
from tools import helpers
from tools import services
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
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"]
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 ""
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(
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(
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)
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)
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(