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

Commit 9c37cd29 authored by Todd Kennedy's avatar Todd Kennedy
Browse files

Maintain legacy signatures

The signature field is deprecated, but must still be populated. The
thought was that for APEX files [which is a new concept and thus
could use the new way to handle signatures] we could remove this
capability, but, it turns out Play relies on it.

Change-Id: I7096567082d4f798be1d3e6007122750453665ae
Fixes: 130827182
Test: Manual.
Test: Create sample app that dumped the signatures of an APEX
Test: Note that the signatures before this change were 'null' and set to something after this change
parent 10ae84a9
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -8447,6 +8447,20 @@ public class PackageParser {
        // Collect certificates
        if ((flags & PackageManager.GET_SIGNING_CERTIFICATES) != 0) {
            collectCertificates(p, apexFile, false);
            // Keep legacy mechanism for handling signatures. While this is deprecated, it's
            // still part of the public API and needs to be maintained
            if (p.mSigningDetails.hasPastSigningCertificates()) {
                // Package has included signing certificate rotation information.  Return
                // the oldest cert so that programmatic checks keep working even if unaware
                // of key rotation.
                pi.signatures = new Signature[1];
                pi.signatures[0] = p.mSigningDetails.pastSigningCertificates[0];
            } else if (p.mSigningDetails.hasSignatures()) {
                // otherwise keep old behavior
                int numberOfSigs = p.mSigningDetails.signatures.length;
                pi.signatures = new Signature[numberOfSigs];
                System.arraycopy(p.mSigningDetails.signatures, 0, pi.signatures, 0, numberOfSigs);
            }
            if (p.mSigningDetails != SigningDetails.UNKNOWN) {
                // only return a valid SigningInfo if there is signing information to report
                pi.signingInfo = new SigningInfo(p.mSigningDetails);