Fix a check failure in the CC background transition.

If there's a process state update from jank perceptible to jank
in-perceptible and a reverse update right after it, there's a chance
that the heap task daemon sees desired_collector_type ==
kCollectorTypeCC rather than kCollectorTypeCCBackground in
DoPendingCollectorTransition() which leads to a !kUseReadBarrier check
failure in TransitionCollector(). The fix is to move this check after
the early return case where collector_type == collector_type_ in
TransitionCollector() like the CMS/Hspace case.

Bug: 31039431
Bug: 12687968
Test: test-art-host, aosp boot with CC, master boot with CC.

Change-Id: I5fe34cb41eaa01c6d8bf80a185253fde6778e852
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index 4d16b6e..e2b5999 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -2125,11 +2125,11 @@
 }
 
 void Heap::TransitionCollector(CollectorType collector_type) {
-  // Collector transition must not happen with CC
-  CHECK(!kUseReadBarrier);
   if (collector_type == collector_type_) {
     return;
   }
+  // Collector transition must not happen with CC
+  CHECK(!kUseReadBarrier);
   VLOG(heap) << "TransitionCollector: " << static_cast<int>(collector_type_)
              << " -> " << static_cast<int>(collector_type);
   uint64_t start_time = NanoTime();