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

Commit c03251d4 authored by Ajay Panicker's avatar Ajay Panicker Committed by The Android Automerger
Browse files

Add StateMachine.removeDeferredMessages()

Bug: 23111466
Change-Id: Ifbb67d4eb080313af0968d5cb6b9508837e3458e
parent b5427b57
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Iterator;
import java.util.HashMap;
import java.util.Vector;

@@ -1863,6 +1864,20 @@ public class StateMachine {
        smh.removeMessages(what);
    }

    /**
     * Removes a message from the deferred messages queue.
     */
    protected final void removeDeferredMessages(int what) {
        SmHandler smh = mSmHandler;
        if (smh == null) return;

        Iterator<Message> iterator = smh.mDeferredMessages.iterator();
        while (iterator.hasNext()) {
            Message msg = iterator.next();
            if (msg.what == what) iterator.remove();
        }
    }

    /**
     * Validate that the message was sent by
     * {@link StateMachine#quit} or {@link StateMachine#quitNow}.