diff --git a/Android.bp b/Android.bp index 185f3a9bd..81d91ced0 100644 --- a/Android.bp +++ b/Android.bp @@ -150,3 +150,21 @@ build_prop { relative_install_path: "etc", // system_ext/etc/build.prop visibility: ["//visibility:private"], } + +build_prop { + name: "product-build.prop", + stem: "build.prop", + product_specific: true, + product_config: ":product_config", + relative_install_path: "etc", // product/etc/build.prop + visibility: ["//visibility:private"], +} + +build_prop { + name: "odm-build.prop", + stem: "build.prop", + device_specific: true, + product_config: ":product_config", + relative_install_path: "etc", // odm/etc/build.prop + visibility: ["//visibility:private"], +} diff --git a/android/build_prop.go b/android/build_prop.go index d48d94d4e..b127755c8 100644 --- a/android/build_prop.go +++ b/android/build_prop.go @@ -61,6 +61,8 @@ func (p *buildPropModule) propFiles(ctx ModuleContext) Paths { return ctx.Config().SystemPropFiles(ctx) } else if partition == "system_ext" { return ctx.Config().SystemExtPropFiles(ctx) + } else if partition == "product" { + return ctx.Config().ProductPropFiles(ctx) } return nil } @@ -80,6 +82,28 @@ func shouldAddBuildThumbprint(config Config) bool { return false } +// Can't use PartitionTag() because PartitionTag() returns the partition this module is actually +// installed (e.g. odm module's partition tag can be either "odm" or "vendor") +func (p *buildPropModule) partition(config DeviceConfig) string { + if p.SocSpecific() { + return "vendor" + } else if p.DeviceSpecific() { + return "odm" + } else if p.ProductSpecific() { + return "product" + } else if p.SystemExtSpecific() { + return "system_ext" + } + return "system" +} + +var validPartitions = []string{ + "system", + "system_ext", + "product", + "odm", +} + func (p *buildPropModule) GenerateAndroidBuildActions(ctx ModuleContext) { p.outputFilePath = PathForModuleOut(ctx, "build.prop").OutputPath if !ctx.Config().KatiEnabled() { @@ -88,9 +112,9 @@ func (p *buildPropModule) GenerateAndroidBuildActions(ctx ModuleContext) { return } - partition := p.PartitionTag(ctx.DeviceConfig()) - if partition != "system" && partition != "system_ext" { - ctx.PropertyErrorf("partition", "unsupported partition %q: only \"system\" and \"system_ext\" are supported", partition) + partition := p.partition(ctx.DeviceConfig()) + if !InList(partition, validPartitions) { + ctx.PropertyErrorf("partition", "unsupported partition %q: only %q are supported", partition, validPartitions) return } @@ -118,7 +142,7 @@ func (p *buildPropModule) GenerateAndroidBuildActions(ctx ModuleContext) { cmd.FlagWithInput("--platform-preview-sdk-fingerprint-file=", ApiFingerprintPath(ctx)) cmd.FlagWithInput("--product-config=", PathForModuleSrc(ctx, proptools.String(p.properties.Product_config))) cmd.FlagWithArg("--partition=", partition) - cmd.FlagForEachInput("--prop-files=", ctx.Config().SystemPropFiles(ctx)) + cmd.FlagForEachInput("--prop-files=", p.propFiles(ctx)) cmd.FlagWithOutput("--out=", p.outputFilePath) postProcessCmd := rule.Command().BuiltTool("post_process_props") diff --git a/android/config.go b/android/config.go index efb42632d..372acd7c6 100644 --- a/android/config.go +++ b/android/config.go @@ -2114,6 +2114,10 @@ func (c *config) SystemExtPropFiles(ctx PathContext) Paths { return PathsForSource(ctx, c.productVariables.SystemExtPropFiles) } +func (c *config) ProductPropFiles(ctx PathContext) Paths { + return PathsForSource(ctx, c.productVariables.ProductPropFiles) +} + func (c *config) EnableUffdGc() string { return String(c.productVariables.EnableUffdGc) } diff --git a/android/variable.go b/android/variable.go index c1ea8d216..ac060f769 100644 --- a/android/variable.go +++ b/android/variable.go @@ -535,6 +535,7 @@ type ProductVariables struct { SystemPropFiles []string `json:",omitempty"` SystemExtPropFiles []string `json:",omitempty"` + ProductPropFiles []string `json:",omitempty"` EnableUffdGc *string `json:",omitempty"` } diff --git a/scripts/gen_build_prop.py b/scripts/gen_build_prop.py index 2bd246dc7..c08a3fd42 100644 --- a/scripts/gen_build_prop.py +++ b/scripts/gen_build_prop.py @@ -472,6 +472,8 @@ def append_additional_product_props(args): # Add the 16K developer args if it is defined for the product. props.append(f"ro.product.build.16k_page.enabled={'true' if config['Product16KDeveloperOption'] else 'false'}") + props.append(f"ro.product.page_size={16384 if config['TargetBoots16K'] else 4096}") + props.append(f"ro.build.characteristics={config['AAPTCharacteristics']}") if "AbOtaUpdater" in config and config["AbOtaUpdater"]: @@ -537,6 +539,7 @@ def build_vendor_prop(args): ] build_prop(args, gen_build_info=False, gen_common_build_props=True, variables=variables) +''' def build_product_prop(args): config = args.config @@ -547,8 +550,32 @@ def build_product_prop(args): "ADDITIONAL_PRODUCT_PROPERTIES", "PRODUCT_PRODUCT_PROPERTIES", ] + + gen_common_build_props = True + + # Skip common /product properties generation if device released before R and + # has no product partition. This is the first part of the check. + if config["Shipping_api_level"] and int(config["Shipping_api_level"]) < 30: + gen_common_build_props = False + + # The second part of the check - always generate common properties for the + # devices with product partition regardless of shipping level. + if config["UsesProductImage"]: + gen_common_build_props = True + + build_prop(args, gen_build_info=False, gen_common_build_props=True, variables=variables) + + if config["OemProperties"]: + print("####################################") + print("# PRODUCT_OEM_PROPERTIES") + print("####################################") + + for prop in config["OemProperties"]: + print(f"import /oem/oem.prop {prop}") + +def build_odm_prop(args): + variables = ["ADDITIONAL_ODM_PROPERTIES", "PRODUCT_ODM_PROPERTIES"] build_prop(args, gen_build_info=False, gen_common_build_props=True, variables=variables) -''' def build_prop(args, gen_build_info, gen_common_build_props, variables): config = args.config @@ -570,18 +597,19 @@ def main(): args = parse_args() with contextlib.redirect_stdout(args.out): - if args.partition == "system": - build_system_prop(args) - elif args.partition == "system_ext": - build_system_ext_prop(args) - ''' - elif args.partition == "vendor": - build_vendor_prop(args) - elif args.partition == "product": - build_product_prop(args) - ''' - else: - sys.exit(f"not supported partition {args.partition}") + match args.partition: + case "system": + build_system_prop(args) + case "system_ext": + build_system_ext_prop(args) + case "odm": + build_odm_prop(args) + case "product": + build_product_prop(args) + # case "vendor": # NOT IMPLEMENTED + # build_vendor_prop(args) + case _: + sys.exit(f"not supported partition {args.partition}") if __name__ == "__main__": main()