同学,别退出呀,我可是全网最牛逼的 Android 蓝牙分析博主,我写了上百篇蓝牙文章,请点击下面了解本专栏,进入本博主主页看看再走呗,一定不会让你后悔的,记得一定要去看主页置顶文章哦。
文章基于android 11流程
一、切换设备
当audio连接完成后,发送广播:BluetoothHeadset.ACTION_AUDIO_STATE_CHANGED
此时继续auido_service接收到,再转给BtHelper.java处理。
audioOn->setBluetoothScoOn->setForceUse(FOR_RECORD, FORCE_BT_SCO)
/frameworks/base/services/core/java/com/android/server/audio/BtHelper.java
synchronized void receiveBtEvent(Intent intent) {
296 final String action = intent.getAction();
297
298 Log.i(TAG, "receiveBtEvent action: " + action + " mScoAudioState: " + mScoAudioState);
299 if (action.equals(BluetoothHeadset.ACTION_ACTIVE_DEVICE_CHANGED)) {
300 BluetoothDevice btDevice