Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e52c9344 authored by Shai Barack's avatar Shai Barack
Browse files

Don't use concurrent MQ when instrumenting

Change-Id: I8db2de77947e603ea616ecd59cba0b2ee0adc24b
Flag: build.RELEASE_PACKAGE_MESSAGEQUEUE_IMPLEMENTATION
Bug: 381868602
parent 5343b035
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ package android.os;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.TestApi;
import android.app.ActivityThread;
import android.app.Instrumentation;
import android.compat.annotation.UnsupportedAppUsage;
import android.os.Process;
import android.os.UserHandle;
@@ -119,7 +121,7 @@ public final class MessageQueue {

    MessageQueue(boolean quitAllowed) {
        initIsProcessAllowedToUseConcurrent();
        mUseConcurrent = sIsProcessAllowedToUseConcurrent;
        mUseConcurrent = sIsProcessAllowedToUseConcurrent && !isInstrumenting();
        mQuitAllowed = quitAllowed;
        mPtr = nativeInit();
    }
@@ -172,6 +174,15 @@ public final class MessageQueue {
        }
    }

    private static boolean isInstrumenting() {
        final ActivityThread activityThread = ActivityThread.currentActivityThread();
        if (activityThread == null) {
            return false;
        }
        final Instrumentation instrumentation = activityThread.getInstrumentation();
        return instrumentation != null && instrumentation.isInstrumenting();
    }

    @Override
    protected void finalize() throws Throwable {
        try {