Chromium Code Reviews| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 163 cls._RunAdbCmd(['start-server'], timeout=timeout, retries=retries, | 163 cls._RunAdbCmd(['start-server'], timeout=timeout, retries=retries, |
| 164 cpu_affinity=0) | 164 cpu_affinity=0) |
| 165 | 165 |
| 166 @classmethod | 166 @classmethod |
| 167 def GetDevices(cls, timeout=_DEFAULT_TIMEOUT, retries=_DEFAULT_RETRIES): | 167 def GetDevices(cls, timeout=_DEFAULT_TIMEOUT, retries=_DEFAULT_RETRIES): |
| 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, long_list=False, timeout=_DEFAULT_TIMEOUT, | 173 def Devices(cls, desired_state=_READY_STATE, long_list=False, |
|
rnephew (Wrong account)
2015/08/21 02:25:12
Is is_ready used anywhere else that isn't changed
jbudorick
2015/08/21 02:27:38
same name, mocking a function in AdbWrapper rather
| |
| 174 retries=_DEFAULT_RETRIES): | 174 timeout=_DEFAULT_TIMEOUT, 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 | 178 desired_state: If not None, limit the devices returned to only those |
| 179 ready for use. | 179 in the given state. |
| 180 long_list: Whether to use the long listing format. | 180 long_list: Whether to use the long listing format. |
| 181 timeout: (optional) Timeout per try in seconds. | 181 timeout: (optional) Timeout per try in seconds. |
| 182 retries: (optional) Number of retries to attempt. | 182 retries: (optional) Number of retries to attempt. |
| 183 | 183 |
| 184 Yields: | 184 Yields: |
| 185 AdbWrapper instances. | 185 AdbWrapper instances. |
| 186 """ | 186 """ |
| 187 lines = cls._RawDevices(long_list=long_list, timeout=timeout, | 187 lines = cls._RawDevices(long_list=long_list, timeout=timeout, |
| 188 retries=retries) | 188 retries=retries) |
| 189 return [AdbWrapper(line[0]) for line in lines | 189 return [AdbWrapper(line[0]) for line in lines |
| 190 if ((long_list or len(line) == 2) | 190 if ((long_list or len(line) == 2) |
| 191 and (not is_ready or line[1] == _READY_STATE))] | 191 and (not desired_state or line[1] == desired_state))] |
| 192 | 192 |
| 193 @classmethod | 193 @classmethod |
| 194 def _RawDevices(cls, long_list=False, timeout=_DEFAULT_TIMEOUT, | 194 def _RawDevices(cls, long_list=False, timeout=_DEFAULT_TIMEOUT, |
| 195 retries=_DEFAULT_RETRIES): | 195 retries=_DEFAULT_RETRIES): |
| 196 cmd = ['devices'] | 196 cmd = ['devices'] |
| 197 if long_list: | 197 if long_list: |
| 198 cmd.append('-l') | 198 cmd.append('-l') |
| 199 output = cls._RunAdbCmd(cmd, timeout=timeout, retries=retries) | 199 output = cls._RunAdbCmd(cmd, timeout=timeout, retries=retries) |
| 200 return [line.split() for line in output.splitlines()[1:]] | 200 return [line.split() for line in output.splitlines()[1:]] |
| 201 | 201 |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 640 @property | 640 @property |
| 641 def is_emulator(self): | 641 def is_emulator(self): |
| 642 return _EMULATOR_RE.match(self._device_serial) | 642 return _EMULATOR_RE.match(self._device_serial) |
| 643 | 643 |
| 644 @property | 644 @property |
| 645 def is_ready(self): | 645 def is_ready(self): |
| 646 try: | 646 try: |
| 647 return self.GetState() == _READY_STATE | 647 return self.GetState() == _READY_STATE |
| 648 except device_errors.CommandFailedError: | 648 except device_errors.CommandFailedError: |
| 649 return False | 649 return False |
| OLD | NEW |