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

Commit 16618cd8 authored by Mohammad Samiul Islam's avatar Mohammad Samiul Islam
Browse files

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
Merged-In: I0c0e6eaee65a6c77f62425c3929ffa805d1e0f47
parent ef4bf730
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -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"