Make system partition import system_ext's aconfig flags

This is the behavior in make since aosp/3261300. It's a problem for
treble though, so maybe should be revised in the future.

If the system -> system_ext dependency becomes a problem (like if we
need to add a system_ext -> system dependency later), I think we could
break it up by creating a ".aconfig" sub-module of filesystem modules,
and then the dependency is only added from system -> system_ext.aconfig.
But we don't need that right now.

Fixes: 382518797
Test: diff out/target/product/vsoc_x86_64/system/etc/aconfig_flags.pb out/soong/.intermediates/build/soong/fsgen/aosp_cf_x86_64_phone_generated_system_image/android_common/system/system/etc/aconfig_flags.pb
Change-Id: Ia0d043e35f03bbf2bc8a29df0b2b8ecd8427e727
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index bff0a10..c4c8879 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -181,6 +181,11 @@
 	// Install aconfig_flags.pb file for the modules installed in this partition.
 	Gen_aconfig_flags_pb *bool
 
+	// List of names of other filesystem partitions to import their aconfig flags from.
+	// This is used for the system partition to import system_ext's aconfig flags, as currently
+	// those are considered one "container": aosp/3261300
+	Import_aconfig_flags_from []string
+
 	Fsverity fsverityProperties
 
 	// If this property is set to true, the filesystem will call ctx.UncheckedModule(), causing
@@ -309,6 +314,9 @@
 	if f.properties.Android_filesystem_deps.System_ext != nil {
 		ctx.AddDependency(ctx.Module(), interPartitionDependencyTag, proptools.String(f.properties.Android_filesystem_deps.System_ext))
 	}
+	for _, partition := range f.properties.Import_aconfig_flags_from {
+		ctx.AddDependency(ctx.Module(), importAconfigDependencyTag, partition)
+	}
 }
 
 type fsType int
@@ -1077,6 +1085,12 @@
 	}
 	thisPartition := f.PartitionType()
 	if thisPartition != "vendor" && thisPartition != "product" {
+		if f.properties.Android_filesystem_deps.System != nil {
+			ctx.PropertyErrorf("android_filesystem_deps.system", "only vendor or product partitions can use android_filesystem_deps")
+		}
+		if f.properties.Android_filesystem_deps.System_ext != nil {
+			ctx.PropertyErrorf("android_filesystem_deps.system_ext", "only vendor or product partitions can use android_filesystem_deps")
+		}
 		return
 	}
 	ctx.WalkDeps(func(child, parent android.Module) bool {