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

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

Issue 1116493003: Revert of [Android] Remove more uses of android_commands from build/android/pylib. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 else: 168 else:
169 raise ValueError('Unsupported device value: %r' % device) 169 raise ValueError('Unsupported device value: %r' % device)
170 self._commands_installed = None 170 self._commands_installed = None
171 self._default_timeout = default_timeout 171 self._default_timeout = default_timeout
172 self._default_retries = default_retries 172 self._default_retries = default_retries
173 self._cache = {} 173 self._cache = {}
174 self._client_caches = {} 174 self._client_caches = {}
175 assert hasattr(self, decorators.DEFAULT_TIMEOUT_ATTR) 175 assert hasattr(self, decorators.DEFAULT_TIMEOUT_ATTR)
176 assert hasattr(self, decorators.DEFAULT_RETRIES_ATTR) 176 assert hasattr(self, decorators.DEFAULT_RETRIES_ATTR)
177 177
178 def __eq__(self, other):
179 """Checks whether |other| refers to the same device as |self|.
180
181 Args:
182 other: The object to compare to. This can be a basestring, an instance
183 of adb_wrapper.AdbWrapper, or an instance of DeviceUtils.
184 Returns:
185 Whether |other| refers to the same device as |self|.
186 """
187 return self.adb.GetDeviceSerial() == str(other)
188
189 def __lt__(self, other):
190 """Compares two instances of DeviceUtils.
191
192 This merely compares their serial numbers.
193
194 Args:
195 other: The instance of DeviceUtils to compare to.
196 Returns:
197 Whether |self| is less than |other|.
198 """
199 return self.adb.GetDeviceSerial() < other.adb.GetDeviceSerial()
200
201 def __str__(self): 178 def __str__(self):
202 """Returns the device serial.""" 179 """Returns the device serial."""
203 return self.adb.GetDeviceSerial() 180 return self.adb.GetDeviceSerial()
204 181
205 @decorators.WithTimeoutAndRetriesFromInstance() 182 @decorators.WithTimeoutAndRetriesFromInstance()
206 def IsOnline(self, timeout=None, retries=None): 183 def IsOnline(self, timeout=None, retries=None):
207 """Checks whether the device is online. 184 """Checks whether the device is online.
208 185
209 Args: 186 Args:
210 timeout: timeout in seconds 187 timeout: timeout in seconds
(...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after
1607 blacklist = device_blacklist.ReadBlacklist() 1584 blacklist = device_blacklist.ReadBlacklist()
1608 def blacklisted(adb): 1585 def blacklisted(adb):
1609 if adb.GetDeviceSerial() in blacklist: 1586 if adb.GetDeviceSerial() in blacklist:
1610 logging.warning('Device %s is blacklisted.', adb.GetDeviceSerial()) 1587 logging.warning('Device %s is blacklisted.', adb.GetDeviceSerial())
1611 return True 1588 return True
1612 return False 1589 return False
1613 1590
1614 return [cls(adb) for adb in adb_wrapper.AdbWrapper.Devices() 1591 return [cls(adb) for adb in adb_wrapper.AdbWrapper.Devices()
1615 if not blacklisted(adb)] 1592 if not blacklisted(adb)]
1616 1593
OLDNEW
« no previous file with comments | « build/android/pylib/device/battery_utils_test.py ('k') | build/android/pylib/device/device_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698