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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 cmd = ['ls', path] | 278 cmd = ['ls', path] |
279 lines = self._RunDeviceAdbCmd( | 279 lines = self._RunDeviceAdbCmd( |
280 cmd, timeout=timeout, retries=retries).splitlines() | 280 cmd, timeout=timeout, retries=retries).splitlines() |
281 if lines: | 281 if lines: |
282 return [ParseLine(line) for line in lines] | 282 return [ParseLine(line) for line in lines] |
283 else: | 283 else: |
284 raise device_errors.AdbCommandFailedError( | 284 raise device_errors.AdbCommandFailedError( |
285 cmd, 'path does not specify an accessible directory in the device', | 285 cmd, 'path does not specify an accessible directory in the device', |
286 device_serial=self._device_serial) | 286 device_serial=self._device_serial) |
287 | 287 |
288 def Logcat(self, filter_spec=None, timeout=None): | 288 def Logcat(self, clear=False, dump=False, filter_spec=None, |
| 289 logcat_format=None, timeout=None): |
289 """Get an iterator over the logcat output. | 290 """Get an iterator over the logcat output. |
290 | 291 |
291 Args: | 292 Args: |
292 filter_spec: (optional) Spec to filter the logcat. | 293 filter_spec: (optional) Spec to filter the logcat. |
293 timeout: (optional) Timeout per try in seconds. | 294 timeout: (optional) Timeout per try in seconds. |
294 | 295 |
295 Yields: | 296 Yields: |
296 logcat output line by line. | 297 logcat output line by line. |
297 """ | 298 """ |
298 cmd = ['logcat'] | 299 cmd = ['logcat'] |
| 300 if clear: |
| 301 cmd.append('-c') |
| 302 if dump: |
| 303 cmd.append('-d') |
| 304 if logcat_format: |
| 305 cmd.extend(['-v', logcat_format]) |
299 if filter_spec is not None: | 306 if filter_spec is not None: |
300 cmd.append(filter_spec) | 307 cmd.append(filter_spec) |
301 return self._IterRunDeviceAdbCmd(cmd, timeout) | 308 return self._IterRunDeviceAdbCmd(cmd, timeout) |
302 | 309 |
303 def Forward(self, local, remote, timeout=_DEFAULT_TIMEOUT, | 310 def Forward(self, local, remote, timeout=_DEFAULT_TIMEOUT, |
304 retries=_DEFAULT_RETRIES): | 311 retries=_DEFAULT_RETRIES): |
305 """Forward socket connections from the local socket to the remote socket. | 312 """Forward socket connections from the local socket to the remote socket. |
306 | 313 |
307 Sockets are specified by one of: | 314 Sockets are specified by one of: |
308 tcp:<port> | 315 tcp:<port> |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 """Restarts the adbd daemon with root permissions, if possible. | 486 """Restarts the adbd daemon with root permissions, if possible. |
480 | 487 |
481 Args: | 488 Args: |
482 timeout: (optional) Timeout per try in seconds. | 489 timeout: (optional) Timeout per try in seconds. |
483 retries: (optional) Number of retries to attempt. | 490 retries: (optional) Number of retries to attempt. |
484 """ | 491 """ |
485 output = self._RunDeviceAdbCmd(['root'], timeout, retries) | 492 output = self._RunDeviceAdbCmd(['root'], timeout, retries) |
486 if 'cannot' in output: | 493 if 'cannot' in output: |
487 raise device_errors.AdbCommandFailedError( | 494 raise device_errors.AdbCommandFailedError( |
488 ['root'], output, device_serial=self._device_serial) | 495 ['root'], output, device_serial=self._device_serial) |
OLD | NEW |