Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Side by Side Diff: build/android/devil/android/device_utils.py

Issue 1335983002: DeviceUtils: Fix SU command for pre-M devices Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | build/android/devil/android/device_utils_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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)
OLDNEW
« no previous file with comments | « no previous file | build/android/devil/android/device_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698