Install VINTF fragment modules in the APEX

Currently APEX ignores vintf_fragments modules within the APEX, and all
VINTF fragments are installed with prebuilt_etc modules. This change
installs vintf_fragment modules in the APEX, so any additional
prebuilt_etc modules are not required as long as binaries define
vintf_fragment_modules references.

Bug: 363105686
Test: AOSP CF x86_64 build succeeded
Change-Id: I33b58178cd51dc2c4bb9226fdd68e7990dccd6a2
Merged-In: I33b58178cd51dc2c4bb9226fdd68e7990dccd6a2
diff --git a/apex/apex.go b/apex/apex.go
index fa796e5..cb9dc49 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -1505,6 +1505,12 @@
 	return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, config)
 }
 
+func apexFileForVintfFragment(ctx android.BaseModuleContext, vintfFragment *android.VintfFragmentModule) apexFile {
+	dirInApex := filepath.Join("etc", "vintf")
+
+	return newApexFile(ctx, vintfFragment.OutputFile(), vintfFragment.BaseModuleName(), dirInApex, etc, vintfFragment)
+}
+
 // javaModule is an interface to handle all Java modules (java_library, dex_import, etc) in the same
 // way.
 type javaModule interface {
@@ -2196,7 +2202,13 @@
 		// nothing
 	} else if am.CanHaveApexVariants() && am.IsInstallableToApex() {
 		ctx.ModuleErrorf("unexpected tag %s for indirect dependency %q", android.PrettyPrintTag(depTag), depName)
+	} else if android.IsVintfDepTag(depTag) {
+		if vf, ok := child.(*android.VintfFragmentModule); ok {
+			apexFile := apexFileForVintfFragment(ctx, vf)
+			vctx.filesInfo = append(vctx.filesInfo, apexFile)
+		}
 	}
+
 	return false
 }