summaryrefslogtreecommitdiffstats
path: root/services/java
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2013-04-12 12:00:59 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-04-12 12:00:59 -0700
commit7415737326d04683240d12bcf7cda46206e57d60 (patch)
treee2d5f03c077dff1ad4d5c3f12e43abd267730c7f /services/java
parent0d1ce86476204045a4b28e627d880c8bd593106d (diff)
parent12cff6f6289cb6bb06b716e75e7776099343323a (diff)
downloadframeworks_base-7415737326d04683240d12bcf7cda46206e57d60.zip
frameworks_base-7415737326d04683240d12bcf7cda46206e57d60.tar.gz
frameworks_base-7415737326d04683240d12bcf7cda46206e57d60.tar.bz2
am 12cff6f6: am 10a25c0a: Merge "Remove keystore entries when app data cleared" into jb-mr2-dev
* commit '12cff6f6289cb6bb06b716e75e7776099343323a': Remove keystore entries when app data cleared
Diffstat (limited to 'services/java')
-rw-r--r--services/java/com/android/server/pm/PackageManagerService.java68
1 files changed, 45 insertions, 23 deletions
diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java
index 7ab7ce6..253ffe4 100644
--- a/services/java/com/android/server/pm/PackageManagerService.java
+++ b/services/java/com/android/server/pm/PackageManagerService.java
@@ -8718,15 +8718,7 @@ public class PackageManagerService extends IPackageManager.Stub {
if (outInfo != null) {
// A user ID was deleted here. Go through all users and remove it
// from KeyStore.
- final int appId = outInfo.removedAppId;
- if (appId != -1) {
- final KeyStore keyStore = KeyStore.getInstance();
- if (keyStore != null) {
- for (final int userId : sUserManager.getUserIds()) {
- keyStore.clearUid(UserHandle.getUid(userId, appId));
- }
- }
- }
+ removeKeystoreDataIfNeeded(UserHandle.USER_ALL, outInfo.removedAppId);
}
}
@@ -8886,6 +8878,7 @@ public class PackageManagerService extends IPackageManager.Stub {
outInfo.removedUsers = new int[] {removeUser};
}
mInstaller.clearUserData(packageName, removeUser);
+ removeKeystoreDataIfNeeded(removeUser, appId);
schedulePackageCleaning(packageName, removeUser, false);
return true;
}
@@ -9041,29 +9034,34 @@ public class PackageManagerService extends IPackageManager.Stub {
}
PackageParser.Package p;
boolean dataOnly = false;
+ final int appId;
synchronized (mPackages) {
p = mPackages.get(packageName);
- if(p == null) {
+ if (p == null) {
dataOnly = true;
PackageSetting ps = mSettings.mPackages.get(packageName);
- if((ps == null) || (ps.pkg == null)) {
- Slog.w(TAG, "Package named '" + packageName +"' doesn't exist.");
+ if ((ps == null) || (ps.pkg == null)) {
+ Slog.w(TAG, "Package named '" + packageName + "' doesn't exist.");
return false;
}
p = ps.pkg;
}
- }
-
- if (!dataOnly) {
- //need to check this only for fully installed applications
- if (p == null) {
- Slog.w(TAG, "Package named '" + packageName +"' doesn't exist.");
- return false;
+ if (!dataOnly) {
+ // need to check this only for fully installed applications
+ if (p == null) {
+ Slog.w(TAG, "Package named '" + packageName + "' doesn't exist.");
+ return false;
+ }
+ final ApplicationInfo applicationInfo = p.applicationInfo;
+ if (applicationInfo == null) {
+ Slog.w(TAG, "Package " + packageName + " has no applicationInfo.");
+ return false;
+ }
}
- final ApplicationInfo applicationInfo = p.applicationInfo;
- if (applicationInfo == null) {
- Slog.w(TAG, "Package " + packageName + " has no applicationInfo.");
- return false;
+ if (p != null && p.applicationInfo != null) {
+ appId = p.applicationInfo.uid;
+ } else {
+ appId = -1;
}
}
int retCode = mInstaller.clearUserData(packageName, userId);
@@ -9072,9 +9070,33 @@ public class PackageManagerService extends IPackageManager.Stub {
+ packageName);
return false;
}
+ removeKeystoreDataIfNeeded(userId, appId);
return true;
}
+ /**
+ * Remove entries from the keystore daemon. Will only remove it if the
+ * {@code appId} is valid.
+ */
+ private static void removeKeystoreDataIfNeeded(int userId, int appId) {
+ if (appId < 0) {
+ return;
+ }
+
+ final KeyStore keyStore = KeyStore.getInstance();
+ if (keyStore != null) {
+ if (userId == UserHandle.USER_ALL) {
+ for (final int individual : sUserManager.getUserIds()) {
+ keyStore.clearUid(UserHandle.getUid(individual, appId));
+ }
+ } else {
+ keyStore.clearUid(UserHandle.getUid(userId, appId));
+ }
+ } else {
+ Slog.w(TAG, "Could not contact keystore to clear entries for app id " + appId);
+ }
+ }
+
public void deleteApplicationCacheFiles(final String packageName,
final IPackageDataObserver observer) {
mContext.enforceCallingOrSelfPermission(