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