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