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 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 # may never return. | 782 # may never return. |
783 if ((self.build_version_sdk >= | 783 if ((self.build_version_sdk >= |
784 constants.ANDROID_SDK_VERSION_CODES.JELLY_BEAN_MR2) | 784 constants.ANDROID_SDK_VERSION_CODES.JELLY_BEAN_MR2) |
785 or self.GetApplicationPath(package)): | 785 or self.GetApplicationPath(package)): |
786 self.RunShellCommand(['pm', 'clear', package], check_return=True) | 786 self.RunShellCommand(['pm', 'clear', package], check_return=True) |
787 | 787 |
788 @decorators.WithTimeoutAndRetriesFromInstance() | 788 @decorators.WithTimeoutAndRetriesFromInstance() |
789 def SendKeyEvent(self, keycode, timeout=None, retries=None): | 789 def SendKeyEvent(self, keycode, timeout=None, retries=None): |
790 """Sends a keycode to the device. | 790 """Sends a keycode to the device. |
791 | 791 |
792 See: http://developer.android.com/reference/android/view/KeyEvent.html | 792 See the pylib.constants.keyevent module for suitable keycode values. |
793 | 793 |
794 Args: | 794 Args: |
795 keycode: A integer keycode to send to the device. | 795 keycode: A integer keycode to send to the device. |
796 timeout: timeout in seconds | 796 timeout: timeout in seconds |
797 retries: number of retries | 797 retries: number of retries |
798 | 798 |
799 Raises: | 799 Raises: |
800 CommandTimeoutError on timeout. | 800 CommandTimeoutError on timeout. |
801 DeviceUnreachableError on missing device. | 801 DeviceUnreachableError on missing device. |
802 """ | 802 """ |
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1614 blacklist = device_blacklist.ReadBlacklist() | 1614 blacklist = device_blacklist.ReadBlacklist() |
1615 def blacklisted(adb): | 1615 def blacklisted(adb): |
1616 if adb.GetDeviceSerial() in blacklist: | 1616 if adb.GetDeviceSerial() in blacklist: |
1617 logging.warning('Device %s is blacklisted.', adb.GetDeviceSerial()) | 1617 logging.warning('Device %s is blacklisted.', adb.GetDeviceSerial()) |
1618 return True | 1618 return True |
1619 return False | 1619 return False |
1620 | 1620 |
1621 return [cls(adb) for adb in adb_wrapper.AdbWrapper.Devices() | 1621 return [cls(adb) for adb in adb_wrapper.AdbWrapper.Devices() |
1622 if not blacklisted(adb)] | 1622 if not blacklisted(adb)] |
1623 | 1623 |
OLD | NEW |