Ejemplo n.º 1
0
    if not validateArgs(options):
        return None
    searchStr = './/node'
    foundNode = None

    if "element" in options:
        lowerSearch = options.get("element").lower()
        for node in uiRoot.findall(searchStr):
            if any(lowerSearch in elem.lower()
                   for elem in node.attrib.values()):
                foundNode = node
                break

    if "property" in options:
        searchProp = options.get("property")
        lowerSearchValue = options.get("value").lower()
        for node in uiRoot.findall(searchStr):
            if searchProp in node.attrib.keys(
            ) and lowerSearchValue in node.attrib.get(searchProp).lower():
                foundNode = node
                break

    if foundNode == None:
        return None
    return midOfBounds(foundNode.attrib.get("bounds"))


if __name__ == "__main__":
    options, uiRoot = setUp()
    print(midOf(options, uiRoot))
Ejemplo n.º 2
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)
Ejemplo n.º 3
0
#!/usr/bin/env python3
from simplifier import setUp
from xml.etree.cElementTree import tostring as XmlToString

if __name__ == "__main__":
    options, xml = setUp(ui_required=True)
    print(XmlToString(xml))