Add signing linage support for android_app_import

Test: app_test
Bug: 153366049
Change-Id: I260f198637a1a0f8b3373250413356785c56588a
This commit is contained in:
Liz Kammer 2020-05-13 15:49:21 -07:00
parent c8f2f186d1
commit 2bc57f6afe
2 changed files with 29 additions and 1 deletions

View File

@ -1245,6 +1245,9 @@ type AndroidAppImportProperties struct {
// be set for presigned modules.
Presigned *bool
// Name of the signing certificate lineage file.
Lineage *string
// Sign with the default system dev certificate. Must be used judiciously. Most imported apps
// need to either specify a specific certificate or be presigned.
Default_dev_cert *bool
@ -1443,7 +1446,11 @@ func (a *AndroidAppImport) generateAndroidBuildActions(ctx android.ModuleContext
}
a.certificate = certificates[0]
signed := android.PathForModuleOut(ctx, "signed", apkFilename)
SignAppPackage(ctx, signed, dexOutput, certificates, nil, nil)
var lineageFile android.Path
if lineage := String(a.properties.Lineage); lineage != "" {
lineageFile = android.PathForModuleSrc(ctx, lineage)
}
SignAppPackage(ctx, signed, dexOutput, certificates, nil, lineageFile)
a.outputFile = signed
} else {
alignedApk := android.PathForModuleOut(ctx, "zip-aligned", apkFilename)

View File

@ -2010,6 +2010,27 @@ func TestAndroidAppImport_Presigned(t *testing.T) {
}
}
func TestAndroidAppImport_SigningLineage(t *testing.T) {
ctx, _ := testJava(t, `
android_app_import {
name: "foo",
apk: "prebuilts/apk/app.apk",
certificate: "platform",
lineage: "lineage.bin",
}
`)
variant := ctx.ModuleForTests("foo", "android_common")
// Check cert signing lineage flag.
signedApk := variant.Output("signed/foo.apk")
signingFlag := signedApk.Args["flags"]
expected := "--lineage lineage.bin"
if expected != signingFlag {
t.Errorf("Incorrect signing flags, expected: %q, got: %q", expected, signingFlag)
}
}
func TestAndroidAppImport_DefaultDevCert(t *testing.T) {
ctx, _ := testJava(t, `
android_app_import {