• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_proxy.h"
17 
18 #include "cellular_call_hisysevent.h"
19 #include "message_option.h"
20 #include "message_parcel.h"
21 #include "telephony_errors.h"
22 #include "telephony_permission.h"
23 
24 namespace OHOS {
25 namespace Telephony {
Dial(const ImsCallInfo & callInfo,CLIRMode mode)26 int32_t ImsCallProxy::Dial(const ImsCallInfo &callInfo, CLIRMode mode)
27 {
28     if (!TelephonyPermission::CheckPermission(Permission::PLACE_CALL)) {
29         TELEPHONY_LOGE("[slot%{public}d]Permission denied!", callInfo.slotId);
30         return TELEPHONY_ERR_PERMISSION_ERR;
31     }
32     MessageParcel in;
33     if (!in.WriteInterfaceToken(ImsCallProxy::GetDescriptor())) {
34         TELEPHONY_LOGE("[slot%{public}d]Write descriptor token fail!", callInfo.slotId);
35         CellularCallHiSysEvent::WriteDialCallFaultEvent(callInfo.slotId, INVALID_PARAMETER, callInfo.videoState,
36             TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL, "ims call proxy write descriptor token fail");
37         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
38     }
39     if (!in.WriteRawData((const void *)&callInfo, sizeof(ImsCallInfo))) {
40         TELEPHONY_LOGE("[slot%{public}d]Write callInfo fail!", callInfo.slotId);
41         CellularCallHiSysEvent::WriteDialCallFaultEvent(callInfo.slotId, INVALID_PARAMETER, callInfo.videoState,
42             TELEPHONY_ERR_WRITE_DATA_FAIL, "ims call proxy write data fail");
43         return TELEPHONY_ERR_WRITE_DATA_FAIL;
44     }
45     if (!in.WriteInt32(mode)) {
46         TELEPHONY_LOGE("[slot%{public}d]Write mode fail!", callInfo.slotId);
47         CellularCallHiSysEvent::WriteDialCallFaultEvent(callInfo.slotId, INVALID_PARAMETER, callInfo.videoState,
48             TELEPHONY_ERR_WRITE_DATA_FAIL, "ims call proxy write data fail");
49         return TELEPHONY_ERR_WRITE_DATA_FAIL;
50     }
51     sptr<IRemoteObject> remote = Remote();
52     if (remote == nullptr) {
53         TELEPHONY_LOGE("[slot%{public}d]Remote is null", callInfo.slotId);
54         CellularCallHiSysEvent::WriteDialCallFaultEvent(callInfo.slotId, INVALID_PARAMETER, callInfo.videoState,
55             TELEPHONY_ERR_LOCAL_PTR_NULL, "ims call proxy remote is nullptr");
56         return TELEPHONY_ERR_LOCAL_PTR_NULL;
57     }
58     MessageParcel out;
59     MessageOption option;
60     int32_t error = remote->SendRequest(IMS_DIAL, in, out, option);
61     if (error == ERR_NONE) {
62         return out.ReadInt32();
63     }
64     TELEPHONY_LOGE("[slot%{public}d]SendRequest fail, error:%{public}d", callInfo.slotId, error);
65     CellularCallHiSysEvent::WriteDialCallFaultEvent(callInfo.slotId, INVALID_PARAMETER, callInfo.videoState,
66         static_cast<int32_t>(CallErrorCode::CALL_ERROR_SEND_REQUEST_FAIL), "ims call proxy send request fail");
67     return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
68 }
69 
HangUp(const ImsCallInfo & callInfo)70 int32_t ImsCallProxy::HangUp(const ImsCallInfo &callInfo)
71 {
72     if (!TelephonyPermission::CheckPermission(Permission::ANSWER_CALL)) {
73         TELEPHONY_LOGE("[slot%{public}d]Permission denied!", callInfo.slotId);
74         return TELEPHONY_ERR_PERMISSION_ERR;
75     }
76     MessageParcel in;
77     if (!in.WriteInterfaceToken(ImsCallProxy::GetDescriptor())) {
78         TELEPHONY_LOGE("[slot%{public}d]Write descriptor token fail!", callInfo.slotId);
79         CellularCallHiSysEvent::WriteHangUpFaultEvent(callInfo.slotId, INVALID_PARAMETER,
80             TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL, "HangUp ims call proxy write descriptor token fail");
81         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
82     }
83     if (!in.WriteRawData((const void *)&callInfo, sizeof(ImsCallInfo))) {
84         TELEPHONY_LOGE("[slot%{public}d]Write callInfo fail!", callInfo.slotId);
85         CellularCallHiSysEvent::WriteHangUpFaultEvent(callInfo.slotId, INVALID_PARAMETER,
86             TELEPHONY_ERR_WRITE_DATA_FAIL, "HangUp ims call proxy write data fail");
87         return TELEPHONY_ERR_WRITE_DATA_FAIL;
88     }
89     sptr<IRemoteObject> remote = Remote();
90     if (remote == nullptr) {
91         TELEPHONY_LOGE("[slot%{public}d]Remote is null", callInfo.slotId);
92         return TELEPHONY_ERR_LOCAL_PTR_NULL;
93     }
94     MessageParcel out;
95     MessageOption option;
96     int32_t error = remote->SendRequest(IMS_HANG_UP, in, out, option);
97     if (error == ERR_NONE) {
98         return out.ReadInt32();
99     }
100     TELEPHONY_LOGE("[slot%{public}d]SendRequest fail, error:%{public}d", callInfo.slotId, error);
101     CellularCallHiSysEvent::WriteHangUpFaultEvent(callInfo.slotId, INVALID_PARAMETER,
102         static_cast<int32_t>(CallErrorCode::CALL_ERROR_SEND_REQUEST_FAIL), "HangUp ims call proxy send request fail");
103     return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
104 }
105 
RejectWithReason(const ImsCallInfo & callInfo,const ImsRejectReason & reason)106 int32_t ImsCallProxy::RejectWithReason(const ImsCallInfo &callInfo, const ImsRejectReason &reason)
107 {
108     if (!TelephonyPermission::CheckPermission(Permission::ANSWER_CALL)) {
109         TELEPHONY_LOGE("[slot%{public}d]Permission denied!", callInfo.slotId);
110         return TELEPHONY_ERR_PERMISSION_ERR;
111     }
112     MessageParcel in;
113     if (!in.WriteInterfaceToken(ImsCallProxy::GetDescriptor())) {
114         TELEPHONY_LOGE("[slot%{public}d]Write descriptor token fail!", callInfo.slotId);
115         CellularCallHiSysEvent::WriteHangUpFaultEvent(callInfo.slotId, INVALID_PARAMETER,
116             TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL, "Reject ims call proxy write descriptor token fail");
117         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
118     }
119     if (!in.WriteRawData((const void *)&callInfo, sizeof(ImsCallInfo))) {
120         TELEPHONY_LOGE("[slot%{public}d]Write callInfo fail!", callInfo.slotId);
121         CellularCallHiSysEvent::WriteHangUpFaultEvent(callInfo.slotId, INVALID_PARAMETER,
122             TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL, "Reject ims call proxy write data fail");
123         return TELEPHONY_ERR_WRITE_DATA_FAIL;
124     }
125     if (!in.WriteInt32(reason)) {
126         TELEPHONY_LOGE("[slot%{public}d]Write reason fail!", callInfo.slotId);
127         return TELEPHONY_ERR_WRITE_DATA_FAIL;
128     }
129     sptr<IRemoteObject> remote = Remote();
130     if (remote == nullptr) {
131         TELEPHONY_LOGE("[slot%{public}d]Remote is null", callInfo.slotId);
132         return TELEPHONY_ERR_LOCAL_PTR_NULL;
133     }
134     MessageParcel out;
135     MessageOption option;
136     int32_t error = remote->SendRequest(IMS_REJECT_WITH_REASON, in, out, option);
137     if (error == ERR_NONE) {
138         return out.ReadInt32();
139     }
140     TELEPHONY_LOGE("[slot%{public}d]SendRequest fail, error:%{public}d", callInfo.slotId, error);
141     CellularCallHiSysEvent::WriteHangUpFaultEvent(callInfo.slotId, INVALID_PARAMETER,
142         static_cast<int32_t>(CallErrorCode::CALL_ERROR_SEND_REQUEST_FAIL), "Reject ims call proxy send request fail");
143     return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
144 }
145 
Answer(const ImsCallInfo & callInfo)146 int32_t ImsCallProxy::Answer(const ImsCallInfo &callInfo)
147 {
148     if (!TelephonyPermission::CheckPermission(Permission::ANSWER_CALL)) {
149         TELEPHONY_LOGE("[slot%{public}d]Permission denied!", callInfo.slotId);
150         return TELEPHONY_ERR_PERMISSION_ERR;
151     }
152     MessageParcel in;
153     if (!in.WriteInterfaceToken(ImsCallProxy::GetDescriptor())) {
154         TELEPHONY_LOGE("[slot%{public}d]Write descriptor token fail!", callInfo.slotId);
155         CellularCallHiSysEvent::WriteAnswerCallFaultEvent(callInfo.slotId, INVALID_PARAMETER, callInfo.videoState,
156             TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL, "ims call proxy write descriptor token fail");
157         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
158     }
159     if (!in.WriteRawData((const void *)&callInfo, sizeof(ImsCallInfo))) {
160         TELEPHONY_LOGE("[slot%{public}d]Write callInfo fail!", callInfo.slotId);
161         CellularCallHiSysEvent::WriteAnswerCallFaultEvent(callInfo.slotId, INVALID_PARAMETER, callInfo.videoState,
162             TELEPHONY_ERR_WRITE_DATA_FAIL, "ims call proxy write data fail");
163         return TELEPHONY_ERR_WRITE_DATA_FAIL;
164     }
165     sptr<IRemoteObject> remote = Remote();
166     if (remote == nullptr) {
167         TELEPHONY_LOGE("[slot%{public}d]Remote is null", callInfo.slotId);
168         return TELEPHONY_ERR_LOCAL_PTR_NULL;
169     }
170     MessageParcel out;
171     MessageOption option;
172     int32_t error = remote->SendRequest(IMS_ANSWER, in, out, option);
173     if (error == ERR_NONE) {
174         return out.ReadInt32();
175     }
176     TELEPHONY_LOGE("[slot%{public}d]SendRequest fail, error:%{public}d", callInfo.slotId, error);
177     CellularCallHiSysEvent::WriteAnswerCallFaultEvent(callInfo.slotId, INVALID_PARAMETER, callInfo.videoState,
178         static_cast<int32_t>(CallErrorCode::CALL_ERROR_SEND_REQUEST_FAIL), "ims call proxy send request fail");
179     return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
180 }
181 
HoldCall(int32_t slotId,int32_t callType)182 int32_t ImsCallProxy::HoldCall(int32_t slotId, int32_t callType)
183 {
184     if (!TelephonyPermission::CheckPermission(Permission::ANSWER_CALL)) {
185         TELEPHONY_LOGE("[slot%{public}d]Permission denied!", slotId);
186         return TELEPHONY_ERR_PERMISSION_ERR;
187     }
188     MessageParcel in;
189     int32_t ret = WriteCommonInfo(__FUNCTION__, in, slotId, callType);
190     if (ret != TELEPHONY_SUCCESS) {
191         return ret;
192     }
193     return SendRequest(in, slotId, IMS_HOLD);
194 }
195 
UnHoldCall(int32_t slotId,int32_t callType)196 int32_t ImsCallProxy::UnHoldCall(int32_t slotId, int32_t callType)
197 {
198     if (!TelephonyPermission::CheckPermission(Permission::ANSWER_CALL)) {
199         TELEPHONY_LOGE("[slot%{public}d]Permission denied!", slotId);
200         return TELEPHONY_ERR_PERMISSION_ERR;
201     }
202     MessageParcel in;
203     int32_t ret = WriteCommonInfo(__FUNCTION__, in, slotId, callType);
204     if (ret != TELEPHONY_SUCCESS) {
205         return ret;
206     }
207     return SendRequest(in, slotId, IMS_UN_HOLD);
208 }
209 
SwitchCall(int32_t slotId,int32_t callType)210 int32_t ImsCallProxy::SwitchCall(int32_t slotId, int32_t callType)
211 {
212     if (!TelephonyPermission::CheckPermission(Permission::ANSWER_CALL)) {
213         TELEPHONY_LOGE("[slot%{public}d]Permission denied!", slotId);
214         return TELEPHONY_ERR_PERMISSION_ERR;
215     }
216     MessageParcel in;
217     int32_t ret = WriteCommonInfo(__FUNCTION__, in, slotId, callType);
218     if (ret != TELEPHONY_SUCCESS) {
219         return ret;
220     }
221     return SendRequest(in, slotId, IMS_SWITCH);
222 }
223 
CombineConference(int32_t slotId)224 int32_t ImsCallProxy::CombineConference(int32_t slotId)
225 {
226     MessageParcel in;
227     int32_t ret = WriteCommonInfo(__FUNCTION__, in, slotId);
228     if (ret != TELEPHONY_SUCCESS) {
229         return ret;
230     }
231     return SendRequest(in, slotId, IMS_COMBINE_CONFERENCE);
232 }
233 
InviteToConference(int32_t slotId,const std::vector<std::string> & numberList)234 int32_t ImsCallProxy::InviteToConference(int32_t slotId, const std::vector<std::string> &numberList)
235 {
236     MessageParcel in;
237     int32_t ret = WriteCommonInfo(__FUNCTION__, in, slotId);
238     if (ret != TELEPHONY_SUCCESS) {
239         return ret;
240     }
241     if (!in.WriteStringVector(numberList)) {
242         TELEPHONY_LOGE("[slot%{public}d]Write numberList fail!", slotId);
243         return TELEPHONY_ERR_WRITE_DATA_FAIL;
244     }
245     return SendRequest(in, slotId, IMS_INVITE_TO_CONFERENCE);
246 }
247 
KickOutFromConference(int32_t slotId,const std::vector<std::string> & numberList)248 int32_t ImsCallProxy::KickOutFromConference(int32_t slotId, const std::vector<std::string> &numberList)
249 {
250     MessageParcel in;
251     int32_t ret = WriteCommonInfo(__FUNCTION__, in, slotId);
252     if (ret != TELEPHONY_SUCCESS) {
253         return ret;
254     }
255     if (!in.WriteStringVector(numberList)) {
256         TELEPHONY_LOGE("[slot%{public}d]Write numberList fail!", slotId);
257         return TELEPHONY_ERR_WRITE_DATA_FAIL;
258     }
259     return SendRequest(in, slotId, IMS_KICK_OUT_CONFERENCE);
260 }
261 
UpdateImsCallMode(const ImsCallInfo & callInfo,ImsCallMode mode)262 int32_t ImsCallProxy::UpdateImsCallMode(const ImsCallInfo &callInfo, ImsCallMode mode)
263 {
264     MessageParcel in;
265     if (!in.WriteInterfaceToken(ImsCallProxy::GetDescriptor())) {
266         TELEPHONY_LOGE("[slot%{public}d]Write descriptor token fail!", callInfo.slotId);
267         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
268     }
269     if (!in.WriteRawData((const void *)&callInfo, sizeof(ImsCallInfo))) {
270         TELEPHONY_LOGE("[slot%{public}d]Write callInfo fail!", callInfo.slotId);
271         return TELEPHONY_ERR_WRITE_DATA_FAIL;
272     }
273     if (!in.WriteInt32(mode)) {
274         TELEPHONY_LOGE("[slot%{public}d]Write mode fail!", callInfo.slotId);
275         return TELEPHONY_ERR_WRITE_DATA_FAIL;
276     }
277     return SendRequest(in, callInfo.slotId, IMS_UPDATE_CALL_MEDIA_MODE);
278 }
279 
GetImsCallsDataRequest(int32_t slotId,int64_t lastCallsDataFlag)280 int32_t ImsCallProxy::GetImsCallsDataRequest(int32_t slotId, int64_t lastCallsDataFlag)
281 {
282     MessageParcel in;
283     int32_t ret = WriteCommonInfo(__FUNCTION__, in, slotId);
284     if (ret != TELEPHONY_SUCCESS) {
285         return ret;
286     }
287     if (!in.WriteInt64(lastCallsDataFlag)) {
288         TELEPHONY_LOGE("[slot%{public}d]Write lastCallsDataFlag fail!", slotId);
289         return TELEPHONY_ERR_WRITE_DATA_FAIL;
290     }
291     return SendRequest(in, slotId, IMS_GET_CALL_DATA);
292 }
293 
GetLastCallFailReason(int32_t slotId)294 int32_t ImsCallProxy::GetLastCallFailReason(int32_t slotId)
295 {
296     MessageParcel in;
297     int32_t ret = WriteCommonInfo(__FUNCTION__, in, slotId);
298     if (ret != TELEPHONY_SUCCESS) {
299         return ret;
300     }
301     return SendRequest(in, slotId, IMS_GET_LAST_CALL_FAIL_REASON);
302 }
303 
StartDtmf(int32_t slotId,char cDtmfCode,int32_t index)304 int32_t ImsCallProxy::StartDtmf(int32_t slotId, char cDtmfCode, int32_t index)
305 {
306     MessageParcel in;
307     int32_t ret = WriteCommonInfo(__FUNCTION__, in, slotId);
308     if (ret != TELEPHONY_SUCCESS) {
309         return ret;
310     }
311     if (!in.WriteInt8(cDtmfCode)) {
312         TELEPHONY_LOGE("[slot%{public}d]Write cDtmfCode fail!", slotId);
313         return TELEPHONY_ERR_WRITE_DATA_FAIL;
314     }
315     if (!in.WriteInt32(index)) {
316         TELEPHONY_LOGE("[slot%{public}d]Write index fail!", slotId);
317         return TELEPHONY_ERR_WRITE_DATA_FAIL;
318     }
319     return SendRequest(in, slotId, IMS_START_DTMF);
320 }
321 
SendDtmf(int32_t slotId,char cDtmfCode,int32_t index)322 int32_t ImsCallProxy::SendDtmf(int32_t slotId, char cDtmfCode, int32_t index)
323 {
324     MessageParcel in;
325     int32_t ret = WriteCommonInfo(__FUNCTION__, in, slotId);
326     if (ret != TELEPHONY_SUCCESS) {
327         return ret;
328     }
329     if (!in.WriteInt8(cDtmfCode)) {
330         TELEPHONY_LOGE("[slot%{public}d]Write cDtmfCode fail!", slotId);
331         return TELEPHONY_ERR_WRITE_DATA_FAIL;
332     }
333     if (!in.WriteInt32(index)) {
334         TELEPHONY_LOGE("[slot%{public}d]Write index fail!", slotId);
335         return TELEPHONY_ERR_WRITE_DATA_FAIL;
336     }
337     return SendRequest(in, slotId, IMS_SEND_DTMF);
338 }
339 
StopDtmf(int32_t slotId,int32_t index)340 int32_t ImsCallProxy::StopDtmf(int32_t slotId, int32_t index)
341 {
342     MessageParcel in;
343     int32_t ret = WriteCommonInfo(__FUNCTION__, in, slotId);
344     if (ret != TELEPHONY_SUCCESS) {
345         return ret;
346     }
347     if (!in.WriteInt32(index)) {
348         TELEPHONY_LOGE("[slot%{public}d]Write index fail!", slotId);
349         return TELEPHONY_ERR_WRITE_DATA_FAIL;
350     }
351     return SendRequest(in, slotId, IMS_STOP_DTMF);
352 }
353 
StartRtt(int32_t slotId,const std::string & msg)354 int32_t ImsCallProxy::StartRtt(int32_t slotId, const std::string &msg)
355 {
356     MessageParcel in;
357     int32_t ret = WriteCommonInfo(__FUNCTION__, in, slotId);
358     if (ret != TELEPHONY_SUCCESS) {
359         return ret;
360     }
361     if (!in.WriteString(msg)) {
362         TELEPHONY_LOGE("[slot%{public}d]Write msg fail!", slotId);
363         return TELEPHONY_ERR_WRITE_DATA_FAIL;
364     }
365     return SendRequest(in, slotId, IMS_START_RTT);
366 }
367 
StopRtt(int32_t slotId)368 int32_t ImsCallProxy::StopRtt(int32_t slotId)
369 {
370     MessageParcel in;
371     int32_t ret = WriteCommonInfo(__FUNCTION__, in, slotId);
372     if (ret != TELEPHONY_SUCCESS) {
373         return ret;
374     }
375     return SendRequest(in, slotId, IMS_STOP_RTT);
376 }
377 
SetDomainPreferenceMode(int32_t slotId,int32_t mode)378 int32_t ImsCallProxy::SetDomainPreferenceMode(int32_t slotId, int32_t mode)
379 {
380     if (!TelephonyPermission::CheckPermission(Permission::SET_TELEPHONY_STATE)) {
381         TELEPHONY_LOGE("[slot%{public}d]Permission denied!", slotId);
382         return TELEPHONY_ERR_PERMISSION_ERR;
383     }
384     MessageParcel in;
385     int32_t ret = WriteCommonInfo(__FUNCTION__, in, slotId);
386     if (ret != TELEPHONY_SUCCESS) {
387         return ret;
388     }
389     if (!in.WriteInt32(mode)) {
390         TELEPHONY_LOGE("[slot%{public}d]Write mode fail!", slotId);
391         return TELEPHONY_ERR_WRITE_DATA_FAIL;
392     }
393     return SendRequest(in, slotId, IMS_SET_DOMAIN_PREFERENCE_MODE);
394 }
395 
GetDomainPreferenceMode(int32_t slotId)396 int32_t ImsCallProxy::GetDomainPreferenceMode(int32_t slotId)
397 {
398     MessageParcel in;
399     int32_t ret = WriteCommonInfo(__FUNCTION__, in, slotId);
400     if (ret != TELEPHONY_SUCCESS) {
401         return ret;
402     }
403     return SendRequest(in, slotId, IMS_GET_DOMAIN_PREFERENCE_MODE);
404 }
405 
SetImsSwitchStatus(int32_t slotId,int32_t active)406 int32_t ImsCallProxy::SetImsSwitchStatus(int32_t slotId, int32_t active)
407 {
408     MessageParcel in;
409     int32_t ret = WriteCommonInfo(__FUNCTION__, in, slotId);
410     if (ret != TELEPHONY_SUCCESS) {
411         return ret;
412     }
413     if (!in.WriteInt32(active)) {
414         TELEPHONY_LOGE("[slot%{public}d]Write active fail!", slotId);
415         return TELEPHONY_ERR_WRITE_DATA_FAIL;
416     }
417     return SendRequest(in, slotId, IMS_SET_SWITCH_STATUS);
418 }
419 
GetImsSwitchStatus(int32_t slotId)420 int32_t ImsCallProxy::GetImsSwitchStatus(int32_t slotId)
421 {
422     MessageParcel in;
423     int32_t ret = WriteCommonInfo(__FUNCTION__, in, slotId);
424     if (ret != TELEPHONY_SUCCESS) {
425         return ret;
426     }
427     return SendRequest(in, slotId, IMS_GET_SWITCH_STATUS);
428 }
429 
SetImsConfig(ImsConfigItem item,const std::string & value)430 int32_t ImsCallProxy::SetImsConfig(ImsConfigItem item, const std::string &value)
431 {
432     MessageParcel in;
433     if (!in.WriteInterfaceToken(ImsCallProxy::GetDescriptor())) {
434         TELEPHONY_LOGE("Write descriptor token fail!");
435         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
436     }
437     if (!in.WriteInt32(item)) {
438         TELEPHONY_LOGE("Write item fail!");
439         return TELEPHONY_ERR_WRITE_DATA_FAIL;
440     }
441     if (!in.WriteString(value)) {
442         TELEPHONY_LOGE("Write value fail!");
443         return TELEPHONY_ERR_WRITE_DATA_FAIL;
444     }
445     return SendRequest(in, IMS_SET_IMS_CONFIG_STRING);
446 }
447 
SetImsConfig(ImsConfigItem item,int32_t value)448 int32_t ImsCallProxy::SetImsConfig(ImsConfigItem item, int32_t value)
449 {
450     MessageParcel in;
451     if (!in.WriteInterfaceToken(ImsCallProxy::GetDescriptor())) {
452         TELEPHONY_LOGE("Write descriptor token fail!");
453         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
454     }
455     if (!in.WriteInt32(item)) {
456         TELEPHONY_LOGE("Write item fail!");
457         return TELEPHONY_ERR_WRITE_DATA_FAIL;
458     }
459     if (!in.WriteInt32(value)) {
460         TELEPHONY_LOGE("Write value fail!");
461         return TELEPHONY_ERR_WRITE_DATA_FAIL;
462     }
463     return SendRequest(in, IMS_SET_IMS_CONFIG_INT);
464 }
465 
GetImsConfig(ImsConfigItem item)466 int32_t ImsCallProxy::GetImsConfig(ImsConfigItem item)
467 {
468     MessageParcel in;
469     if (!in.WriteInterfaceToken(ImsCallProxy::GetDescriptor())) {
470         TELEPHONY_LOGE("Write descriptor token fail!");
471         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
472     }
473     if (!in.WriteInt32(item)) {
474         TELEPHONY_LOGE("Write item fail!");
475         return TELEPHONY_ERR_WRITE_DATA_FAIL;
476     }
477     return SendRequest(in, IMS_GET_IMS_CONFIG);
478 }
479 
SetImsFeatureValue(FeatureType type,int32_t value)480 int32_t ImsCallProxy::SetImsFeatureValue(FeatureType type, int32_t value)
481 {
482     MessageParcel in;
483     if (!in.WriteInterfaceToken(ImsCallProxy::GetDescriptor())) {
484         TELEPHONY_LOGE("Write descriptor token fail!");
485         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
486     }
487     if (!in.WriteInt32(type)) {
488         TELEPHONY_LOGE("Write type fail!");
489         return TELEPHONY_ERR_WRITE_DATA_FAIL;
490     }
491     if (!in.WriteInt32(value)) {
492         TELEPHONY_LOGE("Write value fail!");
493         return TELEPHONY_ERR_WRITE_DATA_FAIL;
494     }
495     return SendRequest(in, IMS_SET_IMS_FEATURE);
496 }
497 
GetImsFeatureValue(FeatureType type,int32_t & value)498 int32_t ImsCallProxy::GetImsFeatureValue(FeatureType type, int32_t &value)
499 {
500     MessageParcel in;
501     if (!in.WriteInterfaceToken(ImsCallProxy::GetDescriptor())) {
502         TELEPHONY_LOGE("Write descriptor token fail!");
503         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
504     }
505     if (!in.WriteInt32(type)) {
506         TELEPHONY_LOGE("Write type fail!");
507         return TELEPHONY_ERR_WRITE_DATA_FAIL;
508     }
509     return SendRequest(in, IMS_GET_IMS_FEATURE);
510 }
511 
SetMute(int32_t slotId,int32_t mute)512 int32_t ImsCallProxy::SetMute(int32_t slotId, int32_t mute)
513 {
514     MessageParcel in;
515     int32_t ret = WriteCommonInfo(__FUNCTION__, in, slotId);
516     if (ret != TELEPHONY_SUCCESS) {
517         return ret;
518     }
519     if (!in.WriteInt32(mute)) {
520         TELEPHONY_LOGE("[slot%{public}d]Write mute fail!", slotId);
521         return TELEPHONY_ERR_WRITE_DATA_FAIL;
522     }
523     return SendRequest(in, slotId, IMS_SET_MUTE);
524 }
525 
GetMute(int32_t slotId)526 int32_t ImsCallProxy::GetMute(int32_t slotId)
527 {
528     MessageParcel in;
529     int32_t ret = WriteCommonInfo(__FUNCTION__, in, slotId);
530     if (ret != TELEPHONY_SUCCESS) {
531         return ret;
532     }
533     return SendRequest(in, slotId, IMS_GET_MUTE);
534 }
535 
CtrlCamera(const std::u16string & cameraId,int32_t callingUid,int32_t callingPid)536 int32_t ImsCallProxy::CtrlCamera(const std::u16string &cameraId, int32_t callingUid, int32_t callingPid)
537 {
538     MessageParcel in;
539     if (!in.WriteInterfaceToken(ImsCallProxy::GetDescriptor())) {
540         TELEPHONY_LOGE("Write descriptor token fail!");
541         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
542     }
543     if (!in.WriteString16(cameraId)) {
544         TELEPHONY_LOGE("Write cameraId fail!");
545         return TELEPHONY_ERR_WRITE_DATA_FAIL;
546     }
547     if (!in.WriteInt32(callingUid)) {
548         TELEPHONY_LOGE("Write callingUid fail!");
549         return TELEPHONY_ERR_WRITE_DATA_FAIL;
550     }
551     if (!in.WriteInt32(callingPid)) {
552         TELEPHONY_LOGE("Write callingPid fail!");
553         return TELEPHONY_ERR_WRITE_DATA_FAIL;
554     }
555     return SendRequest(in, IMS_CTRL_CAMERA);
556 }
557 
SetPreviewWindow(int32_t x,int32_t y,int32_t z,int32_t width,int32_t height)558 int32_t ImsCallProxy::SetPreviewWindow(int32_t x, int32_t y, int32_t z, int32_t width, int32_t height)
559 {
560     MessageParcel in;
561     if (!in.WriteInterfaceToken(ImsCallProxy::GetDescriptor())) {
562         TELEPHONY_LOGE("Write descriptor token fail!");
563         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
564     }
565     if (!in.WriteInt32(x)) {
566         TELEPHONY_LOGE("Write x fail!");
567         return TELEPHONY_ERR_WRITE_DATA_FAIL;
568     }
569     if (!in.WriteInt32(y)) {
570         TELEPHONY_LOGE("Write y fail!");
571         return TELEPHONY_ERR_WRITE_DATA_FAIL;
572     }
573     if (!in.WriteInt32(z)) {
574         TELEPHONY_LOGE("Write z fail!");
575         return TELEPHONY_ERR_WRITE_DATA_FAIL;
576     }
577     if (!in.WriteInt32(width)) {
578         TELEPHONY_LOGE("Write width fail!");
579         return TELEPHONY_ERR_WRITE_DATA_FAIL;
580     }
581     if (!in.WriteInt32(height)) {
582         TELEPHONY_LOGE("Write height fail!");
583         return TELEPHONY_ERR_WRITE_DATA_FAIL;
584     }
585     return SendRequest(in, IMS_SET_PREVIEW_WINDOW);
586 }
587 
SetDisplayWindow(int32_t x,int32_t y,int32_t z,int32_t width,int32_t height)588 int32_t ImsCallProxy::SetDisplayWindow(int32_t x, int32_t y, int32_t z, int32_t width, int32_t height)
589 {
590     MessageParcel in;
591     if (!in.WriteInterfaceToken(ImsCallProxy::GetDescriptor())) {
592         TELEPHONY_LOGE("Write descriptor token fail!");
593         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
594     }
595     if (!in.WriteInt32(x)) {
596         TELEPHONY_LOGE("Write x fail!");
597         return TELEPHONY_ERR_WRITE_DATA_FAIL;
598     }
599     if (!in.WriteInt32(y)) {
600         TELEPHONY_LOGE("Write y fail!");
601         return TELEPHONY_ERR_WRITE_DATA_FAIL;
602     }
603     if (!in.WriteInt32(z)) {
604         TELEPHONY_LOGE("Write z fail!");
605         return TELEPHONY_ERR_WRITE_DATA_FAIL;
606     }
607     if (!in.WriteInt32(width)) {
608         TELEPHONY_LOGE("Write width fail!");
609         return TELEPHONY_ERR_WRITE_DATA_FAIL;
610     }
611     if (!in.WriteInt32(height)) {
612         TELEPHONY_LOGE("Write height fail!");
613         return TELEPHONY_ERR_WRITE_DATA_FAIL;
614     }
615     return SendRequest(in, IMS_SET_DISPLAY_WINDOW);
616 }
617 
SetCameraZoom(float zoomRatio)618 int32_t ImsCallProxy::SetCameraZoom(float zoomRatio)
619 {
620     MessageParcel in;
621     if (!in.WriteInterfaceToken(ImsCallProxy::GetDescriptor())) {
622         TELEPHONY_LOGE("Write descriptor token fail!");
623         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
624     }
625     if (!in.WriteFloat(zoomRatio)) {
626         TELEPHONY_LOGE("Write zoomRatio fail!");
627         return TELEPHONY_ERR_WRITE_DATA_FAIL;
628     }
629     return SendRequest(in, IMS_SET_CAMERA_ZOOM);
630 }
631 
SetPauseImage(const std::u16string & path)632 int32_t ImsCallProxy::SetPauseImage(const std::u16string &path)
633 {
634     MessageParcel in;
635     if (!in.WriteInterfaceToken(ImsCallProxy::GetDescriptor())) {
636         TELEPHONY_LOGE("Write descriptor token fail!");
637         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
638     }
639     if (!in.WriteString16(path)) {
640         TELEPHONY_LOGE("Write path fail!");
641         return TELEPHONY_ERR_WRITE_DATA_FAIL;
642     }
643     return SendRequest(in, IMS_SET_PAUSE_IMAGE);
644 }
645 
SetDeviceDirection(int32_t rotation)646 int32_t ImsCallProxy::SetDeviceDirection(int32_t rotation)
647 {
648     MessageParcel in;
649     if (!in.WriteInterfaceToken(ImsCallProxy::GetDescriptor())) {
650         TELEPHONY_LOGE("Write descriptor token fail!");
651         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
652     }
653     if (!in.WriteInt32(rotation)) {
654         TELEPHONY_LOGE("Write rotation fail!");
655         return TELEPHONY_ERR_WRITE_DATA_FAIL;
656     }
657     return SendRequest(in, IMS_SET_DEVICE_DIRECTION);
658 }
659 
SetClip(int32_t slotId,int32_t action)660 int32_t ImsCallProxy::SetClip(int32_t slotId, int32_t action)
661 {
662     MessageParcel in;
663     int32_t ret = WriteCommonInfo(__FUNCTION__, in, slotId);
664     if (ret != TELEPHONY_SUCCESS) {
665         return ret;
666     }
667     if (!in.WriteInt32(action)) {
668         TELEPHONY_LOGE("[slot%{public}d]Write action fail!", slotId);
669         return TELEPHONY_ERR_WRITE_DATA_FAIL;
670     }
671     return SendRequest(in, slotId, IMS_SET_CLIP);
672 }
673 
GetClip(int32_t slotId)674 int32_t ImsCallProxy::GetClip(int32_t slotId)
675 {
676     MessageParcel in;
677     int32_t ret = WriteCommonInfo(__FUNCTION__, in, slotId);
678     if (ret != TELEPHONY_SUCCESS) {
679         return ret;
680     }
681     return SendRequest(in, slotId, IMS_GET_CLIP);
682 }
683 
SetClir(int32_t slotId,int32_t action)684 int32_t ImsCallProxy::SetClir(int32_t slotId, int32_t action)
685 {
686     MessageParcel in;
687     int32_t ret = WriteCommonInfo(__FUNCTION__, in, slotId);
688     if (ret != TELEPHONY_SUCCESS) {
689         return ret;
690     }
691     if (!in.WriteInt32(action)) {
692         TELEPHONY_LOGE("[slot%{public}d]Write action fail!", slotId);
693         return TELEPHONY_ERR_WRITE_DATA_FAIL;
694     }
695     return SendRequest(in, slotId, IMS_SET_CLIR);
696 }
697 
GetClir(int32_t slotId)698 int32_t ImsCallProxy::GetClir(int32_t slotId)
699 {
700     MessageParcel in;
701     int32_t ret = WriteCommonInfo(__FUNCTION__, in, slotId);
702     if (ret != TELEPHONY_SUCCESS) {
703         return ret;
704     }
705     return SendRequest(in, slotId, IMS_GET_CLIR);
706 }
707 
SetCallTransfer(int32_t slotId,int32_t reason,int32_t mode,const std::string & transferNum,int32_t classType)708 int32_t ImsCallProxy::SetCallTransfer(
709     int32_t slotId, int32_t reason, int32_t mode, const std::string &transferNum, int32_t classType)
710 {
711     if (!TelephonyPermission::CheckPermission(Permission::SET_TELEPHONY_STATE)) {
712         TELEPHONY_LOGE("[slot%{public}d]Permission denied!", slotId);
713         return TELEPHONY_ERR_PERMISSION_ERR;
714     }
715     MessageParcel in;
716     int32_t ret = WriteCommonInfo(__FUNCTION__, in, slotId);
717     if (ret != TELEPHONY_SUCCESS) {
718         return ret;
719     }
720     if (!in.WriteInt32(reason)) {
721         TELEPHONY_LOGE("[slot%{public}d]Write reason fail!", slotId);
722         return TELEPHONY_ERR_WRITE_DATA_FAIL;
723     }
724     if (!in.WriteInt32(mode)) {
725         TELEPHONY_LOGE("[slot%{public}d]Write mode fail!", slotId);
726         return TELEPHONY_ERR_WRITE_DATA_FAIL;
727     }
728     if (!in.WriteString(transferNum)) {
729         TELEPHONY_LOGE("[slot%{public}d]Write transferNum fail!", slotId);
730         return TELEPHONY_ERR_WRITE_DATA_FAIL;
731     }
732     if (!in.WriteInt32(classType)) {
733         TELEPHONY_LOGE("[slot%{public}d]Write classType fail!", slotId);
734         return TELEPHONY_ERR_WRITE_DATA_FAIL;
735     }
736     return SendRequest(in, slotId, IMS_SET_CALL_TRANSFER);
737 }
738 
GetCallTransfer(int32_t slotId,int32_t reason)739 int32_t ImsCallProxy::GetCallTransfer(int32_t slotId, int32_t reason)
740 {
741     if (!TelephonyPermission::CheckPermission(Permission::GET_TELEPHONY_STATE)) {
742         TELEPHONY_LOGE("[slot%{public}d]Permission denied!", slotId);
743         return TELEPHONY_ERR_PERMISSION_ERR;
744     }
745     MessageParcel in;
746     int32_t ret = WriteCommonInfo(__FUNCTION__, in, slotId);
747     if (ret != TELEPHONY_SUCCESS) {
748         return ret;
749     }
750     if (!in.WriteInt32(reason)) {
751         TELEPHONY_LOGE("[slot%{public}d]Write reason fail!", slotId);
752         return TELEPHONY_ERR_WRITE_DATA_FAIL;
753     }
754     return SendRequest(in, slotId, IMS_GET_CALL_TRANSFER);
755 }
756 
SetCallRestriction(int32_t slotId,const std::string & fac,int32_t mode,const std::string & pw)757 int32_t ImsCallProxy::SetCallRestriction(int32_t slotId, const std::string &fac, int32_t mode, const std::string &pw)
758 {
759     if (!TelephonyPermission::CheckPermission(Permission::SET_TELEPHONY_STATE)) {
760         TELEPHONY_LOGE("[slot%{public}d]Permission denied!", slotId);
761         return TELEPHONY_ERR_PERMISSION_ERR;
762     }
763     MessageParcel in;
764     int32_t ret = WriteCommonInfo(__FUNCTION__, in, slotId);
765     if (ret != TELEPHONY_SUCCESS) {
766         return ret;
767     }
768     if (!in.WriteString(fac)) {
769         TELEPHONY_LOGE("[slot%{public}d]Write fac fail!", slotId);
770         return TELEPHONY_ERR_WRITE_DATA_FAIL;
771     }
772     if (!in.WriteInt32(mode)) {
773         TELEPHONY_LOGE("[slot%{public}d]Write mode fail!", slotId);
774         return TELEPHONY_ERR_WRITE_DATA_FAIL;
775     }
776     if (!in.WriteString(pw)) {
777         TELEPHONY_LOGE("[slot%{public}d]Write pw fail!", slotId);
778         return TELEPHONY_ERR_WRITE_DATA_FAIL;
779     }
780     return SendRequest(in, slotId, IMS_SET_CALL_RESTRICTION);
781 }
782 
GetCallRestriction(int32_t slotId,const std::string & fac)783 int32_t ImsCallProxy::GetCallRestriction(int32_t slotId, const std::string &fac)
784 {
785     if (!TelephonyPermission::CheckPermission(Permission::GET_TELEPHONY_STATE)) {
786         TELEPHONY_LOGE("[slot%{public}d]Permission denied!", slotId);
787         return TELEPHONY_ERR_PERMISSION_ERR;
788     }
789     MessageParcel in;
790     int32_t ret = WriteCommonInfo(__FUNCTION__, in, slotId);
791     if (ret != TELEPHONY_SUCCESS) {
792         return ret;
793     }
794     if (!in.WriteString(fac)) {
795         TELEPHONY_LOGE("[slot%{public}d]Write fac fail!", slotId);
796         return TELEPHONY_ERR_WRITE_DATA_FAIL;
797     }
798     return SendRequest(in, slotId, IMS_GET_CALL_RESTRICTION);
799 }
800 
SetCallWaiting(int32_t slotId,bool activate,int32_t classType)801 int32_t ImsCallProxy::SetCallWaiting(int32_t slotId, bool activate, int32_t classType)
802 {
803     if (!TelephonyPermission::CheckPermission(Permission::SET_TELEPHONY_STATE)) {
804         TELEPHONY_LOGE("[slot%{public}d]Permission denied!", slotId);
805         return TELEPHONY_ERR_PERMISSION_ERR;
806     }
807     MessageParcel in;
808     int32_t ret = WriteCommonInfo(__FUNCTION__, in, slotId);
809     if (ret != TELEPHONY_SUCCESS) {
810         return ret;
811     }
812     if (!in.WriteBool(activate)) {
813         TELEPHONY_LOGE("[slot%{public}d]Write activate fail!", slotId);
814         return TELEPHONY_ERR_WRITE_DATA_FAIL;
815     }
816     if (!in.WriteInt32(classType)) {
817         TELEPHONY_LOGE("[slot%{public}d]Write classType fail!", slotId);
818         return TELEPHONY_ERR_WRITE_DATA_FAIL;
819     }
820     return SendRequest(in, slotId, IMS_SET_CALL_WAITING);
821 }
822 
GetCallWaiting(int32_t slotId)823 int32_t ImsCallProxy::GetCallWaiting(int32_t slotId)
824 {
825     if (!TelephonyPermission::CheckPermission(Permission::GET_TELEPHONY_STATE)) {
826         TELEPHONY_LOGE("[slot%{public}d]Permission denied!", slotId);
827         return TELEPHONY_ERR_PERMISSION_ERR;
828     }
829     MessageParcel in;
830     int32_t ret = WriteCommonInfo(__FUNCTION__, in, slotId);
831     if (ret != TELEPHONY_SUCCESS) {
832         return ret;
833     }
834     return SendRequest(in, slotId, IMS_GET_CALL_WAITING);
835 }
836 
SetColr(int32_t slotId,int32_t presentation)837 int32_t ImsCallProxy::SetColr(int32_t slotId, int32_t presentation)
838 {
839     MessageParcel in;
840     int32_t ret = WriteCommonInfo(__FUNCTION__, in, slotId);
841     if (ret != TELEPHONY_SUCCESS) {
842         return ret;
843     }
844     if (!in.WriteInt32(presentation)) {
845         TELEPHONY_LOGE("[slot%{public}d]Write presentation fail!", slotId);
846         return TELEPHONY_ERR_WRITE_DATA_FAIL;
847     }
848     return SendRequest(in, slotId, IMS_SET_COLR);
849 }
850 
GetColr(int32_t slotId)851 int32_t ImsCallProxy::GetColr(int32_t slotId)
852 {
853     MessageParcel in;
854     int32_t ret = WriteCommonInfo(__FUNCTION__, in, slotId);
855     if (ret != TELEPHONY_SUCCESS) {
856         return ret;
857     }
858     return SendRequest(in, slotId, IMS_GET_COLR);
859 }
860 
SetColp(int32_t slotId,int32_t action)861 int32_t ImsCallProxy::SetColp(int32_t slotId, int32_t action)
862 {
863     MessageParcel in;
864     int32_t ret = WriteCommonInfo(__FUNCTION__, in, slotId);
865     if (ret != TELEPHONY_SUCCESS) {
866         return ret;
867     }
868     if (!in.WriteInt32(action)) {
869         TELEPHONY_LOGE("[slot%{public}d]Write action fail!", slotId);
870         return TELEPHONY_ERR_WRITE_DATA_FAIL;
871     }
872     return SendRequest(in, slotId, IMS_SET_COLP);
873 }
874 
GetColp(int32_t slotId)875 int32_t ImsCallProxy::GetColp(int32_t slotId)
876 {
877     MessageParcel in;
878     int32_t ret = WriteCommonInfo(__FUNCTION__, in, slotId);
879     if (ret != TELEPHONY_SUCCESS) {
880         return ret;
881     }
882     return SendRequest(in, slotId, IMS_GET_COLP);
883 }
884 
RegisterImsCallCallback(const sptr<ImsCallCallbackInterface> & callback)885 int32_t ImsCallProxy::RegisterImsCallCallback(const sptr<ImsCallCallbackInterface> &callback)
886 {
887     if (!TelephonyPermission::CheckPermission(Permission::SET_TELEPHONY_STATE)) {
888         TELEPHONY_LOGE("Permission denied!");
889         return TELEPHONY_ERR_PERMISSION_ERR;
890     }
891     if (callback == nullptr) {
892         TELEPHONY_LOGE("callback is nullptr!");
893         return TELEPHONY_ERR_ARGUMENT_INVALID;
894     }
895     MessageParcel in;
896     if (!in.WriteInterfaceToken(ImsCallProxy::GetDescriptor())) {
897         TELEPHONY_LOGE("Write descriptor token fail!");
898         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
899     }
900     if (!in.WriteRemoteObject(callback->AsObject().GetRefPtr())) {
901         TELEPHONY_LOGE("Write ImsCallCallbackInterface fail!");
902         return TELEPHONY_ERR_WRITE_DATA_FAIL;
903     }
904     return SendRequest(in, IMS_CALL_REGISTER_CALLBACK);
905 }
906 
UpdateImsCapabilities(int32_t slotId,const ImsCapabilityList & imsCapabilityList)907 int32_t ImsCallProxy::UpdateImsCapabilities(int32_t slotId, const ImsCapabilityList &imsCapabilityList)
908 {
909     MessageParcel in;
910     int32_t ret = WriteCommonInfo(__FUNCTION__, in, slotId);
911     if (ret != TELEPHONY_SUCCESS) {
912         return ret;
913     }
914     if (!in.WriteRawData((const void *)&imsCapabilityList, sizeof(ImsCapabilityList))) {
915         TELEPHONY_LOGE("[slot%{public}d]Write imsCapabilityList fail!", slotId);
916         return TELEPHONY_ERR_WRITE_DATA_FAIL;
917     }
918     return SendRequest(in, slotId, IMS_UPDATE_CAPABILITY);
919 }
920 
WriteCommonInfo(std::string funcName,MessageParcel & in,int32_t slotId)921 int32_t ImsCallProxy::WriteCommonInfo(std::string funcName, MessageParcel &in, int32_t slotId)
922 {
923     if (!in.WriteInterfaceToken(ImsCallProxy::GetDescriptor())) {
924         TELEPHONY_LOGE("[slot%{public}d] %{public}s Write descriptor token fail!", slotId, funcName.c_str());
925         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
926     }
927     if (!in.WriteInt32(slotId)) {
928         TELEPHONY_LOGE("[slot%{public}d] %{public}s Write slotId fail!", slotId, funcName.c_str());
929         return TELEPHONY_ERR_WRITE_DATA_FAIL;
930     }
931     return TELEPHONY_SUCCESS;
932 }
933 
WriteCommonInfo(std::string funcName,MessageParcel & in,int32_t slotId,int32_t callType)934 int32_t ImsCallProxy::WriteCommonInfo(std::string funcName, MessageParcel &in, int32_t slotId, int32_t callType)
935 {
936     int32_t ret = WriteCommonInfo(funcName, in, slotId);
937     if (ret != TELEPHONY_SUCCESS) {
938         return ret;
939     }
940     if (!in.WriteInt32(callType)) {
941         TELEPHONY_LOGE("[slot%{public}d] %{public}s Write callType fail!", slotId, funcName.c_str());
942         return TELEPHONY_ERR_WRITE_DATA_FAIL;
943     }
944     return TELEPHONY_SUCCESS;
945 }
946 
SendRequest(MessageParcel & in,int32_t eventId)947 int32_t ImsCallProxy::SendRequest(MessageParcel &in, int32_t eventId)
948 {
949     MessageParcel out;
950     MessageOption option;
951 
952     sptr<IRemoteObject> remote = Remote();
953     if (remote == nullptr) {
954         TELEPHONY_LOGE("Remote is null, eventId:%{public}d", eventId);
955         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
956     }
957 
958     int32_t error = remote->SendRequest(eventId, in, out, option);
959     if (error == ERR_NONE) {
960         return out.ReadInt32();
961     }
962     TELEPHONY_LOGE("SendRequest fail, eventId:%{public}d, error:%{public}d", eventId, error);
963     return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
964 }
965 
SendRequest(MessageParcel & in,int32_t slotId,int32_t eventId)966 int32_t ImsCallProxy::SendRequest(MessageParcel &in, int32_t slotId, int32_t eventId)
967 {
968     MessageParcel out;
969     MessageOption option;
970 
971     sptr<IRemoteObject> remote = Remote();
972     if (remote == nullptr) {
973         TELEPHONY_LOGE("[slot%{public}d]Remote is null, eventId:%{public}d", slotId, eventId);
974         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
975     }
976 
977     int32_t error = remote->SendRequest(eventId, in, out, option);
978     if (error == ERR_NONE) {
979         return out.ReadInt32();
980     }
981     TELEPHONY_LOGE("[slot%{public}d]SendRequest fail, eventId:%{public}d, error:%{public}d", slotId, eventId, error);
982     return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
983 }
984 } // namespace Telephony
985 } // namespace OHOS