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

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

Address API Review feedback for TestLooperManager pop/peekWhen

Bug: 382637408
Change-Id: Ie55b6811c78ef84602140c756112288185ad0257
Flag: android.os.message_queue_testability
parent 7bc6fd64
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -34768,7 +34768,7 @@ package android.os {
    method @FlaggedApi("android.os.message_queue_testability") public boolean isBlockedOnSyncBarrier();
    method public android.os.Message next();
    method @FlaggedApi("android.os.message_queue_testability") @Nullable public Long peekWhen();
    method @FlaggedApi("android.os.message_queue_testability") @Nullable public android.os.Message pop();
    method @FlaggedApi("android.os.message_queue_testability") @Nullable public android.os.Message poll();
    method public void recycle(android.os.Message);
    method public void release();
  }
+4 −4
Original line number Diff line number Diff line
@@ -1272,7 +1272,7 @@ public final class MessageQueue {
        return true;
    }

    private Message legacyPeekOrPop(boolean peek) {
    private Message legacyPeekOrPoll(boolean peek) {
        synchronized (this) {
            // Try to retrieve the next message.  Return if found.
            final long now = SystemClock.uptimeMillis();
@@ -1331,7 +1331,7 @@ public final class MessageQueue {
        if (mUseConcurrent) {
            ret = nextMessage(true);
        } else {
            ret = legacyPeekOrPop(true);
            ret = legacyPeekOrPoll(true);
        }
        return ret != null ? ret.when : null;
    }
@@ -1344,12 +1344,12 @@ public final class MessageQueue {
     */
    @SuppressLint("VisiblySynchronized") // Legacy MessageQueue synchronizes on this
    @Nullable
    Message popForTest() {
    Message pollForTest() {
        throwIfNotTest();
        if (mUseConcurrent) {
            return nextMessage(false);
        } else {
            return legacyPeekOrPop(false);
            return legacyPeekOrPoll(false);
        }
    }

+1 −1
Original line number Diff line number Diff line
@@ -1102,7 +1102,7 @@ public final class MessageQueue {
     */
    @SuppressLint("VisiblySynchronized") // Legacy MessageQueue synchronizes on this
    @Nullable
    Message popForTest() {
    Message pollForTest() {
        throwIfNotTest();
        return nextMessage(false);
    }
+4 −4
Original line number Diff line number Diff line
@@ -740,7 +740,7 @@ public final class MessageQueue {
        return true;
    }

    private Message legacyPeekOrPop(boolean peek) {
    private Message legacyPeekOrPoll(boolean peek) {
        synchronized (this) {
            // Try to retrieve the next message.  Return if found.
            final long now = SystemClock.uptimeMillis();
@@ -795,7 +795,7 @@ public final class MessageQueue {
    @SuppressLint("VisiblySynchronized") // Legacy MessageQueue synchronizes on this
    Long peekWhenForTest() {
        throwIfNotTest();
        Message ret = legacyPeekOrPop(true);
        Message ret = legacyPeekOrPoll(true);
        return ret != null ? ret.when : null;
    }

@@ -807,9 +807,9 @@ public final class MessageQueue {
     */
    @SuppressLint("VisiblySynchronized") // Legacy MessageQueue synchronizes on this
    @Nullable
    Message popForTest() {
    Message pollForTest() {
        throwIfNotTest();
        return legacyPeekOrPop(false);
        return legacyPeekOrPoll(false);
    }

    /**
+10 −6
Original line number Diff line number Diff line
@@ -95,8 +95,8 @@ public class TestLooperManager {
    }

    /**
     * Returns the next message that should be executed by this queue, and removes it from the
     * queue. If the queue is empty or no messages are deliverable, returns null.
     * Retrieves and removes the next message that should be executed by this queue.
     * If the queue is empty or no messages are deliverable, returns null.
     * This method never blocks.
     *
     * <p>Callers should always call {@link #recycle(Message)} on the message when all interactions
@@ -104,15 +104,19 @@ public class TestLooperManager {
     */
    @FlaggedApi(Flags.FLAG_MESSAGE_QUEUE_TESTABILITY)
    @Nullable
    public Message pop() {
    public Message poll() {
        checkReleased();
        return mQueue.popForTest();
        return mQueue.pollForTest();
    }

    /**
     * Returns the values of {@link Message#when} of the next message that should be executed by
     * this queue. If the queue is empty or no messages are deliverable, returns null.
     * Retrieves, but does not remove, the values of {@link Message#when} of next message that
     * should be executed by this queue.
     * If the queue is empty or no messages are deliverable, returns null.
     * This method never blocks.
     *
     * <p>Callers should always call {@link #recycle(Message)} on the message when all interactions
     * with it have completed.
     */
    @FlaggedApi(Flags.FLAG_MESSAGE_QUEUE_TESTABILITY)
    @SuppressWarnings("AutoBoxing")  // box the primitive long, or return null to indicate no value