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_handler.h"
17
18 #include "cellular_call_config.h"
19 #include "cellular_call_hisysevent.h"
20 #include "cellular_call_service.h"
21 #include "hitrace_meter.h"
22 #include "hril_call_parcel.h"
23 #include "ims_call_client.h"
24 #include "operator_config_types.h"
25 #include "radio_event.h"
26 #include "resource_utils.h"
27
28 namespace OHOS {
29 namespace Telephony {
30 const uint32_t GET_CS_CALL_DATA_ID = 10001;
31 const uint32_t GET_IMS_CALL_DATA_ID = 10002;
32 const uint32_t OPERATOR_CONFIG_CHANGED_ID = 10004;
33 const int64_t DELAY_TIME = 100;
34 const int64_t FAST_DELAY_TIME = 250;
35
CellularCallHandler(const std::shared_ptr<AppExecFwk::EventRunner> & runner,const EventFwk::CommonEventSubscribeInfo & subscriberInfo)36 CellularCallHandler::CellularCallHandler(
37 const std::shared_ptr<AppExecFwk::EventRunner> &runner, const EventFwk::CommonEventSubscribeInfo &subscriberInfo)
38 : AppExecFwk::EventHandler(runner), CommonEventSubscriber(subscriberInfo)
39 {
40 InitBasicFuncMap();
41 InitConfigFuncMap();
42 InitSupplementFuncMap();
43 InitActiveReportFuncMap();
44 }
45
InitBasicFuncMap()46 void CellularCallHandler::InitBasicFuncMap()
47 {
48 requestFuncMap_[RadioEvent::RADIO_DIAL] = &CellularCallHandler::DialResponse;
49 requestFuncMap_[RadioEvent::RADIO_HANGUP_CONNECT] = &CellularCallHandler::CommonResultResponse;
50 requestFuncMap_[RadioEvent::RADIO_REJECT_CALL] = &CellularCallHandler::CommonResultResponse;
51 requestFuncMap_[RadioEvent::RADIO_ACCEPT_CALL] = &CellularCallHandler::CommonResultResponse;
52 requestFuncMap_[RadioEvent::RADIO_HOLD_CALL] = &CellularCallHandler::CommonResultResponse;
53 requestFuncMap_[RadioEvent::RADIO_ACTIVE_CALL] = &CellularCallHandler::CommonResultResponse;
54 requestFuncMap_[RadioEvent::RADIO_SWAP_CALL] = &CellularCallHandler::CommonResultResponse;
55 requestFuncMap_[RadioEvent::RADIO_JOIN_CALL] = &CellularCallHandler::CommonResultResponse;
56 requestFuncMap_[RadioEvent::RADIO_SPLIT_CALL] = &CellularCallHandler::CommonResultResponse;
57 requestFuncMap_[RadioEvent::RADIO_CALL_SUPPLEMENT] = &CellularCallHandler::CommonResultResponse;
58 requestFuncMap_[RadioEvent::RADIO_SEND_DTMF] = &CellularCallHandler::SendDtmfResponse;
59 requestFuncMap_[RadioEvent::RADIO_START_DTMF] = &CellularCallHandler::StartDtmfResponse;
60 requestFuncMap_[RadioEvent::RADIO_STOP_DTMF] = &CellularCallHandler::StopDtmfResponse;
61 requestFuncMap_[RadioEvent::RADIO_CURRENT_CALLS] = &CellularCallHandler::GetCsCallsDataResponse;
62 requestFuncMap_[RadioEvent::RADIO_GET_CALL_FAIL_REASON] = &CellularCallHandler::GetCallFailReasonResponse;
63
64 requestFuncMap_[GET_CS_CALL_DATA_ID] = &CellularCallHandler::GetCsCallsDataRequest;
65 requestFuncMap_[GET_IMS_CALL_DATA_ID] = &CellularCallHandler::GetImsCallsDataRequest;
66 requestFuncMap_[REGISTER_HANDLER_ID] = &CellularCallHandler::RegisterHandler;
67 requestFuncMap_[MMIHandlerId::EVENT_MMI_Id] = &CellularCallHandler::GetMMIResponse;
68
69 requestFuncMap_[RadioEvent::RADIO_IMS_GET_CALL_DATA] = &CellularCallHandler::GetImsCallsDataResponse;
70 }
71
InitConfigFuncMap()72 void CellularCallHandler::InitConfigFuncMap()
73 {
74 requestFuncMap_[RadioEvent::RADIO_SET_CMUT] = &CellularCallHandler::SetMuteResponse;
75 requestFuncMap_[RadioEvent::RADIO_GET_CMUT] = &CellularCallHandler::GetMuteResponse;
76 requestFuncMap_[RadioEvent::RADIO_SET_CALL_PREFERENCE_MODE] = &CellularCallHandler::SetDomainPreferenceModeResponse;
77 requestFuncMap_[RadioEvent::RADIO_GET_CALL_PREFERENCE_MODE] = &CellularCallHandler::GetDomainPreferenceModeResponse;
78 requestFuncMap_[RadioEvent::RADIO_SET_IMS_SWITCH_STATUS] = &CellularCallHandler::SetImsSwitchStatusResponse;
79 requestFuncMap_[RadioEvent::RADIO_GET_IMS_SWITCH_STATUS] = &CellularCallHandler::GetImsSwitchStatusResponse;
80 requestFuncMap_[RadioEvent::RADIO_SET_EMERGENCY_CALL_LIST] = &CellularCallHandler::SetEmergencyCallListResponse;
81 requestFuncMap_[RadioEvent::RADIO_GET_EMERGENCY_CALL_LIST] = &CellularCallHandler::GetEmergencyCallListResponse;
82 requestFuncMap_[OPERATOR_CONFIG_CHANGED_ID] = &CellularCallHandler::HandleOperatorConfigChanged;
83 }
84
InitSupplementFuncMap()85 void CellularCallHandler::InitSupplementFuncMap()
86 {
87 requestFuncMap_[RadioEvent::RADIO_GET_CALL_WAIT] = &CellularCallHandler::GetCallWaitingResponse;
88 requestFuncMap_[RadioEvent::RADIO_SET_CALL_WAIT] = &CellularCallHandler::SetCallWaitingResponse;
89 requestFuncMap_[RadioEvent::RADIO_GET_CALL_FORWARD] = &CellularCallHandler::GetCallTransferResponse;
90 requestFuncMap_[RadioEvent::RADIO_SET_CALL_FORWARD] = &CellularCallHandler::SetCallTransferInfoResponse;
91 requestFuncMap_[RadioEvent::RADIO_GET_CALL_CLIP] = &CellularCallHandler::GetClipResponse;
92 requestFuncMap_[RadioEvent::RADIO_GET_CALL_CLIR] = &CellularCallHandler::GetClirResponse;
93 requestFuncMap_[RadioEvent::RADIO_SET_CALL_CLIR] = &CellularCallHandler::SetClirResponse;
94 requestFuncMap_[RadioEvent::RADIO_GET_CALL_RESTRICTION] = &CellularCallHandler::GetCallRestrictionResponse;
95 requestFuncMap_[RadioEvent::RADIO_SET_CALL_RESTRICTION] = &CellularCallHandler::SetCallRestrictionResponse;
96 requestFuncMap_[RadioEvent::RADIO_SET_USSD] = &CellularCallHandler::SendUssdResponse;
97 requestFuncMap_[MMIHandlerId::EVENT_SET_UNLOCK_PIN_PUK_ID] = &CellularCallHandler::SendUnlockPinPukResponse;
98 }
99
InitActiveReportFuncMap()100 void CellularCallHandler::InitActiveReportFuncMap()
101 {
102 requestFuncMap_[RadioEvent::RADIO_CALL_STATUS_INFO] = &CellularCallHandler::CsCallStatusInfoReport;
103 requestFuncMap_[RadioEvent::RADIO_IMS_CALL_STATUS_INFO] = &CellularCallHandler::ImsCallStatusInfoReport;
104 requestFuncMap_[RadioEvent::RADIO_AVAIL] = &CellularCallHandler::GetCsCallData;
105 requestFuncMap_[RadioEvent::RADIO_NOT_AVAIL] = &CellularCallHandler::GetCsCallData;
106 requestFuncMap_[RadioEvent::RADIO_CALL_USSD_NOTICE] = &CellularCallHandler::UssdNotifyResponse;
107 requestFuncMap_[RadioEvent::RADIO_CALL_RINGBACK_VOICE] = &CellularCallHandler::CallRingBackVoiceResponse;
108 requestFuncMap_[RadioEvent::RADIO_CALL_SRVCC_STATUS] = &CellularCallHandler::UpdateSrvccStateReport;
109 requestFuncMap_[RadioEvent::RADIO_CALL_SS_NOTICE] = &CellularCallHandler::SsNotifyResponse;
110 requestFuncMap_[RadioEvent::RADIO_CALL_EMERGENCY_NUMBER_REPORT] = &CellularCallHandler::ReportEccChanged;
111 requestFuncMap_[RadioEvent::RADIO_SIM_STATE_CHANGE] = &CellularCallHandler::SimStateChangeReport;
112 requestFuncMap_[RadioEvent::RADIO_SIM_RECORDS_LOADED] = &CellularCallHandler::SimRecordsLoadedReport;
113 requestFuncMap_[RadioEvent::RADIO_CALL_RSRVCC_STATUS] = &CellularCallHandler::UpdateRsrvccStateReport;
114 #ifdef CALL_MANAGER_AUTO_START_OPTIMIZE
115 requestFuncMap_[RadioEvent::RADIO_STATE_CHANGED] = &CellularCallHandler::RadioStateChangeProcess;
116 #endif
117 }
118
RegisterImsCallCallbackHandler()119 void CellularCallHandler::RegisterImsCallCallbackHandler()
120 {
121 // Register IMS
122 std::shared_ptr<ImsCallClient> imsCallClient = DelayedSingleton<ImsCallClient>::GetInstance();
123 if (imsCallClient != nullptr) {
124 imsCallClient->RegisterImsCallCallbackHandler(slotId_, shared_from_this());
125 }
126 }
127
ProcessEvent(const AppExecFwk::InnerEvent::Pointer & event)128 void CellularCallHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event)
129 {
130 if (event == nullptr) {
131 TELEPHONY_LOGE("CellularCallHandler::ProcessEvent, event is nullptr");
132 return;
133 }
134
135 uint32_t eventId = event->GetInnerEventId();
136 TELEPHONY_LOGI("CellularCallHandler::ProcessEvent(), eventId = %{public}d, slotId = %{public}d", eventId, slotId_);
137
138 auto itFunc = requestFuncMap_.find(event->GetInnerEventId());
139 if (itFunc != requestFuncMap_.end()) {
140 auto requestFunc = itFunc->second;
141 if (requestFunc != nullptr) {
142 return (this->*requestFunc)(event);
143 }
144 }
145 TELEPHONY_LOGI("CellularCallHandler::ProcessEvent, default case, need check.");
146 }
147
OnReceiveEvent(const EventFwk::CommonEventData & data)148 void CellularCallHandler::OnReceiveEvent(const EventFwk::CommonEventData &data)
149 {
150 EventFwk::Want want = data.GetWant();
151 std::string action = want.GetAction();
152 TELEPHONY_LOGI("Slot%{public}d: action=%{public}s code=%{public}d", slotId_, action.c_str(), data.GetCode());
153 if (action == EventFwk::CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED) {
154 int32_t slotId = want.GetIntParam(BROADCAST_ARG_SLOT_ID, DEFAULT_SIM_SLOT_ID);
155 if (slotId_ != slotId) {
156 return;
157 }
158 this->SendEvent(OPERATOR_CONFIG_CHANGED_ID, DELAY_TIME, Priority::HIGH);
159 }
160 }
161
GetCsCallData(const AppExecFwk::InnerEvent::Pointer & event)162 void CellularCallHandler::GetCsCallData(const AppExecFwk::InnerEvent::Pointer &event)
163 {
164 if (event == nullptr) {
165 TELEPHONY_LOGE("GetCsCallData return, event is nullptr");
166 return;
167 }
168 TELEPHONY_LOGI("GetCsCallData event id: %{public}d", event->GetInnerEventId());
169 this->SendEvent(GET_CS_CALL_DATA_ID, DELAY_TIME, Priority::HIGH);
170 }
171
GetImsCallData(const AppExecFwk::InnerEvent::Pointer & event)172 void CellularCallHandler::GetImsCallData(const AppExecFwk::InnerEvent::Pointer &event)
173 {
174 if (event == nullptr) {
175 TELEPHONY_LOGE("GetImsCallData return, event is nullptr");
176 return;
177 }
178 TELEPHONY_LOGI("GetImsCallData event id: %{public}d", event->GetInnerEventId());
179 this->SendEvent(GET_IMS_CALL_DATA_ID, DELAY_TIME, Priority::HIGH);
180 }
181
CellularCallIncomingStartTrace(const int32_t state)182 void CellularCallHandler::CellularCallIncomingStartTrace(const int32_t state)
183 {
184 if (state == static_cast<int32_t>(TelCallState::CALL_STATUS_INCOMING)) {
185 StartAsyncTrace(HITRACE_TAG_OHOS, "CellularCallIncoming", getpid());
186 }
187 }
188
CellularCallIncomingFinishTrace(const int32_t state)189 void CellularCallHandler::CellularCallIncomingFinishTrace(const int32_t state)
190 {
191 if (state == static_cast<int32_t>(TelCallState::CALL_STATUS_INCOMING)) {
192 FinishAsyncTrace(HITRACE_TAG_OHOS, "CellularCallIncoming", getpid());
193 }
194 }
195
ReportCsCallsData(const CallInfoList & callInfoList)196 void CellularCallHandler::ReportCsCallsData(const CallInfoList &callInfoList)
197 {
198 auto serviceInstance = DelayedSingleton<CellularCallService>::GetInstance();
199 if (serviceInstance == nullptr) {
200 TELEPHONY_LOGE("ReportCsCallsData return, serviceInstance is nullptr");
201 return;
202 }
203 auto csControl = serviceInstance->GetCsControl(slotId_);
204 CallInfo callInfo;
205 std::vector<CallInfo>::const_iterator it = callInfoList.calls.begin();
206 for (; it != callInfoList.calls.end(); ++it) {
207 callInfo.state = (*it).state;
208 }
209 CellularCallIncomingStartTrace(callInfo.state);
210 if (callInfoList.callSize == 0) {
211 if (isInCsRedial_) {
212 TELEPHONY_LOGI("ReportCsCallsData return, ignore hangup during cs redial");
213 isInCsRedial_ = false;
214 return;
215 }
216 if (csControl == nullptr) {
217 TELEPHONY_LOGE("ReportCsCallsData return, cs_control is nullptr");
218 CellularCallIncomingFinishTrace(callInfo.state);
219 return;
220 }
221 if (csControl->ReportCallsData(slotId_, callInfoList) != TELEPHONY_SUCCESS) {
222 CellularCallIncomingFinishTrace(callInfo.state);
223 }
224 serviceInstance->SetCsControl(slotId_, nullptr);
225 return;
226 }
227 if (isInCsRedial_) {
228 TELEPHONY_LOGI("ReportCsCallsData return, ignore cs call state change during cs redial");
229 return;
230 }
231 if (callInfoList.callSize == 1) {
232 if (csControl == nullptr) {
233 csControl = std::make_shared<CSControl>();
234 serviceInstance->SetCsControl(slotId_, csControl);
235 }
236 }
237 if (csControl == nullptr) {
238 TELEPHONY_LOGE("ReportCsCallsData return, cs_control is nullptr");
239 CellularCallIncomingFinishTrace(callInfo.state);
240 return;
241 }
242 if (csControl->ReportCallsData(slotId_, callInfoList) != TELEPHONY_SUCCESS) {
243 CellularCallIncomingFinishTrace(callInfo.state);
244 }
245 }
246
ReportImsCallsData(const ImsCurrentCallList & imsCallInfoList)247 void CellularCallHandler::ReportImsCallsData(const ImsCurrentCallList &imsCallInfoList)
248 {
249 auto serviceInstance = DelayedSingleton<CellularCallService>::GetInstance();
250 if (serviceInstance == nullptr) {
251 TELEPHONY_LOGE("ReportImsCallsData return, serviceInstance is nullptr");
252 return;
253 }
254 ImsCurrentCall imsCallInfo;
255 std::vector<ImsCurrentCall>::const_iterator it = imsCallInfoList.calls.begin();
256 for (; it != imsCallInfoList.calls.end(); ++it) {
257 imsCallInfo.state = (*it).state;
258 }
259 CellularCallIncomingStartTrace(imsCallInfo.state);
260 TELEPHONY_LOGI("ReportImsCallsData, imsCallInfoList.callSize:%{public}d", imsCallInfoList.callSize);
261 auto imsControl = serviceInstance->GetImsControl(slotId_);
262 if (imsCallInfoList.callSize == 0) {
263 if (imsControl == nullptr) {
264 TELEPHONY_LOGE("ReportImsCallsData return, ims_control is nullptr");
265 return;
266 }
267 if (imsControl->ReportImsCallsData(slotId_, imsCallInfoList) != TELEPHONY_SUCCESS) {
268 CellularCallIncomingFinishTrace(imsCallInfo.state);
269 }
270 serviceInstance->SetImsControl(slotId_, nullptr);
271 return;
272 }
273 if (imsCallInfoList.callSize == 1) {
274 if (imsControl == nullptr) {
275 imsControl = std::make_shared<IMSControl>();
276 TELEPHONY_LOGI("ReportImsCallsData, make control");
277 serviceInstance->SetImsControl(slotId_, imsControl);
278 }
279 }
280 if (imsControl == nullptr) {
281 TELEPHONY_LOGE("ReportImsCallsData return, ims_control is nullptr");
282 CellularCallIncomingFinishTrace(imsCallInfo.state);
283 return;
284 }
285 if (imsControl->ReportImsCallsData(slotId_, imsCallInfoList) != TELEPHONY_SUCCESS) {
286 CellularCallIncomingFinishTrace(imsCallInfo.state);
287 }
288 }
289
GetCsCallsDataResponse(const AppExecFwk::InnerEvent::Pointer & event)290 void CellularCallHandler::GetCsCallsDataResponse(const AppExecFwk::InnerEvent::Pointer &event)
291 {
292 if (event == nullptr) {
293 TELEPHONY_LOGE("GetCsCallsDataResponse return, event is nullptr");
294 return;
295 }
296 // Returns list of current calls of ME. If command succeeds but no calls are available,
297 // no information response is sent to TE. Refer subclause 9.2 for possible <err> values.
298 auto callInfoList = event->GetSharedObject<CallInfoList>();
299 if (callInfoList == nullptr) {
300 TELEPHONY_LOGE("GetCsCallsDataResponse, Cannot get the callInfoList, need to get rilResponseInfo");
301 auto rilResponseInfo = event->GetSharedObject<HRilRadioResponseInfo>();
302 if (rilResponseInfo == nullptr) {
303 TELEPHONY_LOGE("GetCsCallsDataResponse return, callInfoList and rilResponseInfo is nullptr");
304 return;
305 }
306 if (rilResponseInfo->error == HRilErrType::NONE) {
307 TELEPHONY_LOGE("GetCsCallsDataResponse return, failed to query the call list but no reason!");
308 return;
309 }
310 TELEPHONY_LOGE("GetCsCallsDataResponse error, report to call_manager");
311 CellularCallEventInfo eventInfo;
312 eventInfo.eventType = CellularCallEventType::EVENT_REQUEST_RESULT_TYPE;
313 eventInfo.eventId = RequestResultEventId::RESULT_GET_CURRENT_CALLS_FAILED;
314 if (registerInstance_ == nullptr) {
315 TELEPHONY_LOGE("GetCsCallsDataResponse return, GetInstance is nullptr");
316 return;
317 }
318 registerInstance_->ReportEventResultInfo(eventInfo);
319 return;
320 }
321 ReportCsCallsData(*callInfoList);
322 }
323
GetImsCallsDataResponse(const AppExecFwk::InnerEvent::Pointer & event)324 void CellularCallHandler::GetImsCallsDataResponse(const AppExecFwk::InnerEvent::Pointer &event)
325 {
326 if (event == nullptr) {
327 TELEPHONY_LOGE("GetImsCallsDataResponse return, event is nullptr");
328 return;
329 }
330 // Returns list of current calls of ME. If command succeeds but no calls are available,
331 // no information response is sent to TE. Refer subclause 9.2 for possible <err> values.
332 auto imsCallInfoList = event->GetSharedObject<ImsCurrentCallList>();
333 if (imsCallInfoList == nullptr) {
334 TELEPHONY_LOGE("GetImsCallsDataResponse, Cannot get the imsCallInfoList, need to get rilResponseInfo");
335 auto rilResponseInfo = event->GetSharedObject<HRilRadioResponseInfo>();
336 if (rilResponseInfo == nullptr) {
337 TELEPHONY_LOGE("GetImsCallsDataResponse return, callInfoList and rilResponseInfo is nullptr");
338 return;
339 }
340 if (rilResponseInfo->error == HRilErrType::NONE) {
341 TELEPHONY_LOGE("GetImsCallsDataResponse return, failed to query the call list but no reason!");
342 return;
343 }
344 TELEPHONY_LOGE("GetImsCallsDataResponse error, report to call_manager");
345 if (registerInstance_ == nullptr) {
346 TELEPHONY_LOGE("GetImsCallsDataResponse return, GetInstance is nullptr");
347 return;
348 }
349 registerInstance_->ReportGetCallDataResult(static_cast<int32_t>(rilResponseInfo->error));
350 return;
351 }
352 ReportImsCallsData(*imsCallInfoList);
353 }
354
DialResponse(const AppExecFwk::InnerEvent::Pointer & event)355 void CellularCallHandler::DialResponse(const AppExecFwk::InnerEvent::Pointer &event)
356 {
357 if (event == nullptr) {
358 TELEPHONY_LOGE("DialResponse return, event is nullptr");
359 return;
360 }
361 auto result = event->GetSharedObject<HRilRadioResponseInfo>();
362 if (result == nullptr) {
363 TELEPHONY_LOGE("DialResponse return, result is nullptr");
364 return;
365 }
366 struct CallBehaviorParameterInfo info = { 0 };
367 DelayedSingleton<CellularCallHiSysEvent>::GetInstance()->GetCallParameterInfo(info);
368 if (result->error != HRilErrType::NONE) {
369 TELEPHONY_LOGI("DialResponse, dial return error, report to call_manager");
370 CellularCallEventInfo eventInfo;
371 eventInfo.eventType = CellularCallEventType::EVENT_REQUEST_RESULT_TYPE;
372
373 /*
374 * 3GPP TS 27.007 V3.9.0 (2001-06)
375 * If ME has succeeded in establishing a logical link between application protocols and external interface,
376 * it will send CONNECT message to the TE. Otherwise, the NO CARRIER response will be returned.
377 */
378 if (result->error == HRilErrType::HRIL_ERR_CMD_NO_CARRIER) {
379 eventInfo.eventId = RequestResultEventId::RESULT_DIAL_NO_CARRIER;
380 } else {
381 eventInfo.eventId = RequestResultEventId::RESULT_DIAL_SEND_FAILED;
382 }
383 if (registerInstance_ == nullptr) {
384 TELEPHONY_LOGE("DialResponse return, GetInstance is nullptr");
385 return;
386 }
387 registerInstance_->ReportEventResultInfo(eventInfo);
388 CellularCallHiSysEvent::WriteDialCallBehaviorEvent(info, CallResponseResult::COMMAND_FAILURE);
389 } else {
390 CellularCallHiSysEvent::WriteDialCallBehaviorEvent(info, CallResponseResult::COMMAND_SUCCESS);
391 }
392 }
393
CommonResultEventHandling(const AppExecFwk::InnerEvent::Pointer & event,CellularCallEventInfo & eventInfo)394 void CellularCallHandler::CommonResultEventHandling(
395 const AppExecFwk::InnerEvent::Pointer &event, CellularCallEventInfo &eventInfo)
396 {
397 if (event == nullptr) {
398 TELEPHONY_LOGE("CommonResultResponse return, event is nullptr");
399 return;
400 }
401 eventInfo.eventType = CellularCallEventType::EVENT_REQUEST_RESULT_TYPE;
402 switch (event->GetInnerEventId()) {
403 case RadioEvent::RADIO_HANGUP_CONNECT:
404 eventInfo.eventId = RequestResultEventId::RESULT_END_SEND_FAILED;
405 break;
406 case RadioEvent::RADIO_REJECT_CALL:
407 eventInfo.eventId = RequestResultEventId::RESULT_REJECT_SEND_FAILED;
408 break;
409 case RadioEvent::RADIO_ACCEPT_CALL:
410 eventInfo.eventId = RequestResultEventId::RESULT_ACCEPT_SEND_FAILED;
411 break;
412 case RadioEvent::RADIO_HOLD_CALL:
413 eventInfo.eventId = RequestResultEventId::RESULT_HOLD_SEND_FAILED;
414 break;
415 case RadioEvent::RADIO_ACTIVE_CALL:
416 eventInfo.eventId = RequestResultEventId::RESULT_ACTIVE_SEND_FAILED;
417 break;
418 case RadioEvent::RADIO_SWAP_CALL:
419 eventInfo.eventId = RequestResultEventId::RESULT_SWAP_SEND_FAILED;
420 break;
421 case RadioEvent::RADIO_JOIN_CALL:
422 eventInfo.eventId = RequestResultEventId::RESULT_JOIN_SEND_FAILED;
423 break;
424 case RadioEvent::RADIO_SPLIT_CALL:
425 eventInfo.eventId = RequestResultEventId::RESULT_SPLIT_SEND_FAILED;
426 break;
427 case RadioEvent::RADIO_CALL_SUPPLEMENT:
428 eventInfo.eventId = RequestResultEventId::RESULT_SUPPLEMENT_SEND_FAILED;
429 break;
430 default:
431 break;
432 }
433 }
434
CommonResultResponse(const AppExecFwk::InnerEvent::Pointer & event)435 void CellularCallHandler::CommonResultResponse(const AppExecFwk::InnerEvent::Pointer &event)
436 {
437 if (event == nullptr) {
438 TELEPHONY_LOGE("CommonResultResponse return, event is nullptr");
439 return;
440 }
441 auto result = event->GetSharedObject<HRilRadioResponseInfo>();
442 if (result == nullptr) {
443 TELEPHONY_LOGE("CommonResultResponse return, result is nullptr");
444 return;
445 }
446 struct CallBehaviorParameterInfo info = { 0 };
447 DelayedSingleton<CellularCallHiSysEvent>::GetInstance()->GetCallParameterInfo(info);
448 if (result->error != HRilErrType::NONE) {
449 CellularCallEventInfo eventInfo;
450 eventInfo.eventId = RequestResultEventId::INVALID_REQUEST_RESULT_EVENT_ID;
451 CommonResultEventHandling(event, eventInfo);
452 if (eventInfo.eventId == RequestResultEventId::RESULT_END_SEND_FAILED ||
453 eventInfo.eventId == RequestResultEventId::RESULT_REJECT_SEND_FAILED) {
454 CellularCallHiSysEvent::WriteHangUpCallBehaviorEvent(info, CallResponseResult::COMMAND_FAILURE);
455 } else if (eventInfo.eventId == RequestResultEventId::RESULT_ACCEPT_SEND_FAILED) {
456 CellularCallHiSysEvent::WriteAnswerCallBehaviorEvent(info, CallResponseResult::COMMAND_FAILURE);
457 } else {
458 TELEPHONY_LOGI("eventId is not within the scope of processing");
459 }
460 if (registerInstance_ == nullptr) {
461 TELEPHONY_LOGE("CommonResultResponse return, registerInstance_ is nullptr");
462 return;
463 }
464 registerInstance_->ReportEventResultInfo(eventInfo);
465 return;
466 }
467 uint32_t id = event->GetInnerEventId();
468 if (id == RadioEvent::RADIO_HANGUP_CONNECT || id == RadioEvent::RADIO_REJECT_CALL) {
469 CellularCallHiSysEvent::WriteHangUpCallBehaviorEvent(info, CallResponseResult::COMMAND_SUCCESS);
470 } else if (id == RadioEvent::RADIO_ACCEPT_CALL) {
471 CellularCallHiSysEvent::WriteAnswerCallBehaviorEvent(info, CallResponseResult::COMMAND_SUCCESS);
472 } else {
473 TELEPHONY_LOGI("id is not within the scope of processing");
474 }
475 }
476
SendDtmfResponse(const AppExecFwk::InnerEvent::Pointer & event)477 void CellularCallHandler::SendDtmfResponse(const AppExecFwk::InnerEvent::Pointer &event)
478 {
479 if (event == nullptr) {
480 TELEPHONY_LOGE("SendDtmfResponse return, event is nullptr");
481 return;
482 }
483 auto result = event->GetSharedObject<HRilRadioResponseInfo>();
484 if (result == nullptr) {
485 TELEPHONY_LOGE("SendDtmfResponse return, result is nullptr");
486 return;
487 }
488 CellularCallEventInfo eventInfo;
489 eventInfo.eventType = CellularCallEventType::EVENT_REQUEST_RESULT_TYPE;
490 if (result->error != HRilErrType::NONE) {
491 eventInfo.eventId = RequestResultEventId::RESULT_SEND_DTMF_FAILED;
492 } else {
493 eventInfo.eventId = RequestResultEventId::RESULT_SEND_DTMF_SUCCESS;
494 }
495 if (registerInstance_ == nullptr) {
496 TELEPHONY_LOGE("SendDtmfResponse return, GetInstance is nullptr");
497 return;
498 }
499 TELEPHONY_LOGI("SendDtmfResponse: report to call manager");
500 registerInstance_->ReportEventResultInfo(eventInfo);
501 }
502
StartDtmfResponse(const AppExecFwk::InnerEvent::Pointer & event)503 void CellularCallHandler::StartDtmfResponse(const AppExecFwk::InnerEvent::Pointer &event)
504 {
505 if (event == nullptr) {
506 TELEPHONY_LOGE("StartDtmfResponse return, event is nullptr");
507 return;
508 }
509 auto result = event->GetSharedObject<HRilRadioResponseInfo>();
510 if (result == nullptr) {
511 TELEPHONY_LOGE("StartDtmfResponse return, result is nullptr");
512 return;
513 }
514
515 if (registerInstance_ == nullptr) {
516 TELEPHONY_LOGE("StartDtmfResponse return, GetInstance is nullptr");
517 return;
518 }
519 TELEPHONY_LOGI("StartDtmfResponse: report to call manager");
520 registerInstance_->ReportStartDtmfResult(static_cast<int32_t>(result->error));
521 }
522
SimStateChangeReport(const AppExecFwk::InnerEvent::Pointer & event)523 void CellularCallHandler::SimStateChangeReport(const AppExecFwk::InnerEvent::Pointer &event)
524 {
525 if (event == nullptr) {
526 TELEPHONY_LOGE("SimStateChangeReport return, event is nullptr");
527 return;
528 }
529 CellularCallConfig config;
530 config.HandleSimStateChanged(slotId_);
531 }
532
SimRecordsLoadedReport(const AppExecFwk::InnerEvent::Pointer & event)533 void CellularCallHandler::SimRecordsLoadedReport(const AppExecFwk::InnerEvent::Pointer &event)
534 {
535 if (event == nullptr) {
536 TELEPHONY_LOGE("SimRecordsLoadedReport return, event is nullptr");
537 return;
538 }
539 TELEPHONY_LOGI("SimRecordsLoadedReport: report to cellular call config");
540 CellularCallConfig config;
541 config.HandleSimRecordsLoaded(slotId_);
542 }
543
StopDtmfResponse(const AppExecFwk::InnerEvent::Pointer & event)544 void CellularCallHandler::StopDtmfResponse(const AppExecFwk::InnerEvent::Pointer &event)
545 {
546 if (event == nullptr) {
547 TELEPHONY_LOGE("StopDtmfResponse return, event is nullptr");
548 return;
549 }
550 auto result = event->GetSharedObject<HRilRadioResponseInfo>();
551 if (result == nullptr) {
552 TELEPHONY_LOGE("StopDtmfResponse return, result is nullptr");
553 return;
554 }
555
556 if (registerInstance_ == nullptr) {
557 TELEPHONY_LOGE("StopDtmfResponse return, GetInstance is nullptr");
558 return;
559 }
560 TELEPHONY_LOGI("StopDtmfResponse: report to call manager");
561 registerInstance_->ReportStopDtmfResult(static_cast<int32_t>(result->error));
562 }
563
SetSlotId(int32_t id)564 void CellularCallHandler::SetSlotId(int32_t id)
565 {
566 slotId_ = id;
567 }
568
GetSlotId()569 int32_t CellularCallHandler::GetSlotId()
570 {
571 return slotId_;
572 }
573
CurrentTimeMillis()574 int64_t CellularCallHandler::CurrentTimeMillis()
575 {
576 int64_t timems =
577 std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch())
578 .count();
579 return timems;
580 }
581
IsCanRequestCallsData()582 bool CellularCallHandler::IsCanRequestCallsData()
583 {
584 int64_t timems = CurrentTimeMillis();
585 if ((timems - lastTime_) < FAST_DELAY_TIME) {
586 return false;
587 }
588 lastTime_ = timems;
589 return true;
590 }
591
GetCsCallsDataRequest(const AppExecFwk::InnerEvent::Pointer & event)592 void CellularCallHandler::GetCsCallsDataRequest(const AppExecFwk::InnerEvent::Pointer &event)
593 {
594 if (!IsCanRequestCallsData()) {
595 TELEPHONY_LOGE("GetCsCallsDataRequest return, IsCanRequestCallsData false");
596 }
597 lastCallsDataFlag_ = CurrentTimeMillis();
598 CellularCallConnectionCS connectionCs;
599 connectionCs.GetCsCallsDataRequest(slotId_, lastCallsDataFlag_);
600 }
601
GetImsCallsDataRequest(const AppExecFwk::InnerEvent::Pointer & event)602 void CellularCallHandler::GetImsCallsDataRequest(const AppExecFwk::InnerEvent::Pointer &event)
603 {
604 if (!IsCanRequestCallsData()) {
605 TELEPHONY_LOGE("GetImsCallsDataRequest return, IsCanRequestCallsData false");
606 }
607 lastCallsDataFlag_ = CurrentTimeMillis();
608 CellularCallConnectionIMS connectionIms;
609 connectionIms.GetImsCallsDataRequest(slotId_, lastCallsDataFlag_);
610 }
611
RegisterHandler(const AppExecFwk::InnerEvent::Pointer & event)612 void CellularCallHandler::RegisterHandler(const AppExecFwk::InnerEvent::Pointer &event)
613 {
614 CellularCallConnectionCS connectionCs;
615 connectionCs.RegisterHandler();
616 }
617
SetDomainPreferenceModeResponse(const AppExecFwk::InnerEvent::Pointer & event)618 void CellularCallHandler::SetDomainPreferenceModeResponse(const AppExecFwk::InnerEvent::Pointer &event)
619 {
620 TELEPHONY_LOGI("SetDomainPreferenceModeResponse entry");
621 if (event == nullptr) {
622 TELEPHONY_LOGE("SetDomainPreferenceModeResponse return, event is nullptr");
623 return;
624 }
625 auto info = event->GetSharedObject<HRilRadioResponseInfo>();
626 if (info == nullptr) {
627 TELEPHONY_LOGE("SetDomainPreferenceModeResponse return, info is nullptr");
628 return;
629 }
630 CellularCallEventInfo eventInfo;
631 eventInfo.eventType = CellularCallEventType::EVENT_REQUEST_RESULT_TYPE;
632 if (info->error != HRilErrType::NONE) {
633 eventInfo.eventId = RequestResultEventId::RESULT_SET_CALL_PREFERENCE_MODE_FAILED;
634 } else {
635 eventInfo.eventId = RequestResultEventId::RESULT_SET_CALL_PREFERENCE_MODE_SUCCESS;
636
637 CellularCallConfig config;
638 config.SetTempMode(slotId_);
639 }
640 if (registerInstance_ == nullptr) {
641 TELEPHONY_LOGE("SetDomainPreferenceModeResponse return, GetInstance is nullptr");
642 return;
643 }
644 registerInstance_->ReportEventResultInfo(eventInfo);
645 }
646
GetDomainPreferenceModeResponse(const AppExecFwk::InnerEvent::Pointer & event)647 void CellularCallHandler::GetDomainPreferenceModeResponse(const AppExecFwk::InnerEvent::Pointer &event)
648 {
649 TELEPHONY_LOGE("GetDomainPreferenceModeResponse entry");
650 if (event == nullptr) {
651 TELEPHONY_LOGE("GetDomainPreferenceModeResponse return, event is nullptr");
652 return;
653 }
654 auto mode = event->GetSharedObject<int32_t>();
655 if (mode == nullptr) {
656 TELEPHONY_LOGI("GetDomainPreferenceModeResponse return, mode is nullptr");
657 return;
658 }
659 CellularCallConfig config;
660 config.GetDomainPreferenceModeResponse(slotId_, *mode);
661 }
662
SetImsSwitchStatusResponse(const AppExecFwk::InnerEvent::Pointer & event)663 void CellularCallHandler::SetImsSwitchStatusResponse(const AppExecFwk::InnerEvent::Pointer &event)
664 {
665 TELEPHONY_LOGI("SetImsSwitchStatusResponse entry");
666 if (event == nullptr) {
667 TELEPHONY_LOGE("SetImsSwitchStatusResponse return, event is nullptr");
668 return;
669 }
670 auto info = event->GetSharedObject<HRilRadioResponseInfo>();
671 if (info == nullptr) {
672 TELEPHONY_LOGE("SetImsSwitchStatusResponse return, info is nullptr");
673 return;
674 }
675 if (registerInstance_ == nullptr) {
676 TELEPHONY_LOGE("SetImsSwitchStatusResponse return, GetInstance is nullptr");
677 return;
678 }
679 CellularCallConfig config;
680 config.HandleSetLteImsSwitchResult(slotId_, info->error);
681 }
682
GetImsSwitchStatusResponse(const AppExecFwk::InnerEvent::Pointer & event)683 void CellularCallHandler::GetImsSwitchStatusResponse(const AppExecFwk::InnerEvent::Pointer &event)
684 {
685 TELEPHONY_LOGI("GetImsSwitchStatusResponse entry");
686 }
687
CsCallStatusInfoReport(const AppExecFwk::InnerEvent::Pointer & event)688 void CellularCallHandler::CsCallStatusInfoReport(const AppExecFwk::InnerEvent::Pointer &event)
689 {
690 if (event == nullptr) {
691 TELEPHONY_LOGE("CsCallStatusInfoReport return, event is nullptr");
692 return;
693 }
694 if (srvccState_ == SrvccState::STARTED) {
695 TELEPHONY_LOGI("CsCallStatusInfoReport ignore, srvcc started");
696 return;
697 }
698 GetCsCallData(event);
699 }
700
ImsCallStatusInfoReport(const AppExecFwk::InnerEvent::Pointer & event)701 void CellularCallHandler::ImsCallStatusInfoReport(const AppExecFwk::InnerEvent::Pointer &event)
702 {
703 if (event == nullptr) {
704 TELEPHONY_LOGE("ImsCallStatusInfoReport return, event is nullptr");
705 return;
706 }
707 if (srvccState_ == SrvccState::STARTED) {
708 TELEPHONY_LOGI("ImsCallStatusInfoReport ignore, srvcc started");
709 return;
710 }
711 GetImsCallData(event);
712 }
713
UssdNotifyResponse(const AppExecFwk::InnerEvent::Pointer & event)714 void CellularCallHandler::UssdNotifyResponse(const AppExecFwk::InnerEvent::Pointer &event)
715 {
716 TELEPHONY_LOGI("CellularCallHandler::UssdNotifyResponse entry");
717 if (event == nullptr) {
718 TELEPHONY_LOGE("UssdNotifyResponse, event is nullptr");
719 return;
720 }
721 auto result = event->GetSharedObject<UssdNoticeInfo>();
722 if (result == nullptr) {
723 TELEPHONY_LOGE("UssdNotifyResponse, result is nullptr");
724 return;
725 }
726 CellularCallSupplement supplement;
727 supplement.EventUssdNotify(*result);
728 }
729
SetMuteResponse(const AppExecFwk::InnerEvent::Pointer & event)730 void CellularCallHandler::SetMuteResponse(const AppExecFwk::InnerEvent::Pointer &event)
731 {
732 TELEPHONY_LOGI("CellularCallHandler::SetMuteResponse entry");
733 if (event == nullptr) {
734 TELEPHONY_LOGE("SetMuteResponse return, event is nullptr");
735 return;
736 }
737 auto info = event->GetSharedObject<HRilRadioResponseInfo>();
738 if (info == nullptr) {
739 TELEPHONY_LOGE("SetMuteResponse return, info is nullptr");
740 return;
741 }
742 MuteControlResponse response;
743 if (registerInstance_ == nullptr) {
744 TELEPHONY_LOGE("SetMuteResponse return, registerInstance_ is nullptr");
745 return;
746 }
747 response.result = static_cast<int32_t>(info->error);
748 TELEPHONY_LOGI("SetMuteResponse: report to call manager");
749 registerInstance_->ReportSetMuteResult(response);
750 }
751
GetMuteResponse(const AppExecFwk::InnerEvent::Pointer & event)752 void CellularCallHandler::GetMuteResponse(const AppExecFwk::InnerEvent::Pointer &event)
753 {
754 TELEPHONY_LOGI("CellularCallHandler::GetMuteResponse entry");
755 if (event == nullptr) {
756 TELEPHONY_LOGE("GetMuteResponse return, event is nullptr");
757 return;
758 }
759 MuteControlResponse response;
760 auto mute = event->GetSharedObject<int32_t>();
761 if (mute == nullptr) {
762 TELEPHONY_LOGI("GetMuteResponse, mute is nullptr");
763 auto info = event->GetSharedObject<HRilRadioResponseInfo>();
764 if (info == nullptr) {
765 TELEPHONY_LOGE("GetMuteResponse return, info is nullptr");
766 return;
767 }
768 response.result = static_cast<int32_t>(info->error);
769 } else {
770 response.result = static_cast<int32_t>(HRilErrType::NONE);
771 response.value = *mute;
772 }
773 if (registerInstance_ == nullptr) {
774 TELEPHONY_LOGE("GetMuteResponse return, registerInstance_ is nullptr");
775 return;
776 }
777 TELEPHONY_LOGI("GetMuteResponse: report to call manager");
778 registerInstance_->ReportGetMuteResult(response);
779 }
780
GetEmergencyCallListResponse(const AppExecFwk::InnerEvent::Pointer & event)781 void CellularCallHandler::GetEmergencyCallListResponse(const AppExecFwk::InnerEvent::Pointer &event)
782 {
783 TELEPHONY_LOGI("CellularCallHandler::GetEmergencyCallListResponse entry");
784 if (event == nullptr) {
785 TELEPHONY_LOGE("GetEmergencyCallListResponse return, event is nullptr");
786 return;
787 }
788 auto eccList = event->GetSharedObject<EmergencyInfoList>();
789 if (eccList == nullptr) {
790 TELEPHONY_LOGE("UpdateEmergencyCallFromRadio return, eccList is nullptr");
791 return;
792 }
793 CellularCallConfig config;
794 config.UpdateEmergencyCallFromRadio(slotId_, *eccList);
795 }
796
SetEmergencyCallListResponse(const AppExecFwk::InnerEvent::Pointer & event)797 void CellularCallHandler::SetEmergencyCallListResponse(const AppExecFwk::InnerEvent::Pointer &event)
798 {
799 TELEPHONY_LOGI("CellularCallHandler::SetEmergencyCallListResponse entry");
800 if (event == nullptr) {
801 TELEPHONY_LOGE("SetEmergencyCallListResponse return, event is nullptr");
802 return;
803 }
804 auto info = event->GetSharedObject<HRilRadioResponseInfo>();
805 if (info == nullptr) {
806 TELEPHONY_LOGE("SetEmergencyCallListResponse return, info is nullptr");
807 return;
808 }
809 SetEccListResponse response;
810 if (registerInstance_ == nullptr) {
811 TELEPHONY_LOGE("SetEmergencyCallListResponse return, registerInstance_ is nullptr");
812 return;
813 }
814 response.result = static_cast<int32_t>(info->error);
815 TELEPHONY_LOGI("SetEmergencyCallListResponse report to call manager");
816 registerInstance_->ReportSetEmergencyCallListResponse(response);
817 }
818
CallRingBackVoiceResponse(const AppExecFwk::InnerEvent::Pointer & event)819 void CellularCallHandler::CallRingBackVoiceResponse(const AppExecFwk::InnerEvent::Pointer &event)
820 {
821 TELEPHONY_LOGI("CellularCallHandler::CallRingBackVoiceResponse entry");
822 if (event == nullptr) {
823 TELEPHONY_LOGE("CallRingBackVoiceResponse return, event is nullptr");
824 return;
825 }
826 auto ringBackVoice = event->GetSharedObject<RingbackVoice>();
827 if (ringBackVoice == nullptr) {
828 TELEPHONY_LOGE("CallRingBackVoiceResponse return, ringBackVoice is nullptr");
829 return;
830 }
831 if (registerInstance_ == nullptr) {
832 TELEPHONY_LOGE("CallRingBackVoiceResponse return, registerInstance_ is nullptr");
833 return;
834 }
835 TELEPHONY_LOGI("CallRingBackVoiceResponse: report to call manager");
836 registerInstance_->ReportCallRingBackResult(ringBackVoice->status);
837 }
838
GetCallFailReasonResponse(const AppExecFwk::InnerEvent::Pointer & event)839 void CellularCallHandler::GetCallFailReasonResponse(const AppExecFwk::InnerEvent::Pointer &event)
840 {
841 TELEPHONY_LOGI("CellularCallHandler::GetCallFailReasonResponse entry");
842 if (event == nullptr) {
843 TELEPHONY_LOGE("GetCallFailReasonResponse return, event is nullptr");
844 return;
845 }
846 if (registerInstance_ == nullptr) {
847 TELEPHONY_LOGE("GetCallFailReasonResponse return, registerInstance_ is nullptr");
848 return;
849 }
850 auto reason = event->GetSharedObject<int32_t>();
851 DisconnectedDetails details;
852 if (reason == nullptr) {
853 auto info = event->GetSharedObject<DisconnectedDetails>();
854 if (info == nullptr) {
855 TELEPHONY_LOGE("GetCallFailReasonResponse return, info is nullptr");
856 return;
857 }
858 details.reason = static_cast<DisconnectedReason>(info->reason);
859 details.message = (info->message.c_str() == nullptr) ? "" : info->message;
860 } else {
861 details.reason = static_cast<DisconnectedReason>(*reason);
862 details.message = "";
863 }
864
865 if (details.message.empty()) {
866 std::string callFailedMessageName = "";
867 bool ret =
868 ResourceUtils::Get().GetCallFailedMessageName(static_cast<int32_t>(details.reason), callFailedMessageName);
869 if (!ret) {
870 TELEPHONY_LOGE("get call failed message failed!");
871 return;
872 }
873 ResourceUtils::Get().GetStringValueByName(callFailedMessageName, details.message);
874 }
875 CellularCallHiSysEvent::WriteCallEndBehaviorEvent(slotId_, static_cast<int32_t>(details.reason));
876 registerInstance_->ReportCallFailReason(details);
877 }
878
UpdateSrvccStateReport(const AppExecFwk::InnerEvent::Pointer & event)879 void CellularCallHandler::UpdateSrvccStateReport(const AppExecFwk::InnerEvent::Pointer &event)
880 {
881 TELEPHONY_LOGI("CellularCallHandler::UpdateSrvccStateReport entry");
882 if (event == nullptr) {
883 TELEPHONY_LOGE("UpdateSrvccStateReport return, event is nullptr");
884 return;
885 }
886 auto srvccStatus = event->GetSharedObject<SrvccStatus>();
887 if (srvccStatus == nullptr) {
888 TELEPHONY_LOGE("UpdateSrvccStateReport return, srvccStatus is nullptr");
889 return;
890 }
891 TELEPHONY_LOGI("srvccStatus %{public}d", srvccStatus->status);
892 srvccState_ = srvccStatus->status;
893 auto serviceInstance_ = DelayedSingleton<CellularCallService>::GetInstance();
894 if (serviceInstance_ != nullptr) {
895 TELEPHONY_LOGE("UpdateSrvccState");
896 serviceInstance_->SetSrvccState(srvccState_);
897 }
898 if (srvccState_ != SrvccState::COMPLETED) {
899 TELEPHONY_LOGE("UpdateSrvccStateReport return, srvccState_ != SrvccState::COMPLETED");
900 return;
901 }
902 SrvccStateCompleted();
903 }
904
ReportEccChanged(const AppExecFwk::InnerEvent::Pointer & event)905 void CellularCallHandler::ReportEccChanged(const AppExecFwk::InnerEvent::Pointer &event)
906 {
907 TELEPHONY_LOGI("CellularCallHandler::ReportEccChanged entry");
908 if (event == nullptr) {
909 TELEPHONY_LOGE("ReportEccChanged return, event is nullptr");
910 return;
911 }
912 auto emergencyInfoList = event->GetSharedObject<EmergencyInfoList>();
913 if (emergencyInfoList == nullptr) {
914 TELEPHONY_LOGE("ReportEccChanged return, emergencyInfoList is nullptr");
915 return;
916 }
917 CellularCallConfig config;
918 auto calls = emergencyInfoList->calls;
919 if (calls.size() > 0 && static_cast<uint32_t>(calls.back().total) != calls.size()) {
920 TELEPHONY_LOGE("ReportEccChanged data error");
921 auto endCall = calls.back();
922 if (endCall.index < endCall.total) {
923 return;
924 }
925 TELEPHONY_LOGI("ReportEccChanged try query");
926 config.GetEmergencyCallList(slotId_);
927 return;
928 }
929 config.UpdateEmergencyCallFromRadio(slotId_, *emergencyInfoList);
930 }
931
SrvccStateCompleted()932 void CellularCallHandler::SrvccStateCompleted()
933 {
934 TELEPHONY_LOGI("CellularCallHandler::SrvccStateCompleted entry");
935 if (srvccState_ != SrvccState::COMPLETED) {
936 TELEPHONY_LOGE("SrvccStateCompleted return, srvccState_ != SrvccState::COMPLETED");
937 return;
938 }
939 auto serviceInstance_ = DelayedSingleton<CellularCallService>::GetInstance();
940 if (serviceInstance_ == nullptr) {
941 TELEPHONY_LOGE("SrvccStateCompleted return, GetInstance is nullptr");
942 return;
943 }
944 auto csControl = serviceInstance_->GetCsControl(slotId_);
945 if (csControl != nullptr) {
946 TELEPHONY_LOGI("SrvccStateCompleted CsControl ReleaseAllConnection");
947 csControl->ReleaseAllConnection();
948 serviceInstance_->SetCsControl(slotId_, nullptr);
949 } else {
950 TELEPHONY_LOGI("SrvccStateCompleted CsControl is nullptr");
951 csControl = std::make_shared<CSControl>();
952 serviceInstance_->SetCsControl(slotId_, csControl);
953 }
954 auto imsControl = serviceInstance_->GetImsControl(slotId_);
955 if (imsControl != nullptr) {
956 TELEPHONY_LOGI("SrvccStateCompleted ImsControl ReleaseAllConnection");
957 imsControl->ReleaseAllConnection();
958 serviceInstance_->SetImsControl(slotId_, nullptr);
959 } else {
960 TELEPHONY_LOGI("SrvccStateCompleted imsControl is nullptr");
961 }
962 srvccState_ = SrvccState::SRVCC_NONE;
963 }
964
GetMMIResponse(const AppExecFwk::InnerEvent::Pointer & event)965 void CellularCallHandler::GetMMIResponse(const AppExecFwk::InnerEvent::Pointer &event)
966 {
967 if (event == nullptr) {
968 TELEPHONY_LOGE("GetMMIResponse, event is nullptr");
969 return;
970 }
971 std::unique_ptr<MMICodeUtils> mmiCodeUtils = event->GetUniqueObject<MMICodeUtils>();
972 if (mmiCodeUtils == nullptr) {
973 TELEPHONY_LOGE("CellularCallHandler::GetMMIResponse, mmiCodeUtils is nullptr");
974 return;
975 }
976 mmiCodeUtils->ExecuteMmiCode(slotId_);
977 }
978
GetCallWaitingResponse(const AppExecFwk::InnerEvent::Pointer & event)979 void CellularCallHandler::GetCallWaitingResponse(const AppExecFwk::InnerEvent::Pointer &event)
980 {
981 TELEPHONY_LOGI("CellularCallHandler::GetCallWaitingResponse entry");
982 if (event == nullptr) {
983 TELEPHONY_LOGE("GetCallWaitingResponse, event is nullptr");
984 return;
985 }
986 auto result = event->GetSharedObject<CallWaitResult>();
987 if (result == nullptr) {
988 TELEPHONY_LOGE("CellularCallHandler::GetCallWaitingResponse, result is nullptr");
989 return;
990 }
991 CellularCallSupplement supplement;
992 supplement.EventGetCallWaiting(*result);
993 }
994
SetCallWaitingResponse(const AppExecFwk::InnerEvent::Pointer & event)995 void CellularCallHandler::SetCallWaitingResponse(const AppExecFwk::InnerEvent::Pointer &event)
996 {
997 TELEPHONY_LOGI("SetCallWaitingResponse entry");
998 if (event == nullptr) {
999 TELEPHONY_LOGE("SetCallWaitingResponse, event is nullptr");
1000 return;
1001 }
1002 auto result = event->GetSharedObject<HRilRadioResponseInfo>();
1003 if (result == nullptr) {
1004 TELEPHONY_LOGE("SetCallWaitingResponse, result is nullptr");
1005 return;
1006 }
1007 CellularCallSupplement supplement;
1008 supplement.EventSetCallWaiting(*result);
1009 }
1010
GetClirResponse(const AppExecFwk::InnerEvent::Pointer & event)1011 void CellularCallHandler::GetClirResponse(const AppExecFwk::InnerEvent::Pointer &event)
1012 {
1013 TELEPHONY_LOGI("GetClirResponse entry");
1014 if (event == nullptr) {
1015 TELEPHONY_LOGE("GetClirResponse, event is nullptr");
1016 return;
1017 }
1018 auto getClirResult = event->GetSharedObject<GetClirResult>();
1019 if (getClirResult == nullptr) {
1020 TELEPHONY_LOGE("GetClirResponse, getClirResult is nullptr");
1021 return;
1022 }
1023 CellularCallSupplement supplement;
1024 supplement.EventGetClir(*getClirResult);
1025 }
1026
SetClirResponse(const AppExecFwk::InnerEvent::Pointer & event)1027 void CellularCallHandler::SetClirResponse(const AppExecFwk::InnerEvent::Pointer &event)
1028 {
1029 TELEPHONY_LOGI("SetClirResponse entry");
1030 if (event == nullptr) {
1031 TELEPHONY_LOGE("SetClirResponse, event is nullptr");
1032 return;
1033 }
1034 auto result = event->GetSharedObject<HRilRadioResponseInfo>();
1035 if (result == nullptr) {
1036 TELEPHONY_LOGE("SetClirResponse, result is nullptr");
1037 return;
1038 }
1039 CellularCallSupplement supplement;
1040 supplement.EventSetClir(*result);
1041 }
1042
GetClipResponse(const AppExecFwk::InnerEvent::Pointer & event)1043 void CellularCallHandler::GetClipResponse(const AppExecFwk::InnerEvent::Pointer &event)
1044 {
1045 TELEPHONY_LOGI("GetClipResponse entry");
1046 if (event == nullptr) {
1047 TELEPHONY_LOGE("GetClipResponse, event is nullptr");
1048 return;
1049 }
1050 auto getClipResult = event->GetSharedObject<GetClipResult>();
1051 if (getClipResult == nullptr) {
1052 TELEPHONY_LOGE("GetClipResponse, getClipResult is nullptr");
1053 return;
1054 }
1055 CellularCallSupplement supplement;
1056 supplement.EventGetClip(*getClipResult);
1057 }
1058
GetCallTransferResponse(const AppExecFwk::InnerEvent::Pointer & event)1059 void CellularCallHandler::GetCallTransferResponse(const AppExecFwk::InnerEvent::Pointer &event)
1060 {
1061 TELEPHONY_LOGI("GetCallTransferResponse entry");
1062 if (event == nullptr) {
1063 TELEPHONY_LOGE("GetCallTransferResponse, event is nullptr");
1064 return;
1065 }
1066 auto cFQueryList = event->GetSharedObject<CallForwardQueryInfoList>();
1067 if (cFQueryList == nullptr) {
1068 TELEPHONY_LOGE("GetCallTransferResponse, cFQueryList is nullptr");
1069 return;
1070 }
1071 CellularCallSupplement supplement;
1072 supplement.EventGetCallTransferInfo(*cFQueryList);
1073 }
1074
SetCallTransferInfoResponse(const AppExecFwk::InnerEvent::Pointer & event)1075 void CellularCallHandler::SetCallTransferInfoResponse(const AppExecFwk::InnerEvent::Pointer &event)
1076 {
1077 TELEPHONY_LOGI("SetCallTransferInfoResponse entry");
1078 if (event == nullptr) {
1079 TELEPHONY_LOGE("SetCallTransferInfoResponse, event is nullptr");
1080 return;
1081 }
1082 auto result = event->GetSharedObject<HRilRadioResponseInfo>();
1083 if (result == nullptr) {
1084 TELEPHONY_LOGE("SetCallTransferInfoResponse, result is nullptr");
1085 return;
1086 }
1087 CellularCallSupplement supplement;
1088 supplement.EventSetCallTransferInfo(*result);
1089 }
1090
GetCallRestrictionResponse(const AppExecFwk::InnerEvent::Pointer & event)1091 void CellularCallHandler::GetCallRestrictionResponse(const AppExecFwk::InnerEvent::Pointer &event)
1092 {
1093 TELEPHONY_LOGI("GetCallRestrictionResponse entry");
1094 if (event == nullptr) {
1095 TELEPHONY_LOGE("GetCallRestrictionResponse, event is nullptr");
1096 return;
1097 }
1098 auto result = event->GetSharedObject<CallRestrictionResult>();
1099 if (result == nullptr) {
1100 TELEPHONY_LOGE("GetCallRestrictionResponse, result is nullptr");
1101 return;
1102 }
1103 CellularCallSupplement supplement;
1104 supplement.EventGetCallRestriction(*result);
1105 }
1106
SetCallRestrictionResponse(const AppExecFwk::InnerEvent::Pointer & event)1107 void CellularCallHandler::SetCallRestrictionResponse(const AppExecFwk::InnerEvent::Pointer &event)
1108 {
1109 TELEPHONY_LOGI("SetCallRestrictionResponse entry");
1110 if (event == nullptr) {
1111 TELEPHONY_LOGE("SetCallRestrictionResponse, event is nullptr");
1112 return;
1113 }
1114 auto result = event->GetSharedObject<HRilRadioResponseInfo>();
1115 if (result == nullptr) {
1116 TELEPHONY_LOGE("SetCallRestrictionResponse, result is nullptr");
1117 return;
1118 }
1119 CellularCallSupplement supplement;
1120 supplement.EventSetCallRestriction(*result);
1121 }
1122
SendUssdResponse(const AppExecFwk::InnerEvent::Pointer & event)1123 void CellularCallHandler::SendUssdResponse(const AppExecFwk::InnerEvent::Pointer &event)
1124 {
1125 if (event == nullptr) {
1126 TELEPHONY_LOGE("SendUssdResponse, event is nullptr");
1127 return;
1128 }
1129 auto result = event->GetSharedObject<HRilRadioResponseInfo>();
1130 if (result == nullptr) {
1131 TELEPHONY_LOGE("SendUssdResponse, result is nullptr");
1132 return;
1133 }
1134 CellularCallSupplement supplement;
1135 supplement.EventSendUssd(*result);
1136 }
1137
SsNotifyResponse(const AppExecFwk::InnerEvent::Pointer & event)1138 void CellularCallHandler::SsNotifyResponse(const AppExecFwk::InnerEvent::Pointer &event)
1139 {
1140 TELEPHONY_LOGI("CellularCallHandler::SsNotifyResponse entry");
1141 if (event == nullptr) {
1142 TELEPHONY_LOGE("SsNotifyResponse, event is nullptr");
1143 return;
1144 }
1145 auto result = event->GetSharedObject<SsNoticeInfo>();
1146 if (result == nullptr) {
1147 TELEPHONY_LOGE("SsNotifyResponse, result is nullptr");
1148 return;
1149 }
1150 CellularCallSupplement supplement;
1151 supplement.EventSsNotify(*result);
1152 }
1153
SendUnlockPinPukResponse(const AppExecFwk::InnerEvent::Pointer & event)1154 void CellularCallHandler::SendUnlockPinPukResponse(const AppExecFwk::InnerEvent::Pointer &event)
1155 {
1156 if (event == nullptr) {
1157 TELEPHONY_LOGE("SendUnlockPinPukResponse, event is nullptr");
1158 return;
1159 }
1160 auto result = event->GetSharedObject<PinPukResponse>();
1161 if (result == nullptr) {
1162 TELEPHONY_LOGE("SendUnlockPinPukResponse, result is nullptr");
1163 return;
1164 }
1165 CellularCallSupplement supplement;
1166 supplement.EventSetPinPuk(*result);
1167 }
1168
HandleOperatorConfigChanged(const AppExecFwk::InnerEvent::Pointer & event)1169 void CellularCallHandler::HandleOperatorConfigChanged(const AppExecFwk::InnerEvent::Pointer &event)
1170 {
1171 if (event == nullptr) {
1172 TELEPHONY_LOGE("event is nullptr");
1173 return;
1174 }
1175
1176 CellularCallConfig config;
1177 config.HandleOperatorConfigChanged(slotId_);
1178 }
1179
UpdateRsrvccStateReport(const AppExecFwk::InnerEvent::Pointer & event)1180 void CellularCallHandler::UpdateRsrvccStateReport(const AppExecFwk::InnerEvent::Pointer &event)
1181 {
1182 if (event == nullptr) {
1183 TELEPHONY_LOGE("event is nullptr");
1184 return;
1185 }
1186
1187 isInCsRedial_ = true;
1188 auto serviceInstance = DelayedSingleton<CellularCallService>::GetInstance();
1189 if (serviceInstance == nullptr) {
1190 TELEPHONY_LOGE("ReportCsCallsData return, GetInstance is nullptr");
1191 return;
1192 }
1193 serviceInstance->SetCsControl(slotId_, nullptr);
1194 }
1195
1196 #ifdef CALL_MANAGER_AUTO_START_OPTIMIZE
RadioStateChangeProcess(const AppExecFwk::InnerEvent::Pointer & event)1197 void CellularCallHandler::RadioStateChangeProcess(const AppExecFwk::InnerEvent::Pointer &event)
1198 {
1199 if (event == nullptr) {
1200 TELEPHONY_LOGE("event is nullptr");
1201 return;
1202 }
1203
1204 std::shared_ptr<HRilInt32Parcel> object = event->GetSharedObject<HRilInt32Parcel>();
1205 if (object == nullptr) {
1206 TELEPHONY_LOGE("Slot%{public}d: HandleRadioStateChanged object is nullptr!", slotId_);
1207 return;
1208 }
1209 TELEPHONY_LOGI("Slot%{public}d: Radio changed with state: %{public}d", slotId_, object->data);
1210 if (object->data == CORE_SERVICE_POWER_ON) {
1211 auto serviceInstance = DelayedSingleton<CellularCallService>::GetInstance();
1212 if (serviceInstance == nullptr) {
1213 TELEPHONY_LOGE("serviceInstance is nullptr");
1214 return;
1215 }
1216 serviceInstance->StartCallManagerService();
1217 }
1218 }
1219 #endif
1220 } // namespace Telephony
1221 } // namespace OHOS
1222