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 26 matching lines...) Expand all Loading... |
37 | 37 |
38 class AdbWrapper(object): | 38 class AdbWrapper(object): |
39 """A wrapper around a local Android Debug Bridge executable.""" | 39 """A wrapper around a local Android Debug Bridge executable.""" |
40 | 40 |
41 def __init__(self, device_serial): | 41 def __init__(self, device_serial): |
42 """Initializes the AdbWrapper. | 42 """Initializes the AdbWrapper. |
43 | 43 |
44 Args: | 44 Args: |
45 device_serial: The device serial number as a string. | 45 device_serial: The device serial number as a string. |
46 """ | 46 """ |
| 47 if not device_serial: |
| 48 raise ValueError('A device serial must be specified') |
47 self._device_serial = str(device_serial) | 49 self._device_serial = str(device_serial) |
48 | 50 |
49 # pylint: disable=unused-argument | 51 # pylint: disable=unused-argument |
50 @classmethod | 52 @classmethod |
51 @decorators.WithTimeoutAndRetries | 53 @decorators.WithTimeoutAndRetries |
52 def _RunAdbCmd(cls, args, timeout=None, retries=None, device_serial=None, | 54 def _RunAdbCmd(cls, args, timeout=None, retries=None, device_serial=None, |
53 check_error=True): | 55 check_error=True): |
54 cmd = [constants.GetAdbPath()] | 56 cmd = [constants.GetAdbPath()] |
55 if device_serial is not None: | 57 if device_serial is not None: |
56 cmd.extend(['-s', device_serial]) | 58 cmd.extend(['-s', device_serial]) |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 """Restarts the adbd daemon with root permissions, if possible. | 396 """Restarts the adbd daemon with root permissions, if possible. |
395 | 397 |
396 Args: | 398 Args: |
397 timeout: (optional) Timeout per try in seconds. | 399 timeout: (optional) Timeout per try in seconds. |
398 retries: (optional) Number of retries to attempt. | 400 retries: (optional) Number of retries to attempt. |
399 """ | 401 """ |
400 output = self._RunDeviceAdbCmd(['root'], timeout, retries) | 402 output = self._RunDeviceAdbCmd(['root'], timeout, retries) |
401 if 'cannot' in output: | 403 if 'cannot' in output: |
402 raise device_errors.AdbCommandFailedError( | 404 raise device_errors.AdbCommandFailedError( |
403 ['root'], output, device_serial=self._device_serial) | 405 ['root'], output, device_serial=self._device_serial) |
OLD | NEW |