1 /*
2 * Copyright (C) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "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 "radio_event.h"
22 #include "telephony_errors.h"
23 #include "telephony_log_wrapper.h"
24
25 namespace OHOS {
26 namespace Telephony {
ImsCallCallbackStub()27 ImsCallCallbackStub::ImsCallCallbackStub()
28 {
29 TELEPHONY_LOGI("ImsCallCallbackStub");
30 InitFuncMap();
31 }
32
InitFuncMap()33 void ImsCallCallbackStub::InitFuncMap()
34 {
35 InitCallBasicFuncMap();
36 InitConfigFuncMap();
37 InitSupplementFuncMap();
38 }
39
InitCallBasicFuncMap()40 void ImsCallCallbackStub::InitCallBasicFuncMap()
41 {
42 /****************** call basic ******************/
43 requestFuncMap_[ImsCallCallbackInterface::IMS_DIAL] = &ImsCallCallbackStub::OnDialResponseInner;
44 requestFuncMap_[ImsCallCallbackInterface::IMS_HANG_UP] = &ImsCallCallbackStub::OnHangUpResponseInner;
45 requestFuncMap_[ImsCallCallbackInterface::IMS_REJECT] = &ImsCallCallbackStub::OnRejectResponseInner;
46 requestFuncMap_[ImsCallCallbackInterface::IMS_ANSWER] = &ImsCallCallbackStub::OnAnswerResponseInner;
47 requestFuncMap_[ImsCallCallbackInterface::IMS_HOLD] = &ImsCallCallbackStub::OnHoldCallResponseInner;
48 requestFuncMap_[ImsCallCallbackInterface::IMS_UN_HOLD] = &ImsCallCallbackStub::OnUnHoldCallResponseInner;
49 requestFuncMap_[ImsCallCallbackInterface::IMS_SWITCH] = &ImsCallCallbackStub::OnSwitchCallResponseInner;
50 requestFuncMap_[ImsCallCallbackInterface::IMS_CALL_STATE_CHANGE] =
51 &ImsCallCallbackStub::OnCallStateChangeReportInner;
52 requestFuncMap_[ImsCallCallbackInterface::IMS_LAST_CALL_FAIL_REASON] =
53 &ImsCallCallbackStub::OnLastCallFailReasonResponseInner;
54 requestFuncMap_[ImsCallCallbackInterface::IMS_CALL_CRING] = &ImsCallCallbackStub::OnCallRingBackReportInner;
55 }
56
InitConfigFuncMap()57 void ImsCallCallbackStub::InitConfigFuncMap()
58 {
59 /****************** dtmf rtt ******************/
60 requestFuncMap_[ImsCallCallbackInterface::IMS_START_DTMF] = &ImsCallCallbackStub::OnStartDtmfResponseInner;
61 requestFuncMap_[ImsCallCallbackInterface::IMS_SEND_DTMF] = &ImsCallCallbackStub::OnSendDtmfResponseInner;
62 requestFuncMap_[ImsCallCallbackInterface::IMS_STOP_DTMF] = &ImsCallCallbackStub::OnStopDtmfResponseInner;
63
64 /****************** ims config ******************/
65 requestFuncMap_[ImsCallCallbackInterface::IMS_SET_SWITCH_STATUS] =
66 &ImsCallCallbackStub::OnSetImsSwitchResponseInner;
67 requestFuncMap_[ImsCallCallbackInterface::IMS_GET_SWITCH_STATUS] =
68 &ImsCallCallbackStub::OnGetImsSwitchResponseInner;
69 requestFuncMap_[ImsCallCallbackInterface::IMS_GET_CALLS_DATA] =
70 &ImsCallCallbackStub::OnGetImsCallsDataResponseInner;
71 requestFuncMap_[ImsCallCallbackInterface::IMS_SET_MUTE] = &ImsCallCallbackStub::OnSetMuteResponseInner;
72 }
73
InitSupplementFuncMap()74 void ImsCallCallbackStub::InitSupplementFuncMap()
75 {
76 /****************** supplement ******************/
77 requestFuncMap_[ImsCallCallbackInterface::IMS_SET_CALL_CLIP] = &ImsCallCallbackStub::OnSetClipResponseInner;
78 requestFuncMap_[ImsCallCallbackInterface::IMS_GET_CALL_CLIP] = &ImsCallCallbackStub::OnGetClipResponseInner;
79 requestFuncMap_[ImsCallCallbackInterface::IMS_GET_CALL_CLIR] = &ImsCallCallbackStub::OnGetClirResponseInner;
80 requestFuncMap_[ImsCallCallbackInterface::IMS_SET_CALL_CLIR] = &ImsCallCallbackStub::OnSetClirResponseInner;
81 requestFuncMap_[ImsCallCallbackInterface::IMS_GET_CALL_FORWARD] =
82 &ImsCallCallbackStub::OnGetCallTransferResponseInner;
83 requestFuncMap_[ImsCallCallbackInterface::IMS_SET_CALL_FORWARD] =
84 &ImsCallCallbackStub::OnSetCallTransferResponseInner;
85 requestFuncMap_[ImsCallCallbackInterface::IMS_GET_CALL_RESTRICTION] =
86 &ImsCallCallbackStub::OnGetCallRestrictionResponseInner;
87 requestFuncMap_[ImsCallCallbackInterface::IMS_SET_CALL_RESTRICTION] =
88 &ImsCallCallbackStub::OnSetCallRestrictionResponseInner;
89 requestFuncMap_[ImsCallCallbackInterface::IMS_GET_CALL_WAIT] = &ImsCallCallbackStub::OnGetCallWaitingResponseInner;
90 requestFuncMap_[ImsCallCallbackInterface::IMS_SET_CALL_WAIT] = &ImsCallCallbackStub::OnSetCallWaitingResponseInner;
91 requestFuncMap_[ImsCallCallbackInterface::IMS_GET_CALL_COLR] = &ImsCallCallbackStub::OnGetColrResponseInner;
92 requestFuncMap_[ImsCallCallbackInterface::IMS_SET_CALL_COLR] = &ImsCallCallbackStub::OnSetColrResponseInner;
93 requestFuncMap_[ImsCallCallbackInterface::IMS_SET_CALL_COLP] = &ImsCallCallbackStub::OnSetColpResponseInner;
94 requestFuncMap_[ImsCallCallbackInterface::IMS_GET_CALL_COLP] = &ImsCallCallbackStub::OnGetColpResponseInner;
95 }
96
~ImsCallCallbackStub()97 ImsCallCallbackStub::~ImsCallCallbackStub()
98 {
99 requestFuncMap_.clear();
100 }
101
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)102 int32_t ImsCallCallbackStub::OnRemoteRequest(
103 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
104 {
105 std::u16string myDescriptor = ImsCallCallbackStub::GetDescriptor();
106 std::u16string remoteDescriptor = data.ReadInterfaceToken();
107 if (myDescriptor != remoteDescriptor) {
108 TELEPHONY_LOGE("OnRemoteRequest return, descriptor checked fail");
109 return TELEPHONY_ERR_DESCRIPTOR_MISMATCH;
110 }
111 auto itFunc = requestFuncMap_.find(code);
112 if (itFunc != requestFuncMap_.end()) {
113 auto requestFunc = itFunc->second;
114 if (requestFunc != nullptr) {
115 return (this->*requestFunc)(data, reply);
116 }
117 }
118 TELEPHONY_LOGI("ImsCallCallbackStub::OnRemoteRequest, default case, need check.");
119 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
120 }
121
OnDialResponseInner(MessageParcel & data,MessageParcel & reply)122 int32_t ImsCallCallbackStub::OnDialResponseInner(MessageParcel &data, MessageParcel &reply)
123 {
124 TELEPHONY_LOGI("ImsCallCallbackStub::OnDialResponseInner entry");
125 int32_t slotId = data.ReadInt32();
126 auto info = (HRilRadioResponseInfo *)data.ReadRawData(sizeof(HRilRadioResponseInfo));
127 if (info == nullptr) {
128 TELEPHONY_LOGE("OnDialResponseInner return, info is nullptr.");
129 return TELEPHONY_ERR_ARGUMENT_INVALID;
130 }
131 reply.WriteInt32(DialResponse(slotId, *info));
132 return TELEPHONY_SUCCESS;
133 }
134
OnHangUpResponseInner(MessageParcel & data,MessageParcel & reply)135 int32_t ImsCallCallbackStub::OnHangUpResponseInner(MessageParcel &data, MessageParcel &reply)
136 {
137 TELEPHONY_LOGI("ImsCallCallbackStub::OnHangUpResponseInner entry");
138 int32_t slotId = data.ReadInt32();
139 auto info = (HRilRadioResponseInfo *)data.ReadRawData(sizeof(HRilRadioResponseInfo));
140 if (info == nullptr) {
141 TELEPHONY_LOGE("OnHangUpResponseInner return, info is nullptr.");
142 return TELEPHONY_ERR_ARGUMENT_INVALID;
143 }
144 reply.WriteInt32(HangUpResponse(slotId, *info));
145 return TELEPHONY_SUCCESS;
146 }
147
OnRejectResponseInner(MessageParcel & data,MessageParcel & reply)148 int32_t ImsCallCallbackStub::OnRejectResponseInner(MessageParcel &data, MessageParcel &reply)
149 {
150 TELEPHONY_LOGI("ImsCallCallbackStub::OnRejectResponseInner entry");
151 int32_t slotId = data.ReadInt32();
152 auto info = (HRilRadioResponseInfo *)data.ReadRawData(sizeof(HRilRadioResponseInfo));
153 if (info == nullptr) {
154 TELEPHONY_LOGE("OnRejectResponseInner return, info is nullptr.");
155 return TELEPHONY_ERR_ARGUMENT_INVALID;
156 }
157 reply.WriteInt32(RejectWithReasonResponse(slotId, *info));
158 return TELEPHONY_SUCCESS;
159 }
160
OnAnswerResponseInner(MessageParcel & data,MessageParcel & reply)161 int32_t ImsCallCallbackStub::OnAnswerResponseInner(MessageParcel &data, MessageParcel &reply)
162 {
163 TELEPHONY_LOGI("ImsCallCallbackStub::OnAnswerResponseInner entry");
164 int32_t slotId = data.ReadInt32();
165 auto info = (HRilRadioResponseInfo *)data.ReadRawData(sizeof(HRilRadioResponseInfo));
166 if (info == nullptr) {
167 TELEPHONY_LOGE("OnAnswerResponseInner return, info is nullptr.");
168 return TELEPHONY_ERR_ARGUMENT_INVALID;
169 }
170 reply.WriteInt32(AnswerResponse(slotId, *info));
171 return TELEPHONY_SUCCESS;
172 }
173
OnHoldCallResponseInner(MessageParcel & data,MessageParcel & reply)174 int32_t ImsCallCallbackStub::OnHoldCallResponseInner(MessageParcel &data, MessageParcel &reply)
175 {
176 TELEPHONY_LOGI("ImsCallCallbackStub::OnHoldCallResponseInner entry");
177 int32_t slotId = data.ReadInt32();
178 auto info = (HRilRadioResponseInfo *)data.ReadRawData(sizeof(HRilRadioResponseInfo));
179 if (info == nullptr) {
180 TELEPHONY_LOGE("OnHoldCallResponseInner return, info is nullptr.");
181 return TELEPHONY_ERR_ARGUMENT_INVALID;
182 }
183 reply.WriteInt32(HoldCallResponse(slotId, *info));
184 return TELEPHONY_SUCCESS;
185 }
186
OnUnHoldCallResponseInner(MessageParcel & data,MessageParcel & reply)187 int32_t ImsCallCallbackStub::OnUnHoldCallResponseInner(MessageParcel &data, MessageParcel &reply)
188 {
189 TELEPHONY_LOGI("ImsCallCallbackStub::OnUnHoldCallResponseInner entry");
190 int32_t slotId = data.ReadInt32();
191 auto info = (HRilRadioResponseInfo *)data.ReadRawData(sizeof(HRilRadioResponseInfo));
192 if (info == nullptr) {
193 TELEPHONY_LOGE("OnUnHoldCallResponseInner return, info is nullptr.");
194 return TELEPHONY_ERR_ARGUMENT_INVALID;
195 }
196 reply.WriteInt32(UnHoldCallResponse(slotId, *info));
197 return TELEPHONY_SUCCESS;
198 }
199
OnSwitchCallResponseInner(MessageParcel & data,MessageParcel & reply)200 int32_t ImsCallCallbackStub::OnSwitchCallResponseInner(MessageParcel &data, MessageParcel &reply)
201 {
202 TELEPHONY_LOGI("ImsCallCallbackStub::OnSwitchCallResponseInner entry");
203 int32_t slotId = data.ReadInt32();
204 auto info = (HRilRadioResponseInfo *)data.ReadRawData(sizeof(HRilRadioResponseInfo));
205 if (info == nullptr) {
206 TELEPHONY_LOGE("OnSwitchCallResponseInner return, info is nullptr.");
207 return TELEPHONY_ERR_ARGUMENT_INVALID;
208 }
209 reply.WriteInt32(SwitchCallResponse(slotId, *info));
210 return TELEPHONY_SUCCESS;
211 }
212
OnStartDtmfResponseInner(MessageParcel & data,MessageParcel & reply)213 int32_t ImsCallCallbackStub::OnStartDtmfResponseInner(MessageParcel &data, MessageParcel &reply)
214 {
215 TELEPHONY_LOGI("ImsCallCallbackStub::OnStartDtmfResponseInner entry");
216 int32_t slotId = data.ReadInt32();
217 auto info = (HRilRadioResponseInfo *)data.ReadRawData(sizeof(HRilRadioResponseInfo));
218 if (info == nullptr) {
219 TELEPHONY_LOGE("OnStartDtmfResponseInner return, info is nullptr.");
220 return TELEPHONY_ERR_ARGUMENT_INVALID;
221 }
222 reply.WriteInt32(StartDtmfResponse(slotId, *info));
223 return TELEPHONY_SUCCESS;
224 }
225
OnSendDtmfResponseInner(MessageParcel & data,MessageParcel & reply)226 int32_t ImsCallCallbackStub::OnSendDtmfResponseInner(MessageParcel &data, MessageParcel &reply)
227 {
228 TELEPHONY_LOGI("ImsCallCallbackStub::OnSendDtmfResponseInner entry");
229 int32_t slotId = data.ReadInt32();
230 auto info = (HRilRadioResponseInfo *)data.ReadRawData(sizeof(HRilRadioResponseInfo));
231 if (info == nullptr) {
232 TELEPHONY_LOGE("OnSendDtmfResponseInner return, info is nullptr.");
233 return TELEPHONY_ERR_ARGUMENT_INVALID;
234 }
235 reply.WriteInt32(SendDtmfResponse(slotId, *info));
236 return TELEPHONY_SUCCESS;
237 }
238
OnStopDtmfResponseInner(MessageParcel & data,MessageParcel & reply)239 int32_t ImsCallCallbackStub::OnStopDtmfResponseInner(MessageParcel &data, MessageParcel &reply)
240 {
241 TELEPHONY_LOGI("ImsCallCallbackStub::OnStopDtmfResponseInner entry");
242 int32_t slotId = data.ReadInt32();
243 auto info = (HRilRadioResponseInfo *)data.ReadRawData(sizeof(HRilRadioResponseInfo));
244 if (info == nullptr) {
245 TELEPHONY_LOGE("OnStopDtmfResponseInner return, info is nullptr.");
246 return TELEPHONY_ERR_ARGUMENT_INVALID;
247 }
248 reply.WriteInt32(StopDtmfResponse(slotId, *info));
249 return TELEPHONY_SUCCESS;
250 }
251
OnCallStateChangeReportInner(MessageParcel & data,MessageParcel & reply)252 int32_t ImsCallCallbackStub::OnCallStateChangeReportInner(MessageParcel &data, MessageParcel &reply)
253 {
254 TELEPHONY_LOGI("ImsCallCallbackStub::OnCallStateChangeReportInner entry");
255 int32_t slotId = data.ReadInt32();
256 reply.WriteInt32(CallStateChangeReport(slotId));
257 return TELEPHONY_SUCCESS;
258 }
259
OnSetImsSwitchResponseInner(MessageParcel & data,MessageParcel & reply)260 int32_t ImsCallCallbackStub::OnSetImsSwitchResponseInner(MessageParcel &data, MessageParcel &reply)
261 {
262 TELEPHONY_LOGI("ImsCallCallbackStub::OnSetImsSwitchResponseInner entry");
263 int32_t slotId = data.ReadInt32();
264 auto info = (HRilRadioResponseInfo *)data.ReadRawData(sizeof(HRilRadioResponseInfo));
265 if (info == nullptr) {
266 TELEPHONY_LOGE("OnSetImsSwitchResponseInner return, info is nullptr.");
267 return TELEPHONY_ERR_ARGUMENT_INVALID;
268 }
269 reply.WriteInt32(SetImsSwitchResponse(slotId, *info));
270 return TELEPHONY_SUCCESS;
271 }
272
OnGetImsSwitchResponseInner(MessageParcel & data,MessageParcel & reply)273 int32_t ImsCallCallbackStub::OnGetImsSwitchResponseInner(MessageParcel &data, MessageParcel &reply)
274 {
275 TELEPHONY_LOGI("ImsCallCallbackStub::OnGetImsSwitchResponseInner entry");
276 int32_t slotId = data.ReadInt32();
277 auto info = (HRilRadioResponseInfo *)data.ReadRawData(sizeof(HRilRadioResponseInfo));
278 if (info == nullptr) {
279 TELEPHONY_LOGE("OnGetImsSwitchResponseInner, info is nullptr.");
280 int32_t active = data.ReadInt32();
281 reply.WriteInt32(GetImsSwitchResponse(slotId, active));
282 return TELEPHONY_SUCCESS;
283 }
284 reply.WriteInt32(GetImsSwitchResponse(slotId, *info));
285 return TELEPHONY_SUCCESS;
286 }
287
OnGetImsCallsDataResponseInner(MessageParcel & data,MessageParcel & reply)288 int32_t ImsCallCallbackStub::OnGetImsCallsDataResponseInner(MessageParcel &data, MessageParcel &reply)
289 {
290 TELEPHONY_LOGI("ImsCallCallbackStub::OnGetImsCallsDataResponseInner entry");
291 int32_t slotId = data.ReadInt32();
292 auto info = (HRilRadioResponseInfo *)data.ReadRawData(sizeof(HRilRadioResponseInfo));
293 if (info == nullptr) {
294 TELEPHONY_LOGE("OnGetImsCallsDataResponseInner, info is nullptr.");
295 auto callList = (ImsCurrentCallList *)data.ReadRawData(sizeof(ImsCurrentCallList));
296 if (callList == nullptr) {
297 TELEPHONY_LOGE("OnGetImsCallsDataResponseInner, callList is nullptr.");
298 return TELEPHONY_ERR_ARGUMENT_INVALID;
299 }
300 reply.WriteInt32(GetImsCallsDataResponse(slotId, *callList));
301 return TELEPHONY_SUCCESS;
302 }
303 reply.WriteInt32(GetImsCallsDataResponse(slotId, *info));
304 return TELEPHONY_SUCCESS;
305 }
306
OnSetMuteResponseInner(MessageParcel & data,MessageParcel & reply)307 int32_t ImsCallCallbackStub::OnSetMuteResponseInner(MessageParcel &data, MessageParcel &reply)
308 {
309 TELEPHONY_LOGI("ImsCallCallbackStub::OnSetMuteResponseInner entry");
310 int32_t slotId = data.ReadInt32();
311 auto info = (MuteControlResponse *)data.ReadRawData(sizeof(MuteControlResponse));
312 if (info == nullptr) {
313 TELEPHONY_LOGE("OnSetMuteResponseInner return, info is nullptr.");
314 return TELEPHONY_ERR_ARGUMENT_INVALID;
315 }
316 reply.WriteInt32(SetMuteResponse(slotId, *info));
317 return TELEPHONY_SUCCESS;
318 }
319
OnCallRingBackReportInner(MessageParcel & data,MessageParcel & reply)320 int32_t ImsCallCallbackStub::OnCallRingBackReportInner(MessageParcel &data, MessageParcel &reply)
321 {
322 TELEPHONY_LOGI("ImsCallCallbackStub::OnCallRingBackReportInner entry");
323 int32_t slotId = data.ReadInt32();
324 auto info = (RingbackVoice *)data.ReadRawData(sizeof(RingbackVoice));
325 if (info == nullptr) {
326 TELEPHONY_LOGE("OnCallRingBackReportInner return, info is nullptr.");
327 return TELEPHONY_ERR_ARGUMENT_INVALID;
328 }
329 reply.WriteInt32(CallRingBackReport(slotId, *info));
330 return TELEPHONY_SUCCESS;
331 }
332
OnLastCallFailReasonResponseInner(MessageParcel & data,MessageParcel & reply)333 int32_t ImsCallCallbackStub::OnLastCallFailReasonResponseInner(MessageParcel &data, MessageParcel &reply)
334 {
335 TELEPHONY_LOGI("ImsCallCallbackStub::OnLastCallFailReasonResponseInner entry");
336 int32_t slotId = data.ReadInt32();
337 auto details = (DisconnectedDetails *)data.ReadRawData(sizeof(DisconnectedDetails));
338 reply.WriteInt32(LastCallFailReasonResponse(slotId, *details));
339 return TELEPHONY_SUCCESS;
340 }
341
OnSetClipResponseInner(MessageParcel & data,MessageParcel & reply)342 int32_t ImsCallCallbackStub::OnSetClipResponseInner(MessageParcel &data, MessageParcel &reply)
343 {
344 TELEPHONY_LOGI("ImsCallCallbackStub::OnSetClipResponseInner entry");
345 int32_t slotId = data.ReadInt32();
346 auto info = (HRilRadioResponseInfo *)data.ReadRawData(sizeof(HRilRadioResponseInfo));
347 if (info == nullptr) {
348 TELEPHONY_LOGE("OnGetClipResponseInner return, response is nullptr.");
349 return TELEPHONY_ERR_ARGUMENT_INVALID;
350 }
351 reply.WriteInt32(SetClipResponse(slotId, *info));
352 return TELEPHONY_SUCCESS;
353 }
354
OnGetClipResponseInner(MessageParcel & data,MessageParcel & reply)355 int32_t ImsCallCallbackStub::OnGetClipResponseInner(MessageParcel &data, MessageParcel &reply)
356 {
357 TELEPHONY_LOGI("ImsCallCallbackStub::OnGetClipResponseInner entry");
358 int32_t slotId = data.ReadInt32();
359 auto response = (ClipResponse *)data.ReadRawData(sizeof(ClipResponse));
360 if (response == nullptr) {
361 TELEPHONY_LOGE("OnGetClipResponseInner return, response is nullptr.");
362 return TELEPHONY_ERR_ARGUMENT_INVALID;
363 }
364 reply.WriteInt32(GetClipResponse(slotId, *response));
365 return TELEPHONY_SUCCESS;
366 }
367
OnGetClirResponseInner(MessageParcel & data,MessageParcel & reply)368 int32_t ImsCallCallbackStub::OnGetClirResponseInner(MessageParcel &data, MessageParcel &reply)
369 {
370 TELEPHONY_LOGI("ImsCallCallbackStub::OnGetClirResponseInner entry");
371 int32_t slotId = data.ReadInt32();
372 auto response = (ClirResponse *)data.ReadRawData(sizeof(ClirResponse));
373 if (response == nullptr) {
374 TELEPHONY_LOGE("OnGetClirResponseInner return, response is nullptr.");
375 return TELEPHONY_ERR_ARGUMENT_INVALID;
376 }
377 reply.WriteInt32(GetClirResponse(slotId, *response));
378 return TELEPHONY_SUCCESS;
379 }
380
OnSetClirResponseInner(MessageParcel & data,MessageParcel & reply)381 int32_t ImsCallCallbackStub::OnSetClirResponseInner(MessageParcel &data, MessageParcel &reply)
382 {
383 TELEPHONY_LOGI("ImsCallCallbackStub::OnSetClirResponseInner entry");
384 int32_t slotId = data.ReadInt32();
385 auto info = (HRilRadioResponseInfo *)data.ReadRawData(sizeof(HRilRadioResponseInfo));
386 if (info == nullptr) {
387 TELEPHONY_LOGE("OnGetClipResponseInner return, response is nullptr.");
388 return TELEPHONY_ERR_ARGUMENT_INVALID;
389 }
390 reply.WriteInt32(SetClirResponse(slotId, *info));
391 return TELEPHONY_SUCCESS;
392 }
393
OnGetCallTransferResponseInner(MessageParcel & data,MessageParcel & reply)394 int32_t ImsCallCallbackStub::OnGetCallTransferResponseInner(MessageParcel &data, MessageParcel &reply)
395 {
396 TELEPHONY_LOGI("ImsCallCallbackStub::OnGetCallTransferResponseInner entry");
397 int32_t slotId = data.ReadInt32();
398 auto response = (CallTransferResponse *)data.ReadRawData(sizeof(CallTransferResponse));
399 if (response == nullptr) {
400 TELEPHONY_LOGE("OnGetCallTransferResponseInner return, response is nullptr.");
401 return TELEPHONY_ERR_ARGUMENT_INVALID;
402 }
403 reply.WriteInt32(GetCallTransferResponse(slotId, *response));
404 return TELEPHONY_SUCCESS;
405 }
406
OnSetCallTransferResponseInner(MessageParcel & data,MessageParcel & reply)407 int32_t ImsCallCallbackStub::OnSetCallTransferResponseInner(MessageParcel &data, MessageParcel &reply)
408 {
409 TELEPHONY_LOGI("ImsCallCallbackStub::OnSetCallTransferResponseInner entry");
410 int32_t slotId = data.ReadInt32();
411 auto info = (HRilRadioResponseInfo *)data.ReadRawData(sizeof(HRilRadioResponseInfo));
412 if (info == nullptr) {
413 TELEPHONY_LOGE("OnGetClipResponseInner return, response is nullptr.");
414 return TELEPHONY_ERR_ARGUMENT_INVALID;
415 }
416 reply.WriteInt32(SetCallTransferResponse(slotId, *info));
417 return TELEPHONY_SUCCESS;
418 }
419
OnGetCallRestrictionResponseInner(MessageParcel & data,MessageParcel & reply)420 int32_t ImsCallCallbackStub::OnGetCallRestrictionResponseInner(MessageParcel &data, MessageParcel &reply)
421 {
422 TELEPHONY_LOGI("ImsCallCallbackStub::OnGetCallRestrictionResponseInner entry");
423 int32_t slotId = data.ReadInt32();
424 auto response = (CallRestrictionResponse *)data.ReadRawData(sizeof(CallRestrictionResponse));
425 if (response == nullptr) {
426 TELEPHONY_LOGE("OnGetCallRestrictionResponseInner return, response is nullptr.");
427 return TELEPHONY_ERR_ARGUMENT_INVALID;
428 }
429 reply.WriteInt32(GetCallRestrictionResponse(slotId, *response));
430 return TELEPHONY_SUCCESS;
431 }
432
OnSetCallRestrictionResponseInner(MessageParcel & data,MessageParcel & reply)433 int32_t ImsCallCallbackStub::OnSetCallRestrictionResponseInner(MessageParcel &data, MessageParcel &reply)
434 {
435 TELEPHONY_LOGI("ImsCallCallbackStub::OnSetCallRestrictionResponseInner entry");
436 int32_t slotId = data.ReadInt32();
437 auto info = (HRilRadioResponseInfo *)data.ReadRawData(sizeof(HRilRadioResponseInfo));
438 if (info == nullptr) {
439 TELEPHONY_LOGE("OnSetCallRestrictionResponseInner return, response is nullptr.");
440 return TELEPHONY_ERR_ARGUMENT_INVALID;
441 }
442 reply.WriteInt32(SetCallRestrictionResponse(slotId, *info));
443 return TELEPHONY_SUCCESS;
444 }
445
OnGetCallWaitingResponseInner(MessageParcel & data,MessageParcel & reply)446 int32_t ImsCallCallbackStub::OnGetCallWaitingResponseInner(MessageParcel &data, MessageParcel &reply)
447 {
448 TELEPHONY_LOGI("ImsCallCallbackStub::OnGetCallWaitingResponseInner entry");
449 int32_t slotId = data.ReadInt32();
450 auto response = (CallWaitResponse *)data.ReadRawData(sizeof(CallWaitResponse));
451 if (response == nullptr) {
452 TELEPHONY_LOGE("OnGetCallWaitingResponseInner return, response is nullptr.");
453 return TELEPHONY_ERR_ARGUMENT_INVALID;
454 }
455 reply.WriteInt32(GetCallWaitingResponse(slotId, *response));
456 return TELEPHONY_SUCCESS;
457 }
458
OnSetCallWaitingResponseInner(MessageParcel & data,MessageParcel & reply)459 int32_t ImsCallCallbackStub::OnSetCallWaitingResponseInner(MessageParcel &data, MessageParcel &reply)
460 {
461 TELEPHONY_LOGI("ImsCallCallbackStub::OnSetCallWaitingResponseInner entry");
462 int32_t slotId = data.ReadInt32();
463 auto info = (HRilRadioResponseInfo *)data.ReadRawData(sizeof(HRilRadioResponseInfo));
464 if (info == nullptr) {
465 TELEPHONY_LOGE("OnGetCallWaitingResponseInner return, response is nullptr.");
466 return TELEPHONY_ERR_ARGUMENT_INVALID;
467 }
468 reply.WriteInt32(SetCallWaitingResponse(slotId, *info));
469 return TELEPHONY_SUCCESS;
470 }
471
OnSetColrResponseInner(MessageParcel & data,MessageParcel & reply)472 int32_t ImsCallCallbackStub::OnSetColrResponseInner(MessageParcel &data, MessageParcel &reply)
473 {
474 TELEPHONY_LOGI("ImsCallCallbackStub::OnSetColrResponseInner entry");
475 int32_t slotId = data.ReadInt32();
476 auto info = (HRilRadioResponseInfo *)data.ReadRawData(sizeof(HRilRadioResponseInfo));
477 if (info == nullptr) {
478 TELEPHONY_LOGE("OnSetColrResponseInner return, response is nullptr.");
479 return TELEPHONY_ERR_ARGUMENT_INVALID;
480 }
481 reply.WriteInt32(SetColrResponse(slotId, *info));
482 return TELEPHONY_SUCCESS;
483 }
484
OnGetColrResponseInner(MessageParcel & data,MessageParcel & reply)485 int32_t ImsCallCallbackStub::OnGetColrResponseInner(MessageParcel &data, MessageParcel &reply)
486 {
487 TELEPHONY_LOGI("ImsCallCallbackStub::OnGetColrResponseInner entry");
488 int32_t slotId = data.ReadInt32();
489 auto response = (ColrResponse *)data.ReadRawData(sizeof(ColrResponse));
490 if (response == nullptr) {
491 TELEPHONY_LOGE("OnGetColrResponseInner return, response is nullptr.");
492 return TELEPHONY_ERR_ARGUMENT_INVALID;
493 }
494 reply.WriteInt32(GetColrResponse(slotId, *response));
495 return TELEPHONY_SUCCESS;
496 }
497
OnSetColpResponseInner(MessageParcel & data,MessageParcel & reply)498 int32_t ImsCallCallbackStub::OnSetColpResponseInner(MessageParcel &data, MessageParcel &reply)
499 {
500 TELEPHONY_LOGI("ImsCallCallbackStub::OnSetColpResponseInner entry");
501 int32_t slotId = data.ReadInt32();
502 auto info = (HRilRadioResponseInfo *)data.ReadRawData(sizeof(HRilRadioResponseInfo));
503 if (info == nullptr) {
504 TELEPHONY_LOGE("OnSetColpResponseInner return, response is nullptr.");
505 return TELEPHONY_ERR_ARGUMENT_INVALID;
506 }
507 reply.WriteInt32(SetColpResponse(slotId, *info));
508 return TELEPHONY_SUCCESS;
509 }
510
OnGetColpResponseInner(MessageParcel & data,MessageParcel & reply)511 int32_t ImsCallCallbackStub::OnGetColpResponseInner(MessageParcel &data, MessageParcel &reply)
512 {
513 TELEPHONY_LOGI("ImsCallCallbackStub::OnGetColpResponseInner entry");
514 int32_t slotId = data.ReadInt32();
515 auto response = (ColpResponse *)data.ReadRawData(sizeof(ColpResponse));
516 if (response == nullptr) {
517 TELEPHONY_LOGE("OnGetColpResponseInner return, response is nullptr.");
518 return TELEPHONY_ERR_ARGUMENT_INVALID;
519 }
520 reply.WriteInt32(GetColpResponse(slotId, *response));
521 return TELEPHONY_SUCCESS;
522 }
523
DialResponse(int32_t slotId,const HRilRadioResponseInfo & info)524 int32_t ImsCallCallbackStub::DialResponse(int32_t slotId, const HRilRadioResponseInfo &info)
525 {
526 TELEPHONY_LOGI("ImsCallCallbackStub::DialResponse entry");
527 return SendEvent(slotId, RadioEvent::RADIO_DIAL, info);
528 }
529
HangUpResponse(int32_t slotId,const HRilRadioResponseInfo & info)530 int32_t ImsCallCallbackStub::HangUpResponse(int32_t slotId, const HRilRadioResponseInfo &info)
531 {
532 TELEPHONY_LOGI("ImsCallCallbackStub::HangUpResponse entry");
533 return SendEvent(slotId, RadioEvent::RADIO_HANGUP_CONNECT, info);
534 }
535
RejectWithReasonResponse(int32_t slotId,const HRilRadioResponseInfo & info)536 int32_t ImsCallCallbackStub::RejectWithReasonResponse(int32_t slotId, const HRilRadioResponseInfo &info)
537 {
538 TELEPHONY_LOGI("ImsCallCallbackStub::RejectWithReasonResponse entry");
539 return SendEvent(slotId, RadioEvent::RADIO_REJECT_CALL, info);
540 }
541
AnswerResponse(int32_t slotId,const HRilRadioResponseInfo & info)542 int32_t ImsCallCallbackStub::AnswerResponse(int32_t slotId, const HRilRadioResponseInfo &info)
543 {
544 TELEPHONY_LOGI("ImsCallCallbackStub::AnswerResponse entry");
545 return SendEvent(slotId, RadioEvent::RADIO_ACCEPT_CALL, info);
546 }
547
HoldCallResponse(int32_t slotId,const HRilRadioResponseInfo & info)548 int32_t ImsCallCallbackStub::HoldCallResponse(int32_t slotId, const HRilRadioResponseInfo &info)
549 {
550 TELEPHONY_LOGI("ImsCallCallbackStub::HoldCallResponse entry");
551 return SendEvent(slotId, RadioEvent::RADIO_HOLD_CALL, info);
552 }
553
UnHoldCallResponse(int32_t slotId,const HRilRadioResponseInfo & info)554 int32_t ImsCallCallbackStub::UnHoldCallResponse(int32_t slotId, const HRilRadioResponseInfo &info)
555 {
556 TELEPHONY_LOGI("ImsCallCallbackStub::UnHoldCallResponse entry");
557 return SendEvent(slotId, RadioEvent::RADIO_ACTIVE_CALL, info);
558 }
559
SwitchCallResponse(int32_t slotId,const HRilRadioResponseInfo & info)560 int32_t ImsCallCallbackStub::SwitchCallResponse(int32_t slotId, const HRilRadioResponseInfo &info)
561 {
562 TELEPHONY_LOGI("ImsCallCallbackStub::SwitchCallResponse entry");
563 return SendEvent(slotId, RadioEvent::RADIO_SWAP_CALL, info);
564 }
565
StartDtmfResponse(int32_t slotId,const HRilRadioResponseInfo & info)566 int32_t ImsCallCallbackStub::StartDtmfResponse(int32_t slotId, const HRilRadioResponseInfo &info)
567 {
568 TELEPHONY_LOGI("ImsCallCallbackStub::StartDtmfResponse entry");
569 return SendEvent(slotId, RadioEvent::RADIO_START_DTMF, info);
570 }
571
SendDtmfResponse(int32_t slotId,const HRilRadioResponseInfo & info)572 int32_t ImsCallCallbackStub::SendDtmfResponse(int32_t slotId, const HRilRadioResponseInfo &info)
573 {
574 TELEPHONY_LOGI("ImsCallCallbackStub::SendDtmfResponse entry");
575 return SendEvent(slotId, RadioEvent::RADIO_SEND_DTMF, info);
576 }
577
StopDtmfResponse(int32_t slotId,const HRilRadioResponseInfo & info)578 int32_t ImsCallCallbackStub::StopDtmfResponse(int32_t slotId, const HRilRadioResponseInfo &info)
579 {
580 TELEPHONY_LOGI("ImsCallCallbackStub::StopDtmfResponse entry");
581 return SendEvent(slotId, RadioEvent::RADIO_STOP_DTMF, info);
582 }
583
CallStateChangeReport(int32_t slotId)584 int32_t ImsCallCallbackStub::CallStateChangeReport(int32_t slotId)
585 {
586 TELEPHONY_LOGI("ImsCallCallbackStub::CallStateChangeReport entry");
587 std::shared_ptr<AppExecFwk::EventHandler> handler =
588 DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
589 if (handler.get() == nullptr) {
590 TELEPHONY_LOGE("handler is nullptr");
591 return TELEPHONY_ERR_LOCAL_PTR_NULL;
592 }
593
594 bool ret = handler->SendEvent(RadioEvent::RADIO_IMS_CALL_STATUS_INFO);
595 if (!ret) {
596 TELEPHONY_LOGE("SendEvent failed! status update failed, slotId:%{public}d", slotId);
597 return TELEPHONY_ERR_FAIL;
598 }
599 return TELEPHONY_SUCCESS;
600 }
601
GetImsCallsDataResponse(int32_t slotId,const HRilRadioResponseInfo & info)602 int32_t ImsCallCallbackStub::GetImsCallsDataResponse(int32_t slotId, const HRilRadioResponseInfo &info)
603 {
604 TELEPHONY_LOGI("ImsCallCallbackStub::GetImsCallsDataResponse entry");
605 return SendEvent(slotId, RadioEvent::RADIO_IMS_GET_CALL_DATA, info);
606 }
607
GetImsCallsDataResponse(int32_t slotId,const ImsCurrentCallList & callList)608 int32_t ImsCallCallbackStub::GetImsCallsDataResponse(int32_t slotId, const ImsCurrentCallList &callList)
609 {
610 TELEPHONY_LOGI("ImsCallCallbackStub::GetImsCallsDataResponse entry");
611 std::shared_ptr<AppExecFwk::EventHandler> handler =
612 DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
613 if (handler.get() == nullptr) {
614 TELEPHONY_LOGE("handler is nullptr");
615 return TELEPHONY_ERR_LOCAL_PTR_NULL;
616 }
617 std::shared_ptr<ImsCurrentCallList> imsCurrentCallList = std::make_shared<ImsCurrentCallList>();
618 if (imsCurrentCallList == nullptr) {
619 TELEPHONY_LOGE("make_shared ImsCurrentCallList failed!");
620 return TELEPHONY_ERR_LOCAL_PTR_NULL;
621 }
622 *imsCurrentCallList = callList;
623 bool ret = handler->SendEvent(RadioEvent::RADIO_IMS_GET_CALL_DATA, imsCurrentCallList);
624 if (!ret) {
625 TELEPHONY_LOGE("SendEvent failed! status update failed, slotId:%{public}d", slotId);
626 return TELEPHONY_ERR_FAIL;
627 }
628 return TELEPHONY_SUCCESS;
629 }
630
SetImsSwitchResponse(int32_t slotId,const HRilRadioResponseInfo & info)631 int32_t ImsCallCallbackStub::SetImsSwitchResponse(int32_t slotId, const HRilRadioResponseInfo &info)
632 {
633 TELEPHONY_LOGI("ImsCallCallbackStub::SetImsSwitchResponse entry");
634 return SendEvent(slotId, RadioEvent::RADIO_SET_IMS_SWITCH_STATUS, info);
635 }
636
GetImsSwitchResponse(int32_t slotId,const HRilRadioResponseInfo & info)637 int32_t ImsCallCallbackStub::GetImsSwitchResponse(int32_t slotId, const HRilRadioResponseInfo &info)
638 {
639 TELEPHONY_LOGI("ImsCallCallbackStub::GetImsSwitchResponse entry");
640 return SendEvent(slotId, RadioEvent::RADIO_GET_IMS_SWITCH_STATUS, info);
641 }
642
GetImsSwitchResponse(int32_t slotId,int32_t active)643 int32_t ImsCallCallbackStub::GetImsSwitchResponse(int32_t slotId, int32_t active)
644 {
645 TELEPHONY_LOGI("ImsCallCallbackStub::GetImsSwitchResponse entry active:%{public}d", active);
646 DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId)->SendEvent(
647 RadioEvent::RADIO_GET_IMS_SWITCH_STATUS, active);
648 return TELEPHONY_SUCCESS;
649 }
650
SetMuteResponse(int32_t slotId,const MuteControlResponse & response)651 int32_t ImsCallCallbackStub::SetMuteResponse(int32_t slotId, const MuteControlResponse &response)
652 {
653 TELEPHONY_LOGI("ImsCallCallbackStub::SetMuteResponse entry");
654 return TELEPHONY_SUCCESS;
655 }
656
CallRingBackReport(int32_t slotId,const RingbackVoice & info)657 int32_t ImsCallCallbackStub::CallRingBackReport(int32_t slotId, const RingbackVoice &info)
658 {
659 TELEPHONY_LOGI("ImsCallCallbackStub::CallRingBackReport entry");
660 std::shared_ptr<AppExecFwk::EventHandler> handler =
661 DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
662 if (handler.get() == nullptr) {
663 TELEPHONY_LOGE("handler is nullptr");
664 return TELEPHONY_ERR_LOCAL_PTR_NULL;
665 }
666 std::shared_ptr<RingbackVoice> ringbackVoice = std::make_shared<RingbackVoice>();
667 if (ringbackVoice == nullptr) {
668 TELEPHONY_LOGE("make_shared RingbackVoice failed!");
669 return TELEPHONY_ERR_LOCAL_PTR_NULL;
670 }
671 *ringbackVoice = info;
672 bool ret = handler->SendEvent(RadioEvent::RADIO_CALL_RINGBACK_VOICE, ringbackVoice);
673 if (!ret) {
674 TELEPHONY_LOGE("SendEvent failed! status update failed, slotId:%{public}d", slotId);
675 return TELEPHONY_ERR_FAIL;
676 }
677 return TELEPHONY_SUCCESS;
678 }
679
LastCallFailReasonResponse(int32_t slotId,const DisconnectedDetails & details)680 int32_t ImsCallCallbackStub::LastCallFailReasonResponse(int32_t slotId, const DisconnectedDetails &details)
681 {
682 TELEPHONY_LOGI("ImsCallCallbackStub::LastCallFailReasonResponse entry, reason is %{public}d", details.reason);
683 std::shared_ptr<AppExecFwk::EventHandler> handler =
684 DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
685 if (handler.get() == nullptr) {
686 TELEPHONY_LOGE("handler is nullptr");
687 return TELEPHONY_ERR_LOCAL_PTR_NULL;
688 }
689 std::shared_ptr<DisconnectedDetails> detailsInfo = std::make_shared<DisconnectedDetails>();
690 if (detailsInfo == nullptr) {
691 TELEPHONY_LOGE("make_shared detailsInfo failed!");
692 return TELEPHONY_ERR_LOCAL_PTR_NULL;
693 }
694 detailsInfo->reason = details.reason;
695 detailsInfo->message = details.message;
696 CellularCallConfig config;
697 auto vecReasonInfo = config.GetImsCallDisconnectResoninfoMappingConfig(slotId);
698 for (auto reasonInfo : vecReasonInfo) {
699 char *p = nullptr;
700 char *ptr = nullptr;
701 ptr = strtok_r((char *)(reasonInfo.c_str()), "|", &p);
702 int32_t tmpReason = (int32_t)std::atoi(ptr);
703 int flag = false;
704 while (tmpReason == static_cast<int32_t>(detailsInfo->reason)) {
705 ptr = strtok_r(nullptr, "|", &p);
706 if (ptr == nullptr) {
707 break;
708 }
709 if (!flag) {
710 detailsInfo->message = ptr;
711 flag = true;
712 } else {
713 detailsInfo->reason = static_cast<DisconnectedReason>(std::atoi(ptr));
714 }
715 }
716 if (flag) {
717 break;
718 }
719 }
720 bool ret = handler->SendEvent(RadioEvent::RADIO_GET_CALL_FAIL_REASON, detailsInfo);
721 if (!ret) {
722 TELEPHONY_LOGE("SendEvent failed! status update failed, slotId:%{public}d", slotId);
723 return TELEPHONY_ERR_FAIL;
724 }
725 return TELEPHONY_SUCCESS;
726 }
727
SetClipResponse(int32_t slotId,const HRilRadioResponseInfo & info)728 int32_t ImsCallCallbackStub::SetClipResponse(int32_t slotId, const HRilRadioResponseInfo &info)
729 {
730 TELEPHONY_LOGI("ImsCallCallbackStub::SetClipResponse entry");
731 return SendEvent(slotId, RadioEvent::RADIO_IMS_SET_CLIP, info);
732 }
733
GetClipResponse(int32_t slotId,const ClipResponse & response)734 int32_t ImsCallCallbackStub::GetClipResponse(int32_t slotId, const ClipResponse &response)
735 {
736 TELEPHONY_LOGI("ImsCallCallbackStub::GetClipResponse entry");
737 std::shared_ptr<AppExecFwk::EventHandler> handler =
738 DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
739 if (handler.get() == nullptr) {
740 TELEPHONY_LOGE("handler is nullptr");
741 return TELEPHONY_ERR_LOCAL_PTR_NULL;
742 }
743 std::shared_ptr<ClipResponse> clipResponse = std::make_shared<ClipResponse>();
744 if (clipResponse == nullptr) {
745 TELEPHONY_LOGE("make_shared ClipResponse failed!");
746 return TELEPHONY_ERR_LOCAL_PTR_NULL;
747 }
748 *clipResponse = response;
749 bool ret = handler->SendEvent(RadioEvent::RADIO_GET_CALL_CLIP, clipResponse);
750 if (!ret) {
751 TELEPHONY_LOGE("SendEvent failed! status update failed, slotId:%{public}d", slotId);
752 return TELEPHONY_ERR_FAIL;
753 }
754 return TELEPHONY_SUCCESS;
755 }
756
GetClirResponse(int32_t slotId,const ClirResponse & response)757 int32_t ImsCallCallbackStub::GetClirResponse(int32_t slotId, const ClirResponse &response)
758 {
759 TELEPHONY_LOGI("ImsCallCallbackStub::GetClirResponse entry");
760 std::shared_ptr<AppExecFwk::EventHandler> handler =
761 DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
762 if (handler.get() == nullptr) {
763 TELEPHONY_LOGE("handler is nullptr");
764 return TELEPHONY_ERR_LOCAL_PTR_NULL;
765 }
766 std::shared_ptr<ClirResponse> clirResponse = std::make_shared<ClirResponse>();
767 if (clirResponse == nullptr) {
768 TELEPHONY_LOGE("make_shared ClirResponse failed!");
769 return TELEPHONY_ERR_LOCAL_PTR_NULL;
770 }
771 *clirResponse = response;
772 bool ret = handler->SendEvent(RadioEvent::RADIO_GET_CALL_CLIR, clirResponse);
773 if (!ret) {
774 TELEPHONY_LOGE("SendEvent failed! status update failed, slotId:%{public}d", slotId);
775 return TELEPHONY_ERR_FAIL;
776 }
777 return TELEPHONY_SUCCESS;
778 }
779
SetClirResponse(int32_t slotId,const HRilRadioResponseInfo & info)780 int32_t ImsCallCallbackStub::SetClirResponse(int32_t slotId, const HRilRadioResponseInfo &info)
781 {
782 TELEPHONY_LOGI("ImsCallCallbackStub::SetClirResponse entry");
783 return SendEvent(slotId, RadioEvent::RADIO_GET_CALL_CLIR, info);
784 }
785
GetCallTransferResponse(int32_t slotId,const CallTransferResponse & response)786 int32_t ImsCallCallbackStub::GetCallTransferResponse(int32_t slotId, const CallTransferResponse &response)
787 {
788 TELEPHONY_LOGI("ImsCallCallbackStub::GetCallTransferResponse entry");
789 std::shared_ptr<AppExecFwk::EventHandler> handler =
790 DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
791 if (handler.get() == nullptr) {
792 TELEPHONY_LOGE("handler is nullptr");
793 return TELEPHONY_ERR_LOCAL_PTR_NULL;
794 }
795 std::shared_ptr<CallTransferResponse> callTransferResponse = std::make_shared<CallTransferResponse>();
796 if (callTransferResponse == nullptr) {
797 TELEPHONY_LOGE("make_shared CallTransferResponse failed!");
798 return TELEPHONY_ERR_LOCAL_PTR_NULL;
799 }
800 *callTransferResponse = response;
801 bool ret = handler->SendEvent(RadioEvent::RADIO_GET_CALL_FORWARD, callTransferResponse);
802 if (!ret) {
803 TELEPHONY_LOGE("SendEvent failed! status update failed, slotId:%{public}d", slotId);
804 return TELEPHONY_ERR_FAIL;
805 }
806 return TELEPHONY_SUCCESS;
807 }
808
SetCallTransferResponse(int32_t slotId,const HRilRadioResponseInfo & info)809 int32_t ImsCallCallbackStub::SetCallTransferResponse(int32_t slotId, const HRilRadioResponseInfo &info)
810 {
811 TELEPHONY_LOGI("ImsCallCallbackStub::SetCallTransferResponse entry");
812 return SendEvent(slotId, RadioEvent::RADIO_SET_CALL_FORWARD, info);
813 }
814
GetCallRestrictionResponse(int32_t slotId,const CallRestrictionResponse & response)815 int32_t ImsCallCallbackStub::GetCallRestrictionResponse(int32_t slotId, const CallRestrictionResponse &response)
816 {
817 TELEPHONY_LOGI("ImsCallCallbackStub::GetCallRestrictionResponse entry");
818 std::shared_ptr<AppExecFwk::EventHandler> handler =
819 DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
820 if (handler.get() == nullptr) {
821 TELEPHONY_LOGE("handler is nullptr");
822 return TELEPHONY_ERR_LOCAL_PTR_NULL;
823 }
824 std::shared_ptr<CallRestrictionResponse> callRestrictionResponse = std::make_shared<CallRestrictionResponse>();
825 if (callRestrictionResponse == nullptr) {
826 TELEPHONY_LOGE("make_shared CallRestrictionResponse failed!");
827 return TELEPHONY_ERR_LOCAL_PTR_NULL;
828 }
829 *callRestrictionResponse = response;
830 bool ret = handler->SendEvent(RadioEvent::RADIO_SET_CALL_RESTRICTION, callRestrictionResponse);
831 if (!ret) {
832 TELEPHONY_LOGE("SendEvent failed! status update failed, slotId:%{public}d", slotId);
833 return TELEPHONY_ERR_FAIL;
834 }
835 return TELEPHONY_SUCCESS;
836 }
837
SetCallRestrictionResponse(int32_t slotId,const HRilRadioResponseInfo & info)838 int32_t ImsCallCallbackStub::SetCallRestrictionResponse(int32_t slotId, const HRilRadioResponseInfo &info)
839 {
840 TELEPHONY_LOGI("ImsCallCallbackStub::SetCallRestrictionResponse entry");
841 return SendEvent(slotId, RadioEvent::RADIO_SET_CALL_RESTRICTION, info);
842 }
843
GetCallWaitingResponse(int32_t slotId,const CallWaitResponse & response)844 int32_t ImsCallCallbackStub::GetCallWaitingResponse(int32_t slotId, const CallWaitResponse &response)
845 {
846 TELEPHONY_LOGI("ImsCallCallbackStub::GetCallWaitingResponse entry");
847 std::shared_ptr<AppExecFwk::EventHandler> handler =
848 DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
849 if (handler.get() == nullptr) {
850 TELEPHONY_LOGE("handler is nullptr");
851 return TELEPHONY_ERR_LOCAL_PTR_NULL;
852 }
853 std::shared_ptr<CallWaitResponse> callWaitResponse = std::make_shared<CallWaitResponse>();
854 if (callWaitResponse == nullptr) {
855 TELEPHONY_LOGE("make_shared CallWaitResponse failed!");
856 return TELEPHONY_ERR_LOCAL_PTR_NULL;
857 }
858 *callWaitResponse = response;
859 bool ret = handler->SendEvent(RadioEvent::RADIO_GET_CALL_WAIT, callWaitResponse);
860 if (!ret) {
861 TELEPHONY_LOGE("SendEvent failed! status update failed, slotId:%{public}d", slotId);
862 return TELEPHONY_ERR_FAIL;
863 }
864 return TELEPHONY_SUCCESS;
865 }
866
SetCallWaitingResponse(int32_t slotId,const HRilRadioResponseInfo & info)867 int32_t ImsCallCallbackStub::SetCallWaitingResponse(int32_t slotId, const HRilRadioResponseInfo &info)
868 {
869 TELEPHONY_LOGI("ImsCallCallbackStub::SetCallWaitingResponse entry");
870 return SendEvent(slotId, RadioEvent::RADIO_SET_CALL_WAIT, info);
871 }
872
SetColrResponse(int32_t slotId,const HRilRadioResponseInfo & info)873 int32_t ImsCallCallbackStub::SetColrResponse(int32_t slotId, const HRilRadioResponseInfo &info)
874 {
875 TELEPHONY_LOGI("ImsCallCallbackStub::SetColrResponse entry");
876 return SendEvent(slotId, RadioEvent::RADIO_IMS_SET_COLR, info);
877 }
878
GetColrResponse(int32_t slotId,const ColrResponse & response)879 int32_t ImsCallCallbackStub::GetColrResponse(int32_t slotId, const ColrResponse &response)
880 {
881 TELEPHONY_LOGI("ImsCallCallbackStub::GetColrResponse entry");
882 std::shared_ptr<AppExecFwk::EventHandler> handler =
883 DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
884 if (handler.get() == nullptr) {
885 TELEPHONY_LOGE("handler is nullptr");
886 return TELEPHONY_ERR_LOCAL_PTR_NULL;
887 }
888 std::shared_ptr<ColrResponse> colrResponse = std::make_shared<ColrResponse>();
889 if (colrResponse == nullptr) {
890 TELEPHONY_LOGE("make_shared ColrResponse failed!");
891 return TELEPHONY_ERR_LOCAL_PTR_NULL;
892 }
893 *colrResponse = response;
894 bool ret = handler->SendEvent(RadioEvent::RADIO_IMS_GET_COLR, colrResponse);
895 if (!ret) {
896 TELEPHONY_LOGE("SendEvent failed! status update failed, slotId:%{public}d", slotId);
897 return TELEPHONY_ERR_FAIL;
898 }
899 return TELEPHONY_SUCCESS;
900 }
901
SetColpResponse(int32_t slotId,const HRilRadioResponseInfo & info)902 int32_t ImsCallCallbackStub::SetColpResponse(int32_t slotId, const HRilRadioResponseInfo &info)
903 {
904 TELEPHONY_LOGI("ImsCallCallbackStub::SetColpResponse entry");
905 return SendEvent(slotId, RadioEvent::RADIO_IMS_SET_COLP, info);
906 }
907
GetColpResponse(int32_t slotId,const ColpResponse & response)908 int32_t ImsCallCallbackStub::GetColpResponse(int32_t slotId, const ColpResponse &response)
909 {
910 TELEPHONY_LOGI("ImsCallCallbackStub::GetColpResponse entry");
911 std::shared_ptr<AppExecFwk::EventHandler> handler =
912 DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
913 if (handler.get() == nullptr) {
914 TELEPHONY_LOGE("handler is nullptr");
915 return TELEPHONY_ERR_LOCAL_PTR_NULL;
916 }
917 std::shared_ptr<ColpResponse> colpResponse = std::make_shared<ColpResponse>();
918 if (colpResponse == nullptr) {
919 TELEPHONY_LOGE("make_shared ColpResponse failed!");
920 return TELEPHONY_ERR_LOCAL_PTR_NULL;
921 }
922 *colpResponse = response;
923 bool ret = handler->SendEvent(RadioEvent::RADIO_IMS_GET_COLP, colpResponse);
924 if (!ret) {
925 TELEPHONY_LOGE("SendEvent failed! status update failed, slotId:%{public}d", slotId);
926 return TELEPHONY_ERR_FAIL;
927 }
928 return TELEPHONY_SUCCESS;
929 }
930
SendEvent(int32_t slotId,int32_t eventId,const HRilRadioResponseInfo & info)931 int32_t ImsCallCallbackStub::SendEvent(int32_t slotId, int32_t eventId, const HRilRadioResponseInfo &info)
932 {
933 std::shared_ptr<AppExecFwk::EventHandler> handler =
934 DelayedSingleton<ImsCallClient>::GetInstance()->GetHandler(slotId);
935 if (handler.get() == nullptr) {
936 TELEPHONY_LOGE("handler is nullptr");
937 return TELEPHONY_ERR_LOCAL_PTR_NULL;
938 }
939 std::shared_ptr<HRilRadioResponseInfo> hRilRadioResponseInfo = std::make_shared<HRilRadioResponseInfo>();
940 if (hRilRadioResponseInfo == nullptr) {
941 TELEPHONY_LOGE("make_shared HRilRadioResponseInfo failed!");
942 return TELEPHONY_ERR_LOCAL_PTR_NULL;
943 }
944 *hRilRadioResponseInfo = info;
945 bool ret = handler->SendEvent(eventId, hRilRadioResponseInfo);
946 if (!ret) {
947 TELEPHONY_LOGE("SendEvent failed! status update failed, slotId:%{public}d", slotId);
948 return TELEPHONY_ERR_FAIL;
949 }
950 return TELEPHONY_SUCCESS;
951 }
952 } // namespace Telephony
953 } // namespace OHOS
954