您的位置:首页 > 其它

建立通话,如何连接蓝牙耳机SCO

2013-01-18 16:01 399 查看
1)通话之前,ACL是连接好的。在PoneApp里用了bluetoothhandfree这个类.在onCreate方法中,定义了bluetoothhandfree的对象,并把CM的信息传给了bluetoothhandfree类里。

if (BluetoothAdapter.getDefaultAdapter() != null) {

// Start BluetoothHandsree even if device is not voice capable.

// The device can still support VOIP.

mBtHandsfree = BluetoothHandsfree.init(this, mCM);

startService(new Intent(this, BluetoothHeadsetService.class));

} else {

// Device is not bluetooth capable

mBtHandsfree = null;

}

2)有电话被激活时,PhoneApp收到由PhoneProxy发送的intent ACTION_RADIO_TECHNOLOGY_CHANGED.

else if (action.equals(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED)) {

String newPhone = intent.getStringExtra(Phone.PHONE_NAME_KEY);

Log.d(LOG_TAG, "Radio technology switched. Now " + newPhone + " is active.");

initForNewRadioTechnology();

}

3)在initForNewRadioTechnology私有方法中

if (mBtHandsfree != null) {

mBtHandsfree.updateBtHandsfreeAfterRadioTechnologyChange();

}当RadioTechnology有变化时,交由bluetoothhandfree处理;

4)BluetoothHandfree处理:

void updateBtHandsfreeAfterRadioTechnologyChange() {

if (VDBG) Log.d(TAG, "updateBtHandsfreeAfterRadioTechnologyChange...");

mBluetoothPhoneState.updateBtPhoneStateAfterRadioTechnologyChange();

}

mBluetoothPhoneState.updateBtPhoneStateAfterRadioTechnologyChange()的处理:

//Register all events new to the new active phone

mCM.getDefaultPhone().registerForServiceStateChanged(mStateChangeHandler,SERVICE_STATE_CHANGED, null);

mCM.registerForPreciseCallStateChanged(mStateChangeHandler,PRECISE_CALL_STATE_CHANGED, null);

mCM.registerForCallWaiting(mStateChangeHandler,PHONE_CDMA_CALL_WAITING, null);

5)BluetoothHandfree处理注册的消息,在有变化时;

handlePreciseCallStateChange,这个方法将处理响铃和通话和蓝牙相关的东西,包括连接SCO,用AudioManager设置声音通道等。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: