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

Commit 0dfeda60 authored by Amit Mahajan's avatar Amit Mahajan Committed by android-build-merger
Browse files

Merge "Adding StateMachine.hasMessages(), StateMachine.hasDeferredMessages()"...

Merge "Adding StateMachine.hasMessages(), StateMachine.hasDeferredMessages()" into mnc-dr1.5-dev am: cd2cc9aa
am: d515b124

* commit 'd515b124':
  Adding StateMachine.hasMessages(), StateMachine.hasDeferredMessages()
parents bfa2be0f d515b124
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -1878,6 +1878,33 @@ public class StateMachine {
        }
    }

    /**
     * Check if there are any pending messages with code 'what' in deferred messages queue.
     */
    protected final boolean hasDeferredMessages(int what) {
        SmHandler smh = mSmHandler;
        if (smh == null) return false;

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

        return false;
    }

    /**
     * Check if there are any pending posts of messages with code 'what' in
     * the message queue. This does NOT check messages in deferred message queue.
     */
    protected final boolean hasMessages(int what) {
        SmHandler smh = mSmHandler;
        if (smh == null) return false;

        return smh.hasMessages(what);
    }

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