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

Commit 49b28db6 authored by Mark Fasheh's avatar Mark Fasheh
Browse files

MessageHeap.peek() should check heapIndex before removing a message

Also quitting message no longer needs to manually set heapIndex.

Bug: 421623328
Flag: EXEMPT - bugfix
Test: atest MessageQueueTest
Change-Id: I70ab0904748c46a05e94c40af5999ac6fba50756
parent bf6437d4
Loading
Loading
Loading
Loading
+6 −6
Original line number Original line Diff line number Diff line
@@ -87,8 +87,6 @@ public final class MessageStack {
        Message quittingMsg = Message.obtain();
        Message quittingMsg = Message.obtain();
        quittingMsg.obj = QUITTING_NODE_OBJ;
        quittingMsg.obj = QUITTING_NODE_OBJ;
        quittingMsg.when = when;
        quittingMsg.when = when;
        /* Should never go into the heap, initialize idx to an impossible value */
        quittingMsg.heapIndex = -1;
        final boolean ret = pushMessage(quittingMsg);
        final boolean ret = pushMessage(quittingMsg);
        if (!ret) {
        if (!ret) {
            quittingMsg.recycleUnchecked();
            quittingMsg.recycleUnchecked();
@@ -334,6 +332,7 @@ public final class MessageStack {
            if (!m.isRemoved()) {
            if (!m.isRemoved()) {
                return m;
                return m;
            }
            }
            if (m.heapIndex >= 0) {
                if (async) {
                if (async) {
                    mAsyncHeap.removeMessage(m);
                    mAsyncHeap.removeMessage(m);
                } else {
                } else {
@@ -341,6 +340,7 @@ public final class MessageStack {
                }
                }
            }
            }
        }
        }
    }


    /**
    /**
     * Remove the input Message.
     * Remove the input Message.