Create a filegroup for public stub sources

For use by framework-doc-stubs, to avoid duplicating the list of
modules there.

Bug: 169103987
Test: m framework-doc-stubs ; diff intermediates before & after
Merged-In: Ib1a1d1bb9fcf866278c6ddd057712a9c92716dbf
Change-Id: Ib1a1d1bb9fcf866278c6ddd057712a9c92716dbf
diff --git a/api/api.go b/api/api.go
index e4c1b96..4b6ebc1 100644
--- a/api/api.go
+++ b/api/api.go
@@ -81,6 +81,12 @@
 	Visibility  []string
 }
 
+type fgProps struct {
+	Name       *string
+	Srcs       []string
+	Visibility []string
+}
+
 // Struct to pass parameters for the various merged [current|removed].txt file modules we create.
 type MergedTxtDefinition struct {
 	// "current.txt" or "removed.txt"
@@ -188,6 +194,14 @@
 	ctx.CreateModule(java.LibraryFactory, &props)
 }
 
+func createPublicStubsSourceFilegroup(ctx android.LoadHookContext, modules []string) {
+	props := fgProps{}
+	props.Name = proptools.StringPtr("all-modules-public-stubs-source")
+	props.Srcs = createSrcs(modules, "{.public.stubs.source}")
+	props.Visibility = []string{"//frameworks/base"}
+	ctx.CreateModule(android.FileGroupFactory, &props)
+}
+
 func createMergedTxts(ctx android.LoadHookContext, bootclasspath, system_server_classpath []string) {
 	var textFiles []MergedTxtDefinition
 	// Two module libraries currently do not support @SystemApi so only have the public scope.
@@ -244,6 +258,8 @@
 	createMergedAnnotations(ctx, bootclasspath)
 
 	createFilteredApiVersions(ctx, bootclasspath)
+
+	createPublicStubsSourceFilegroup(ctx, bootclasspath)
 }
 
 func combinedApisModuleFactory() android.Module {