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

Commit b5f3968a authored by Mark Fasheh's avatar Mark Fasheh
Browse files

Add ChangeId for new message queue

Bug: 421623328
Test: Boot and find ENABLE_FORCE_NEW_MESSAGEQUEUE in app
Test: compat options.
Flag: build.RELEASE_PACKAGE_MESSAGEQUEUE_IMPLEMENTATION
Change-Id: Ib207c7be8f481e1c1035dc3cb816c1cfef7f9d8e
parent 92b59bc5
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -16,13 +16,19 @@

package android.os;

import android.annotation.FlaggedApi;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SuppressLint;
import android.annotation.TestApi;
import android.app.compat.CompatChanges;
import android.app.ActivityThread;
import android.app.Instrumentation;
import android.compat.annotation.ChangeId;
import android.compat.annotation.Disabled;
import android.compat.annotation.EnabledAfter;
import android.compat.annotation.Overridable;
import android.compat.annotation.UnsupportedAppUsage;
import android.ravenwood.annotation.RavenwoodKeepWholeClass;
import android.ravenwood.annotation.RavenwoodRedirect;
@@ -68,6 +74,16 @@ public final class MessageQueue {
    private static final String TAG_C = "ConcurrentMessageQueue";
    private static final boolean DEBUG = false;

    /**
     * Enables concurrent message queue implementation in all applications.
     *
     * @hide
     */
    @ChangeId
    @EnabledAfter(targetSdkVersion = android.os.Build.VERSION_CODES.BAKLAVA)
    @Overridable // Can be overridden on user builds
    public static final long USE_NEW_MESSAGEQUEUE = 421623328L;

    // True if the message queue can be quit.
    @UnsupportedAppUsage
    private final boolean mQuitAllowed;
@@ -165,6 +181,9 @@ public final class MessageQueue {
    }

    private static boolean computeUseConcurrent() {
        if (CompatChanges.isChangeEnabled(USE_NEW_MESSAGEQUEUE)) {
            return true;
        }
        if (Flags.useConcurrentMessageQueueInApps()) {
            // b/379472827: Robolectric tests use reflection to access MessageQueue.mMessages.
            // This is a hack to allow Robolectric tests to use the legacy implementation.