diff --git a/core/java/com/android/internal/util/StateMachine.java b/core/java/com/android/internal/util/StateMachine.java index 58d4aa7199e05..e547f238b770f 100644 --- a/core/java/com/android/internal/util/StateMachine.java +++ b/core/java/com/android/internal/util/StateMachine.java @@ -1601,6 +1601,19 @@ public class StateMachine { smh.sendMessage(obtainMessage(what, obj)); } + /** + * Enqueue a message to this state machine. + * + * Message is ignored if state machine has quit. + */ + public final void sendMessage(int what, int arg1, int arg2, Object obj) { + // mSmHandler can be null if the state machine has quit. + SmHandler smh = mSmHandler; + if (smh == null) return; + + smh.sendMessage(obtainMessage(what, arg1, arg2, obj)); + } + /** * Enqueue a message to this state machine. * @@ -1640,6 +1653,20 @@ public class StateMachine { smh.sendMessageDelayed(obtainMessage(what, obj), delayMillis); } + /** + * Enqueue a message to this state machine after a delay. + * + * Message is ignored if state machine has quit. + */ + public final void sendMessageDelayed(int what, int arg1, int arg2, Object obj, + long delayMillis) { + // mSmHandler can be null if the state machine has quit. + SmHandler smh = mSmHandler; + if (smh == null) return; + + smh.sendMessageDelayed(obtainMessage(what, arg1, arg2, obj), delayMillis); + } + /** * Enqueue a message to this state machine after a delay. * @@ -1681,6 +1708,20 @@ public class StateMachine { smh.sendMessageAtFrontOfQueue(obtainMessage(what)); } + /** + * Enqueue a message to the front of the queue for this state machine. + * Protected, may only be called by instances of StateMachine. + * + * Message is ignored if state machine has quit. + */ + protected final void sendMessageAtFrontOfQueue(int what, int arg1, int arg2, Object obj) { + // mSmHandler can be null if the state machine has quit. + SmHandler smh = mSmHandler; + if (smh == null) return; + + smh.sendMessageAtFrontOfQueue(obtainMessage(what, arg1, arg2, obj)); + } + /** * Enqueue a message to the front of the queue for this state machine. * Protected, may only be called by instances of StateMachine.