/** Start the state machine. */
  public void start() {
    // mSmHandler can be null if the state machine has quit.
    if (mSmHandler == null) return;

    /** Send the complete construction message */
    mSmHandler.completeConstruction();
  }
  /** Enqueue a message to this state machine after a delay. */
  public final void sendMessageDelayed(Message msg, long delayMillis) {
    // mSmHandler can be null if the state machine has quit.
    if (mSmHandler == null) return;

    mSmHandler.sendMessageDelayed(msg, delayMillis);
  }
  /** Enqueue a message to this state machine after a delay. */
  public final void sendMessageDelayed(int what, Object obj, long delayMillis) {
    // mSmHandler can be null if the state machine has quit.
    if (mSmHandler == null) return;

    mSmHandler.sendMessageDelayed(obtainMessage(what, obj), delayMillis);
  }
  /** Enqueue a message to this state machine. */
  public final void sendMessage(Message msg) {
    // mSmHandler can be null if the state machine has quit.
    if (mSmHandler == null) return;

    mSmHandler.sendMessage(msg);
  }
 /** @return current message */
 protected final Message getCurrentMessage() {
   return mSmHandler.getCurrentMessage();
 }
  /**
   * Set debug enable/disabled.
   *
   * @param dbg is true to enable debugging.
   */
  public void setDbg(boolean dbg) {
    // mSmHandler can be null if the state machine has quit.
    if (mSmHandler == null) return;

    mSmHandler.setDbg(dbg);
  }
 /** @return ture if msg is quit */
 protected final boolean isQuit(Message msg) {
   return mSmHandler.isQuit(msg);
 }
 /**
  * Removes a message from the message queue. Protected, may only be called by instances of
  * StateMachine.
  */
 protected final void removeMessages(int what) {
   mSmHandler.removeMessages(what);
 }
 /**
  * Defer this message until next state transition. Upon transitioning all deferred messages will
  * be placed on the queue and reprocessed in the original order. (i.e. The next state the oldest
  * messages will be processed first)
  *
  * @param msg is deferred until the next transition.
  */
 protected final void deferMessage(Message msg) {
   mSmHandler.deferMessage(msg);
 }
 /**
  * transition to halt state. Upon returning from processMessage we will exit all current states,
  * execute the halting() method and then all subsequent messages haltedProcessMesage will be
  * called.
  */
 protected final void transitionToHaltingState() {
   mSmHandler.transitionTo(mSmHandler.mHaltingState);
 }
 /**
  * transition to destination state. Upon returning from processMessage the current state's exit
  * will be executed and upon the next message arriving destState.enter will be invoked.
  *
  * <p>this function can also be called inside the enter function of the previous transition
  * target, but the behavior is undefined when it is called mid-way through a previous transition
  * (for example, calling this in the enter() routine of a intermediate node when the current
  * transition target is one of the nodes descendants).
  *
  * @param destState will be the state that receives the next message.
  */
 protected final void transitionTo(IState destState) {
   mSmHandler.transitionTo(destState);
 }
 /**
  * Set the initial state. This must be invoked before and messages are sent to the state machine.
  *
  * @param initialState is the state which will receive the first message.
  */
 protected final void setInitialState(State initialState) {
   mSmHandler.setInitialState(initialState);
 }
 /**
  * Add a new state to the state machine, parent will be null
  *
  * @param state to add
  */
 protected final void addState(State state) {
   mSmHandler.addState(state, null);
 }
 /** @return current state */
 protected final IState getCurrentState() {
   return mSmHandler.getCurrentState();
 }
 /**
  * Enqueue a message to the front of the queue for this state machine. Protected, may only be
  * called by instances of StateMachine.
  */
 protected final void sendMessageAtFrontOfQueue(int what) {
   mSmHandler.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.
  */
 protected final void sendMessageAtFrontOfQueue(Message msg) {
   mSmHandler.sendMessageAtFrontOfQueue(msg);
 }
 /**
  * Set size of messages to maintain and clears all current messages.
  *
  * @param maxSize number of messages to maintain at anyone time.
  */
 public final void setProcessedMessagesSize(int maxSize) {
   mSmHandler.setProcessedMessagesSize(maxSize);
 }
  /**
   * Conditionally quit the looper and stop execution.
   *
   * <p>This sends the SM_QUIT_MSG to the state machine and if not handled by any state's
   * processMessage then the state machine will be stopped and no further messages will be
   * processed.
   */
  public final void quit() {
    // mSmHandler can be null if the state machine has quit.
    if (mSmHandler == null) return;

    mSmHandler.quit();
  }
 /** @return the total number of messages processed */
 public final int getProcessedMessagesCount() {
   return mSmHandler.getProcessedMessagesCount();
 }
  /** @return if debugging is enabled */
  public boolean isDbg() {
    // mSmHandler can be null if the state machine has quit.
    if (mSmHandler == null) return false;

    return mSmHandler.isDbg();
  }
 /** @return a processed message information */
 public final ProcessedMessageInfo getProcessedMessageInfo(int index) {
   return mSmHandler.getProcessedMessageInfo(index);
 }
  /** Enqueue a message to this state machine. */
  public final void sendMessage(int what, Object obj) {
    // mSmHandler can be null if the state machine has quit.
    if (mSmHandler == null) return;

    mSmHandler.sendMessage(obtainMessage(what, obj));
  }
 /**
  * Add a new state to the state machine
  *
  * @param state the state to add
  * @param parent the parent of state
  */
 protected final void addState(State state, State parent) {
   mSmHandler.addState(state, parent);
 }