Don't use concurrent message queue when debugging is enabled

Debugging (and instrumentation) is known to make assumptions
about MessageQueue implementation details that are broken by
the modern concurrent implementation.
Until an alternative to the above is developed and rolled out,
opt out of the new implementation when exposed to this risk.

Bug: 336880969
Change-Id: I59a43a21534f7166803a3927bde8b9ed0fe1696e
Flag: build.RELEASE_PACKAGE_MESSAGEQUEUE_IMPLEMENTATION
diff --git a/core/java/android/os/CombinedMessageQueue/MessageQueue.java b/core/java/android/os/CombinedMessageQueue/MessageQueue.java
index 69bd668..7529ab9 100644
--- a/core/java/android/os/CombinedMessageQueue/MessageQueue.java
+++ b/core/java/android/os/CombinedMessageQueue/MessageQueue.java
@@ -31,6 +31,7 @@
 import android.util.proto.ProtoOutputStream;
 
 import dalvik.annotation.optimization.NeverCompile;
+import dalvik.system.VMDebug;
 
 import java.io.FileDescriptor;
 import java.lang.annotation.Retention;
@@ -110,7 +111,7 @@
     private native static void nativeSetFileDescriptorEvents(long ptr, int fd, int events);
 
     MessageQueue(boolean quitAllowed) {
-        mUseConcurrent = UserHandle.isCore(Process.myUid());
+        mUseConcurrent = UserHandle.isCore(Process.myUid()) && !VMDebug.isDebuggingEnabled();
         mQuitAllowed = quitAllowed;
         mPtr = nativeInit();
     }