Add soong config variables of paths of *_dlkm partitions and whether they are built for a product.

Update prebuilt_etc to use these variable so fs_config_dirs and fs_config_files could be installed to *_dlkm partitions.

Bug: 377304441
Test: lunch aosp_cf_x86_64_phone-trunk_staging-eng && m, check fs_config_dirs
and fs_config_files exist in etc/ in each partitions

Change-Id: Ic90267f6b3fd60674bb27016cf5f31fc2614e35b
diff --git a/android/config.go b/android/config.go
index 16d77db..275c07f 100644
--- a/android/config.go
+++ b/android/config.go
@@ -1522,6 +1522,13 @@
 	return "vendor"
 }
 
+func (c *deviceConfig) VendorDlkmPath() string {
+	if c.config.productVariables.VendorDlkmPath != nil {
+		return *c.config.productVariables.VendorDlkmPath
+	}
+	return "vendor_dlkm"
+}
+
 func (c *deviceConfig) BuildingVendorImage() bool {
 	return proptools.Bool(c.config.productVariables.BuildingVendorImage)
 }
@@ -1553,6 +1560,13 @@
 	return proptools.Bool(c.config.productVariables.BuildingOdmImage)
 }
 
+func (c *deviceConfig) OdmDlkmPath() string {
+	if c.config.productVariables.OdmDlkmPath != nil {
+		return *c.config.productVariables.OdmDlkmPath
+	}
+	return "odm_dlkm"
+}
+
 func (c *deviceConfig) ProductPath() string {
 	if c.config.productVariables.ProductPath != nil {
 		return *c.config.productVariables.ProductPath
@@ -1571,6 +1585,20 @@
 	return "system_ext"
 }
 
+func (c *deviceConfig) SystemDlkmPath() string {
+	if c.config.productVariables.SystemDlkmPath != nil {
+		return *c.config.productVariables.SystemDlkmPath
+	}
+	return "system_dlkm"
+}
+
+func (c *deviceConfig) OemPath() string {
+	if c.config.productVariables.OemPath != nil {
+		return *c.config.productVariables.OemPath
+	}
+	return "oem"
+}
+
 func (c *deviceConfig) BtConfigIncludeDir() string {
 	return String(c.config.productVariables.BtConfigIncludeDir)
 }
diff --git a/android/variable.go b/android/variable.go
index a4ee886..c2da278 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -339,12 +339,16 @@
 	HWASanExcludePaths []string `json:",omitempty"`
 
 	VendorPath           *string `json:",omitempty"`
+	VendorDlkmPath       *string `json:",omitempty"`
 	BuildingVendorImage  *bool   `json:",omitempty"`
 	OdmPath              *string `json:",omitempty"`
 	BuildingOdmImage     *bool   `json:",omitempty"`
+	OdmDlkmPath          *string `json:",omitempty"`
 	ProductPath          *string `json:",omitempty"`
 	BuildingProductImage *bool   `json:",omitempty"`
 	SystemExtPath        *string `json:",omitempty"`
+	SystemDlkmPath       *string `json:",omitempty"`
+	OemPath              *string `json:",omitempty"`
 
 	ClangTidy  *bool   `json:",omitempty"`
 	TidyChecks *string `json:",omitempty"`
diff --git a/etc/prebuilt_etc.go b/etc/prebuilt_etc.go
index a46da77..8461b3e 100644
--- a/etc/prebuilt_etc.go
+++ b/etc/prebuilt_etc.go
@@ -132,6 +132,18 @@
 
 	// Install symlinks to the installed file.
 	Symlinks []string `android:"arch_variant"`
+
+	// Install to partition system_dlkm when set to true.
+	System_dlkm_specific *bool `android:"arch_variant"`
+
+	// Install to partition vendor_dlkm when set to true.
+	Vendor_dlkm_specific *bool `android:"arch_variant"`
+
+	// Install to partition odm_dlkm when set to true.
+	Odm_dlkm_specific *bool `android:"arch_variant"`
+
+	// Install to partition oem when set to true.
+	Oem_specific *bool `android:"arch_variant"`
 }
 
 type prebuiltSubdirProperties struct {
@@ -369,6 +381,16 @@
 		ctx.PropertyErrorf("sub_dir", "relative_install_path is set. Cannot set sub_dir")
 	}
 	baseInstallDirPath := android.PathForModuleInstall(ctx, p.installBaseDir(ctx), p.SubDir())
+	// TODO(b/377304441)
+	if android.Bool(p.properties.System_dlkm_specific) {
+		baseInstallDirPath = android.PathForModuleInPartitionInstall(ctx, ctx.DeviceConfig().SystemDlkmPath(), p.installBaseDir(ctx), p.SubDir())
+	} else if android.Bool(p.properties.Vendor_dlkm_specific) {
+		baseInstallDirPath = android.PathForModuleInPartitionInstall(ctx, ctx.DeviceConfig().VendorDlkmPath(), p.installBaseDir(ctx), p.SubDir())
+	} else if android.Bool(p.properties.Odm_dlkm_specific) {
+		baseInstallDirPath = android.PathForModuleInPartitionInstall(ctx, ctx.DeviceConfig().OdmDlkmPath(), p.installBaseDir(ctx), p.SubDir())
+	} else if android.Bool(p.properties.Oem_specific) {
+		baseInstallDirPath = android.PathForModuleInPartitionInstall(ctx, ctx.DeviceConfig().OemPath(), p.installBaseDir(ctx), p.SubDir())
+	}
 
 	filename := proptools.String(p.properties.Filename)
 	filenameFromSrc := proptools.Bool(p.properties.Filename_from_src)