From 8ed715e31e4be65b4bc752a2d230a21adce2bb3a Mon Sep 17 00:00:00 2001 From: Amit Mahajan Date: Tue, 3 Nov 2015 10:06:03 -0800 Subject: Adding StateMachine.hasMessages(), StateMachine.hasDeferredMessages() Bug: 23067429 Change-Id: Ia66fd1a6ff248520e86f6e502767b22c4d9d4814 --- .../com/android/internal/util/StateMachine.java | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/core/java/com/android/internal/util/StateMachine.java b/core/java/com/android/internal/util/StateMachine.java index 447292c9f357..be78a129aada 100644 --- a/core/java/com/android/internal/util/StateMachine.java +++ b/core/java/com/android/internal/util/StateMachine.java @@ -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 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}. -- cgit v1.2.3-59-g8ed1b