Chromium Code Reviews| 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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 383 timeout: (optional) Timeout per try in seconds. | 383 timeout: (optional) Timeout per try in seconds. |
| 384 retries: (optional) Number of retries to attempt. | 384 retries: (optional) Number of retries to attempt. |
| 385 | 385 |
| 386 Returns: | 386 Returns: |
| 387 A list of PIDs as strings. | 387 A list of PIDs as strings. |
| 388 """ | 388 """ |
| 389 return [a.strip() for a in | 389 return [a.strip() for a in |
| 390 self._RunDeviceAdbCmd(['jdwp'], timeout, retries).split('\n')] | 390 self._RunDeviceAdbCmd(['jdwp'], timeout, retries).split('\n')] |
| 391 | 391 |
| 392 def Install(self, apk_path, forward_lock=False, reinstall=False, | 392 def Install(self, apk_path, forward_lock=False, reinstall=False, |
| 393 sd_card=False, timeout=60*2, retries=_DEFAULT_RETRIES): | 393 sd_card=False, timeout=60*2, retries=_DEFAULT_RETRIES, |
| 394 split_paths=None): | |
| 394 """Install an apk on the device. | 395 """Install an apk on the device. |
| 395 | 396 |
| 396 Args: | 397 Args: |
| 397 apk_path: Host path to the APK file. | 398 apk_path: Host path to the APK file. |
| 398 forward_lock: (optional) If set forward-locks the app. | 399 forward_lock: (optional) If set forward-locks the app. |
| 399 reinstall: (optional) If set reinstalls the app, keeping its data. | 400 reinstall: (optional) If set reinstalls the app, keeping its data. |
| 400 sd_card: (optional) If set installs on the SD card. | 401 sd_card: (optional) If set installs on the SD card. |
| 401 timeout: (optional) Timeout per try in seconds. | 402 timeout: (optional) Timeout per try in seconds. |
| 402 retries: (optional) Number of retries to attempt. | 403 retries: (optional) Number of retries to attempt. |
| 404 split_paths: (optional) List of splits to install. Triggers use of | |
| 405 "adb install-multiple" rather than "adb install". | |
| 403 """ | 406 """ |
| 404 _VerifyLocalFileExists(apk_path) | 407 _VerifyLocalFileExists(apk_path) |
| 405 cmd = ['install'] | 408 if split_paths: |
| 409 cmd = ['install-multiple'] | |
|
jbudorick
2015/05/13 15:15:42
This should be in its own InstallMultiple function
agrieve
2015/05/13 15:47:46
Done.
| |
| 410 else: | |
| 411 cmd = ['install'] | |
| 406 if forward_lock: | 412 if forward_lock: |
| 407 cmd.append('-l') | 413 cmd.append('-l') |
| 408 if reinstall: | 414 if reinstall: |
| 409 cmd.append('-r') | 415 cmd.append('-r') |
| 410 if sd_card: | 416 if sd_card: |
| 411 cmd.append('-s') | 417 cmd.append('-s') |
| 412 cmd.append(apk_path) | 418 cmd.append(apk_path) |
| 419 if split_paths: | |
| 420 cmd.extend(split_paths) | |
| 413 output = self._RunDeviceAdbCmd(cmd, timeout, retries) | 421 output = self._RunDeviceAdbCmd(cmd, timeout, retries) |
| 414 if 'Success' not in output: | 422 if 'Success' not in output: |
| 415 raise device_errors.AdbCommandFailedError( | 423 raise device_errors.AdbCommandFailedError( |
| 416 cmd, output, device_serial=self._device_serial) | 424 cmd, output, device_serial=self._device_serial) |
| 417 | 425 |
| 418 def Uninstall(self, package, keep_data=False, timeout=_DEFAULT_TIMEOUT, | 426 def Uninstall(self, package, keep_data=False, timeout=_DEFAULT_TIMEOUT, |
| 419 retries=_DEFAULT_RETRIES): | 427 retries=_DEFAULT_RETRIES): |
| 420 """Remove the app |package| from the device. | 428 """Remove the app |package| from the device. |
| 421 | 429 |
| 422 Args: | 430 Args: |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 563 @property | 571 @property |
| 564 def is_emulator(self): | 572 def is_emulator(self): |
| 565 return _EMULATOR_RE.match(self._device_serial) | 573 return _EMULATOR_RE.match(self._device_serial) |
| 566 | 574 |
| 567 @property | 575 @property |
| 568 def is_ready(self): | 576 def is_ready(self): |
| 569 try: | 577 try: |
| 570 return self.GetState() == _READY_STATE | 578 return self.GetState() == _READY_STATE |
| 571 except device_errors.CommandFailedError: | 579 except device_errors.CommandFailedError: |
| 572 return False | 580 return False |
| 573 | |
| OLD | NEW |