def chmod(path, mode):
if os.path.exists(path):
command = ["chmod", mode, "-R", path]
- tools.helpers.run.root(args, command, check=False)
+ tools.helpers.run.user(args, command, check=False)
# Nodes list
if not perm_list:
# Networking
command = [tools.config.tools_src +
"/data/scripts/waydroid-net.sh", "start"]
- tools.helpers.run.root(args, command, check=False)
+ tools.helpers.run.user(args, command, check=False)
# Sensors
- tools.helpers.run.root(
+ tools.helpers.run.user(
args, ["waydroid-sensord", "/dev/" + args.HWBINDER_DRIVER], output="background")
# Mount rootfs
# Cgroup hacks
if which("start"):
command = ["start", "cgroup-lite"]
- tools.helpers.run.root(args, command, check=False)
+ tools.helpers.run.user(args, command, check=False)
helpers.mount.umount_all(args, "/sys/fs/cgroup/schedtune")
#TODO: remove NFC hacks
if which("stop"):
command = ["stop", "nfcd"]
- tools.helpers.run.root(args, command, check=False)
+ tools.helpers.run.user(args, command, check=False)
# Set permissions
set_permissions()
# Networking
command = [tools.config.tools_src +
"/data/scripts/waydroid-net.sh", "stop"]
- tools.helpers.run.root(args, command, check=False)
+ tools.helpers.run.user(args, command, check=False)
#TODO: remove NFC hacks
if which("start"):
command = ["start", "nfcd"]
- tools.helpers.run.root(args, command, check=False)
+ tools.helpers.run.user(args, command, check=False)
# Sensors
if which("waydroid-sensord"):
command = ["pidof", "waydroid-sensord"]
- pid = tools.helpers.run.root(args, command, check=False, output_return=True)
+ pid = tools.helpers.run.user(args, command, check=False, output_return=True)
if pid:
command = ["kill", "-9", pid]
- tools.helpers.run.root(args, command, check=False)
+ tools.helpers.run.user(args, command, check=False)
else:
logging.error("WayDroid container is {}".format(status))
if not isBinderfsLoaded(args):
devices = ','.join(binder_dev_nodes)
command = ["modprobe", "binder_linux", "devices=\"{}\"".format(devices)]
- output = tools.helpers.run.root(args, command, check=False, output_return=True)
+ output = tools.helpers.run.user(args, command, check=False, output_return=True)
if output:
logging.error("Failed to load binder driver for devices: {}".format(devices))
logging.error(output.strip())
if isBinderfsLoaded(args):
command = ["mkdir", "-p", "/dev/binderfs"]
- tools.helpers.run.root(args, command, check=False)
+ tools.helpers.run.user(args, command, check=False)
command = ["mount", "-t", "binder", "binder", "/dev/binderfs"]
- tools.helpers.run.root(args, command, check=False)
+ tools.helpers.run.user(args, command, check=False)
command = ["ln", "-s"]
command.extend(glob.glob("/dev/binderfs/*"))
command.append("/dev/")
- tools.helpers.run.root(args, command, check=False)
+ tools.helpers.run.user(args, command, check=False)
else:
return -1
def probeAshmemDriver(args):
if not os.path.exists("/dev/ashmem"):
command = ["modprobe", "ashmem_linux"]
- output = tools.helpers.run.root(args, command, check=False, output_return=True)
+ output = tools.helpers.run.user(args, command, check=False, output_return=True)
if output:
logging.error("Failed to load ashmem driver")
logging.error(output.strip())
config_path = tools.config.tools_src + "/data/configs/" + config_file
command = ["mkdir", "-p", lxc_path]
- tools.helpers.run.root(args, command)
+ tools.helpers.run.user(args, command)
command = ["cp", "-fpr", config_path, lxc_path + "/config"]
- tools.helpers.run.root(args, command)
+ tools.helpers.run.user(args, command)
command = ["sed", "-i", "s/LXCARCH/{}/".format(platform.machine()), lxc_path + "/config"]
- tools.helpers.run.root(args, command)
+ tools.helpers.run.user(args, command)
nodes = generate_nodes_lxc_config(args)
config_nodes_tmp_path = args.work + "/config_nodes"
config_nodes.write(node + "\n")
config_nodes.close()
command = ["mv", config_nodes_tmp_path, lxc_path]
- tools.helpers.run.root(args, command)
+ tools.helpers.run.user(args, command)
def make_base_props(args):
for lib in ["lib", "lib64"]:
hal_file = "/vendor/" + lib + "/hw/" + hardware + "." + prop + ".so"
command = ["readlink", "-f", hal_file]
- hal_file_path = tools.helpers.run.root(args, command, output_return=True).strip()
+ hal_file_path = tools.helpers.run.user(args, command, output_return=True).strip()
if os.path.isfile(hal_file_path):
hal_prop = re.sub(".*" + hardware + ".", "", hal_file_path)
hal_prop = re.sub(".so", "", hal_prop)
shutil.copy(filename, tools.config.defaults["host_perms"])
def status(args):
- command = ["sudo", "lxc-info", "-P", tools.config.defaults["lxc"], "-n", "waydroid", "-sH"]
+ command = ["lxc-info", "-P", tools.config.defaults["lxc"], "-n", "waydroid", "-sH"]
return subprocess.run(command, stdout=subprocess.PIPE).stdout.decode('utf-8').strip()
def start(args):
command = ["lxc-start", "-P", tools.config.defaults["lxc"],
"-F", "-n", "waydroid", "--", "/init"]
- tools.helpers.run.root(args, command, output="background")
+ tools.helpers.run.user(args, command, output="background")
def stop(args):
command = ["lxc-stop", "-P",
tools.config.defaults["lxc"], "-n", "waydroid", "-k"]
- tools.helpers.run.root(args, command)
+ tools.helpers.run.user(args, command)
def freeze(args):
command = ["lxc-freeze", "-P", tools.config.defaults["lxc"], "-n", "waydroid"]
- tools.helpers.run.root(args, command)
+ tools.helpers.run.user(args, command)
def unfreeze(args):
command = ["lxc-unfreeze", "-P",
tools.config.defaults["lxc"], "-n", "waydroid"]
- tools.helpers.run.root(args, command)
+ tools.helpers.run.user(args, command)
def shell(args):
if status(args) != "RUNNING":
if os.path.exists(path):
continue
if create_folders:
- tools.helpers.run.root(args, ["mkdir", "-p", path])
+ tools.helpers.run.user(args, ["mkdir", "-p", path])
else:
raise RuntimeError("Mount failed, folder does not exist: " +
path)
# Actually mount the folder
- tools.helpers.run.root(args, ["mount", "-o", "bind", source, destination])
+ tools.helpers.run.user(args, ["mount", "-o", "bind", source, destination])
# Verify, that it has worked
if not ismount(destination):
if create_folders:
dir = os.path.dirname(destination)
if not os.path.isdir(dir):
- tools.helpers.run.root(args, ["mkdir", "-p", dir])
+ tools.helpers.run.user(args, ["mkdir", "-p", dir])
- tools.helpers.run.root(args, ["touch", destination])
+ tools.helpers.run.user(args, ["touch", destination])
# Mount
- tools.helpers.run.root(args, ["mount", "-o", "bind", source,
+ tools.helpers.run.user(args, ["mount", "-o", "bind", source,
destination])
Umount all folders, that are mounted inside a given folder.
"""
for mountpoint in umount_all_list(folder):
- tools.helpers.run.root(args, ["umount", mountpoint])
+ tools.helpers.run.user(args, ["umount", mountpoint])
if ismount(mountpoint):
raise RuntimeError("Failed to umount: " + mountpoint)
# Check/create folders
if not os.path.exists(destination):
if create_folders:
- tools.helpers.run.root(args, ["mkdir", "-p", destination])
+ tools.helpers.run.user(args, ["mkdir", "-p", destination])
else:
raise RuntimeError("Mount failed, folder does not exist: " +
destination)
# Actually mount the folder
- tools.helpers.run.root(args, ["mount", source, destination])
+ tools.helpers.run.user(args, ["mount", source, destination])
if readonly:
- tools.helpers.run.root(args, ["mount", "-o", "remount,ro", source, destination])
+ tools.helpers.run.user(args, ["mount", "-o", "remount,ro", source, destination])
# Verify, that it has worked
if not ismount(destination):