| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """This module wraps Android's adb tool. | 5 """This module wraps Android's adb tool. |
| 6 | 6 |
| 7 This is a thin wrapper around the adb interface. Any additional complexity | 7 This is a thin wrapper around the adb interface. Any additional complexity |
| 8 should be delegated to a higher level (ex. DeviceUtils). | 8 should be delegated to a higher level (ex. DeviceUtils). |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 cmd = ['ls', path] | 292 cmd = ['ls', path] |
| 293 lines = self._RunDeviceAdbCmd( | 293 lines = self._RunDeviceAdbCmd( |
| 294 cmd, timeout=timeout, retries=retries).splitlines() | 294 cmd, timeout=timeout, retries=retries).splitlines() |
| 295 if lines: | 295 if lines: |
| 296 return [ParseLine(line) for line in lines] | 296 return [ParseLine(line) for line in lines] |
| 297 else: | 297 else: |
| 298 raise device_errors.AdbCommandFailedError( | 298 raise device_errors.AdbCommandFailedError( |
| 299 cmd, 'path does not specify an accessible directory in the device', | 299 cmd, 'path does not specify an accessible directory in the device', |
| 300 device_serial=self._device_serial) | 300 device_serial=self._device_serial) |
| 301 | 301 |
| 302 def Logcat(self, clear=False, dump=False, filter_spec=None, | 302 def Logcat(self, clear=False, dump=False, filter_specs=None, |
| 303 logcat_format=None, timeout=None, retries=_DEFAULT_RETRIES): | 303 logcat_format=None, timeout=None, retries=_DEFAULT_RETRIES): |
| 304 """Get an iterable over the logcat output. | 304 """Get an iterable over the logcat output. |
| 305 | 305 |
| 306 Args: | 306 Args: |
| 307 clear: If true, clear the logcat. | 307 clear: If true, clear the logcat. |
| 308 dump: If true, dump the current logcat contents. | 308 dump: If true, dump the current logcat contents. |
| 309 filter_spec: If set, spec to filter the logcat. | 309 filter_specs: If set, a list of specs to filter the logcat. |
| 310 logcat_format: If set, the format in which the logcat should be output. | 310 logcat_format: If set, the format in which the logcat should be output. |
| 311 Options include "brief", "process", "tag", "thread", "raw", "time", | 311 Options include "brief", "process", "tag", "thread", "raw", "time", |
| 312 "threadtime", and "long" | 312 "threadtime", and "long" |
| 313 timeout: (optional) If set, timeout per try in seconds. If clear or dump | 313 timeout: (optional) If set, timeout per try in seconds. If clear or dump |
| 314 is set, defaults to _DEFAULT_TIMEOUT. | 314 is set, defaults to _DEFAULT_TIMEOUT. |
| 315 retries: (optional) If clear or dump is set, the number of retries to | 315 retries: (optional) If clear or dump is set, the number of retries to |
| 316 attempt. Otherwise, does nothing. | 316 attempt. Otherwise, does nothing. |
| 317 | 317 |
| 318 Yields: | 318 Yields: |
| 319 logcat output line by line. | 319 logcat output line by line. |
| 320 """ | 320 """ |
| 321 cmd = ['logcat'] | 321 cmd = ['logcat'] |
| 322 use_iter = True | 322 use_iter = True |
| 323 if clear: | 323 if clear: |
| 324 cmd.append('-c') | 324 cmd.append('-c') |
| 325 use_iter = False | 325 use_iter = False |
| 326 if dump: | 326 if dump: |
| 327 cmd.append('-d') | 327 cmd.append('-d') |
| 328 use_iter = False | 328 use_iter = False |
| 329 if logcat_format: | 329 if logcat_format: |
| 330 cmd.extend(['-v', logcat_format]) | 330 cmd.extend(['-v', logcat_format]) |
| 331 if filter_spec is not None: | 331 if filter_specs: |
| 332 cmd.append(filter_spec) | 332 cmd.extend(filter_specs) |
| 333 | 333 |
| 334 if use_iter: | 334 if use_iter: |
| 335 return self._IterRunDeviceAdbCmd(cmd, timeout) | 335 return self._IterRunDeviceAdbCmd(cmd, timeout) |
| 336 else: | 336 else: |
| 337 timeout = timeout if timeout is not None else _DEFAULT_TIMEOUT | 337 timeout = timeout if timeout is not None else _DEFAULT_TIMEOUT |
| 338 return self._RunDeviceAdbCmd(cmd, timeout, retries) | 338 return self._RunDeviceAdbCmd(cmd, timeout, retries) |
| 339 | 339 |
| 340 def Forward(self, local, remote, timeout=_DEFAULT_TIMEOUT, | 340 def Forward(self, local, remote, timeout=_DEFAULT_TIMEOUT, |
| 341 retries=_DEFAULT_RETRIES): | 341 retries=_DEFAULT_RETRIES): |
| 342 """Forward socket connections from the local socket to the remote socket. | 342 """Forward socket connections from the local socket to the remote socket. |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 """Restarts the adbd daemon with root permissions, if possible. | 516 """Restarts the adbd daemon with root permissions, if possible. |
| 517 | 517 |
| 518 Args: | 518 Args: |
| 519 timeout: (optional) Timeout per try in seconds. | 519 timeout: (optional) Timeout per try in seconds. |
| 520 retries: (optional) Number of retries to attempt. | 520 retries: (optional) Number of retries to attempt. |
| 521 """ | 521 """ |
| 522 output = self._RunDeviceAdbCmd(['root'], timeout, retries) | 522 output = self._RunDeviceAdbCmd(['root'], timeout, retries) |
| 523 if 'cannot' in output: | 523 if 'cannot' in output: |
| 524 raise device_errors.AdbCommandFailedError( | 524 raise device_errors.AdbCommandFailedError( |
| 525 ['root'], output, device_serial=self._device_serial) | 525 ['root'], output, device_serial=self._device_serial) |
| OLD | NEW |