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