android4.2 bluetooth蓝牙HFP/HSP/A2DP

HFP/HSP:

JniCallbacks 回调AdapterState.stateChangeCallback,当状态时BT_STATE_ON,则自动连接Headset A2dp

if (status == AbstractionLayer.BT_STATE_ON) {

            // We should have got the property change for adapter and remote devices.

            sendMessage(ENABLED_READY);

继而transitionTo(mOnState),在OnState enter 里连接HeadsetA2DP,

      public void enter() {

            infoLog("Entering On State");

            mAdapterService.autoConnect();

        }

AdapterState:

public void autoConnect(){

      …

         if (isQuietModeEnabled() == false) {

            if (DBG) debugLog( "Initiate auto connection on BT on...");

             autoConnectHeadset();

             autoConnectA2dp();

         }

      …

    }

 

 

切换蓝牙通道:

电话接听时,如果是从其他方式切换到蓝牙,则需要重新连接HFP/A2DP,

直接调用函数connectBluetoothAudio()/disconnectBluetoothAudio()来实现切换蓝牙通道,

如果蓝牙已经连接上了,则不做任何操作。

case BLUETOOTH:

                // If already connected to BT, there's nothing to do here.

                if (isBluetoothAvailable() && !isBluetoothAudioConnected()) {

                    if (PhoneUtils.isSpeakerOn(this)) {

                        PhoneUtils.turnOnSpeaker(this, false, true);

                    }

                    connectBluetoothAudio();

                }

                break;

函数调用:

|――connectBluetoothAudio

       |――mBluetoothHeadset.connectAudio()

              |――mService.connectAudio()

                     |――HeadsetService.connectAudio()

                     |――mStateMachine.sendMessage(HeadsetStateMachine

                            .CONNECT_AUDIO);

                            |――connectHfpNative(getByteAddress(device))

                            |――HeadsetStateMachine.connectAudioNative

                                   (getByteAddress(mCurrentDevice))

A2DP:

在设置界面进行A2DP业务的连接时,函数调用流程如下:

BluetoothDevicePreference(    onClick() / connect()   )配对

CachedBluetoothDevice.connect()---->

CachedBluetoothDevice. connectWithoutResettingTimer()---->

connectInt()---->

profile.connect(mDevice)

这时的profileLocalBluetoothProfile,由其子类A2DProfile实现connect方法

A2dpProfile(   connect()   ) ---->

BluetoothA2DP(   connect()   ) ---->

AdapterService$BluetoothA2dpBinder (  connect()  ) ---->

A2dpStateMachine  ( connectA2dpNative() )

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
│ ANP_SPEC_V10.pdf │ ANS_SPEC_V10.pdf │ AVRCP_SPEC_V14r00.pdf │ BAS_SPEC_V10 (2).pdf │ BLP_V10r00.pdf │ BLS_V10r00.pdf │ CPP_V10.pdf │ CPS_V10.pdf │ CSCP_SPEC_V10.pdf │ CSCS_SPEC_V10.pdf │ CTS_SPEC_V10.pdf │ DIS_SPEC_V11r00.pdf │ FMP_SPEC_V10.pdf │ GLP_SPEC_V10.pdf │ GLS_SPEC_V10.pdf │ GOEP_SPEC_V1.1.pdf │ HIDS_SPEC_V10.pdf │ HOGP_SPEC_V10.pdf │ HRP_V10.pdf │ HRS_SPEC_V10.pdf │ HTP_V10.pdf │ HTS V10.pdf │ IAS_SPEC_V10.pdf │ LLS_SPEC_V10.pdf │ LNP_V10.pdf │ LNS_V10.pdf │ NDCS_SPEC_V10.pdf │ PASP_SPEC_V10.pdf │ PASS_SPEC_V10.pdf │ PXP_SPEC_V10.pdf │ RSCP_SPEC_V10.pdf │ RSCS_SPEC_V10.pdf │ RTUS_SPEC_V10.pdf │ ScPP_SPEC_V10.pdf │ ScPS_SPEC_V10.pdf │ TIP_SPEC_V10.pdf │ TPS_SPEC_V10.pdf │ tree.txt │ ├─3DSP=3D Synchronization Profile │ 3DS_SPEC_V10.pdf │ 3DS_SPEC_V101.pdf │ ├─A2DP=Advanced Audio Distribution Profile │ A2DP spec v10.pdf │ A2DP_SPEC_V12.pdf │ A2DP_SPEC_V13.pdf │ ├─AVCTP=AV Control Transport (Qualifiable) │ AVCTP Spec v1_0.pdf │ AVCTP_SPEC_V12.pdf │ AVCTP_SPEC_V13r00.pdf │ AVCTP_SPEC_V14.pdf │ ├─AVDTP=AV Distribution Transport (Qualifiable) │ AVDTP Spec v10.pdf │ AVDTP_SPEC_V12.pdf │ AVDTP_SPEC_V13.pdf │ ├─AVRCP=AV Remote Control Profile │ AVRCP Spec v10.pdf │ AVRCP_SPEC_V13.pdf │ AVRCP_SPEC_V14r00.pdf │ AVRCP_SPEC_V15.pdf │ ├─BIP=Basic Imaging Profile │ BIP_Spec_1_0_Final_a_2003_07_25.pdf │ BIP_SPEC_V11r00.pdf │ BIP_SPEC_V12.pdf │ ├─BNEP=Bluetooth Network Encapsulation Protocol (Qualifiable) │ BNEP Specification.pdf │ ├─BPP=Basic Printing Profile │ BPP_SPEC_V10.pdf │ BPP_SPEC_V12r00.pdf │ ├─Core │ Core v2.0 + EDR.pdf │ Core_V2.1+EDR.pdf │ Core_V3.0 + HS.pdf │ Core_V4.0.pdf │ Core_v4.1.pdf │ ├─DI=Device ID Profile │ DeviceID_SPEC_V13.pdf │ DI_SPEC_V12r00.pdf │ ├─DUN=Dial-Up Networking Profile │ DUN_SPEC_V12.pdf │

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值