From 6158528e152304f1259e31ff343358ff0f50c0e4 Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Fri, 14 Jul 2023 16:23:39 -0700 Subject: Only allow setting presigned without preprocessed on targetSdk < 30 When targetSdk is >= 30, the system verifies that you use a valid signature V2+ certificate. Uncompressing ndk/dex files or aligning the zip file will break a signature V2, so these apks should really just set preprocessed: true. Fixes: 185811447 Test: Presubmits Change-Id: Id89c42bcd5b5daa6eda1716bff4023423298036b --- java/builder.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'java/builder.go') diff --git a/java/builder.go b/java/builder.go index debf49a00..bf919175d 100644 --- a/java/builder.go +++ b/java/builder.go @@ -277,6 +277,14 @@ var ( Command: `${config.Zip2ZipCmd} -i ${in} -o ${out} -x 'META-INF/services/**/*'`, CommandDeps: []string{"${config.Zip2ZipCmd}"}, }) + + checkBelowTargetSdk30ForNonPreprocessedApks = pctx.AndroidStaticRule("checkBelowTargetSdk30ForNonPreprocessedApks", + blueprint.RuleParams{ + Command: "build/soong/scripts/check_target_sdk_less_than_30.py ${config.Aapt2Cmd} $in $out", + CommandDeps: []string{"build/soong/scripts/check_target_sdk_less_than_30.py", "${config.Aapt2Cmd}"}, + Description: "Check prebuilt target sdk version", + }, + ) ) func init() { @@ -689,12 +697,13 @@ func GenerateMainClassManifest(ctx android.ModuleContext, outputFile android.Wri android.WriteFileRule(ctx, outputFile, "Main-Class: "+mainClass+"\n") } -func TransformZipAlign(ctx android.ModuleContext, outputFile android.WritablePath, inputFile android.Path) { +func TransformZipAlign(ctx android.ModuleContext, outputFile android.WritablePath, inputFile android.Path, validations android.Paths) { ctx.Build(pctx, android.BuildParams{ Rule: zipalign, Description: "align", Input: inputFile, Output: outputFile, + Validations: validations, }) } -- cgit v1.2.3-59-g8ed1b