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=W0613 | 9 # pylint: disable=W0613 |
10 | 10 |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 | 627 |
628 Args: | 628 Args: |
629 package: A string containing the name of the package to stop. | 629 package: A string containing the name of the package to stop. |
630 timeout: timeout in seconds | 630 timeout: timeout in seconds |
631 retries: number of retries | 631 retries: number of retries |
632 | 632 |
633 Raises: | 633 Raises: |
634 CommandTimeoutError on timeout. | 634 CommandTimeoutError on timeout. |
635 DeviceUnreachableError on missing device. | 635 DeviceUnreachableError on missing device. |
636 """ | 636 """ |
637 # Check that the package exists before clearing it. Necessary because | 637 # Check that the package exists before clearing it for android builds below |
638 # calling pm clear on a package that doesn't exist may never return. | 638 # JB MR2. Necessary because calling pm clear on a package that doesn't exist |
639 if self.GetApplicationPath(package): | 639 # may never return. |
| 640 if ((self.build_version_sdk >= |
| 641 constants.ANDROID_SDK_VERSION_CODES.JELLY_BEAN_MR2) |
| 642 or self.GetApplicationPath(package)): |
640 self.RunShellCommand(['pm', 'clear', package], check_return=True) | 643 self.RunShellCommand(['pm', 'clear', package], check_return=True) |
641 | 644 |
642 @decorators.WithTimeoutAndRetriesFromInstance() | 645 @decorators.WithTimeoutAndRetriesFromInstance() |
643 def SendKeyEvent(self, keycode, timeout=None, retries=None): | 646 def SendKeyEvent(self, keycode, timeout=None, retries=None): |
644 """Sends a keycode to the device. | 647 """Sends a keycode to the device. |
645 | 648 |
646 See: http://developer.android.com/reference/android/view/KeyEvent.html | 649 See: http://developer.android.com/reference/android/view/KeyEvent.html |
647 | 650 |
648 Args: | 651 Args: |
649 keycode: A integer keycode to send to the device. | 652 keycode: A integer keycode to send to the device. |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1285 Returns: | 1288 Returns: |
1286 A Parallelizer operating over |devices|. | 1289 A Parallelizer operating over |devices|. |
1287 """ | 1290 """ |
1288 if not devices: | 1291 if not devices: |
1289 devices = adb_wrapper.AdbWrapper.GetDevices() | 1292 devices = adb_wrapper.AdbWrapper.GetDevices() |
1290 devices = [d if isinstance(d, cls) else cls(d) for d in devices] | 1293 devices = [d if isinstance(d, cls) else cls(d) for d in devices] |
1291 if async: | 1294 if async: |
1292 return parallelizer.Parallelizer(devices) | 1295 return parallelizer.Parallelizer(devices) |
1293 else: | 1296 else: |
1294 return parallelizer.SyncParallelizer(devices) | 1297 return parallelizer.SyncParallelizer(devices) |
OLD | NEW |