Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(397)

Side by Side Diff: build/android/pylib/device/device_utils.py

Issue 1291793007: GN(android): Add scripts & runtime logic for installing _managed apks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gn-managed-install
Patch Set: review comments Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 other: The instance of DeviceUtils to compare to. 209 other: The instance of DeviceUtils to compare to.
210 Returns: 210 Returns:
211 Whether |self| is less than |other|. 211 Whether |self| is less than |other|.
212 """ 212 """
213 return self.adb.GetDeviceSerial() < other.adb.GetDeviceSerial() 213 return self.adb.GetDeviceSerial() < other.adb.GetDeviceSerial()
214 214
215 def __str__(self): 215 def __str__(self):
216 """Returns the device serial.""" 216 """Returns the device serial."""
217 return self.adb.GetDeviceSerial() 217 return self.adb.GetDeviceSerial()
218 218
219 @property
220 def default_timeout(self):
221 return self._default_timeout
222
223 @default_timeout.setter
jbudorick 2015/08/27 00:37:37 nix the setters.
agrieve 2015/08/27 03:20:00 whoops, done.
224 def default_timeout(self, value):
225 self._default_timeout = value
226
227 @property
228 def default_retries(self):
229 return self._default_retries
230
231 @default_retries.setter
232 def default_retries(self, value):
233 self._default_retries = value
234
219 @decorators.WithTimeoutAndRetriesFromInstance() 235 @decorators.WithTimeoutAndRetriesFromInstance()
220 def IsOnline(self, timeout=None, retries=None): 236 def IsOnline(self, timeout=None, retries=None):
221 """Checks whether the device is online. 237 """Checks whether the device is online.
222 238
223 Args: 239 Args:
224 timeout: timeout in seconds 240 timeout: timeout in seconds
225 retries: number of retries 241 retries: number of retries
226 242
227 Returns: 243 Returns:
228 True if the device is online, False otherwise. 244 True if the device is online, False otherwise.
(...skipping 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after
1862 if not devices: 1878 if not devices:
1863 raise device_errors.NoDevicesError() 1879 raise device_errors.NoDevicesError()
1864 1880
1865 devices = [d if isinstance(d, cls) else cls(d) for d in devices] 1881 devices = [d if isinstance(d, cls) else cls(d) for d in devices]
1866 if async: 1882 if async:
1867 return parallelizer.Parallelizer(devices) 1883 return parallelizer.Parallelizer(devices)
1868 else: 1884 else:
1869 return parallelizer.SyncParallelizer(devices) 1885 return parallelizer.SyncParallelizer(devices)
1870 1886
1871 @classmethod 1887 @classmethod
1872 def HealthyDevices(cls): 1888 def HealthyDevices(cls, **kwargs):
1873 blacklist = device_blacklist.ReadBlacklist() 1889 blacklist = device_blacklist.ReadBlacklist()
1874 def blacklisted(adb): 1890 def blacklisted(adb):
1875 if adb.GetDeviceSerial() in blacklist: 1891 if adb.GetDeviceSerial() in blacklist:
1876 logging.warning('Device %s is blacklisted.', adb.GetDeviceSerial()) 1892 logging.warning('Device %s is blacklisted.', adb.GetDeviceSerial())
1877 return True 1893 return True
1878 return False 1894 return False
1879 1895
1880 return [cls(adb) for adb in adb_wrapper.AdbWrapper.Devices() 1896 return [cls(adb, **kwargs) for adb in adb_wrapper.AdbWrapper.Devices()
1881 if not blacklisted(adb)] 1897 if not blacklisted(adb)]
1882 1898
1883 @decorators.WithTimeoutAndRetriesFromInstance() 1899 @decorators.WithTimeoutAndRetriesFromInstance()
1884 def RestartAdbd(self, timeout=None, retries=None): 1900 def RestartAdbd(self, timeout=None, retries=None):
1885 logging.info('Restarting adbd on device.') 1901 logging.info('Restarting adbd on device.')
1886 with device_temp_file.DeviceTempFile(self.adb, suffix='.sh') as script: 1902 with device_temp_file.DeviceTempFile(self.adb, suffix='.sh') as script:
1887 self.WriteFile(script.name, _RESTART_ADBD_SCRIPT) 1903 self.WriteFile(script.name, _RESTART_ADBD_SCRIPT)
1888 self.RunShellCommand(['source', script.name], as_root=True) 1904 self.RunShellCommand(['source', script.name], as_root=True)
1889 self.adb.WaitForDevice() 1905 self.adb.WaitForDevice()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698