| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 | 145 |
| 146 Args: | 146 Args: |
| 147 remote: Path on the device filesystem. | 147 remote: Path on the device filesystem. |
| 148 local: Path on the host filesystem. | 148 local: Path on the host filesystem. |
| 149 timeout: (optional) Timeout per try in seconds. | 149 timeout: (optional) Timeout per try in seconds. |
| 150 retries: (optional) Number of retries to attempt. | 150 retries: (optional) Number of retries to attempt. |
| 151 """ | 151 """ |
| 152 self._DeviceAdbCmd(['pull', remote, local], timeout, retries) | 152 self._DeviceAdbCmd(['pull', remote, local], timeout, retries) |
| 153 _VerifyLocalFileExists(local) | 153 _VerifyLocalFileExists(local) |
| 154 | 154 |
| 155 def Shell(self, command, expect_rc=None, timeout=_DEFAULT_TIMEOUT, | 155 def Shell(self, command, expect_rc=0, timeout=_DEFAULT_TIMEOUT, |
| 156 retries=_DEFAULT_RETRIES): | 156 retries=_DEFAULT_RETRIES): |
| 157 """Runs a shell command on the device. | 157 """Runs a shell command on the device. |
| 158 | 158 |
| 159 Args: | 159 Args: |
| 160 command: The shell command to run. | 160 command: The shell command to run. |
| 161 expect_rc: (optional) If set checks that the command's return code matches | 161 expect_rc: (optional) Check that the command's return code matches this |
| 162 this value. | 162 value. Default is 0. If set to None the test is skipped. |
| 163 timeout: (optional) Timeout per try in seconds. | 163 timeout: (optional) Timeout per try in seconds. |
| 164 retries: (optional) Number of retries to attempt. | 164 retries: (optional) Number of retries to attempt. |
| 165 | 165 |
| 166 Returns: | 166 Returns: |
| 167 The output of the shell command as a string. | 167 The output of the shell command as a string. |
| 168 | 168 |
| 169 Raises: | 169 Raises: |
| 170 device_errors.AdbCommandFailedError: If the return code doesn't match | 170 device_errors.AdbCommandFailedError: If the return code doesn't match |
| 171 |expect_rc|. | 171 |expect_rc|. |
| 172 """ | 172 """ |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 """Restarts the adbd daemon with root permissions, if possible. | 389 """Restarts the adbd daemon with root permissions, if possible. |
| 390 | 390 |
| 391 Args: | 391 Args: |
| 392 timeout: (optional) Timeout per try in seconds. | 392 timeout: (optional) Timeout per try in seconds. |
| 393 retries: (optional) Number of retries to attempt. | 393 retries: (optional) Number of retries to attempt. |
| 394 """ | 394 """ |
| 395 output = self._DeviceAdbCmd(['root'], timeout, retries) | 395 output = self._DeviceAdbCmd(['root'], timeout, retries) |
| 396 if 'cannot' in output: | 396 if 'cannot' in output: |
| 397 raise device_errors.AdbCommandFailedError(['root'], output) | 397 raise device_errors.AdbCommandFailedError(['root'], output) |
| 398 | 398 |
| OLD | NEW |