Convert some of java/ to ModuleProxy and Providers

When cc modules are marked with FreeModuleAfterGenerateBuildActions
it will be an error to visit any cc dependency using VisitDirectDeps,
and VisitDirectDepsProxy must be used instead.  Convert any part of
java/ that visits cc dependencies to ModuleProxy and Providers.

Test: all Soong tests pass
Change-Id: Icf1f47ac27d4dc1acf227902a8ef7af5024e8d15
diff --git a/java/java.go b/java/java.go
index 7e510e8..231da86 100644
--- a/java/java.go
+++ b/java/java.go
@@ -266,6 +266,8 @@
 type SdkLibraryComponentDependencyInfo struct {
 	// The name of the implementation library for the optional SDK library or nil, if there isn't one.
 	OptionalSdkLibraryImplementation *string
+	// The name of the java_sdk_library/_import module if this module was created by one.
+	SdkLibraryName *string
 }
 
 type ProvidesUsesLibInfo struct {
@@ -400,6 +402,11 @@
 	// this file so using the encoded dex jar here would result in a cycle in the ninja rules.
 	BootDexJarPath OptionalDexJarPath
 
+	// The paths to the classes jars that contain classes and class members annotated with
+	// the UnsupportedAppUsage annotation that need to be extracted as part of the hidden API
+	// processing.
+	HiddenapiClassesJarPaths android.Paths
+
 	// The compressed state of the dex file being encoded. This is used to ensure that the encoded
 	// dex file has the same state.
 	UncompressDexState *bool
@@ -448,6 +455,8 @@
 	SystemModules         string
 	Installable           bool
 	ApexDependencyInfo    *ApexDependencyInfo
+
+	MaxSdkVersion android.ApiLevel
 }
 
 var JavaInfoProvider = blueprint.NewProvider[*JavaInfo]()
@@ -1171,8 +1180,6 @@
 		javaInfo.ExtraOutputFiles = j.extraOutputFiles
 		javaInfo.DexJarFile = j.dexJarFile
 		javaInfo.InstallFile = j.installFile
-		javaInfo.BootDexJarPath = j.bootDexJarPath
-		javaInfo.UncompressDexState = j.uncompressDexState
 		javaInfo.Active = j.active
 		javaInfo.BuiltInstalled = j.builtInstalled
 		javaInfo.ConfigPath = j.configPath
@@ -1243,7 +1250,7 @@
 	// Static deps
 	staticDepNames := make([]string, 0)
 	staticDepFiles := android.Paths{}
-	ctx.VisitDirectDepsWithTag(staticLibTag, func(module android.Module) {
+	ctx.VisitDirectDepsProxyWithTag(staticLibTag, func(module android.ModuleProxy) {
 		if dep, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok {
 			staticDepNames = append(staticDepNames, module.Name())
 			staticDepFiles = append(staticDepFiles, dep.ImplementationJars...)
@@ -3598,6 +3605,8 @@
 
 	javaInfo := &JavaInfo{}
 	setExtraJavaInfo(ctx, j, javaInfo)
+	javaInfo.BootDexJarPath = j.dexJarFile
+
 	android.SetProvider(ctx, JavaInfoProvider, javaInfo)
 
 	android.SetProvider(ctx, JavaDexImportInfoProvider, JavaDexImportInfo{})
@@ -3880,6 +3889,7 @@
 	if slcDep, ok := module.(SdkLibraryComponentDependency); ok {
 		javaInfo.SdkLibraryComponentDependencyInfo = &SdkLibraryComponentDependencyInfo{
 			OptionalSdkLibraryImplementation: slcDep.OptionalSdkLibraryImplementation(),
+			SdkLibraryName:                   slcDep.SdkLibraryName(),
 		}
 	}
 
@@ -3911,6 +3921,18 @@
 		javaInfo.DexJarBuildPath = mm.DexJarBuildPath(ctx)
 	}
 
+	if ham, ok := module.(hiddenAPIModule); ok {
+		javaInfo.BootDexJarPath = ham.bootDexJar()
+		javaInfo.HiddenapiClassesJarPaths = ham.classesJars()
+		javaInfo.UncompressDexState = ham.uncompressDex()
+	}
+
+	if mm, ok := module.(interface {
+		MaxSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel
+	}); ok {
+		javaInfo.MaxSdkVersion = mm.MaxSdkVersion(ctx)
+	}
+
 	if di, ok := module.(DexpreopterInterface); ok {
 		javaInfo.DexpreopterInfo = &DexpreopterInfo{
 			OutputProfilePathOnHost:           di.OutputProfilePathOnHost(),