Fix CombinedMessageQueue for ravenwood

Flag: EXEMPT host test change only
Bug: 379145063
Test: atest CtsContentTestCasesRavenwood
Change-Id: I32bc7fd2838c9fc8b71d787d0d1e02127b752565
diff --git a/core/java/android/os/CombinedMessageQueue/MessageQueue.java b/core/java/android/os/CombinedMessageQueue/MessageQueue.java
index 9ad2e7f..4c9f08d 100644
--- a/core/java/android/os/CombinedMessageQueue/MessageQueue.java
+++ b/core/java/android/os/CombinedMessageQueue/MessageQueue.java
@@ -118,11 +118,8 @@
         mUseConcurrent = UserHandle.isCore(Process.myUid());
         // Even then, we don't use it if instrumentation is loaded as it breaks some
         // platform tests.
-        final ActivityThread activityThread = ActivityThread.currentActivityThread();
-        if (activityThread != null) {
-            final Instrumentation instrumentation = activityThread.getInstrumentation();
-            mUseConcurrent &= instrumentation == null || !instrumentation.isInstrumenting();
-        }
+        final Instrumentation instrumentation = getInstrumentation();
+        mUseConcurrent &= instrumentation == null || !instrumentation.isInstrumenting();
         // We can lift this restriction in the future after we've made it possible for test authors
         // to test Looper and MessageQueue without resorting to reflection.
 
@@ -130,6 +127,19 @@
         mPtr = nativeInit();
     }
 
+    @android.ravenwood.annotation.RavenwoodReplace(blockedBy = ActivityThread.class)
+    private static Instrumentation getInstrumentation() {
+        final ActivityThread activityThread = ActivityThread.currentActivityThread();
+        if (activityThread != null) {
+            return activityThread.getInstrumentation();
+        }
+        return null;
+    }
+
+    private static Instrumentation getInstrumentation$ravenwood() {
+        return null; // Instrumentation not supported on Ravenwood yet.
+    }
+
     @Override
     protected void finalize() throws Throwable {
         try {