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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
431 Args: | 431 Args: |
432 timeout: (optional) Timeout per try in seconds. | 432 timeout: (optional) Timeout per try in seconds. |
433 retries: (optional) Number of retries to attempt. | 433 retries: (optional) Number of retries to attempt. |
434 | 434 |
435 Returns: | 435 Returns: |
436 A list of PIDs as strings. | 436 A list of PIDs as strings. |
437 """ | 437 """ |
438 return [a.strip() for a in | 438 return [a.strip() for a in |
439 self._RunDeviceAdbCmd(['jdwp'], timeout, retries).split('\n')] | 439 self._RunDeviceAdbCmd(['jdwp'], timeout, retries).split('\n')] |
440 | 440 |
441 def Install(self, apk_path, forward_lock=False, reinstall=False, | 441 def Install(self, apk_path, forward_lock=False, allow_downgrade=False, |
442 sd_card=False, timeout=60*2, retries=_DEFAULT_RETRIES): | 442 reinstall=False, sd_card=False, timeout=60*2, |
443 retries=_DEFAULT_RETRIES): | |
443 """Install an apk on the device. | 444 """Install an apk on the device. |
444 | 445 |
445 Args: | 446 Args: |
446 apk_path: Host path to the APK file. | 447 apk_path: Host path to the APK file. |
447 forward_lock: (optional) If set forward-locks the app. | 448 forward_lock: (optional) If set forward-locks the app. |
448 reinstall: (optional) If set reinstalls the app, keeping its data. | 449 reinstall: (optional) If set reinstalls the app, keeping its data. |
449 sd_card: (optional) If set installs on the SD card. | 450 sd_card: (optional) If set installs on the SD card. |
450 timeout: (optional) Timeout per try in seconds. | 451 timeout: (optional) Timeout per try in seconds. |
451 retries: (optional) Number of retries to attempt. | 452 retries: (optional) Number of retries to attempt. |
453 allow_downgrade: (optional) If set, allows for downgrades. | |
jbudorick
2015/12/08 16:44:56
nit: same
rnephew (Reviews Here)
2015/12/08 16:57:57
Done.
| |
452 """ | 454 """ |
453 VerifyLocalFileExists(apk_path) | 455 VerifyLocalFileExists(apk_path) |
454 cmd = ['install'] | 456 cmd = ['install'] |
455 if forward_lock: | 457 if forward_lock: |
456 cmd.append('-l') | 458 cmd.append('-l') |
457 if reinstall: | 459 if reinstall: |
458 cmd.append('-r') | 460 cmd.append('-r') |
459 if sd_card: | 461 if sd_card: |
460 cmd.append('-s') | 462 cmd.append('-s') |
463 if allow_downgrade: | |
464 cmd.append('-d') | |
461 cmd.append(apk_path) | 465 cmd.append(apk_path) |
462 output = self._RunDeviceAdbCmd(cmd, timeout, retries) | 466 output = self._RunDeviceAdbCmd(cmd, timeout, retries) |
463 if 'Success' not in output: | 467 if 'Success' not in output: |
464 raise device_errors.AdbCommandFailedError( | 468 raise device_errors.AdbCommandFailedError( |
465 cmd, output, device_serial=self._device_serial) | 469 cmd, output, device_serial=self._device_serial) |
466 | 470 |
467 def InstallMultiple(self, apk_paths, forward_lock=False, reinstall=False, | 471 def InstallMultiple(self, apk_paths, forward_lock=False, reinstall=False, |
468 sd_card=False, allow_downgrade=False, partial=False, | 472 sd_card=False, allow_downgrade=False, partial=False, |
469 timeout=60*2, retries=_DEFAULT_RETRIES): | 473 timeout=60*2, retries=_DEFAULT_RETRIES): |
470 """Install an apk with splits on the device. | 474 """Install an apk with splits on the device. |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
655 @property | 659 @property |
656 def is_emulator(self): | 660 def is_emulator(self): |
657 return _EMULATOR_RE.match(self._device_serial) | 661 return _EMULATOR_RE.match(self._device_serial) |
658 | 662 |
659 @property | 663 @property |
660 def is_ready(self): | 664 def is_ready(self): |
661 try: | 665 try: |
662 return self.GetState() == _READY_STATE | 666 return self.GetState() == _READY_STATE |
663 except device_errors.CommandFailedError: | 667 except device_errors.CommandFailedError: |
664 return False | 668 return False |
OLD | NEW |