Merge "Export host available libraries to soong_injection"
diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go
index 9700f8b..e22eec5 100644
--- a/android/allowlists/allowlists.go
+++ b/android/allowlists/allowlists.go
@@ -1565,10 +1565,10 @@
 	// also be built - do not add them to this list.
 	StagingMixedBuildsEnabledList = []string{
 		// M13: media.swcodec launch
-		// TODO(b/282042844): reenable
-		// "com.android.media.swcodec",
-		// "test_com.android.media.swcodec",
-		// "libstagefright_foundation",
+		"com.android.media.swcodec",
+		"test_com.android.media.swcodec",
+		"libstagefright_foundation",
+		"libcodec2_hidl@1.0",
 	}
 
 	// These should be the libs that are included by the apexes in the ProdMixedBuildsEnabledList
diff --git a/apex/apex.go b/apex/apex.go
index ff7ee35..1c79463 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -3273,7 +3273,7 @@
 	//
 	// Module separator
 	//
-	m["com.android.cellbroadcast"] = []string{"CellBroadcastApp", "CellBroadcastServiceModule"}
+	m["com.android.cellbroadcast"] = []string{}
 	//
 	// Module separator
 	//
diff --git a/cc/config/global.go b/cc/config/global.go
index d4106eb..d63e324 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -438,6 +438,8 @@
 	pctx.StaticVariableWithEnvOverride("ClangShortVersion", "LLVM_RELEASE_VERSION", ClangDefaultShortVersion)
 	pctx.StaticVariable("ClangAsanLibDir", "${ClangBase}/linux-x86/${ClangVersion}/lib/clang/${ClangShortVersion}/lib/linux")
 
+	exportedVars.ExportStringListStaticVariable("WarningAllowedProjects", WarningAllowedProjects)
+
 	// These are tied to the version of LLVM directly in external/llvm, so they might trail the host prebuilts
 	// being used for the rest of the build process.
 	pctx.SourcePathVariable("RSClangBase", "prebuilts/clang/host")
diff --git a/cc/lto.go b/cc/lto.go
index 1afa1dd..581856b 100644
--- a/cc/lto.go
+++ b/cc/lto.go
@@ -91,11 +91,6 @@
 		return flags
 	}
 
-	// TODO(b/254713216): LTO doesn't work on riscv64 yet.
-	if ctx.Arch().ArchType == android.Riscv64 {
-		return flags
-	}
-
 	if lto.LTO(ctx) {
 		var ltoCFlag string
 		var ltoLdFlag string
diff --git a/java/androidmk.go b/java/androidmk.go
index 148d7c2..9c21633 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -133,13 +133,19 @@
 	return entriesList
 }
 
-func (j *JavaFuzzLibrary) AndroidMkEntries() []android.AndroidMkEntries {
+func (j *JavaFuzzTest) AndroidMkEntries() []android.AndroidMkEntries {
 	entriesList := j.Library.AndroidMkEntries()
 	entries := &entriesList[0]
 	entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
 		entries.AddStrings("LOCAL_COMPATIBILITY_SUITE", "null-suite")
-		androidMkWriteTestData(j.jniFilePaths, entries)
 		androidMkWriteTestData(android.Paths{j.implementationJarFile}, entries)
+		androidMkWriteTestData(j.jniFilePaths, entries)
+		if j.fuzzPackagedModule.Corpus != nil {
+			androidMkWriteTestData(j.fuzzPackagedModule.Corpus, entries)
+		}
+		if j.fuzzPackagedModule.Dictionary != nil {
+			androidMkWriteTestData(android.Paths{j.fuzzPackagedModule.Dictionary}, entries)
+		}
 	})
 	return entriesList
 }
diff --git a/java/app.go b/java/app.go
index 3344647..e095092 100755
--- a/java/app.go
+++ b/java/app.go
@@ -585,19 +585,6 @@
 		certificates = append([]Certificate{mainCert}, certificates...)
 	}
 
-	if !m.Platform() {
-		certPath := certificates[0].Pem.String()
-		systemCertPath := ctx.Config().DefaultAppCertificateDir(ctx).String()
-		if strings.HasPrefix(certPath, systemCertPath) {
-			enforceSystemCert := ctx.Config().EnforceSystemCertificate()
-			allowed := ctx.Config().EnforceSystemCertificateAllowList()
-
-			if enforceSystemCert && !inList(m.Name(), allowed) {
-				ctx.PropertyErrorf("certificate", "The module in product partition cannot be signed with certificate in system.")
-			}
-		}
-	}
-
 	if len(certificates) > 0 {
 		mainCertificate = certificates[0]
 	} else {
@@ -613,6 +600,20 @@
 		}
 	}
 
+	if !m.Platform() {
+		certPath := mainCertificate.Pem.String()
+		systemCertPath := ctx.Config().DefaultAppCertificateDir(ctx).String()
+		if strings.HasPrefix(certPath, systemCertPath) {
+			enforceSystemCert := ctx.Config().EnforceSystemCertificate()
+			allowed := ctx.Config().EnforceSystemCertificateAllowList()
+
+			if enforceSystemCert && !inList(m.Name(), allowed) {
+				ctx.PropertyErrorf("certificate", "The module in product partition cannot be signed with certificate in system.")
+			}
+		}
+	}
+
+
 	return mainCertificate, certificates
 }
 
diff --git a/java/app_test.go b/java/app_test.go
index 8a69a03..c485478 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -3382,6 +3382,14 @@
 			srcs: ["a.java"],
 			certificate: ":missing_certificate",
 			sdk_version: "current",
+		}
+
+		android_app {
+			name: "bar",
+			srcs: ["a.java"],
+			certificate: ":missing_certificate",
+			product_specific: true,
+			sdk_version: "current",
 		}`)
 
 	foo := result.ModuleForTests("foo", "android_common")
diff --git a/java/fuzz.go b/java/fuzz.go
index 9a0c908..4aa6dbf 100644
--- a/java/fuzz.go
+++ b/java/fuzz.go
@@ -19,12 +19,12 @@
 	"sort"
 	"strings"
 
-	"github.com/google/blueprint"
-	"github.com/google/blueprint/proptools"
-
 	"android/soong/android"
 	"android/soong/cc"
 	"android/soong/fuzz"
+
+	"github.com/google/blueprint"
+	"github.com/google/blueprint/proptools"
 )
 
 const (
@@ -32,63 +32,63 @@
 	targetString = "target"
 )
 
-type jniProperties struct {
-	// list of jni libs
-	Jni_libs []string
-
-	// sanitization
-	Sanitizers []string
-}
-
 func init() {
 	RegisterJavaFuzzBuildComponents(android.InitRegistrationContext)
 }
 
 func RegisterJavaFuzzBuildComponents(ctx android.RegistrationContext) {
 	ctx.RegisterModuleType("java_fuzz", JavaFuzzFactory)
-	ctx.RegisterModuleType("java_fuzz_host", JavaFuzzHostFactory)
-	ctx.RegisterSingletonType("java_fuzz_host_packaging", javaFuzzHostPackagingFactory)
-	ctx.RegisterSingletonType("java_fuzz_device_packaging", javaFuzzDevicePackagingFactory)
+	ctx.RegisterSingletonType("java_fuzz_packaging", javaFuzzPackagingFactory)
 }
 
-type JavaFuzzLibrary struct {
-	Library
+type JavaFuzzTest struct {
+	Test
 	fuzzPackagedModule fuzz.FuzzPackagedModule
-	jniProperties      jniProperties
 	jniFilePaths       android.Paths
 }
 
-// IsSanitizerEnabledForJni implemented to make JavaFuzzLibrary implement
-// cc.JniSanitizeable. It returns a bool for whether a cc dependency should be
-// sanitized for the given sanitizer or not.
-func (j *JavaFuzzLibrary) IsSanitizerEnabledForJni(ctx android.BaseModuleContext, sanitizerName string) bool {
-	// TODO: once b/231370928 is resolved, please uncomment the loop
-	//     for _, s := range j.jniProperties.Sanitizers {
-	//         if sanitizerName == s {
-	//             return true
-	//         }
-	//     }
-	return false
+// java_fuzz builds and links sources into a `.jar` file for the device.
+// This generates .class files in a jar which can then be instrumented before
+// fuzzing in Android Runtime (ART: Android OS on emulator or device)
+func JavaFuzzFactory() android.Module {
+	module := &JavaFuzzTest{}
+
+	module.addHostAndDeviceProperties()
+	module.AddProperties(&module.testProperties)
+	module.AddProperties(&module.fuzzPackagedModule.FuzzProperties)
+
+	module.Module.properties.Installable = proptools.BoolPtr(true)
+	module.Module.dexpreopter.isTest = true
+	module.Module.linter.properties.Lint.Test = proptools.BoolPtr(true)
+
+	android.AddLoadHook(module, func(ctx android.LoadHookContext) {
+		disableLinuxBionic := struct {
+			Target struct {
+				Linux_bionic struct {
+					Enabled *bool
+				}
+			}
+		}{}
+		disableLinuxBionic.Target.Linux_bionic.Enabled = proptools.BoolPtr(false)
+		ctx.AppendProperties(&disableLinuxBionic)
+	})
+
+	InitJavaModuleMultiTargets(module, android.HostAndDeviceSupported)
+	return module
 }
 
-func (j *JavaFuzzLibrary) DepsMutator(mctx android.BottomUpMutatorContext) {
-	if len(j.jniProperties.Jni_libs) > 0 {
-		if j.fuzzPackagedModule.FuzzProperties.Fuzz_config == nil {
-			config := &fuzz.FuzzConfig{}
-			j.fuzzPackagedModule.FuzzProperties.Fuzz_config = config
-		}
-		// this will be used by the ingestion pipeline to determine the version
-		// of jazzer to add to the fuzzer package
-		j.fuzzPackagedModule.FuzzProperties.Fuzz_config.IsJni = proptools.BoolPtr(true)
-		for _, target := range mctx.MultiTargets() {
+func (j *JavaFuzzTest) DepsMutator(ctx android.BottomUpMutatorContext) {
+	if len(j.testProperties.Jni_libs) > 0 {
+		for _, target := range ctx.MultiTargets() {
 			sharedLibVariations := append(target.Variations(), blueprint.Variation{Mutator: "link", Variation: "shared"})
-			mctx.AddFarVariationDependencies(sharedLibVariations, cc.JniFuzzLibTag, j.jniProperties.Jni_libs...)
+			ctx.AddFarVariationDependencies(sharedLibVariations, jniLibTag, j.testProperties.Jni_libs...)
 		}
 	}
-	j.Library.DepsMutator(mctx)
+
+	j.deps(ctx)
 }
 
-func (j *JavaFuzzLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+func (j *JavaFuzzTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
 	if j.fuzzPackagedModule.FuzzProperties.Corpus != nil {
 		j.fuzzPackagedModule.Corpus = android.PathsForModuleSrc(ctx, j.fuzzPackagedModule.FuzzProperties.Corpus)
 	}
@@ -105,21 +105,15 @@
 	}
 
 	_, sharedDeps := cc.CollectAllSharedDependencies(ctx)
-
 	for _, dep := range sharedDeps {
 		sharedLibInfo := ctx.OtherModuleProvider(dep, cc.SharedLibraryInfoProvider).(cc.SharedLibraryInfo)
 		if sharedLibInfo.SharedLibrary != nil {
-			// The .class jars are output in slightly different locations
-			// relative to the jni libs. Therefore, for consistency across
-			// host and device fuzzers of jni lib location, we save it in a
-			// native_libs directory.
-			var relPath string
+			arch := "lib"
 			if sharedLibInfo.Target.Arch.ArchType.Multilib == "lib64" {
-				relPath = filepath.Join("lib64", sharedLibInfo.SharedLibrary.Base())
-			} else {
-				relPath = filepath.Join("lib", sharedLibInfo.SharedLibrary.Base())
+				arch = "lib64"
 			}
-			libPath := android.PathForModuleOut(ctx, relPath)
+
+			libPath := android.PathForModuleOut(ctx, filepath.Join(arch, sharedLibInfo.SharedLibrary.Base()))
 			ctx.Build(pctx, android.BuildParams{
 				Rule:   android.Cp,
 				Input:  sharedLibInfo.SharedLibrary,
@@ -129,104 +123,35 @@
 		} else {
 			ctx.PropertyErrorf("jni_libs", "%q of type %q is not supported", dep.Name(), ctx.OtherModuleType(dep))
 		}
+
 	}
 
-	j.Library.GenerateAndroidBuildActions(ctx)
+	j.Test.GenerateAndroidBuildActions(ctx)
 }
 
-// java_fuzz_host builds and links sources into a `.jar` file for the host.
-//
-// By default, a java_fuzz produces a `.jar` file containing `.class` files.
-// This jar is not suitable for installing on a device.
-func JavaFuzzHostFactory() android.Module {
-	module := &JavaFuzzLibrary{}
-	module.addHostProperties()
-	module.AddProperties(&module.jniProperties)
-	module.Module.properties.Installable = proptools.BoolPtr(true)
-	module.AddProperties(&module.fuzzPackagedModule.FuzzProperties)
-
-	// java_fuzz packaging rules collide when both linux_glibc and linux_bionic are enabled, disable the linux_bionic variants.
-	android.AddLoadHook(module, func(ctx android.LoadHookContext) {
-		disableLinuxBionic := struct {
-			Target struct {
-				Linux_bionic struct {
-					Enabled *bool
-				}
-			}
-		}{}
-		disableLinuxBionic.Target.Linux_bionic.Enabled = proptools.BoolPtr(false)
-		ctx.AppendProperties(&disableLinuxBionic)
-	})
-
-	InitJavaModuleMultiTargets(module, android.HostSupportedNoCross)
-	return module
-}
-
-// java_fuzz builds and links sources into a `.jar` file for the device.
-// This generates .class files in a jar which can then be instrumented before
-// fuzzing in Android Runtime (ART: Android OS on emulator or device)
-func JavaFuzzFactory() android.Module {
-	module := &JavaFuzzLibrary{}
-	module.addHostAndDeviceProperties()
-	module.AddProperties(&module.jniProperties)
-	module.Module.properties.Installable = proptools.BoolPtr(true)
-	module.AddProperties(&module.fuzzPackagedModule.FuzzProperties)
-	module.Module.dexpreopter.isTest = true
-	module.Module.linter.properties.Lint.Test = proptools.BoolPtr(true)
-	InitJavaModuleMultiTargets(module, android.DeviceSupported)
-	return module
-}
-
-// Responsible for generating rules that package host fuzz targets into
-// a zip file.
-type javaFuzzHostPackager struct {
+type javaFuzzPackager struct {
 	fuzz.FuzzPackager
 }
 
-// Responsible for generating rules that package device fuzz targets into
-// a zip file.
-type javaFuzzDevicePackager struct {
-	fuzz.FuzzPackager
+func javaFuzzPackagingFactory() android.Singleton {
+	return &javaFuzzPackager{}
 }
 
-func javaFuzzHostPackagingFactory() android.Singleton {
-	return &javaFuzzHostPackager{}
-}
-
-func javaFuzzDevicePackagingFactory() android.Singleton {
-	return &javaFuzzDevicePackager{}
-}
-
-func (s *javaFuzzHostPackager) GenerateBuildActions(ctx android.SingletonContext) {
-	generateBuildActions(&s.FuzzPackager, hostString, ctx)
-}
-
-func (s *javaFuzzDevicePackager) GenerateBuildActions(ctx android.SingletonContext) {
-	generateBuildActions(&s.FuzzPackager, targetString, ctx)
-}
-
-func generateBuildActions(s *fuzz.FuzzPackager, hostOrTargetString string, ctx android.SingletonContext) {
+func (s *javaFuzzPackager) GenerateBuildActions(ctx android.SingletonContext) {
 	// Map between each architecture + host/device combination.
 	archDirs := make(map[fuzz.ArchOs][]fuzz.FileToZip)
 
-	// List of individual fuzz targets.
 	s.FuzzTargets = make(map[string]bool)
-
 	ctx.VisitAllModules(func(module android.Module) {
 		// Discard non-fuzz targets.
-		javaFuzzModule, ok := module.(*JavaFuzzLibrary)
+		javaFuzzModule, ok := module.(*JavaFuzzTest)
 		if !ok {
 			return
 		}
 
-		if hostOrTargetString == hostString {
-			if !javaFuzzModule.Host() {
-				return
-			}
-		} else if hostOrTargetString == targetString {
-			if javaFuzzModule.Host() || javaFuzzModule.Target().HostCross {
-				return
-			}
+		hostOrTargetString := "target"
+		if javaFuzzModule.Host() {
+			hostOrTargetString = "host"
 		}
 
 		fuzzModuleValidator := fuzz.FuzzModule{
@@ -246,7 +171,7 @@
 		var files []fuzz.FileToZip
 		builder := android.NewRuleBuilder(pctx, ctx)
 
-		// Package the artifacts (data, corpus, config and dictionary into a zipfile.
+		// Package the artifacts (data, corpus, config and dictionary) into a zipfile.
 		files = s.PackageArtifacts(ctx, module, javaFuzzModule.fuzzPackagedModule, archDir, builder)
 
 		// Add .jar
@@ -261,27 +186,14 @@
 		if !ok {
 			return
 		}
-
 	})
 	s.CreateFuzzPackage(ctx, archDirs, fuzz.Java, pctx)
 }
 
-func (s *javaFuzzHostPackager) MakeVars(ctx android.MakeVarsContext) {
+func (s *javaFuzzPackager) MakeVars(ctx android.MakeVarsContext) {
 	packages := s.Packages.Strings()
 	sort.Strings(packages)
-
-	ctx.Strict("SOONG_JAVA_FUZZ_HOST_PACKAGING_ARCH_MODULES", strings.Join(packages, " "))
-
+	ctx.Strict("SOONG_JAVA_FUZZ_PACKAGING_ARCH_MODULES", strings.Join(packages, " "))
 	// Preallocate the slice of fuzz targets to minimize memory allocations.
-	s.PreallocateSlice(ctx, "ALL_JAVA_FUZZ_HOST_TARGETS")
-}
-
-func (s *javaFuzzDevicePackager) MakeVars(ctx android.MakeVarsContext) {
-	packages := s.Packages.Strings()
-	sort.Strings(packages)
-
-	ctx.Strict("SOONG_JAVA_FUZZ_DEVICE_PACKAGING_ARCH_MODULES", strings.Join(packages, " "))
-
-	// Preallocate the slice of fuzz targets to minimize memory allocations.
-	s.PreallocateSlice(ctx, "ALL_JAVA_FUZZ_DEVICE_TARGETS")
+	s.PreallocateSlice(ctx, "ALL_JAVA_FUZZ_TARGETS")
 }
diff --git a/java/fuzz_test.go b/java/fuzz_test.go
index 186c3aa..dd1e96b 100644
--- a/java/fuzz_test.go
+++ b/java/fuzz_test.go
@@ -31,18 +31,16 @@
 
 func TestJavaFuzz(t *testing.T) {
 	result := prepForJavaFuzzTest.RunTestWithBp(t, `
-		java_fuzz_host {
+		java_fuzz {
 			name: "foo",
 			srcs: ["a.java"],
+			host_supported: true,
+			device_supported: false,
 			libs: ["bar"],
 			static_libs: ["baz"],
             jni_libs: [
                 "libjni",
             ],
-            sanitizers: [
-                "address",
-                "fuzzer",
-            ],
 		}
 
 		java_library_host {
@@ -84,7 +82,7 @@
 	}
 
 	ctx := result.TestContext
-	foo := ctx.ModuleForTests("foo", osCommonTarget).Module().(*JavaFuzzLibrary)
+	foo := ctx.ModuleForTests("foo", osCommonTarget).Module().(*JavaFuzzTest)
 
 	expected := "lib64/libjni.so"
 	if runtime.GOOS == "darwin" {
diff --git a/java/java.go b/java/java.go
index a98762c..bb8fe62 100644
--- a/java/java.go
+++ b/java/java.go
@@ -1156,7 +1156,6 @@
 	}
 
 	j.addDataDeviceBinsDeps(ctx)
-
 	j.deps(ctx)
 }
 
@@ -1651,7 +1650,7 @@
 	// list of api.txt files relative to this directory that contribute to the
 	// API surface.
 	// This is a list of relative paths
-	Api_files []string
+	Api_files []string `android:"path"`
 
 	// List of flags to be passed to the javac compiler to generate jar file
 	Javacflags []string
@@ -1833,9 +1832,7 @@
 
 	// Add the api_files inputs
 	for _, api := range al.properties.Api_files {
-		// Use MaybeExistentPathForSource since the api file might not exist during analysis.
-		// This will be provided by the orchestrator in the combined execution.
-		srcFiles = append(srcFiles, android.MaybeExistentPathForSource(ctx, ctx.ModuleDir(), api))
+		srcFiles = append(srcFiles, android.PathForModuleSrc(ctx, api))
 	}
 
 	if srcFiles == nil {
diff --git a/java/java_test.go b/java/java_test.go
index 2a4913e..ea89e6e 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -2252,6 +2252,29 @@
 	android.AssertStringDoesContain(t, "Command expected to contain output files list text file flag", manifestCommand, "--out __SBOX_SANDBOX_DIR__/out/sources.txt")
 }
 
+func TestJavaApiLibraryFilegroupInput(t *testing.T) {
+	ctx, _ := testJavaWithFS(t, `
+	    filegroup {
+			name: "default_current.txt",
+			srcs: ["current.txt"],
+		}
+
+		java_api_library {
+			name: "foo",
+			api_files: [":default_current.txt"],
+		}
+		`,
+		map[string][]byte{
+			"current.txt": nil,
+		})
+
+	m := ctx.ModuleForTests("foo", "android_common")
+	outputs := fmt.Sprint(m.AllOutputs())
+	if !strings.Contains(outputs, "foo/foo.jar") {
+		t.Errorf("Module output does not contain expected jar %s", "foo/foo.jar")
+	}
+}
+
 func TestTradefedOptions(t *testing.T) {
 	result := PrepareForTestWithJavaBuildComponents.RunTestWithBp(t, `
 java_test_host {
diff --git a/java/testing.go b/java/testing.go
index 6671bf0..ffc3a08 100644
--- a/java/testing.go
+++ b/java/testing.go
@@ -71,7 +71,12 @@
 		// Needed for framework
 		defaultJavaDir + "/framework/aidl": nil,
 		// Needed for various deps defined in GatherRequiredDepsForTest()
-		defaultJavaDir + "/a.java": nil,
+		defaultJavaDir + "/a.java":                        nil,
+		defaultJavaDir + "/api/current.txt":               nil,
+		defaultJavaDir + "/api/system-current.txt":        nil,
+		defaultJavaDir + "/api/test-current.txt":          nil,
+		defaultJavaDir + "/api/module-lib-current.txt":    nil,
+		defaultJavaDir + "/api/system-server-current.txt": nil,
 
 		// Needed for R8 rules on apps
 		"build/make/core/proguard.flags":             nil,
diff --git a/python/test.go b/python/test.go
index 31da17e..7de7af2 100644
--- a/python/test.go
+++ b/python/test.go
@@ -39,7 +39,7 @@
 }
 
 func PythonTestHostFactory() android.Module {
-	return NewTest(android.HostSupportedNoCross).init()
+	return NewTest(android.HostSupported).init()
 }
 
 func PythonTestFactory() android.Module {
@@ -98,7 +98,7 @@
 	android.InitAndroidArchModule(p, p.hod, p.multilib)
 	android.InitDefaultableModule(p)
 	android.InitBazelModule(p)
-	if p.hod == android.HostSupportedNoCross && p.testProperties.Test_options.Unit_test == nil {
+	if p.hod == android.HostSupported && p.testProperties.Test_options.Unit_test == nil {
 		p.testProperties.Test_options.Unit_test = proptools.BoolPtr(true)
 	}
 	return p
diff --git a/tests/dcla_apex_comparison_test.sh b/tests/dcla_apex_comparison_test.sh
index 97ae97e..667dde0 100755
--- a/tests/dcla_apex_comparison_test.sh
+++ b/tests/dcla_apex_comparison_test.sh
@@ -45,6 +45,11 @@
   com.android.tethering
 )
 
+BAZEL_TARGETS=(
+  //packages/modules/adb/apex:com.android.adbd
+  //frameworks/av/apex:com.android.media.swcodec
+)
+
 DCLA_LIBS=(
   libbase.so
   libc++.so
@@ -76,6 +81,10 @@
 ############
 OUTPUT_DIR="$(mktemp -d tmp.XXXXXX)"
 
+function call_bazel() {
+  build/bazel/bin/bazel $@
+}
+
 function cleanup {
   rm -rf "${OUTPUT_DIR}"
 }
@@ -87,7 +96,9 @@
 
 function extract_dcla_libs() {
   local product=$1; shift
-  for module in "${MODULES[@]}"; do
+  local modules=("$@"); shift
+
+  for module in "${modules[@]}"; do
     local apex="${OUTPUT_DIR}/${product}/${module}.apex"
     local extract_dir="${OUTPUT_DIR}/${product}/${module}/extract"
 
@@ -97,11 +108,12 @@
 
 function compare_dcla_libs() {
   local product=$1; shift
+  local modules=("$@"); shift
 
   for lib in "${DCLA_LIBS[@]}"; do
     for arch in lib lib64; do
       local prev_sha=""
-      for module in "${MODULES[@]}"; do
+      for module in "${modules[@]}"; do
         local file="${OUTPUT_DIR}/${product}/${module}/extract/${arch}/${lib}"
         if [[ ! -f "${file}" ]]; then
           # not all libs are present in a module
@@ -112,7 +124,7 @@
         sha="${sha% *}"
         if [ "${prev_sha}" == "" ]; then
           prev_sha="${sha}"
-        elif [ "${sha}" != "${prev_sha}" ] && { [ "${lib}" != "libcrypto.so" ] || [ "${module}" != "com.android.tethering" ]; }; then
+        elif [ "${sha}" != "${prev_sha}" ] && { [ "${lib}" != "libcrypto.so" ] || [[ "${module}" != *"com.android.tethering" ]]; }; then
           echo "Test failed, ${lib} has different hash value"
           exit 1
         fi
@@ -131,8 +143,22 @@
     --product "${product}" \
     --dist_dir "${OUTPUT_DIR}/${product}"
 
-  extract_dcla_libs "${product}"
-  compare_dcla_libs "${product}"
+  bazel_apexes=()
+  if [[ -n ${TEST_BAZEL+x} ]] && [ "${TEST_BAZEL}" = true ]; then
+    export TARGET_PRODUCT="${product/module/aosp}"
+    call_bazel build --config=bp2build --config=ci --config=android "${BAZEL_TARGETS[@]}"
+    for target in "${BAZEL_TARGETS[@]}"; do
+      apex_path="$(realpath $(call_bazel cquery --config=bp2build --config=android --config=ci --output=files $target))"
+      mkdir -p ${OUTPUT_DIR}/${product}
+      bazel_apex="bazel_$(basename $apex_path)"
+      mv $apex_path ${OUTPUT_DIR}/${product}/${bazel_apex}
+      bazel_apexes+=(${bazel_apex%".apex"})
+    done
+  fi
+
+  all_modeuls=(${MODULES[@]} ${bazel_apexes[@]})
+  extract_dcla_libs "${product}" "${all_modeuls[@]}"
+  compare_dcla_libs "${product}" "${all_modeuls[@]}"
 done
 
 echo "Test passed"
diff --git a/tests/run_integration_tests.sh b/tests/run_integration_tests.sh
index e1aa70c..db14bd4 100755
--- a/tests/run_integration_tests.sh
+++ b/tests/run_integration_tests.sh
@@ -15,8 +15,8 @@
 # mock client.
 "$TOP/build/soong/tests/apex_comparison_tests.sh"
 "$TOP/build/soong/tests/apex_comparison_tests.sh" "module_arm64only"
-extra_build_params=--bazel-mode-staging "$TOP/build/soong/tests/dcla_apex_comparison_test.sh"
-BUILD_BROKEN_DISABLE_BAZEL=true "$TOP/build/soong/tests/dcla_apex_comparison_test.sh"
+TEST_BAZEL=true extra_build_params=--bazel-mode-staging "$TOP/build/soong/tests/dcla_apex_comparison_test.sh"
+#BUILD_BROKEN_DISABLE_BAZEL=true "$TOP/build/soong/tests/dcla_apex_comparison_test.sh"
 "$TOP/build/soong/tests/apex_cc_module_arch_variant_tests.sh"
 "$TOP/build/soong/tests/apex_cc_module_arch_variant_tests.sh" "aosp_arm" "armv7-a"
 "$TOP/build/soong/tests/apex_cc_module_arch_variant_tests.sh" "aosp_cf_arm64_phone" "armv8-a" "cortex-a53"
diff --git a/ui/build/config.go b/ui/build/config.go
index 6b6ce71..8ec9680 100644
--- a/ui/build/config.go
+++ b/ui/build/config.go
@@ -316,9 +316,8 @@
 
 func NewConfig(ctx Context, args ...string) Config {
 	ret := &configImpl{
-		environ:               OsEnvironment(),
-		sandboxConfig:         &SandboxConfig{},
-		ninjaWeightListSource: HINT_FROM_SOONG,
+		environ:       OsEnvironment(),
+		sandboxConfig: &SandboxConfig{},
 	}
 
 	// Default matching ninja