31-Android之修改蓝牙断开后的音频切换
Android10 MTK_6739
话机项目, 在话柄放下的时候. 蓝牙通话, 如果把蓝牙突然断开, 音频需要切换到免提, 而不是听筒
vendor/mediatek/proprietary/packages/services/Telecomm/src/com/android/server/telecom/CallAudioRouteStateMachine.java
private int calculateBaselineRouteMessage(boolean isExplicitUserRequest,
boolean includeBluetooth) {
boolean isSkipEarpiece = false;
if (!isExplicitUserRequest) {
synchronized (mLock) {
// Check video calls to skip earpiece since the baseline for video
// calls should be the speakerphone route
isSkipEarpiece = mCallsManager.hasVideoCall();
}
}
if ((mAvailableRoutes & ROUTE_BLUETOOTH) != 0
&& !mHasUserExplicitlyLeftBluetooth
&& includeBluetooth
/// M: ALPS03945922, Cannot switch to bluetooth route if no HFP device @{
&& mBluetoothRouteManager.hasBtActiveDevice()) {
/// @}
return isExplicitUserRequest ? USER_SWITCH_BLUETOOTH : SWITCH_BLUETOOTH;
} else if ((mAvailableRoutes & ROUTE_EARPIECE) != 0 && !isSkipEarpiece && !isHandDown(mContext)) { // TODO
return isExplicitUserRequest ? USER_SWITCH_EARPIECE : SWITCH_EARPIECE;
} else if ((mAvailableRoutes & ROUTE_WIRED_HEADSET) != 0) {
return isExplicitUserRequest ? USER_SWITCH_HEADSET : SWITCH_HEADSET;
} else {
return isExplicitUserRequest ? USER_SWITCH_SPEAKER : SWITCH_SPEAKER;
}
}
public static boolean isHandDown(Context context) {
return Settings.System.getInt(context.getContentResolver(), Settings.IS_HAND_DOWN, 1) == 1;
}