Force the use of the CMC (UFFD) GC by default on Android U and earlier.

This change amends the logic controlling the use of ART's garbage
collector (GC), for the pre-opting of a product's Dex code at build
time and for the selection of the GC used at run time on the
device. The currently available garbage collectors are:
* the Concurrent Mark-Compact (CMC) garbage collector, which requires
  `userfaultfd` (UFFD) support in the Linux kernel;
* the Concurrent Copying (CC) garbage collector, which is supported
  with all Linux kernels.

When using an ART Module containing this change on a device running
Android S, T, or U:
* The product's Dex code is pre-opted according to the value of
  product variable `PRODUCT_ENABLE_UFFD_GC`:
  * When set to `default`: if the product supports the CMC (UFFD) GC,
    the product's Dex code is pre-opted for the CMC GC; otherwise the
    product's Dex code is pre-opted for the CC GC.
  * When set to `true`: the product's Dex code is unconditionally
    pre-opted for the CMC GC.
  * When set to `false`: the product's Dex code is unconditionally
    pre-opted for the CC GC.
* However, the selection of the garbage collector at run time on the
  device *does not* take into account the value of product variable
  `PRODUCT_ENABLE_UFFD_GC`: the device will try to use the CMC GC if
  the device supports it; otherwise, it will use the CC GC. If the Dex
  code on device has been pre-opted for a collector different than the
  one eventually selected by the device at run time, `odrefresh` will
  be triggered on the first boot to recompile core artifacts.
* The use of the CC GC can be forced by setting the
  `runtime_native_boot/force_disable_uffd_gc` P/H flag to `true` (see
  below) on Android T and Android U (on Android S, an `init` order bug
  doesn't make the P/H settings available early enough during boot).

When using an ART Module containing this change on a device with SDK
platform level `VanillaIceCream` (running Android built from current
`main` sources):
* Dex pre-opting and the selection of the garbage
  collector at run time on the device *do* take into account the value
  of product variable `PRODUCT_ENABLE_UFFD_GC`:
  * When set to `default`: if the product supports the CMC (UFFD) GC,
    the product's Dex code is pre-opted for the CMC GC, which is used
    at run time on the device; otherwise the product's Dex code is
    pre-opted for the CC GC, which is used at run time on the device.
  * When set to `true`: the product's Dex code is unconditionally
    pre-opted for the CMC GC; if the product supports the CMC GC, it
    is used at run time on the device; otherwise, the CC GC is used
    (thus triggering `odrefresh` on first boot).
  * When set to `false`: the product's Dex code is unconditionally
    pre-opted for the CC GC, which is used at run time on the device.
* (The previous logic may change in future ART Module updates.)
* The use of the CMC GC can be forced by setting the
  `runtime_native_boot/enable_uffd_gc_2` P/H flag to `true`.

This change reverts and amends commit
f53cfb405ccdf4dedd4094a5ca3fee63424ba5ee.

Reason for revert: b/320249002

Test: atest art_standalone_odrefresh_tests
Test: atest odsign_e2e_tests odsign_e2e_tests_full
Test: Build product with bundled modules on main with
  `OVERRIDE_ENABLE_UFFD_GC=false`, check that `odrefresh` runs on
  boot, check that the logcat output contains "Using CollectorTypeCC
  GC.", and that the boot image is actually used (i.e. JIT-Zygote is
  not used)
Test: Build module on Mainline branch, install on device running S,
  check that `odrefresh` runs on reboot, and check that the logcat
  output contains "Using CollectorTypeCMC GC."
  Reboot again, and check that `odrefresh` does not run and that the
  logcat output contains "Using CollectorTypeCMC GC."
Test: Same as above on a device running T or U, and then flip the GC
  type using the following commands:
      adb root
      adb shell device_config set_sync_disabled_for_tests persistent
      adb shell device_config put \
        runtime_native_boot force_disable_uffd_gc true
      adb reboot
  Check that `odrefresh` runs on reboot, and check that the logcat
  output contains "Using CollectorTypeCC GC."
  Reboot again, and check that `odrefresh` does not run and that the
  logcat output contains "Using CollectorTypeCC GC."
Bug: 320249002
Bug: 251150519
Change-Id: Ibe41499622f5a2853cc195d5ab755c74c4efa42a
diff --git a/odrefresh/odr_common_test.cc b/odrefresh/odr_common_test.cc
index 77becad..0cf34bd 100644
--- a/odrefresh/odr_common_test.cc
+++ b/odrefresh/odr_common_test.cc
@@ -57,13 +57,21 @@
 
 TEST(OdrCommonTest, CheckBuildUserfaultFdGc) {
   EXPECT_TRUE(CheckBuildUserfaultFdGc(
-      /*build_enable_uffd_gc=*/false, /*kernel_supports_uffd=*/false));
+      /*build_enable_uffd_gc=*/false, /*is_at_most_u=*/false, /*kernel_supports_uffd=*/false));
   EXPECT_FALSE(CheckBuildUserfaultFdGc(
-      /*build_enable_uffd_gc=*/true, /*kernel_supports_uffd=*/false));
-  EXPECT_FALSE(CheckBuildUserfaultFdGc(
-      /*build_enable_uffd_gc=*/false, /*kernel_supports_uffd=*/true));
+      /*build_enable_uffd_gc=*/true, /*is_at_most_u=*/false, /*kernel_supports_uffd=*/false));
   EXPECT_TRUE(CheckBuildUserfaultFdGc(
-      /*build_enable_uffd_gc=*/true, /*kernel_supports_uffd=*/true));
+      /*build_enable_uffd_gc=*/false, /*is_at_most_u=*/true, /*kernel_supports_uffd=*/false));
+  EXPECT_FALSE(CheckBuildUserfaultFdGc(
+      /*build_enable_uffd_gc=*/true, /*is_at_most_u=*/true, /*kernel_supports_uffd=*/false));
+  EXPECT_TRUE(CheckBuildUserfaultFdGc(
+      /*build_enable_uffd_gc=*/false, /*is_at_most_u=*/false, /*kernel_supports_uffd=*/true));
+  EXPECT_TRUE(CheckBuildUserfaultFdGc(
+      /*build_enable_uffd_gc=*/true, /*is_at_most_u=*/false, /*kernel_supports_uffd=*/true));
+  EXPECT_FALSE(CheckBuildUserfaultFdGc(
+      /*build_enable_uffd_gc=*/false, /*is_at_most_u=*/true, /*kernel_supports_uffd=*/true));
+  EXPECT_TRUE(CheckBuildUserfaultFdGc(
+      /*build_enable_uffd_gc=*/true, /*is_at_most_u=*/true, /*kernel_supports_uffd=*/true));
 }
 
 }  // namespace odrefresh