def delete_last_file(self, device: Device): last_file_result = device.shell(ADBShell_GetLastFileCommand) last_file_result.strip() last_file_full_path = f"{DEFAULT_VIDEO_DIR}/{last_file_result}".strip() self._run_shell( device, f"mv {last_file_full_path} {last_file_full_path}_DISCARDED") print(last_file_full_path)
def get_architecture(device: Device): cpu = device.get_properties()['ro.product.cpu.abi'] if "arm64" in cpu: return "arm64" if "x86_64" in cpu: return "x86_64" if "arm" in cpu: return "arm" if "x86" in cpu: return "x86" return ""
def perform_cmd(device: Device, command: str, root: bool = False, timeout: int = None): if root: command = "su -c {}".format(command) try: return device.shell(command, timeout=timeout) except: pass return ""
def save_last_file(self, device: Device): last_file_result = device.shell(ADBShell_GetLastFileCommand) last_file_result.strip() last_file_full_path = f"{DEFAULT_VIDEO_DIR}/{last_file_result}".strip() self._run_shell( device, f"{ADBShell_CreateSaveDirCommand} {self.get_save_dir()}") self._run_shell(device, f"cp {last_file_full_path} {self.get_save_dir()}") print(last_file_full_path)
def devices(self, state=None): cmd = "host:devices" result = self._execute_cmd(cmd) devices = [] for line in result.split('\n'): if not line: break tokens = line.split() if state and len(tokens) > 1 and tokens[1] != state: continue devices.append(Device(self, tokens[0])) return devices
def __init__(self, client, serial, status): Device.__init__(self, client, serial) self.status = status
def click(self, device: Device) -> None: device.shell(f"input tap {self.position.x} {self.position.y}") return None
def get_device_model(device: Device): return "{} {}".format( device.get_properties().get("ro.vendor.product.manufacturer", "Unknown"), device.get_properties().get("ro.vendor.product.model", "Unkown"))
def monitor(self, device: Device): serial = device.get_serial_no() output_filename = f"scrcpy-{serial}.out" subprocess.Popen( f"scrcpy --serial {serial} -b 2M -m800 --stay-awake > {output_filename} 2>&1", shell=True)
def _run_shell(self, device: Device, shellcmd: str): if self.args.dry_run: print(shellcmd) else: return device.shell(shellcmd)
def get_device_model(device: Device): return "{}_A{}".format( device.get_properties().get("ro.product.model", "Unknown").replace(" ", ""), device.get_properties().get("ro.build.version.release", "Unknown"))
def get_device_model(device: Device): return "{} {}".format( device.get_properties()["ro.vendor.product.manufacturer"], device.get_properties()["ro.vendor.product.model"])