| 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 |
| 11 import collections | 11 import collections |
| 12 import errno | 12 import errno |
| 13 import logging | 13 import logging |
| 14 import os | 14 import os |
| 15 import re | 15 import re |
| 16 | 16 |
| 17 from devil import devil_env |
| 17 from devil.android import decorators | 18 from devil.android import decorators |
| 18 from devil.android import device_errors | 19 from devil.android import device_errors |
| 19 from devil.utils import cmd_helper | 20 from devil.utils import cmd_helper |
| 20 from devil.utils import timeout_retry | 21 from devil.utils import timeout_retry |
| 21 from pylib import constants | |
| 22 | 22 |
| 23 | 23 |
| 24 _DEFAULT_TIMEOUT = 30 | 24 _DEFAULT_TIMEOUT = 30 |
| 25 _DEFAULT_RETRIES = 2 | 25 _DEFAULT_RETRIES = 2 |
| 26 | 26 |
| 27 _EMULATOR_RE = re.compile(r'^emulator-[0-9]+$') | 27 _EMULATOR_RE = re.compile(r'^emulator-[0-9]+$') |
| 28 | 28 |
| 29 _READY_STATE = 'device' | 29 _READY_STATE = 'device' |
| 30 | 30 |
| 31 | 31 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 59 raise ValueError('A device serial must be specified') | 59 raise ValueError('A device serial must be specified') |
| 60 self._device_serial = str(device_serial) | 60 self._device_serial = str(device_serial) |
| 61 | 61 |
| 62 # pylint: disable=unused-argument | 62 # pylint: disable=unused-argument |
| 63 @classmethod | 63 @classmethod |
| 64 def _BuildAdbCmd(cls, args, device_serial, cpu_affinity=None): | 64 def _BuildAdbCmd(cls, args, device_serial, cpu_affinity=None): |
| 65 if cpu_affinity is not None: | 65 if cpu_affinity is not None: |
| 66 cmd = ['taskset', '-c', str(cpu_affinity)] | 66 cmd = ['taskset', '-c', str(cpu_affinity)] |
| 67 else: | 67 else: |
| 68 cmd = [] | 68 cmd = [] |
| 69 cmd.append(constants.GetAdbPath()) | 69 cmd.append(devil_env.instance.adb_path) |
| 70 if device_serial is not None: | 70 if device_serial is not None: |
| 71 cmd.extend(['-s', device_serial]) | 71 cmd.extend(['-s', device_serial]) |
| 72 cmd.extend(args) | 72 cmd.extend(args) |
| 73 return cmd | 73 return cmd |
| 74 # pylint: enable=unused-argument | 74 # pylint: enable=unused-argument |
| 75 | 75 |
| 76 # pylint: disable=unused-argument | 76 # pylint: disable=unused-argument |
| 77 @classmethod | 77 @classmethod |
| 78 @decorators.WithTimeoutAndRetries | 78 @decorators.WithTimeoutAndRetries |
| 79 def _RunAdbCmd(cls, args, timeout=None, retries=None, device_serial=None, | 79 def _RunAdbCmd(cls, args, timeout=None, retries=None, device_serial=None, |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 @property | 650 @property |
| 651 def is_emulator(self): | 651 def is_emulator(self): |
| 652 return _EMULATOR_RE.match(self._device_serial) | 652 return _EMULATOR_RE.match(self._device_serial) |
| 653 | 653 |
| 654 @property | 654 @property |
| 655 def is_ready(self): | 655 def is_ready(self): |
| 656 try: | 656 try: |
| 657 return self.GetState() == _READY_STATE | 657 return self.GetState() == _READY_STATE |
| 658 except device_errors.CommandFailedError: | 658 except device_errors.CommandFailedError: |
| 659 return False | 659 return False |
| OLD | NEW |