1d95e75fdSopenharmony_ci/* 2d95e75fdSopenharmony_ci * Copyright (C) 2021-2022 Huawei Device Co., Ltd. 3d95e75fdSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4d95e75fdSopenharmony_ci * you may not use this file except in compliance with the License. 5d95e75fdSopenharmony_ci * You may obtain a copy of the License at 6d95e75fdSopenharmony_ci * 7d95e75fdSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8d95e75fdSopenharmony_ci * 9d95e75fdSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10d95e75fdSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11d95e75fdSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12d95e75fdSopenharmony_ci * See the License for the specific language governing permissions and 13d95e75fdSopenharmony_ci * limitations under the License. 14d95e75fdSopenharmony_ci */ 15d95e75fdSopenharmony_ci 16d95e75fdSopenharmony_ci#include "cellular_call_register.h" 17d95e75fdSopenharmony_ci 18d95e75fdSopenharmony_ci#include "cellular_call_hisysevent.h" 19d95e75fdSopenharmony_ci#include "core_manager_inner.h" 20d95e75fdSopenharmony_ci#include "hitrace_meter.h" 21d95e75fdSopenharmony_ci#include "iservice_registry.h" 22d95e75fdSopenharmony_ci 23d95e75fdSopenharmony_cinamespace OHOS { 24d95e75fdSopenharmony_cinamespace Telephony { 25d95e75fdSopenharmony_ciconstexpr size_t CHAR_LENG = 1; 26d95e75fdSopenharmony_ci 27d95e75fdSopenharmony_ciCellularCallRegister::CellularCallRegister() : callManagerCallBack_(nullptr) {} 28d95e75fdSopenharmony_ci 29d95e75fdSopenharmony_ciCellularCallRegister::~CellularCallRegister() {} 30d95e75fdSopenharmony_ci 31d95e75fdSopenharmony_civoid CellularCallRegister::ReportCallsInfo(const CallsReportInfo &callsReportInfo) 32d95e75fdSopenharmony_ci{ 33d95e75fdSopenharmony_ci TELEPHONY_LOGD("ReportCallsInfo entry."); 34d95e75fdSopenharmony_ci CallsReportInfo callsInfo = callsReportInfo; 35d95e75fdSopenharmony_ci CallDetailInfo detailInfo; 36d95e75fdSopenharmony_ci detailInfo.state = TelCallState::CALL_STATUS_UNKNOWN; 37d95e75fdSopenharmony_ci std::vector<CallReportInfo>::iterator it = callsInfo.callVec.begin(); 38d95e75fdSopenharmony_ci for (; it != callsInfo.callVec.end(); ++it) { 39d95e75fdSopenharmony_ci detailInfo.callType = (*it).callType; 40d95e75fdSopenharmony_ci detailInfo.accountId = (*it).accountId; 41d95e75fdSopenharmony_ci detailInfo.state = (*it).state; 42d95e75fdSopenharmony_ci detailInfo.callMode = (*it).callMode; 43d95e75fdSopenharmony_ci } 44d95e75fdSopenharmony_ci 45d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 46d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 47d95e75fdSopenharmony_ci TELEPHONY_LOGE("ReportCallsInfo return, callManagerCallBack_ is nullptr, report fail!"); 48d95e75fdSopenharmony_ci if (detailInfo.state == TelCallState::CALL_STATUS_INCOMING) { 49d95e75fdSopenharmony_ci FinishAsyncTrace(HITRACE_TAG_OHOS, "CellularCallIncoming", getpid()); 50d95e75fdSopenharmony_ci } 51d95e75fdSopenharmony_ci return; 52d95e75fdSopenharmony_ci } 53d95e75fdSopenharmony_ci CoreManagerInner::GetInstance().NotifyCallStatusToNetworkSearch( 54d95e75fdSopenharmony_ci detailInfo.accountId, static_cast<int32_t>(detailInfo.state)); 55d95e75fdSopenharmony_ci if (detailInfo.state == TelCallState::CALL_STATUS_INCOMING) { 56d95e75fdSopenharmony_ci DelayedSingleton<CellularCallHiSysEvent>::GetInstance()->SetIncomingCallParameterInfo( 57d95e75fdSopenharmony_ci static_cast<int32_t>(detailInfo.callType), static_cast<int32_t>(detailInfo.callMode)); 58d95e75fdSopenharmony_ci FinishAsyncTrace(HITRACE_TAG_OHOS, "CellularCallIncoming", getpid()); 59d95e75fdSopenharmony_ci } 60d95e75fdSopenharmony_ci callManagerCallBack_->UpdateCallsReportInfo(callsReportInfo); 61d95e75fdSopenharmony_ci} 62d95e75fdSopenharmony_ci 63d95e75fdSopenharmony_ciint32_t CellularCallRegister::RegisterCallManagerCallBack(const sptr<ICallStatusCallback> &callback) 64d95e75fdSopenharmony_ci{ 65d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 66d95e75fdSopenharmony_ci TELEPHONY_LOGI("CellularCallRegister::RegisterCallManagerCallBack"); 67d95e75fdSopenharmony_ci callManagerCallBack_ = callback; 68d95e75fdSopenharmony_ci return TELEPHONY_SUCCESS; 69d95e75fdSopenharmony_ci} 70d95e75fdSopenharmony_ci 71d95e75fdSopenharmony_civoid CellularCallRegister::ReportSingleCallInfo(const CallReportInfo &info, TelCallState callState) 72d95e75fdSopenharmony_ci{ 73d95e75fdSopenharmony_ci TELEPHONY_LOGD("ReportSingleCallInfo entry"); 74d95e75fdSopenharmony_ci CallReportInfo cellularCallReportInfo = info; 75d95e75fdSopenharmony_ci cellularCallReportInfo.state = callState; 76d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 77d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 78d95e75fdSopenharmony_ci TELEPHONY_LOGE("ReportSingleCallInfo return, callManagerCallBack_ is nullptr, report fail!"); 79d95e75fdSopenharmony_ci return; 80d95e75fdSopenharmony_ci } 81d95e75fdSopenharmony_ci callManagerCallBack_->UpdateCallReportInfo(cellularCallReportInfo); 82d95e75fdSopenharmony_ci} 83d95e75fdSopenharmony_ci 84d95e75fdSopenharmony_ciint32_t CellularCallRegister::UnRegisterCallManagerCallBack() 85d95e75fdSopenharmony_ci{ 86d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 87d95e75fdSopenharmony_ci TELEPHONY_LOGI("CellularCallRegister::UnRegisterCallManagerCallBack"); 88d95e75fdSopenharmony_ci callManagerCallBack_ = nullptr; 89d95e75fdSopenharmony_ci return TELEPHONY_SUCCESS; 90d95e75fdSopenharmony_ci} 91d95e75fdSopenharmony_ci 92d95e75fdSopenharmony_civoid CellularCallRegister::ReportEventResultInfo(const CellularCallEventInfo &info) 93d95e75fdSopenharmony_ci{ 94d95e75fdSopenharmony_ci TELEPHONY_LOGI("ReportEventResultInfo entry eventId:%{public}d", info.eventId); 95d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 96d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 97d95e75fdSopenharmony_ci TELEPHONY_LOGE("ReportEventResultInfo return, callManagerCallBack_ is nullptr, report fail!"); 98d95e75fdSopenharmony_ci return; 99d95e75fdSopenharmony_ci } 100d95e75fdSopenharmony_ci callManagerCallBack_->UpdateEventResultInfo(info); 101d95e75fdSopenharmony_ci} 102d95e75fdSopenharmony_ci 103d95e75fdSopenharmony_civoid CellularCallRegister::ReportGetWaitingResult(const CallWaitResponse &response) 104d95e75fdSopenharmony_ci{ 105d95e75fdSopenharmony_ci TELEPHONY_LOGI("ReportGetWaitingResult result:%{public}d, status:%{public}d, class:%{public}d", response.result, 106d95e75fdSopenharmony_ci response.status, response.classCw); 107d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 108d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 109d95e75fdSopenharmony_ci TELEPHONY_LOGE("ReportGetWaitingResult return, callManagerCallBack_ is nullptr, report fail!"); 110d95e75fdSopenharmony_ci return; 111d95e75fdSopenharmony_ci } 112d95e75fdSopenharmony_ci callManagerCallBack_->UpdateGetWaitingResult(response); 113d95e75fdSopenharmony_ci} 114d95e75fdSopenharmony_ci 115d95e75fdSopenharmony_civoid CellularCallRegister::ReportSetWaitingResult(int32_t result) 116d95e75fdSopenharmony_ci{ 117d95e75fdSopenharmony_ci TELEPHONY_LOGI("ReportSetWaitingResult result:%{public}d", result); 118d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 119d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 120d95e75fdSopenharmony_ci TELEPHONY_LOGE("ReportSetWaitingResult return, callManagerCallBack_ is nullptr, report fail!"); 121d95e75fdSopenharmony_ci return; 122d95e75fdSopenharmony_ci } 123d95e75fdSopenharmony_ci callManagerCallBack_->UpdateSetWaitingResult(result); 124d95e75fdSopenharmony_ci} 125d95e75fdSopenharmony_ci 126d95e75fdSopenharmony_civoid CellularCallRegister::ReportGetRestrictionResult(const CallRestrictionResponse &response) 127d95e75fdSopenharmony_ci{ 128d95e75fdSopenharmony_ci TELEPHONY_LOGI("ReportGetRestrictionResult result:%{public}d, status:%{public}d, class:%{public}d", 129d95e75fdSopenharmony_ci response.result, response.status, response.classCw); 130d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 131d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 132d95e75fdSopenharmony_ci TELEPHONY_LOGE("ReportGetRestrictionResult return, callManagerCallBack_ is nullptr, report fail!"); 133d95e75fdSopenharmony_ci return; 134d95e75fdSopenharmony_ci } 135d95e75fdSopenharmony_ci callManagerCallBack_->UpdateGetRestrictionResult(response); 136d95e75fdSopenharmony_ci} 137d95e75fdSopenharmony_ci 138d95e75fdSopenharmony_civoid CellularCallRegister::ReportSetRestrictionResult(int32_t result) 139d95e75fdSopenharmony_ci{ 140d95e75fdSopenharmony_ci TELEPHONY_LOGI("ReportSetRestrictionResult result:%{public}d", result); 141d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 142d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 143d95e75fdSopenharmony_ci TELEPHONY_LOGE("ReportSetRestrictionResult return, callManagerCallBack_ is nullptr, report fail!"); 144d95e75fdSopenharmony_ci return; 145d95e75fdSopenharmony_ci } 146d95e75fdSopenharmony_ci callManagerCallBack_->UpdateSetRestrictionResult(result); 147d95e75fdSopenharmony_ci} 148d95e75fdSopenharmony_ci 149d95e75fdSopenharmony_civoid CellularCallRegister::ReportGetTransferResult(const CallTransferResponse &response) 150d95e75fdSopenharmony_ci{ 151d95e75fdSopenharmony_ci TELEPHONY_LOGI("ReportGetTransferResult result:%{public}d, status:%{public}d, class:%{public}d", response.result, 152d95e75fdSopenharmony_ci response.status, response.classx); 153d95e75fdSopenharmony_ci TELEPHONY_LOGI("ReportGetTransferResult type:%{public}d, reason:%{public}d, time:%{public}d", 154d95e75fdSopenharmony_ci response.type, response.reason, response.time); 155d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 156d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 157d95e75fdSopenharmony_ci TELEPHONY_LOGE("ReportGetTransferResult return, callManagerCallBack_ is nullptr, report fail!"); 158d95e75fdSopenharmony_ci return; 159d95e75fdSopenharmony_ci } 160d95e75fdSopenharmony_ci callManagerCallBack_->UpdateGetTransferResult(response); 161d95e75fdSopenharmony_ci} 162d95e75fdSopenharmony_ci 163d95e75fdSopenharmony_civoid CellularCallRegister::ReportSetBarringPasswordResult(int32_t result) 164d95e75fdSopenharmony_ci{ 165d95e75fdSopenharmony_ci TELEPHONY_LOGI("Set barring password result:%{public}d", result); 166d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 167d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 168d95e75fdSopenharmony_ci TELEPHONY_LOGE("callManagerCallBack_ is nullptr, report fail!"); 169d95e75fdSopenharmony_ci return; 170d95e75fdSopenharmony_ci } 171d95e75fdSopenharmony_ci callManagerCallBack_->UpdateSetRestrictionPasswordResult(result); 172d95e75fdSopenharmony_ci} 173d95e75fdSopenharmony_ci 174d95e75fdSopenharmony_civoid CellularCallRegister::ReportSetTransferResult(int32_t result) 175d95e75fdSopenharmony_ci{ 176d95e75fdSopenharmony_ci TELEPHONY_LOGI("ReportSetTransferResult result:%{public}d", result); 177d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 178d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 179d95e75fdSopenharmony_ci TELEPHONY_LOGE("ReportSetTransferResult return, callManagerCallBack_ is nullptr, report fail!"); 180d95e75fdSopenharmony_ci return; 181d95e75fdSopenharmony_ci } 182d95e75fdSopenharmony_ci callManagerCallBack_->UpdateSetTransferResult(result); 183d95e75fdSopenharmony_ci} 184d95e75fdSopenharmony_ci 185d95e75fdSopenharmony_civoid CellularCallRegister::ReportGetClipResult(const ClipResponse &response) 186d95e75fdSopenharmony_ci{ 187d95e75fdSopenharmony_ci TELEPHONY_LOGI("ReportGetClipResult result:%{public}d, action:%{public}d, stat:%{public}d", response.result, 188d95e75fdSopenharmony_ci response.action, response.clipStat); 189d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 190d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 191d95e75fdSopenharmony_ci TELEPHONY_LOGE("ReportGetClipResult return, callManagerCallBack_ is nullptr, report fail!"); 192d95e75fdSopenharmony_ci return; 193d95e75fdSopenharmony_ci } 194d95e75fdSopenharmony_ci callManagerCallBack_->UpdateGetCallClipResult(response); 195d95e75fdSopenharmony_ci} 196d95e75fdSopenharmony_ci 197d95e75fdSopenharmony_civoid CellularCallRegister::ReportGetClirResult(const ClirResponse &response) 198d95e75fdSopenharmony_ci{ 199d95e75fdSopenharmony_ci TELEPHONY_LOGI("ReportGetClirResult result:%{public}d, action:%{public}d, stat:%{public}d", response.result, 200d95e75fdSopenharmony_ci response.action, response.clirStat); 201d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 202d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 203d95e75fdSopenharmony_ci TELEPHONY_LOGE("ReportGetClirResult return, callManagerCallBack_ is nullptr, report fail!"); 204d95e75fdSopenharmony_ci return; 205d95e75fdSopenharmony_ci } 206d95e75fdSopenharmony_ci callManagerCallBack_->UpdateGetCallClirResult(response); 207d95e75fdSopenharmony_ci} 208d95e75fdSopenharmony_ci 209d95e75fdSopenharmony_civoid CellularCallRegister::ReportSetClirResult(int32_t result) 210d95e75fdSopenharmony_ci{ 211d95e75fdSopenharmony_ci TELEPHONY_LOGI("ReportSetClirResult result:%{public}d", result); 212d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 213d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 214d95e75fdSopenharmony_ci TELEPHONY_LOGE("ReportSetClirResult return, callManagerCallBack_ is nullptr, report fail!"); 215d95e75fdSopenharmony_ci return; 216d95e75fdSopenharmony_ci } 217d95e75fdSopenharmony_ci callManagerCallBack_->UpdateSetCallClirResult(result); 218d95e75fdSopenharmony_ci} 219d95e75fdSopenharmony_ci 220d95e75fdSopenharmony_civoid CellularCallRegister::ReportGetImsConfigResult(const GetImsConfigResponse &response) 221d95e75fdSopenharmony_ci{ 222d95e75fdSopenharmony_ci TELEPHONY_LOGI("ReportGetImsConfigResult entry, value:%{public}d", response.value); 223d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 224d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 225d95e75fdSopenharmony_ci TELEPHONY_LOGE("ReportGetImsConfigResult return, callManagerCallBack_ is nullptr, report fail!"); 226d95e75fdSopenharmony_ci return; 227d95e75fdSopenharmony_ci } 228d95e75fdSopenharmony_ci callManagerCallBack_->GetImsConfigResult(response); 229d95e75fdSopenharmony_ci} 230d95e75fdSopenharmony_ci 231d95e75fdSopenharmony_civoid CellularCallRegister::ReportSetImsConfigResult(int32_t result) 232d95e75fdSopenharmony_ci{ 233d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 234d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 235d95e75fdSopenharmony_ci TELEPHONY_LOGE("ReportSetImsConfigResult return, callManagerCallBack_ is nullptr, report fail!"); 236d95e75fdSopenharmony_ci return; 237d95e75fdSopenharmony_ci } 238d95e75fdSopenharmony_ci callManagerCallBack_->SetImsConfigResult(result); 239d95e75fdSopenharmony_ci} 240d95e75fdSopenharmony_ci 241d95e75fdSopenharmony_civoid CellularCallRegister::ReportSetImsFeatureResult(int32_t result) 242d95e75fdSopenharmony_ci{ 243d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 244d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 245d95e75fdSopenharmony_ci TELEPHONY_LOGE("ReportSetImsFeatureResult return, callManagerCallBack_ is nullptr, report fail!"); 246d95e75fdSopenharmony_ci return; 247d95e75fdSopenharmony_ci } 248d95e75fdSopenharmony_ci callManagerCallBack_->SetImsFeatureValueResult(result); 249d95e75fdSopenharmony_ci} 250d95e75fdSopenharmony_ci 251d95e75fdSopenharmony_civoid CellularCallRegister::ReportGetImsFeatureResult(const GetImsFeatureValueResponse &response) 252d95e75fdSopenharmony_ci{ 253d95e75fdSopenharmony_ci TELEPHONY_LOGI("ReportGetImsFeatureResult entry, value:%{public}d", response.value); 254d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 255d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 256d95e75fdSopenharmony_ci TELEPHONY_LOGE("ReportGetImsFeatureResult return, callManagerCallBack_ is nullptr, report fail!"); 257d95e75fdSopenharmony_ci return; 258d95e75fdSopenharmony_ci } 259d95e75fdSopenharmony_ci callManagerCallBack_->GetImsFeatureValueResult(response); 260d95e75fdSopenharmony_ci} 261d95e75fdSopenharmony_ci 262d95e75fdSopenharmony_civoid CellularCallRegister::ReportCallRingBackResult(int32_t status) 263d95e75fdSopenharmony_ci{ 264d95e75fdSopenharmony_ci TELEPHONY_LOGI("ReportCallRingBackResult entry"); 265d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 266d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 267d95e75fdSopenharmony_ci TELEPHONY_LOGE("ReportCallRingBackResult return, callManagerCallBack_ is nullptr, report fail!"); 268d95e75fdSopenharmony_ci return; 269d95e75fdSopenharmony_ci } 270d95e75fdSopenharmony_ci callManagerCallBack_->UpdateRBTPlayInfo(static_cast<RBTPlayInfo>(status)); 271d95e75fdSopenharmony_ci} 272d95e75fdSopenharmony_ci 273d95e75fdSopenharmony_civoid CellularCallRegister::ReportCallFailReason(const DisconnectedDetails &details) 274d95e75fdSopenharmony_ci{ 275d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 276d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 277d95e75fdSopenharmony_ci TELEPHONY_LOGE("ReportCallFailReason return, callManagerCallBack_ is nullptr, report fail!"); 278d95e75fdSopenharmony_ci return; 279d95e75fdSopenharmony_ci } 280d95e75fdSopenharmony_ci callManagerCallBack_->UpdateDisconnectedCause(details); 281d95e75fdSopenharmony_ci} 282d95e75fdSopenharmony_ci 283d95e75fdSopenharmony_civoid CellularCallRegister::ReportGetMuteResult(const MuteControlResponse &response) 284d95e75fdSopenharmony_ci{ 285d95e75fdSopenharmony_ci TELEPHONY_LOGI("ReportGetMuteResult entry result:%{public}d, value:%{public}d", response.result, response.value); 286d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 287d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 288d95e75fdSopenharmony_ci TELEPHONY_LOGE("ReportMuteResult return, callManagerCallBack_ is nullptr, report fail!"); 289d95e75fdSopenharmony_ci return; 290d95e75fdSopenharmony_ci } 291d95e75fdSopenharmony_ci} 292d95e75fdSopenharmony_ci 293d95e75fdSopenharmony_civoid CellularCallRegister::ReportSetMuteResult(const MuteControlResponse &response) 294d95e75fdSopenharmony_ci{ 295d95e75fdSopenharmony_ci TELEPHONY_LOGI("ReportSetMuteResult entry result:%{public}d, value:%{public}d", response.result, response.value); 296d95e75fdSopenharmony_ci} 297d95e75fdSopenharmony_ci 298d95e75fdSopenharmony_civoid CellularCallRegister::ReportInviteToConferenceResult(int32_t result) 299d95e75fdSopenharmony_ci{ 300d95e75fdSopenharmony_ci TELEPHONY_LOGI("ReportInviteToConferenceResult entry result:%{public}d", result); 301d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 302d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 303d95e75fdSopenharmony_ci TELEPHONY_LOGE("ReportInviteToConferenceResult return, callManagerCallBack_ is nullptr, report fail!"); 304d95e75fdSopenharmony_ci return; 305d95e75fdSopenharmony_ci } 306d95e75fdSopenharmony_ci callManagerCallBack_->InviteToConferenceResult(result); 307d95e75fdSopenharmony_ci} 308d95e75fdSopenharmony_ci 309d95e75fdSopenharmony_civoid CellularCallRegister::ReportGetCallDataResult(int32_t result) 310d95e75fdSopenharmony_ci{ 311d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 312d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 313d95e75fdSopenharmony_ci TELEPHONY_LOGE("ReportGetCallDataResult return, callManagerCallBack_ is nullptr, report fail!"); 314d95e75fdSopenharmony_ci return; 315d95e75fdSopenharmony_ci } 316d95e75fdSopenharmony_ci callManagerCallBack_->GetImsCallDataResult(result); 317d95e75fdSopenharmony_ci} 318d95e75fdSopenharmony_ci 319d95e75fdSopenharmony_civoid CellularCallRegister::ReportStartDtmfResult(int32_t result) 320d95e75fdSopenharmony_ci{ 321d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 322d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 323d95e75fdSopenharmony_ci TELEPHONY_LOGE("ReportStartDtmfResult return, callManagerCallBack_ is nullptr, report fail!"); 324d95e75fdSopenharmony_ci return; 325d95e75fdSopenharmony_ci } 326d95e75fdSopenharmony_ci callManagerCallBack_->StartDtmfResult(result); 327d95e75fdSopenharmony_ci} 328d95e75fdSopenharmony_ci 329d95e75fdSopenharmony_civoid CellularCallRegister::ReportStopDtmfResult(int32_t result) 330d95e75fdSopenharmony_ci{ 331d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 332d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 333d95e75fdSopenharmony_ci TELEPHONY_LOGE("ReportStopDtmfResult return, callManagerCallBack_ is nullptr, report fail!"); 334d95e75fdSopenharmony_ci return; 335d95e75fdSopenharmony_ci } 336d95e75fdSopenharmony_ci callManagerCallBack_->StopDtmfResult(result); 337d95e75fdSopenharmony_ci} 338d95e75fdSopenharmony_ci 339d95e75fdSopenharmony_civoid CellularCallRegister::ReportStartRttResult(int32_t result) 340d95e75fdSopenharmony_ci{ 341d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 342d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 343d95e75fdSopenharmony_ci TELEPHONY_LOGE("ReportStartRttResult return, callManagerCallBack_ is nullptr, report fail!"); 344d95e75fdSopenharmony_ci return; 345d95e75fdSopenharmony_ci } 346d95e75fdSopenharmony_ci callManagerCallBack_->StartRttResult(result); 347d95e75fdSopenharmony_ci} 348d95e75fdSopenharmony_ci 349d95e75fdSopenharmony_civoid CellularCallRegister::ReportStopRttResult(int32_t result) 350d95e75fdSopenharmony_ci{ 351d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 352d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 353d95e75fdSopenharmony_ci TELEPHONY_LOGE("ReportStopRttResult return, callManagerCallBack_ is nullptr, report fail!"); 354d95e75fdSopenharmony_ci return; 355d95e75fdSopenharmony_ci } 356d95e75fdSopenharmony_ci callManagerCallBack_->StopRttResult(result); 357d95e75fdSopenharmony_ci} 358d95e75fdSopenharmony_ci 359d95e75fdSopenharmony_civoid CellularCallRegister::ReportSendUssdResult(int32_t result) 360d95e75fdSopenharmony_ci{ 361d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 362d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 363d95e75fdSopenharmony_ci TELEPHONY_LOGE("ReportSendUssdResult return, callManagerCallBack_ is nullptr, report fail!"); 364d95e75fdSopenharmony_ci return; 365d95e75fdSopenharmony_ci } 366d95e75fdSopenharmony_ci callManagerCallBack_->SendUssdResult(result); 367d95e75fdSopenharmony_ci} 368d95e75fdSopenharmony_ci 369d95e75fdSopenharmony_civoid CellularCallRegister::ReportMmiCodeResult(const MmiCodeInfo &info) 370d95e75fdSopenharmony_ci{ 371d95e75fdSopenharmony_ci TELEPHONY_LOGI("ReportMmiCodeResult entry result:%{public}d, value:%{public}s", info.result, info.message); 372d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 373d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 374d95e75fdSopenharmony_ci TELEPHONY_LOGE("ReportMmiCodeResult return, callManagerCallBack_ is nullptr, report fail!"); 375d95e75fdSopenharmony_ci return; 376d95e75fdSopenharmony_ci } 377d95e75fdSopenharmony_ci callManagerCallBack_->SendMmiCodeResult(info); 378d95e75fdSopenharmony_ci} 379d95e75fdSopenharmony_ci 380d95e75fdSopenharmony_civoid CellularCallRegister::ReportSetEmergencyCallListResponse(const SetEccListResponse &response) 381d95e75fdSopenharmony_ci{ 382d95e75fdSopenharmony_ci TELEPHONY_LOGD("ReportSetEmergencyCallListResponse entry result:%{public}d, value:%{public}d", response.result, 383d95e75fdSopenharmony_ci response.value); 384d95e75fdSopenharmony_ci} 385d95e75fdSopenharmony_ci 386d95e75fdSopenharmony_cibool CellularCallRegister::IsCallManagerCallBackRegistered() 387d95e75fdSopenharmony_ci{ 388d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 389d95e75fdSopenharmony_ci return callManagerCallBack_ != nullptr; 390d95e75fdSopenharmony_ci} 391d95e75fdSopenharmony_ci 392d95e75fdSopenharmony_civoid CellularCallRegister::ReportCloseUnFinishedUssdResult(int32_t result) 393d95e75fdSopenharmony_ci{ 394d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 395d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 396d95e75fdSopenharmony_ci TELEPHONY_LOGE("ReportCloseUnFinishedUssdResult return, callManagerCallBack_ is nullptr, report fail!"); 397d95e75fdSopenharmony_ci return; 398d95e75fdSopenharmony_ci } 399d95e75fdSopenharmony_ci callManagerCallBack_->CloseUnFinishedUssdResult(result); 400d95e75fdSopenharmony_ci} 401d95e75fdSopenharmony_ci 402d95e75fdSopenharmony_civoid CellularCallRegister::ReportPostDialChar(char c) 403d95e75fdSopenharmony_ci{ 404d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 405d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 406d95e75fdSopenharmony_ci TELEPHONY_LOGE("ReportPostDialChar return, callManagerCallBack_ is nullptr, report fail!"); 407d95e75fdSopenharmony_ci return; 408d95e75fdSopenharmony_ci } 409d95e75fdSopenharmony_ci std::string nextDtmf(CHAR_LENG, c); 410d95e75fdSopenharmony_ci callManagerCallBack_->ReportPostDialChar(nextDtmf); 411d95e75fdSopenharmony_ci} 412d95e75fdSopenharmony_ci 413d95e75fdSopenharmony_civoid CellularCallRegister::ReportPostDialDelay(std::string str) 414d95e75fdSopenharmony_ci{ 415d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 416d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 417d95e75fdSopenharmony_ci TELEPHONY_LOGE("ReportPostDialChar return, callManagerCallBack_ is nullptr, report fail!"); 418d95e75fdSopenharmony_ci return; 419d95e75fdSopenharmony_ci } 420d95e75fdSopenharmony_ci callManagerCallBack_->ReportPostDialDelay(str); 421d95e75fdSopenharmony_ci} 422d95e75fdSopenharmony_ci 423d95e75fdSopenharmony_civoid CellularCallRegister::ReceiveUpdateCallMediaModeRequest(int32_t slotId, ImsCallModeReceiveInfo &callModeInfo) 424d95e75fdSopenharmony_ci{ 425d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 426d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 427d95e75fdSopenharmony_ci TELEPHONY_LOGE("ReceiveUpdateCallMediaModeRequest return, callManagerCallBack_ is nullptr, report fail!"); 428d95e75fdSopenharmony_ci return; 429d95e75fdSopenharmony_ci } 430d95e75fdSopenharmony_ci CallModeReportInfo response; 431d95e75fdSopenharmony_ci response.callIndex = callModeInfo.callIndex; 432d95e75fdSopenharmony_ci response.result = static_cast<VideoRequestResultType>(callModeInfo.result); 433d95e75fdSopenharmony_ci response.slotId = slotId; 434d95e75fdSopenharmony_ci ImsCallMode callMode = ConverToImsCallMode(callModeInfo.callType); 435d95e75fdSopenharmony_ci response.callMode = callMode; 436d95e75fdSopenharmony_ci callManagerCallBack_->ReceiveUpdateCallMediaModeRequest(response); 437d95e75fdSopenharmony_ci} 438d95e75fdSopenharmony_ci 439d95e75fdSopenharmony_civoid CellularCallRegister::ReceiveUpdateCallMediaModeResponse(int32_t slotId, ImsCallModeReceiveInfo &callModeInfo) 440d95e75fdSopenharmony_ci{ 441d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 442d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 443d95e75fdSopenharmony_ci TELEPHONY_LOGE("ReceiveUpdateCallMediaModeResponse return, callManagerCallBack_ is nullptr, report fail!"); 444d95e75fdSopenharmony_ci return; 445d95e75fdSopenharmony_ci } 446d95e75fdSopenharmony_ci CallModeReportInfo response; 447d95e75fdSopenharmony_ci response.callIndex = callModeInfo.callIndex; 448d95e75fdSopenharmony_ci response.result = static_cast<VideoRequestResultType>(callModeInfo.result); 449d95e75fdSopenharmony_ci ImsCallMode callMode = ConverToImsCallMode(callModeInfo.callType); 450d95e75fdSopenharmony_ci response.callMode = callMode; 451d95e75fdSopenharmony_ci response.slotId = slotId; 452d95e75fdSopenharmony_ci callManagerCallBack_->ReceiveUpdateCallMediaModeResponse(response); 453d95e75fdSopenharmony_ci} 454d95e75fdSopenharmony_ci 455d95e75fdSopenharmony_civoid CellularCallRegister::HandleCallSessionEventChanged(ImsCallSessionEventInfo &callSessionEventInfo) 456d95e75fdSopenharmony_ci{ 457d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 458d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 459d95e75fdSopenharmony_ci TELEPHONY_LOGE("HandleCallSessionEventChanged return, callManagerCallBack_ is nullptr, report fail!"); 460d95e75fdSopenharmony_ci return; 461d95e75fdSopenharmony_ci } 462d95e75fdSopenharmony_ci CallSessionReportInfo response; 463d95e75fdSopenharmony_ci response.index = callSessionEventInfo.callIndex; 464d95e75fdSopenharmony_ci response.eventId = static_cast<CallSessionEventId>(callSessionEventInfo.eventType); 465d95e75fdSopenharmony_ci callManagerCallBack_->HandleCallSessionEventChanged(response); 466d95e75fdSopenharmony_ci} 467d95e75fdSopenharmony_ci 468d95e75fdSopenharmony_civoid CellularCallRegister::HandlePeerDimensionsChanged(ImsCallPeerDimensionsInfo &callPeerDimensionsInfo) 469d95e75fdSopenharmony_ci{ 470d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 471d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 472d95e75fdSopenharmony_ci TELEPHONY_LOGE("HandlePeerDimensionsChanged return, callManagerCallBack_ is nullptr, report fail!"); 473d95e75fdSopenharmony_ci return; 474d95e75fdSopenharmony_ci } 475d95e75fdSopenharmony_ci PeerDimensionsReportInfo response; 476d95e75fdSopenharmony_ci response.index = callPeerDimensionsInfo.callIndex; 477d95e75fdSopenharmony_ci response.width = callPeerDimensionsInfo.width; 478d95e75fdSopenharmony_ci response.height = callPeerDimensionsInfo.height; 479d95e75fdSopenharmony_ci callManagerCallBack_->HandlePeerDimensionsChanged(response); 480d95e75fdSopenharmony_ci} 481d95e75fdSopenharmony_ci 482d95e75fdSopenharmony_civoid CellularCallRegister::HandleCallDataUsageChanged(ImsCallDataUsageInfo &callDataUsageInfo) 483d95e75fdSopenharmony_ci{ 484d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 485d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 486d95e75fdSopenharmony_ci TELEPHONY_LOGE("HandleCallDataUsageChanged return, callManagerCallBack_ is nullptr, report fail!"); 487d95e75fdSopenharmony_ci return; 488d95e75fdSopenharmony_ci } 489d95e75fdSopenharmony_ci int64_t response = callDataUsageInfo.dataUsage; 490d95e75fdSopenharmony_ci callManagerCallBack_->HandleCallDataUsageChanged(response); 491d95e75fdSopenharmony_ci} 492d95e75fdSopenharmony_ci 493d95e75fdSopenharmony_civoid CellularCallRegister::HandleCameraCapabilitiesChanged(CameraCapabilitiesInfo &cameraCapabilitiesInfo) 494d95e75fdSopenharmony_ci{ 495d95e75fdSopenharmony_ci std::lock_guard<std::mutex> lock(mutex_); 496d95e75fdSopenharmony_ci if (callManagerCallBack_ == nullptr) { 497d95e75fdSopenharmony_ci TELEPHONY_LOGE("HandleCameraCapabilitiesChanged return, callManagerCallBack_ is nullptr, report fail!"); 498d95e75fdSopenharmony_ci return; 499d95e75fdSopenharmony_ci } 500d95e75fdSopenharmony_ci CameraCapabilitiesReportInfo response; 501d95e75fdSopenharmony_ci response.index = cameraCapabilitiesInfo.callIndex; 502d95e75fdSopenharmony_ci response.width = cameraCapabilitiesInfo.width; 503d95e75fdSopenharmony_ci response.height = cameraCapabilitiesInfo.height; 504d95e75fdSopenharmony_ci callManagerCallBack_->HandleCameraCapabilitiesChanged(response); 505d95e75fdSopenharmony_ci} 506d95e75fdSopenharmony_ci 507d95e75fdSopenharmony_ciImsCallMode CellularCallRegister::ConverToImsCallMode(ImsCallType callType) 508d95e75fdSopenharmony_ci{ 509d95e75fdSopenharmony_ci ImsCallMode callMode = ImsCallMode::CALL_MODE_AUDIO_ONLY; 510d95e75fdSopenharmony_ci switch (callType) { 511d95e75fdSopenharmony_ci case ImsCallType::TEL_IMS_CALL_TYPE_VOICE: 512d95e75fdSopenharmony_ci callMode = ImsCallMode::CALL_MODE_AUDIO_ONLY; 513d95e75fdSopenharmony_ci break; 514d95e75fdSopenharmony_ci case ImsCallType::TEL_IMS_CALL_TYPE_VT_TX: 515d95e75fdSopenharmony_ci callMode = ImsCallMode::CALL_MODE_SEND_ONLY; 516d95e75fdSopenharmony_ci break; 517d95e75fdSopenharmony_ci case ImsCallType::TEL_IMS_CALL_TYPE_VT_RX: 518d95e75fdSopenharmony_ci callMode = ImsCallMode::CALL_MODE_RECEIVE_ONLY; 519d95e75fdSopenharmony_ci break; 520d95e75fdSopenharmony_ci case ImsCallType::TEL_IMS_CALL_TYPE_VT: 521d95e75fdSopenharmony_ci callMode = ImsCallMode::CALL_MODE_SEND_RECEIVE; 522d95e75fdSopenharmony_ci break; 523d95e75fdSopenharmony_ci case ImsCallType::TEL_IMS_CALL_TYPE_PAUSE: 524d95e75fdSopenharmony_ci callMode = ImsCallMode::CALL_MODE_VIDEO_PAUSED; 525d95e75fdSopenharmony_ci break; 526d95e75fdSopenharmony_ci default: 527d95e75fdSopenharmony_ci TELEPHONY_LOGE("unknown callType"); 528d95e75fdSopenharmony_ci break; 529d95e75fdSopenharmony_ci } 530d95e75fdSopenharmony_ci return callMode; 531d95e75fdSopenharmony_ci} 532d95e75fdSopenharmony_ci} // namespace Telephony 533d95e75fdSopenharmony_ci} // namespace OHOS 534