• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022-2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "ims_call_callback_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 (WriteCallInfo(in, call)) {
164             return TELEPHONY_ERR_WRITE_DATA_FAIL;
165         }
166     }
167     return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_GET_CALLS_DATA), in);
168 }
169 
WriteCallInfo(MessageParcel & in,const ImsCurrentCall & call)170 bool ImsCallCallbackProxy::WriteCallInfo(MessageParcel &in, const ImsCurrentCall &call)
171 {
172     return (!in.WriteInt32(call.index) || !in.WriteInt32(call.dir) || !in.WriteInt32(call.state) ||
173             !in.WriteInt32(call.mode) || !in.WriteInt32(call.mpty) || !in.WriteInt32(call.voiceDomain) ||
174             !in.WriteInt32(call.callType) || !in.WriteString(call.number) || !in.WriteString(call.name) ||
175             !in.WriteInt32(call.type) || !in.WriteString(call.alpha) || !in.WriteInt32(call.toa) ||
176             !in.WriteInt32(call.toneType) || !in.WriteInt32(call.callInitialType) ||
177             !in.WriteInt32(call.namePresentation) || !in.WriteInt32(call.newCallUseBox));
178 }
179 
SetImsSwitchResponse(int32_t slotId,const RadioResponseInfo & info)180 int32_t ImsCallCallbackProxy::SetImsSwitchResponse(int32_t slotId, const RadioResponseInfo &info)
181 {
182     MessageParcel in;
183     int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in, info);
184     if (ret != TELEPHONY_SUCCESS) {
185         return ret;
186     }
187 
188     return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_SET_SWITCH_STATUS), in);
189 }
190 
GetImsSwitchResponse(int32_t slotId,const RadioResponseInfo & info)191 int32_t ImsCallCallbackProxy::GetImsSwitchResponse(int32_t slotId, const RadioResponseInfo &info)
192 {
193     MessageParcel in;
194     int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in, info);
195     if (ret != TELEPHONY_SUCCESS) {
196         return ret;
197     }
198 
199     return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_GET_SWITCH_STATUS), in);
200 }
201 
GetImsSwitchResponse(int32_t slotId,int32_t active)202 int32_t ImsCallCallbackProxy::GetImsSwitchResponse(int32_t slotId, int32_t active)
203 {
204     MessageParcel in;
205     int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
206     if (ret != TELEPHONY_SUCCESS) {
207         return ret;
208     }
209     if (!in.WriteInt32(active)) {
210         return TELEPHONY_ERR_WRITE_DATA_FAIL;
211     }
212 
213     return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_GET_SWITCH_STATUS), in);
214 }
215 
CallRingBackReport(int32_t slotId,const RingbackVoice & info)216 int32_t ImsCallCallbackProxy::CallRingBackReport(int32_t slotId, const RingbackVoice &info)
217 {
218     MessageParcel in;
219     int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
220     if (ret != TELEPHONY_SUCCESS) {
221         return ret;
222     }
223     if (!in.WriteRawData((const void *)&info, sizeof(RingbackVoice))) {
224         return TELEPHONY_ERR_WRITE_DATA_FAIL;
225     }
226 
227     return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_CALL_CRING), in);
228 }
229 
SetMuteResponse(int32_t slotId,const MuteControlResponse & response)230 int32_t ImsCallCallbackProxy::SetMuteResponse(int32_t slotId, const MuteControlResponse &response)
231 {
232     MessageParcel in;
233     int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
234     if (ret != TELEPHONY_SUCCESS) {
235         return ret;
236     }
237     if (!in.WriteRawData((const void *)&response, sizeof(MuteControlResponse))) {
238         return TELEPHONY_ERR_WRITE_DATA_FAIL;
239     }
240 
241     return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_SET_MUTE), in);
242 }
243 
LastCallFailReasonResponse(int32_t slotId,const DisconnectedDetails & details)244 int32_t ImsCallCallbackProxy::LastCallFailReasonResponse(int32_t slotId, const DisconnectedDetails &details)
245 {
246     MessageParcel in;
247     int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
248     if (ret != TELEPHONY_SUCCESS) {
249         return ret;
250     }
251     if (!in.WriteInt32(static_cast<int32_t>(details.reason))) {
252         TELEPHONY_LOGE("[slot%{public}d] Write reason fail!", slotId);
253         return TELEPHONY_ERR_WRITE_DATA_FAIL;
254     }
255     if (!in.WriteString(details.message)) {
256         TELEPHONY_LOGE("[slot%{public}d] Write message fail!", slotId);
257         return TELEPHONY_ERR_WRITE_DATA_FAIL;
258     }
259     return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_LAST_CALL_FAIL_REASON), in);
260 }
261 
SetClipResponse(int32_t slotId,const SsBaseResult & resultInfo)262 int32_t ImsCallCallbackProxy::SetClipResponse(int32_t slotId, const SsBaseResult &resultInfo)
263 {
264     MessageParcel in;
265     int32_t ret = WriteSsBaseResultCommonInfo(slotId, __FUNCTION__, in, resultInfo);
266     if (ret != TELEPHONY_SUCCESS) {
267         return ret;
268     }
269 
270     return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_SET_CALL_CLIP), in);
271 }
272 
GetClipResponse(int32_t slotId,const GetClipResult & result)273 int32_t ImsCallCallbackProxy::GetClipResponse(int32_t slotId, const GetClipResult &result)
274 {
275     MessageParcel in;
276     int32_t ret = WriteSsBaseResultCommonInfo(slotId, __FUNCTION__, in, result.result);
277     if (ret != TELEPHONY_SUCCESS) {
278         return ret;
279     }
280     if (!in.WriteInt32(result.action)) {
281         return TELEPHONY_ERR_WRITE_DATA_FAIL;
282     }
283     if (!in.WriteInt32(result.clipStat)) {
284         return TELEPHONY_ERR_WRITE_DATA_FAIL;
285     }
286 
287     return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_GET_CALL_CLIP), in);
288 }
289 
GetClirResponse(int32_t slotId,const GetClirResult & result)290 int32_t ImsCallCallbackProxy::GetClirResponse(int32_t slotId, const GetClirResult &result)
291 {
292     MessageParcel in;
293     int32_t ret = WriteSsBaseResultCommonInfo(slotId, __FUNCTION__, in, result.result);
294     if (ret != TELEPHONY_SUCCESS) {
295         return ret;
296     }
297     if (!in.WriteInt32(result.action)) {
298         return TELEPHONY_ERR_WRITE_DATA_FAIL;
299     }
300     if (!in.WriteInt32(result.clirStat)) {
301         return TELEPHONY_ERR_WRITE_DATA_FAIL;
302     }
303 
304     return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_GET_CALL_CLIR), in);
305 }
306 
SetClirResponse(int32_t slotId,const SsBaseResult & resultInfo)307 int32_t ImsCallCallbackProxy::SetClirResponse(int32_t slotId, const SsBaseResult &resultInfo)
308 {
309     MessageParcel in;
310     int32_t ret = WriteSsBaseResultCommonInfo(slotId, __FUNCTION__, in, resultInfo);
311     if (ret != TELEPHONY_SUCCESS) {
312         return ret;
313     }
314 
315     return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_SET_CALL_CLIR), in);
316 }
317 
GetCallTransferResponse(int32_t slotId,const CallForwardQueryInfoList & cFQueryList)318 int32_t ImsCallCallbackProxy::GetCallTransferResponse(int32_t slotId, const CallForwardQueryInfoList &cFQueryList)
319 {
320     MessageParcel in;
321     int32_t ret = WriteSsBaseResultCommonInfo(slotId, __FUNCTION__, in, cFQueryList.result);
322     if (ret != TELEPHONY_SUCCESS) {
323         return ret;
324     }
325     if (!in.WriteInt32(cFQueryList.callSize) || !in.WriteInt32(cFQueryList.flag)) {
326         return TELEPHONY_ERR_WRITE_DATA_FAIL;
327     }
328     if (!in.WriteInt32(static_cast<int32_t>(cFQueryList.calls.size()))) {
329         return TELEPHONY_ERR_WRITE_DATA_FAIL;
330     }
331     for (auto call : cFQueryList.calls) {
332         if (!in.WriteInt32(call.serial) || !in.WriteInt32(call.result) || !in.WriteInt32(call.status) ||
333             !in.WriteInt32(call.classx) || !in.WriteString(call.number) || !in.WriteInt32(call.type) ||
334             !in.WriteInt32(call.reason) || !in.WriteInt32(call.time) || !in.WriteInt32(call.startHour) ||
335             !in.WriteInt32(call.startMinute) || !in.WriteInt32(call.endHour) || !in.WriteInt32(call.endMinute)) {
336             return TELEPHONY_ERR_WRITE_DATA_FAIL;
337         }
338     }
339 
340     return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_GET_CALL_FORWARD), in);
341 }
342 
SetCallTransferResponse(int32_t slotId,const SsBaseResult & resultInfo)343 int32_t ImsCallCallbackProxy::SetCallTransferResponse(int32_t slotId, const SsBaseResult &resultInfo)
344 {
345     MessageParcel in;
346     int32_t ret = WriteSsBaseResultCommonInfo(slotId, __FUNCTION__, in, resultInfo);
347     if (ret != TELEPHONY_SUCCESS) {
348         return ret;
349     }
350 
351     return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_SET_CALL_FORWARD), in);
352 }
353 
GetCallRestrictionResponse(int32_t slotId,const CallRestrictionResult & result)354 int32_t ImsCallCallbackProxy::GetCallRestrictionResponse(int32_t slotId, const CallRestrictionResult &result)
355 {
356     MessageParcel in;
357     int32_t ret = WriteSsBaseResultCommonInfo(slotId, __FUNCTION__, in, result.result);
358     if (ret != TELEPHONY_SUCCESS) {
359         return ret;
360     }
361     if (!in.WriteInt32(result.status)) {
362         return TELEPHONY_ERR_WRITE_DATA_FAIL;
363     }
364     if (!in.WriteInt32(result.classCw)) {
365         return TELEPHONY_ERR_WRITE_DATA_FAIL;
366     }
367 
368     return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_GET_CALL_RESTRICTION), in);
369 }
370 
SetCallRestrictionResponse(int32_t slotId,const SsBaseResult & resultInfo)371 int32_t ImsCallCallbackProxy::SetCallRestrictionResponse(int32_t slotId, const SsBaseResult &resultInfo)
372 {
373     MessageParcel in;
374     int32_t ret = WriteSsBaseResultCommonInfo(slotId, __FUNCTION__, in, resultInfo);
375     if (ret != TELEPHONY_SUCCESS) {
376         return ret;
377     }
378 
379     return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_SET_CALL_RESTRICTION), in);
380 }
381 
GetCallWaitingResponse(int32_t slotId,const CallWaitResult & result)382 int32_t ImsCallCallbackProxy::GetCallWaitingResponse(int32_t slotId, const CallWaitResult &result)
383 {
384     MessageParcel in;
385     int32_t ret = WriteSsBaseResultCommonInfo(slotId, __FUNCTION__, in, result.result);
386     if (ret != TELEPHONY_SUCCESS) {
387         return ret;
388     }
389     if (!in.WriteInt32(result.status)) {
390         return TELEPHONY_ERR_WRITE_DATA_FAIL;
391     }
392     if (!in.WriteInt32(result.classCw)) {
393         return TELEPHONY_ERR_WRITE_DATA_FAIL;
394     }
395 
396     return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_GET_CALL_WAIT), in);
397 }
398 
SetCallWaitingResponse(int32_t slotId,const SsBaseResult & resultInfo)399 int32_t ImsCallCallbackProxy::SetCallWaitingResponse(int32_t slotId, const SsBaseResult &resultInfo)
400 {
401     MessageParcel in;
402     int32_t ret = WriteSsBaseResultCommonInfo(slotId, __FUNCTION__, in, resultInfo);
403     if (ret != TELEPHONY_SUCCESS) {
404         return ret;
405     }
406 
407     return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_SET_CALL_WAIT), in);
408 }
409 
SetColrResponse(int32_t slotId,const SsBaseResult & resultInfo)410 int32_t ImsCallCallbackProxy::SetColrResponse(int32_t slotId, const SsBaseResult &resultInfo)
411 {
412     MessageParcel in;
413     int32_t ret = WriteSsBaseResultCommonInfo(slotId, __FUNCTION__, in, resultInfo);
414     if (ret != TELEPHONY_SUCCESS) {
415         return ret;
416     }
417 
418     return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_SET_CALL_COLR), in);
419 }
420 
GetColrResponse(int32_t slotId,const GetColrResult & result)421 int32_t ImsCallCallbackProxy::GetColrResponse(int32_t slotId, const GetColrResult &result)
422 {
423     MessageParcel in;
424     int32_t ret = WriteSsBaseResultCommonInfo(slotId, __FUNCTION__, in, result.result);
425     if (ret != TELEPHONY_SUCCESS) {
426         return ret;
427     }
428     if (!in.WriteInt32(result.action)) {
429         return TELEPHONY_ERR_WRITE_DATA_FAIL;
430     }
431     if (!in.WriteInt32(result.colrStat)) {
432         return TELEPHONY_ERR_WRITE_DATA_FAIL;
433     }
434 
435     return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_GET_CALL_COLR), in);
436 }
437 
SetColpResponse(int32_t slotId,const SsBaseResult & resultInfo)438 int32_t ImsCallCallbackProxy::SetColpResponse(int32_t slotId, const SsBaseResult &resultInfo)
439 {
440     MessageParcel in;
441     int32_t ret = WriteSsBaseResultCommonInfo(slotId, __FUNCTION__, in, resultInfo);
442     if (ret != TELEPHONY_SUCCESS) {
443         return ret;
444     }
445 
446     return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_SET_CALL_COLP), in);
447 }
448 
GetColpResponse(int32_t slotId,const GetColpResult & result)449 int32_t ImsCallCallbackProxy::GetColpResponse(int32_t slotId, const GetColpResult &result)
450 {
451     MessageParcel in;
452     int32_t ret = WriteSsBaseResultCommonInfo(slotId, __FUNCTION__, in, result.result);
453     if (ret != TELEPHONY_SUCCESS) {
454         return ret;
455     }
456     if (!in.WriteInt32(result.action)) {
457         return TELEPHONY_ERR_WRITE_DATA_FAIL;
458     }
459     if (!in.WriteInt32(result.colpStat)) {
460         return TELEPHONY_ERR_WRITE_DATA_FAIL;
461     }
462 
463     return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_GET_CALL_COLP), in);
464 }
465 
CombineConferenceResponse(int32_t slotId,const RadioResponseInfo & info)466 int32_t ImsCallCallbackProxy::CombineConferenceResponse(int32_t slotId, const RadioResponseInfo &info)
467 {
468     MessageParcel in;
469     int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in, info);
470     if (ret != TELEPHONY_SUCCESS) {
471         return ret;
472     }
473     return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_COMBINE_CONFERENCE), in);
474 }
475 
InviteToConferenceResponse(int32_t slotId,const RadioResponseInfo & info)476 int32_t ImsCallCallbackProxy::InviteToConferenceResponse(int32_t slotId, const RadioResponseInfo &info)
477 {
478     MessageParcel in;
479     int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in, info);
480     if (ret != TELEPHONY_SUCCESS) {
481         return ret;
482     }
483     return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_INVITE_TO_CONFERENCE), in);
484 }
485 
ReceiveUpdateCallMediaModeRequest(int32_t slotId,const ImsCallModeReceiveInfo & callModeRequest)486 int32_t ImsCallCallbackProxy::ReceiveUpdateCallMediaModeRequest(
487     int32_t slotId, const ImsCallModeReceiveInfo &callModeRequest)
488 {
489     MessageParcel in;
490     int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
491     if (ret != TELEPHONY_SUCCESS) {
492         return ret;
493     }
494     if (!in.WriteRawData((const void *)&callModeRequest, sizeof(ImsCallModeReceiveInfo))) {
495         TELEPHONY_LOGE("[slot%{public}d]Write callModeRequest fail!", slotId);
496         return TELEPHONY_ERR_WRITE_DATA_FAIL;
497     }
498     return SendResponseInfo(static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_RECV_CALL_MEDIA_MODE_REQUEST), in);
499 }
500 
ReceiveUpdateCallMediaModeResponse(int32_t slotId,const ImsCallModeReceiveInfo & callModeResponse)501 int32_t ImsCallCallbackProxy::ReceiveUpdateCallMediaModeResponse(
502     int32_t slotId, const ImsCallModeReceiveInfo &callModeResponse)
503 {
504     MessageParcel in;
505     int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
506     if (ret != TELEPHONY_SUCCESS) {
507         return ret;
508     }
509     if (!in.WriteRawData((const void *)&callModeResponse, sizeof(ImsCallModeReceiveInfo))) {
510         TELEPHONY_LOGE("[slot%{public}d]Write callModeResponse fail!", slotId);
511         return TELEPHONY_ERR_WRITE_DATA_FAIL;
512     }
513     return SendResponseInfo(
514         static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_RECV_CALL_MEDIA_MODE_RESPONSE), in);
515 }
516 
CallSessionEventChanged(int32_t slotId,const ImsCallSessionEventInfo & callSessionEventInfo)517 int32_t ImsCallCallbackProxy::CallSessionEventChanged(
518     int32_t slotId, const ImsCallSessionEventInfo &callSessionEventInfo)
519 {
520     MessageParcel in;
521     int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
522     if (ret != TELEPHONY_SUCCESS) {
523         return ret;
524     }
525     if (!in.WriteRawData((const void *)&callSessionEventInfo, sizeof(ImsCallSessionEventInfo))) {
526         TELEPHONY_LOGE("[slot%{public}d]Write callSessionEventInfo fail!", slotId);
527         return TELEPHONY_ERR_WRITE_DATA_FAIL;
528     }
529     return SendResponseInfo(static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_CALL_SESSION_EVENT_CHANGED), in);
530 }
531 
PeerDimensionsChanged(int32_t slotId,const ImsCallPeerDimensionsInfo & callPeerDimensionsInfo)532 int32_t ImsCallCallbackProxy::PeerDimensionsChanged(
533     int32_t slotId, const ImsCallPeerDimensionsInfo &callPeerDimensionsInfo)
534 {
535     MessageParcel in;
536     int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
537     if (ret != TELEPHONY_SUCCESS) {
538         return ret;
539     }
540     if (!in.WriteRawData((const void *)&callPeerDimensionsInfo, sizeof(ImsCallPeerDimensionsInfo))) {
541         TELEPHONY_LOGE("[slot%{public}d]Write callPeerDimensionsInfo fail!", slotId);
542         return TELEPHONY_ERR_WRITE_DATA_FAIL;
543     }
544     return SendResponseInfo(static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_CALL_PEER_DIMENSIONS_CHANGED), in);
545 }
546 
CallDataUsageChanged(int32_t slotId,const ImsCallDataUsageInfo & callDataUsageInfo)547 int32_t ImsCallCallbackProxy::CallDataUsageChanged(int32_t slotId, const ImsCallDataUsageInfo &callDataUsageInfo)
548 {
549     MessageParcel in;
550     int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
551     if (ret != TELEPHONY_SUCCESS) {
552         return ret;
553     }
554     if (!in.WriteRawData((const void *)&callDataUsageInfo, sizeof(ImsCallDataUsageInfo))) {
555         TELEPHONY_LOGE("[slot%{public}d]Write callDataUsageInfo fail!", slotId);
556         return TELEPHONY_ERR_WRITE_DATA_FAIL;
557     }
558     return SendResponseInfo(static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_CALL_DATA_USAGE_CHANGED), in);
559 }
560 
CameraCapabilitiesChanged(int32_t slotId,const CameraCapabilitiesInfo & cameraCapabilitiesInfo)561 int32_t ImsCallCallbackProxy::CameraCapabilitiesChanged(
562     int32_t slotId, const CameraCapabilitiesInfo &cameraCapabilitiesInfo)
563 {
564     MessageParcel in;
565     int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
566     if (ret != TELEPHONY_SUCCESS) {
567         return ret;
568     }
569     if (!in.WriteRawData((const void *)&cameraCapabilitiesInfo, sizeof(CameraCapabilitiesInfo))) {
570         TELEPHONY_LOGE("[slot%{public}d]Write cameraCapabilitiesInfo fail!", slotId);
571         return TELEPHONY_ERR_WRITE_DATA_FAIL;
572     }
573     return SendResponseInfo(
574         static_cast<uint32_t>(ImsCallCallbackInterfaceCode::IMS_CALL_CAMERA_CAPABILITIES_CHANGED), in);
575 }
576 
SendResponseInfo(int32_t eventId,MessageParcel & in)577 int32_t ImsCallCallbackProxy::SendResponseInfo(int32_t eventId, MessageParcel &in)
578 {
579     TELEPHONY_LOGI("SendResponseInfo eventId = %{public}d", eventId);
580     MessageOption option;
581     MessageParcel out;
582     sptr<IRemoteObject> remote = Remote();
583     if (remote == nullptr) {
584         return TELEPHONY_ERR_LOCAL_PTR_NULL;
585     }
586     int32_t error = remote->SendRequest(eventId, in, out, option);
587     if (error == ERR_NONE) {
588         return out.ReadInt32();
589     }
590     return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
591 }
592 
WriteCommonInfo(int32_t slotId,const std::string & funcName,MessageParcel & in)593 int32_t ImsCallCallbackProxy::WriteCommonInfo(int32_t slotId, const std::string &funcName, MessageParcel &in)
594 {
595     if (!in.WriteInterfaceToken(ImsCallCallbackProxy::GetDescriptor())) {
596         TELEPHONY_LOGE("[slot%{public}d]%{public}s:Write descriptor token fail!", slotId, funcName.c_str());
597         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
598     }
599     if (!in.WriteInt32(slotId)) {
600         TELEPHONY_LOGE("[slot%{public}d]%{public}s:Write slotId fail!", slotId, funcName.c_str());
601         return TELEPHONY_ERR_WRITE_DATA_FAIL;
602     }
603     return TELEPHONY_SUCCESS;
604 }
605 
WriteCommonInfo(int32_t slotId,const std::string & funcName,MessageParcel & in,const RadioResponseInfo & info)606 int32_t ImsCallCallbackProxy::WriteCommonInfo(
607     int32_t slotId, const std::string &funcName, MessageParcel &in, const RadioResponseInfo &info)
608 {
609     int32_t ret = WriteCommonInfo(slotId, funcName, in);
610     if (ret != TELEPHONY_SUCCESS) {
611         return ret;
612     }
613     if (!in.WriteRawData((const void *)&info, sizeof(RadioResponseInfo))) {
614         TELEPHONY_LOGE("[slot%{public}d]%{public}s:Write info fail!", slotId, funcName.c_str());
615         return TELEPHONY_ERR_WRITE_DATA_FAIL;
616     }
617     return TELEPHONY_SUCCESS;
618 }
619 
WriteSsBaseResultCommonInfo(int32_t slotId,const std::string & funcName,MessageParcel & in,const SsBaseResult & ssResult)620 int32_t ImsCallCallbackProxy::WriteSsBaseResultCommonInfo(
621     int32_t slotId, const std::string &funcName, MessageParcel &in, const SsBaseResult &ssResult)
622 {
623     int32_t ret = WriteCommonInfo(slotId, funcName, in);
624     if (ret != TELEPHONY_SUCCESS) {
625         return ret;
626     }
627     if (!in.WriteInt32(ssResult.index)) {
628         return TELEPHONY_ERR_WRITE_DATA_FAIL;
629     }
630     if (!in.WriteInt32(ssResult.result)) {
631         return TELEPHONY_ERR_WRITE_DATA_FAIL;
632     }
633     if (!in.WriteInt32(ssResult.reason)) {
634         return TELEPHONY_ERR_WRITE_DATA_FAIL;
635     }
636     if (!in.WriteString(ssResult.message)) {
637         return TELEPHONY_ERR_WRITE_DATA_FAIL;
638     }
639     return TELEPHONY_SUCCESS;
640 }
641 
GetImsCapResponse(int32_t slotId,const ImsCapFromChip & imsCap)642 int32_t ImsCallCallbackProxy::GetImsCapResponse(int32_t slotId, const ImsCapFromChip &imsCap)
643 {
644     MessageParcel in;
645     int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
646     if (ret != TELEPHONY_SUCCESS) {
647         return ret;
648     }
649 
650     if (!in.WriteInt32(imsCap.volteCap) || !in.WriteInt32(imsCap.vowifiCap) ||
651         !in.WriteInt32(imsCap.vonrCap) || !in.WriteInt32(imsCap.vtCap)) {
652         return TELEPHONY_ERR_WRITE_DATA_FAIL;
653     }
654 
655     return SendResponseInfo(static_cast<int32_t>(ImsCallCallbackInterfaceCode::IMS_GET_IMS_CAPABILITY), in);
656 }
657 } // namespace Telephony
658 } // namespace OHOS
659