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 1892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1903 if not devices: | 1903 if not devices: |
1904 raise device_errors.NoDevicesError() | 1904 raise device_errors.NoDevicesError() |
1905 | 1905 |
1906 devices = [d if isinstance(d, cls) else cls(d) for d in devices] | 1906 devices = [d if isinstance(d, cls) else cls(d) for d in devices] |
1907 if async: | 1907 if async: |
1908 return parallelizer.Parallelizer(devices) | 1908 return parallelizer.Parallelizer(devices) |
1909 else: | 1909 else: |
1910 return parallelizer.SyncParallelizer(devices) | 1910 return parallelizer.SyncParallelizer(devices) |
1911 | 1911 |
1912 @classmethod | 1912 @classmethod |
1913 def HealthyDevices(cls, blacklist=None): | 1913 def HealthyDevices(cls, blacklist=None, **kwargs): |
1914 if not blacklist: | 1914 if not blacklist: |
1915 # TODO(jbudorick): Remove once clients pass in the blacklist. | 1915 # TODO(jbudorick): Remove once clients pass in the blacklist. |
1916 blacklist = device_blacklist.Blacklist(device_blacklist.BLACKLIST_JSON) | 1916 blacklist = device_blacklist.Blacklist(device_blacklist.BLACKLIST_JSON) |
1917 | 1917 |
1918 blacklisted_devices = blacklist.Read() | 1918 blacklisted_devices = blacklist.Read() |
1919 def blacklisted(adb): | 1919 def blacklisted(adb): |
1920 if adb.GetDeviceSerial() in blacklisted_devices: | 1920 if adb.GetDeviceSerial() in blacklisted_devices: |
1921 logging.warning('Device %s is blacklisted.', adb.GetDeviceSerial()) | 1921 logging.warning('Device %s is blacklisted.', adb.GetDeviceSerial()) |
1922 return True | 1922 return True |
1923 return False | 1923 return False |
1924 | 1924 |
1925 return [cls(adb) for adb in adb_wrapper.AdbWrapper.Devices() | 1925 return [cls(adb, **kwargs) for adb in adb_wrapper.AdbWrapper.Devices() |
1926 if not blacklisted(adb)] | 1926 if not blacklisted(adb)] |
1927 | 1927 |
1928 @decorators.WithTimeoutAndRetriesFromInstance() | 1928 @decorators.WithTimeoutAndRetriesFromInstance() |
1929 def RestartAdbd(self, timeout=None, retries=None): | 1929 def RestartAdbd(self, timeout=None, retries=None): |
1930 logging.info('Restarting adbd on device.') | 1930 logging.info('Restarting adbd on device.') |
1931 with device_temp_file.DeviceTempFile(self.adb, suffix='.sh') as script: | 1931 with device_temp_file.DeviceTempFile(self.adb, suffix='.sh') as script: |
1932 self.WriteFile(script.name, _RESTART_ADBD_SCRIPT) | 1932 self.WriteFile(script.name, _RESTART_ADBD_SCRIPT) |
1933 self.RunShellCommand(['source', script.name], as_root=True) | 1933 self.RunShellCommand(['source', script.name], as_root=True) |
1934 self.adb.WaitForDevice() | 1934 self.adb.WaitForDevice() |
OLD | NEW |