Remove duplicates in monolithic hidden API files

Previously, multiple APEX variants of some boot jars were being
processed by hiddenapi to extract information which resulted in
duplicate entries in the monolithic hidden API files.

This change applies the same filter that was previously used to ensure
that the hiddenapi-flags.csv file did not include any duplicates to all
sources of hidden API information.

Bug: 180102243
Test: m droid
      Verified that hiddenapi files (both aggregated ones and for the
      individual modules) are not affected by this change other than
      removing some duplicates entries.
Change-Id: I9ffc8586d5d6efea4e3440be2dfd5424790665c8
diff --git a/java/hiddenapi.go b/java/hiddenapi.go
index 9caea94..2d94ac4 100644
--- a/java/hiddenapi.go
+++ b/java/hiddenapi.go
@@ -124,7 +124,8 @@
 	// on the boot jars list because the runtime only enforces access to the hidden API for the
 	// bootclassloader. If information is gathered for modules not on the list then that will cause
 	// failures in the CtsHiddenApiBlocklist... tests.
-	h.active = inList(configurationName, ctx.Config().BootJars())
+	module := ctx.Module()
+	h.active = isModuleInBootClassPath(ctx, module)
 	if !h.active {
 		// The rest of the properties will be ignored if active is false.
 		return
@@ -135,7 +136,6 @@
 
 	// A prebuilt module is only primary if it is preferred and conversely a source module is only
 	// primary if it has not been replaced by a prebuilt module.
-	module := ctx.Module()
 	if pi, ok := module.(android.PrebuiltInterface); ok {
 		if p := pi.Prebuilt(); p != nil {
 			primary = p.UsePrebuilt()
@@ -153,6 +153,15 @@
 	h.primary = primary
 }
 
+func isModuleInBootClassPath(ctx android.BaseModuleContext, module android.Module) bool {
+	// Get the configured non-updatable and updatable boot jars.
+	nonUpdatableBootJars := ctx.Config().NonUpdatableBootJars()
+	updatableBootJars := ctx.Config().UpdatableBootJars()
+	active := isModuleInConfiguredList(ctx, module, nonUpdatableBootJars) ||
+		isModuleInConfiguredList(ctx, module, updatableBootJars)
+	return active
+}
+
 // hiddenAPIExtractAndEncode is called by any module that could contribute to the hiddenapi
 // processing.
 //