| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 """Provides a variety of device interactions based on adb. | 5 """Provides a variety of device interactions based on adb. |
| 6 | 6 |
| 7 Eventually, this will be based on adb_wrapper. | 7 Eventually, this will be based on adb_wrapper. |
| 8 """ | 8 """ |
| 9 # pylint: disable=unused-argument | 9 # pylint: disable=unused-argument |
| 10 | 10 |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 timeout_retry.WaitFor(device_offline, wait_period=1) | 437 timeout_retry.WaitFor(device_offline, wait_period=1) |
| 438 if block: | 438 if block: |
| 439 self.WaitUntilFullyBooted(wifi=wifi) | 439 self.WaitUntilFullyBooted(wifi=wifi) |
| 440 | 440 |
| 441 INSTALL_DEFAULT_TIMEOUT = 4 * _DEFAULT_TIMEOUT | 441 INSTALL_DEFAULT_TIMEOUT = 4 * _DEFAULT_TIMEOUT |
| 442 INSTALL_DEFAULT_RETRIES = _DEFAULT_RETRIES | 442 INSTALL_DEFAULT_RETRIES = _DEFAULT_RETRIES |
| 443 | 443 |
| 444 @decorators.WithTimeoutAndRetriesDefaults( | 444 @decorators.WithTimeoutAndRetriesDefaults( |
| 445 INSTALL_DEFAULT_TIMEOUT, | 445 INSTALL_DEFAULT_TIMEOUT, |
| 446 INSTALL_DEFAULT_RETRIES) | 446 INSTALL_DEFAULT_RETRIES) |
| 447 def Install(self, apk_path, reinstall=False, timeout=None, retries=None): | 447 def Install(self, apk_path, reinstall=False, timeout=None, retries=None, |
| 448 split_paths=None): |
| 448 """Install an APK. | 449 """Install an APK. |
| 449 | 450 |
| 450 Noop if an identical APK is already installed. | 451 Noop if an identical APK is already installed. |
| 451 | 452 |
| 452 Args: | 453 Args: |
| 453 apk_path: A string containing the path to the APK to install. | 454 apk_path: A string containing the path to the APK to install. |
| 454 reinstall: A boolean indicating if we should keep any existing app data. | 455 reinstall: A boolean indicating if we should keep any existing app data. |
| 455 timeout: timeout in seconds | 456 timeout: timeout in seconds |
| 456 retries: number of retries | 457 retries: number of retries |
| 458 split_paths: (optional) List of splits to install. Triggers use of |
| 459 "adb install-multiple" rather than "adb install". |
| 457 | 460 |
| 458 Raises: | 461 Raises: |
| 459 CommandFailedError if the installation fails. | 462 CommandFailedError if the installation fails. |
| 460 CommandTimeoutError if the installation times out. | 463 CommandTimeoutError if the installation times out. |
| 461 DeviceUnreachableError on missing device. | 464 DeviceUnreachableError on missing device. |
| 462 """ | 465 """ |
| 463 package_name = apk_helper.GetPackageName(apk_path) | 466 package_name = apk_helper.GetPackageName(apk_path) |
| 464 device_path = self.GetApplicationPath(package_name) | 467 device_path = self.GetApplicationPath(package_name) |
| 465 if device_path is not None: | 468 if device_path is not None: |
| 466 should_install = bool(self._GetChangedFilesImpl(apk_path, device_path)) | 469 should_install = bool(self._GetChangedFilesImpl(apk_path, device_path)) |
| 467 if should_install and not reinstall: | 470 if should_install and not reinstall: |
| 468 self.adb.Uninstall(package_name) | 471 self.adb.Uninstall(package_name) |
| 469 else: | 472 else: |
| 470 should_install = True | 473 should_install = True |
| 471 if should_install: | 474 if should_install: |
| 472 self.adb.Install(apk_path, reinstall=reinstall) | 475 self.adb.Install(apk_path, reinstall=reinstall, split_paths=split_paths) |
| 473 | 476 |
| 474 @decorators.WithTimeoutAndRetriesFromInstance() | 477 @decorators.WithTimeoutAndRetriesFromInstance() |
| 475 def RunShellCommand(self, cmd, check_return=False, cwd=None, env=None, | 478 def RunShellCommand(self, cmd, check_return=False, cwd=None, env=None, |
| 476 as_root=False, single_line=False, large_output=False, | 479 as_root=False, single_line=False, large_output=False, |
| 477 timeout=None, retries=None): | 480 timeout=None, retries=None): |
| 478 """Run an ADB shell command. | 481 """Run an ADB shell command. |
| 479 | 482 |
| 480 The command to run |cmd| should be a sequence of program arguments or else | 483 The command to run |cmd| should be a sequence of program arguments or else |
| 481 a single string. | 484 a single string. |
| 482 | 485 |
| (...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1578 def HealthyDevices(cls): | 1581 def HealthyDevices(cls): |
| 1579 blacklist = device_blacklist.ReadBlacklist() | 1582 blacklist = device_blacklist.ReadBlacklist() |
| 1580 def blacklisted(adb): | 1583 def blacklisted(adb): |
| 1581 if adb.GetDeviceSerial() in blacklist: | 1584 if adb.GetDeviceSerial() in blacklist: |
| 1582 logging.warning('Device %s is blacklisted.', adb.GetDeviceSerial()) | 1585 logging.warning('Device %s is blacklisted.', adb.GetDeviceSerial()) |
| 1583 return True | 1586 return True |
| 1584 return False | 1587 return False |
| 1585 | 1588 |
| 1586 return [cls(adb) for adb in adb_wrapper.AdbWrapper.Devices() | 1589 return [cls(adb) for adb in adb_wrapper.AdbWrapper.Devices() |
| 1587 if not blacklisted(adb)] | 1590 if not blacklisted(adb)] |
| 1588 | |
| OLD | NEW |