Disable native modules by default when ART prebuilts are used.

libjavacore unit tests and benchmark that are referenced from platform
are exempt for now.

Cherry-picked from https://r.android.com/1710849.

Test: m nothing
Test: m nothing SOONG_CONFIG_art_module_source_build=false
Bug: 172480615
Change-Id: Ie15e7a291b63a3eb470bdda9c8e3738ed54da50b
Merged-In: Ie15e7a291b63a3eb470bdda9c8e3738ed54da50b
diff --git a/NativeCode.bp b/NativeCode.bp
index dac2387..534c3ad 100644
--- a/NativeCode.bp
+++ b/NativeCode.bp
@@ -20,6 +20,7 @@
 
 cc_defaults {
     name: "core_native_default_flags",
+    defaults: ["art_module_source_build_defaults"],
     host_supported: true,
     cflags: [
         "-Wall",
@@ -213,6 +214,10 @@
     name: "libjavacore-unit-tests",
     defaults: ["core_native_default_flags"],
 
+    // TODO(b/172480617): Fix this source dependency from
+    // platform_testing/build/tasks/tests/native_test_list.mk.
+    enabled: true,
+
     // Add -fno-builtin so that the compiler doesn't attempt to inline
     // memcpy calls that are not really aligned.
     cflags: ["-fno-builtin"],
@@ -234,6 +239,10 @@
     name: "libjavacore-benchmarks",
     defaults: ["core_native_default_flags"],
 
+    // TODO(b/172480617): Fix this source dependency from
+    // platform_testing/build/tasks/tests/native_metric_test_list.mk.
+    enabled: true,
+
     srcs: [
         "luni/src/benchmark/native/libcore_io_Memory_bench.cpp",
         // libcore_io_Memory_bench.cpp includes libcore_io_Memory.cpp which