Add signing linage support for android_app_import
(This is a cherry pick.) Test: app_test Bug: 153366049 Merged-In: I260f198637a1a0f8b3373250413356785c56588a Change-Id: I260f198637a1a0f8b3373250413356785c56588a
This commit is contained in:
@@ -1282,6 +1282,9 @@ type AndroidAppImportProperties struct {
|
|||||||
// be set for presigned modules.
|
// be set for presigned modules.
|
||||||
Presigned *bool
|
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
|
// Sign with the default system dev certificate. Must be used judiciously. Most imported apps
|
||||||
// need to either specify a specific certificate or be presigned.
|
// need to either specify a specific certificate or be presigned.
|
||||||
Default_dev_cert *bool
|
Default_dev_cert *bool
|
||||||
@@ -1480,7 +1483,11 @@ func (a *AndroidAppImport) generateAndroidBuildActions(ctx android.ModuleContext
|
|||||||
}
|
}
|
||||||
a.certificate = certificates[0]
|
a.certificate = certificates[0]
|
||||||
signed := android.PathForModuleOut(ctx, "signed", apkFilename)
|
signed := android.PathForModuleOut(ctx, "signed", apkFilename)
|
||||||
SignAppPackage(ctx, signed, dexOutput, certificates, nil)
|
var lineageFile android.Path
|
||||||
|
if lineage := String(a.properties.Lineage); lineage != "" {
|
||||||
|
lineageFile = android.PathForModuleSrc(ctx, lineage)
|
||||||
|
}
|
||||||
|
SignAppPackage(ctx, signed, dexOutput, certificates, lineageFile)
|
||||||
a.outputFile = signed
|
a.outputFile = signed
|
||||||
} else {
|
} else {
|
||||||
alignedApk := android.PathForModuleOut(ctx, "zip-aligned", apkFilename)
|
alignedApk := android.PathForModuleOut(ctx, "zip-aligned", apkFilename)
|
||||||
|
@@ -2071,6 +2071,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) {
|
func TestAndroidAppImport_DefaultDevCert(t *testing.T) {
|
||||||
ctx, _ := testJava(t, `
|
ctx, _ := testJava(t, `
|
||||||
android_app_import {
|
android_app_import {
|
||||||
|
Reference in New Issue
Block a user