Beispiel #1
0
 def test_value_changed_if_different(self):
     self.assertFalse(self.hasBeenRead)
     self.assertFalse(self.hasBeenChanged)
     result = alternator(self.methodRead, self.lamda_dictionary, 7)
     self.assertTrue(result)
     self.assertTrue(self.hasBeenRead)
     self.assertTrue(self.hasBeenChanged)
     self.assertEqual(self.valueSet, 7)
Beispiel #2
0
 def test_value_is_read_throws_if_null(self):
     try:
         result = alternator(self.methodReadNullReturn,
                             self.lamda_dictionary)
         self.assertFalse(self.hasBeenChanged)
         self.fail("This should not be passing: ValueError expected")
     except Exception as e:
         self.assertTrue(e.__class__ is RuntimeError)
     self.assertFalse(self.hasBeenChanged)
Beispiel #3
0
 def test_value_changed_always_when_no_value_sent(self):
     self.valueSet = 5
     self.assertFalse(self.hasBeenRead)
     self.assertFalse(self.hasBeenChanged)
     result = alternator(self.methodReadDynamic, self.lamda_dictionary)
     self.assertTrue(result)
     self.assertTrue(self.hasBeenRead)
     self.assertTrue(self.hasBeenChanged)
     self.assertEqual(self.valueSet, 7)
     self.assertEqual(self.methodCallCount, 1)
     self.hasBeenRead = False
     self.hasBeenChanged = False
     self.assertFalse(self.hasBeenRead)
     self.assertFalse(self.hasBeenChanged)
     result = alternator(self.methodReadDynamic, self.lamda_dictionary)
     self.assertTrue(result)
     self.assertTrue(self.hasBeenRead)
     self.assertTrue(self.hasBeenChanged)
     self.assertEqual(self.valueSet, 5)
     self.assertEqual(self.methodCallCount, 2)
Beispiel #4
0
            raise ValueError("Illegal combination of arguments. Usage: " + density_usage)
        if arguments[0] not in valid_args:
            raise ValueError("Illegal argument: " + arguments[0] + ". Usage: " + density_usage)
        return valid_args[arguments[0]]
    return None

def modify_density(new_value, device):
    adbCommand(["shell", "wm", "density", new_value], device)

def get_density(device):
    value = adbGetValue("secure", "display_density_forced", device)
    if value not in density_dictionary(device):
        value = "440"
    return value

def density_dictionary(device):
    return {
         "374": lambda: modify_density("374", device),
         "440": lambda: modify_density("440", device),
         "490": lambda: modify_density("490", device),
         "540": lambda: modify_density("540", device)
    }

if __name__ == "__main__":
    options = setUp(ui_required = False)
    device = options.get("device")
    args = sys.argv
    del args[0]
    direction = validateArgs(args)
    alternator(lambda: get_density(device), density_dictionary(device), direction)
Beispiel #5
0
    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 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


def forcertl_dictionary(device):
    return {
        "1": lambda: modify_forcertl("1", device),
        "0": lambda: modify_forcertl("0", device)
    }


if __name__ == "__main__":
    options = setUp(ui_required=False)
    device = options.get("device")
    args = sys.argv
    del args[0]
    direction = validateArgs(args)
    alternator(lambda: get_forcertl(device), forcertl_dictionary(device),
               direction)
Beispiel #6
0
show_touch_usage = """
  show_touch.py [-s __DEVICE__] [-t, --toggle, --on, --off]
"""


def modify_touch(new_value, device):
    adbSetValue("system", "show_touches", new_value, device)
    # technically do not need unless you are already on the settings screen
    sysprops_transaction(device)


def get_touch_state(device):
    return adbGetValue("system", "show_touches", device)


def touch_dictionary(device):
    return {
        "0": lambda: modify_touch("0", device),
        "1": lambda: modify_touch("1", device)
    }


if __name__ == "__main__":
    options = setUp(ui_required=False)
    device = options.get("device")
    args = sys.argv
    del args[0]
    desired_value = validateArgs(args, show_touch_usage)
    alternator(lambda: get_touch_state(device), touch_dictionary(device),
               desired_value)
Beispiel #7
0
        device)


def turn_on_scanner(device):
    turn_on_defaults(device)
    adbSetValue(
        "secure", "enabled_accessibility_services",
        "com.google.android.apps.accessibility.auditor/com.google.android.apps.accessibility.auditor.ScannerService:com.android.talkback/com.google.android.marvin.talkback.TalkBackService",
        device)


def accessibility_dictionary(device):
    return {
        "com.android.talkback/com.google.android.marvin.talkback.TalkBackService":
        lambda: turn_off(device),
        "com.google.android.marvin.talkback/com.google.android.marvin.talkback.TalkBackService:com.balsdon.accessibilityDeveloperService/.AccessibilityDeveloperService":
        lambda: turn_on_screen_reader(device),
        "com.google.android.apps.accessibility.auditor/com.google.android.apps.accessibility.auditor.ScannerService:com.android.talkback/com.google.android.marvin.talkback.TalkBackService":
        lambda: turn_on_scanner(device)
    }


if __name__ == "__main__":
    options = setUp(ui_required=False)
    device = options.get("device")
    args = sys.argv
    del args[0]
    service = validateArgs(args)
    alternator(lambda: get_accessibility_state(device),
               accessibility_dictionary(device), service)
Beispiel #8
0
            return None
        if "-l" in arguments or "--landscape" in arguments:
            return 1
        if "-p" in arguments or "--portrait" in arguments:
            return 0
        raise ValueError("Illegal argument: " + arguments[0] + ". Usage: " + flip_usage)
    return None

def modifier(new_value):
    adbSetValue("system", "user_rotation", new_value, device)

def get_orientation(device):
    return int(adbGetValue("system", "user_rotation", device))

def flip_dictionary(device):
    return {
         0: lambda: modifier("0"), #change from LANDSCAPE to PORTRAIT
         1: lambda: modifier("1")  #change from PORTRAIT to LANDSCAPE
    }

if __name__ == "__main__":
    options = setUp(ui_required = False)
    device = options.get("device")
    args = sys.argv
    del args[0]
    direction = validateArgs(args)
    #always required
    adbSetValue("system", "accelerometer_rotation", "0", device)

    alternator(lambda: get_orientation(device), flip_dictionary(device), direction)
Beispiel #9
0
        if len(arguments) == 0:
            return None
        if len(arguments) > 1:
            raise ValueError("Illegal combination of arguments. Usage: " + fontscale_usage)
        if arguments[0] not in valid_args:
            raise ValueError("Illegal argument: " + arguments[0] + ". Usage: " + fontscale_usage)
        return valid_args[arguments[0]]
    return None

def modify_font_scale(new_value, device):
    adbSetValue("system", "font_scale", new_value, device)

def get_font_scale(device):
    return float(adbGetValue("system", "font_scale", device))

def font_scale_dictionary(device):
    return {
         0.85: lambda: modify_font_scale("0.85", device),
         1.0:  lambda: modify_font_scale("1.0", device),
         1.15: lambda: modify_font_scale("1.15", device),
         1.13: lambda: modify_font_scale("1.13", device)
    }

if __name__ == "__main__":
    options = setUp(ui_required = False)
    device = options.get("device")
    args = sys.argv
    del args[0]
    direction = validateArgs(args)
    alternator(lambda: get_font_scale(device), font_scale_dictionary(device), direction)
Beispiel #10
0
 def test_value_not_changed_if_same(self):
     self.assertFalse(self.hasBeenRead)
     result = alternator(self.methodRead, self.lamda_dictionary, 5)
     self.assertFalse(result)
     self.assertTrue(self.hasBeenRead)
     self.assertFalse(self.hasBeenChanged)
Beispiel #11
0
 def test_value_is_read(self):
     result = alternator(self.methodRead, self.lamda_dictionary, 5)
     self.assertTrue(self.hasBeenRead)
Beispiel #12
0

# setprop debug.layout true
def modify_show_layout(new_value, device):
    adbCommand(["shell", "setprop", "debug.layout", new_value], device)
    sysprops_transaction(device)


def get_show_layout(device):
    value = adbCommand(["shell", "getprop", "debug.layout"], device)
    if value == None or value == "":
        value = "false"
    return value


def show_layout_dictionary(device):
    return {
        "true": lambda: modify_show_layout("true", device),
        "false": lambda: modify_show_layout("false", device)
    }


if __name__ == "__main__":
    options = setUp(ui_required=False)
    device = options.get("device")
    args = sys.argv
    del args[0]
    desired_value = validateArgs(args)
    alternator(lambda: get_show_layout(device), show_layout_dictionary(device),
               desired_value)
Beispiel #13
0
        return valid_args[arguments[0]]
    raise ValueError("Unknown argument\n    " + arguments[0] + "\n" + usage)


def modify_animations(new_value, device):
    adbSetValue("global", "window_animation_scale", new_value, device)
    adbSetValue("global", "transition_animation_scale", new_value, device)
    adbSetValue("global", "animator_duration_scale", new_value, device)
    sysprops_transaction(device)  # TODO: CHECK!!


def get_animation_state(device):
    return float(adbGetValue("global", "window_animation_scale", device))


def animation_dictionary(device):
    return {
        0.0: lambda: modify_animations("0.0", device),
        1.0: lambda: modify_animations("1.0", device)
    }


if __name__ == "__main__":
    options = setUp(ui_required=False)
    device = options.get("device")
    args = sys.argv
    del args[0]
    desired_value = validateArgs(args)
    alternator(lambda: get_animation_state(device),
               animation_dictionary(device), desired_value)