Use classpath elements in platform_bootclasspath

Use classpath elements in newMonolithicHiddenAPIInfo. That means the
method can collate information from both fragments and libraries rather
than just fragments. So, this change moves the collation of the
classesJars into the method.

Bug: 177892522
Test: m out/soong/hiddenapi/hiddenapi-flags.csv out/soong/hiddenapi/hiddenapi-index.csv
      - make sure that this change does not affect the contents.
Change-Id: I7c2a229fab60d02bd211438735a8d7303ed83386
diff --git a/java/hiddenapi_monolithic.go b/java/hiddenapi_monolithic.go
index edf4235..8a83d10 100644
--- a/java/hiddenapi_monolithic.go
+++ b/java/hiddenapi_monolithic.go
@@ -43,22 +43,37 @@
 
 	// The paths to the generated all-flags.csv files.
 	AllFlagsPaths android.Paths
+
+	// The classes jars from the libraries on the platform bootclasspath.
+	ClassesJars android.Paths
 }
 
 // newMonolithicHiddenAPIInfo creates a new MonolithicHiddenAPIInfo from the flagFilesByCategory
 // plus information provided by each of the fragments.
-func newMonolithicHiddenAPIInfo(ctx android.ModuleContext, flagFilesByCategory FlagFilesByCategory, fragments []android.Module) MonolithicHiddenAPIInfo {
+func newMonolithicHiddenAPIInfo(ctx android.ModuleContext, flagFilesByCategory FlagFilesByCategory, classpathElements ClasspathElements) MonolithicHiddenAPIInfo {
 	monolithicInfo := MonolithicHiddenAPIInfo{}
 
 	monolithicInfo.FlagsFilesByCategory = flagFilesByCategory
 
-	// Merge all the information from the fragments. The fragments form a DAG so it is possible that
-	// this will introduce duplicates so they will be resolved after processing all the fragments.
-	for _, fragment := range fragments {
-		if ctx.OtherModuleHasProvider(fragment, HiddenAPIInfoProvider) {
-			info := ctx.OtherModuleProvider(fragment, HiddenAPIInfoProvider).(HiddenAPIInfo)
-			monolithicInfo.append(&info)
+	// Merge all the information from the classpathElements. The fragments form a DAG so it is possible that
+	// this will introduce duplicates so they will be resolved after processing all the classpathElements.
+	for _, element := range classpathElements {
+		var classesJars android.Paths
+		switch e := element.(type) {
+		case *ClasspathLibraryElement:
+			classesJars = retrieveClassesJarsFromModule(e.Module())
+
+		case *ClasspathFragmentElement:
+			fragment := e.Module()
+			if ctx.OtherModuleHasProvider(fragment, HiddenAPIInfoProvider) {
+				info := ctx.OtherModuleProvider(fragment, HiddenAPIInfoProvider).(HiddenAPIInfo)
+				monolithicInfo.append(&info)
+			}
+
+			classesJars = extractClassesJarsFromModules(e.Contents)
 		}
+
+		monolithicInfo.ClassesJars = append(monolithicInfo.ClassesJars, classesJars...)
 	}
 
 	// Dedup paths.