bazel apex: Add mixed builds support for <module>_using.xml file.

This file contains the java APIs parsed by the 'dexdeps' tool within the gen_java_usedby_apex.sh.

Bug: 239084755
Fixes: 239084755
Test: presubmits
Change-Id: Ia271783a6be3ea3a343481306cde1aaba2166e88
diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go
index e981ad5..529285f 100644
--- a/android/allowlists/allowlists.go
+++ b/android/allowlists/allowlists.go
@@ -69,6 +69,9 @@
 		"build/soong/scripts":                Bp2BuildDefaultTrueRecursively,
 
 		"cts/common/device-side/nativetesthelper/jni": Bp2BuildDefaultTrueRecursively,
+
+		"dalvik/tools/dexdeps": Bp2BuildDefaultTrueRecursively,
+
 		"development/apps/DevelopmentSettings":        Bp2BuildDefaultTrue,
 		"development/apps/Fallback":                   Bp2BuildDefaultTrue,
 		"development/apps/WidgetPreview":              Bp2BuildDefaultTrue,
@@ -176,7 +179,7 @@
 		"external/zopfli":                        Bp2BuildDefaultTrueRecursively,
 		"external/zstd":                          Bp2BuildDefaultTrueRecursively,
 
-		"frameworks/av":                                      Bp2BuildDefaultTrue,
+		"frameworks/av": Bp2BuildDefaultTrue,
 		"frameworks/av/media/codec2/components/aom":          Bp2BuildDefaultTrueRecursively,
 		"frameworks/av/media/codecs":                         Bp2BuildDefaultTrueRecursively,
 		"frameworks/av/media/liberror":                       Bp2BuildDefaultTrueRecursively,
diff --git a/apex/apex.go b/apex/apex.go
index 3676607..98722c4 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -1910,7 +1910,7 @@
 		a.nativeApisUsedByModuleFile = android.ModuleOutPath(android.PathForBazelOut(ctx, outputs.SymbolsUsedByApex))
 		a.nativeApisBackedByModuleFile = android.ModuleOutPath(android.PathForBazelOut(ctx, outputs.BackingLibs))
 		// TODO(b/239084755): Generate the java api using.xml file from Bazel.
-		a.javaApisUsedByModuleFile = android.ModuleOutPath(android.PathForBazelOut(ctx, a.Name()+"_using.xml"))
+		a.javaApisUsedByModuleFile = android.ModuleOutPath(android.PathForBazelOut(ctx, outputs.JavaSymbolsUsedByApex))
 		installSuffix := imageApexSuffix
 		if a.isCompressed {
 			installSuffix = imageCapexSuffix
diff --git a/apex/apex_test.go b/apex/apex_test.go
index d8debef..9964ae4 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -9754,11 +9754,12 @@
 				OutputBaseDir: outputBaseDir,
 				LabelToApexInfo: map[string]cquery.ApexInfo{
 					"//:foo": cquery.ApexInfo{
-						SignedOutput:      "signed_out.apex",
-						UnsignedOutput:    "unsigned_out.apex",
-						BundleKeyInfo:     []string{"public_key", "private_key"},
-						ContainerKeyInfo:  []string{"container_cert", "container_private"},
-						SymbolsUsedByApex: "foo_using.txt",
+						SignedOutput:          "signed_out.apex",
+						UnsignedOutput:        "unsigned_out.apex",
+						BundleKeyInfo:         []string{"public_key", "private_key"},
+						ContainerKeyInfo:      []string{"container_cert", "container_private"},
+						SymbolsUsedByApex:     "foo_using.txt",
+						JavaSymbolsUsedByApex: "foo_using.xml",
 
 						// unused
 						PackageName:  "pkg_name",
@@ -9799,4 +9800,8 @@
 	if w, g := "out/bazel/execroot/__main__/foo_using.txt", ab.nativeApisUsedByModuleFile.String(); w != g {
 		t.Errorf("Expected output file %q, got %q", w, g)
 	}
+
+	if w, g := "out/bazel/execroot/__main__/foo_using.xml", ab.javaApisUsedByModuleFile.String(); w != g {
+		t.Errorf("Expected output file %q, got %q", w, g)
+	}
 }
diff --git a/bazel/cquery/request_type.go b/bazel/cquery/request_type.go
index e47e85f..b1b9089 100644
--- a/bazel/cquery/request_type.go
+++ b/bazel/cquery/request_type.go
@@ -219,20 +219,22 @@
     "container_key_info": [container_key_info.pem.path, container_key_info.pk8.path, container_key_info.key_name],
     "package_name": info.package_name,
     "symbols_used_by_apex": info.symbols_used_by_apex.path,
+    "java_symbols_used_by_apex": info.java_symbols_used_by_apex.path,
     "backing_libs": info.backing_libs.path,
 })`
 }
 
 type ApexInfo struct {
-	SignedOutput      string   `json:"signed_output"`
-	UnsignedOutput    string   `json:"unsigned_output"`
-	ProvidesLibs      []string `json:"provides_native_libs"`
-	RequiresLibs      []string `json:"requires_native_libs"`
-	BundleKeyInfo     []string `json:"bundle_key_info"`
-	ContainerKeyInfo  []string `json:"container_key_info"`
-	PackageName       string   `json:"package_name"`
-	SymbolsUsedByApex string   `json:"symbols_used_by_apex"`
-	BackingLibs       string   `json:"backing_libs"`
+	SignedOutput          string   `json:"signed_output"`
+	UnsignedOutput        string   `json:"unsigned_output"`
+	ProvidesLibs          []string `json:"provides_native_libs"`
+	RequiresLibs          []string `json:"requires_native_libs"`
+	BundleKeyInfo         []string `json:"bundle_key_info"`
+	ContainerKeyInfo      []string `json:"container_key_info"`
+	PackageName           string   `json:"package_name"`
+	SymbolsUsedByApex     string   `json:"symbols_used_by_apex"`
+	JavaSymbolsUsedByApex string   `json:"java_symbols_used_by_apex"`
+	BackingLibs           string   `json:"backing_libs"`
 }
 
 // ParseResult returns a value obtained by parsing the result of the request's Starlark function.