def perform_swipe(startX, startY, endX, endY, device): adbCommand([ "shell", "input", "swipe", str(startX), str(startY), str(endX), str(endY) ], device)
def modify_forcertl(new_value, device): # adb shell settings put global debug.force_rtl 1.0 adbSetValue("global", "debug.force_rtl", new_value, device) prop_value = "false" if new_value != "0": prop_value = "true" adbCommand(["shell", "setprop", "debug.force_rtl", prop_value], device, False) # print("SET\nProp value: [{}]\nGlobal value: [{}]".format(prop_value, new_value)) force_refresh(device)
def tap_element(options, root): mid = midOf(options, root) if mid != None: adbCommand( ["shell", "input", "tap", str(mid.get("x")), str(mid.get("y"))], device=options.get("device"), output=False) else: print("Element not found")
def force_refresh(device): # force a refresh size # ----RATTLE---- # output_size = getScreenSize(device = device) # size_string = "{}x{}".format(int(output_size["width"] / 0.59), int(output_size["height"])) # adbCommand(["shell", "wm", "size", size_string], device, False) # size_string = "{}x{}".format(int(output_size["width"]), int(output_size["height"])) # adbCommand(["shell", "wm", "size", "reset"], device, False) # ------------- # adbCommand(["adb", "shell", "settings", "put", "system", "user_rotation", "3"], device) # landscape # adbCommand(["adb", "shell", "settings", "put", "system", "user_rotation", "0"], device) # portrait adbCommand(getOption("locale"), device) options = {"element": "dragHandle", "device": device} tap_element(options, parseXML(options=options)) press_button("KEYCODE_BACK", device)
def modify_density(new_value, device): adbCommand(["shell", "wm", "density", new_value], device)
def get_forcertl(device): prop_value = adbCommand(["shell", "getprop", "debug.force_rtl"], device) global_value = str(adbGetValue("global", "debug.force_rtl", device)) global_value = global_value.replace(".0", "") # print("GET\nProp value: [{}]\nGlobal value: [{}]".format(prop_value, global_value)) return global_value
from simplifier import setUp from common import adbCommand import re """ adb shell dumpsys window displays example output: ... mCurrentFocus=Window{5fb753e u0 com.android.vending/com.android.vending.AssetBrowserActivity} ... """ currentactivity_usage = """ currentactivity.py [-s __DEVICE__] """ def extract_activity(data): currentWindow = re.search("mCurrentFocus=.*\{.*\}", data) return currentWindow.group().replace("{", "").replace("}", "").split(" ")[2] if __name__ == "__main__": options = setUp(ui_required=False) device = options.get("device") print( extract_activity( adbCommand(["shell", "dumpsys", "window", "displays"], device)))
output=True) return int(night_mode) def change_required(device, argument, read_state=get_state): if argument == None: return True if argument not in ["dark", "light"]: raise ValueError("Unknown parameter: " + argument) state = read_state(device) return (state == 1 and argument == "dark") or (state == 2 and argument == "light") if __name__ == "__main__": options = setUp(ui_required=False) device = options.get("device") args = sys.argv del args[0] argument = validateArgs(args) changeRequired = change_required(device, argument) if changeRequired: adbCommand(getOption("display"), device) uiRoot = parseXML(options=options) options["element"] = "switchWidget" tap_element(options, uiRoot) press_button("KEYCODE_BACK", device)
# https://stackoverflow.com/a/68655882/932052 screen_options={ "developer":"com.android.settings.APPLICATION_DEVELOPMENT_SETTINGS", "dark": "android.settings.DARK_THEME_SETTINGS", "colour_inversion": "com.android.settings.ACCESSIBILITY_COLOR_SPACE_SETTINGS", "display": "android.settings.DISPLAY_SETTINGS", "bluetooth": "android.settings.BLUETOOTH_SETTINGS", "wifi":"android.settings.WIFI_SETTINGS", "airplane": "android.settings.AIRPLANE_MODE_SETTINGS", "accessibility":"android.settings.ACCESSIBILITY_SETTINGS", "locale": "android.settings.LOCALE_SETTINGS", } activity_screens={ "talkback":"com.google.android.marvin.talkback/com.android.talkback.TalkBackPreferencesActivity", # "talkback_dev": "com.google.android.marvin.talkback/com.google.android.accessibility.talkback.TalkBackDeveloperPreferencesActivity", } def getOption(option): if option in screen_options: return ["shell", "am", "start", "-a", screen_options[option]] if option in activity_screens: return ["shell", "am", "start", "-n", activity_screens[option]] if __name__ == "__main__": options = setUp(ui_required = False) device = options.get("device") args = sys.argv del args[0] adbCommand(getOption(validateArgs(args)), device)
def read_settings(settings_name, device): return convert_settings_to_dictionary( adbCommand(["shell", "settings", "list", settings_name], device))
def get_show_layout(device): value = adbCommand(["shell", "getprop", "debug.layout"], device) if value == None or value == "": value = "false" return value
def modify_show_layout(new_value, device): adbCommand(["shell", "setprop", "debug.layout", new_value], device) sysprops_transaction(device)
def get_screen_settings(device): return adbCommand(["shell", "dumpsys", "power"], device)