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
This commit is contained in:
Jaewoong Jung
2019-01-18 14:27:16 -08:00
parent 9d085dea9e
commit 2ad817c65d
5 changed files with 112 additions and 4 deletions

View File

@@ -893,7 +893,16 @@ func (c *deviceConfig) PlatPrivateSepolicyDirs() []string {
}
func (c *deviceConfig) OverrideManifestPackageNameFor(name string) (manifestName string, overridden bool) {
overrides := c.config.productVariables.ManifestPackageNameOverrides
return findOverrideValue(c.config.productVariables.ManifestPackageNameOverrides, name,
"invalid override rule %q in PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDES should be <module_name>:<manifest_name>")
}
func (c *deviceConfig) OverrideCertificateFor(name string) (certificatePath string, overridden bool) {
return findOverrideValue(c.config.productVariables.CertificateOverrides, name,
"invalid override rule %q in PRODUCT_CERTIFICATE_OVERRIDES should be <module_name>:<certificate_module_name>")
}
func findOverrideValue(overrides []string, name string, errorMsg string) (newValue string, overridden bool) {
if overrides == nil || len(overrides) == 0 {
return "", false
}
@@ -901,7 +910,7 @@ func (c *deviceConfig) OverrideManifestPackageNameFor(name string) (manifestName
split := strings.Split(o, ":")
if len(split) != 2 {
// This shouldn't happen as this is first checked in make, but just in case.
panic(fmt.Errorf("invalid override rule %q in PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDES should be <module_name>:<manifest_name>", o))
panic(fmt.Errorf(errorMsg, o))
}
if matchPattern(split[0], name) {
return substPattern(split[0], split[1], name), true

View File

@@ -270,6 +270,7 @@ type productVariables struct {
DexpreoptGlobalConfig *string `json:",omitempty"`
ManifestPackageNameOverrides []string `json:",omitempty"`
CertificateOverrides []string `json:",omitempty"`
EnforceSystemCertificate *bool `json:",omitempty"`
EnforceSystemCertificateWhitelist []string `json:",omitempty"`