summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/content/pm/PackageManager.java6
-rw-r--r--services/core/java/com/android/server/vr/VrManagerService.java20
2 files changed, 20 insertions, 6 deletions
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index a75f11167721..39133b829d36 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -3291,7 +3291,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
@@ -3316,7 +3317,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
diff --git a/services/core/java/com/android/server/vr/VrManagerService.java b/services/core/java/com/android/server/vr/VrManagerService.java
index fdadc8de717f..10a0f6f5c6ba 100644
--- a/services/core/java/com/android/server/vr/VrManagerService.java
+++ b/services/core/java/com/android/server/vr/VrManagerService.java
@@ -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.");
+ }
}
}