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

Commit c0dfab9f authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add ChangeId for new message queue" into main

parents ba9f8e73 b5f3968a
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.