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 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 path: Local path to store the backup file. | 443 path: Local path to store the backup file. |
444 packages: List of to packages to be backed up. | 444 packages: List of to packages to be backed up. |
445 apk: (optional) If set include the .apk files in the archive. | 445 apk: (optional) If set include the .apk files in the archive. |
446 shared: (optional) If set buckup the device's SD card. | 446 shared: (optional) If set buckup the device's SD card. |
447 nosystem: (optional) If set exclude system applications. | 447 nosystem: (optional) If set exclude system applications. |
448 include_all: (optional) If set back up all installed applications and | 448 include_all: (optional) If set back up all installed applications and |
449 |packages| is optional. | 449 |packages| is optional. |
450 timeout: (optional) Timeout per try in seconds. | 450 timeout: (optional) Timeout per try in seconds. |
451 retries: (optional) Number of retries to attempt. | 451 retries: (optional) Number of retries to attempt. |
452 """ | 452 """ |
453 cmd = ['backup', path] | 453 cmd = ['backup', '-f', path] |
454 if apk: | 454 if apk: |
455 cmd.append('-apk') | 455 cmd.append('-apk') |
456 if shared: | 456 if shared: |
457 cmd.append('-shared') | 457 cmd.append('-shared') |
458 if nosystem: | 458 if nosystem: |
459 cmd.append('-nosystem') | 459 cmd.append('-nosystem') |
460 if include_all: | 460 if include_all: |
461 cmd.append('-all') | 461 cmd.append('-all') |
462 if packages: | 462 if packages: |
463 cmd.extend(packages) | 463 cmd.extend(packages) |
(...skipping 71 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 |