Enable mainline prebuilts on tm-dev branch.

Except for santizer and framework Java coverage tests as they require
specialized prebuilts built from a matching configuration and we do not
provide them.

Bug: 230478310
Bug: 223592962
Test: presubmit
Merged-In: I3ed091156c4b39dad6eaf578144ac3d070025988
Merged-In: I9731400acfade95b3eab8f2d99fddb4cf856aa91
Change-Id: Ibc3ea584b95f8186c63e29f71b5164451dc433cd
diff --git a/core/android_soong_config_vars.mk b/core/android_soong_config_vars.mk
index 329847f..144edd0 100644
--- a/core/android_soong_config_vars.mk
+++ b/core/android_soong_config_vars.mk
@@ -39,7 +39,14 @@
 # Default behavior for the tree wrt building modules or using prebuilts. This
 # can always be overridden by setting the environment variable
 # MODULE_BUILD_FROM_SOURCE.
-BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE := true
+ifneq ($(SANITIZE_TARGET)$(EMMA_INSTRUMENT_FRAMEWORK),)
+  # Always use sources when building the framework with Java coverage or
+  # sanitized builds as they both require purpose built prebuilts which we do
+  # not provide.
+  BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE := true
+else
+  BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE := false
+endif
 
 ifneq (,$(MODULE_BUILD_FROM_SOURCE))
   # Keep an explicit setting.