1 /*
2 * Copyright (C) 2022-2023 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 "ims_call_callback_stub.h"
17
18 #include "cellular_call_register.h"
19 #include "cellular_call_service.h"
20 #include "ims_call_client.h"
21 #include "ims_error.h"
22 #include "radio_event.h"
23 #include "supplement_request_cs.h"
24 #include "tel_event_handler.h"
25 #include "telephony_errors.h"
26 #include "telephony_log_wrapper.h"
27
28 namespace OHOS {
29 namespace Telephony {
30 const int32_t MAX_SIZE = 10;
31 const int32_t IMS_CALL = 1;
32
ImsCallCallbackStub()33 ImsCallCallbackStub::ImsCallCallbackStub()
34 {
35 TELEPHONY_LOGI("ImsCallCallbackStub");
36 InitFuncMap();
37 }
38
InitFuncMap()39 void ImsCallCallbackStub::InitFuncMap()
40 {
41 InitCallBasicFuncMap();
42 InitConfigFuncMap();
43 InitSupplementFuncMap();
44 }
45
InitCallBasicFuncMap()46 void ImsCallCallbackStub::InitCallBasicFuncMap()
47 {
48 /****************** call basic ******************/
49 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_DIAL)] =
50 &ImsCallCallbackStub::OnDialResponseInner;
51 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_HANG_UP)] =
52 &ImsCallCallbackStub::OnHangUpResponseInner;
53 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_REJECT)] =
54 &ImsCallCallbackStub::OnRejectResponseInner;
55 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_ANSWER)] =
56 &ImsCallCallbackStub::OnAnswerResponseInner;
57 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_HOLD)] =
58 &ImsCallCallbackStub::OnHoldCallResponseInner;
59 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_UN_HOLD)] =
60 &ImsCallCallbackStub::OnUnHoldCallResponseInner;
61 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_SWITCH)] =
62 &ImsCallCallbackStub::OnSwitchCallResponseInner;
63 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_CALL_STATE_CHANGE)] =
64 &ImsCallCallbackStub::OnCallStateChangeReportInner;
65 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_LAST_CALL_FAIL_REASON)] =
66 &ImsCallCallbackStub::OnLastCallFailReasonResponseInner;
67 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_CALL_CRING)] =
68 &ImsCallCallbackStub::OnCallRingBackReportInner;
69 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_COMBINE_CONFERENCE)] =
70 &ImsCallCallbackStub::OnCombineConferenceResponseInner;
71 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_INVITE_TO_CONFERENCE)] =
72 &ImsCallCallbackStub::OnInviteToConferenceResponseInner;
73 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_RECV_CALL_MEDIA_MODE_REQUEST)] =
74 &ImsCallCallbackStub::OnReceiveUpdateCallMediaModeRequestInner;
75 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_RECV_CALL_MEDIA_MODE_RESPONSE)] =
76 &ImsCallCallbackStub::OnReceiveUpdateCallMediaModeResponseInner;
77 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_CALL_SESSION_EVENT_CHANGED)] =
78 &ImsCallCallbackStub::OnCallSessionEventChangedInner;
79 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_CALL_PEER_DIMENSIONS_CHANGED)] =
80 &ImsCallCallbackStub::OnPeerDimensionsChangedInner;
81 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_CALL_DATA_USAGE_CHANGED)] =
82 &ImsCallCallbackStub::OnCallDataUsageChangedInner;
83 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_CALL_CAMERA_CAPABILITIES_CHANGED)] =
84 &ImsCallCallbackStub::OnCameraCapabilitiesChangedInner;
85 }
86
InitConfigFuncMap()87 void ImsCallCallbackStub::InitConfigFuncMap()
88 {
89 /****************** dtmf rtt ******************/
90 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_START_DTMF)] =
91 &ImsCallCallbackStub::OnStartDtmfResponseInner;
92 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_SEND_DTMF)] =
93 &ImsCallCallbackStub::OnSendDtmfResponseInner;
94 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_STOP_DTMF)] =
95 &ImsCallCallbackStub::OnStopDtmfResponseInner;
96
97 /****************** ims config ******************/
98 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_SET_SWITCH_STATUS)] =
99 &ImsCallCallbackStub::OnSetImsSwitchResponseInner;
100 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_GET_SWITCH_STATUS)] =
101 &ImsCallCallbackStub::OnGetImsSwitchResponseInner;
102 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_GET_CALLS_DATA)] =
103 &ImsCallCallbackStub::OnGetImsCallsDataResponseInner;
104 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_SET_MUTE)] =
105 &ImsCallCallbackStub::OnSetMuteResponseInner;
106 }
107
InitSupplementFuncMap()108 void ImsCallCallbackStub::InitSupplementFuncMap()
109 {
110 /****************** supplement ******************/
111 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_SET_CALL_CLIP)] =
112 &ImsCallCallbackStub::OnSetClipResponseInner;
113 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_GET_CALL_CLIP)] =
114 &ImsCallCallbackStub::OnGetClipResponseInner;
115 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_GET_CALL_CLIR)] =
116 &ImsCallCallbackStub::OnGetClirResponseInner;
117 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_SET_CALL_CLIR)] =
118 &ImsCallCallbackStub::OnSetClirResponseInner;
119 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_GET_CALL_FORWARD)] =
120 &ImsCallCallbackStub::OnGetCallTransferResponseInner;
121 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_SET_CALL_FORWARD)] =
122 &ImsCallCallbackStub::OnSetCallTransferResponseInner;
123 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_GET_CALL_RESTRICTION)] =
124 &ImsCallCallbackStub::OnGetCallRestrictionResponseInner;
125 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_SET_CALL_RESTRICTION)] =
126 &ImsCallCallbackStub::OnSetCallRestrictionResponseInner;
127 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_GET_CALL_WAIT)] =
128 &ImsCallCallbackStub::OnGetCallWaitingResponseInner;
129 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_SET_CALL_WAIT)] =
130 &ImsCallCallbackStub::OnSetCallWaitingResponseInner;
131 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_GET_CALL_COLR)] =
132 &ImsCallCallbackStub::OnGetColrResponseInner;
133 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_SET_CALL_COLR)] =
134 &ImsCallCallbackStub::OnSetColrResponseInner;
135 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_SET_CALL_COLP)] =
136 &ImsCallCallbackStub::OnSetColpResponseInner;
137 requestFuncMap_[static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_GET_CALL_COLP)] =
138 &ImsCallCallbackStub::OnGetColpResponseInner;
139 }
140
~ImsCallCallbackStub()141 ImsCallCallbackStub::~ImsCallCallbackStub()
142 {
143 requestFuncMap_.clear();
144 }
145
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)146 int32_t ImsCallCallbackStub::OnRemoteRequest(
147 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
148 {
149 std::u16string myDescriptor = ImsCallCallbackStub::GetDescriptor();
150 std::u16string remoteDescriptor = data.ReadInterfaceToken();
151 if (myDescriptor != remoteDescriptor) {
152 TELEPHONY_LOGE("descriptor checked fail");
153 return TELEPHONY_ERR_DESCRIPTOR_MISMATCH;
154 }
155 auto itFunc = requestFuncMap_.find(code);
156 if (itFunc != requestFuncMap_.end()) {
157 auto requestFunc = itFunc->second;
158 if (requestFunc != nullptr) {
159 return (this->*requestFunc)(data, reply);
160 }
161 }
162 TELEPHONY_LOGI("Function not found, need check.");
163 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
164 }
165
OnDialResponseInner(MessageParcel & data,MessageParcel & reply)166 int32_t ImsCallCallbackStub::OnDialResponseInner(MessageParcel &data, MessageParcel &reply)
167 {
168 int32_t slotId = data.ReadInt32();
169 auto info = static_cast<const HRilRadioResponseInfo *>(data.ReadRawData(sizeof(HRilRadioResponseInfo)));
170 if (info == nullptr) {
171 TELEPHONY_LOGE("[slot%{public}d] info is null.", slotId);
172 return TELEPHONY_ERR_ARGUMENT_INVALID;
173 }
174 reply.WriteInt32(DialResponse(slotId, *info));
175 return TELEPHONY_SUCCESS;
176 }
177
OnHangUpResponseInner(MessageParcel & data,MessageParcel & reply)178 int32_t ImsCallCallbackStub::OnHangUpResponseInner(MessageParcel &data, MessageParcel &reply)
179 {
180 int32_t slotId = data.ReadInt32();
181 auto info = static_cast<const HRilRadioResponseInfo *>(data.ReadRawData(sizeof(HRilRadioResponseInfo)));
182 if (info == nullptr) {
183 TELEPHONY_LOGE("[slot%{public}d] info is null.", slotId);
184 return TELEPHONY_ERR_ARGUMENT_INVALID;
185 }
186 reply.WriteInt32(HangUpResponse(slotId, *info));
187 return TELEPHONY_SUCCESS;
188 }
189
OnRejectResponseInner(MessageParcel & data,MessageParcel & reply)190 int32_t ImsCallCallbackStub::OnRejectResponseInner(MessageParcel &data, MessageParcel &reply)
191 {
192 int32_t slotId = data.ReadInt32();
193 auto info = static_cast<const HRilRadioResponseInfo *>(data.ReadRawData(sizeof(HRilRadioResponseInfo)));
194 if (info == nullptr) {
195 TELEPHONY_LOGE("[slot%{public}d] info is null.", slotId);
196 return TELEPHONY_ERR_ARGUMENT_INVALID;
197 }
198 reply.WriteInt32(RejectWithReasonResponse(slotId, *info));
199 return TELEPHONY_SUCCESS;
200 }
201
OnAnswerResponseInner(MessageParcel & data,MessageParcel & reply)202 int32_t ImsCallCallbackStub::OnAnswerResponseInner(MessageParcel &data, MessageParcel &reply)
203 {
204 int32_t slotId = data.ReadInt32();
205 auto info = static_cast<const HRilRadioResponseInfo *>(data.ReadRawData(sizeof(HRilRadioResponseInfo)));
206 if (info == nullptr) {
207 TELEPHONY_LOGE("[slot%{public}d] info is null.", slotId);
208 return TELEPHONY_ERR_ARGUMENT_INVALID;
209 }
210 reply.WriteInt32(AnswerResponse(slotId, *info));
211 return TELEPHONY_SUCCESS;
212 }
213
OnHoldCallResponseInner(MessageParcel & data,MessageParcel & reply)214 int32_t ImsCallCallbackStub::OnHoldCallResponseInner(MessageParcel &data, MessageParcel &reply)
215 {
216 int32_t slotId = data.ReadInt32();
217 auto info = static_cast<const HRilRadioResponseInfo *>(data.ReadRawData(sizeof(HRilRadioResponseInfo)));
218 if (info == nullptr) {
219 TELEPHONY_LOGE("[slot%{public}d] info is null.", slotId);
220 return TELEPHONY_ERR_ARGUMENT_INVALID;
221 }
222 reply.WriteInt32(HoldCallResponse(slotId, *info));
223 return TELEPHONY_SUCCESS;
224 }
225
OnUnHoldCallResponseInner(MessageParcel & data,MessageParcel & reply)226 int32_t ImsCallCallbackStub::OnUnHoldCallResponseInner(MessageParcel &data, MessageParcel &reply)
227 {
228 int32_t slotId = data.ReadInt32();
229 auto info = static_cast<const HRilRadioResponseInfo *>(data.ReadRawData(sizeof(HRilRadioResponseInfo)));
230 if (info == nullptr) {
231 TELEPHONY_LOGE("[slot%{public}d] info is null.", slotId);
232 return TELEPHONY_ERR_ARGUMENT_INVALID;
233 }
234 reply.WriteInt32(UnHoldCallResponse(slotId, *info));
235 return TELEPHONY_SUCCESS;
236 }
237
OnSwitchCallResponseInner(MessageParcel & data,MessageParcel & reply)238 int32_t ImsCallCallbackStub::OnSwitchCallResponseInner(MessageParcel &data, MessageParcel &reply)
239 {
240 int32_t slotId = data.ReadInt32();
241 auto info = static_cast<const HRilRadioResponseInfo *>(data.ReadRawData(sizeof(HRilRadioResponseInfo)));
242 if (info == nullptr) {
243 TELEPHONY_LOGE("[slot%{public}d] info is null.", slotId);
244 return TELEPHONY_ERR_ARGUMENT_INVALID;
245 }
246 reply.WriteInt32(SwitchCallResponse(slotId, *info));
247 return TELEPHONY_SUCCESS;
248 }
249
OnStartDtmfResponseInner(MessageParcel & data,MessageParcel & reply)250 int32_t ImsCallCallbackStub::OnStartDtmfResponseInner(MessageParcel &data, MessageParcel &reply)
251 {
252 int32_t slotId = data.ReadInt32();
253 auto info = static_cast<const HRilRadioResponseInfo *>(data.ReadRawData(sizeof(HRilRadioResponseInfo)));
254 if (info == nullptr) {
255 TELEPHONY_LOGE("[slot%{public}d] info is null.", slotId);
256 return TELEPHONY_ERR_ARGUMENT_INVALID;
257 }
258 reply.WriteInt32(StartDtmfResponse(slotId, *info));
259 return TELEPHONY_SUCCESS;
260 }
261
OnSendDtmfResponseInner(MessageParcel & data,MessageParcel & reply)262 int32_t ImsCallCallbackStub::OnSendDtmfResponseInner(MessageParcel &data, MessageParcel &reply)
263 {
264 int32_t slotId = data.ReadInt32();
265 int32_t callIndex = data.ReadInt32();
266 auto info = static_cast<const HRilRadioResponseInfo *>(data.ReadRawData(sizeof(HRilRadioResponseInfo)));
267 if (info == nullptr) {
268 TELEPHONY_LOGE("[slot%{public}d] info is null.", slotId);
269 return TELEPHONY_ERR_ARGUMENT_INVALID;
270 }
271 reply.WriteInt32(SendDtmfResponse(slotId, *info, callIndex));
272 return TELEPHONY_SUCCESS;
273 }
274
OnStopDtmfResponseInner(MessageParcel & data,MessageParcel & reply)275 int32_t ImsCallCallbackStub::OnStopDtmfResponseInner(MessageParcel &data, MessageParcel &reply)
276 {
277 int32_t slotId = data.ReadInt32();
278 auto info = static_cast<const HRilRadioResponseInfo *>(data.ReadRawData(sizeof(HRilRadioResponseInfo)));
279 if (info == nullptr) {
280 TELEPHONY_LOGE("[slot%{public}d] info is null.", slotId);
281 return TELEPHONY_ERR_ARGUMENT_INVALID;
282 }
283 reply.WriteInt32(StopDtmfResponse(slotId, *info));
284 return TELEPHONY_SUCCESS;
285 }
286
OnCallStateChangeReportInner(MessageParcel & data,MessageParcel & reply)287 int32_t ImsCallCallbackStub::OnCallStateChangeReportInner(MessageParcel &data, MessageParcel &reply)
288 {
289 int32_t slotId = data.ReadInt32();
290 reply.WriteInt32(CallStateChangeReport(slotId));
291 return TELEPHONY_SUCCESS;
292 }
293
OnSetImsSwitchResponseInner(MessageParcel & data,MessageParcel & reply)294 int32_t ImsCallCallbackStub::OnSetImsSwitchResponseInner(MessageParcel &data, MessageParcel &reply)
295 {
296 int32_t slotId = data.ReadInt32();
297 auto info = static_cast<const HRilRadioResponseInfo *>(data.ReadRawData(sizeof(HRilRadioResponseInfo)));
298 if (info == nullptr) {
299 TELEPHONY_LOGE("[slot%{public}d] info is null.", slotId);
300 return TELEPHONY_ERR_ARGUMENT_INVALID;
301 }
302 reply.WriteInt32(SetImsSwitchResponse(slotId, *info));
303 return TELEPHONY_SUCCESS;
304 }
305
OnGetImsSwitchResponseInner(MessageParcel & data,MessageParcel & reply)306 int32_t ImsCallCallbackStub::OnGetImsSwitchResponseInner(MessageParcel &data, MessageParcel &reply)
307 {
308 int32_t slotId = data.ReadInt32();
309 auto info = static_cast<const HRilRadioResponseInfo *>(data.ReadRawData(sizeof(HRilRadioResponseInfo)));
310 if (info == nullptr) {
311 TELEPHONY_LOGE("[slot%{public}d] info is null.", slotId);
312 int32_t active = data.ReadInt32();
313 reply.WriteInt32(GetImsSwitchResponse(slotId, active));
314 return TELEPHONY_SUCCESS;
315 }
316 reply.WriteInt32(GetImsSwitchResponse(slotId, *info));
317 return TELEPHONY_SUCCESS;
318 }
319
OnGetImsCallsDataResponseInner(MessageParcel & data,MessageParcel & reply)320 int32_t ImsCallCallbackStub::OnGetImsCallsDataResponseInner(MessageParcel &data, MessageParcel &reply)
321 {
322 int32_t slotId = data.ReadInt32();
323 auto info = static_cast<const HRilRadioResponseInfo *>(data.ReadRawData(sizeof(HRilRadioResponseInfo)));
324 if (info == nullptr) {
325 TELEPHONY_LOGE("[slot%{public}d] info is null.", slotId);
326 auto callList = std::make_shared<ImsCurrentCallList>();
327 callList->callSize = data.ReadInt32();
328 callList->flag = data.ReadInt32();
329 int32_t len = data.ReadInt32();
330 if (len < 0 || len > MAX_SIZE) {
331 TELEPHONY_LOGE("ImsCallCallbackStub::OnGetImsCallsDataResponseInner callSize error");
332 return TELEPHONY_ERR_FAIL;
333 }
334 for (int32_t i = 0; i < len; i++) {
335 ImsCurrentCall call;
336 call.index = data.ReadInt32();
337 call.dir = data.ReadInt32();
338 call.state = data.ReadInt32();
339 call.mode = data.ReadInt32();
340 call.mpty = data.ReadInt32();
341 call.voiceDomain = data.ReadInt32();
342 call.callType = static_cast<ImsCallType>(data.ReadInt32());
343 data.ReadString(call.number);
344 call.type = data.ReadInt32();
345 data.ReadString(call.alpha);
346 call.toa = data.ReadInt32();
347 call.toneType = data.ReadInt32();
348 call.callInitialType = data.ReadInt32();
349 callList->calls.push_back(call);
350 }
351 reply.WriteInt32(GetImsCallsDataResponse(slotId, *callList));
352 return TELEPHONY_SUCCESS;
353 }
354 reply.WriteInt32(GetImsCallsDataResponse(slotId, *info));
355 return TELEPHONY_SUCCESS;
356 }
357
OnSetMuteResponseInner(MessageParcel & data,MessageParcel & reply)358 int32_t ImsCallCallbackStub::OnSetMuteResponseInner(MessageParcel &data, MessageParcel &reply)
359 {
360 int32_t slotId = data.ReadInt32();
361 auto info = static_cast<const MuteControlResponse *>(data.ReadRawData(sizeof(MuteControlResponse)));
362 if (info == nullptr) {
363 TELEPHONY_LOGE("[slot%{public}d] info is null.", slotId);
364 return TELEPHONY_ERR_ARGUMENT_INVALID;
365 }
366 reply.WriteInt32(SetMuteResponse(slotId, *info));
367 return TELEPHONY_SUCCESS;
368 }
369
OnCallRingBackReportInner(MessageParcel & data,MessageParcel & reply)370 int32_t ImsCallCallbackStub::OnCallRingBackReportInner(MessageParcel &data, MessageParcel &reply)
371 {
372 int32_t slotId = data.ReadInt32();
373 auto info = static_cast<const RingbackVoice *>(data.ReadRawData(sizeof(RingbackVoice)));
374 if (info == nullptr) {
375 TELEPHONY_LOGE("[slot%{public}d] info is null.", slotId);
376 return TELEPHONY_ERR_ARGUMENT_INVALID;
377 }
378 reply.WriteInt32(CallRingBackReport(slotId, *info));
379 return TELEPHONY_SUCCESS;
380 }
381
OnLastCallFailReasonResponseInner(MessageParcel & data,MessageParcel & reply)382 int32_t ImsCallCallbackStub::OnLastCallFailReasonResponseInner(MessageParcel &data, MessageParcel &reply)
383 {
384 int32_t slotId = data.ReadInt32();
385 DisconnectedDetails details;
386 details.reason = static_cast<const DisconnectedReason>(data.ReadInt32());
387 details.message = data.ReadString();
388 reply.WriteInt32(LastCallFailReasonResponse(slotId, details));
389 return TELEPHONY_SUCCESS;
390 }
391
OnSetClipResponseInner(MessageParcel & data,MessageParcel & reply)392 int32_t ImsCallCallbackStub::OnSetClipResponseInner(MessageParcel &data, MessageParcel &reply)
393 {
394 int32_t slotId = data.ReadInt32();
395 SsBaseResult resultInfo;
396 resultInfo.index = data.ReadInt32();
397 resultInfo.result = data.ReadInt32();
398 resultInfo.reason = data.ReadInt32();
399 resultInfo.message = data.ReadString();
400 if (resultInfo.index == INVALID_INDEX) {
401 reply.WriteInt32(TELEPHONY_SUCCESS);
402 } else {
403 reply.WriteInt32(SetClipResponse(slotId, resultInfo));
404 }
405 return TELEPHONY_SUCCESS;
406 }
407
OnGetClipResponseInner(MessageParcel & data,MessageParcel & reply)408 int32_t ImsCallCallbackStub::OnGetClipResponseInner(MessageParcel &data, MessageParcel &reply)
409 {
410 int32_t slotId = data.ReadInt32();
411 GetClipResult result;
412 result.result.index = data.ReadInt32();
413 result.result.result = data.ReadInt32();
414 result.result.reason = data.ReadInt32();
415 result.result.message = data.ReadString();
416 result.action = data.ReadInt32();
417 result.clipStat = data.ReadInt32();
418 if (result.result.index == INVALID_INDEX) {
419 reply.WriteInt32(TELEPHONY_SUCCESS);
420 } else {
421 reply.WriteInt32(GetClipResponse(slotId, result));
422 }
423 return TELEPHONY_SUCCESS;
424 }
425
OnGetClirResponseInner(MessageParcel & data,MessageParcel & reply)426 int32_t ImsCallCallbackStub::OnGetClirResponseInner(MessageParcel &data, MessageParcel &reply)
427 {
428 int32_t slotId = data.ReadInt32();
429 GetClirResult result;
430 result.result.index = data.ReadInt32();
431 result.result.result = data.ReadInt32();
432 result.result.reason = data.ReadInt32();
433 result.result.message = data.ReadString();
434 result.action = data.ReadInt32();
435 result.clirStat = data.ReadInt32();
436 if (result.result.index == INVALID_INDEX) {
437 reply.WriteInt32(TELEPHONY_SUCCESS);
438 } else {
439 reply.WriteInt32(GetClirResponse(slotId, result));
440 }
441 return TELEPHONY_SUCCESS;
442 }
443
OnSetClirResponseInner(MessageParcel & data,MessageParcel & reply)444 int32_t ImsCallCallbackStub::OnSetClirResponseInner(MessageParcel &data, MessageParcel &reply)
445 {
446 int32_t slotId = data.ReadInt32();
447 SsBaseResult resultInfo;
448 resultInfo.index = data.ReadInt32();
449 resultInfo.result = data.ReadInt32();
450 resultInfo.reason = data.ReadInt32();
451 resultInfo.message = data.ReadString();
452 if (resultInfo.index == INVALID_INDEX) {
453 reply.WriteInt32(TELEPHONY_SUCCESS);
454 } else {
455 reply.WriteInt32(SetClirResponse(slotId, resultInfo));
456 }
457 return TELEPHONY_SUCCESS;
458 }
459
OnGetCallTransferResponseInner(MessageParcel & data,MessageParcel & reply)460 int32_t ImsCallCallbackStub::OnGetCallTransferResponseInner(MessageParcel &data, MessageParcel &reply)
461 {
462 int32_t slotId = data.ReadInt32();
463 auto cFQueryList = std::make_shared<CallForwardQueryInfoList>();
464 cFQueryList->result.index = data.ReadInt32();
465 cFQueryList->result.result = data.ReadInt32();
466 cFQueryList->result.reason = data.ReadInt32();
467 data.ReadString(cFQueryList->result.message);
468 cFQueryList->callSize = data.ReadInt32();
469 cFQueryList->flag = data.ReadInt32();
470 int32_t len = data.ReadInt32();
471 if (len < 0 || len > MAX_SIZE) {
472 TELEPHONY_LOGE("ImsCallCallbackStub::OnGetCallTransferResponseInner callSize error");
473 return TELEPHONY_ERR_FAIL;
474 }
475 for (int32_t i = 0; i < len; i++) {
476 CallForwardQueryResult call;
477 call.serial = data.ReadInt32();
478 call.result = data.ReadInt32();
479 call.status = data.ReadInt32();
480 call.classx = data.ReadInt32();
481 data.ReadString(call.number);
482 call.type = data.ReadInt32();
483 call.reason = data.ReadInt32();
484 call.time = data.ReadInt32();
485 call.startHour = data.ReadInt32();
486 call.startMinute = data.ReadInt32();
487 call.endHour = data.ReadInt32();
488 call.endMinute = data.ReadInt32();
489 cFQueryList->calls.push_back(call);
490 }
491 if (cFQueryList->result.index == INVALID_INDEX) {
492 reply.WriteInt32(TELEPHONY_SUCCESS);
493 } else {
494 reply.WriteInt32(GetCallTransferResponse(slotId, *cFQueryList));
495 }
496 return TELEPHONY_SUCCESS;
497 }
498
OnSetCallTransferResponseInner(MessageParcel & data,MessageParcel & reply)499 int32_t ImsCallCallbackStub::OnSetCallTransferResponseInner(MessageParcel &data, MessageParcel &reply)
500 {
501 int32_t slotId = data.ReadInt32();
502 SsBaseResult resultInfo;
503 resultInfo.index = data.ReadInt32();
504 resultInfo.result = data.ReadInt32();
505 resultInfo.reason = data.ReadInt32();
506 resultInfo.message = data.ReadString();
507 if (resultInfo.index == INVALID_INDEX) {
508 reply.WriteInt32(TELEPHONY_SUCCESS);
509 } else {
510 reply.WriteInt32(SetCallTransferResponse(slotId, resultInfo));
511 }
512 return TELEPHONY_SUCCESS;
513 }
514
OnGetCallRestrictionResponseInner(MessageParcel & data,MessageParcel & reply)515 int32_t ImsCallCallbackStub::OnGetCallRestrictionResponseInner(MessageParcel &data, MessageParcel &reply)
516 {
517 int32_t slotId = data.ReadInt32();
518 CallRestrictionResult result;
519 result.result.index = data.ReadInt32();
520 result.result.result = data.ReadInt32();
521 result.result.reason = data.ReadInt32();
522 result.result.message = data.ReadString();
523 result.status = data.ReadInt32();
524 result.classCw = data.ReadInt32();
525 if (result.result.index == INVALID_INDEX) {
526 reply.WriteInt32(TELEPHONY_SUCCESS);
527 } else {
528 reply.WriteInt32(GetCallRestrictionResponse(slotId, result));
529 }
530 return TELEPHONY_SUCCESS;
531 }
532
OnSetCallRestrictionResponseInner(MessageParcel & data,MessageParcel & reply)533 int32_t ImsCallCallbackStub::OnSetCallRestrictionResponseInner(MessageParcel &data, MessageParcel &reply)
534 {
535 int32_t slotId = data.ReadInt32();
536 SsBaseResult resultInfo;
537 resultInfo.index = data.ReadInt32();
538 resultInfo.result = data.ReadInt32();
539 resultInfo.reason = data.ReadInt32();
540 resultInfo.message = data.ReadString();
541 if (resultInfo.index == INVALID_INDEX) {
542 reply.WriteInt32(TELEPHONY_SUCCESS);
543 } else {
544 reply.WriteInt32(SetCallRestrictionResponse(slotId, resultInfo));
545 }
546 return TELEPHONY_SUCCESS;
547 }
548
OnGetCallWaitingResponseInner(MessageParcel & data,MessageParcel & reply)549 int32_t ImsCallCallbackStub::OnGetCallWaitingResponseInner(MessageParcel &data, MessageParcel &reply)
550 {
551 int32_t slotId = data.ReadInt32();
552 CallWaitResult result;
553 result.result.index = data.ReadInt32();
554 result.result.result = data.ReadInt32();
555 result.result.reason = data.ReadInt32();
556 result.result.message = data.ReadString();
557 result.status = data.ReadInt32();
558 result.classCw = data.ReadInt32();
559 if (result.result.index == INVALID_INDEX) {
560 reply.WriteInt32(TELEPHONY_SUCCESS);
561 } else {
562 reply.WriteInt32(GetCallWaitingResponse(slotId, result));
563 }
564 return TELEPHONY_SUCCESS;
565 }
566
OnSetCallWaitingResponseInner(MessageParcel & data,MessageParcel & reply)567 int32_t ImsCallCallbackStub::OnSetCallWaitingResponseInner(MessageParcel &data, MessageParcel &reply)
568 {
569 int32_t slotId = data.ReadInt32();
570 SsBaseResult resultInfo;
571 resultInfo.index = data.ReadInt32();
572 resultInfo.result = data.ReadInt32();
573 resultInfo.reason = data.ReadInt32();
574 resultInfo.message = data.ReadString();
575 if (resultInfo.index == INVALID_INDEX) {
576 reply.WriteInt32(TELEPHONY_SUCCESS);
577 } else {
578 reply.WriteInt32(SetCallWaitingResponse(slotId, resultInfo));
579 }
580 return TELEPHONY_SUCCESS;
581 }
582
OnSetColrResponseInner(MessageParcel & data,MessageParcel & reply)583 int32_t ImsCallCallbackStub::OnSetColrResponseInner(MessageParcel &data, MessageParcel &reply)
584 {
585 int32_t slotId = data.ReadInt32();
586 SsBaseResult resultInfo;
587 resultInfo.index = data.ReadInt32();
588 resultInfo.result = data.ReadInt32();
589 resultInfo.reason = data.ReadInt32();
590 resultInfo.message = data.ReadString();
591 if (resultInfo.index == INVALID_INDEX) {
592 reply.WriteInt32(TELEPHONY_SUCCESS);
593 } else {
594 reply.WriteInt32(SetColrResponse(slotId, resultInfo));
595 }
596 return TELEPHONY_SUCCESS;
597 }
598
OnGetColrResponseInner(MessageParcel & data,MessageParcel & reply)599 int32_t ImsCallCallbackStub::OnGetColrResponseInner(MessageParcel &data, MessageParcel &reply)
600 {
601 int32_t slotId = data.ReadInt32();
602 GetColrResult result;
603 result.result.index = data.ReadInt32();
604 result.result.result = data.ReadInt32();
605 result.result.reason = data.ReadInt32();
606 result.result.message = data.ReadString();
607 result.action = data.ReadInt32();
608 result.colrStat = data.ReadInt32();
609 if (result.result.index == INVALID_INDEX) {
610 reply.WriteInt32(TELEPHONY_SUCCESS);
611 } else {
612 reply.WriteInt32(GetColrResponse(slotId, result));
613 }
614 return TELEPHONY_SUCCESS;
615 }
616
OnSetColpResponseInner(MessageParcel & data,MessageParcel & reply)617 int32_t ImsCallCallbackStub::OnSetColpResponseInner(MessageParcel &data, MessageParcel &reply)
618 {
619 int32_t slotId = data.ReadInt32();
620 SsBaseResult resultInfo;
621 resultInfo.index = data.ReadInt32();
622 resultInfo.result = data.ReadInt32();
623 resultInfo.reason = data.ReadInt32();
624 resultInfo.message = data.ReadString();
625 if (resultInfo.index == INVALID_INDEX) {
626 reply.WriteInt32(TELEPHONY_SUCCESS);
627 } else {
628 reply.WriteInt32(SetColpResponse(slotId, resultInfo));
629 }
630 return TELEPHONY_SUCCESS;
631 }
632
OnGetColpResponseInner(MessageParcel & data,MessageParcel & reply)633 int32_t ImsCallCallbackStub::OnGetColpResponseInner(MessageParcel &data, MessageParcel &reply)
634 {
635 int32_t slotId = data.ReadInt32();
636 GetColpResult result;
637 result.result.index = data.ReadInt32();
638 result.result.result = data.ReadInt32();
639 result.result.reason = data.ReadInt32();
640 result.result.message = data.ReadString();
641 result.action = data.ReadInt32();
642 result.colpStat = data.ReadInt32();
643 if (result.result.index == INVALID_INDEX) {
644 reply.WriteInt32(TELEPHONY_SUCCESS);
645 } else {
646 reply.WriteInt32(GetColpResponse(slotId, result));
647 }
648 return TELEPHONY_SUCCESS;
649 }
650
OnCombineConferenceResponseInner(MessageParcel & data,MessageParcel & reply)651 int32_t ImsCallCallbackStub::OnCombineConferenceResponseInner(MessageParcel &data, MessageParcel &reply)
652 {
653 int32_t slotId = data.ReadInt32();
654 auto info = static_cast<const HRilRadioResponseInfo *>(data.ReadRawData(sizeof(HRilRadioResponseInfo)));
655 if (info == nullptr) {
656 TELEPHONY_LOGE("[slot%{public}d] info is null.", slotId);
657 return TELEPHONY_ERR_ARGUMENT_INVALID;
658 }
659 reply.WriteInt32(CombineConferenceResponse(slotId, *info));
660 return TELEPHONY_SUCCESS;
661 }
662
OnInviteToConferenceResponseInner(MessageParcel & data,MessageParcel & reply)663 int32_t ImsCallCallbackStub::OnInviteToConferenceResponseInner(MessageParcel &data, MessageParcel &reply)
664 {
665 int32_t slotId = data.ReadInt32();
666 auto info = static_cast<const HRilRadioResponseInfo *>(data.ReadRawData(sizeof(HRilRadioResponseInfo)));
667 if (info == nullptr) {
668 TELEPHONY_LOGE("[slot%{public}d] info is null.", slotId);
669 return TELEPHONY_ERR_ARGUMENT_INVALID;
670 }
671 reply.WriteInt32(InviteToConferenceResponse(slotId, *info));
672 return TELEPHONY_SUCCESS;
673 }
674
OnReceiveUpdateCallMediaModeRequestInner(MessageParcel & data,MessageParcel & reply)675 int32_t ImsCallCallbackStub::OnReceiveUpdateCallMediaModeRequestInner(MessageParcel &data, MessageParcel &reply)
676 {
677 int32_t slotId = data.ReadInt32();
678 auto info = static_cast<const ImsCallModeReceiveInfo *>(data.ReadRawData(sizeof(ImsCallModeReceiveInfo)));
679 if (info == nullptr) {
680 TELEPHONY_LOGE("[slot%{public}d] info is null.", slotId);
681 return TELEPHONY_ERR_ARGUMENT_INVALID;
682 }
683 reply.WriteInt32(ReceiveUpdateCallMediaModeRequest(slotId, *info));
684 return TELEPHONY_SUCCESS;
685 }
686
OnReceiveUpdateCallMediaModeResponseInner(MessageParcel & data,MessageParcel & reply)687 int32_t ImsCallCallbackStub::OnReceiveUpdateCallMediaModeResponseInner(MessageParcel &data, MessageParcel &reply)
688 {
689 int32_t slotId = data.ReadInt32();
690 auto info = static_cast<const ImsCallModeReceiveInfo *>(data.ReadRawData(sizeof(ImsCallModeReceiveInfo)));
691 if (info == nullptr) {
692 TELEPHONY_LOGE("[slot%{public}d] info is null.", slotId);
693 return TELEPHONY_ERR_ARGUMENT_INVALID;
694 }
695 reply.WriteInt32(ReceiveUpdateCallMediaModeResponse(slotId, *info));
696 return TELEPHONY_SUCCESS;
697 }
698
OnCallSessionEventChangedInner(MessageParcel & data,MessageParcel & reply)699 int32_t ImsCallCallbackStub::OnCallSessionEventChangedInner(MessageParcel &data, MessageParcel &reply)
700 {
701 int32_t slotId = data.ReadInt32();
702 auto info = static_cast<const ImsCallSessionEventInfo *>(data.ReadRawData(sizeof(ImsCallSessionEventInfo)));
703 if (info == nullptr) {
704 TELEPHONY_LOGE("[slot%{public}d] info is null.", slotId);
705 return TELEPHONY_ERR_ARGUMENT_INVALID;
706 }
707 reply.WriteInt32(CallSessionEventChanged(slotId, *info));
708 return TELEPHONY_SUCCESS;
709 }
710
OnPeerDimensionsChangedInner(MessageParcel & data,MessageParcel & reply)711 int32_t ImsCallCallbackStub::OnPeerDimensionsChangedInner(MessageParcel &data, MessageParcel &reply)
712 {
713 int32_t slotId = data.ReadInt32();
714 auto info = static_cast<const ImsCallPeerDimensionsInfo *>(data.ReadRawData(sizeof(ImsCallPeerDimensionsInfo)));
715 if (info == nullptr) {
716 TELEPHONY_LOGE("[slot%{public}d] info is null.", slotId);
717 return TELEPHONY_ERR_ARGUMENT_INVALID;
718 }
719 reply.WriteInt32(PeerDimensionsChanged(slotId, *info));
720 return TELEPHONY_SUCCESS;
721 }
722
OnCallDataUsageChangedInner(MessageParcel & data,MessageParcel & reply)723 int32_t ImsCallCallbackStub::OnCallDataUsageChangedInner(MessageParcel &data, MessageParcel &reply)
724 {
725 int32_t slotId = data.ReadInt32();
726 auto info = static_cast<const ImsCallDataUsageInfo *>(data.ReadRawData(sizeof(ImsCallDataUsageInfo)));
727 if (info == nullptr) {
728 TELEPHONY_LOGE("[slot%{public}d] info is null.", slotId);
729 return TELEPHONY_ERR_ARGUMENT_INVALID;
730 }
731 reply.WriteInt32(CallDataUsageChanged(slotId, *info));
732 return TELEPHONY_SUCCESS;
733 }
734
OnCameraCapabilitiesChangedInner(MessageParcel & data,MessageParcel & reply)735 int32_t ImsCallCallbackStub::OnCameraCapabilitiesChangedInner(MessageParcel &data, MessageParcel &reply)
736 {
737 int32_t slotId = data.ReadInt32();
738 auto info = static_cast<const CameraCapabilitiesInfo *>(data.ReadRawData(sizeof(CameraCapabilitiesInfo)));
739 if (info == nullptr) {
740 TELEPHONY_LOGE("[slot%{public}d] info is null.", slotId);
741 return TELEPHONY_ERR_ARGUMENT_INVALID;
742 }
743 reply.WriteInt32(CameraCapabilitiesChanged(slotId, *info));
744 return TELEPHONY_SUCCESS;
745 }
746
DialResponse(int32_t slotId,const HRilRadioResponseInfo & info)747 int32_t ImsCallCallbackStub::DialResponse(int32_t slotId, const HRilRadioResponseInfo &info)
748 {
749 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
750 return SendEvent(slotId, RadioEvent::RADIO_DIAL, info);
751 }
752
HangUpResponse(int32_t slotId,const HRilRadioResponseInfo & info)753 int32_t ImsCallCallbackStub::HangUpResponse(int32_t slotId, const HRilRadioResponseInfo &info)
754 {
755 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
756 return SendEvent(slotId, RadioEvent::RADIO_HANGUP_CONNECT, info);
757 }
758
RejectWithReasonResponse(int32_t slotId,const HRilRadioResponseInfo & info)759 int32_t ImsCallCallbackStub::RejectWithReasonResponse(int32_t slotId, const HRilRadioResponseInfo &info)
760 {
761 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
762 return SendEvent(slotId, RadioEvent::RADIO_REJECT_CALL, info);
763 }
764
AnswerResponse(int32_t slotId,const HRilRadioResponseInfo & info)765 int32_t ImsCallCallbackStub::AnswerResponse(int32_t slotId, const HRilRadioResponseInfo &info)
766 {
767 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
768 return SendEvent(slotId, RadioEvent::RADIO_ACCEPT_CALL, info);
769 }
770
HoldCallResponse(int32_t slotId,const HRilRadioResponseInfo & info)771 int32_t ImsCallCallbackStub::HoldCallResponse(int32_t slotId, const HRilRadioResponseInfo &info)
772 {
773 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
774 return SendEvent(slotId, RadioEvent::RADIO_HOLD_CALL, info);
775 }
776
UnHoldCallResponse(int32_t slotId,const HRilRadioResponseInfo & info)777 int32_t ImsCallCallbackStub::UnHoldCallResponse(int32_t slotId, const HRilRadioResponseInfo &info)
778 {
779 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
780 return SendEvent(slotId, RadioEvent::RADIO_ACTIVE_CALL, info);
781 }
782
SwitchCallResponse(int32_t slotId,const HRilRadioResponseInfo & info)783 int32_t ImsCallCallbackStub::SwitchCallResponse(int32_t slotId, const HRilRadioResponseInfo &info)
784 {
785 auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
786 if (handler == nullptr) {
787 TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
788 return TELEPHONY_ERR_LOCAL_PTR_NULL;
789 }
790 std::shared_ptr<HRilRadioResponseInfo> responseInfo = std::make_shared<HRilRadioResponseInfo>();
791 *responseInfo = info;
792 AppExecFwk::InnerEvent::Pointer response =
793 AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_SWAP_CALL, responseInfo, IMS_CALL);
794 bool ret = TelEventHandler::SendTelEvent(handler, response);
795 if (!ret) {
796 TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
797 return TELEPHONY_ERR_FAIL;
798 }
799 return TELEPHONY_SUCCESS;
800 }
801
StartDtmfResponse(int32_t slotId,const HRilRadioResponseInfo & info)802 int32_t ImsCallCallbackStub::StartDtmfResponse(int32_t slotId, const HRilRadioResponseInfo &info)
803 {
804 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
805 return SendEvent(slotId, RadioEvent::RADIO_START_DTMF, info);
806 }
807
SendDtmfResponse(int32_t slotId,const HRilRadioResponseInfo & info,int32_t callIndex)808 int32_t ImsCallCallbackStub::SendDtmfResponse(int32_t slotId, const HRilRadioResponseInfo &info, int32_t callIndex)
809 {
810 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
811 auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
812 if (handler == nullptr) {
813 TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
814 return TELEPHONY_ERR_LOCAL_PTR_NULL;
815 }
816 std::shared_ptr<HRilRadioResponseInfo> responseInfo = std::make_shared<HRilRadioResponseInfo>();
817
818 *responseInfo = info;
819 responseInfo->flag = callIndex;
820 AppExecFwk::InnerEvent::Pointer response =
821 AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_SEND_DTMF, responseInfo, IMS_CALL);
822 bool ret = TelEventHandler::SendTelEvent(handler, response);
823 if (!ret) {
824 TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
825 return TELEPHONY_ERR_FAIL;
826 }
827 return TELEPHONY_SUCCESS;
828 }
829
StopDtmfResponse(int32_t slotId,const HRilRadioResponseInfo & info)830 int32_t ImsCallCallbackStub::StopDtmfResponse(int32_t slotId, const HRilRadioResponseInfo &info)
831 {
832 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
833 return SendEvent(slotId, RadioEvent::RADIO_STOP_DTMF, info);
834 }
835
CallStateChangeReport(int32_t slotId)836 int32_t ImsCallCallbackStub::CallStateChangeReport(int32_t slotId)
837 {
838 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
839 auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
840 if (handler == nullptr) {
841 TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
842 return TELEPHONY_ERR_LOCAL_PTR_NULL;
843 }
844
845 bool ret = TelEventHandler::SendTelEvent(handler, RadioEvent::RADIO_IMS_CALL_STATUS_INFO);
846 if (!ret) {
847 TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
848 return TELEPHONY_ERR_FAIL;
849 }
850 return TELEPHONY_SUCCESS;
851 }
852
GetImsCallsDataResponse(int32_t slotId,const HRilRadioResponseInfo & info)853 int32_t ImsCallCallbackStub::GetImsCallsDataResponse(int32_t slotId, const HRilRadioResponseInfo &info)
854 {
855 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
856 return SendEvent(slotId, RadioEvent::RADIO_IMS_GET_CALL_DATA, info);
857 }
858
GetImsCallsDataResponse(int32_t slotId,const ImsCurrentCallList & callList)859 int32_t ImsCallCallbackStub::GetImsCallsDataResponse(int32_t slotId, const ImsCurrentCallList &callList)
860 {
861 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
862 auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
863 if (handler == nullptr) {
864 TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
865 return TELEPHONY_ERR_LOCAL_PTR_NULL;
866 }
867 auto imsCurrentCallList = std::make_shared<ImsCurrentCallList>();
868 *imsCurrentCallList = callList;
869 bool ret = TelEventHandler::SendTelEvent(handler, RadioEvent::RADIO_IMS_GET_CALL_DATA, imsCurrentCallList);
870 if (!ret) {
871 TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
872 return TELEPHONY_ERR_FAIL;
873 }
874 return TELEPHONY_SUCCESS;
875 }
876
SetImsSwitchResponse(int32_t slotId,const HRilRadioResponseInfo & info)877 int32_t ImsCallCallbackStub::SetImsSwitchResponse(int32_t slotId, const HRilRadioResponseInfo &info)
878 {
879 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
880 return SendEvent(slotId, RadioEvent::RADIO_SET_IMS_SWITCH_STATUS, info);
881 }
882
GetImsSwitchResponse(int32_t slotId,const HRilRadioResponseInfo & info)883 int32_t ImsCallCallbackStub::GetImsSwitchResponse(int32_t slotId, const HRilRadioResponseInfo &info)
884 {
885 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
886 return SendEvent(slotId, RadioEvent::RADIO_GET_IMS_SWITCH_STATUS, info);
887 }
888
GetImsSwitchResponse(int32_t slotId,int32_t active)889 int32_t ImsCallCallbackStub::GetImsSwitchResponse(int32_t slotId, int32_t active)
890 {
891 TELEPHONY_LOGI("[slot%{public}d] entry active:%{public}d", slotId, active);
892 auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
893 if (handler == nullptr || handler.get() == nullptr) {
894 TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
895 return TELEPHONY_ERR_LOCAL_PTR_NULL;
896 }
897 TelEventHandler::SendTelEvent(handler, RadioEvent::RADIO_GET_IMS_SWITCH_STATUS, active);
898 return TELEPHONY_SUCCESS;
899 }
900
SetMuteResponse(int32_t slotId,const MuteControlResponse & response)901 int32_t ImsCallCallbackStub::SetMuteResponse(int32_t slotId, const MuteControlResponse &response)
902 {
903 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
904 return TELEPHONY_SUCCESS;
905 }
906
CallRingBackReport(int32_t slotId,const RingbackVoice & info)907 int32_t ImsCallCallbackStub::CallRingBackReport(int32_t slotId, const RingbackVoice &info)
908 {
909 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
910 auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
911 if (handler == nullptr) {
912 TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
913 return TELEPHONY_ERR_LOCAL_PTR_NULL;
914 }
915 auto ringbackVoice = std::make_shared<RingbackVoice>();
916 *ringbackVoice = info;
917 bool ret = TelEventHandler::SendTelEvent(handler, RadioEvent::RADIO_CALL_RINGBACK_VOICE, ringbackVoice);
918 if (!ret) {
919 TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
920 return TELEPHONY_ERR_FAIL;
921 }
922 return TELEPHONY_SUCCESS;
923 }
924
LastCallFailReasonResponse(int32_t slotId,const DisconnectedDetails & details)925 int32_t ImsCallCallbackStub::LastCallFailReasonResponse(int32_t slotId, const DisconnectedDetails &details)
926 {
927 TELEPHONY_LOGI("[slot%{public}d] entry, reason is %{public}d", slotId, details.reason);
928 auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
929 if (handler == nullptr) {
930 TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
931 return TELEPHONY_ERR_LOCAL_PTR_NULL;
932 }
933 std::shared_ptr<DisconnectedDetails> detailsInfo = std::make_shared<DisconnectedDetails>();
934 detailsInfo->reason = details.reason;
935 detailsInfo->message = details.message;
936 CellularCallConfig config;
937 auto vecReasonInfo = config.GetImsCallDisconnectResoninfoMappingConfig(slotId);
938 for (auto reasonInfo : vecReasonInfo) {
939 char *p = nullptr;
940 char *ptr = nullptr;
941 ptr = strtok_r((char *)(reasonInfo.c_str()), "|", &p);
942 int32_t tmpReason = (int32_t)std::atoi(ptr);
943 int flag = false;
944 while (tmpReason == static_cast<int32_t>(detailsInfo->reason)) {
945 ptr = strtok_r(nullptr, "|", &p);
946 if (ptr == nullptr) {
947 break;
948 }
949 if (!flag) {
950 detailsInfo->message = ptr;
951 flag = true;
952 } else {
953 detailsInfo->reason = static_cast<DisconnectedReason>(std::atoi(ptr));
954 }
955 }
956 if (flag) {
957 break;
958 }
959 }
960 bool ret = TelEventHandler::SendTelEvent(handler, RadioEvent::RADIO_GET_CALL_FAIL_REASON, detailsInfo);
961 if (!ret) {
962 TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
963 return TELEPHONY_ERR_FAIL;
964 }
965 return TELEPHONY_SUCCESS;
966 }
967
SetClipResponse(int32_t slotId,const SsBaseResult & resultInfo)968 int32_t ImsCallCallbackStub::SetClipResponse(int32_t slotId, const SsBaseResult &resultInfo)
969 {
970 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
971 return SendEvent(slotId, RadioEvent::RADIO_SET_CALL_CLIP, resultInfo);
972 }
973
GetClipResponse(int32_t slotId,const GetClipResult & result)974 int32_t ImsCallCallbackStub::GetClipResponse(int32_t slotId, const GetClipResult &result)
975 {
976 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
977 // CS fall back when IMS return failed
978 if (result.result.result == IMS_ERROR_UT_CS_FALLBACK) {
979 SupplementRequestCs supplementRequest;
980 return supplementRequest.GetClipRequest(slotId, result.result.index);
981 }
982 auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
983 if (handler == nullptr) {
984 TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
985 return TELEPHONY_ERR_LOCAL_PTR_NULL;
986 }
987 auto clipResponse = std::make_shared<GetClipResult>();
988 clipResponse->action = result.action;
989 clipResponse->clipStat = result.clipStat;
990 clipResponse->result.index = result.result.index;
991 clipResponse->result.result = result.result.result;
992 clipResponse->result.reason = result.result.reason;
993 clipResponse->result.message = result.result.message;
994 AppExecFwk::InnerEvent::Pointer response =
995 AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_GET_CALL_CLIP, clipResponse, result.result.index);
996 bool ret = TelEventHandler::SendTelEvent(handler, response);
997 if (!ret) {
998 TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
999 return TELEPHONY_ERR_FAIL;
1000 }
1001 return TELEPHONY_SUCCESS;
1002 }
1003
GetClirResponse(int32_t slotId,const GetClirResult & result)1004 int32_t ImsCallCallbackStub::GetClirResponse(int32_t slotId, const GetClirResult &result)
1005 {
1006 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1007 // CS fall back when IMS return failed
1008 if (result.result.result == IMS_ERROR_UT_CS_FALLBACK) {
1009 SupplementRequestCs supplementRequest;
1010 return supplementRequest.GetClirRequest(slotId, result.result.index);
1011 }
1012 auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
1013 if (handler == nullptr) {
1014 TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
1015 return TELEPHONY_ERR_LOCAL_PTR_NULL;
1016 }
1017 auto clirResponse = std::make_shared<GetClirResult>();
1018 clirResponse->action = result.action;
1019 clirResponse->clirStat = result.clirStat;
1020 clirResponse->result.index = result.result.index;
1021 clirResponse->result.result = result.result.result;
1022 clirResponse->result.reason = result.result.reason;
1023 clirResponse->result.message = result.result.message;
1024 AppExecFwk::InnerEvent::Pointer response =
1025 AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_GET_CALL_CLIR, clirResponse, result.result.index);
1026 bool ret = TelEventHandler::SendTelEvent(handler, response);
1027 if (!ret) {
1028 TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
1029 return TELEPHONY_ERR_FAIL;
1030 }
1031 return TELEPHONY_SUCCESS;
1032 }
1033
SetClirResponse(int32_t slotId,const SsBaseResult & resultInfo)1034 int32_t ImsCallCallbackStub::SetClirResponse(int32_t slotId, const SsBaseResult &resultInfo)
1035 {
1036 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1037 // CS fall back when IMS return failed
1038 if (resultInfo.result == IMS_ERROR_UT_CS_FALLBACK) {
1039 SupplementRequestCs supplementRequest;
1040 SsRequestCommand ss;
1041 int32_t ret = GetSsRequestCommand(slotId, resultInfo.index, ss);
1042 if (ret != TELEPHONY_SUCCESS) {
1043 TELEPHONY_LOGI("[slot%{public}d] cs fall back error since haven't found the ss command", slotId);
1044 return ret;
1045 }
1046 return supplementRequest.SetClirRequest(slotId, ss.clirAction, resultInfo.index);
1047 }
1048 return SendEvent(slotId, RadioEvent::RADIO_SET_CALL_CLIR, resultInfo);
1049 }
1050
GetCallTransferResponse(int32_t slotId,const CallForwardQueryInfoList & cFQueryList)1051 int32_t ImsCallCallbackStub::GetCallTransferResponse(int32_t slotId, const CallForwardQueryInfoList &cFQueryList)
1052 {
1053 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1054 // CS fall back when IMS return failed
1055 if (cFQueryList.result.result == IMS_ERROR_UT_CS_FALLBACK) {
1056 SsRequestCommand ss;
1057 int32_t ret = GetSsRequestCommand(slotId, cFQueryList.result.index, ss);
1058 if (ret != TELEPHONY_SUCCESS) {
1059 TELEPHONY_LOGI("[slot%{public}d] cs fall back error since haven't found the ss command", slotId);
1060 return ret;
1061 }
1062 SupplementRequestCs supplementRequest;
1063 return supplementRequest.GetCallTransferRequest(slotId, ss.cfReason, cFQueryList.result.index);
1064 }
1065 auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
1066 if (handler == nullptr) {
1067 TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
1068 return TELEPHONY_ERR_LOCAL_PTR_NULL;
1069 }
1070 auto callTransferResponse = std::make_shared<CallForwardQueryInfoList>();
1071 BuildCallForwardInfo(cFQueryList, *callTransferResponse);
1072 AppExecFwk::InnerEvent::Pointer response =
1073 AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_GET_CALL_FORWARD, callTransferResponse, cFQueryList.result.index);
1074 bool ret = TelEventHandler::SendTelEvent(handler, response);
1075 if (!ret) {
1076 TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
1077 return TELEPHONY_ERR_FAIL;
1078 }
1079 return TELEPHONY_SUCCESS;
1080 }
1081
SetCallTransferResponse(int32_t slotId,const SsBaseResult & resultInfo)1082 int32_t ImsCallCallbackStub::SetCallTransferResponse(int32_t slotId, const SsBaseResult &resultInfo)
1083 {
1084 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1085 // CS fall back when IMS return failed
1086 if (resultInfo.result == IMS_ERROR_UT_CS_FALLBACK) {
1087 SsRequestCommand ss;
1088 int32_t ret = GetSsRequestCommand(slotId, resultInfo.index, ss);
1089 if (ret != TELEPHONY_SUCCESS) {
1090 TELEPHONY_LOGI("[slot%{public}d] cs fall back error since haven't found the ss command", slotId);
1091 return ret;
1092 }
1093 SupplementRequestCs supplementRequest;
1094 CallTransferParam callTransferParam;
1095 callTransferParam.mode = ss.cfAction;
1096 callTransferParam.reason = ss.cfReason;
1097 callTransferParam.number = ss.number;
1098 callTransferParam.classx = ss.classType;
1099 return supplementRequest.SetCallTransferRequest(slotId, callTransferParam, resultInfo.index);
1100 }
1101 return SendEvent(slotId, RadioEvent::RADIO_SET_CALL_FORWARD, resultInfo);
1102 }
1103
GetCallRestrictionResponse(int32_t slotId,const CallRestrictionResult & result)1104 int32_t ImsCallCallbackStub::GetCallRestrictionResponse(int32_t slotId, const CallRestrictionResult &result)
1105 {
1106 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1107 if (result.result.result == IMS_ERROR_UT_CS_FALLBACK) {
1108 SsRequestCommand ss;
1109 int32_t ret = GetSsRequestCommand(slotId, result.result.index, ss);
1110 if (ret != TELEPHONY_SUCCESS) {
1111 TELEPHONY_LOGI("[slot%{public}d] cs fall back error since haven't found the ss command", slotId);
1112 return ret;
1113 }
1114 const std::string fac = ss.facility;
1115 SupplementRequestCs supplementRequest;
1116 return supplementRequest.GetCallRestrictionRequest(slotId, fac, result.result.index);
1117 }
1118 auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
1119 if (handler == nullptr) {
1120 TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
1121 return TELEPHONY_ERR_LOCAL_PTR_NULL;
1122 }
1123 auto callRestrictionResponse = std::make_shared<CallRestrictionResult>();
1124 callRestrictionResponse->status = result.status;
1125 callRestrictionResponse->classCw = result.classCw;
1126 callRestrictionResponse->result.result = result.result.result;
1127 callRestrictionResponse->result.index = result.result.index;
1128 callRestrictionResponse->result.reason = result.result.reason;
1129 callRestrictionResponse->result.message = result.result.message;
1130 AppExecFwk::InnerEvent::Pointer response = AppExecFwk::InnerEvent::Get(
1131 RadioEvent::RADIO_GET_CALL_RESTRICTION, callRestrictionResponse, result.result.index);
1132 bool ret = TelEventHandler::SendTelEvent(handler, response);
1133 if (!ret) {
1134 TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
1135 return TELEPHONY_ERR_FAIL;
1136 }
1137 return TELEPHONY_SUCCESS;
1138 }
1139
SetCallRestrictionResponse(int32_t slotId,const SsBaseResult & resultInfo)1140 int32_t ImsCallCallbackStub::SetCallRestrictionResponse(int32_t slotId, const SsBaseResult &resultInfo)
1141 {
1142 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1143 // CS fall back when IMS return failed
1144 if (resultInfo.result == IMS_ERROR_UT_CS_FALLBACK) {
1145 SsRequestCommand ss;
1146 int32_t ret = GetSsRequestCommand(slotId, resultInfo.index, ss);
1147 if (ret != TELEPHONY_SUCCESS) {
1148 TELEPHONY_LOGI("[slot%{public}d] cs fall bacK error since haven't found the ss command", slotId);
1149 return ret;
1150 }
1151 SupplementRequestCs supplementRequest;
1152 return supplementRequest.SetCallRestrictionRequest(
1153 slotId, ss.facility, ss.enable, ss.password, resultInfo.index);
1154 }
1155 return SendEvent(slotId, RadioEvent::RADIO_SET_CALL_RESTRICTION, resultInfo);
1156 }
1157
GetCallWaitingResponse(int32_t slotId,const CallWaitResult & result)1158 int32_t ImsCallCallbackStub::GetCallWaitingResponse(int32_t slotId, const CallWaitResult &result)
1159 {
1160 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1161 // CS fall back when IMS return failed
1162 if (result.result.result == IMS_ERROR_UT_CS_FALLBACK) {
1163 SupplementRequestCs supplementRequest;
1164 return supplementRequest.GetCallWaitingRequest(slotId, result.result.index);
1165 }
1166 auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
1167 if (handler == nullptr) {
1168 TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
1169 return TELEPHONY_ERR_LOCAL_PTR_NULL;
1170 }
1171 auto callWaitResponse = std::make_shared<CallWaitResult>();
1172 callWaitResponse->status = result.status;
1173 callWaitResponse->classCw = result.classCw;
1174 callWaitResponse->result.result = result.result.result;
1175 callWaitResponse->result.index = result.result.index;
1176 callWaitResponse->result.reason = result.result.reason;
1177 callWaitResponse->result.message = result.result.message;
1178 AppExecFwk::InnerEvent::Pointer response =
1179 AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_GET_CALL_WAIT, callWaitResponse, result.result.index);
1180 bool ret = TelEventHandler::SendTelEvent(handler, response);
1181 if (!ret) {
1182 TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
1183 return TELEPHONY_ERR_FAIL;
1184 }
1185 return TELEPHONY_SUCCESS;
1186 }
1187
SetCallWaitingResponse(int32_t slotId,const SsBaseResult & resultInfo)1188 int32_t ImsCallCallbackStub::SetCallWaitingResponse(int32_t slotId, const SsBaseResult &resultInfo)
1189 {
1190 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1191 // CS fall back when IMS return failed
1192 if (resultInfo.result == IMS_ERROR_UT_CS_FALLBACK) {
1193 SsRequestCommand ss;
1194 int32_t ret = GetSsRequestCommand(slotId, resultInfo.index, ss);
1195 if (ret != TELEPHONY_SUCCESS) {
1196 TELEPHONY_LOGI("[slot%{public}d] cs fall back error since haven't found the ss command", slotId);
1197 return ret;
1198 }
1199 SupplementRequestCs supplementRequest;
1200 return supplementRequest.SetCallWaitingRequest(slotId, ss.enable, ss.classType, resultInfo.index);
1201 }
1202 return SendEvent(slotId, RadioEvent::RADIO_SET_CALL_WAIT, resultInfo);
1203 }
1204
SetColrResponse(int32_t slotId,const SsBaseResult & resultInfo)1205 int32_t ImsCallCallbackStub::SetColrResponse(int32_t slotId, const SsBaseResult &resultInfo)
1206 {
1207 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1208 return SendEvent(slotId, RadioEvent::RADIO_IMS_SET_COLR, resultInfo);
1209 }
1210
GetColrResponse(int32_t slotId,const GetColrResult & result)1211 int32_t ImsCallCallbackStub::GetColrResponse(int32_t slotId, const GetColrResult &result)
1212 {
1213 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1214 auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
1215 if (handler == nullptr) {
1216 TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
1217 return TELEPHONY_ERR_LOCAL_PTR_NULL;
1218 }
1219 auto colrResponse = std::make_shared<GetColrResult>();
1220 colrResponse->action = result.action;
1221 colrResponse->colrStat = result.colrStat;
1222 colrResponse->result.result = result.result.result;
1223 colrResponse->result.index = result.result.index;
1224 colrResponse->result.reason = result.result.reason;
1225 colrResponse->result.message = result.result.message;
1226 AppExecFwk::InnerEvent::Pointer response =
1227 AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_IMS_GET_COLR, colrResponse, result.result.index);
1228 bool ret = TelEventHandler::SendTelEvent(handler, response);
1229 if (!ret) {
1230 TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
1231 return TELEPHONY_ERR_FAIL;
1232 }
1233 return TELEPHONY_SUCCESS;
1234 }
1235
SetColpResponse(int32_t slotId,const SsBaseResult & resultInfo)1236 int32_t ImsCallCallbackStub::SetColpResponse(int32_t slotId, const SsBaseResult &resultInfo)
1237 {
1238 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1239 return SendEvent(slotId, RadioEvent::RADIO_IMS_SET_COLP, resultInfo);
1240 }
1241
GetColpResponse(int32_t slotId,const GetColpResult & result)1242 int32_t ImsCallCallbackStub::GetColpResponse(int32_t slotId, const GetColpResult &result)
1243 {
1244 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1245 auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
1246 if (handler == nullptr) {
1247 TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
1248 return TELEPHONY_ERR_LOCAL_PTR_NULL;
1249 }
1250 auto colpResponse = std::make_shared<GetColpResult>();
1251 colpResponse->action = result.action;
1252 colpResponse->colpStat = result.colpStat;
1253 colpResponse->result.result = result.result.result;
1254 colpResponse->result.index = result.result.index;
1255 colpResponse->result.reason = result.result.reason;
1256 colpResponse->result.message = result.result.message;
1257 AppExecFwk::InnerEvent::Pointer response =
1258 AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_IMS_GET_COLP, colpResponse, result.result.index);
1259 bool ret = TelEventHandler::SendTelEvent(handler, response);
1260 if (!ret) {
1261 TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
1262 return TELEPHONY_ERR_FAIL;
1263 }
1264 return TELEPHONY_SUCCESS;
1265 }
1266
CombineConferenceResponse(int32_t slotId,const HRilRadioResponseInfo & info)1267 int32_t ImsCallCallbackStub::CombineConferenceResponse(int32_t slotId, const HRilRadioResponseInfo &info)
1268 {
1269 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1270 return SendEvent(slotId, RadioEvent::RADIO_COMBINE_CALL, info);
1271 }
1272
InviteToConferenceResponse(int32_t slotId,const HRilRadioResponseInfo & info)1273 int32_t ImsCallCallbackStub::InviteToConferenceResponse(int32_t slotId, const HRilRadioResponseInfo &info)
1274 {
1275 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1276 return SendEvent(slotId, RadioEvent::RADIO_JOIN_CALL, info);
1277 }
1278
ReceiveUpdateCallMediaModeRequest(int32_t slotId,const ImsCallModeReceiveInfo & callModeRequest)1279 int32_t ImsCallCallbackStub::ReceiveUpdateCallMediaModeRequest(
1280 int32_t slotId, const ImsCallModeReceiveInfo &callModeRequest)
1281 {
1282 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1283 return SendEvent(slotId, RadioEvent::RADIO_RECV_CALL_MEDIA_MODE_REQUEST, callModeRequest);
1284 }
1285
ReceiveUpdateCallMediaModeResponse(int32_t slotId,const ImsCallModeReceiveInfo & callModeResponse)1286 int32_t ImsCallCallbackStub::ReceiveUpdateCallMediaModeResponse(
1287 int32_t slotId, const ImsCallModeReceiveInfo &callModeResponse)
1288 {
1289 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1290 return SendEvent(slotId, RadioEvent::RADIO_RECV_CALL_MEDIA_MODE_RESPONSE, callModeResponse);
1291 }
1292
CallSessionEventChanged(int32_t slotId,const ImsCallSessionEventInfo & callSessionEventInfo)1293 int32_t ImsCallCallbackStub::CallSessionEventChanged(
1294 int32_t slotId, const ImsCallSessionEventInfo &callSessionEventInfo)
1295 {
1296 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1297 auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
1298 if (handler == nullptr) {
1299 TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
1300 return TELEPHONY_ERR_LOCAL_PTR_NULL;
1301 }
1302 std::shared_ptr<ImsCallSessionEventInfo> responseInfo = std::make_shared<ImsCallSessionEventInfo>();
1303 *responseInfo = callSessionEventInfo;
1304 bool ret = TelEventHandler::SendTelEvent(handler, RadioEvent::RADIO_CALL_SESSION_EVENT_CHANGED, responseInfo);
1305 if (!ret) {
1306 TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
1307 return TELEPHONY_ERR_FAIL;
1308 }
1309 return TELEPHONY_SUCCESS;
1310 }
1311
PeerDimensionsChanged(int32_t slotId,const ImsCallPeerDimensionsInfo & callPeerDimensionsInfo)1312 int32_t ImsCallCallbackStub::PeerDimensionsChanged(
1313 int32_t slotId, const ImsCallPeerDimensionsInfo &callPeerDimensionsInfo)
1314 {
1315 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1316 auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
1317 if (handler == nullptr) {
1318 TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
1319 return TELEPHONY_ERR_LOCAL_PTR_NULL;
1320 }
1321 std::shared_ptr<ImsCallPeerDimensionsInfo> responseInfo = std::make_shared<ImsCallPeerDimensionsInfo>();
1322 *responseInfo = callPeerDimensionsInfo;
1323 bool ret = TelEventHandler::SendTelEvent(handler, RadioEvent::RADIO_CALL_PEER_DIMENSIONS_CHANGED, responseInfo);
1324 if (!ret) {
1325 TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
1326 return TELEPHONY_ERR_FAIL;
1327 }
1328 return TELEPHONY_SUCCESS;
1329 }
1330
CallDataUsageChanged(int32_t slotId,const ImsCallDataUsageInfo & callDataUsageInfo)1331 int32_t ImsCallCallbackStub::CallDataUsageChanged(int32_t slotId, const ImsCallDataUsageInfo &callDataUsageInfo)
1332 {
1333 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1334 auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
1335 if (handler == nullptr) {
1336 TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
1337 return TELEPHONY_ERR_LOCAL_PTR_NULL;
1338 }
1339 std::shared_ptr<ImsCallDataUsageInfo> responseInfo = std::make_shared<ImsCallDataUsageInfo>();
1340 *responseInfo = callDataUsageInfo;
1341 bool ret = TelEventHandler::SendTelEvent(handler, RadioEvent::RADIO_CALL_DATA_USAGE_CHANGED, responseInfo);
1342 if (!ret) {
1343 TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
1344 return TELEPHONY_ERR_FAIL;
1345 }
1346 return TELEPHONY_SUCCESS;
1347 }
1348
CameraCapabilitiesChanged(int32_t slotId,const CameraCapabilitiesInfo & cameraCapabilitiesInfo)1349 int32_t ImsCallCallbackStub::CameraCapabilitiesChanged(
1350 int32_t slotId, const CameraCapabilitiesInfo &cameraCapabilitiesInfo)
1351 {
1352 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1353 auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
1354 if (handler == nullptr) {
1355 TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
1356 return TELEPHONY_ERR_LOCAL_PTR_NULL;
1357 }
1358 std::shared_ptr<CameraCapabilitiesInfo> responseInfo = std::make_shared<CameraCapabilitiesInfo>();
1359 *responseInfo = cameraCapabilitiesInfo;
1360 bool ret = TelEventHandler::SendTelEvent(handler, RadioEvent::RADIO_CAMERA_CAPABILITIES_CHANGED, responseInfo);
1361 if (!ret) {
1362 TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
1363 return TELEPHONY_ERR_FAIL;
1364 }
1365 return TELEPHONY_SUCCESS;
1366 }
1367
GetSsRequestCommand(int32_t slotId,int32_t index,SsRequestCommand & ss)1368 int32_t ImsCallCallbackStub::GetSsRequestCommand(int32_t slotId, int32_t index, SsRequestCommand &ss)
1369 {
1370 auto handler = DelayedSingleton<CellularCallService>::GetInstance()->GetHandler(slotId);
1371 if (handler == nullptr) {
1372 TELEPHONY_LOGE("[slot%{public}d] handler is null!", slotId);
1373 return TELEPHONY_ERR_LOCAL_PTR_NULL;
1374 }
1375 return handler->GetSsRequestCommand(index, ss);
1376 }
1377
BuildCallForwardInfo(const CallForwardQueryInfoList & cFQueryList,CallForwardQueryInfoList & cFQueryResultList)1378 void ImsCallCallbackStub::BuildCallForwardInfo(
1379 const CallForwardQueryInfoList &cFQueryList, CallForwardQueryInfoList &cFQueryResultList)
1380 {
1381 cFQueryResultList.callSize = cFQueryList.callSize;
1382 for (auto info : cFQueryList.calls) {
1383 CallForwardQueryResult call;
1384 call.serial = info.serial;
1385 call.result = info.result;
1386 call.status = info.status;
1387 call.classx = info.classx;
1388 call.number = info.number;
1389 call.type = info.type;
1390 call.reason = info.reason;
1391 call.time = info.time;
1392 call.startHour = info.startHour;
1393 call.startMinute = info.startMinute;
1394 call.endHour = info.endHour;
1395 call.endMinute = info.endMinute;
1396 cFQueryResultList.calls.push_back(call);
1397 }
1398 cFQueryResultList.result.result = cFQueryList.result.result;
1399 cFQueryResultList.result.index = cFQueryList.result.index;
1400 cFQueryResultList.result.reason = cFQueryList.result.reason;
1401 cFQueryResultList.result.message = cFQueryList.result.message;
1402 }
1403
SendEvent(int32_t slotId,int32_t eventId,const HRilRadioResponseInfo & info)1404 int32_t ImsCallCallbackStub::SendEvent(int32_t slotId, int32_t eventId, const HRilRadioResponseInfo &info)
1405 {
1406 auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
1407 if (handler == nullptr) {
1408 TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
1409 return TELEPHONY_ERR_LOCAL_PTR_NULL;
1410 }
1411 std::shared_ptr<HRilRadioResponseInfo> responseInfo = std::make_shared<HRilRadioResponseInfo>();
1412 *responseInfo = info;
1413 bool ret = TelEventHandler::SendTelEvent(handler, eventId, responseInfo);
1414 if (!ret) {
1415 TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
1416 return TELEPHONY_ERR_FAIL;
1417 }
1418 return TELEPHONY_SUCCESS;
1419 }
1420
SendEvent(int32_t slotId,int32_t eventId,const SsBaseResult & resultInfo)1421 int32_t ImsCallCallbackStub::SendEvent(int32_t slotId, int32_t eventId, const SsBaseResult &resultInfo)
1422 {
1423 auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
1424 if (handler == nullptr) {
1425 TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
1426 return TELEPHONY_ERR_LOCAL_PTR_NULL;
1427 }
1428 auto ssResponseInfo = std::make_shared<SsBaseResult>();
1429 ssResponseInfo->result = resultInfo.result;
1430 ssResponseInfo->index = resultInfo.index;
1431 ssResponseInfo->reason = resultInfo.reason;
1432 ssResponseInfo->message = resultInfo.message;
1433 AppExecFwk::InnerEvent::Pointer response = AppExecFwk::InnerEvent::Get(eventId, ssResponseInfo, resultInfo.index);
1434 bool ret = TelEventHandler::SendTelEvent(handler, response);
1435 if (!ret) {
1436 TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
1437 return TELEPHONY_ERR_FAIL;
1438 }
1439 return TELEPHONY_SUCCESS;
1440 }
1441
SendEvent(int32_t slotId,int32_t eventId,const ImsCallModeReceiveInfo & callModeInfo)1442 int32_t ImsCallCallbackStub::SendEvent(int32_t slotId, int32_t eventId, const ImsCallModeReceiveInfo &callModeInfo)
1443 {
1444 auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
1445 if (handler == nullptr) {
1446 TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
1447 return TELEPHONY_ERR_LOCAL_PTR_NULL;
1448 }
1449 std::shared_ptr<ImsCallModeReceiveInfo> info = std::make_shared<ImsCallModeReceiveInfo>();
1450 *info = callModeInfo;
1451 bool ret = TelEventHandler::SendTelEvent(handler, eventId, info);
1452 if (!ret) {
1453 TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
1454 return TELEPHONY_ERR_FAIL;
1455 }
1456 return TELEPHONY_SUCCESS;
1457 }
1458 } // namespace Telephony
1459 } // namespace OHOS
1460