Merge "Ensure all aconfig module is visible for vendor extensions" into main
diff --git a/aconfig/all_aconfig_declarations_extension.go b/aconfig/all_aconfig_declarations_extension.go
index 44992cd..d5a4588 100644
--- a/aconfig/all_aconfig_declarations_extension.go
+++ b/aconfig/all_aconfig_declarations_extension.go
@@ -79,12 +79,10 @@
 
 	ctx.Phony(ctx.ModuleName(), ext.finalizedFlags)
 
+	ctx.DistForGoalWithFilename("sdk", ext.finalizedFlags, path.Join(proptools.String(ext.properties.Dist_dir), "finalized-flags.txt"))
+
 	// This module must not set any provider or call `ctx.SetOutputFiles`!
 	// This module is only used to depend on the singleton module all_aconfig_declarations and
 	// generate the custom finalized-flags.txt file in dist builds, and should not be depended
 	// by other modules.
 }
-
-func (ext *allAconfigDeclarationsExtension) MakeVars(ctx android.MakeVarsContext) {
-	ctx.DistForGoalWithFilename("sdk", ext.finalizedFlags, path.Join(proptools.String(ext.properties.Dist_dir), "finalized-flags.txt"))
-}
diff --git a/filesystem/android_device.go b/filesystem/android_device.go
index 514fd28..eb967ad 100644
--- a/filesystem/android_device.go
+++ b/filesystem/android_device.go
@@ -454,6 +454,10 @@
 		abOtaKeysSorted := android.SortedUniqueStrings(a.deviceProps.Ab_ota_keys)
 		abOtaKeysSortedString := proptools.ShellEscape(strings.Join(abOtaKeysSorted, "\\n"))
 		builder.Command().Textf("echo -e").Flag(abOtaKeysSortedString).Textf(" > %s/META/otakeys.txt", targetFilesDir.String())
+		// selinuxfc
+		if a.getFsInfos(ctx)["system"].SelinuxFc != nil {
+			builder.Command().Textf("cp").Input(a.getFsInfos(ctx)["system"].SelinuxFc).Textf(" %s/META/file_contexts.bin", targetFilesDir.String())
+		}
 	}
 }
 
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index c3c06bd..0381951 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -90,6 +90,8 @@
 	entries []string
 
 	filesystemBuilder filesystemBuilder
+
+	selinuxFc android.Path
 }
 
 type filesystemBuilder interface {
@@ -417,6 +419,8 @@
 	// Path to compress hints file for erofs filesystems
 	// This will be nil for other fileystems like ext4
 	ErofsCompressHints android.Path
+
+	SelinuxFc android.Path
 }
 
 // FullInstallPathInfo contains information about the "full install" paths of all the files
@@ -660,6 +664,7 @@
 			Json: installedFileJson,
 		},
 		ErofsCompressHints: erofsCompressHints,
+		SelinuxFc:          f.selinuxFc,
 	}
 
 	android.SetProvider(ctx, FilesystemProvider, fsInfo)
@@ -1006,12 +1011,12 @@
 	if f.properties.File_contexts != nil && f.properties.Precompiled_file_contexts != nil {
 		ctx.ModuleErrorf("file_contexts and precompiled_file_contexts cannot both be set")
 	} else if f.properties.File_contexts != nil {
-		addPath("selinux_fc", f.buildFileContexts(ctx))
+		f.selinuxFc = f.buildFileContexts(ctx)
 	} else if f.properties.Precompiled_file_contexts != nil {
-		src := android.PathForModuleSrc(ctx, *f.properties.Precompiled_file_contexts)
-		if src != nil {
-			addPath("selinux_fc", src)
-		}
+		f.selinuxFc = android.PathForModuleSrc(ctx, *f.properties.Precompiled_file_contexts)
+	}
+	if f.selinuxFc != nil {
+		addPath("selinux_fc", f.selinuxFc)
 	}
 	if timestamp := proptools.String(f.properties.Fake_timestamp); timestamp != "" {
 		addStr("timestamp", timestamp)
diff --git a/phony/phony.go b/phony/phony.go
index 4f61c45..807b95b 100644
--- a/phony/phony.go
+++ b/phony/phony.go
@@ -38,11 +38,9 @@
 
 type phony struct {
 	android.ModuleBase
-
 	requiredModuleNames       []string
 	hostRequiredModuleNames   []string
 	targetRequiredModuleNames []string
-	outputDeps                android.Paths
 }
 
 func PhonyFactory() android.Module {
@@ -56,14 +54,6 @@
 	p.requiredModuleNames = ctx.RequiredModuleNames(ctx)
 	p.hostRequiredModuleNames = ctx.HostRequiredModuleNames()
 	p.targetRequiredModuleNames = ctx.TargetRequiredModuleNames()
-
-	ctx.VisitDirectDepsWithTag(android.RequiredDepTag, func(dep android.Module) {
-		if o, ok := android.OtherModuleProvider(ctx, dep, android.OutputFilesProvider); ok {
-			p.outputDeps = append(p.outputDeps, o.DefaultOutputFiles...)
-		}
-	})
-
-	ctx.Phony(p.Name(), p.outputDeps...)
 }
 
 func (p *phony) AndroidMk() android.AndroidMkData {
@@ -87,10 +77,6 @@
 				fmt.Fprintln(w, "LOCAL_TARGET_REQUIRED_MODULES :=",
 					strings.Join(p.targetRequiredModuleNames, " "))
 			}
-			if len(p.outputDeps) > 0 {
-				fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES :=",
-					strings.Join(p.outputDeps.Strings(), " "))
-			}
 			// AconfigUpdateAndroidMkData may have added elements to Extra.  Process them here.
 			for _, extra := range data.Extra {
 				extra(w, nil)