Move installation of dexpreopted system server classpath libraries into apex

System server jars in apexes currently use a heuristic to determine
whether or not they are the "main" variant in order to create rules
that copy their dexpreopt artifacts to the final installed location
and their dex jars to a known location for other modules to reference.
The heuristic depends on knowing all apexes that depend on the
module, which will not be possible when the apex info mutator is
rewritten to support future incremental analysis.

Instead, export the dexpreopt artifacts and dex jars, and let the
apex decide whether or not to install them.

Bug: 372543712
Test: all soong tests pass
Change-Id: I478bc2edceca4614e08e9a695b05d091e5437ba1
diff --git a/java/java.go b/java/java.go
index 8d10e3b..9f0de46 100644
--- a/java/java.go
+++ b/java/java.go
@@ -402,7 +402,12 @@
 
 	BuiltInstalled string
 
-	BuiltInstalledForApex []dexpreopterInstall
+	// ApexSystemServerDexpreoptInstalls stores the list of dexpreopt artifacts if this is a system server
+	// jar in an apex.
+	ApexSystemServerDexpreoptInstalls []DexpreopterInstall
+
+	// ApexSystemServerDexJars stores the list of dex jars if this is a system server jar in an apex.
+	ApexSystemServerDexJars android.Paths
 
 	// The config is used for two purposes:
 	// - Passing dexpreopt information about libraries from Soong to Make. This is needed when
@@ -1129,7 +1134,8 @@
 		javaInfo.BootDexJarPath = j.bootDexJarPath
 		javaInfo.UncompressDexState = j.uncompressDexState
 		javaInfo.Active = j.active
-		javaInfo.BuiltInstalledForApex = j.builtInstalledForApex
+		javaInfo.ApexSystemServerDexpreoptInstalls = j.apexSystemServerDexpreoptInstalls
+		javaInfo.ApexSystemServerDexJars = j.apexSystemServerDexJars
 		javaInfo.BuiltInstalled = j.builtInstalled
 		javaInfo.ConfigPath = j.configPath
 		javaInfo.OutputProfilePathOnHost = j.outputProfilePathOnHost
@@ -1170,7 +1176,6 @@
 
 	if j.hideApexVariantFromMake {
 		moduleInfoJSON.Disabled = true
-		j.dexpreopter.ModuleInfoJSONForApex(ctx)
 	}
 	return moduleInfoJSON
 }