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
SetCarrierVtConfig(int32_t slotId,int32_t active)430 int32_t ImsCallProxy::SetCarrierVtConfig(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_VT_CONFIG));
442 }
443
SetImsSwitchStatus(int32_t slotId,int32_t active)444 int32_t ImsCallProxy::SetImsSwitchStatus(int32_t slotId, int32_t active)
445 {
446 MessageParcel in;
447 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
448 if (ret != TELEPHONY_SUCCESS) {
449 return ret;
450 }
451 if (!in.WriteInt32(active)) {
452 TELEPHONY_LOGE("[slot%{public}d]Write active fail!", slotId);
453 return TELEPHONY_ERR_WRITE_DATA_FAIL;
454 }
455 return SendRequest(slotId, in, static_cast<int32_t>(ImsCallInterfaceCode::IMS_SET_SWITCH_STATUS));
456 }
457
GetImsSwitchStatus(int32_t slotId)458 int32_t ImsCallProxy::GetImsSwitchStatus(int32_t slotId)
459 {
460 MessageParcel in;
461 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
462 if (ret != TELEPHONY_SUCCESS) {
463 return ret;
464 }
465 return SendRequest(slotId, in, static_cast<int32_t>(ImsCallInterfaceCode::IMS_GET_SWITCH_STATUS));
466 }
467
SetImsConfig(ImsConfigItem item,const std::string & value)468 int32_t ImsCallProxy::SetImsConfig(ImsConfigItem item, const std::string &value)
469 {
470 MessageParcel in;
471 if (!in.WriteInterfaceToken(ImsCallProxy::GetDescriptor())) {
472 TELEPHONY_LOGE("Write descriptor token fail!");
473 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
474 }
475 if (!in.WriteInt32(item)) {
476 TELEPHONY_LOGE("Write item fail!");
477 return TELEPHONY_ERR_WRITE_DATA_FAIL;
478 }
479 if (!in.WriteString(value)) {
480 TELEPHONY_LOGE("Write value fail!");
481 return TELEPHONY_ERR_WRITE_DATA_FAIL;
482 }
483 return SendRequest(in, static_cast<int32_t>(ImsCallInterfaceCode::IMS_SET_IMS_CONFIG_STRING));
484 }
485
SetImsConfig(ImsConfigItem item,int32_t value)486 int32_t ImsCallProxy::SetImsConfig(ImsConfigItem item, int32_t value)
487 {
488 MessageParcel in;
489 if (!in.WriteInterfaceToken(ImsCallProxy::GetDescriptor())) {
490 TELEPHONY_LOGE("Write descriptor token fail!");
491 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
492 }
493 if (!in.WriteInt32(item)) {
494 TELEPHONY_LOGE("Write item fail!");
495 return TELEPHONY_ERR_WRITE_DATA_FAIL;
496 }
497 if (!in.WriteInt32(value)) {
498 TELEPHONY_LOGE("Write value fail!");
499 return TELEPHONY_ERR_WRITE_DATA_FAIL;
500 }
501 return SendRequest(in, static_cast<int32_t>(ImsCallInterfaceCode::IMS_SET_IMS_CONFIG_INT));
502 }
503
GetImsConfig(ImsConfigItem item)504 int32_t ImsCallProxy::GetImsConfig(ImsConfigItem item)
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(item)) {
512 TELEPHONY_LOGE("Write item fail!");
513 return TELEPHONY_ERR_WRITE_DATA_FAIL;
514 }
515 return SendRequest(in, static_cast<int32_t>(ImsCallInterfaceCode::IMS_GET_IMS_CONFIG));
516 }
517
SetImsFeatureValue(FeatureType type,int32_t value)518 int32_t ImsCallProxy::SetImsFeatureValue(FeatureType type, int32_t value)
519 {
520 MessageParcel in;
521 if (!in.WriteInterfaceToken(ImsCallProxy::GetDescriptor())) {
522 TELEPHONY_LOGE("Write descriptor token fail!");
523 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
524 }
525 if (!in.WriteInt32(type)) {
526 TELEPHONY_LOGE("Write type fail!");
527 return TELEPHONY_ERR_WRITE_DATA_FAIL;
528 }
529 if (!in.WriteInt32(value)) {
530 TELEPHONY_LOGE("Write value fail!");
531 return TELEPHONY_ERR_WRITE_DATA_FAIL;
532 }
533 return SendRequest(in, static_cast<int32_t>(ImsCallInterfaceCode::IMS_SET_IMS_FEATURE));
534 }
535
GetImsFeatureValue(FeatureType type,int32_t & value)536 int32_t ImsCallProxy::GetImsFeatureValue(FeatureType type, int32_t &value)
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.WriteInt32(type)) {
544 TELEPHONY_LOGE("Write type fail!");
545 return TELEPHONY_ERR_WRITE_DATA_FAIL;
546 }
547 return SendRequest(in, static_cast<int32_t>(ImsCallInterfaceCode::IMS_GET_IMS_FEATURE));
548 }
549
SetMute(int32_t slotId,int32_t mute)550 int32_t ImsCallProxy::SetMute(int32_t slotId, int32_t mute)
551 {
552 MessageParcel in;
553 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
554 if (ret != TELEPHONY_SUCCESS) {
555 return ret;
556 }
557 if (!in.WriteInt32(mute)) {
558 TELEPHONY_LOGE("[slot%{public}d]Write mute fail!", slotId);
559 return TELEPHONY_ERR_WRITE_DATA_FAIL;
560 }
561 return SendRequest(slotId, in, static_cast<int32_t>(ImsCallInterfaceCode::IMS_SET_MUTE));
562 }
563
GetMute(int32_t slotId)564 int32_t ImsCallProxy::GetMute(int32_t slotId)
565 {
566 MessageParcel in;
567 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
568 if (ret != TELEPHONY_SUCCESS) {
569 return ret;
570 }
571 return SendRequest(slotId, in, static_cast<int32_t>(ImsCallInterfaceCode::IMS_GET_MUTE));
572 }
573
ControlCamera(int32_t slotId,int32_t callIndex,const std::string & cameraId)574 int32_t ImsCallProxy::ControlCamera(int32_t slotId, int32_t callIndex, const std::string &cameraId)
575 {
576 MessageParcel in;
577 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
578 if (ret != TELEPHONY_SUCCESS) {
579 return ret;
580 }
581 if (!in.WriteInt32(callIndex)) {
582 TELEPHONY_LOGE("Write callIndex fail!");
583 return TELEPHONY_ERR_WRITE_DATA_FAIL;
584 }
585 if (!in.WriteString(cameraId)) {
586 TELEPHONY_LOGE("Write cameraId fail!");
587 return TELEPHONY_ERR_WRITE_DATA_FAIL;
588 }
589 return SendRequest(slotId, in, static_cast<int32_t>(ImsCallInterfaceCode::IMS_CTRL_CAMERA));
590 }
591
SetPreviewWindow(int32_t slotId,int32_t callIndex,const std::string & surfaceID,sptr<Surface> surface)592 int32_t ImsCallProxy::SetPreviewWindow(
593 int32_t slotId, int32_t callIndex, const std::string &surfaceID, sptr<Surface> surface)
594 {
595 MessageParcel in;
596 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
597 if (ret != TELEPHONY_SUCCESS) {
598 return ret;
599 }
600 if (!in.WriteInt32(callIndex)) {
601 TELEPHONY_LOGE("Write callIndex fail!");
602 return TELEPHONY_ERR_WRITE_DATA_FAIL;
603 }
604 if (!in.WriteString(surfaceID)) {
605 TELEPHONY_LOGE("Write surface id fail!");
606 return TELEPHONY_ERR_WRITE_DATA_FAIL;
607 }
608 if (surface != nullptr) {
609 sptr<IBufferProducer> producer = surface->GetProducer();
610 if (producer != nullptr) {
611 in.WriteRemoteObject(producer->AsObject());
612 }
613 }
614 return SendRequest(slotId, in, static_cast<int32_t>(ImsCallInterfaceCode::IMS_SET_PREVIEW_WINDOW));
615 }
616
SetDisplayWindow(int32_t slotId,int32_t callIndex,const std::string & surfaceID,sptr<Surface> surface)617 int32_t ImsCallProxy::SetDisplayWindow(
618 int32_t slotId, int32_t callIndex, const std::string &surfaceID, sptr<Surface> surface)
619 {
620 MessageParcel in;
621 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
622 if (ret != TELEPHONY_SUCCESS) {
623 return ret;
624 }
625 if (!in.WriteInt32(callIndex)) {
626 TELEPHONY_LOGE("Write callIndex fail!");
627 return TELEPHONY_ERR_WRITE_DATA_FAIL;
628 }
629 if (!in.WriteString(surfaceID)) {
630 TELEPHONY_LOGE("Write surface id fail!");
631 return TELEPHONY_ERR_WRITE_DATA_FAIL;
632 }
633 if (surface != nullptr) {
634 sptr<IBufferProducer> producer = surface->GetProducer();
635 if (producer != nullptr) {
636 in.WriteRemoteObject(producer->AsObject());
637 }
638 }
639 return SendRequest(slotId, in, static_cast<int32_t>(ImsCallInterfaceCode::IMS_SET_DISPLAY_WINDOW));
640 }
641
SetCameraZoom(float zoomRatio)642 int32_t ImsCallProxy::SetCameraZoom(float zoomRatio)
643 {
644 MessageParcel in;
645 if (!in.WriteInterfaceToken(ImsCallProxy::GetDescriptor())) {
646 TELEPHONY_LOGE("Write descriptor token fail!");
647 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
648 }
649 if (!in.WriteFloat(zoomRatio)) {
650 TELEPHONY_LOGE("Write zoomRatio fail!");
651 return TELEPHONY_ERR_WRITE_DATA_FAIL;
652 }
653 return SendRequest(in, static_cast<int32_t>(ImsCallInterfaceCode::IMS_SET_CAMERA_ZOOM));
654 }
655
SetPausePicture(int32_t slotId,int32_t callIndex,const std::string & path)656 int32_t ImsCallProxy::SetPausePicture(int32_t slotId, int32_t callIndex, const std::string &path)
657 {
658 MessageParcel in;
659 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
660 if (ret != TELEPHONY_SUCCESS) {
661 return ret;
662 }
663 if (!in.WriteInt32(callIndex)) {
664 TELEPHONY_LOGE("Write callIndex fail!");
665 return TELEPHONY_ERR_WRITE_DATA_FAIL;
666 }
667 if (!in.WriteString(path)) {
668 TELEPHONY_LOGE("Write path fail!");
669 return TELEPHONY_ERR_WRITE_DATA_FAIL;
670 }
671 return SendRequest(slotId, in, static_cast<int32_t>(ImsCallInterfaceCode::IMS_SET_PAUSE_IMAGE));
672 }
673
SetDeviceDirection(int32_t slotId,int32_t callIndex,int32_t rotation)674 int32_t ImsCallProxy::SetDeviceDirection(int32_t slotId, int32_t callIndex, int32_t rotation)
675 {
676 MessageParcel in;
677 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
678 if (ret != TELEPHONY_SUCCESS) {
679 return ret;
680 }
681 if (!in.WriteInt32(callIndex)) {
682 TELEPHONY_LOGE("Write callIndex fail!");
683 return TELEPHONY_ERR_WRITE_DATA_FAIL;
684 }
685 if (!in.WriteInt32(rotation)) {
686 TELEPHONY_LOGE("Write rotation fail!");
687 return TELEPHONY_ERR_WRITE_DATA_FAIL;
688 }
689 return SendRequest(slotId, in, static_cast<int32_t>(ImsCallInterfaceCode::IMS_SET_DEVICE_DIRECTION));
690 }
691
SetClip(int32_t slotId,int32_t action,int32_t index)692 int32_t ImsCallProxy::SetClip(int32_t slotId, int32_t action, int32_t index)
693 {
694 MessageParcel in;
695 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
696 if (ret != TELEPHONY_SUCCESS) {
697 return ret;
698 }
699 if (!in.WriteInt32(action)) {
700 TELEPHONY_LOGE("[slot%{public}d]Write action fail!", slotId);
701 return TELEPHONY_ERR_WRITE_DATA_FAIL;
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_SET_CLIP));
708 }
709
GetClip(int32_t slotId,int32_t index)710 int32_t ImsCallProxy::GetClip(int32_t slotId, 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(index)) {
718 TELEPHONY_LOGE("[slot%{public}d]Write index fail!", slotId);
719 return TELEPHONY_ERR_WRITE_DATA_FAIL;
720 }
721 return SendRequest(slotId, in, static_cast<int32_t>(ImsCallInterfaceCode::IMS_GET_CLIP));
722 }
723
SetClir(int32_t slotId,int32_t action,int32_t index)724 int32_t ImsCallProxy::SetClir(int32_t slotId, int32_t action, int32_t index)
725 {
726 MessageParcel in;
727 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
728 if (ret != TELEPHONY_SUCCESS) {
729 return ret;
730 }
731 if (!in.WriteInt32(action)) {
732 TELEPHONY_LOGE("[slot%{public}d]Write action fail!", slotId);
733 return TELEPHONY_ERR_WRITE_DATA_FAIL;
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_SET_CLIR));
740 }
741
GetClir(int32_t slotId,int32_t index)742 int32_t ImsCallProxy::GetClir(int32_t slotId, 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.WriteInt32(index)) {
750 TELEPHONY_LOGE("[slot%{public}d]Write index fail!", slotId);
751 return TELEPHONY_ERR_WRITE_DATA_FAIL;
752 }
753 return SendRequest(slotId, in, static_cast<int32_t>(ImsCallInterfaceCode::IMS_GET_CLIR));
754 }
755
SetCallTransfer(int32_t slotId,const CallTransferInfo & cfInfo,int32_t classType,int32_t index)756 int32_t ImsCallProxy::SetCallTransfer(int32_t slotId, const CallTransferInfo &cfInfo, int32_t classType, int32_t index)
757 {
758 MessageParcel in;
759 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
760 if (ret != TELEPHONY_SUCCESS) {
761 return ret;
762 }
763 if (!in.WriteRawData((const void *)&cfInfo, sizeof(CallTransferInfo))) {
764 TELEPHONY_LOGE("[slot%{public}d]Write cfInfo fail!", slotId);
765 return TELEPHONY_ERR_WRITE_DATA_FAIL;
766 }
767 if (!in.WriteInt32(classType)) {
768 TELEPHONY_LOGE("[slot%{public}d]Write classType fail!", slotId);
769 return TELEPHONY_ERR_WRITE_DATA_FAIL;
770 }
771 if (!in.WriteInt32(index)) {
772 TELEPHONY_LOGE("[slot%{public}d]Write index fail!", slotId);
773 return TELEPHONY_ERR_WRITE_DATA_FAIL;
774 }
775 return SendRequest(slotId, in, static_cast<int32_t>(ImsCallInterfaceCode::IMS_SET_CALL_TRANSFER));
776 }
777
CanSetCallTransferTime(int32_t slotId,bool & result)778 int32_t ImsCallProxy::CanSetCallTransferTime(int32_t slotId, bool &result)
779 {
780 MessageParcel in;
781 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
782 if (ret != TELEPHONY_SUCCESS) {
783 return ret;
784 }
785 if (!in.WriteBool(result)) {
786 TELEPHONY_LOGE("[slot%{public}d]Write classType fail!", slotId);
787 return TELEPHONY_ERR_WRITE_DATA_FAIL;
788 }
789 MessageParcel out;
790 MessageOption option;
791
792 sptr<IRemoteObject> remote = Remote();
793 if (remote == nullptr) {
794 TELEPHONY_LOGE("[slot%{public}d]Remote is null", slotId);
795 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
796 }
797
798 int32_t error = remote->SendRequest(static_cast<int32_t>(ImsCallInterfaceCode::IMS_CAN_SET_CALL_TRANSFER_TIME), in,
799 out, option);
800 if (error == ERR_NONE) {
801 result = out.ReadBool();
802 return out.ReadInt32();
803 }
804 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
805 }
806
GetCallTransfer(int32_t slotId,int32_t reason,int32_t index)807 int32_t ImsCallProxy::GetCallTransfer(int32_t slotId, int32_t reason, int32_t index)
808 {
809 MessageParcel in;
810 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
811 if (ret != TELEPHONY_SUCCESS) {
812 return ret;
813 }
814 if (!in.WriteInt32(reason)) {
815 TELEPHONY_LOGE("[slot%{public}d]Write reason fail!", slotId);
816 return TELEPHONY_ERR_WRITE_DATA_FAIL;
817 }
818 if (!in.WriteInt32(index)) {
819 TELEPHONY_LOGE("[slot%{public}d]Write index fail!", slotId);
820 return TELEPHONY_ERR_WRITE_DATA_FAIL;
821 }
822 return SendRequest(slotId, in, static_cast<int32_t>(ImsCallInterfaceCode::IMS_GET_CALL_TRANSFER));
823 }
824
SetCallRestriction(int32_t slotId,const std::string & fac,int32_t mode,const std::string & pw,int32_t index)825 int32_t ImsCallProxy::SetCallRestriction(
826 int32_t slotId, const std::string &fac, int32_t mode, const std::string &pw, int32_t index)
827 {
828 MessageParcel in;
829 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
830 if (ret != TELEPHONY_SUCCESS) {
831 return ret;
832 }
833 if (!in.WriteString(fac)) {
834 TELEPHONY_LOGE("[slot%{public}d]Write fac fail!", slotId);
835 return TELEPHONY_ERR_WRITE_DATA_FAIL;
836 }
837 if (!in.WriteInt32(mode)) {
838 TELEPHONY_LOGE("[slot%{public}d]Write mode fail!", slotId);
839 return TELEPHONY_ERR_WRITE_DATA_FAIL;
840 }
841 if (!in.WriteString(pw)) {
842 TELEPHONY_LOGE("[slot%{public}d]Write pw fail!", slotId);
843 return TELEPHONY_ERR_WRITE_DATA_FAIL;
844 }
845 if (!in.WriteInt32(index)) {
846 TELEPHONY_LOGE("[slot%{public}d]Write index fail!", slotId);
847 return TELEPHONY_ERR_WRITE_DATA_FAIL;
848 }
849 return SendRequest(slotId, in, static_cast<int32_t>(ImsCallInterfaceCode::IMS_SET_CALL_RESTRICTION));
850 }
851
GetCallRestriction(int32_t slotId,const std::string & fac,int32_t index)852 int32_t ImsCallProxy::GetCallRestriction(int32_t slotId, const std::string &fac, int32_t index)
853 {
854 MessageParcel in;
855 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
856 if (ret != TELEPHONY_SUCCESS) {
857 return ret;
858 }
859 if (!in.WriteString(fac)) {
860 TELEPHONY_LOGE("[slot%{public}d]Write fac fail!", slotId);
861 return TELEPHONY_ERR_WRITE_DATA_FAIL;
862 }
863 if (!in.WriteInt32(index)) {
864 TELEPHONY_LOGE("[slot%{public}d]Write index fail!", slotId);
865 return TELEPHONY_ERR_WRITE_DATA_FAIL;
866 }
867 return SendRequest(slotId, in, static_cast<int32_t>(ImsCallInterfaceCode::IMS_GET_CALL_RESTRICTION));
868 }
869
SetCallWaiting(int32_t slotId,bool activate,int32_t classType,int32_t index)870 int32_t ImsCallProxy::SetCallWaiting(int32_t slotId, bool activate, int32_t classType, int32_t index)
871 {
872 MessageParcel in;
873 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
874 if (ret != TELEPHONY_SUCCESS) {
875 return ret;
876 }
877 if (!in.WriteBool(activate)) {
878 TELEPHONY_LOGE("[slot%{public}d]Write activate fail!", slotId);
879 return TELEPHONY_ERR_WRITE_DATA_FAIL;
880 }
881 if (!in.WriteInt32(classType)) {
882 TELEPHONY_LOGE("[slot%{public}d]Write classType fail!", slotId);
883 return TELEPHONY_ERR_WRITE_DATA_FAIL;
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_SET_CALL_WAITING));
890 }
891
SetVideoCallWaiting(int32_t slotId,bool activate)892 int32_t ImsCallProxy::SetVideoCallWaiting(int32_t slotId, bool activate)
893 {
894 MessageParcel in;
895 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
896 if (ret != TELEPHONY_SUCCESS) {
897 return ret;
898 }
899 if (!in.WriteBool(activate)) {
900 TELEPHONY_LOGE("[slot%{public}d]Write activate fail!", slotId);
901 return TELEPHONY_ERR_WRITE_DATA_FAIL;
902 }
903 return SendRequest(slotId, in, static_cast<int32_t>(ImsCallInterfaceCode::IMS_SET_VIDEO_CALL_WAITING));
904 }
905
GetCallWaiting(int32_t slotId,int32_t index)906 int32_t ImsCallProxy::GetCallWaiting(int32_t slotId, int32_t index)
907 {
908 MessageParcel in;
909 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
910 if (ret != TELEPHONY_SUCCESS) {
911 return ret;
912 }
913 if (!in.WriteInt32(index)) {
914 TELEPHONY_LOGE("[slot%{public}d]Write index fail!", slotId);
915 return TELEPHONY_ERR_WRITE_DATA_FAIL;
916 }
917 return SendRequest(slotId, in, static_cast<int32_t>(ImsCallInterfaceCode::IMS_GET_CALL_WAITING));
918 }
919
SetColr(int32_t slotId,int32_t presentation,int32_t index)920 int32_t ImsCallProxy::SetColr(int32_t slotId, int32_t presentation, int32_t index)
921 {
922 MessageParcel in;
923 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
924 if (ret != TELEPHONY_SUCCESS) {
925 return ret;
926 }
927 if (!in.WriteInt32(presentation)) {
928 TELEPHONY_LOGE("[slot%{public}d]Write presentation fail!", slotId);
929 return TELEPHONY_ERR_WRITE_DATA_FAIL;
930 }
931 if (!in.WriteInt32(index)) {
932 TELEPHONY_LOGE("[slot%{public}d]Write index fail!", slotId);
933 return TELEPHONY_ERR_WRITE_DATA_FAIL;
934 }
935 return SendRequest(slotId, in, static_cast<int32_t>(ImsCallInterfaceCode::IMS_SET_COLR));
936 }
937
GetColr(int32_t slotId,int32_t index)938 int32_t ImsCallProxy::GetColr(int32_t slotId, int32_t index)
939 {
940 MessageParcel in;
941 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
942 if (ret != TELEPHONY_SUCCESS) {
943 return ret;
944 }
945 if (!in.WriteInt32(index)) {
946 TELEPHONY_LOGE("[slot%{public}d]Write index fail!", slotId);
947 return TELEPHONY_ERR_WRITE_DATA_FAIL;
948 }
949 return SendRequest(slotId, in, static_cast<int32_t>(ImsCallInterfaceCode::IMS_GET_COLR));
950 }
951
SetColp(int32_t slotId,int32_t action,int32_t index)952 int32_t ImsCallProxy::SetColp(int32_t slotId, int32_t action, int32_t index)
953 {
954 MessageParcel in;
955 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
956 if (ret != TELEPHONY_SUCCESS) {
957 return ret;
958 }
959 if (!in.WriteInt32(action)) {
960 TELEPHONY_LOGE("[slot%{public}d]Write action fail!", slotId);
961 return TELEPHONY_ERR_WRITE_DATA_FAIL;
962 }
963 if (!in.WriteInt32(index)) {
964 TELEPHONY_LOGE("[slot%{public}d]Write index fail!", slotId);
965 return TELEPHONY_ERR_WRITE_DATA_FAIL;
966 }
967 return SendRequest(slotId, in, static_cast<int32_t>(ImsCallInterfaceCode::IMS_SET_COLP));
968 }
969
GetColp(int32_t slotId,int32_t index)970 int32_t ImsCallProxy::GetColp(int32_t slotId, int32_t index)
971 {
972 MessageParcel in;
973 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
974 if (ret != TELEPHONY_SUCCESS) {
975 return ret;
976 }
977 if (!in.WriteInt32(index)) {
978 TELEPHONY_LOGE("[slot%{public}d]Write index fail!", slotId);
979 return TELEPHONY_ERR_WRITE_DATA_FAIL;
980 }
981 return SendRequest(slotId, in, static_cast<int32_t>(ImsCallInterfaceCode::IMS_GET_COLP));
982 }
983
RegisterImsCallCallback(const sptr<ImsCallCallbackInterface> & callback)984 int32_t ImsCallProxy::RegisterImsCallCallback(const sptr<ImsCallCallbackInterface> &callback)
985 {
986 if (callback == nullptr) {
987 TELEPHONY_LOGE("callback is null!");
988 return TELEPHONY_ERR_ARGUMENT_INVALID;
989 }
990 MessageParcel in;
991 if (!in.WriteInterfaceToken(ImsCallProxy::GetDescriptor())) {
992 TELEPHONY_LOGE("Write descriptor token fail!");
993 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
994 }
995 if (!in.WriteRemoteObject(callback->AsObject().GetRefPtr())) {
996 TELEPHONY_LOGE("Write ImsCallCallbackInterface fail!");
997 return TELEPHONY_ERR_WRITE_DATA_FAIL;
998 }
999 return SendRequest(in, static_cast<int32_t>(ImsCallInterfaceCode::IMS_CALL_REGISTER_CALLBACK));
1000 }
1001
UpdateImsCapabilities(int32_t slotId,const ImsCapabilityList & imsCapabilityList)1002 int32_t ImsCallProxy::UpdateImsCapabilities(int32_t slotId, const ImsCapabilityList &imsCapabilityList)
1003 {
1004 MessageParcel in;
1005 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
1006 if (ret != TELEPHONY_SUCCESS) {
1007 return ret;
1008 }
1009 int32_t imsCapabilitiesSize = static_cast<int32_t>(imsCapabilityList.imsCapabilities.size());
1010 if (!in.WriteInt32(imsCapabilitiesSize)) {
1011 return TELEPHONY_ERR_WRITE_DATA_FAIL;
1012 }
1013 for (auto imsCapability : imsCapabilityList.imsCapabilities) {
1014 if (!in.WriteInt32(static_cast<int32_t>(imsCapability.imsCapabilityType))) {
1015 TELEPHONY_LOGE("[slot%{public}d] Write imsCapabilityType fail!", slotId);
1016 return TELEPHONY_ERR_WRITE_DATA_FAIL;
1017 }
1018 if (!in.WriteInt32(static_cast<int32_t>(imsCapability.imsRadioTech))) {
1019 TELEPHONY_LOGE("[slot%{public}d] Write imsRadioTech fail!", slotId);
1020 return TELEPHONY_ERR_WRITE_DATA_FAIL;
1021 }
1022 if (!in.WriteBool(imsCapability.enable)) {
1023 TELEPHONY_LOGE("[slot%{public}d] Write enable fail!", slotId);
1024 return TELEPHONY_ERR_WRITE_DATA_FAIL;
1025 }
1026 }
1027 return SendRequest(slotId, in, static_cast<int32_t>(ImsCallInterfaceCode::IMS_UPDATE_CAPABILITY));
1028 }
1029
GetUtImpuFromNetwork(int32_t slotId,std::string & impu)1030 int32_t ImsCallProxy::GetUtImpuFromNetwork(int32_t slotId, std::string &impu)
1031 {
1032 MessageParcel in;
1033 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
1034 if (ret != TELEPHONY_SUCCESS) {
1035 return ret;
1036 }
1037 if (!in.WriteString(impu)) {
1038 TELEPHONY_LOGE("[slot%{public}d]Write impu fail!", slotId);
1039 return TELEPHONY_ERR_WRITE_DATA_FAIL;
1040 }
1041 return SendRequest(slotId, in, static_cast<int32_t>(ImsCallInterfaceCode::IMS_GET_IMPU_FROM_NETWORK));
1042 }
1043
NotifyOperatorConfigChanged(int32_t slotId,int32_t state)1044 int32_t ImsCallProxy::NotifyOperatorConfigChanged(int32_t slotId, int32_t state)
1045 {
1046 MessageParcel in;
1047 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
1048 if (ret != TELEPHONY_SUCCESS) {
1049 return ret;
1050 }
1051 if (!in.WriteInt32(state)) {
1052 TELEPHONY_LOGE("[slot%{public}d]Write state fail!", slotId);
1053 return TELEPHONY_ERR_WRITE_DATA_FAIL;
1054 }
1055 return SendRequest(slotId, in, static_cast<int32_t>(ImsCallInterfaceCode::IMS_OPERATOR_CONFIG_CHANGED));
1056 }
1057
WriteCommonInfo(int32_t slotId,std::string funcName,MessageParcel & in)1058 int32_t ImsCallProxy::WriteCommonInfo(int32_t slotId, std::string funcName, MessageParcel &in)
1059 {
1060 if (!in.WriteInterfaceToken(ImsCallProxy::GetDescriptor())) {
1061 TELEPHONY_LOGE("[slot%{public}d] %{public}s Write descriptor token fail!", slotId, funcName.c_str());
1062 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1063 }
1064 if (!in.WriteInt32(slotId)) {
1065 TELEPHONY_LOGE("[slot%{public}d] %{public}s Write slotId fail!", slotId, funcName.c_str());
1066 return TELEPHONY_ERR_WRITE_DATA_FAIL;
1067 }
1068 return TELEPHONY_SUCCESS;
1069 }
1070
WriteCommonInfo(int32_t slotId,std::string funcName,MessageParcel & in,int32_t callType)1071 int32_t ImsCallProxy::WriteCommonInfo(int32_t slotId, std::string funcName, MessageParcel &in, int32_t callType)
1072 {
1073 int32_t ret = WriteCommonInfo(slotId, funcName, in);
1074 if (ret != TELEPHONY_SUCCESS) {
1075 return ret;
1076 }
1077 if (!in.WriteInt32(callType)) {
1078 TELEPHONY_LOGE("[slot%{public}d] %{public}s Write callType fail!", slotId, funcName.c_str());
1079 return TELEPHONY_ERR_WRITE_DATA_FAIL;
1080 }
1081 return TELEPHONY_SUCCESS;
1082 }
1083
SendRequest(MessageParcel & in,int32_t eventId)1084 int32_t ImsCallProxy::SendRequest(MessageParcel &in, int32_t eventId)
1085 {
1086 sptr<IRemoteObject> remote = Remote();
1087 if (remote == nullptr) {
1088 TELEPHONY_LOGE("Remote is null, eventId:%{public}d", eventId);
1089 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1090 }
1091
1092 MessageParcel out;
1093 MessageOption option;
1094 int32_t error = remote->SendRequest(eventId, in, out, option);
1095 if (error == ERR_NONE) {
1096 return out.ReadInt32();
1097 }
1098 TELEPHONY_LOGE("SendRequest fail, eventId:%{public}d, error:%{public}d", eventId, error);
1099 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1100 }
1101
SendRequest(int32_t slotId,MessageParcel & in,int32_t eventId)1102 int32_t ImsCallProxy::SendRequest(int32_t slotId, MessageParcel &in, int32_t eventId)
1103 {
1104 sptr<IRemoteObject> remote = Remote();
1105 if (remote == nullptr) {
1106 TELEPHONY_LOGE("[slot%{public}d]Remote is null, eventId:%{public}d", slotId, eventId);
1107 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1108 }
1109
1110 MessageParcel out;
1111 MessageOption option;
1112 int32_t error = remote->SendRequest(eventId, in, out, option);
1113 if (error == ERR_NONE) {
1114 return out.ReadInt32();
1115 }
1116 TELEPHONY_LOGE("[slot%{public}d]SendRequest fail, eventId:%{public}d, error:%{public}d", slotId, eventId, error);
1117 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1118 }
1119
GetImsCapabilities(int32_t slotId)1120 int32_t ImsCallProxy::GetImsCapabilities(int32_t slotId)
1121 {
1122 MessageParcel in;
1123 int32_t ret = WriteCommonInfo(slotId, __FUNCTION__, in);
1124 if (ret != TELEPHONY_SUCCESS) {
1125 return ret;
1126 }
1127 return SendRequest(slotId, in, static_cast<int32_t>(ImsCallInterfaceCode::IMS_GET_IMS_CAPABILITY));
1128 }
1129 } // namespace Telephony
1130 } // namespace OHOS
1131