Merge "Revert "Merge "Restore V2+ signature requirement for system apps" into tm-dev am: a347b6c2e6 am: 8aa6d20125"" into tm-d1-dev
This commit is contained in:
@@ -1414,9 +1414,11 @@ public class PackageParser {
|
||||
final ParseTypeImpl input = ParseTypeImpl.forDefaultParsing();
|
||||
final ParseResult<android.content.pm.SigningDetails> result;
|
||||
if (skipVerify) {
|
||||
// systemDir APKs are already trusted, save time by not verifying
|
||||
// systemDir APKs are already trusted, save time by not verifying; since the signature
|
||||
// is not verified and some system apps can have their V2+ signatures stripped allow
|
||||
// pulling the certs from the jar signature.
|
||||
result = ApkSignatureVerifier.unsafeGetCertsWithoutVerification(
|
||||
input, apkPath, minSignatureScheme);
|
||||
input, apkPath, SigningDetails.SignatureSchemeVersion.JAR);
|
||||
} else {
|
||||
result = ApkSignatureVerifier.verify(input, apkPath, minSignatureScheme);
|
||||
}
|
||||
|
||||
@@ -4187,8 +4187,8 @@ final class InstallPackageHelper {
|
||||
assertOverlayIsValid(pkg, parseFlags, scanFlags);
|
||||
}
|
||||
|
||||
// Ensure the package is signed with at least the minimum signature scheme version
|
||||
// required for its target SDK.
|
||||
// If the package is not on a system partition ensure it is signed with at least the
|
||||
// minimum signature scheme version required for its target SDK.
|
||||
ScanPackageUtils.assertMinSignatureSchemeIsValid(pkg, parseFlags);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -690,14 +690,16 @@ final class ScanPackageUtils {
|
||||
|
||||
public static void assertMinSignatureSchemeIsValid(AndroidPackage pkg,
|
||||
@ParsingPackageUtils.ParseFlags int parseFlags) throws PackageManagerException {
|
||||
int minSignatureSchemeVersion =
|
||||
ApkSignatureVerifier.getMinimumSignatureSchemeVersionForTargetSdk(
|
||||
pkg.getTargetSdkVersion());
|
||||
if (pkg.getSigningDetails().getSignatureSchemeVersion()
|
||||
< minSignatureSchemeVersion) {
|
||||
throw new PackageManagerException(INSTALL_PARSE_FAILED_NO_CERTIFICATES,
|
||||
"No signature found in package of version " + minSignatureSchemeVersion
|
||||
+ " or newer for package " + pkg.getPackageName());
|
||||
if ((parseFlags & ParsingPackageUtils.PARSE_IS_SYSTEM_DIR) == 0) {
|
||||
int minSignatureSchemeVersion =
|
||||
ApkSignatureVerifier.getMinimumSignatureSchemeVersionForTargetSdk(
|
||||
pkg.getTargetSdkVersion());
|
||||
if (pkg.getSigningDetails().getSignatureSchemeVersion()
|
||||
< minSignatureSchemeVersion) {
|
||||
throw new PackageManagerException(INSTALL_PARSE_FAILED_NO_CERTIFICATES,
|
||||
"No signature found in package of version " + minSignatureSchemeVersion
|
||||
+ " or newer for package " + pkg.getPackageName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3105,9 +3105,11 @@ public class ParsingPackageUtils {
|
||||
}
|
||||
final ParseResult<SigningDetails> verified;
|
||||
if (skipVerify) {
|
||||
// systemDir APKs are already trusted, save time by not verifying
|
||||
// systemDir APKs are already trusted, save time by not verifying; since the
|
||||
// signature is not verified and some system apps can have their V2+ signatures
|
||||
// stripped allow pulling the certs from the jar signature.
|
||||
verified = ApkSignatureVerifier.unsafeGetCertsWithoutVerification(input, baseCodePath,
|
||||
minSignatureScheme);
|
||||
SigningDetails.SignatureSchemeVersion.JAR);
|
||||
} else {
|
||||
verified = ApkSignatureVerifier.verify(input, baseCodePath, minSignatureScheme);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user