Add android_info module type

This is heavily inspired by the implementation in
https://r.android.com/3081436. `android_info` will generate a .txt file
with board specific information which will subsequently be used to
generate build.prop file for vendor.

The key differences are
1. `android_info` is not a singleton module.
2. Create android_info.prop from android_info.txt. The .prop file will
   be passed to --prop-files when generating /vendor/build.prop
3. Board info properties like `TARGET_BOARD_INFO_FILES` will not be
   added to android.Config API. (But they will be added to the unstable
   `PartitionVarsForSoongMigrationOnlyDoNotUse` in a followup CL)
3. android-info.txt will _not_ be installed via ctx.InstallFile,
   atleast for now. This file is created in $PRODUCT_OUT, but not
   installed on device.

Test: m nothing --no-skip-soong-tests
Bug: 375500423
Change-Id: Ie79f4f5fe828d7876c12e224f4dff1cc17e1b4d4
diff --git a/android/build_prop.go b/android/build_prop.go
index 7c3c506..5547680 100644
--- a/android/build_prop.go
+++ b/android/build_prop.go
@@ -19,8 +19,12 @@
 )
 
 func init() {
-	ctx := InitRegistrationContext
+	registerBuildPropComponents(InitRegistrationContext)
+}
+
+func registerBuildPropComponents(ctx RegistrationContext) {
 	ctx.RegisterModuleType("build_prop", BuildPropFactory)
+	ctx.RegisterModuleType("android_info", AndroidInfoFactory)
 }
 
 type buildPropProperties struct {
@@ -38,6 +42,10 @@
 	// Path to a JSON file containing product configs.
 	Product_config *string `android:"path"`
 
+	// Path to android-info.txt file containing board specific info.
+	// This is empty for build.prop of all partitions except vendor.
+	Android_info *string `android:"path"`
+
 	// Optional subdirectory under which this file is installed into
 	Relative_install_path *string
 }
@@ -66,7 +74,10 @@
 	} else if partition == "odm" {
 		return ctx.Config().OdmPropFiles(ctx)
 	} else if partition == "vendor" {
-		// TODO (b/375500423): Add android-info.txt to prop files
+		if p.properties.Android_info != nil {
+			androidInfo := PathForModuleSrc(ctx, proptools.String(p.properties.Android_info))
+			return append(ctx.Config().VendorPropFiles(ctx), androidInfo)
+		}
 		return ctx.Config().VendorPropFiles(ctx)
 	}
 	return nil
@@ -111,13 +122,12 @@
 }
 
 func (p *buildPropModule) GenerateAndroidBuildActions(ctx ModuleContext) {
-	p.outputFilePath = PathForModuleOut(ctx, "build.prop").OutputPath
-	if !ctx.Config().KatiEnabled() {
-		WriteFileRule(ctx, p.outputFilePath, "# no build.prop if kati is disabled")
-		ctx.SetOutputFiles(Paths{p.outputFilePath}, "")
-		return
+	if !p.SocSpecific() && p.properties.Android_info != nil {
+		ctx.ModuleErrorf("Android_info cannot be set if build.prop is not installed in vendor partition")
 	}
 
+	p.outputFilePath = PathForModuleOut(ctx, "build.prop").OutputPath
+
 	partition := p.partition(ctx.DeviceConfig())
 	if !InList(partition, validPartitions) {
 		ctx.PropertyErrorf("partition", "unsupported partition %q: only %q are supported", partition, validPartitions)