Merge "Don't panic if no certificates found" into udc-dev am: 16ef197d6a

Original change: https://googleplex-android-review.googlesource.com/c/platform/build/soong/+/23297153

Change-Id: Iccfde3be1358c29a64122c9f2b021a4de6accf43
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot
2023-05-19 17:01:59 +00:00
committed by Automerger Merge Worker
2 changed files with 22 additions and 13 deletions

View File

@@ -563,19 +563,6 @@ func processMainCert(m android.ModuleBase, certPropValue string, certificates []
certificates = append([]Certificate{mainCert}, certificates...)
}
if !m.Platform() {
certPath := certificates[0].Pem.String()
systemCertPath := ctx.Config().DefaultAppCertificateDir(ctx).String()
if strings.HasPrefix(certPath, systemCertPath) {
enforceSystemCert := ctx.Config().EnforceSystemCertificate()
allowed := ctx.Config().EnforceSystemCertificateAllowList()
if enforceSystemCert && !inList(m.Name(), allowed) {
ctx.PropertyErrorf("certificate", "The module in product partition cannot be signed with certificate in system.")
}
}
}
if len(certificates) > 0 {
mainCertificate = certificates[0]
} else {
@@ -591,6 +578,20 @@ func processMainCert(m android.ModuleBase, certPropValue string, certificates []
}
}
if !m.Platform() {
certPath := mainCertificate.Pem.String()
systemCertPath := ctx.Config().DefaultAppCertificateDir(ctx).String()
if strings.HasPrefix(certPath, systemCertPath) {
enforceSystemCert := ctx.Config().EnforceSystemCertificate()
allowed := ctx.Config().EnforceSystemCertificateAllowList()
if enforceSystemCert && !inList(m.Name(), allowed) {
ctx.PropertyErrorf("certificate", "The module in product partition cannot be signed with certificate in system.")
}
}
}
return mainCertificate, certificates
}

View File

@@ -3382,6 +3382,14 @@ func TestAppMissingCertificateAllowMissingDependencies(t *testing.T) {
srcs: ["a.java"],
certificate: ":missing_certificate",
sdk_version: "current",
}
android_app {
name: "bar",
srcs: ["a.java"],
certificate: ":missing_certificate",
product_specific: true,
sdk_version: "current",
}`)
foo := result.ModuleForTests("foo", "android_common")