Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3495c736 authored by Zyan Wu's avatar Zyan Wu Committed by Automerger Merge Worker
Browse files

Don't panic if no certificates found am: b7550aa0

parents 7e94ed29 b7550aa0
Loading
Loading
Loading
Loading
+14 −13
Original line number Diff line number Diff line
@@ -585,19 +585,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 {
@@ -613,6 +600,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
}

+8 −0
Original line number Diff line number Diff line
@@ -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")