import logging
import glob
import shutil
+import time
import platform
import gbinder
import tools.config
make_entry("/dev/pvr_sync")
make_entry("/dev/pmsg0")
make_entry("/dev/dxg")
- make_entry(tools.helpers.gpu.getDriNode(args), "dev/dri/renderD128")
+ render, card = tools.helpers.gpu.getDriNode(args)
+ make_entry(render, "dev/dri/renderD128")
+ make_entry(card, "dev/dri/card0")
for n in glob.glob("/dev/fb*"):
make_entry(n)
props.append("sys.use_memfd=true")
egl = tools.helpers.props.host_get(args, "ro.hardware.egl")
- dri = tools.helpers.gpu.getDriNode(args)
+ dri, _ = tools.helpers.gpu.getDriNode(args)
gralloc = find_hal("gralloc")
if not gralloc:
def status(args):
command = ["lxc-info", "-P", tools.config.defaults["lxc"], "-n", "waydroid", "-sH"]
out = subprocess.run(command, stdout=subprocess.PIPE).stdout.decode('utf-8').strip()
- os.chmod(args.log, 0o666)
return out
+def wait_for_running(args):
+ lxc_status = status(args)
+ timeout = 10
+ while lxc_status != "RUNNING" and timeout > 0:
+ lxc_status = status(args)
+ logging.info(
+ "waiting {} seconds for container to start...".format(timeout))
+ timeout = timeout - 1
+ time.sleep(1)
+ if lxc_status != "RUNNING":
+ raise OSError("container failed to start")
+
def start(args):
command = ["lxc-start", "-P", tools.config.defaults["lxc"],
"-F", "-n", "waydroid", "--", "/init"]
tools.helpers.run.user(args, command, output="background")
+ wait_for_running(args)
+ # Workaround lxc-start changing stdout/stderr permissions to 700
+ os.chmod(args.log, 0o666)
def stop(args):
command = ["lxc-stop", "-P",
tools.helpers.run.user(args, command)
def shell(args):
- if status(args) != "RUNNING":
- logging.error("WayDroid container is {}".format(status(args)))
+ state = status(args)
+ if state == "FROZEN":
+ unfreeze(args)
+ elif state != "RUNNING":
+ logging.error("WayDroid container is {}".format(state))
return
command = ["lxc-attach", "-P", tools.config.defaults["lxc"],
"-n", "waydroid", "--"]
else:
command.append("/system/bin/sh")
subprocess.run(command, env={"PATH": os.environ['PATH'] + ":/system/bin:/vendor/bin"})
+ if state == "FROZEN":
+ freeze(args)
def logcat(args):
- if status(args) != "RUNNING":
- logging.error("WayDroid container is {}".format(status(args)))
+ state = status(args)
+ if state == "FROZEN":
+ unfreeze(args)
+ elif state != "RUNNING":
+ logging.error("WayDroid container is {}".format(state))
return
command = ["lxc-attach", "-P", tools.config.defaults["lxc"],
"-n", "waydroid", "--", "/system/bin/logcat"]
subprocess.run(command)
+ if state == "FROZEN":
+ freeze(args)