How to use the uiautomator2.init.Initer function in uiautomator2

To help you get started, we’ve selected a few uiautomator2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openatx / uiautomator2 / uiautomator2 / __main__.py View on Github external
def cmd_init(args):
    serial = args.serial or args.serial_optional
    if serial:
        device = adbutils.adb.device(serial)
        init = Initer(device)
        init.install(args.server)
    else:
        for device in adbutils.adb.iter_device():
            init = Initer(device, loglevel=logging.DEBUG)
            init.install(args.server)
github openatx / uiautomator2 / uiautomator2 / __main__.py View on Github external
def cmd_init(args):
    serial = args.serial or args.serial_optional
    if serial:
        device = adbutils.adb.device(serial)
        init = Initer(device)
        init.install(args.server)
    else:
        for device in adbutils.adb.iter_device():
            init = Initer(device, loglevel=logging.DEBUG)
            init.install(args.server)
github openatx / uiautomator2 / uiautomator2 / init.py View on Github external
self._device.shell(["rm", "/data/local/tmp/minicap"])
        self._device.shell(["rm", "/data/local/tmp/minicap.so"])
        self._device.shell(["rm", "/data/local/tmp/minitouch"])
        self.logger.info("minicap, minitouch removed")
        self._device.shell(["pm", "uninstall", "com.github.uiautomator"])
        self._device.shell(["pm", "uninstall", "com.github.uiautomator.test"])
        self.logger.info("com.github.uiautomator uninstalled, all done !!!")



if __name__ == "__main__":
    import adbutils

    serial = None
    device = adbutils.adb.device(serial)
    init = Initer(device, loglevel=logging.DEBUG)
    print(init.check_install())
github openatx / uiautomator2 / uiautomator2 / __init__.py View on Github external
Raises:
        ConnectError
    """
    adb = adbutils.AdbClient()
    if not serial:
        device = adb.device()
    else:
        device = adbutils.AdbDevice(adb, serial)
    lport = device.forward_port(7912)
    d = connect_wifi('127.0.0.1:' + str(lport))
    d._serial = device.serial
    d._adb_device = device

    if not d.agent_alive or not d.alive:
        initer = Initer(device)
        if not initer.check_install():
            if not init:
                raise RuntimeError(
                    "Device need to be init with command: uiautomator2 init -s "
                    + device.serial)
            initer.install()  # same as run cli: uiautomator2 init
        elif not d.agent_alive:
            warnings.warn("start atx-agent ...", RuntimeWarning)
            # TODO: /data/local/tmp might not be execuable and atx-agent can be somewhere else
            device.shell(
                ["/data/local/tmp/atx-agent", "server", "--nouia", "-d"])
            deadline = time.time() + 3
            while time.time() < deadline:
                if d.agent_alive:
                    break
            else:
github openatx / uiautomator2 / uiautomator2 / __main__.py View on Github external
def cmd_purge(args):
    """ remove minicap, minitouch, uiautomator ... """
    device = adbutils.adb.device(args.serial)
    init = Initer(device, loglevel=logging.DEBUG)
    init.uninstall()