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 1516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1527 | 1527 |
1528 Parameters passed to this function are passed directly to | 1528 Parameters passed to this function are passed directly to |
1529 |logcat_monitor.LogcatMonitor| and are documented there. | 1529 |logcat_monitor.LogcatMonitor| and are documented there. |
1530 | 1530 |
1531 Args: | 1531 Args: |
1532 timeout: timeout in seconds | 1532 timeout: timeout in seconds |
1533 retries: number of retries | 1533 retries: number of retries |
1534 """ | 1534 """ |
1535 return logcat_monitor.LogcatMonitor(self.adb, *args, **kwargs) | 1535 return logcat_monitor.LogcatMonitor(self.adb, *args, **kwargs) |
1536 | 1536 |
1537 @decorators.WithTimeoutAndRetriesFromInstance() | |
1538 def GetDevicePieWrapper(self, timeout=None, retries=None): | |
1539 """Gets the absolute path to the run_pie wrapper on the device. | |
1540 | |
1541 We have to build our device executables to be PIE, but they need to be able | |
1542 to run on versions of android that don't support PIE (i.e. ICS and below). | |
1543 To do so, we push a wrapper to the device that lets older android versions | |
1544 run PIE executables. This method pushes that wrapper to the device if | |
1545 necessary and returns the path to it. | |
1546 | |
1547 This is exposed publicly to allow clients to write scripts using run_pie | |
1548 (e.g. md5sum.CalculateDeviceMd5Sum). | |
1549 | |
1550 Args: | |
1551 timeout: timeout in seconds | |
1552 retries: number of retries | |
1553 | |
1554 Returns: | |
1555 The path to the PIE wrapper on the device, or an empty string if the | |
1556 device does not require the wrapper. | |
1557 """ | |
1558 if 'run_pie' not in self._cache: | |
1559 pie = '' | |
1560 if (self.build_version_sdk < | |
1561 constants.ANDROID_SDK_VERSION_CODES.JELLY_BEAN): | |
1562 host_pie_path = os.path.join(constants.GetOutDirectory(), 'run_pie') | |
1563 if not os.path.exists(host_pie_path): | |
1564 raise device_errors.CommandFailedError('Please build run_pie') | |
1565 pie = '%s/run_pie' % constants.TEST_EXECUTABLE_DIR | |
1566 self.adb.Push(host_pie_path, pie) | |
1567 | |
1568 self._cache['run_pie'] = pie | |
1569 | |
1570 return self._cache['run_pie'] | |
1571 | |
1572 def GetClientCache(self, client_name): | 1537 def GetClientCache(self, client_name): |
1573 """Returns client cache.""" | 1538 """Returns client cache.""" |
1574 if client_name not in self._client_caches: | 1539 if client_name not in self._client_caches: |
1575 self._client_caches[client_name] = {} | 1540 self._client_caches[client_name] = {} |
1576 return self._client_caches[client_name] | 1541 return self._client_caches[client_name] |
1577 | 1542 |
1578 def _ClearCache(self): | 1543 def _ClearCache(self): |
1579 """Clears all caches.""" | 1544 """Clears all caches.""" |
1580 for client in self._client_caches: | 1545 for client in self._client_caches: |
1581 self._client_caches[client].clear() | 1546 self._client_caches[client].clear() |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1614 blacklist = device_blacklist.ReadBlacklist() | 1579 blacklist = device_blacklist.ReadBlacklist() |
1615 def blacklisted(adb): | 1580 def blacklisted(adb): |
1616 if adb.GetDeviceSerial() in blacklist: | 1581 if adb.GetDeviceSerial() in blacklist: |
1617 logging.warning('Device %s is blacklisted.', adb.GetDeviceSerial()) | 1582 logging.warning('Device %s is blacklisted.', adb.GetDeviceSerial()) |
1618 return True | 1583 return True |
1619 return False | 1584 return False |
1620 | 1585 |
1621 return [cls(adb) for adb in adb_wrapper.AdbWrapper.Devices() | 1586 return [cls(adb) for adb in adb_wrapper.AdbWrapper.Devices() |
1622 if not blacklisted(adb)] | 1587 if not blacklisted(adb)] |
1623 | 1588 |
OLD | NEW |