| 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 | |
| 563 @property | 545 @property |
| 564 def is_emulator(self): | 546 def is_emulator(self): |
| 565 return _EMULATOR_RE.match(self._device_serial) | 547 return _EMULATOR_RE.match(self._device_serial) |
| 566 | 548 |
| 567 @property | 549 @property |
| 568 def is_ready(self): | 550 def is_ready(self): |
| 569 try: | 551 try: |
| 570 return self.GetState() == _READY_STATE | 552 return self.GetState() == _READY_STATE |
| 571 except device_errors.CommandFailedError: | 553 except device_errors.CommandFailedError: |
| 572 return False | 554 return False |
| 573 | 555 |
| OLD | NEW |