From 6e96460f76b481017a5f5c8ffe8b99165eb2acd0 Mon Sep 17 00:00:00 2001 From: Jeongsik Mun Date: Fri, 20 Jan 2023 13:07:10 +0900 Subject: [PATCH] Remove UPDATED_SYSTEM_APP from updated system apps no longer exist This address an issue where getPkgState().isUpdatedSystemApp() remains true even if the apk on /system is removed during OTA. With this change, it sets updatedSystemApp to false when revoking system privileges before re-scanning an apk on /data for updated system apps no longer exist. Bug: 265752747 Test: Manually tested 1. Install an app on /product 2. Update the app 3. Delete the apk on /product and reboot 4. Make sure FLAG_UPDATED_SYSTEM_APP removed Change-Id: I9d9136ac19326599a20afd4710afdaf904572cb2 --- .../java/com/android/server/pm/InstallPackageHelper.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/services/core/java/com/android/server/pm/InstallPackageHelper.java b/services/core/java/com/android/server/pm/InstallPackageHelper.java index 5f424edb15c4b..596e9b9646434 100644 --- a/services/core/java/com/android/server/pm/InstallPackageHelper.java +++ b/services/core/java/com/android/server/pm/InstallPackageHelper.java @@ -3588,6 +3588,11 @@ final class InstallPackageHelper { // remove the package from the system and re-scan it without any // special privileges mRemovePackageHelper.removePackage(pkg, true); + PackageSetting ps = mPm.mSettings.getPackageLPr(packageName); + if (ps != null) { + ps.getPkgState().setUpdatedSystemApp(false); + } + try { final File codePath = new File(pkg.getPath()); synchronized (mPm.mInstallLock) {