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 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 | 535 |
536 Args: | 536 Args: |
537 timeout: (optional) Timeout per try in seconds. | 537 timeout: (optional) Timeout per try in seconds. |
538 retries: (optional) Number of retries to attempt. | 538 retries: (optional) Number of retries to attempt. |
539 """ | 539 """ |
540 output = self._RunDeviceAdbCmd(['root'], timeout, retries) | 540 output = self._RunDeviceAdbCmd(['root'], timeout, retries) |
541 if 'cannot' in output: | 541 if 'cannot' in output: |
542 raise device_errors.AdbCommandFailedError( | 542 raise device_errors.AdbCommandFailedError( |
543 ['root'], output, device_serial=self._device_serial) | 543 ['root'], output, device_serial=self._device_serial) |
544 | 544 |
| 545 def Emu(self, cmd, timeout=_DEFAULT_TIMEOUT, |
| 546 retries=_DEFAULT_RETRIES): |
| 547 """Runs an emulator console command. |
| 548 |
| 549 See http://developer.android.com/tools/devices/emulator.html#console |
| 550 |
| 551 Args: |
| 552 cmd: The command to run on the emulator console. |
| 553 timeout: (optional) Timeout per try in seconds. |
| 554 retries: (optional) Number of retries to attempt. |
| 555 |
| 556 Returns: |
| 557 The output of the emulator console command. |
| 558 """ |
| 559 if isinstance(cmd, basestring): |
| 560 cmd = [cmd] |
| 561 return self._RunDeviceAdbCmd(['emu'] + cmd, timeout, retries) |
| 562 |
545 @property | 563 @property |
546 def is_emulator(self): | 564 def is_emulator(self): |
547 return _EMULATOR_RE.match(self._device_serial) | 565 return _EMULATOR_RE.match(self._device_serial) |
548 | 566 |
549 @property | 567 @property |
550 def is_ready(self): | 568 def is_ready(self): |
551 try: | 569 try: |
552 return self.GetState() == _READY_STATE | 570 return self.GetState() == _READY_STATE |
553 except device_errors.CommandFailedError: | 571 except device_errors.CommandFailedError: |
554 return False | 572 return False |
555 | 573 |
OLD | NEW |