| 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 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 # We won't know the resulting device apk names. | 558 # We won't know the resulting device apk names. |
| 559 self._cache['package_apk_paths'].pop(package_name, 0) | 559 self._cache['package_apk_paths'].pop(package_name, 0) |
| 560 self.adb.Install(apk_path, reinstall=reinstall) | 560 self.adb.Install(apk_path, reinstall=reinstall) |
| 561 self._cache['package_apk_checksums'][package_name] = host_checksums | 561 self._cache['package_apk_checksums'][package_name] = host_checksums |
| 562 | 562 |
| 563 if (permissions is None | 563 if (permissions is None |
| 564 and self.build_version_sdk >= version_codes.MARSHMALLOW): | 564 and self.build_version_sdk >= version_codes.MARSHMALLOW): |
| 565 permissions = apk_helper.ApkHelper(apk_path).GetPermissions() | 565 permissions = apk_helper.ApkHelper(apk_path).GetPermissions() |
| 566 self.GrantPermissions(package_name, permissions) | 566 self.GrantPermissions(package_name, permissions) |
| 567 | 567 |
| 568 | |
| 569 @decorators.WithTimeoutAndRetriesDefaults( | 568 @decorators.WithTimeoutAndRetriesDefaults( |
| 570 INSTALL_DEFAULT_TIMEOUT, | 569 INSTALL_DEFAULT_TIMEOUT, |
| 571 INSTALL_DEFAULT_RETRIES) | 570 INSTALL_DEFAULT_RETRIES) |
| 572 def InstallSplitApk(self, base_apk, split_apks, reinstall=False, | 571 def InstallSplitApk(self, base_apk, split_apks, reinstall=False, |
| 573 allow_cached_props=False, timeout=None, retries=None): | 572 allow_cached_props=False, timeout=None, retries=None): |
| 574 """Install a split APK. | 573 """Install a split APK. |
| 575 | 574 |
| 576 Noop if all of the APK splits are already installed. | 575 Noop if all of the APK splits are already installed. |
| 577 | 576 |
| 578 Args: | 577 Args: |
| (...skipping 1377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1956 | 1955 |
| 1957 @decorators.WithTimeoutAndRetriesFromInstance() | 1956 @decorators.WithTimeoutAndRetriesFromInstance() |
| 1958 def GrantPermissions(self, package, permissions, timeout=None, retries=None): | 1957 def GrantPermissions(self, package, permissions, timeout=None, retries=None): |
| 1959 # Permissions only need to be set on M and above because of the changes to | 1958 # Permissions only need to be set on M and above because of the changes to |
| 1960 # the permission model. | 1959 # the permission model. |
| 1961 if not permissions or self.build_version_sdk < version_codes.MARSHMALLOW: | 1960 if not permissions or self.build_version_sdk < version_codes.MARSHMALLOW: |
| 1962 return | 1961 return |
| 1963 # TODO(rnephew): After permission blacklist is complete, switch to using | 1962 # TODO(rnephew): After permission blacklist is complete, switch to using |
| 1964 # &&s instead of ;s. | 1963 # &&s instead of ;s. |
| 1965 cmd = '' | 1964 cmd = '' |
| 1966 logging.info('Setting permissions for %s', package) | 1965 logging.info('Setting permissions for %s.', package) |
| 1967 for p in permissions: | 1966 permissions = [p for p in permissions if p not in _PERMISSIONS_BLACKLIST] |
| 1968 if p not in _PERMISSIONS_BLACKLIST: | 1967 if ('android.permission.WRITE_EXTERNAL_STORAGE' in permissions |
| 1969 cmd += 'pm grant %s %s;' % (package, p) | 1968 and 'android.permission.READ_EXTERNAL_STORAGE' not in permissions): |
| 1970 logging.info(' %s', p) | 1969 permissions.append('android.permission.READ_EXTERNAL_STORAGE') |
| 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 |