From c211978650580904a4b11b7c5b899e9d2f7ed294 Mon Sep 17 00:00:00 2001 From: Ajay Panicker Date: Wed, 26 Aug 2015 14:06:34 -0700 Subject: Add StateMachine.removeDeferredMessages() Bug: 23111466 Change-Id: Ifbb67d4eb080313af0968d5cb6b9508837e3458e --- core/java/com/android/internal/util/StateMachine.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/core/java/com/android/internal/util/StateMachine.java b/core/java/com/android/internal/util/StateMachine.java index 916f19d..447292c 100644 --- a/core/java/com/android/internal/util/StateMachine.java +++ b/core/java/com/android/internal/util/StateMachine.java @@ -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; @@ -1864,6 +1865,20 @@ public class StateMachine { } /** + * Removes a message from the deferred messages queue. + */ + protected final void removeDeferredMessages(int what) { + SmHandler smh = mSmHandler; + if (smh == null) return; + + Iterator 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}. * */ -- cgit v1.1