stateMachine状态转换流程(transitionTo)

stateMachine状态转换流程

/packages/apps/Bluetooth/src/com/android/bluetooth/pbapclient/PbapClientStateMachine.java
351    public void disconnect(BluetoothDevice device) {
   
352        Log.d(TAG, "Disconnect Request " + device);
353        sendMessage(MSG_DISCONNECT, device);
354    }
/frameworks/base/core/java/com/android/internal/util/StateMachine.java
1713    /**
1714     * Enqueue a message to this state machine.
1715     *
1716     * Message is ignored if state machine has quit.
1717     */
1718    public void sendMessage(int what, Object obj) {
   
1719        // mSmHandler can be null if the state machine has quit.
1720        SmHandler smh = mSmHandler;
1721        if (smh == null) return;
1722
1723        smh.sendMessage(obtainMessage(what, obj)); // private static class SmHandler extends Handler
1724    }
/frameworks/base/core/java/android/os/Handler.java
593    /**
594     * Pushes a message onto the end of the message queue after all pending messages
595     * before the current time. It will be received in {@link #handleMessage},
596     * in the thread attached to this handler.
597     *
598     * @return Returns true if the message was successfully placed in to the
599     *         message queue.  Returns false on failure, usually because the
600     *         looper processing the message queue is exiting.
601     */
602    public final boolean sendMessage(Message msg)
603    {
   
604        return sendMessageDelayed(msg, 0);
605    }
/frameworks/base/core/java/com/android/internal/util/StateMachine.java
787        /**
788         * Handle messages sent to the state machine by calling
789         * the current state's processMessage. It also handles
790         * the enter/exit calls and placing any deferred messages
791         * back onto the queue when transitioning to a new state.
792         */
793        @Override
794        public final void handleMessage(Message msg) {
   
795            if (!mHasQuit) {
   
796                if (mSm != null && msg.what != SM_INIT_CMD && msg.what != SM_QUIT_CMD) {
   
797                    mSm.onPreHandleMessage(msg);
798                }
799
800                if (mDbg) mSm.log("handleMessage: E msg.what=" + msg.what);
801
802                /** Save the current message */
803                mMsg = msg;
804
805                /** State that processed the message */
806                State msgProcessedState = null;
807                if (mIsConstructionCompleted || (mMsg.what == SM_QUIT_CMD)) {
   
808                    
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值