Enable certificate overrides with product vars.
Currently it is only for android_app, though it can be easily ported to
apex.
The make-side change will be made later, along with a real application.
Bug: 122957760
Test: app_test.go
Change-Id: I41f0be84f8b9f93e9518a16160e10eaa649388cd
diff --git a/java/app.go b/java/app.go
index 335d9fc..07a97ed 100644
--- a/java/app.go
+++ b/java/app.go
@@ -120,7 +120,7 @@
ctx.AddFarVariationDependencies(variation, tag, a.appProperties.Jni_libs...)
}
- cert := android.SrcIsModule(String(a.appProperties.Certificate))
+ cert := android.SrcIsModule(a.getCertString(ctx))
if cert != "" {
ctx.AddDependency(ctx.Module(), certificateTag, cert)
}
@@ -241,7 +241,7 @@
return
}
- cert := String(a.appProperties.Certificate)
+ cert := a.getCertString(ctx)
certModule := android.SrcIsModule(cert)
if certModule != "" {
a.certificate = certificateDeps[0]
@@ -327,6 +327,14 @@
return jniLibs, certificates
}
+func (a *AndroidApp) getCertString(ctx android.BaseContext) string {
+ certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(ctx.ModuleName())
+ if overridden {
+ return ":" + certificate
+ }
+ return String(a.appProperties.Certificate)
+}
+
func AndroidAppFactory() android.Module {
module := &AndroidApp{}