diff options
| -rw-r--r-- | core/java/android/os/CombinedMessageQueue/MessageQueue.java | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/core/java/android/os/CombinedMessageQueue/MessageQueue.java b/core/java/android/os/CombinedMessageQueue/MessageQueue.java index 5c73de4669cd..036ccd84a600 100644 --- a/core/java/android/os/CombinedMessageQueue/MessageQueue.java +++ b/core/java/android/os/CombinedMessageQueue/MessageQueue.java @@ -118,11 +118,8 @@ public final class MessageQueue { 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. @@ -135,6 +132,19 @@ public final class MessageQueue { 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 { |