OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 """This module wraps Android's adb tool. | 5 """This module wraps Android's adb tool. |
6 | 6 |
7 This is a thin wrapper around the adb interface. Any additional complexity | 7 This is a thin wrapper around the adb interface. Any additional complexity |
8 should be delegated to a higher level (ex. DeviceUtils). | 8 should be delegated to a higher level (ex. DeviceUtils). |
9 """ | 9 """ |
10 | 10 |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 """DEPRECATED. Refer to Devices(...) below.""" | 168 """DEPRECATED. Refer to Devices(...) below.""" |
169 # TODO(jbudorick): Remove this function once no more clients are using it. | 169 # TODO(jbudorick): Remove this function once no more clients are using it. |
170 return cls.Devices(timeout=timeout, retries=retries) | 170 return cls.Devices(timeout=timeout, retries=retries) |
171 | 171 |
172 @classmethod | 172 @classmethod |
173 def Devices(cls, is_ready=True, timeout=_DEFAULT_TIMEOUT, | 173 def Devices(cls, is_ready=True, timeout=_DEFAULT_TIMEOUT, |
174 retries=_DEFAULT_RETRIES): | 174 retries=_DEFAULT_RETRIES): |
175 """Get the list of active attached devices. | 175 """Get the list of active attached devices. |
176 | 176 |
177 Args: | 177 Args: |
| 178 is_ready: Whether the devices should be limited to only those that are |
| 179 ready for use. |
178 timeout: (optional) Timeout per try in seconds. | 180 timeout: (optional) Timeout per try in seconds. |
179 retries: (optional) Number of retries to attempt. | 181 retries: (optional) Number of retries to attempt. |
180 | 182 |
181 Yields: | 183 Yields: |
182 AdbWrapper instances. | 184 AdbWrapper instances. |
183 """ | 185 """ |
184 output = cls._RunAdbCmd(['devices'], timeout=timeout, retries=retries) | 186 output = cls._RunAdbCmd(['devices'], timeout=timeout, retries=retries) |
185 lines = (line.split() for line in output.splitlines()) | 187 lines = (line.split() for line in output.splitlines()) |
186 return [AdbWrapper(line[0]) for line in lines | 188 return [AdbWrapper(line[0]) for line in lines |
187 if len(line) == 2 and (not is_ready or line[1] == _READY_STATE)] | 189 if len(line) == 2 and (not is_ready or line[1] == _READY_STATE)] |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 @property | 599 @property |
598 def is_emulator(self): | 600 def is_emulator(self): |
599 return _EMULATOR_RE.match(self._device_serial) | 601 return _EMULATOR_RE.match(self._device_serial) |
600 | 602 |
601 @property | 603 @property |
602 def is_ready(self): | 604 def is_ready(self): |
603 try: | 605 try: |
604 return self.GetState() == _READY_STATE | 606 return self.GetState() == _READY_STATE |
605 except device_errors.CommandFailedError: | 607 except device_errors.CommandFailedError: |
606 return False | 608 return False |
OLD | NEW |