DivestOS/Patches/LineageOS-20.0/android_frameworks_base/0029-Strict_versionCode_Checks-2.patch
2023-01-11 12:19:41 -05:00

52 lines
3.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Dmitry Muhomor <muhomor.dmitry@gmail.com>
Date: Tue, 27 Dec 2022 11:21:28 +0200
Subject: [PATCH] prefer package from OS image over equal version of upgraded
system package
Previously, system package that was upgraded on the previous OS version was used by the OS even
after OS upgrade that included the same version of this package in OS image.
This weakened verified boot and wasted storage space.
---
.../com/android/server/pm/InstallPackageHelper.java | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/services/core/java/com/android/server/pm/InstallPackageHelper.java b/services/core/java/com/android/server/pm/InstallPackageHelper.java
index 0f3802ac794b..9a4dbb0a0a12 100644
--- a/services/core/java/com/android/server/pm/InstallPackageHelper.java
+++ b/services/core/java/com/android/server/pm/InstallPackageHelper.java
@@ -3842,10 +3842,10 @@ final class InstallPackageHelper {
final boolean newPkgChangedPaths = pkgAlreadyExists
&& !pkgSetting.getPathString().equals(parsedPackage.getPath());
- final boolean newPkgVersionGreater = pkgAlreadyExists
- && parsedPackage.getLongVersionCode() > pkgSetting.getVersionCode();
+ final boolean newPkgVersionGreaterOrEqual = pkgAlreadyExists
+ && parsedPackage.getLongVersionCode() >= pkgSetting.getVersionCode();
final boolean isSystemPkgBetter = scanSystemPartition && isSystemPkgUpdated
- && newPkgChangedPaths && newPkgVersionGreater;
+ && newPkgChangedPaths && newPkgVersionGreaterOrEqual;
if (isSystemPkgBetter) {
// The version of the application on /system is greater than the version on
// /data. Switch back to the application on /system.
@@ -3873,8 +3873,8 @@ final class InstallPackageHelper {
}
}
- // The version of the application on the /system partition is less than or
- // equal to the version on the /data partition. Throw an exception and use
+ // The version of the application on the /system partition is less than
+ // the version on the /data partition. Throw an exception and use
// the application already installed on the /data partition.
if (scanSystemPartition && isSystemPkgUpdated && !isSystemPkgBetter) {
// In the case of a skipped package, commitReconciledScanResultLocked is not called to
@@ -3938,7 +3938,7 @@ final class InstallPackageHelper {
deletePackageHelper.deletePackageLIF(parsedPackage.getPackageName(), null, true,
mPm.mUserManager.getUserIds(), 0, null, false);
}
- } else if (newPkgVersionGreater) {
+ } else if (newPkgVersionGreaterOrEqual) {
// The application on /system is newer than the application on /data.
// Simply remove the application on /data [keeping application data]
// and replace it with the version on /system.