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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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_specs=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, ring_buffer=None, timeout=None, |
| 304 retries=_DEFAULT_RETRIES): |
304 """Get an iterable over the logcat output. | 305 """Get an iterable over the logcat output. |
305 | 306 |
306 Args: | 307 Args: |
307 clear: If true, clear the logcat. | 308 clear: If true, clear the logcat. |
308 dump: If true, dump the current logcat contents. | 309 dump: If true, dump the current logcat contents. |
309 filter_specs: If set, a list of specs to filter the logcat. | 310 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. | 311 logcat_format: If set, the format in which the logcat should be output. |
311 Options include "brief", "process", "tag", "thread", "raw", "time", | 312 Options include "brief", "process", "tag", "thread", "raw", "time", |
312 "threadtime", and "long" | 313 "threadtime", and "long" |
| 314 ring_buffer: If set, a list of alternate ring buffers to request. |
| 315 Options include "main", "system", "radio", "events", "crash" or "all". |
| 316 The default is equivalent to ["main", "system", "crash"]. |
313 timeout: (optional) If set, timeout per try in seconds. If clear or dump | 317 timeout: (optional) If set, timeout per try in seconds. If clear or dump |
314 is set, defaults to _DEFAULT_TIMEOUT. | 318 is set, defaults to _DEFAULT_TIMEOUT. |
315 retries: (optional) If clear or dump is set, the number of retries to | 319 retries: (optional) If clear or dump is set, the number of retries to |
316 attempt. Otherwise, does nothing. | 320 attempt. Otherwise, does nothing. |
317 | 321 |
318 Yields: | 322 Yields: |
319 logcat output line by line. | 323 logcat output line by line. |
320 """ | 324 """ |
321 cmd = ['logcat'] | 325 cmd = ['logcat'] |
322 use_iter = True | 326 use_iter = True |
323 if clear: | 327 if clear: |
324 cmd.append('-c') | 328 cmd.append('-c') |
325 use_iter = False | 329 use_iter = False |
326 if dump: | 330 if dump: |
327 cmd.append('-d') | 331 cmd.append('-d') |
328 use_iter = False | 332 use_iter = False |
329 if logcat_format: | 333 if logcat_format: |
330 cmd.extend(['-v', logcat_format]) | 334 cmd.extend(['-v', logcat_format]) |
| 335 if ring_buffer: |
| 336 for buffer_name in ring_buffer: |
| 337 cmd.extend(['-b', buffer_name]) |
331 if filter_specs: | 338 if filter_specs: |
332 cmd.extend(filter_specs) | 339 cmd.extend(filter_specs) |
333 | 340 |
334 if use_iter: | 341 if use_iter: |
335 return self._IterRunDeviceAdbCmd(cmd, timeout) | 342 return self._IterRunDeviceAdbCmd(cmd, timeout) |
336 else: | 343 else: |
337 timeout = timeout if timeout is not None else _DEFAULT_TIMEOUT | 344 timeout = timeout if timeout is not None else _DEFAULT_TIMEOUT |
338 return self._RunDeviceAdbCmd(cmd, timeout, retries).splitlines() | 345 return self._RunDeviceAdbCmd(cmd, timeout, retries).splitlines() |
339 | 346 |
340 def Forward(self, local, remote, timeout=_DEFAULT_TIMEOUT, | 347 def Forward(self, local, remote, timeout=_DEFAULT_TIMEOUT, |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 """Restarts the adbd daemon with root permissions, if possible. | 523 """Restarts the adbd daemon with root permissions, if possible. |
517 | 524 |
518 Args: | 525 Args: |
519 timeout: (optional) Timeout per try in seconds. | 526 timeout: (optional) Timeout per try in seconds. |
520 retries: (optional) Number of retries to attempt. | 527 retries: (optional) Number of retries to attempt. |
521 """ | 528 """ |
522 output = self._RunDeviceAdbCmd(['root'], timeout, retries) | 529 output = self._RunDeviceAdbCmd(['root'], timeout, retries) |
523 if 'cannot' in output: | 530 if 'cannot' in output: |
524 raise device_errors.AdbCommandFailedError( | 531 raise device_errors.AdbCommandFailedError( |
525 ['root'], output, device_serial=self._device_serial) | 532 ['root'], output, device_serial=self._device_serial) |
OLD | NEW |