How to use the mobly.controllers.android_device_lib.adb function in mobly

To help you get started, we’ve selected a few mobly 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 google / mobly / mobly / controllers / android_device_lib / services / logcat.py View on Github external
def _start(self):
        """The actual logic of starting logcat."""
        self._enable_logpersist()
        if self._config.output_file_path:
            self._close_logcat_file()
            self.adb_logcat_file_path = self._config.output_file_path
        if not self.adb_logcat_file_path:
            f_name = self._ad.generate_filename(self.OUTPUT_FILE_TYPE,
                                                extension_name='txt')
            logcat_file_path = os.path.join(self._ad.log_path, f_name)
            self.adb_logcat_file_path = logcat_file_path
        utils.create_dir(os.path.dirname(self.adb_logcat_file_path))
        cmd = '"%s" -s %s logcat -v threadtime -T 1 %s >> "%s"' % (
            adb.ADB, self._ad.serial, self._config.logcat_params,
            self.adb_logcat_file_path)
        process = utils.start_standing_subprocess(cmd, shell=True)
        self._adb_logcat_process = process
github google / mobly / mobly / utils.py View on Github external
"""Gets a host port number available for adb forward.

    Returns:
        An integer representing a port number on the host available for adb
        forward.

    Raises:
        Error: when no port is found after MAX_PORT_ALLOCATION_RETRY times.
    """
    # Only import adb module if needed.
    from mobly.controllers.android_device_lib import adb
    for _ in range(MAX_PORT_ALLOCATION_RETRY):
        port = portpicker.PickUnusedPort()
        # Make sure adb is not using this port so we don't accidentally
        # interrupt ongoing runs by trying to bind to the port.
        if port not in adb.list_occupied_adb_ports():
            return port
    raise Error('Failed to find available port after {} retries'.format(
        MAX_PORT_ALLOCATION_RETRY))
github google / mobly / mobly / controllers / android_device_lib / snippet_client.py View on Github external
def _do_start_app(self, launch_cmd):
        adb_cmd = [adb.ADB]
        if self._adb.serial:
            adb_cmd += ['-s', self._adb.serial]
        adb_cmd += ['shell', launch_cmd]
        return utils.start_standing_subprocess(adb_cmd, shell=False)