def swipe(dev_id: str, x1: int, y1: int, x2: int, y2: int): """ Method for perform swipe by coordinates """ command = "adb -s {dev_id} shell input swipe {x1} {y1} {x2} {y2}".format(dev_id=dev_id, x1=x1, y1=y1, x2=x2, y2=y2) ADB.exec_adb(command)
def tap(dev_id: str, x: int, y: int): """ Method for perform tap by coordinates """ command = "adb -s {dev_id} shell input tap {x} {y}".format(dev_id=dev_id, x=x, y=y) ADB.exec_adb(command)
def close_package(dev_id: str, package: str): """ Method to close package """ command = "adb -s {dev_id} shell am force-stop {package}".format( dev_id=dev_id, package=package) ADB.exec_adb(command)
def install_app(dev_id, path_apk): """ Method to install package to the device. """ command = "adb -s {dev_id} install {path}".format(dev_id=dev_id, path=path_apk) ADB.exec_adb(command)
def screenshot(dev_id: str, path_save: str): """ Make a screenshot TODO: Test """ command = "adb -s {dev_id} shell screencap {path}".format(dev_id=dev_id, path=path_save) ADB.exec_adb(command)
def send_text(dev_id: str, text: str): """ Method perform typing text NOTE: Before use, make sure input text field in selected """ command = "adb -s {dev_id} shell input text {text}".format( dev_id=dev_id, text=text.strip().replace(" ", "%s")) # %s - Space ADB.exec_adb(command)
def delete(dev_id: str, path_file: str): """ Method to delete file a device :dev_id: Device ID :path_file: Path to file """ command = "adb -s {dev} shell rm {path}".format(dev=dev_id, path=path_file) ADB.exec_adb(command)
def clear_package_cache(dev_id, package): """ Method to clean app cashe :dev_id: device id :package: package name """ command = "adb -s {dev_id} shell pm clear {package}".format( dev_id=dev_id, package=package) ADB.exec_adb(command)
def start_package(dev_id: str, package: str): """ Method to start package TODO: Test """ command = "adb -s {dev_id} shell am startservice {package}".format( dev_id=dev_id, package=package) ADB.exec_adb(command)
def execute_keyevent(dev_id, android_keyevent): """ Method to execute Keyevent :dev_id: Device ID :android_keyevent: Android KeyEvent """ command = "adb -s {dev_id} shell input keyevent {keycode}".format( dev_id=dev_id, keycode=android_keyevent.value.get("key_code")) ADB.exec_adb(command)
def save_meminfo(dev_id: str, path: str, ps=""): """ Method save meminfo into txt files :path: path to save file :ps: By default system, pid or package name TODO: Refactor, add Utility """ filename = "sys" if ps == "" else ps command = "adb -s {dev} shell dumpsys meminfo {ps} > {path}.txt".format( dev=dev_id, ps=ps, path=os.path.join(path, filename)) ADB.exec_adb(command)
def set_screen_brightness(dev_id: str, value): """ Method to change screen brightness on the device in range - 0 to 255 """ if value > 255: value = 255 if value < 0: value = 0 command = "adb -s {dev_id} shell settings put system screen_brightness {value}".format(dev_id=dev_id, value=value) ADB.exec_adb(command)