Merge "Move AllowMissingDependencies handling into processMainCert"
This commit is contained in:
39
java/app.go
39
java/app.go
@@ -526,7 +526,8 @@ func (a *AndroidApp) JNISymbolsInstalls(installPath string) android.RuleBuilderI
|
|||||||
|
|
||||||
// Reads and prepends a main cert from the default cert dir if it hasn't been set already, i.e. it
|
// Reads and prepends a main cert from the default cert dir if it hasn't been set already, i.e. it
|
||||||
// isn't a cert module reference. Also checks and enforces system cert restriction if applicable.
|
// isn't a cert module reference. Also checks and enforces system cert restriction if applicable.
|
||||||
func processMainCert(m android.ModuleBase, certPropValue string, certificates []Certificate, ctx android.ModuleContext) []Certificate {
|
func processMainCert(m android.ModuleBase, certPropValue string, certificates []Certificate,
|
||||||
|
ctx android.ModuleContext) (mainCertificate Certificate, allCertificates []Certificate) {
|
||||||
if android.SrcIsModule(certPropValue) == "" {
|
if android.SrcIsModule(certPropValue) == "" {
|
||||||
var mainCert Certificate
|
var mainCert Certificate
|
||||||
if certPropValue != "" {
|
if certPropValue != "" {
|
||||||
@@ -558,7 +559,22 @@ func processMainCert(m android.ModuleBase, certPropValue string, certificates []
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return certificates
|
if len(certificates) > 0 {
|
||||||
|
mainCertificate = certificates[0]
|
||||||
|
} else {
|
||||||
|
// This can be reached with an empty certificate list if AllowMissingDependencies is set
|
||||||
|
// and the certificate property for this module is a module reference to a missing module.
|
||||||
|
if !ctx.Config().AllowMissingDependencies() && len(ctx.GetMissingDependencies()) > 0 {
|
||||||
|
panic("Should only get here if AllowMissingDependencies set and there are missing dependencies")
|
||||||
|
}
|
||||||
|
// Set a certificate to avoid panics later when accessing it.
|
||||||
|
mainCertificate = Certificate{
|
||||||
|
Key: android.PathForModuleOut(ctx, "missing.pk8"),
|
||||||
|
Pem: android.PathForModuleOut(ctx, "missing.pem"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mainCertificate, certificates
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AndroidApp) InstallApkName() string {
|
func (a *AndroidApp) InstallApkName() string {
|
||||||
@@ -632,29 +648,14 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
|
|
||||||
dexJarFile := a.dexBuildActions(ctx)
|
dexJarFile := a.dexBuildActions(ctx)
|
||||||
|
|
||||||
jniLibs, prebuiltJniPackages, certificateDeps := collectAppDeps(ctx, a, a.shouldEmbedJnis(ctx), !Bool(a.appProperties.Jni_uses_platform_apis))
|
jniLibs, prebuiltJniPackages, certificates := collectAppDeps(ctx, a, a.shouldEmbedJnis(ctx), !Bool(a.appProperties.Jni_uses_platform_apis))
|
||||||
jniJarFile := a.jniBuildActions(jniLibs, prebuiltJniPackages, ctx)
|
jniJarFile := a.jniBuildActions(jniLibs, prebuiltJniPackages, ctx)
|
||||||
|
|
||||||
if ctx.Failed() {
|
if ctx.Failed() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
certificates := processMainCert(a.ModuleBase, a.getCertString(ctx), certificateDeps, ctx)
|
a.certificate, certificates = processMainCert(a.ModuleBase, a.getCertString(ctx), certificates, ctx)
|
||||||
|
|
||||||
// This can be reached with an empty certificate list if AllowMissingDependencies is set
|
|
||||||
// and the certificate property for this module is a module reference to a missing module.
|
|
||||||
if len(certificates) > 0 {
|
|
||||||
a.certificate = certificates[0]
|
|
||||||
} else {
|
|
||||||
if !ctx.Config().AllowMissingDependencies() && len(ctx.GetMissingDependencies()) > 0 {
|
|
||||||
panic("Should only get here if AllowMissingDependencies set and there are missing dependencies")
|
|
||||||
}
|
|
||||||
// Set a certificate to avoid panics later when accessing it.
|
|
||||||
a.certificate = Certificate{
|
|
||||||
Key: android.PathForModuleOut(ctx, "missing.pk8"),
|
|
||||||
Pem: android.PathForModuleOut(ctx, "missing.pem"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Build a final signed app package.
|
// Build a final signed app package.
|
||||||
packageFile := android.PathForModuleOut(ctx, a.installApkName+".apk")
|
packageFile := android.PathForModuleOut(ctx, a.installApkName+".apk")
|
||||||
|
@@ -318,19 +318,17 @@ func (a *AndroidAppImport) generateAndroidBuildActions(ctx android.ModuleContext
|
|||||||
|
|
||||||
if a.isPrebuiltFrameworkRes() {
|
if a.isPrebuiltFrameworkRes() {
|
||||||
a.outputFile = srcApk
|
a.outputFile = srcApk
|
||||||
certificates = processMainCert(a.ModuleBase, String(a.properties.Certificate), certificates, ctx)
|
a.certificate, certificates = processMainCert(a.ModuleBase, String(a.properties.Certificate), certificates, ctx)
|
||||||
if len(certificates) != 1 {
|
if len(certificates) != 1 {
|
||||||
ctx.ModuleErrorf("Unexpected number of certificates were extracted: %q", certificates)
|
ctx.ModuleErrorf("Unexpected number of certificates were extracted: %q", certificates)
|
||||||
}
|
}
|
||||||
a.certificate = certificates[0]
|
|
||||||
} else if a.preprocessed {
|
} else if a.preprocessed {
|
||||||
a.outputFile = srcApk
|
a.outputFile = srcApk
|
||||||
a.certificate = PresignedCertificate
|
a.certificate = PresignedCertificate
|
||||||
} else if !Bool(a.properties.Presigned) {
|
} else if !Bool(a.properties.Presigned) {
|
||||||
// If the certificate property is empty at this point, default_dev_cert must be set to true.
|
// If the certificate property is empty at this point, default_dev_cert must be set to true.
|
||||||
// Which makes processMainCert's behavior for the empty cert string WAI.
|
// Which makes processMainCert's behavior for the empty cert string WAI.
|
||||||
certificates = processMainCert(a.ModuleBase, String(a.properties.Certificate), certificates, ctx)
|
a.certificate, certificates = processMainCert(a.ModuleBase, String(a.properties.Certificate), certificates, ctx)
|
||||||
a.certificate = certificates[0]
|
|
||||||
signed := android.PathForModuleOut(ctx, "signed", apkFilename)
|
signed := android.PathForModuleOut(ctx, "signed", apkFilename)
|
||||||
var lineageFile android.Path
|
var lineageFile android.Path
|
||||||
if lineage := String(a.properties.Lineage); lineage != "" {
|
if lineage := String(a.properties.Lineage); lineage != "" {
|
||||||
|
@@ -807,3 +807,23 @@ func TestAndroidTestImport_UncompressDex(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAppImportMissingCertificateAllowMissingDependencies(t *testing.T) {
|
||||||
|
result := android.GroupFixturePreparers(
|
||||||
|
PrepareForTestWithJavaDefaultModules,
|
||||||
|
android.PrepareForTestWithAllowMissingDependencies,
|
||||||
|
android.PrepareForTestWithAndroidMk,
|
||||||
|
).RunTestWithBp(t, `
|
||||||
|
android_app_import {
|
||||||
|
name: "foo",
|
||||||
|
apk: "a.apk",
|
||||||
|
certificate: ":missing_certificate",
|
||||||
|
}`)
|
||||||
|
|
||||||
|
foo := result.ModuleForTests("foo", "android_common")
|
||||||
|
fooApk := foo.Output("signed/foo.apk")
|
||||||
|
if fooApk.Rule != android.ErrorRule {
|
||||||
|
t.Fatalf("expected ErrorRule for foo.apk, got %s", fooApk.Rule.String())
|
||||||
|
}
|
||||||
|
android.AssertStringDoesContain(t, "expected error rule message", fooApk.Args["error"], "missing dependencies: missing_certificate\n")
|
||||||
|
}
|
||||||
|
@@ -684,7 +684,7 @@ func javadocCmd(ctx android.ModuleContext, rule *android.RuleBuilder, srcs andro
|
|||||||
outDir, srcJarDir, srcJarList android.Path, sourcepaths android.Paths) *android.RuleBuilderCommand {
|
outDir, srcJarDir, srcJarList android.Path, sourcepaths android.Paths) *android.RuleBuilderCommand {
|
||||||
|
|
||||||
cmd := rule.Command().
|
cmd := rule.Command().
|
||||||
BuiltTool("soong_javac_wrapper").Tool(config.JavadocCmd(ctx)).
|
BuiltTool("soong_javac_wrapper").Tool(android.PathForSource(ctx, "prebuilts/jdk/jdk11/linux-x86/bin/javadoc")).
|
||||||
Flag(config.JavacVmFlags).
|
Flag(config.JavacVmFlags).
|
||||||
FlagWithArg("-encoding ", "UTF-8").
|
FlagWithArg("-encoding ", "UTF-8").
|
||||||
FlagWithRspFileInputList("@", android.PathForModuleOut(ctx, "javadoc.rsp"), srcs).
|
FlagWithRspFileInputList("@", android.PathForModuleOut(ctx, "javadoc.rsp"), srcs).
|
||||||
|
@@ -146,7 +146,7 @@ func (r *RuntimeResourceOverlay) GenerateAndroidBuildActions(ctx android.ModuleC
|
|||||||
|
|
||||||
// Sign the built package
|
// Sign the built package
|
||||||
_, _, certificates := collectAppDeps(ctx, r, false, false)
|
_, _, certificates := collectAppDeps(ctx, r, false, false)
|
||||||
certificates = processMainCert(r.ModuleBase, String(r.properties.Certificate), certificates, ctx)
|
r.certificate, certificates = processMainCert(r.ModuleBase, String(r.properties.Certificate), certificates, ctx)
|
||||||
signed := android.PathForModuleOut(ctx, "signed", r.Name()+".apk")
|
signed := android.PathForModuleOut(ctx, "signed", r.Name()+".apk")
|
||||||
var lineageFile android.Path
|
var lineageFile android.Path
|
||||||
if lineage := String(r.properties.Lineage); lineage != "" {
|
if lineage := String(r.properties.Lineage); lineage != "" {
|
||||||
@@ -156,7 +156,6 @@ func (r *RuntimeResourceOverlay) GenerateAndroidBuildActions(ctx android.ModuleC
|
|||||||
rotationMinSdkVersion := String(r.properties.RotationMinSdkVersion)
|
rotationMinSdkVersion := String(r.properties.RotationMinSdkVersion)
|
||||||
|
|
||||||
SignAppPackage(ctx, signed, r.aapt.exportPackage, certificates, nil, lineageFile, rotationMinSdkVersion)
|
SignAppPackage(ctx, signed, r.aapt.exportPackage, certificates, nil, lineageFile, rotationMinSdkVersion)
|
||||||
r.certificate = certificates[0]
|
|
||||||
|
|
||||||
r.outputFile = signed
|
r.outputFile = signed
|
||||||
partition := rroPartition(ctx)
|
partition := rroPartition(ctx)
|
||||||
|
Reference in New Issue
Block a user