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