From 7cd62d05e664b7f697645abac54e5aa536201462 Mon Sep 17 00:00:00 2001 From: Bryan Henry Date: Mon, 13 Aug 2018 16:01:43 -0700 Subject: [PATCH] Only collect APK certificates for system apps after OTA Tweak to ag/4642341 to reduce boot time impact. Bug: 112482814 Bug: 80093599 Bug: 74501739 Test: Manually 'faked' an OTA by switching slots between two builds with some apps installed. Verified only system apps got the forced certificate rescan. Change-Id: I987cf721e118297b1c40df92cc35e75830a7659c --- .../android/server/pm/PackageManagerService.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 6df0308931849..4121f5f524744 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -8914,15 +8914,16 @@ public class PackageManagerService extends IPackageManager.Stub + " better than this " + pkg.getLongVersionCode()); } - // Verify certificates against what was last scanned. If there was an upgrade or this is an - // updated priv app, we will force re-collecting certificate. - final boolean forceCollect = mIsUpgrade || - PackageManagerServiceUtils.isApkVerificationForced(disabledPkgSetting); + // Verify certificates against what was last scanned. If there was an upgrade and this is an + // app in a system partition, or if this is an updated priv app, we will force re-collecting + // certificate. + final boolean forceCollect = (mIsUpgrade && scanSystemPartition) + || PackageManagerServiceUtils.isApkVerificationForced(disabledPkgSetting); // Full APK verification can be skipped during certificate collection, only if the file is // in verified partition, or can be verified on access (when apk verity is enabled). In both // cases, only data in Signing Block is verified instead of the whole file. - final boolean skipVerify = ((parseFlags & PackageParser.PARSE_IS_SYSTEM_DIR) != 0) || - (forceCollect && canSkipFullPackageVerification(pkg)); + final boolean skipVerify = scanSystemPartition + || (forceCollect && canSkipFullPackageVerification(pkg)); collectCertificatesLI(pkgSetting, pkg, forceCollect, skipVerify); // Reset profile if the application version is changed