Fix logic error in downgrade of system apps

A logic error would allow not deleting data when uninstalling a system
app upgrade that's of a newer release than the on on the system
partition. If the system app had a database upgrade and this happened,
you might be in trouble.

Luckily it appears no one ever does this in code. You'd have to manually
get there doing:

adb uninstall -k updated.system.package

Change-Id: I3110fedf2d147975a0635c71898d985dd642a2c1
This commit is contained in:
Kenny Root
2010-09-01 13:44:11 -07:00
parent fca5677aee
commit 7c1bd7fdbf

View File

@@ -6181,18 +6181,15 @@ class PackageManagerService extends IPackageManager.Stub {
}
// Delete the updated package
outInfo.isRemovedPackageSystemUpdate = true;
boolean deleteCodeAndResources = false;
if (ps.versionCode < p.mVersionCode) {
final boolean deleteCodeAndResources;
if (ps.versionCode < p.mVersionCode) {
// Delete code and resources for downgrades
deleteCodeAndResources = true;
if ((flags & PackageManager.DONT_DELETE_DATA) == 0) {
flags &= ~PackageManager.DONT_DELETE_DATA;
}
flags &= ~PackageManager.DONT_DELETE_DATA;
} else {
// Preserve data by setting flag
if ((flags & PackageManager.DONT_DELETE_DATA) == 0) {
flags |= PackageManager.DONT_DELETE_DATA;
}
deleteCodeAndResources = false;
flags |= PackageManager.DONT_DELETE_DATA;
}
boolean ret = deleteInstalledPackageLI(p, deleteCodeAndResources, flags, outInfo);
if (!ret) {