Index: build/android/devil/android/device_utils.py |
diff --git a/build/android/devil/android/device_utils.py b/build/android/devil/android/device_utils.py |
index e9d16935ad2fc307b406fb5e8e45b5b7decf4993..2ff5d9359e258769024de66917e90a42357f1cc2 100644 |
--- a/build/android/devil/android/device_utils.py |
+++ b/build/android/devil/android/device_utils.py |
@@ -625,6 +625,10 @@ class DeviceUtils(object): |
apks_to_install, partial=partial, reinstall=reinstall) |
else: |
self.adb.Install(base_apk, reinstall=reinstall) |
+ if (permissions is None |
+ and self.build_version_sdk >= version_codes.MARSHMALLOW): |
+ permissions = apk_helper.ApkHelper(base_apk).GetPermissions() |
+ self.GrantPermissions(package_name, permissions) |
# Upon success, we know the device checksums, but not their paths. |
if host_checksums is not None: |
self._cache['package_apk_checksums'][package_name] = host_checksums |
@@ -633,11 +637,6 @@ class DeviceUtils(object): |
# consistent, we explicitly terminate it when skipping the install. |
self.ForceStop(package_name) |
- if (permissions is None |
- and self.build_version_sdk >= version_codes.MARSHMALLOW): |
- permissions = apk_helper.ApkHelper(base_apk).GetPermissions() |
- self.GrantPermissions(package_name, permissions) |
- |
@decorators.WithTimeoutAndRetriesFromInstance() |
def Uninstall(self, package_name, keep_data=False, timeout=None, |
retries=None): |