OSDN Git Service

Interface to check for deferred messages
authorRavindra Thattahalli Javaraiah <c_rthat@codeaurora.org>
Tue, 23 Aug 2016 14:56:59 +0000 (20:26 +0530)
committerRavindra <c_rthat@codeaurora.org>
Fri, 26 Aug 2016 13:31:24 +0000 (19:01 +0530)
Adding new inerface to check for deferred messages with a matching object.

Change-Id: Id518ec2ccdc9b27fc073b7ec8bcaa6b285190ede
CRs-Fixed: 1049393

core/java/com/android/internal/util/StateMachine.java

index 39fd36b..e93d911 100644 (file)
@@ -1922,6 +1922,22 @@ public class StateMachine {
     }
 
     /**
+     * Check if there are any pending messages with code 'what' in deferred messages queue.
+     */
+    protected final boolean hasDeferredMessages(int what, Object obj) {
+        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) && (msg.obj == obj)) 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.
      */