Merge changes from topic "fix-presigned-apk-validation" into main am: 38f97d7a08
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/3194336 Change-Id: Ic8bd8e7201aad8099924856bc9341e1c6874e29c Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -431,6 +431,9 @@ func (a *AndroidAppImport) validatePresignedApk(ctx android.ModuleContext, srcAp
|
||||
var extraArgs []string
|
||||
if a.Privileged() {
|
||||
extraArgs = append(extraArgs, "--privileged")
|
||||
if ctx.Config().UncompressPrivAppDex() {
|
||||
extraArgs = append(extraArgs, "--uncompress-priv-app-dex")
|
||||
}
|
||||
}
|
||||
if proptools.Bool(a.properties.Skip_preprocessed_apk_checks) {
|
||||
extraArgs = append(extraArgs, "--skip-preprocessed-apk-checks")
|
||||
|
@@ -777,30 +777,79 @@ func TestAndroidTestImport_Preprocessed(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAndroidAppImport_Preprocessed(t *testing.T) {
|
||||
ctx, _ := testJava(t, `
|
||||
android_app_import {
|
||||
name: "foo",
|
||||
apk: "prebuilts/apk/app.apk",
|
||||
presigned: true,
|
||||
preprocessed: true,
|
||||
}
|
||||
`)
|
||||
for _, dontUncompressPrivAppDexs := range []bool{false, true} {
|
||||
name := fmt.Sprintf("dontUncompressPrivAppDexs:%t", dontUncompressPrivAppDexs)
|
||||
t.Run(name, func(t *testing.T) {
|
||||
result := android.GroupFixturePreparers(
|
||||
PrepareForTestWithJavaDefaultModules,
|
||||
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
||||
variables.UncompressPrivAppDex = proptools.BoolPtr(!dontUncompressPrivAppDexs)
|
||||
}),
|
||||
).RunTestWithBp(t, `
|
||||
android_app_import {
|
||||
name: "foo",
|
||||
apk: "prebuilts/apk/app.apk",
|
||||
presigned: true,
|
||||
preprocessed: true,
|
||||
}
|
||||
|
||||
apkName := "foo.apk"
|
||||
variant := ctx.ModuleForTests("foo", "android_common")
|
||||
outputBuildParams := variant.Output(apkName).BuildParams
|
||||
if outputBuildParams.Rule.String() != android.Cp.String() {
|
||||
t.Errorf("Unexpected prebuilt android_app_import rule: " + outputBuildParams.Rule.String())
|
||||
}
|
||||
android_app_import {
|
||||
name: "bar",
|
||||
apk: "prebuilts/apk/app.apk",
|
||||
presigned: true,
|
||||
privileged: true,
|
||||
preprocessed: true,
|
||||
}
|
||||
`)
|
||||
|
||||
// Make sure compression and aligning were validated.
|
||||
if outputBuildParams.Validation == nil {
|
||||
t.Errorf("Expected validation rule, but was not found")
|
||||
}
|
||||
// non-privileged app
|
||||
apkName := "foo.apk"
|
||||
variant := result.ModuleForTests("foo", "android_common")
|
||||
outputBuildParams := variant.Output(apkName).BuildParams
|
||||
if outputBuildParams.Rule.String() != android.Cp.String() {
|
||||
t.Errorf("Unexpected prebuilt android_app_import rule: " + outputBuildParams.Rule.String())
|
||||
}
|
||||
|
||||
validationBuildParams := variant.Output("validated-prebuilt/check.stamp").BuildParams
|
||||
if validationBuildParams.Rule.String() != checkPresignedApkRule.String() {
|
||||
t.Errorf("Unexpected validation rule: " + validationBuildParams.Rule.String())
|
||||
// Make sure compression and aligning were validated.
|
||||
if outputBuildParams.Validation == nil {
|
||||
t.Errorf("Expected validation rule, but was not found")
|
||||
}
|
||||
|
||||
validationBuildParams := variant.Output("validated-prebuilt/check.stamp").BuildParams
|
||||
if validationBuildParams.Rule.String() != checkPresignedApkRule.String() {
|
||||
t.Errorf("Unexpected validation rule: " + validationBuildParams.Rule.String())
|
||||
}
|
||||
|
||||
expectedScriptArgs := "--preprocessed"
|
||||
actualScriptArgs := validationBuildParams.Args["extraArgs"]
|
||||
android.AssertStringEquals(t, "check script extraArgs", expectedScriptArgs, actualScriptArgs)
|
||||
|
||||
// privileged app
|
||||
apkName = "bar.apk"
|
||||
variant = result.ModuleForTests("bar", "android_common")
|
||||
outputBuildParams = variant.Output(apkName).BuildParams
|
||||
if outputBuildParams.Rule.String() != android.Cp.String() {
|
||||
t.Errorf("Unexpected prebuilt android_app_import rule: " + outputBuildParams.Rule.String())
|
||||
}
|
||||
|
||||
// Make sure compression and aligning were validated.
|
||||
if outputBuildParams.Validation == nil {
|
||||
t.Errorf("Expected validation rule, but was not found")
|
||||
}
|
||||
|
||||
validationBuildParams = variant.Output("validated-prebuilt/check.stamp").BuildParams
|
||||
if validationBuildParams.Rule.String() != checkPresignedApkRule.String() {
|
||||
t.Errorf("Unexpected validation rule: " + validationBuildParams.Rule.String())
|
||||
}
|
||||
|
||||
expectedScriptArgs = "--privileged"
|
||||
if !dontUncompressPrivAppDexs {
|
||||
expectedScriptArgs += " --uncompress-priv-app-dex"
|
||||
}
|
||||
expectedScriptArgs += " --preprocessed"
|
||||
actualScriptArgs = validationBuildParams.Args["extraArgs"]
|
||||
android.AssertStringEquals(t, "check script extraArgs", expectedScriptArgs, actualScriptArgs)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user