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):
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
if cfg["waydroid"]["vendor_type"] == "MAINLINE":
if helpers.drivers.probeBinderDriver(args) != 0:
logging.error("Failed to load Binder driver")
- if helpers.drivers.probeAshmemDriver(args) != 0:
- logging.error("Failed to load Ashmem driver")
+ helpers.drivers.probeAshmemDriver(args)
helpers.drivers.loadBinderNodes(args)
set_permissions([
"/dev/" + args.BINDER_DRIVER,
# Load session configs
session_cfg = tools.config.load_session()
-
- # Generate props
- make_prop(args.work + "/waydroid.prop")
# Networking
command = [tools.config.tools_src +
# Mount rootfs
helpers.images.mount_rootfs(args, cfg["waydroid"]["images_path"])
+ helpers.protocol.set_aidl_version(args)
+
# Mount data
helpers.mount.bind(args, session_cfg["session"]["waydroid_data"],
tools.config.defaults["data"])
if which("start"):
command = ["start", "cgroup-lite"]
tools.helpers.run.user(args, command, check=False)
- command = ["umount", "-l", "/sys/fs/cgroup/schedtune"]
- tools.helpers.run.user(args, command, check=False)
+ 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"):