summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2012-05-07 23:04:52 -0700
committerKenny Root <kroot@google.com>2012-05-07 23:07:49 -0700
commitc52d6fd04316483f4a88f3a087b93bb197cd97f4 (patch)
tree9870f2edcfd9f3e84f087a75d6f388b7244c2d75 /services
parent775bcac6bcdd04b6bffd23b5de0da4588a749337 (diff)
downloadframeworks_base-c52d6fd04316483f4a88f3a087b93bb197cd97f4.zip
frameworks_base-c52d6fd04316483f4a88f3a087b93bb197cd97f4.tar.gz
frameworks_base-c52d6fd04316483f4a88f3a087b93bb197cd97f4.tar.bz2
Prune hidden system apps when removed via OTA
System applications which had an update applied to them at some point were in a semi-broken state when removed via an OTA. The "updated-package" setting would stay around forever and permissions wouldn't be revoked. Change-Id: I908e813b5de59c0f777d9b051253b28255a1c694
Diffstat (limited to 'services')
-rw-r--r--services/java/com/android/server/pm/PackageManagerService.java34
-rw-r--r--services/java/com/android/server/pm/Settings.java10
2 files changed, 36 insertions, 8 deletions
diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java
index b5567d3..4ae3c57 100644
--- a/services/java/com/android/server/pm/PackageManagerService.java
+++ b/services/java/com/android/server/pm/PackageManagerService.java
@@ -1063,23 +1063,29 @@ public class PackageManagerService extends IPackageManager.Stub {
mInstaller.moveFiles();
// Prune any system packages that no longer exist.
+ final List<String> possiblyDeletedSystemApps = new ArrayList<String>();
if (!mOnlyCore) {
Iterator<PackageSetting> psit = mSettings.mPackages.values().iterator();
while (psit.hasNext()) {
PackageSetting ps = psit.next();
- if ((ps.pkgFlags&ApplicationInfo.FLAG_SYSTEM) != 0
- && !mPackages.containsKey(ps.name)
- && !mSettings.mDisabledSysPackages.containsKey(ps.name)) {
+ if ((ps.pkgFlags&ApplicationInfo.FLAG_SYSTEM) == 0
+ || mPackages.containsKey(ps.name)) {
+ continue;
+ }
+
+ if (!mSettings.isDisabledSystemPackageLPr(ps.name)) {
psit.remove();
String msg = "System package " + ps.name
+ " no longer exists; wiping its data";
reportSettingsProblem(Log.WARN, msg);
mInstaller.remove(ps.name, 0);
sUserManager.removePackageForAllUsers(ps.name);
+ } else {
+ possiblyDeletedSystemApps.add(ps.name);
}
}
}
-
+
mAppInstallDir = new File(dataDir, "app");
//look for any incomplete package installations
ArrayList<PackageSetting> deletePkgsList = mSettings.getListOfIncompleteInstallPackagesLPr();
@@ -1104,6 +1110,21 @@ public class PackageManagerService extends IPackageManager.Stub {
mDrmAppInstallObserver.startWatching();
scanDirLI(mDrmAppPrivateInstallDir, PackageParser.PARSE_FORWARD_LOCK,
scanMode, 0);
+
+ /**
+ * Remove disable package settings for any system apps
+ * that were removed via an OTA.
+ */
+ for (String deletedAppName : possiblyDeletedSystemApps) {
+ PackageParser.Package deletedPkg = mPackages.get(deletedAppName);
+ if (deletedPkg != null) {
+ mSettings.removeDisabledSystemPackageLPw(deletedAppName);
+ deletedPkg.applicationInfo.flags &= ~ApplicationInfo.FLAG_SYSTEM;
+
+ PackageSetting deletedPs = mSettings.mPackages.get(deletedAppName);
+ deletedPs.pkgFlags &= ~ApplicationInfo.FLAG_SYSTEM;
+ }
+ }
} else {
mAppInstallObserver = null;
mDrmAppInstallObserver = null;
@@ -3043,8 +3064,7 @@ public class PackageManagerService extends IPackageManager.Stub {
// Check to see if this package could be hiding/updating a system
// package. Must look for it either under the original or real
// package name depending on our state.
- updatedPkg = mSettings.mDisabledSysPackages.get(
- ps != null ? ps.name : pkg.packageName);
+ updatedPkg = mSettings.getDisabledSystemPkgLPr(ps != null ? ps.name : pkg.packageName);
}
// First check if this is a system package that may involve an update
if (updatedPkg != null && (parseFlags&PackageParser.PARSE_IS_SYSTEM) != 0) {
@@ -3523,7 +3543,7 @@ public class PackageManagerService extends IPackageManager.Stub {
mTransferedPackages.add(pkg.packageName);
}
- if (mSettings.mDisabledSysPackages.get(pkg.packageName) != null) {
+ if (mSettings.isDisabledSystemPackageLPr(pkg.packageName)) {
pkg.applicationInfo.flags |= ApplicationInfo.FLAG_UPDATED_SYSTEM_APP;
}
diff --git a/services/java/com/android/server/pm/Settings.java b/services/java/com/android/server/pm/Settings.java
index d015278..d0eda2d 100644
--- a/services/java/com/android/server/pm/Settings.java
+++ b/services/java/com/android/server/pm/Settings.java
@@ -102,7 +102,7 @@ final class Settings {
final HashMap<String, PackageSetting> mPackages =
new HashMap<String, PackageSetting>();
// List of replaced system applications
- final HashMap<String, PackageSetting> mDisabledSysPackages =
+ private final HashMap<String, PackageSetting> mDisabledSysPackages =
new HashMap<String, PackageSetting>();
// These are the last platform API version we were using for
@@ -280,6 +280,14 @@ final class Settings {
return ret;
}
+ boolean isDisabledSystemPackageLPr(String name) {
+ return mDisabledSysPackages.containsKey(name);
+ }
+
+ void removeDisabledSystemPackageLPw(String name) {
+ mDisabledSysPackages.remove(name);
+ }
+
PackageSetting addPackageLPw(String name, String realName, File codePath, File resourcePath,
String nativeLibraryPathString, int uid, int vc, int pkgFlags) {
PackageSetting p = mPackages.get(name);