Prevent crash on uninstall.

am: 12ab5e1d70

Change-Id: I8301d17bb0bbd16a4adeaadb7b7bd04ad7159407
This commit is contained in:
Ruben Brunk
2016-12-14 00:34:59 +00:00
committed by android-build-merger
2 changed files with 20 additions and 6 deletions

View File

@@ -3290,7 +3290,8 @@ public abstract class PackageManager {
* Grant a runtime permission to an application which the application does not
* already have. The permission must have been requested by the application.
* If the application is not allowed to hold the permission, a {@link
* java.lang.SecurityException} is thrown.
* java.lang.SecurityException} is thrown. If the package or permission is
* invalid, a {@link java.lang.IllegalArgumentException} is thrown.
* <p>
* <strong>Note: </strong>Using this API requires holding
* android.permission.GRANT_REVOKE_PERMISSIONS and if the user id is
@@ -3315,7 +3316,8 @@ public abstract class PackageManager {
* #grantRuntimePermission(String, String, android.os.UserHandle)}. The
* permission must have been requested by and granted to the application.
* If the application is not allowed to hold the permission, a {@link
* java.lang.SecurityException} is thrown.
* java.lang.SecurityException} is thrown. If the package or permission is
* invalid, a {@link java.lang.IllegalArgumentException} is thrown.
* <p>
* <strong>Note: </strong>Using this API requires holding
* android.permission.GRANT_REVOKE_PERMISSIONS and if the user id is

View File

@@ -663,16 +663,28 @@ public class VrManagerService extends SystemService implements EnabledComponentC
private void grantCoarseLocationPermissionIfNeeded(String pkg, int userId) {
// Don't clobber the user if permission set in current state explicitly
if (!isPermissionUserUpdated(Manifest.permission.ACCESS_COARSE_LOCATION, pkg, userId)) {
mContext.getPackageManager().grantRuntimePermission(pkg,
Manifest.permission.ACCESS_COARSE_LOCATION, new UserHandle(userId));
try {
mContext.getPackageManager().grantRuntimePermission(pkg,
Manifest.permission.ACCESS_COARSE_LOCATION, new UserHandle(userId));
} catch (IllegalArgumentException e) {
// Package was removed during update.
Slog.w(TAG, "Could not grant coarse location permission, package " + pkg
+ " was removed.");
}
}
}
private void revokeCoarseLocationPermissionIfNeeded(String pkg, int userId) {
// Don't clobber the user if permission set in current state explicitly
if (!isPermissionUserUpdated(Manifest.permission.ACCESS_COARSE_LOCATION, pkg, userId)) {
mContext.getPackageManager().revokeRuntimePermission(pkg,
Manifest.permission.ACCESS_COARSE_LOCATION, new UserHandle(userId));
try {
mContext.getPackageManager().revokeRuntimePermission(pkg,
Manifest.permission.ACCESS_COARSE_LOCATION, new UserHandle(userId));
} catch (IllegalArgumentException e) {
// Package was removed during update.
Slog.w(TAG, "Could not revoke coarse location permission, package " + pkg
+ " was removed.");
}
}
}