diff --git a/services/bluetooth/src/bluetooth_connection.cpp b/services/bluetooth/src/bluetooth_connection.cpp index 83c6cd8daa41a1e75dd1ae3d5b1a29f83a7921e4..df9fd317e6496d4ef4eec6d1114cc6686f913b6e 100644 --- a/services/bluetooth/src/bluetooth_connection.cpp +++ b/services/bluetooth/src/bluetooth_connection.cpp @@ -14,7 +14,7 @@ */ #include "bluetooth_connection.h" - +#include "bluetooth_call_connection.h" #include "audio_control_manager.h" #include "bluetooth_call_manager.h" #include "telephony_log_wrapper.h" @@ -280,7 +280,7 @@ void SystemAbilityListener::OnRemoveSystemAbility(int32_t systemAbilityId, const TELEPHONY_LOGE("removed SA is not bluetooth service, ignored."); return; } - + DelayedSingleton::GetInstance()->HfpDisConnectedEndBtCall(); DelayedSingleton::GetInstance()->ResetBtConnection(); std::shared_ptr audioDeviceManager = DelayedSingleton::GetInstance(); audioDeviceManager->ResetBtAudioDevicesList(); diff --git a/services/telephony_interaction/src/bluetooth_call_connection.cpp b/services/telephony_interaction/src/bluetooth_call_connection.cpp index 74a8c4f9df26da6ed9ecc1dbfa596787b02e0bad..de979278ab0b344e3142acc2f3f90a856b0ad80f 100644 --- a/services/telephony_interaction/src/bluetooth_call_connection.cpp +++ b/services/telephony_interaction/src/bluetooth_call_connection.cpp @@ -154,27 +154,29 @@ bool BluetoothCallConnection::GetBtCallScoConnected() void BluetoothCallConnection::HfpDisConnectedEndBtCall() { - sptr call = CallObjectManager::GetOneCallObject(CallRunningState::CALL_RUNNING_STATE_DIALING); - if (call == nullptr || call->GetCallType() != CallType::TYPE_BLUETOOTH) { - return; - } - TELEPHONY_LOGW("When BluetoothCall dialing Hfp is disconnected."); - CallAttributeInfo info; - (void)memset_s(&info, sizeof(CallAttributeInfo), 0, sizeof(CallAttributeInfo)); - call->GetCallAttributeBaseInfo(info); - CallDetailInfo detailInfo; - detailInfo.callType = info.callType; - detailInfo.accountId = info.accountId; - detailInfo.index = info.index; - detailInfo.state = TelCallState::CALL_STATUS_DISCONNECTED; - (void)memcpy_s(detailInfo.phoneNum, kMaxNumberLen, info.accountNumber, kMaxNumberLen); - (void)memset_s(detailInfo.bundleName, kMaxBundleNameLen + 1, 0, kMaxBundleNameLen + 1); - int32_t ret = DelayedSingleton::GetInstance()->UpdateCallReportInfo(detailInfo); - if (ret != TELEPHONY_SUCCESS) { - TELEPHONY_LOGE("UpdateCallReportInfo failed! errCode:%{public}d", ret); - } else { - TELEPHONY_LOGW("UpdateCallReportInfo success! state:%{public}d, index:%{public}d", - detailInfo.state, detailInfo.index); + TELEPHONY_LOGI("hfp disconnected, hangup all bt call."); + std::list> allCallList = CallObjectManager::GetAllCallList(); + for (auto call : allCallList) { + if (call == nullptr || call->GetCallType() != CallType::TYPE_BLUETOOTH) { + continue; + } + CallAttributeInfo info; + (void)memset_s(&info, sizeof(CallAttributeInfo), 0, sizeof(CallAttributeInfo)); + call->GetCallAttributeBaseInfo(info); + CallDetailInfo detailInfo; + detailInfo.callType = info.callType; + detailInfo.accountId = info.accountId; + detailInfo.index = call->GetCallIndex(); + detailInfo.state = TelCallState::CALL_STATUS_DISCONNECTED; + (void)memcpy_s(detailInfo.phoneNum, kMaxNumberLen, info.accountNumber, kMaxNumberLen); + (void)memset_s(detailInfo.bundleName, kMaxBundleNameLen + 1, 0, kMaxBundleNameLen + 1); + int32_t ret = DelayedSingleton::GetInstance()->UpdateCallReportInfo(detailInfo); + if (ret != TELEPHONY_SUCCESS) { + TELEPHONY_LOGE("UpdateCallReportInfo failed! errCode:%{public}d", ret); + } else { + TELEPHONY_LOGI("UpdateCallReportInfo success! state:%{public}d, index:%{public}d", + detailInfo.state, detailInfo.index); + } } }