- 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):
- command = ["chmod", mode, "-R", path]
- tools.helpers.run.user(args, command, check=False)
-
- # Nodes list
- if not perm_list:
- perm_list = [
- "/dev/ashmem",
-
- # sw_sync for HWC
- "/dev/sw_sync",
- "/sys/kernel/debug/sync/sw_sync",
-
- # Media
- "/dev/Vcodec",
- "/dev/MTK_SMI",
- "/dev/mdp_sync",
- "/dev/mtk_cmdq",
-
- # Graphics
- "/dev/dri",
- "/dev/graphics",
- "/dev/pvr_sync",
- "/dev/ion",
- ]
-
- # Framebuffers
- perm_list.extend(glob.glob("/dev/fb*"))
- # Videos
- perm_list.extend(glob.glob("/dev/video*"))
-
- 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()