Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7c1bd7fd authored by Kenny Root's avatar Kenny Root
Browse files

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
parent fca5677a
Loading
Loading
Loading
Loading
+5 −8
Original line number Diff line number Diff line
@@ -6181,19 +6181,16 @@ class PackageManagerService extends IPackageManager.Stub {
        }
        // Delete the updated package
        outInfo.isRemovedPackageSystemUpdate = true;
        boolean deleteCodeAndResources = false;
        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;
            }
        } else {
            // Preserve data by setting flag
            if ((flags & PackageManager.DONT_DELETE_DATA) == 0) {
            deleteCodeAndResources = false;
            flags |= PackageManager.DONT_DELETE_DATA;
        }
        }
        boolean ret = deleteInstalledPackageLI(p, deleteCodeAndResources, flags, outInfo);
        if (!ret) {
            return false;