Allow key downgrade during staged install of apex packages

Downgrade is permitted only for the system server initiated
sessions. This is enforced by INSTALL_ALLOW_DOWNGRADE flag
parameter.

Bug: 136002636
Test: atest RollbackManagerHostTest#testApexKeyRotationStagedRollback
Change-Id: I0c0e6eaee65a6c77f62425c3929ffa805d1e0f47
This commit is contained in:
Mohammad Samiul Islam
2019-08-22 15:43:55 +01:00
parent 14275a9388
commit 8e35db194f

View File

@@ -150,6 +150,14 @@ public class StagingManager {
return; return;
} }
// Verify signing details for downgrade
// Allow downgrading from B to A iff it is possible to upgrade from A to B
if (existingApexPkg.getLongVersionCode() > newApexPkg.getLongVersionCode()
&& existingSigningDetails.checkCapability(signingDetails,
PackageParser.SigningDetails.CertCapabilities.INSTALLED_DATA)) {
return;
}
throw new PackageManagerException(SessionInfo.STAGED_SESSION_VERIFICATION_FAILED, throw new PackageManagerException(SessionInfo.STAGED_SESSION_VERIFICATION_FAILED,
"APK-container signature of APEX package " + packageName + " with version " "APK-container signature of APEX package " + packageName + " with version "
+ newApexPkg.versionCodeMajor + " and path " + apexPath + " is not" + newApexPkg.versionCodeMajor + " and path " + apexPath + " is not"