微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 手机设计讨论 > MTK手机平台交流 > mt6735 通话由BT耳机优先改成后插优先

mt6735 通话由BT耳机优先改成后插优先

时间:10-02 整理:3721RD 点击:
[DESCRIPTION]
默认情况下,由于BT耳机的优先级>有线耳机,所以不论先连接BT耳机再插入有线耳机或者先插入有线耳机后连接BT耳机,通话声音都从BT耳机中出来。
如果希望客制化成后插优先,请参考此下面 solution.
[SOLUTION]
请参考//mtkadd+++和//mtkadd---之间代码

----------------------------------------JB版本参考如下----------------------------------------
1.AudioService.java
private void onSetWiredDeviceConnectionState(int device, int state, String name)
{
......
if ((state == 0) && ((device == AudioSystem.DEVICE_OUT_WIRED_HEADSET) ||
(device == AudioSystem.DEVICE_OUT_WIRED_HEADPHONE))) {
......
if (shouldNotify) {
setbluetoothA2dpOnInt(true);
//mtkadd+++
if ((mMode == AudioSystem.MODE_IN_CALL) || (mMode == AudioSystem.MODE_IN_CALL_2) ||
(mMode == AudioSystem.MODE_IN_CALL_EXTERNAL)) {
setBluetoothScoOn(true);
}
//mtkadd---
}
if (state != 0) {
if ((device == AudioSystem.DEVICE_OUT_WIRED_HEADSET) ||
(device == AudioSystem.DEVICE_OUT_WIRED_HEADPHONE)) {
/// M: safe media @{
mHeadsetOrHeadphoneOn = true;
/// @}
setBluetoothA2dpOnInt(false);
//mtkadd+++
setBluetoothScoOn(false);
//mtkadd---
}

2.InCallScreen.java
public void switchInCallAudio(InCallAudioMode newMode) {
......
case BLUETOOTH:
// If already connected to BT, there's nothing to do here.
//mtkadd+++
//if (isBluetoothAvailable() && !isBluetoothAudioConnected()) {
if (isBluetoothAvailable()) {
//mtkadd---
// Manually turn the speaker phone off, instead of allowing the
// Bluetooth audio routing to handle it, since there's other
// important state-updating that needs to happen in the
// PhoneUtils.turnOnSpeaker() method.
// (SIMilarly, whenever the user turns *on* the speaker, we
// manually disconnect the active bluetooth headset;
// see toggleSpeaker() and/or switchInCallAudio().)
if (PhoneUtils.isSpeakerOn(this)) {
PhoneUtils.turnOnSpeaker(this, false, true);
}
//mtkadd+++
disconnectBluetoothAudio();
//mtkadd---
connectBluetoothAudio();
}
break;

3.InCalltouchUi.java
位置1:import android.media.AudioManager;
位置2:
private void updateAudioButton(InCallControlState inCallControlState) {
......
//mtkadd+++
AudioManager mAudioManager = null;
if (getContext() != null) {
mAudioManager = (AudioManager) getContext().getSystEMService(Context.AUDIO_SERVICE);
}
//mtkadd---
if (inCallControlState.bluetoothEnabled) {
......
//mtkadd+++
//if (inCallControlState.bluetoothIndicatorOn) {
if (mAudioManager != null && mAudioManager.isBluetoothScoOn()) {
//mtkadd---
showBluetoothIcon = true;
} else if (inCallControlState.speakerOn) {
showSpeakerOnIcon = true;
} else {

----------------------------------------KK版本参考如下----------------------------------------
1.AudioService.java
private void onSetWiredDeviceConnectionState(int device, int state, String name)
{
......
if ((state == 0) && ((device == AudioSystem.DEVICE_OUT_WIRED_HEADSET) ||
(device == AudioSystem.DEVICE_OUT_WIRED_HEADPHONE))) {
......
if (shouldNotify) {
setBluetoothA2dpOnInt(true);
//mtkadd+++
if ((mMode == AudioSystem.MODE_IN_CALL) || (mMode == AudioSystem.MODE_IN_CALL_2) ||
(mMode == AudioSystem.MODE_IN_CALL_EXTERNAL)) {
setBluetoothScoOn(true);
}
//mtkadd---
}
if (state != 0) {
if ((device == AudioSystem.DEVICE_OUT_WIRED_HEADSET) ||
(device == AudioSystem.DEVICE_OUT_WIRED_HEADPHONE)) {
/// M: safe media @{
mHeadsetOrHeadphoneOn = true;
/// @}
setBluetoothA2dpOnInt(false);
//mtkadd+++
setBluetoothScoOn(false);
//mtkadd---
}

2.AudioRouter.java
位置1:import android.media.AudioManager;
位置2:
private boolean turnOnOffBluetooth(boolean onOff) {
if (mBluetoothManager.isBluetoothAvailable()) {
final boolean isAlreadyOn = mBluetoothManager.isBluetoothAudioConnected();
//mtkadd+++
AudioManager mAudioManager = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
if (onOff){
mAudioManager.setBluetoothScoOn(true);
}
//mtkadd---
if (onOff && !isAlreadyOn) {
mBluetoothManager.connectBluetoothAudio();
} else if (!onOff && isAlreadyOn) {
mBluetoothManager.disconnectBluetoothAudio();
}
}
位置3:
private void updateAudioModeTo(int mode) {
......
mPreviousMode = mAudioMode;
mAudioMode = mode;
//mtkadd+++
if (AudioMode.BLUETOOTH == mode){
doNotify = true;
}
//mtkadd---
if (doNotify) {
notifyListeners();
}
}

3.CallButtonFragment.java
位置1:import android.media.AudioManager;
位置2:
private void updateAudioButtons(int supportedModes) {
......
//mtkadd+++
AudioManager mAudioManager = null;
if (getContext() != null) {
mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
}
//mtkadd---
if (bluetoothSupported) {
Log.d(this, "updateAudioButtons - popup menu mode");
......
//mtkadd+++
//if (isAudio(AudioMode.BLUETOOTH)) {
if (mAudioManager != null && mAudioManager.isBluetoothScoOn()) {
//mtkadd---
showBluetoothIcon = true;
} else if (isAudio(AudioMode.SPEAKER)) {
showSpeakerphoneOnIcon = true;
} else {

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top