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

Commit 2a8c23fc authored by Brett Chabot's avatar Brett Chabot
Browse files

Return times in future in peekWhenForTest.

Previously peekWhenForTest only returns a value if when <= current time.
This contradicts the spec for TestLooperManager#peekWhen.

Flag: android.os.message_queue_testability
Bug: 112000181
Test: atest TestLooperManagerTest
Change-Id: Ic3dcb2b9c0230786ca33245debae2bb4b549abc1
parent a51dcf16
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ import android.util.Printer;
import android.util.SparseArray;
import android.util.proto.ProtoOutputStream;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.ravenwood.RavenwoodEnvironment;

import dalvik.annotation.optimization.NeverCompile;
@@ -1286,12 +1285,12 @@ public final class MessageQueue {
                } while (msg != null && !msg.isAsynchronous());
            }
            if (msg != null) {
                if (now >= msg.when) {
                    // Got a message.
                    mBlocked = false;
                if (peek) {
                    return msg;
                }
                if (now >= msg.when) {
                    // Got a message.
                    mBlocked = false;
                    if (prevMsg != null) {
                        prevMsg.next = msg.next;
                        if (prevMsg.next == null) {
+3 −4
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package android.os;

import android.annotation.FlaggedApi;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -754,12 +753,12 @@ public final class MessageQueue {
                } while (msg != null && !msg.isAsynchronous());
            }
            if (msg != null) {
                if (now >= msg.when) {
                    // Got a message.
                    mBlocked = false;
                if (peek) {
                    return msg;
                }
                if (now >= msg.when) {
                    // Got a message.
                    mBlocked = false;
                    if (prevMsg != null) {
                        prevMsg.next = msg.next;
                        if (prevMsg.next == null) {