| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 """Provides a variety of device interactions based on adb. | 5 """Provides a variety of device interactions based on adb. |
| 6 | 6 |
| 7 Eventually, this will be based on adb_wrapper. | 7 Eventually, this will be based on adb_wrapper. |
| 8 """ | 8 """ |
| 9 # pylint: disable=unused-argument | 9 # pylint: disable=unused-argument |
| 10 | 10 |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 timeout=self._default_timeout if timeout is DEFAULT else timeout, | 287 timeout=self._default_timeout if timeout is DEFAULT else timeout, |
| 288 retries=self._default_retries if retries is DEFAULT else retries) | 288 retries=self._default_retries if retries is DEFAULT else retries) |
| 289 self._cache['needs_su'] = True | 289 self._cache['needs_su'] = True |
| 290 except device_errors.AdbCommandFailedError: | 290 except device_errors.AdbCommandFailedError: |
| 291 self._cache['needs_su'] = False | 291 self._cache['needs_su'] = False |
| 292 return self._cache['needs_su'] | 292 return self._cache['needs_su'] |
| 293 | 293 |
| 294 def _Su(self, command): | 294 def _Su(self, command): |
| 295 if self.build_version_sdk >= version_codes.MARSHMALLOW: | 295 if self.build_version_sdk >= version_codes.MARSHMALLOW: |
| 296 return 'su 0 %s' % command | 296 return 'su 0 %s' % command |
| 297 return 'su -c %s' % command | 297 return 'su -c %s' % cmd_helper.SingleQuote(command) |
| 298 | 298 |
| 299 @decorators.WithTimeoutAndRetriesFromInstance() | 299 @decorators.WithTimeoutAndRetriesFromInstance() |
| 300 def EnableRoot(self, timeout=None, retries=None): | 300 def EnableRoot(self, timeout=None, retries=None): |
| 301 """Restarts adbd with root privileges. | 301 """Restarts adbd with root privileges. |
| 302 | 302 |
| 303 Args: | 303 Args: |
| 304 timeout: timeout in seconds | 304 timeout: timeout in seconds |
| 305 retries: number of retries | 305 retries: number of retries |
| 306 | 306 |
| 307 Raises: | 307 Raises: |
| (...skipping 1659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1967 if ('android.permission.WRITE_EXTERNAL_STORAGE' in permissions | 1967 if ('android.permission.WRITE_EXTERNAL_STORAGE' in permissions |
| 1968 and 'android.permission.READ_EXTERNAL_STORAGE' not in permissions): | 1968 and 'android.permission.READ_EXTERNAL_STORAGE' not in permissions): |
| 1969 permissions.append('android.permission.READ_EXTERNAL_STORAGE') | 1969 permissions.append('android.permission.READ_EXTERNAL_STORAGE') |
| 1970 cmd = ';'.join('pm grant %s %s' %(package, p) for p in permissions) | 1970 cmd = ';'.join('pm grant %s %s' %(package, p) for p in permissions) |
| 1971 if cmd: | 1971 if cmd: |
| 1972 output = self.RunShellCommand(cmd) | 1972 output = self.RunShellCommand(cmd) |
| 1973 if output: | 1973 if output: |
| 1974 logging.warning('Possible problem when granting permissions. Blacklist ' | 1974 logging.warning('Possible problem when granting permissions. Blacklist ' |
| 1975 'may need to be updated.') | 1975 'may need to be updated.') |
| 1976 logging.warning(output) | 1976 logging.warning(output) |
| OLD | NEW |