• 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             call.newCallUseBox = data.ReadInt32();
358             callList->calls.push_back(call);
359         }
360         reply.WriteInt32(GetImsCallsDataResponse(slotId, *callList));
361         return TELEPHONY_SUCCESS;
362     }
363     reply.WriteInt32(GetImsCallsDataResponse(slotId, *info));
364     return TELEPHONY_SUCCESS;
365 }
366 
OnSetMuteResponseInner(MessageParcel & data,MessageParcel & reply)367 int32_t ImsCallCallbackStub::OnSetMuteResponseInner(MessageParcel &data, MessageParcel &reply)
368 {
369     int32_t slotId = data.ReadInt32();
370     auto info = static_cast<const MuteControlResponse *>(data.ReadRawData(sizeof(MuteControlResponse)));
371     if (info == nullptr) {
372         TELEPHONY_LOGE("[slot%{public}d] info is null.", slotId);
373         return TELEPHONY_ERR_ARGUMENT_INVALID;
374     }
375     reply.WriteInt32(SetMuteResponse(slotId, *info));
376     return TELEPHONY_SUCCESS;
377 }
378 
OnCallRingBackReportInner(MessageParcel & data,MessageParcel & reply)379 int32_t ImsCallCallbackStub::OnCallRingBackReportInner(MessageParcel &data, MessageParcel &reply)
380 {
381     int32_t slotId = data.ReadInt32();
382     auto info = static_cast<const RingbackVoice *>(data.ReadRawData(sizeof(RingbackVoice)));
383     if (info == nullptr) {
384         TELEPHONY_LOGE("[slot%{public}d] info is null.", slotId);
385         return TELEPHONY_ERR_ARGUMENT_INVALID;
386     }
387     reply.WriteInt32(CallRingBackReport(slotId, *info));
388     return TELEPHONY_SUCCESS;
389 }
390 
OnLastCallFailReasonResponseInner(MessageParcel & data,MessageParcel & reply)391 int32_t ImsCallCallbackStub::OnLastCallFailReasonResponseInner(MessageParcel &data, MessageParcel &reply)
392 {
393     int32_t slotId = data.ReadInt32();
394     DisconnectedDetails details;
395     details.reason = static_cast<const DisconnectedReason>(data.ReadInt32());
396     details.message = data.ReadString();
397     reply.WriteInt32(LastCallFailReasonResponse(slotId, details));
398     return TELEPHONY_SUCCESS;
399 }
400 
OnSetClipResponseInner(MessageParcel & data,MessageParcel & reply)401 int32_t ImsCallCallbackStub::OnSetClipResponseInner(MessageParcel &data, MessageParcel &reply)
402 {
403     int32_t slotId = data.ReadInt32();
404     SsBaseResult resultInfo;
405     resultInfo.index = data.ReadInt32();
406     resultInfo.result = data.ReadInt32();
407     resultInfo.reason = data.ReadInt32();
408     resultInfo.message = data.ReadString();
409     if (resultInfo.index == INVALID_INDEX) {
410         reply.WriteInt32(TELEPHONY_SUCCESS);
411     } else {
412         reply.WriteInt32(SetClipResponse(slotId, resultInfo));
413     }
414     return TELEPHONY_SUCCESS;
415 }
416 
OnGetClipResponseInner(MessageParcel & data,MessageParcel & reply)417 int32_t ImsCallCallbackStub::OnGetClipResponseInner(MessageParcel &data, MessageParcel &reply)
418 {
419     int32_t slotId = data.ReadInt32();
420     GetClipResult result;
421     result.result.index = data.ReadInt32();
422     result.result.result = data.ReadInt32();
423     result.result.reason = data.ReadInt32();
424     result.result.message = data.ReadString();
425     result.action = data.ReadInt32();
426     result.clipStat = data.ReadInt32();
427     if (result.result.index == INVALID_INDEX) {
428         reply.WriteInt32(TELEPHONY_SUCCESS);
429     } else {
430         reply.WriteInt32(GetClipResponse(slotId, result));
431     }
432     return TELEPHONY_SUCCESS;
433 }
434 
OnGetClirResponseInner(MessageParcel & data,MessageParcel & reply)435 int32_t ImsCallCallbackStub::OnGetClirResponseInner(MessageParcel &data, MessageParcel &reply)
436 {
437     int32_t slotId = data.ReadInt32();
438     GetClirResult result;
439     result.result.index = data.ReadInt32();
440     result.result.result = data.ReadInt32();
441     result.result.reason = data.ReadInt32();
442     result.result.message = data.ReadString();
443     result.action = data.ReadInt32();
444     result.clirStat = data.ReadInt32();
445     if (result.result.index == INVALID_INDEX) {
446         reply.WriteInt32(TELEPHONY_SUCCESS);
447     } else {
448         reply.WriteInt32(GetClirResponse(slotId, result));
449     }
450     return TELEPHONY_SUCCESS;
451 }
452 
OnSetClirResponseInner(MessageParcel & data,MessageParcel & reply)453 int32_t ImsCallCallbackStub::OnSetClirResponseInner(MessageParcel &data, MessageParcel &reply)
454 {
455     int32_t slotId = data.ReadInt32();
456     SsBaseResult resultInfo;
457     resultInfo.index = data.ReadInt32();
458     resultInfo.result = data.ReadInt32();
459     resultInfo.reason = data.ReadInt32();
460     resultInfo.message = data.ReadString();
461     if (resultInfo.index == INVALID_INDEX) {
462         reply.WriteInt32(TELEPHONY_SUCCESS);
463     } else {
464         reply.WriteInt32(SetClirResponse(slotId, resultInfo));
465     }
466     return TELEPHONY_SUCCESS;
467 }
468 
OnGetCallTransferResponseInner(MessageParcel & data,MessageParcel & reply)469 int32_t ImsCallCallbackStub::OnGetCallTransferResponseInner(MessageParcel &data, MessageParcel &reply)
470 {
471     int32_t slotId = data.ReadInt32();
472     auto cFQueryList = std::make_shared<CallForwardQueryInfoList>();
473     cFQueryList->result.index = data.ReadInt32();
474     cFQueryList->result.result = data.ReadInt32();
475     cFQueryList->result.reason = data.ReadInt32();
476     data.ReadString(cFQueryList->result.message);
477     cFQueryList->callSize = data.ReadInt32();
478     cFQueryList->flag = data.ReadInt32();
479     int32_t len = data.ReadInt32();
480     if (len < 0 || len > MAX_SIZE) {
481         TELEPHONY_LOGE("ImsCallCallbackStub::OnGetCallTransferResponseInner callSize error");
482         return TELEPHONY_ERR_FAIL;
483     }
484     for (int32_t i = 0; i < len; i++) {
485         CallForwardQueryResult call;
486         call.serial = data.ReadInt32();
487         call.result = data.ReadInt32();
488         call.status = data.ReadInt32();
489         call.classx = data.ReadInt32();
490         data.ReadString(call.number);
491         call.type = data.ReadInt32();
492         call.reason = data.ReadInt32();
493         call.time = data.ReadInt32();
494         call.startHour = data.ReadInt32();
495         call.startMinute = data.ReadInt32();
496         call.endHour = data.ReadInt32();
497         call.endMinute = data.ReadInt32();
498         cFQueryList->calls.push_back(call);
499     }
500     if (cFQueryList->result.index == INVALID_INDEX) {
501         reply.WriteInt32(TELEPHONY_SUCCESS);
502     } else {
503         reply.WriteInt32(GetCallTransferResponse(slotId, *cFQueryList));
504     }
505     return TELEPHONY_SUCCESS;
506 }
507 
OnSetCallTransferResponseInner(MessageParcel & data,MessageParcel & reply)508 int32_t ImsCallCallbackStub::OnSetCallTransferResponseInner(MessageParcel &data, MessageParcel &reply)
509 {
510     int32_t slotId = data.ReadInt32();
511     SsBaseResult resultInfo;
512     resultInfo.index = data.ReadInt32();
513     resultInfo.result = data.ReadInt32();
514     resultInfo.reason = data.ReadInt32();
515     resultInfo.message = data.ReadString();
516     if (resultInfo.index == INVALID_INDEX) {
517         reply.WriteInt32(TELEPHONY_SUCCESS);
518     } else {
519         reply.WriteInt32(SetCallTransferResponse(slotId, resultInfo));
520     }
521     return TELEPHONY_SUCCESS;
522 }
523 
OnGetCallRestrictionResponseInner(MessageParcel & data,MessageParcel & reply)524 int32_t ImsCallCallbackStub::OnGetCallRestrictionResponseInner(MessageParcel &data, MessageParcel &reply)
525 {
526     int32_t slotId = data.ReadInt32();
527     CallRestrictionResult result;
528     result.result.index = data.ReadInt32();
529     result.result.result = data.ReadInt32();
530     result.result.reason = data.ReadInt32();
531     result.result.message = data.ReadString();
532     result.status = data.ReadInt32();
533     result.classCw = data.ReadInt32();
534     if (result.result.index == INVALID_INDEX) {
535         reply.WriteInt32(TELEPHONY_SUCCESS);
536     } else {
537         reply.WriteInt32(GetCallRestrictionResponse(slotId, result));
538     }
539     return TELEPHONY_SUCCESS;
540 }
541 
OnSetCallRestrictionResponseInner(MessageParcel & data,MessageParcel & reply)542 int32_t ImsCallCallbackStub::OnSetCallRestrictionResponseInner(MessageParcel &data, MessageParcel &reply)
543 {
544     int32_t slotId = data.ReadInt32();
545     SsBaseResult resultInfo;
546     resultInfo.index = data.ReadInt32();
547     resultInfo.result = data.ReadInt32();
548     resultInfo.reason = data.ReadInt32();
549     resultInfo.message = data.ReadString();
550     if (resultInfo.index == INVALID_INDEX) {
551         reply.WriteInt32(TELEPHONY_SUCCESS);
552     } else {
553         reply.WriteInt32(SetCallRestrictionResponse(slotId, resultInfo));
554     }
555     return TELEPHONY_SUCCESS;
556 }
557 
OnGetCallWaitingResponseInner(MessageParcel & data,MessageParcel & reply)558 int32_t ImsCallCallbackStub::OnGetCallWaitingResponseInner(MessageParcel &data, MessageParcel &reply)
559 {
560     int32_t slotId = data.ReadInt32();
561     CallWaitResult result;
562     result.result.index = data.ReadInt32();
563     result.result.result = data.ReadInt32();
564     result.result.reason = data.ReadInt32();
565     result.result.message = data.ReadString();
566     result.status = data.ReadInt32();
567     result.classCw = data.ReadInt32();
568     if (result.result.index == INVALID_INDEX) {
569         reply.WriteInt32(TELEPHONY_SUCCESS);
570     } else {
571         reply.WriteInt32(GetCallWaitingResponse(slotId, result));
572     }
573     return TELEPHONY_SUCCESS;
574 }
575 
OnSetCallWaitingResponseInner(MessageParcel & data,MessageParcel & reply)576 int32_t ImsCallCallbackStub::OnSetCallWaitingResponseInner(MessageParcel &data, MessageParcel &reply)
577 {
578     int32_t slotId = data.ReadInt32();
579     SsBaseResult resultInfo;
580     resultInfo.index = data.ReadInt32();
581     resultInfo.result = data.ReadInt32();
582     resultInfo.reason = data.ReadInt32();
583     resultInfo.message = data.ReadString();
584     if (resultInfo.index == INVALID_INDEX) {
585         reply.WriteInt32(TELEPHONY_SUCCESS);
586     } else {
587         reply.WriteInt32(SetCallWaitingResponse(slotId, resultInfo));
588     }
589     return TELEPHONY_SUCCESS;
590 }
591 
OnSetColrResponseInner(MessageParcel & data,MessageParcel & reply)592 int32_t ImsCallCallbackStub::OnSetColrResponseInner(MessageParcel &data, MessageParcel &reply)
593 {
594     int32_t slotId = data.ReadInt32();
595     SsBaseResult resultInfo;
596     resultInfo.index = data.ReadInt32();
597     resultInfo.result = data.ReadInt32();
598     resultInfo.reason = data.ReadInt32();
599     resultInfo.message = data.ReadString();
600     if (resultInfo.index == INVALID_INDEX) {
601         reply.WriteInt32(TELEPHONY_SUCCESS);
602     } else {
603         reply.WriteInt32(SetColrResponse(slotId, resultInfo));
604     }
605     return TELEPHONY_SUCCESS;
606 }
607 
OnGetColrResponseInner(MessageParcel & data,MessageParcel & reply)608 int32_t ImsCallCallbackStub::OnGetColrResponseInner(MessageParcel &data, MessageParcel &reply)
609 {
610     int32_t slotId = data.ReadInt32();
611     GetColrResult result;
612     result.result.index = data.ReadInt32();
613     result.result.result = data.ReadInt32();
614     result.result.reason = data.ReadInt32();
615     result.result.message = data.ReadString();
616     result.action = data.ReadInt32();
617     result.colrStat = data.ReadInt32();
618     if (result.result.index == INVALID_INDEX) {
619         reply.WriteInt32(TELEPHONY_SUCCESS);
620     } else {
621         reply.WriteInt32(GetColrResponse(slotId, result));
622     }
623     return TELEPHONY_SUCCESS;
624 }
625 
OnSetColpResponseInner(MessageParcel & data,MessageParcel & reply)626 int32_t ImsCallCallbackStub::OnSetColpResponseInner(MessageParcel &data, MessageParcel &reply)
627 {
628     int32_t slotId = data.ReadInt32();
629     SsBaseResult resultInfo;
630     resultInfo.index = data.ReadInt32();
631     resultInfo.result = data.ReadInt32();
632     resultInfo.reason = data.ReadInt32();
633     resultInfo.message = data.ReadString();
634     if (resultInfo.index == INVALID_INDEX) {
635         reply.WriteInt32(TELEPHONY_SUCCESS);
636     } else {
637         reply.WriteInt32(SetColpResponse(slotId, resultInfo));
638     }
639     return TELEPHONY_SUCCESS;
640 }
641 
OnGetColpResponseInner(MessageParcel & data,MessageParcel & reply)642 int32_t ImsCallCallbackStub::OnGetColpResponseInner(MessageParcel &data, MessageParcel &reply)
643 {
644     int32_t slotId = data.ReadInt32();
645     GetColpResult result;
646     result.result.index = data.ReadInt32();
647     result.result.result = data.ReadInt32();
648     result.result.reason = data.ReadInt32();
649     result.result.message = data.ReadString();
650     result.action = data.ReadInt32();
651     result.colpStat = data.ReadInt32();
652     if (result.result.index == INVALID_INDEX) {
653         reply.WriteInt32(TELEPHONY_SUCCESS);
654     } else {
655         reply.WriteInt32(GetColpResponse(slotId, result));
656     }
657     return TELEPHONY_SUCCESS;
658 }
659 
OnCombineConferenceResponseInner(MessageParcel & data,MessageParcel & reply)660 int32_t ImsCallCallbackStub::OnCombineConferenceResponseInner(MessageParcel &data, MessageParcel &reply)
661 {
662     int32_t slotId = data.ReadInt32();
663     auto info = static_cast<const RadioResponseInfo *>(data.ReadRawData(sizeof(RadioResponseInfo)));
664     if (info == nullptr) {
665         TELEPHONY_LOGE("[slot%{public}d] info is null.", slotId);
666         return TELEPHONY_ERR_ARGUMENT_INVALID;
667     }
668     reply.WriteInt32(CombineConferenceResponse(slotId, *info));
669     return TELEPHONY_SUCCESS;
670 }
671 
OnInviteToConferenceResponseInner(MessageParcel & data,MessageParcel & reply)672 int32_t ImsCallCallbackStub::OnInviteToConferenceResponseInner(MessageParcel &data, MessageParcel &reply)
673 {
674     int32_t slotId = data.ReadInt32();
675     auto info = static_cast<const RadioResponseInfo *>(data.ReadRawData(sizeof(RadioResponseInfo)));
676     if (info == nullptr) {
677         TELEPHONY_LOGE("[slot%{public}d] info is null.", slotId);
678         return TELEPHONY_ERR_ARGUMENT_INVALID;
679     }
680     reply.WriteInt32(InviteToConferenceResponse(slotId, *info));
681     return TELEPHONY_SUCCESS;
682 }
683 
OnReceiveUpdateCallMediaModeRequestInner(MessageParcel & data,MessageParcel & reply)684 int32_t ImsCallCallbackStub::OnReceiveUpdateCallMediaModeRequestInner(MessageParcel &data, MessageParcel &reply)
685 {
686     int32_t slotId = data.ReadInt32();
687     auto info = static_cast<const ImsCallModeReceiveInfo *>(data.ReadRawData(sizeof(ImsCallModeReceiveInfo)));
688     if (info == nullptr) {
689         TELEPHONY_LOGE("[slot%{public}d] info is null.", slotId);
690         return TELEPHONY_ERR_ARGUMENT_INVALID;
691     }
692     reply.WriteInt32(ReceiveUpdateCallMediaModeRequest(slotId, *info));
693     return TELEPHONY_SUCCESS;
694 }
695 
OnReceiveUpdateCallMediaModeResponseInner(MessageParcel & data,MessageParcel & reply)696 int32_t ImsCallCallbackStub::OnReceiveUpdateCallMediaModeResponseInner(MessageParcel &data, MessageParcel &reply)
697 {
698     int32_t slotId = data.ReadInt32();
699     auto info = static_cast<const ImsCallModeReceiveInfo *>(data.ReadRawData(sizeof(ImsCallModeReceiveInfo)));
700     if (info == nullptr) {
701         TELEPHONY_LOGE("[slot%{public}d] info is null.", slotId);
702         return TELEPHONY_ERR_ARGUMENT_INVALID;
703     }
704     reply.WriteInt32(ReceiveUpdateCallMediaModeResponse(slotId, *info));
705     return TELEPHONY_SUCCESS;
706 }
707 
OnCallSessionEventChangedInner(MessageParcel & data,MessageParcel & reply)708 int32_t ImsCallCallbackStub::OnCallSessionEventChangedInner(MessageParcel &data, MessageParcel &reply)
709 {
710     int32_t slotId = data.ReadInt32();
711     auto info = static_cast<const ImsCallSessionEventInfo *>(data.ReadRawData(sizeof(ImsCallSessionEventInfo)));
712     if (info == nullptr) {
713         TELEPHONY_LOGE("[slot%{public}d] info is null.", slotId);
714         return TELEPHONY_ERR_ARGUMENT_INVALID;
715     }
716     reply.WriteInt32(CallSessionEventChanged(slotId, *info));
717     return TELEPHONY_SUCCESS;
718 }
719 
OnPeerDimensionsChangedInner(MessageParcel & data,MessageParcel & reply)720 int32_t ImsCallCallbackStub::OnPeerDimensionsChangedInner(MessageParcel &data, MessageParcel &reply)
721 {
722     int32_t slotId = data.ReadInt32();
723     auto info = static_cast<const ImsCallPeerDimensionsInfo *>(data.ReadRawData(sizeof(ImsCallPeerDimensionsInfo)));
724     if (info == nullptr) {
725         TELEPHONY_LOGE("[slot%{public}d] info is null.", slotId);
726         return TELEPHONY_ERR_ARGUMENT_INVALID;
727     }
728     reply.WriteInt32(PeerDimensionsChanged(slotId, *info));
729     return TELEPHONY_SUCCESS;
730 }
731 
OnCallDataUsageChangedInner(MessageParcel & data,MessageParcel & reply)732 int32_t ImsCallCallbackStub::OnCallDataUsageChangedInner(MessageParcel &data, MessageParcel &reply)
733 {
734     int32_t slotId = data.ReadInt32();
735     auto info = static_cast<const ImsCallDataUsageInfo *>(data.ReadRawData(sizeof(ImsCallDataUsageInfo)));
736     if (info == nullptr) {
737         TELEPHONY_LOGE("[slot%{public}d] info is null.", slotId);
738         return TELEPHONY_ERR_ARGUMENT_INVALID;
739     }
740     reply.WriteInt32(CallDataUsageChanged(slotId, *info));
741     return TELEPHONY_SUCCESS;
742 }
743 
OnCameraCapabilitiesChangedInner(MessageParcel & data,MessageParcel & reply)744 int32_t ImsCallCallbackStub::OnCameraCapabilitiesChangedInner(MessageParcel &data, MessageParcel &reply)
745 {
746     int32_t slotId = data.ReadInt32();
747     auto info = static_cast<const CameraCapabilitiesInfo *>(data.ReadRawData(sizeof(CameraCapabilitiesInfo)));
748     if (info == nullptr) {
749         TELEPHONY_LOGE("[slot%{public}d] info is null.", slotId);
750         return TELEPHONY_ERR_ARGUMENT_INVALID;
751     }
752     reply.WriteInt32(CameraCapabilitiesChanged(slotId, *info));
753     return TELEPHONY_SUCCESS;
754 }
755 
DialResponse(int32_t slotId,const RadioResponseInfo & info)756 int32_t ImsCallCallbackStub::DialResponse(int32_t slotId, const RadioResponseInfo &info)
757 {
758     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
759     return SendEvent(slotId, RadioEvent::RADIO_DIAL, info);
760 }
761 
HangUpResponse(int32_t slotId,const RadioResponseInfo & info)762 int32_t ImsCallCallbackStub::HangUpResponse(int32_t slotId, const RadioResponseInfo &info)
763 {
764     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
765     return SendEvent(slotId, RadioEvent::RADIO_HANGUP_CONNECT, info);
766 }
767 
RejectWithReasonResponse(int32_t slotId,const RadioResponseInfo & info)768 int32_t ImsCallCallbackStub::RejectWithReasonResponse(int32_t slotId, const RadioResponseInfo &info)
769 {
770     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
771     return SendEvent(slotId, RadioEvent::RADIO_REJECT_CALL, info);
772 }
773 
AnswerResponse(int32_t slotId,const RadioResponseInfo & info)774 int32_t ImsCallCallbackStub::AnswerResponse(int32_t slotId, const RadioResponseInfo &info)
775 {
776     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
777     return SendEvent(slotId, RadioEvent::RADIO_ACCEPT_CALL, info);
778 }
779 
HoldCallResponse(int32_t slotId,const RadioResponseInfo & info)780 int32_t ImsCallCallbackStub::HoldCallResponse(int32_t slotId, const RadioResponseInfo &info)
781 {
782     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
783     return SendEvent(slotId, RadioEvent::RADIO_HOLD_CALL, info);
784 }
785 
UnHoldCallResponse(int32_t slotId,const RadioResponseInfo & info)786 int32_t ImsCallCallbackStub::UnHoldCallResponse(int32_t slotId, const RadioResponseInfo &info)
787 {
788     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
789     return SendEvent(slotId, RadioEvent::RADIO_ACTIVE_CALL, info);
790 }
791 
SwitchCallResponse(int32_t slotId,const RadioResponseInfo & info)792 int32_t ImsCallCallbackStub::SwitchCallResponse(int32_t slotId, const RadioResponseInfo &info)
793 {
794     auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
795     if (handler == nullptr) {
796         TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
797         return TELEPHONY_ERR_LOCAL_PTR_NULL;
798     }
799     std::shared_ptr<RadioResponseInfo> responseInfo = std::make_shared<RadioResponseInfo>();
800     *responseInfo = info;
801     AppExecFwk::InnerEvent::Pointer response =
802         AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_SWAP_CALL, responseInfo, IMS_CALL);
803     bool ret = TelEventHandler::SendTelEvent(handler, response);
804     if (!ret) {
805         TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
806         return TELEPHONY_ERR_FAIL;
807     }
808     return TELEPHONY_SUCCESS;
809 }
810 
StartDtmfResponse(int32_t slotId,const RadioResponseInfo & info)811 int32_t ImsCallCallbackStub::StartDtmfResponse(int32_t slotId, const RadioResponseInfo &info)
812 {
813     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
814     return SendEvent(slotId, RadioEvent::RADIO_START_DTMF, info);
815 }
816 
SendDtmfResponse(int32_t slotId,const RadioResponseInfo & info,int32_t callIndex)817 int32_t ImsCallCallbackStub::SendDtmfResponse(int32_t slotId, const RadioResponseInfo &info, int32_t callIndex)
818 {
819     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
820     auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
821     if (handler == nullptr) {
822         TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
823         return TELEPHONY_ERR_LOCAL_PTR_NULL;
824     }
825     std::shared_ptr<RadioResponseInfo> responseInfo = std::make_shared<RadioResponseInfo>();
826 
827     *responseInfo = info;
828     responseInfo->flag = callIndex;
829     AppExecFwk::InnerEvent::Pointer response =
830         AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_SEND_DTMF, responseInfo, IMS_CALL);
831     bool ret = TelEventHandler::SendTelEvent(handler, response);
832     if (!ret) {
833         TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
834         return TELEPHONY_ERR_FAIL;
835     }
836     return TELEPHONY_SUCCESS;
837 }
838 
StopDtmfResponse(int32_t slotId,const RadioResponseInfo & info)839 int32_t ImsCallCallbackStub::StopDtmfResponse(int32_t slotId, const RadioResponseInfo &info)
840 {
841     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
842     return SendEvent(slotId, RadioEvent::RADIO_STOP_DTMF, info);
843 }
844 
CallStateChangeReport(int32_t slotId)845 int32_t ImsCallCallbackStub::CallStateChangeReport(int32_t slotId)
846 {
847     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
848     auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
849     if (handler == nullptr) {
850         TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
851         return TELEPHONY_ERR_LOCAL_PTR_NULL;
852     }
853 
854     bool ret = TelEventHandler::SendTelEvent(handler, RadioEvent::RADIO_IMS_CALL_STATUS_INFO);
855     if (!ret) {
856         TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
857         return TELEPHONY_ERR_FAIL;
858     }
859     return TELEPHONY_SUCCESS;
860 }
861 
GetImsCallsDataResponse(int32_t slotId,const RadioResponseInfo & info)862 int32_t ImsCallCallbackStub::GetImsCallsDataResponse(int32_t slotId, const RadioResponseInfo &info)
863 {
864     TELEPHONY_LOGD("[slot%{public}d] entry", slotId);
865     return SendEvent(slotId, RadioEvent::RADIO_IMS_GET_CALL_DATA, info);
866 }
867 
GetImsCallsDataResponse(int32_t slotId,const ImsCurrentCallList & callList)868 int32_t ImsCallCallbackStub::GetImsCallsDataResponse(int32_t slotId, const ImsCurrentCallList &callList)
869 {
870     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
871     auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
872     if (handler == nullptr) {
873         TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
874         return TELEPHONY_ERR_LOCAL_PTR_NULL;
875     }
876     auto imsCurrentCallList = std::make_shared<ImsCurrentCallList>();
877     *imsCurrentCallList = callList;
878     bool ret = TelEventHandler::SendTelEvent(handler, RadioEvent::RADIO_IMS_GET_CALL_DATA, imsCurrentCallList);
879     if (!ret) {
880         TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
881         return TELEPHONY_ERR_FAIL;
882     }
883     return TELEPHONY_SUCCESS;
884 }
885 
SetImsSwitchResponse(int32_t slotId,const RadioResponseInfo & info)886 int32_t ImsCallCallbackStub::SetImsSwitchResponse(int32_t slotId, const RadioResponseInfo &info)
887 {
888     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
889     return SendEvent(slotId, RadioEvent::RADIO_SET_IMS_SWITCH_STATUS, info);
890 }
891 
GetImsSwitchResponse(int32_t slotId,const RadioResponseInfo & info)892 int32_t ImsCallCallbackStub::GetImsSwitchResponse(int32_t slotId, const RadioResponseInfo &info)
893 {
894     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
895     return SendEvent(slotId, RadioEvent::RADIO_GET_IMS_SWITCH_STATUS, info);
896 }
897 
GetImsSwitchResponse(int32_t slotId,int32_t active)898 int32_t ImsCallCallbackStub::GetImsSwitchResponse(int32_t slotId, int32_t active)
899 {
900     TELEPHONY_LOGI("[slot%{public}d] entry active:%{public}d", slotId, active);
901     auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
902     std::shared_ptr<int32_t> imsActiveState = std::make_shared<int32_t>(active);
903     if (handler == nullptr || handler.get() == nullptr || imsActiveState == nullptr) {
904         TELEPHONY_LOGE("[slot%{public}d] handler or imsActiveState is null", slotId);
905         return TELEPHONY_ERR_LOCAL_PTR_NULL;
906     }
907     TelEventHandler::SendTelEvent(handler, RadioEvent::RADIO_GET_IMS_SWITCH_STATUS, imsActiveState);
908     return TELEPHONY_SUCCESS;
909 }
910 
SetMuteResponse(int32_t slotId,const MuteControlResponse & response)911 int32_t ImsCallCallbackStub::SetMuteResponse(int32_t slotId, const MuteControlResponse &response)
912 {
913     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
914     return TELEPHONY_SUCCESS;
915 }
916 
CallRingBackReport(int32_t slotId,const RingbackVoice & info)917 int32_t ImsCallCallbackStub::CallRingBackReport(int32_t slotId, const RingbackVoice &info)
918 {
919     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
920     auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
921     if (handler == nullptr) {
922         TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
923         return TELEPHONY_ERR_LOCAL_PTR_NULL;
924     }
925     auto ringbackVoice = std::make_shared<RingbackVoice>();
926     *ringbackVoice = info;
927     bool ret = TelEventHandler::SendTelEvent(handler, RadioEvent::RADIO_CALL_RINGBACK_VOICE, ringbackVoice);
928     if (!ret) {
929         TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
930         return TELEPHONY_ERR_FAIL;
931     }
932     return TELEPHONY_SUCCESS;
933 }
934 
LastCallFailReasonResponse(int32_t slotId,const DisconnectedDetails & details)935 int32_t ImsCallCallbackStub::LastCallFailReasonResponse(int32_t slotId, const DisconnectedDetails &details)
936 {
937     TELEPHONY_LOGI("[slot%{public}d] entry, reason is %{public}d", slotId, details.reason);
938     auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
939     if (handler == nullptr) {
940         TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
941         return TELEPHONY_ERR_LOCAL_PTR_NULL;
942     }
943     std::shared_ptr<DisconnectedDetails> detailsInfo = std::make_shared<DisconnectedDetails>();
944     detailsInfo->reason = details.reason;
945     detailsInfo->message = details.message;
946     CellularCallConfig config;
947     auto vecReasonInfo = config.GetImsCallDisconnectResoninfoMappingConfig(slotId);
948     for (auto reasonInfo : vecReasonInfo) {
949         char *p = nullptr;
950         char *ptr = nullptr;
951         ptr = strtok_r((char *)(reasonInfo.c_str()), "|", &p);
952         if (ptr == nullptr) {
953             TELEPHONY_LOGE("strtok_r ptr is null");
954             continue;
955         }
956         int32_t tmpReason = (int32_t)std::atoi(ptr);
957         int flag = false;
958         while (tmpReason == static_cast<int32_t>(detailsInfo->reason)) {
959             ptr = strtok_r(nullptr, "|", &p);
960             if (ptr == nullptr) {
961                 break;
962             }
963             if (!flag) {
964                 detailsInfo->message = ptr;
965                 flag = true;
966             } else {
967                 detailsInfo->reason = static_cast<DisconnectedReason>(std::atoi(ptr));
968             }
969         }
970         if (flag) {
971             break;
972         }
973     }
974     bool ret = TelEventHandler::SendTelEvent(handler, RadioEvent::RADIO_GET_CALL_FAIL_REASON, detailsInfo);
975     if (!ret) {
976         TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
977         return TELEPHONY_ERR_FAIL;
978     }
979     return TELEPHONY_SUCCESS;
980 }
981 
SetClipResponse(int32_t slotId,const SsBaseResult & resultInfo)982 int32_t ImsCallCallbackStub::SetClipResponse(int32_t slotId, const SsBaseResult &resultInfo)
983 {
984     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
985     return SendEvent(slotId, RadioEvent::RADIO_SET_CALL_CLIP, resultInfo);
986 }
987 
GetClipResponse(int32_t slotId,const GetClipResult & result)988 int32_t ImsCallCallbackStub::GetClipResponse(int32_t slotId, const GetClipResult &result)
989 {
990     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
991     // CS fall back when IMS return failed
992     if (result.result.result == IMS_ERROR_UT_CS_FALLBACK) {
993         SupplementRequestCs supplementRequest;
994         return supplementRequest.GetClipRequest(slotId, result.result.index);
995     }
996     auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
997     if (handler == nullptr) {
998         TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
999         return TELEPHONY_ERR_LOCAL_PTR_NULL;
1000     }
1001     auto clipResponse = std::make_shared<GetClipResult>();
1002     clipResponse->action = result.action;
1003     clipResponse->clipStat = result.clipStat;
1004     clipResponse->result.index = result.result.index;
1005     clipResponse->result.result = result.result.result;
1006     clipResponse->result.reason = result.result.reason;
1007     clipResponse->result.message = result.result.message;
1008     AppExecFwk::InnerEvent::Pointer response =
1009         AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_GET_CALL_CLIP, clipResponse, result.result.index);
1010     bool ret = TelEventHandler::SendTelEvent(handler, response);
1011     if (!ret) {
1012         TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
1013         return TELEPHONY_ERR_FAIL;
1014     }
1015     return TELEPHONY_SUCCESS;
1016 }
1017 
GetClirResponse(int32_t slotId,const GetClirResult & result)1018 int32_t ImsCallCallbackStub::GetClirResponse(int32_t slotId, const GetClirResult &result)
1019 {
1020     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1021     // CS fall back when IMS return failed
1022     if (result.result.result == IMS_ERROR_UT_CS_FALLBACK) {
1023         SupplementRequestCs supplementRequest;
1024         return supplementRequest.GetClirRequest(slotId, result.result.index);
1025     }
1026     auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
1027     if (handler == nullptr) {
1028         TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
1029         return TELEPHONY_ERR_LOCAL_PTR_NULL;
1030     }
1031     auto clirResponse = std::make_shared<GetClirResult>();
1032     clirResponse->action = result.action;
1033     clirResponse->clirStat = result.clirStat;
1034     clirResponse->result.index = result.result.index;
1035     clirResponse->result.result = result.result.result;
1036     clirResponse->result.reason = result.result.reason;
1037     clirResponse->result.message = result.result.message;
1038     AppExecFwk::InnerEvent::Pointer response =
1039         AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_GET_CALL_CLIR, clirResponse, result.result.index);
1040     bool ret = TelEventHandler::SendTelEvent(handler, response);
1041     if (!ret) {
1042         TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
1043         return TELEPHONY_ERR_FAIL;
1044     }
1045     return TELEPHONY_SUCCESS;
1046 }
1047 
SetClirResponse(int32_t slotId,const SsBaseResult & resultInfo)1048 int32_t ImsCallCallbackStub::SetClirResponse(int32_t slotId, const SsBaseResult &resultInfo)
1049 {
1050     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1051     // CS fall back when IMS return failed
1052     if (resultInfo.result == IMS_ERROR_UT_CS_FALLBACK) {
1053         SupplementRequestCs supplementRequest;
1054         SsRequestCommand ss;
1055         int32_t ret = GetSsRequestCommand(slotId, resultInfo.index, ss);
1056         if (ret != TELEPHONY_SUCCESS) {
1057             TELEPHONY_LOGI("[slot%{public}d] cs fall back error since haven't found the ss command", slotId);
1058             return ret;
1059         }
1060         return supplementRequest.SetClirRequest(slotId, ss.clirAction, resultInfo.index);
1061     }
1062     return SendEvent(slotId, RadioEvent::RADIO_SET_CALL_CLIR, resultInfo);
1063 }
1064 
GetCallTransferResponse(int32_t slotId,const CallForwardQueryInfoList & cFQueryList)1065 int32_t ImsCallCallbackStub::GetCallTransferResponse(int32_t slotId, const CallForwardQueryInfoList &cFQueryList)
1066 {
1067     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1068     // CS fall back when IMS return failed
1069     if (cFQueryList.result.result == IMS_ERROR_UT_CS_FALLBACK) {
1070         SsRequestCommand ss;
1071         int32_t ret = GetSsRequestCommand(slotId, cFQueryList.result.index, ss);
1072         if (ret != TELEPHONY_SUCCESS) {
1073             TELEPHONY_LOGI("[slot%{public}d] cs fall back error since haven't found the ss command", slotId);
1074             return ret;
1075         }
1076         SupplementRequestCs supplementRequest;
1077         return supplementRequest.GetCallTransferRequest(slotId, ss.cfReason, cFQueryList.result.index);
1078     }
1079     auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
1080     if (handler == nullptr) {
1081         TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
1082         return TELEPHONY_ERR_LOCAL_PTR_NULL;
1083     }
1084     auto callTransferResponse = std::make_shared<CallForwardQueryInfoList>();
1085     BuildCallForwardInfo(cFQueryList, *callTransferResponse);
1086     AppExecFwk::InnerEvent::Pointer response =
1087         AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_GET_CALL_FORWARD, callTransferResponse, cFQueryList.result.index);
1088     bool ret = TelEventHandler::SendTelEvent(handler, response);
1089     if (!ret) {
1090         TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
1091         return TELEPHONY_ERR_FAIL;
1092     }
1093     return TELEPHONY_SUCCESS;
1094 }
1095 
SetCallTransferResponse(int32_t slotId,const SsBaseResult & resultInfo)1096 int32_t ImsCallCallbackStub::SetCallTransferResponse(int32_t slotId, const SsBaseResult &resultInfo)
1097 {
1098     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1099     // CS fall back when IMS return failed
1100     if (resultInfo.result == IMS_ERROR_UT_CS_FALLBACK) {
1101         SsRequestCommand ss;
1102         int32_t ret = GetSsRequestCommand(slotId, resultInfo.index, ss);
1103         if (ret != TELEPHONY_SUCCESS) {
1104             TELEPHONY_LOGI("[slot%{public}d] cs fall back error since haven't found the ss command", slotId);
1105             return ret;
1106         }
1107         SupplementRequestCs supplementRequest;
1108         CallTransferParam callTransferParam;
1109         callTransferParam.mode = ss.cfAction;
1110         callTransferParam.reason = ss.cfReason;
1111         callTransferParam.number = ss.number;
1112         callTransferParam.classx = ss.classType;
1113         return supplementRequest.SetCallTransferRequest(slotId, callTransferParam, resultInfo.index);
1114     }
1115     return SendEvent(slotId, RadioEvent::RADIO_SET_CALL_FORWARD, resultInfo);
1116 }
1117 
GetCallRestrictionResponse(int32_t slotId,const CallRestrictionResult & result)1118 int32_t ImsCallCallbackStub::GetCallRestrictionResponse(int32_t slotId, const CallRestrictionResult &result)
1119 {
1120     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1121     if (result.result.result == IMS_ERROR_UT_CS_FALLBACK) {
1122         SsRequestCommand ss;
1123         int32_t ret = GetSsRequestCommand(slotId, result.result.index, ss);
1124         if (ret != TELEPHONY_SUCCESS) {
1125             TELEPHONY_LOGI("[slot%{public}d] cs fall back error since haven't found the ss command", slotId);
1126             return ret;
1127         }
1128         const std::string fac = ss.facility;
1129         SupplementRequestCs supplementRequest;
1130         return supplementRequest.GetCallRestrictionRequest(slotId, fac, result.result.index);
1131     }
1132     auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
1133     if (handler == nullptr) {
1134         TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
1135         return TELEPHONY_ERR_LOCAL_PTR_NULL;
1136     }
1137     auto callRestrictionResponse = std::make_shared<CallRestrictionResult>();
1138     callRestrictionResponse->status = result.status;
1139     callRestrictionResponse->classCw = result.classCw;
1140     callRestrictionResponse->result.result = result.result.result;
1141     callRestrictionResponse->result.index = result.result.index;
1142     callRestrictionResponse->result.reason = result.result.reason;
1143     callRestrictionResponse->result.message = result.result.message;
1144     AppExecFwk::InnerEvent::Pointer response = AppExecFwk::InnerEvent::Get(
1145         RadioEvent::RADIO_GET_CALL_RESTRICTION, callRestrictionResponse, result.result.index);
1146     bool ret = TelEventHandler::SendTelEvent(handler, response);
1147     if (!ret) {
1148         TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
1149         return TELEPHONY_ERR_FAIL;
1150     }
1151     return TELEPHONY_SUCCESS;
1152 }
1153 
SetCallRestrictionResponse(int32_t slotId,const SsBaseResult & resultInfo)1154 int32_t ImsCallCallbackStub::SetCallRestrictionResponse(int32_t slotId, const SsBaseResult &resultInfo)
1155 {
1156     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1157     // CS fall back when IMS return failed
1158     if (resultInfo.result == IMS_ERROR_UT_CS_FALLBACK) {
1159         SsRequestCommand ss;
1160         int32_t ret = GetSsRequestCommand(slotId, resultInfo.index, ss);
1161         if (ret != TELEPHONY_SUCCESS) {
1162             TELEPHONY_LOGI("[slot%{public}d] cs fall bacK error since haven't found the ss command", slotId);
1163             return ret;
1164         }
1165         SupplementRequestCs supplementRequest;
1166         return supplementRequest.SetCallRestrictionRequest(
1167             slotId, ss.facility, ss.enable, ss.password, resultInfo.index);
1168     }
1169     return SendEvent(slotId, RadioEvent::RADIO_SET_CALL_RESTRICTION, resultInfo);
1170 }
1171 
GetCallWaitingResponse(int32_t slotId,const CallWaitResult & result)1172 int32_t ImsCallCallbackStub::GetCallWaitingResponse(int32_t slotId, const CallWaitResult &result)
1173 {
1174     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1175     // CS fall back when IMS return failed
1176     if (result.result.result == IMS_ERROR_UT_CS_FALLBACK) {
1177         SupplementRequestCs supplementRequest;
1178         return supplementRequest.GetCallWaitingRequest(slotId, result.result.index);
1179     }
1180     auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
1181     if (handler == nullptr) {
1182         TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
1183         return TELEPHONY_ERR_LOCAL_PTR_NULL;
1184     }
1185     auto callWaitResponse = std::make_shared<CallWaitResult>();
1186     callWaitResponse->status = result.status;
1187     callWaitResponse->classCw = result.classCw;
1188     callWaitResponse->result.result = result.result.result;
1189     callWaitResponse->result.index = result.result.index;
1190     callWaitResponse->result.reason = result.result.reason;
1191     callWaitResponse->result.message = result.result.message;
1192     AppExecFwk::InnerEvent::Pointer response =
1193         AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_GET_CALL_WAIT, callWaitResponse, result.result.index);
1194     bool ret = TelEventHandler::SendTelEvent(handler, response);
1195     if (!ret) {
1196         TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
1197         return TELEPHONY_ERR_FAIL;
1198     }
1199     return TELEPHONY_SUCCESS;
1200 }
1201 
SetCallWaitingResponse(int32_t slotId,const SsBaseResult & resultInfo)1202 int32_t ImsCallCallbackStub::SetCallWaitingResponse(int32_t slotId, const SsBaseResult &resultInfo)
1203 {
1204     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1205     // CS fall back when IMS return failed
1206     if (resultInfo.result == IMS_ERROR_UT_CS_FALLBACK) {
1207         SsRequestCommand ss;
1208         int32_t ret = GetSsRequestCommand(slotId, resultInfo.index, ss);
1209         if (ret != TELEPHONY_SUCCESS) {
1210             TELEPHONY_LOGI("[slot%{public}d] cs fall back error since haven't found the ss command", slotId);
1211             return ret;
1212         }
1213         SupplementRequestCs supplementRequest;
1214         return supplementRequest.SetCallWaitingRequest(slotId, ss.enable, ss.classType, resultInfo.index);
1215     }
1216     return SendEvent(slotId, RadioEvent::RADIO_SET_CALL_WAIT, resultInfo);
1217 }
1218 
SetColrResponse(int32_t slotId,const SsBaseResult & resultInfo)1219 int32_t ImsCallCallbackStub::SetColrResponse(int32_t slotId, const SsBaseResult &resultInfo)
1220 {
1221     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1222     return SendEvent(slotId, RadioEvent::RADIO_IMS_SET_COLR, resultInfo);
1223 }
1224 
GetColrResponse(int32_t slotId,const GetColrResult & result)1225 int32_t ImsCallCallbackStub::GetColrResponse(int32_t slotId, const GetColrResult &result)
1226 {
1227     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1228     auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
1229     if (handler == nullptr) {
1230         TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
1231         return TELEPHONY_ERR_LOCAL_PTR_NULL;
1232     }
1233     auto colrResponse = std::make_shared<GetColrResult>();
1234     colrResponse->action = result.action;
1235     colrResponse->colrStat = result.colrStat;
1236     colrResponse->result.result = result.result.result;
1237     colrResponse->result.index = result.result.index;
1238     colrResponse->result.reason = result.result.reason;
1239     colrResponse->result.message = result.result.message;
1240     AppExecFwk::InnerEvent::Pointer response =
1241         AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_IMS_GET_COLR, colrResponse, result.result.index);
1242     bool ret = TelEventHandler::SendTelEvent(handler, response);
1243     if (!ret) {
1244         TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
1245         return TELEPHONY_ERR_FAIL;
1246     }
1247     return TELEPHONY_SUCCESS;
1248 }
1249 
SetColpResponse(int32_t slotId,const SsBaseResult & resultInfo)1250 int32_t ImsCallCallbackStub::SetColpResponse(int32_t slotId, const SsBaseResult &resultInfo)
1251 {
1252     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1253     return SendEvent(slotId, RadioEvent::RADIO_IMS_SET_COLP, resultInfo);
1254 }
1255 
GetColpResponse(int32_t slotId,const GetColpResult & result)1256 int32_t ImsCallCallbackStub::GetColpResponse(int32_t slotId, const GetColpResult &result)
1257 {
1258     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1259     auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
1260     if (handler == nullptr) {
1261         TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
1262         return TELEPHONY_ERR_LOCAL_PTR_NULL;
1263     }
1264     auto colpResponse = std::make_shared<GetColpResult>();
1265     colpResponse->action = result.action;
1266     colpResponse->colpStat = result.colpStat;
1267     colpResponse->result.result = result.result.result;
1268     colpResponse->result.index = result.result.index;
1269     colpResponse->result.reason = result.result.reason;
1270     colpResponse->result.message = result.result.message;
1271     AppExecFwk::InnerEvent::Pointer response =
1272         AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_IMS_GET_COLP, colpResponse, result.result.index);
1273     bool ret = TelEventHandler::SendTelEvent(handler, response);
1274     if (!ret) {
1275         TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
1276         return TELEPHONY_ERR_FAIL;
1277     }
1278     return TELEPHONY_SUCCESS;
1279 }
1280 
CombineConferenceResponse(int32_t slotId,const RadioResponseInfo & info)1281 int32_t ImsCallCallbackStub::CombineConferenceResponse(int32_t slotId, const RadioResponseInfo &info)
1282 {
1283     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1284     return SendEvent(slotId, RadioEvent::RADIO_COMBINE_CALL, info);
1285 }
1286 
InviteToConferenceResponse(int32_t slotId,const RadioResponseInfo & info)1287 int32_t ImsCallCallbackStub::InviteToConferenceResponse(int32_t slotId, const RadioResponseInfo &info)
1288 {
1289     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1290     return SendEvent(slotId, RadioEvent::RADIO_JOIN_CALL, info);
1291 }
1292 
ReceiveUpdateCallMediaModeRequest(int32_t slotId,const ImsCallModeReceiveInfo & callModeRequest)1293 int32_t ImsCallCallbackStub::ReceiveUpdateCallMediaModeRequest(
1294     int32_t slotId, const ImsCallModeReceiveInfo &callModeRequest)
1295 {
1296     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1297     return SendEvent(slotId, RadioEvent::RADIO_RECV_CALL_MEDIA_MODE_REQUEST, callModeRequest);
1298 }
1299 
ReceiveUpdateCallMediaModeResponse(int32_t slotId,const ImsCallModeReceiveInfo & callModeResponse)1300 int32_t ImsCallCallbackStub::ReceiveUpdateCallMediaModeResponse(
1301     int32_t slotId, const ImsCallModeReceiveInfo &callModeResponse)
1302 {
1303     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1304     return SendEvent(slotId, RadioEvent::RADIO_RECV_CALL_MEDIA_MODE_RESPONSE, callModeResponse);
1305 }
1306 
CallSessionEventChanged(int32_t slotId,const ImsCallSessionEventInfo & callSessionEventInfo)1307 int32_t ImsCallCallbackStub::CallSessionEventChanged(
1308     int32_t slotId, const ImsCallSessionEventInfo &callSessionEventInfo)
1309 {
1310     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1311     auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
1312     if (handler == nullptr) {
1313         TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
1314         return TELEPHONY_ERR_LOCAL_PTR_NULL;
1315     }
1316     std::shared_ptr<ImsCallSessionEventInfo> responseInfo = std::make_shared<ImsCallSessionEventInfo>();
1317     *responseInfo = callSessionEventInfo;
1318     bool ret = TelEventHandler::SendTelEvent(handler, RadioEvent::RADIO_CALL_SESSION_EVENT_CHANGED, responseInfo);
1319     if (!ret) {
1320         TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
1321         return TELEPHONY_ERR_FAIL;
1322     }
1323     return TELEPHONY_SUCCESS;
1324 }
1325 
PeerDimensionsChanged(int32_t slotId,const ImsCallPeerDimensionsInfo & callPeerDimensionsInfo)1326 int32_t ImsCallCallbackStub::PeerDimensionsChanged(
1327     int32_t slotId, const ImsCallPeerDimensionsInfo &callPeerDimensionsInfo)
1328 {
1329     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1330     auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
1331     if (handler == nullptr) {
1332         TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
1333         return TELEPHONY_ERR_LOCAL_PTR_NULL;
1334     }
1335     std::shared_ptr<ImsCallPeerDimensionsInfo> responseInfo = std::make_shared<ImsCallPeerDimensionsInfo>();
1336     *responseInfo = callPeerDimensionsInfo;
1337     bool ret = TelEventHandler::SendTelEvent(handler, RadioEvent::RADIO_CALL_PEER_DIMENSIONS_CHANGED, responseInfo);
1338     if (!ret) {
1339         TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
1340         return TELEPHONY_ERR_FAIL;
1341     }
1342     return TELEPHONY_SUCCESS;
1343 }
1344 
CallDataUsageChanged(int32_t slotId,const ImsCallDataUsageInfo & callDataUsageInfo)1345 int32_t ImsCallCallbackStub::CallDataUsageChanged(int32_t slotId, const ImsCallDataUsageInfo &callDataUsageInfo)
1346 {
1347     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1348     auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
1349     if (handler == nullptr) {
1350         TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
1351         return TELEPHONY_ERR_LOCAL_PTR_NULL;
1352     }
1353     std::shared_ptr<ImsCallDataUsageInfo> responseInfo = std::make_shared<ImsCallDataUsageInfo>();
1354     *responseInfo = callDataUsageInfo;
1355     bool ret = TelEventHandler::SendTelEvent(handler, RadioEvent::RADIO_CALL_DATA_USAGE_CHANGED, responseInfo);
1356     if (!ret) {
1357         TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
1358         return TELEPHONY_ERR_FAIL;
1359     }
1360     return TELEPHONY_SUCCESS;
1361 }
1362 
CameraCapabilitiesChanged(int32_t slotId,const CameraCapabilitiesInfo & cameraCapabilitiesInfo)1363 int32_t ImsCallCallbackStub::CameraCapabilitiesChanged(
1364     int32_t slotId, const CameraCapabilitiesInfo &cameraCapabilitiesInfo)
1365 {
1366     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1367     auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
1368     if (handler == nullptr) {
1369         TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
1370         return TELEPHONY_ERR_LOCAL_PTR_NULL;
1371     }
1372     std::shared_ptr<CameraCapabilitiesInfo> responseInfo = std::make_shared<CameraCapabilitiesInfo>();
1373     *responseInfo = cameraCapabilitiesInfo;
1374     bool ret = TelEventHandler::SendTelEvent(handler, RadioEvent::RADIO_CAMERA_CAPABILITIES_CHANGED, responseInfo);
1375     if (!ret) {
1376         TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
1377         return TELEPHONY_ERR_FAIL;
1378     }
1379     return TELEPHONY_SUCCESS;
1380 }
1381 
GetSsRequestCommand(int32_t slotId,int32_t index,SsRequestCommand & ss)1382 int32_t ImsCallCallbackStub::GetSsRequestCommand(int32_t slotId, int32_t index, SsRequestCommand &ss)
1383 {
1384     auto handler = DelayedSingleton<CellularCallService>::GetInstance()->GetHandler(slotId);
1385     if (handler == nullptr) {
1386         TELEPHONY_LOGE("[slot%{public}d] handler is null!", slotId);
1387         return TELEPHONY_ERR_LOCAL_PTR_NULL;
1388     }
1389     return handler->GetSsRequestCommand(index, ss);
1390 }
1391 
BuildCallForwardInfo(const CallForwardQueryInfoList & cFQueryList,CallForwardQueryInfoList & cFQueryResultList)1392 void ImsCallCallbackStub::BuildCallForwardInfo(
1393     const CallForwardQueryInfoList &cFQueryList, CallForwardQueryInfoList &cFQueryResultList)
1394 {
1395     cFQueryResultList.callSize = cFQueryList.callSize;
1396     for (auto info : cFQueryList.calls) {
1397         CallForwardQueryResult call;
1398         call.serial = info.serial;
1399         call.result = info.result;
1400         call.status = info.status;
1401         call.classx = info.classx;
1402         call.number = info.number;
1403         call.type = info.type;
1404         call.reason = info.reason;
1405         call.time = info.time;
1406         call.startHour = info.startHour;
1407         call.startMinute = info.startMinute;
1408         call.endHour = info.endHour;
1409         call.endMinute = info.endMinute;
1410         cFQueryResultList.calls.push_back(call);
1411     }
1412     cFQueryResultList.result.result = cFQueryList.result.result;
1413     cFQueryResultList.result.index = cFQueryList.result.index;
1414     cFQueryResultList.result.reason = cFQueryList.result.reason;
1415     cFQueryResultList.result.message = cFQueryList.result.message;
1416 }
1417 
SendEvent(int32_t slotId,int32_t eventId,const RadioResponseInfo & info)1418 int32_t ImsCallCallbackStub::SendEvent(int32_t slotId, int32_t eventId, const RadioResponseInfo &info)
1419 {
1420     auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
1421     if (handler == nullptr) {
1422         TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
1423         return TELEPHONY_ERR_LOCAL_PTR_NULL;
1424     }
1425     std::shared_ptr<RadioResponseInfo> responseInfo = std::make_shared<RadioResponseInfo>();
1426     *responseInfo = info;
1427     bool ret = TelEventHandler::SendTelEvent(handler, eventId, responseInfo);
1428     if (!ret) {
1429         TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
1430         return TELEPHONY_ERR_FAIL;
1431     }
1432     return TELEPHONY_SUCCESS;
1433 }
1434 
SendEvent(int32_t slotId,int32_t eventId,const SsBaseResult & resultInfo)1435 int32_t ImsCallCallbackStub::SendEvent(int32_t slotId, int32_t eventId, const SsBaseResult &resultInfo)
1436 {
1437     auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
1438     if (handler == nullptr) {
1439         TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
1440         return TELEPHONY_ERR_LOCAL_PTR_NULL;
1441     }
1442     auto ssResponseInfo = std::make_shared<SsBaseResult>();
1443     ssResponseInfo->result = resultInfo.result;
1444     ssResponseInfo->index = resultInfo.index;
1445     ssResponseInfo->reason = resultInfo.reason;
1446     ssResponseInfo->message = resultInfo.message;
1447     AppExecFwk::InnerEvent::Pointer response = AppExecFwk::InnerEvent::Get(eventId, ssResponseInfo, resultInfo.index);
1448     bool ret = TelEventHandler::SendTelEvent(handler, response);
1449     if (!ret) {
1450         TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
1451         return TELEPHONY_ERR_FAIL;
1452     }
1453     return TELEPHONY_SUCCESS;
1454 }
1455 
SendEvent(int32_t slotId,int32_t eventId,const ImsCallModeReceiveInfo & callModeInfo)1456 int32_t ImsCallCallbackStub::SendEvent(int32_t slotId, int32_t eventId, const ImsCallModeReceiveInfo &callModeInfo)
1457 {
1458     auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
1459     if (handler == nullptr) {
1460         TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
1461         return TELEPHONY_ERR_LOCAL_PTR_NULL;
1462     }
1463     std::shared_ptr<ImsCallModeReceiveInfo> info = std::make_shared<ImsCallModeReceiveInfo>();
1464     *info = callModeInfo;
1465     bool ret = TelEventHandler::SendTelEvent(handler, eventId, info);
1466     if (!ret) {
1467         TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
1468         return TELEPHONY_ERR_FAIL;
1469     }
1470     return TELEPHONY_SUCCESS;
1471 }
1472 
GetImsCapResponse(int32_t slotId,const ImsCapFromChip & imsCap)1473 int32_t ImsCallCallbackStub::GetImsCapResponse(int32_t slotId, const ImsCapFromChip &imsCap)
1474 {
1475     TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
1476 
1477     auto handler = DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
1478     if (handler == nullptr) {
1479         TELEPHONY_LOGE("[slot%{public}d] handler is null", slotId);
1480         return TELEPHONY_ERR_LOCAL_PTR_NULL;
1481     }
1482 
1483     auto imsCapability = std::make_shared<ImsCapFromChip>();
1484     *imsCapability = imsCap;
1485     bool ret = TelEventHandler::SendTelEvent(handler, RadioEvent::RADIO_GET_IMS_CAPABILITY_FINISHED, imsCapability);
1486     if (!ret) {
1487         TELEPHONY_LOGE("[slot%{public}d] SendEvent failed!", slotId);
1488         return TELEPHONY_ERR_FAIL;
1489     }
1490     return TELEPHONY_SUCCESS;
1491 }
1492 
OnGetImsCapResponseInner(MessageParcel & data,MessageParcel & reply)1493 int32_t ImsCallCallbackStub::OnGetImsCapResponseInner(MessageParcel &data, MessageParcel &reply)
1494 {
1495     int32_t slotId = data.ReadInt32();
1496     ImsCapFromChip imsCap = {
1497         .volteCap = data.ReadInt32(),
1498         .vowifiCap = data.ReadInt32(),
1499         .vonrCap = data.ReadInt32(),
1500         .vtCap = data.ReadInt32()
1501     };
1502 
1503     reply.WriteInt32(GetImsCapResponse(slotId, imsCap));
1504     return TELEPHONY_SUCCESS;
1505 }
1506 } // namespace Telephony
1507 } // namespace OHOS
1508