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 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1551 Raises: | 1551 Raises: |
1552 CommandFailedError if check is true and the property was not correctly | 1552 CommandFailedError if check is true and the property was not correctly |
1553 set on the device (e.g. because it is not rooted). | 1553 set on the device (e.g. because it is not rooted). |
1554 CommandTimeoutError on timeout. | 1554 CommandTimeoutError on timeout. |
1555 """ | 1555 """ |
1556 assert isinstance(property_name, basestring), ( | 1556 assert isinstance(property_name, basestring), ( |
1557 "property_name is not a string: %r" % property_name) | 1557 "property_name is not a string: %r" % property_name) |
1558 assert isinstance(value, basestring), "value is not a string: %r" % value | 1558 assert isinstance(value, basestring), "value is not a string: %r" % value |
1559 | 1559 |
1560 self.RunShellCommand(['setprop', property_name, value], check_return=True) | 1560 self.RunShellCommand(['setprop', property_name, value], check_return=True) |
1561 if property_name in self._cache: | 1561 cache_key = '_prop:' + property_name |
jbudorick
2015/08/11 00:47:54
optional nit: wdyt about a _PropertyCacheKey funct
agrieve
2015/08/11 13:51:56
If we're going to go with having sub-caches for AP
jbudorick
2015/08/11 13:53:18
Hmm, good point.
| |
1562 del self._cache[property_name] | 1562 if cache_key in self._cache: |
1563 del self._cache[cache_key] | |
1563 # TODO(perezju) remove the option and make the check mandatory, but using a | 1564 # TODO(perezju) remove the option and make the check mandatory, but using a |
1564 # single shell script to both set- and getprop. | 1565 # single shell script to both set- and getprop. |
1565 if check and value != self.GetProp(property_name): | 1566 if check and value != self.GetProp(property_name): |
1566 raise device_errors.CommandFailedError( | 1567 raise device_errors.CommandFailedError( |
1567 'Unable to set property %r on the device to %r' | 1568 'Unable to set property %r on the device to %r' |
1568 % (property_name, value), str(self)) | 1569 % (property_name, value), str(self)) |
1569 | 1570 |
1570 @decorators.WithTimeoutAndRetriesFromInstance() | 1571 @decorators.WithTimeoutAndRetriesFromInstance() |
1571 def GetABI(self, timeout=None, retries=None): | 1572 def GetABI(self, timeout=None, retries=None): |
1572 """Gets the device main ABI. | 1573 """Gets the device main ABI. |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1797 def HealthyDevices(cls): | 1798 def HealthyDevices(cls): |
1798 blacklist = device_blacklist.ReadBlacklist() | 1799 blacklist = device_blacklist.ReadBlacklist() |
1799 def blacklisted(adb): | 1800 def blacklisted(adb): |
1800 if adb.GetDeviceSerial() in blacklist: | 1801 if adb.GetDeviceSerial() in blacklist: |
1801 logging.warning('Device %s is blacklisted.', adb.GetDeviceSerial()) | 1802 logging.warning('Device %s is blacklisted.', adb.GetDeviceSerial()) |
1802 return True | 1803 return True |
1803 return False | 1804 return False |
1804 | 1805 |
1805 return [cls(adb) for adb in adb_wrapper.AdbWrapper.Devices() | 1806 return [cls(adb) for adb in adb_wrapper.AdbWrapper.Devices() |
1806 if not blacklisted(adb)] | 1807 if not blacklisted(adb)] |
OLD | NEW |