diff --git a/apex/apex.go b/apex/apex.go index 3b06a9958..408415eb3 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -379,6 +379,13 @@ type apexBundle struct { outputFiles map[apexPackaging]android.WritablePath installDir android.OutputPath + public_key_file android.Path + private_key_file android.Path + bundle_public_key bool + + container_certificate_file android.Path + container_private_key_file android.Path + // list of files to be included in this apex filesInfo []apexFile @@ -635,10 +642,6 @@ func getCopyManifestForPrebuiltEtc(prebuilt *android.PrebuiltEtc) (fileToCopy an func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { filesInfo := []apexFile{} - var keyFile android.Path - var pubKeyFile android.Path - var certificate java.Certificate - if a.properties.Payload_type == nil || *a.properties.Payload_type == "image" { a.apexTypes = imageApex } else if *a.properties.Payload_type == "zip" { @@ -704,20 +707,20 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { } case keyTag: if key, ok := child.(*apexKey); ok { - keyFile = key.private_key_file - if !key.installable() && ctx.Config().Debuggable() { - // If the key is not installed, bundled it with the APEX. - // Note: this bundled key is valid only for non-production builds - // (eng/userdebug). - pubKeyFile = key.public_key_file - } + a.private_key_file = key.private_key_file + a.public_key_file = key.public_key_file + // If the key is not installed, bundled it with the APEX. + // Note: this bundled key is valid only for non-production builds + // (eng/userdebug). + a.bundle_public_key = !key.installable() && ctx.Config().Debuggable() return false } else { ctx.PropertyErrorf("key", "%q is not an apex_key module", depName) } case certificateTag: if dep, ok := child.(*java.AndroidAppCertificate); ok { - certificate = dep.Certificate + a.container_certificate_file = dep.Certificate.Pem + a.container_private_key_file = dep.Certificate.Key return false } else { ctx.ModuleErrorf("certificate dependency %q must be an android_app_certificate module", depName) @@ -741,7 +744,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { }) a.flattened = ctx.Config().FlattenApex() && !ctx.Config().UnbundledBuild() - if keyFile == nil { + if a.private_key_file == nil { ctx.PropertyErrorf("key", "private_key for %q could not be found", String(a.properties.Key)) return } @@ -775,30 +778,28 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { a.filesInfo = filesInfo if a.apexTypes.zip() { - a.buildUnflattenedApex(ctx, keyFile, pubKeyFile, certificate, zipApex) + a.buildUnflattenedApex(ctx, zipApex) } if a.apexTypes.image() { // Build rule for unflattened APEX is created even when ctx.Config().FlattenApex() // is true. This is to support referencing APEX via ":