diff --git a/aconfig/aconfig_declarations.go b/aconfig/aconfig_declarations.go index 565d18534..0278048cf 100644 --- a/aconfig/aconfig_declarations.go +++ b/aconfig/aconfig_declarations.go @@ -96,6 +96,15 @@ func joinAndPrefix(prefix string, values []string) string { return sb.String() } +func optionalVariable(prefix string, value string) string { + var sb strings.Builder + if value != "" { + sb.WriteString(prefix) + sb.WriteString(value) + } + return sb.String() +} + // Provider published by aconfig_value_set type declarationsProviderData struct { Package string @@ -123,15 +132,17 @@ func (module *DeclarationsModule) GenerateAndroidBuildActions(ctx android.Module // Intermediate format inputFiles := android.PathsForModuleSrc(ctx, module.properties.Srcs) intermediatePath := android.PathForModuleOut(ctx, "intermediate.pb") + defaultPermission := ctx.Config().ReleaseAconfigFlagDefaultPermission() ctx.Build(pctx, android.BuildParams{ Rule: aconfigRule, Output: intermediatePath, Description: "aconfig_declarations", Args: map[string]string{ - "release_version": ctx.Config().ReleaseVersion(), - "package": module.properties.Package, - "declarations": android.JoinPathsWithPrefix(inputFiles, "--declarations "), - "values": joinAndPrefix(" --values ", module.properties.Values), + "release_version": ctx.Config().ReleaseVersion(), + "package": module.properties.Package, + "declarations": android.JoinPathsWithPrefix(inputFiles, "--declarations "), + "values": joinAndPrefix(" --values ", module.properties.Values), + "default-permission": optionalVariable(" --default-permission ", defaultPermission), }, }) diff --git a/aconfig/init.go b/aconfig/init.go index 37167aa5d..887198bfc 100644 --- a/aconfig/init.go +++ b/aconfig/init.go @@ -29,6 +29,7 @@ var ( ` --package ${package}` + ` ${declarations}` + ` ${values}` + + ` ${default-permission}` + ` --cache ${out}.tmp` + ` && ( if cmp -s ${out}.tmp ${out} ; then rm ${out}.tmp ; else mv ${out}.tmp ${out} ; fi )`, // ` --build-id ${release_version}` + @@ -36,7 +37,7 @@ var ( "${aconfig}", }, Restat: true, - }, "release_version", "package", "declarations", "values") + }, "release_version", "package", "declarations", "values", "default-permission") // For java_aconfig_library: Generate java file javaRule = pctx.AndroidStaticRule("java_aconfig_library", diff --git a/android/config.go b/android/config.go index eb894932f..0ef3b916c 100644 --- a/android/config.go +++ b/android/config.go @@ -200,6 +200,12 @@ func (c Config) ReleaseAconfigValueSets() []string { return c.config.productVariables.ReleaseAconfigValueSets } +// The flag default permission value passed to aconfig +// derived from RELEASE_ACONFIG_FLAG_DEFAULT_PERMISSION +func (c Config) ReleaseAconfigFlagDefaultPermission() string { + return c.config.productVariables.ReleaseAconfigFlagDefaultPermission +} + // A DeviceConfig object represents the configuration for a particular device // being built. For now there will only be one of these, but in the future there // may be multiple devices being built. diff --git a/android/variable.go b/android/variable.go index 03a80c161..eb44847a0 100644 --- a/android/variable.go +++ b/android/variable.go @@ -491,6 +491,8 @@ type ProductVariables struct { ReleaseVersion string `json:",omitempty"` ReleaseAconfigValueSets []string `json:",omitempty"` + ReleaseAconfigFlagDefaultPermission string `json:",omitempty"` + KeepVndk *bool `json:",omitempty"` }