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_proxy.h"
17
18 #include "message_option.h"
19 #include "message_parcel.h"
20
21 namespace OHOS {
22 namespace Telephony {
ImsCallCallbackProxy(const sptr<IRemoteObject> & impl)23 ImsCallCallbackProxy::ImsCallCallbackProxy(const sptr<IRemoteObject> &impl)
24 : IRemoteProxy<ImsCallCallbackInterface>(impl) {}
25
DialResponse(int32_t slotId,const RadioResponseInfo & info)26 int32_t ImsCallCallbackProxy::DialResponse(int32_t slotId, const RadioResponseInfo &info)
27 {
28 MessageParcel in;
29 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in, info);
30 if (ret != TELEPHONY_SUCCESS) {
31 return ret;
32 }
33 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_DIAL), in);
34 }
35
HangUpResponse(int32_t slotId,const RadioResponseInfo & info)36 int32_t ImsCallCallbackProxy::HangUpResponse(int32_t slotId, const RadioResponseInfo &info)
37 {
38 MessageParcel in;
39 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in, info);
40 if (ret != TELEPHONY_SUCCESS) {
41 return ret;
42 }
43 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_HANG_UP), in);
44 }
45
RejectWithReasonResponse(int32_t slotId,const RadioResponseInfo & info)46 int32_t ImsCallCallbackProxy::RejectWithReasonResponse(int32_t slotId, const RadioResponseInfo &info)
47 {
48 MessageParcel in;
49 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in, info);
50 if (ret != TELEPHONY_SUCCESS) {
51 return ret;
52 }
53 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_REJECT), in);
54 }
55
AnswerResponse(int32_t slotId,const RadioResponseInfo & info)56 int32_t ImsCallCallbackProxy::AnswerResponse(int32_t slotId, const RadioResponseInfo &info)
57 {
58 MessageParcel in;
59 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in, info);
60 if (ret != TELEPHONY_SUCCESS) {
61 return ret;
62 }
63 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_ANSWER), in);
64 }
65
HoldCallResponse(int32_t slotId,const RadioResponseInfo & info)66 int32_t ImsCallCallbackProxy::HoldCallResponse(int32_t slotId, const RadioResponseInfo &info)
67 {
68 MessageParcel in;
69 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in, info);
70 if (ret != TELEPHONY_SUCCESS) {
71 return ret;
72 }
73 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_HOLD), in);
74 }
75
UnHoldCallResponse(int32_t slotId,const RadioResponseInfo & info)76 int32_t ImsCallCallbackProxy::UnHoldCallResponse(int32_t slotId, const RadioResponseInfo &info)
77 {
78 MessageParcel in;
79 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in, info);
80 if (ret != TELEPHONY_SUCCESS) {
81 return ret;
82 }
83 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_UN_HOLD), in);
84 }
85
SwitchCallResponse(int32_t slotId,const RadioResponseInfo & info)86 int32_t ImsCallCallbackProxy::SwitchCallResponse(int32_t slotId, const RadioResponseInfo &info)
87 {
88 MessageParcel in;
89 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in, info);
90 if (ret != TELEPHONY_SUCCESS) {
91 return ret;
92 }
93 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_SWITCH), in);
94 }
95
StartDtmfResponse(int32_t slotId,const RadioResponseInfo & info)96 int32_t ImsCallCallbackProxy::StartDtmfResponse(int32_t slotId, const RadioResponseInfo &info)
97 {
98 MessageParcel in;
99 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in, info);
100 if (ret != TELEPHONY_SUCCESS) {
101 return ret;
102 }
103 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_START_DTMF), in);
104 }
105
SendDtmfResponse(int32_t slotId,const RadioResponseInfo & info,int32_t callIndex)106 int32_t ImsCallCallbackProxy::SendDtmfResponse(int32_t slotId, const RadioResponseInfo &info, int32_t callIndex)
107 {
108 MessageParcel in;
109 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in, info);
110 if (ret != TELEPHONY_SUCCESS) {
111 return ret;
112 }
113 if (!in.WriteInt32(callIndex)) {
114 return TELEPHONY_ERR_WRITE_DATA_FAIL;
115 }
116 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_SEND_DTMF), in);
117 }
118
StopDtmfResponse(int32_t slotId,const RadioResponseInfo & info)119 int32_t ImsCallCallbackProxy::StopDtmfResponse(int32_t slotId, const RadioResponseInfo &info)
120 {
121 MessageParcel in;
122 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in, info);
123 if (ret != TELEPHONY_SUCCESS) {
124 return ret;
125 }
126 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_STOP_DTMF), in);
127 }
128
CallStateChangeReport(int32_t slotId)129 int32_t ImsCallCallbackProxy::CallStateChangeReport(int32_t slotId)
130 {
131 MessageParcel in;
132 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
133 if (ret != TELEPHONY_SUCCESS) {
134 return ret;
135 }
136 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_CALL_STATE_CHANGE), in);
137 }
138
GetImsCallsDataResponse(int32_t slotId,const RadioResponseInfo & info)139 int32_t ImsCallCallbackProxy::GetImsCallsDataResponse(int32_t slotId, const RadioResponseInfo &info)
140 {
141 MessageParcel in;
142 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in, info);
143 if (ret != TELEPHONY_SUCCESS) {
144 return ret;
145 }
146 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_GET_CALLS_DATA), in);
147 }
148
GetImsCallsDataResponse(int32_t slotId,const ImsCurrentCallList & callList)149 int32_t ImsCallCallbackProxy::GetImsCallsDataResponse(int32_t slotId, const ImsCurrentCallList &callList)
150 {
151 MessageParcel in;
152 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
153 if (ret != TELEPHONY_SUCCESS) {
154 return ret;
155 }
156 if (!in.WriteInt32(callList.callSize) || !in.WriteInt32(callList.flag)) {
157 return TELEPHONY_ERR_WRITE_DATA_FAIL;
158 }
159 if (!in.WriteInt32(static_cast<int32_t>(callList.calls.size()))) {
160 return TELEPHONY_ERR_WRITE_DATA_FAIL;
161 }
162 for (auto call : callList.calls) {
163 if (!in.WriteInt32(call.index) || !in.WriteInt32(call.dir) || !in.WriteInt32(call.state) ||
164 !in.WriteInt32(call.mode) || !in.WriteInt32(call.mpty) || !in.WriteInt32(call.voiceDomain) ||
165 !in.WriteInt32(call.callType) || !in.WriteString(call.number) || !in.WriteString(call.name) ||
166 !in.WriteInt32(call.type) || !in.WriteString(call.alpha) || !in.WriteInt32(call.toa) ||
167 !in.WriteInt32(call.toneType) || !in.WriteInt32(call.callInitialType)) {
168 return TELEPHONY_ERR_WRITE_DATA_FAIL;
169 }
170 }
171 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_GET_CALLS_DATA), in);
172 }
173
SetImsSwitchResponse(int32_t slotId,const RadioResponseInfo & info)174 int32_t ImsCallCallbackProxy::SetImsSwitchResponse(int32_t slotId, const RadioResponseInfo &info)
175 {
176 MessageParcel in;
177 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in, info);
178 if (ret != TELEPHONY_SUCCESS) {
179 return ret;
180 }
181
182 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_SET_SWITCH_STATUS), in);
183 }
184
GetImsSwitchResponse(int32_t slotId,const RadioResponseInfo & info)185 int32_t ImsCallCallbackProxy::GetImsSwitchResponse(int32_t slotId, const RadioResponseInfo &info)
186 {
187 MessageParcel in;
188 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in, info);
189 if (ret != TELEPHONY_SUCCESS) {
190 return ret;
191 }
192
193 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_GET_SWITCH_STATUS), in);
194 }
195
GetImsSwitchResponse(int32_t slotId,int32_t active)196 int32_t ImsCallCallbackProxy::GetImsSwitchResponse(int32_t slotId, int32_t active)
197 {
198 MessageParcel in;
199 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
200 if (ret != TELEPHONY_SUCCESS) {
201 return ret;
202 }
203 if (!in.WriteInt32(active)) {
204 return TELEPHONY_ERR_WRITE_DATA_FAIL;
205 }
206
207 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_GET_SWITCH_STATUS), in);
208 }
209
CallRingBackReport(int32_t slotId,const RingbackVoice & info)210 int32_t ImsCallCallbackProxy::CallRingBackReport(int32_t slotId, const RingbackVoice &info)
211 {
212 MessageParcel in;
213 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
214 if (ret != TELEPHONY_SUCCESS) {
215 return ret;
216 }
217 if (!in.WriteRawData((const void *)&info, sizeof(RingbackVoice))) {
218 return TELEPHONY_ERR_WRITE_DATA_FAIL;
219 }
220
221 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_CALL_CRING), in);
222 }
223
SetMuteResponse(int32_t slotId,const MuteControlResponse & response)224 int32_t ImsCallCallbackProxy::SetMuteResponse(int32_t slotId, const MuteControlResponse &response)
225 {
226 MessageParcel in;
227 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
228 if (ret != TELEPHONY_SUCCESS) {
229 return ret;
230 }
231 if (!in.WriteRawData((const void *)&response, sizeof(MuteControlResponse))) {
232 return TELEPHONY_ERR_WRITE_DATA_FAIL;
233 }
234
235 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_SET_MUTE), in);
236 }
237
LastCallFailReasonResponse(int32_t slotId,const DisconnectedDetails & details)238 int32_t ImsCallCallbackProxy::LastCallFailReasonResponse(int32_t slotId, const DisconnectedDetails &details)
239 {
240 MessageParcel in;
241 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
242 if (ret != TELEPHONY_SUCCESS) {
243 return ret;
244 }
245 if (!in.WriteInt32(static_cast<int32_t>(details.reason))) {
246 TELEPHONY_LOGE("[slot%{public}d] Write reason fail!", slotId);
247 return TELEPHONY_ERR_WRITE_DATA_FAIL;
248 }
249 if (!in.WriteString(details.message)) {
250 TELEPHONY_LOGE("[slot%{public}d] Write message fail!", slotId);
251 return TELEPHONY_ERR_WRITE_DATA_FAIL;
252 }
253 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_LAST_CALL_FAIL_REASON), in);
254 }
255
SetClipResponse(int32_t slotId,const SsBaseResult & resultInfo)256 int32_t ImsCallCallbackProxy::SetClipResponse(int32_t slotId, const SsBaseResult &resultInfo)
257 {
258 MessageParcel in;
259 int32_t ret = WriteSsBaseResultCommonInfo(slotId, __FUNCTION__, in, resultInfo);
260 if (ret != TELEPHONY_SUCCESS) {
261 return ret;
262 }
263
264 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_SET_CALL_CLIP), in);
265 }
266
GetClipResponse(int32_t slotId,const GetClipResult & result)267 int32_t ImsCallCallbackProxy::GetClipResponse(int32_t slotId, const GetClipResult &result)
268 {
269 MessageParcel in;
270 int32_t ret = WriteSsBaseResultCommonInfo(slotId, __FUNCTION__, in, result.result);
271 if (ret != TELEPHONY_SUCCESS) {
272 return ret;
273 }
274 if (!in.WriteInt32(result.action)) {
275 return TELEPHONY_ERR_WRITE_DATA_FAIL;
276 }
277 if (!in.WriteInt32(result.clipStat)) {
278 return TELEPHONY_ERR_WRITE_DATA_FAIL;
279 }
280
281 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_GET_CALL_CLIP), in);
282 }
283
GetClirResponse(int32_t slotId,const GetClirResult & result)284 int32_t ImsCallCallbackProxy::GetClirResponse(int32_t slotId, const GetClirResult &result)
285 {
286 MessageParcel in;
287 int32_t ret = WriteSsBaseResultCommonInfo(slotId, __FUNCTION__, in, result.result);
288 if (ret != TELEPHONY_SUCCESS) {
289 return ret;
290 }
291 if (!in.WriteInt32(result.action)) {
292 return TELEPHONY_ERR_WRITE_DATA_FAIL;
293 }
294 if (!in.WriteInt32(result.clirStat)) {
295 return TELEPHONY_ERR_WRITE_DATA_FAIL;
296 }
297
298 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_GET_CALL_CLIR), in);
299 }
300
SetClirResponse(int32_t slotId,const SsBaseResult & resultInfo)301 int32_t ImsCallCallbackProxy::SetClirResponse(int32_t slotId, const SsBaseResult &resultInfo)
302 {
303 MessageParcel in;
304 int32_t ret = WriteSsBaseResultCommonInfo(slotId, __FUNCTION__, in, resultInfo);
305 if (ret != TELEPHONY_SUCCESS) {
306 return ret;
307 }
308
309 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_SET_CALL_CLIR), in);
310 }
311
GetCallTransferResponse(int32_t slotId,const CallForwardQueryInfoList & cFQueryList)312 int32_t ImsCallCallbackProxy::GetCallTransferResponse(int32_t slotId, const CallForwardQueryInfoList &cFQueryList)
313 {
314 MessageParcel in;
315 int32_t ret = WriteSsBaseResultCommonInfo(slotId, __FUNCTION__, in, cFQueryList.result);
316 if (ret != TELEPHONY_SUCCESS) {
317 return ret;
318 }
319 if (!in.WriteInt32(cFQueryList.callSize) || !in.WriteInt32(cFQueryList.flag)) {
320 return TELEPHONY_ERR_WRITE_DATA_FAIL;
321 }
322 if (!in.WriteInt32(static_cast<int32_t>(cFQueryList.calls.size()))) {
323 return TELEPHONY_ERR_WRITE_DATA_FAIL;
324 }
325 for (auto call : cFQueryList.calls) {
326 if (!in.WriteInt32(call.serial) || !in.WriteInt32(call.result) || !in.WriteInt32(call.status) ||
327 !in.WriteInt32(call.classx) || !in.WriteString(call.number) || !in.WriteInt32(call.type) ||
328 !in.WriteInt32(call.reason) || !in.WriteInt32(call.time) || !in.WriteInt32(call.startHour) ||
329 !in.WriteInt32(call.startMinute) || !in.WriteInt32(call.endHour) || !in.WriteInt32(call.endMinute)) {
330 return TELEPHONY_ERR_WRITE_DATA_FAIL;
331 }
332 }
333
334 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_GET_CALL_FORWARD), in);
335 }
336
SetCallTransferResponse(int32_t slotId,const SsBaseResult & resultInfo)337 int32_t ImsCallCallbackProxy::SetCallTransferResponse(int32_t slotId, const SsBaseResult &resultInfo)
338 {
339 MessageParcel in;
340 int32_t ret = WriteSsBaseResultCommonInfo(slotId, __FUNCTION__, in, resultInfo);
341 if (ret != TELEPHONY_SUCCESS) {
342 return ret;
343 }
344
345 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_SET_CALL_FORWARD), in);
346 }
347
GetCallRestrictionResponse(int32_t slotId,const CallRestrictionResult & result)348 int32_t ImsCallCallbackProxy::GetCallRestrictionResponse(int32_t slotId, const CallRestrictionResult &result)
349 {
350 MessageParcel in;
351 int32_t ret = WriteSsBaseResultCommonInfo(slotId, __FUNCTION__, in, result.result);
352 if (ret != TELEPHONY_SUCCESS) {
353 return ret;
354 }
355 if (!in.WriteInt32(result.status)) {
356 return TELEPHONY_ERR_WRITE_DATA_FAIL;
357 }
358 if (!in.WriteInt32(result.classCw)) {
359 return TELEPHONY_ERR_WRITE_DATA_FAIL;
360 }
361
362 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_GET_CALL_RESTRICTION), in);
363 }
364
SetCallRestrictionResponse(int32_t slotId,const SsBaseResult & resultInfo)365 int32_t ImsCallCallbackProxy::SetCallRestrictionResponse(int32_t slotId, const SsBaseResult &resultInfo)
366 {
367 MessageParcel in;
368 int32_t ret = WriteSsBaseResultCommonInfo(slotId, __FUNCTION__, in, resultInfo);
369 if (ret != TELEPHONY_SUCCESS) {
370 return ret;
371 }
372
373 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_SET_CALL_RESTRICTION), in);
374 }
375
GetCallWaitingResponse(int32_t slotId,const CallWaitResult & result)376 int32_t ImsCallCallbackProxy::GetCallWaitingResponse(int32_t slotId, const CallWaitResult &result)
377 {
378 MessageParcel in;
379 int32_t ret = WriteSsBaseResultCommonInfo(slotId, __FUNCTION__, in, result.result);
380 if (ret != TELEPHONY_SUCCESS) {
381 return ret;
382 }
383 if (!in.WriteInt32(result.status)) {
384 return TELEPHONY_ERR_WRITE_DATA_FAIL;
385 }
386 if (!in.WriteInt32(result.classCw)) {
387 return TELEPHONY_ERR_WRITE_DATA_FAIL;
388 }
389
390 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_GET_CALL_WAIT), in);
391 }
392
SetCallWaitingResponse(int32_t slotId,const SsBaseResult & resultInfo)393 int32_t ImsCallCallbackProxy::SetCallWaitingResponse(int32_t slotId, const SsBaseResult &resultInfo)
394 {
395 MessageParcel in;
396 int32_t ret = WriteSsBaseResultCommonInfo(slotId, __FUNCTION__, in, resultInfo);
397 if (ret != TELEPHONY_SUCCESS) {
398 return ret;
399 }
400
401 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_SET_CALL_WAIT), in);
402 }
403
SetColrResponse(int32_t slotId,const SsBaseResult & resultInfo)404 int32_t ImsCallCallbackProxy::SetColrResponse(int32_t slotId, const SsBaseResult &resultInfo)
405 {
406 MessageParcel in;
407 int32_t ret = WriteSsBaseResultCommonInfo(slotId, __FUNCTION__, in, resultInfo);
408 if (ret != TELEPHONY_SUCCESS) {
409 return ret;
410 }
411
412 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_SET_CALL_COLR), in);
413 }
414
GetColrResponse(int32_t slotId,const GetColrResult & result)415 int32_t ImsCallCallbackProxy::GetColrResponse(int32_t slotId, const GetColrResult &result)
416 {
417 MessageParcel in;
418 int32_t ret = WriteSsBaseResultCommonInfo(slotId, __FUNCTION__, in, result.result);
419 if (ret != TELEPHONY_SUCCESS) {
420 return ret;
421 }
422 if (!in.WriteInt32(result.action)) {
423 return TELEPHONY_ERR_WRITE_DATA_FAIL;
424 }
425 if (!in.WriteInt32(result.colrStat)) {
426 return TELEPHONY_ERR_WRITE_DATA_FAIL;
427 }
428
429 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_GET_CALL_COLR), in);
430 }
431
SetColpResponse(int32_t slotId,const SsBaseResult & resultInfo)432 int32_t ImsCallCallbackProxy::SetColpResponse(int32_t slotId, const SsBaseResult &resultInfo)
433 {
434 MessageParcel in;
435 int32_t ret = WriteSsBaseResultCommonInfo(slotId, __FUNCTION__, in, resultInfo);
436 if (ret != TELEPHONY_SUCCESS) {
437 return ret;
438 }
439
440 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_SET_CALL_COLP), in);
441 }
442
GetColpResponse(int32_t slotId,const GetColpResult & result)443 int32_t ImsCallCallbackProxy::GetColpResponse(int32_t slotId, const GetColpResult &result)
444 {
445 MessageParcel in;
446 int32_t ret = WriteSsBaseResultCommonInfo(slotId, __FUNCTION__, in, result.result);
447 if (ret != TELEPHONY_SUCCESS) {
448 return ret;
449 }
450 if (!in.WriteInt32(result.action)) {
451 return TELEPHONY_ERR_WRITE_DATA_FAIL;
452 }
453 if (!in.WriteInt32(result.colpStat)) {
454 return TELEPHONY_ERR_WRITE_DATA_FAIL;
455 }
456
457 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_GET_CALL_COLP), in);
458 }
459
CombineConferenceResponse(int32_t slotId,const RadioResponseInfo & info)460 int32_t ImsCallCallbackProxy::CombineConferenceResponse(int32_t slotId, const RadioResponseInfo &info)
461 {
462 MessageParcel in;
463 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in, info);
464 if (ret != TELEPHONY_SUCCESS) {
465 return ret;
466 }
467 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_COMBINE_CONFERENCE), in);
468 }
469
InviteToConferenceResponse(int32_t slotId,const RadioResponseInfo & info)470 int32_t ImsCallCallbackProxy::InviteToConferenceResponse(int32_t slotId, const RadioResponseInfo &info)
471 {
472 MessageParcel in;
473 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in, info);
474 if (ret != TELEPHONY_SUCCESS) {
475 return ret;
476 }
477 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_INVITE_TO_CONFERENCE), in);
478 }
479
ReceiveUpdateCallMediaModeRequest(int32_t slotId,const ImsCallModeReceiveInfo & callModeRequest)480 int32_t ImsCallCallbackProxy::ReceiveUpdateCallMediaModeRequest(
481 int32_t slotId, const ImsCallModeReceiveInfo &callModeRequest)
482 {
483 MessageParcel in;
484 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
485 if (ret != TELEPHONY_SUCCESS) {
486 return ret;
487 }
488 if (!in.WriteRawData((const void *)&callModeRequest, sizeof(ImsCallModeReceiveInfo))) {
489 TELEPHONY_LOGE("[slot%{public}d]Write callModeRequest fail!", slotId);
490 return TELEPHONY_ERR_WRITE_DATA_FAIL;
491 }
492 return SendResponseInfo(static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_RECV_CALL_MEDIA_MODE_REQUEST), in);
493 }
494
ReceiveUpdateCallMediaModeResponse(int32_t slotId,const ImsCallModeReceiveInfo & callModeResponse)495 int32_t ImsCallCallbackProxy::ReceiveUpdateCallMediaModeResponse(
496 int32_t slotId, const ImsCallModeReceiveInfo &callModeResponse)
497 {
498 MessageParcel in;
499 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
500 if (ret != TELEPHONY_SUCCESS) {
501 return ret;
502 }
503 if (!in.WriteRawData((const void *)&callModeResponse, sizeof(ImsCallModeReceiveInfo))) {
504 TELEPHONY_LOGE("[slot%{public}d]Write callModeResponse fail!", slotId);
505 return TELEPHONY_ERR_WRITE_DATA_FAIL;
506 }
507 return SendResponseInfo(
508 static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_RECV_CALL_MEDIA_MODE_RESPONSE), in);
509 }
510
CallSessionEventChanged(int32_t slotId,const ImsCallSessionEventInfo & callSessionEventInfo)511 int32_t ImsCallCallbackProxy::CallSessionEventChanged(
512 int32_t slotId, const ImsCallSessionEventInfo &callSessionEventInfo)
513 {
514 MessageParcel in;
515 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
516 if (ret != TELEPHONY_SUCCESS) {
517 return ret;
518 }
519 if (!in.WriteRawData((const void *)&callSessionEventInfo, sizeof(ImsCallSessionEventInfo))) {
520 TELEPHONY_LOGE("[slot%{public}d]Write callSessionEventInfo fail!", slotId);
521 return TELEPHONY_ERR_WRITE_DATA_FAIL;
522 }
523 return SendResponseInfo(static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_CALL_SESSION_EVENT_CHANGED), in);
524 }
525
PeerDimensionsChanged(int32_t slotId,const ImsCallPeerDimensionsInfo & callPeerDimensionsInfo)526 int32_t ImsCallCallbackProxy::PeerDimensionsChanged(
527 int32_t slotId, const ImsCallPeerDimensionsInfo &callPeerDimensionsInfo)
528 {
529 MessageParcel in;
530 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
531 if (ret != TELEPHONY_SUCCESS) {
532 return ret;
533 }
534 if (!in.WriteRawData((const void *)&callPeerDimensionsInfo, sizeof(ImsCallPeerDimensionsInfo))) {
535 TELEPHONY_LOGE("[slot%{public}d]Write callPeerDimensionsInfo fail!", slotId);
536 return TELEPHONY_ERR_WRITE_DATA_FAIL;
537 }
538 return SendResponseInfo(static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_CALL_PEER_DIMENSIONS_CHANGED), in);
539 }
540
CallDataUsageChanged(int32_t slotId,const ImsCallDataUsageInfo & callDataUsageInfo)541 int32_t ImsCallCallbackProxy::CallDataUsageChanged(int32_t slotId, const ImsCallDataUsageInfo &callDataUsageInfo)
542 {
543 MessageParcel in;
544 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
545 if (ret != TELEPHONY_SUCCESS) {
546 return ret;
547 }
548 if (!in.WriteRawData((const void *)&callDataUsageInfo, sizeof(ImsCallDataUsageInfo))) {
549 TELEPHONY_LOGE("[slot%{public}d]Write callDataUsageInfo fail!", slotId);
550 return TELEPHONY_ERR_WRITE_DATA_FAIL;
551 }
552 return SendResponseInfo(static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_CALL_DATA_USAGE_CHANGED), in);
553 }
554
CameraCapabilitiesChanged(int32_t slotId,const CameraCapabilitiesInfo & cameraCapabilitiesInfo)555 int32_t ImsCallCallbackProxy::CameraCapabilitiesChanged(
556 int32_t slotId, const CameraCapabilitiesInfo &cameraCapabilitiesInfo)
557 {
558 MessageParcel in;
559 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
560 if (ret != TELEPHONY_SUCCESS) {
561 return ret;
562 }
563 if (!in.WriteRawData((const void *)&cameraCapabilitiesInfo, sizeof(CameraCapabilitiesInfo))) {
564 TELEPHONY_LOGE("[slot%{public}d]Write cameraCapabilitiesInfo fail!", slotId);
565 return TELEPHONY_ERR_WRITE_DATA_FAIL;
566 }
567 return SendResponseInfo(
568 static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_CALL_CAMERA_CAPABILITIES_CHANGED), in);
569 }
570
SendResponseInfo(int32_t eventId,MessageParcel & in)571 int32_t ImsCallCallbackProxy::SendResponseInfo(int32_t eventId, MessageParcel &in)
572 {
573 TELEPHONY_LOGI("SendResponseInfo eventId = %{public}d", eventId);
574 MessageOption option;
575 MessageParcel out;
576 sptr<IRemoteObject> remote = Remote();
577 if (remote == nullptr) {
578 return TELEPHONY_ERR_LOCAL_PTR_NULL;
579 }
580 int32_t error = remote->SendRequest(eventId, in, out, option);
581 if (error == ERR_NONE) {
582 return out.ReadInt32();
583 }
584 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
585 }
586
WriteCommonInfo(int32_t slotId,const std::string & funcName,MessageParcel & in)587 int32_t ImsCallCallbackProxy::WriteCommonInfo(int32_t slotId, const std::string &funcName, MessageParcel &in)
588 {
589 if (!in.WriteInterfaceToken(ImsCallCallbackProxy::GetDescriptor())) {
590 TELEPHONY_LOGE("[slot%{public}d]%{public}s:Write descriptor token fail!", slotId, funcName.c_str());
591 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
592 }
593 if (!in.WriteInt32(slotId)) {
594 TELEPHONY_LOGE("[slot%{public}d]%{public}s:Write slotId fail!", slotId, funcName.c_str());
595 return TELEPHONY_ERR_WRITE_DATA_FAIL;
596 }
597 return TELEPHONY_SUCCESS;
598 }
599
WriteCommonInfo(int32_t slotId,const std::string & funcName,MessageParcel & in,const RadioResponseInfo & info)600 int32_t ImsCallCallbackProxy::WriteCommonInfo(
601 int32_t slotId, const std::string &funcName, MessageParcel &in, const RadioResponseInfo &info)
602 {
603 int32_t ret = WriteCommonInfo(slotId, funcName, in);
604 if (ret != TELEPHONY_SUCCESS) {
605 return ret;
606 }
607 if (!in.WriteRawData((const void *)&info, sizeof(RadioResponseInfo))) {
608 TELEPHONY_LOGE("[slot%{public}d]%{public}s:Write info fail!", slotId, funcName.c_str());
609 return TELEPHONY_ERR_WRITE_DATA_FAIL;
610 }
611 return TELEPHONY_SUCCESS;
612 }
613
WriteSsBaseResultCommonInfo(int32_t slotId,const std::string & funcName,MessageParcel & in,const SsBaseResult & ssResult)614 int32_t ImsCallCallbackProxy::WriteSsBaseResultCommonInfo(
615 int32_t slotId, const std::string &funcName, MessageParcel &in, const SsBaseResult &ssResult)
616 {
617 int32_t ret = WriteCommonInfo(slotId, funcName, in);
618 if (ret != TELEPHONY_SUCCESS) {
619 return ret;
620 }
621 if (!in.WriteInt32(ssResult.index)) {
622 return TELEPHONY_ERR_WRITE_DATA_FAIL;
623 }
624 if (!in.WriteInt32(ssResult.result)) {
625 return TELEPHONY_ERR_WRITE_DATA_FAIL;
626 }
627 if (!in.WriteInt32(ssResult.reason)) {
628 return TELEPHONY_ERR_WRITE_DATA_FAIL;
629 }
630 if (!in.WriteString(ssResult.message)) {
631 return TELEPHONY_ERR_WRITE_DATA_FAIL;
632 }
633 return TELEPHONY_SUCCESS;
634 }
635
CallNvCfgFinishedIndication(int32_t slotId)636 int32_t ImsCallCallbackProxy::CallNvCfgFinishedIndication(int32_t slotId)
637 {
638 MessageParcel in;
639 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
640 if (ret != TELEPHONY_SUCCESS) {
641 return ret;
642 }
643 return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_NV_CONFIG_REFRESHED), in);
644 }
645 } // namespace Telephony
646 } // namespace OHOS
647