1 /*
2 * Copyright (C) 2021-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 "call_manager_service_proxy.h"
17
18 #include "call_manager_errors.h"
19 #include "message_option.h"
20 #include "message_parcel.h"
21
22 namespace OHOS {
23 namespace Telephony {
CallManagerServiceProxy(const sptr<IRemoteObject> & impl)24 CallManagerServiceProxy::CallManagerServiceProxy(const sptr<IRemoteObject> &impl)
25 : IRemoteProxy<ICallManagerService>(impl)
26 {}
27
RegisterCallBack(const sptr<ICallAbilityCallback> & callback)28 int32_t CallManagerServiceProxy::RegisterCallBack(const sptr<ICallAbilityCallback> &callback)
29 {
30 MessageOption option;
31 MessageParcel dataParcel;
32 MessageParcel replyParcel;
33 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
34 TELEPHONY_LOGE("write descriptor fail");
35 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
36 }
37 dataParcel.WriteRemoteObject(callback->AsObject().GetRefPtr());
38 auto remote = Remote();
39 if (remote == nullptr) {
40 TELEPHONY_LOGE("function Remote() return nullptr!");
41 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
42 }
43 int32_t error = remote->SendRequest(INTERFACE_REGISTER_CALLBACK, dataParcel, replyParcel, option);
44 if (error != TELEPHONY_SUCCESS) {
45 TELEPHONY_LOGE("Function RegisterCallBack! errCode:%{public}d", error);
46 return error;
47 }
48 return replyParcel.ReadInt32();
49 }
50
UnRegisterCallBack()51 int32_t CallManagerServiceProxy::UnRegisterCallBack()
52 {
53 MessageOption option;
54 MessageParcel dataParcel;
55 MessageParcel replyParcel;
56 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
57 TELEPHONY_LOGE("write descriptor fail");
58 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
59 }
60 auto remote = Remote();
61 if (remote == nullptr) {
62 TELEPHONY_LOGE("function Remote() return nullptr!");
63 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
64 }
65 int32_t error = remote->SendRequest(INTERFACE_UNREGISTER_CALLBACK, dataParcel, replyParcel, option);
66 if (error != TELEPHONY_SUCCESS) {
67 TELEPHONY_LOGE("Function RegisterCallBack! errCode:%{public}d", error);
68 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
69 }
70 return replyParcel.ReadInt32();
71 }
72
DialCall(std::u16string number,AppExecFwk::PacMap & extras)73 int32_t CallManagerServiceProxy::DialCall(std::u16string number, AppExecFwk::PacMap &extras)
74 {
75 MessageOption option;
76 MessageParcel dataParcel;
77 MessageParcel replyParcel;
78 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
79 TELEPHONY_LOGE("write descriptor fail");
80 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
81 }
82 if (number.empty()) {
83 TELEPHONY_LOGE("number is empty");
84 return TELEPHONY_ERR_ARGUMENT_INVALID;
85 }
86 dataParcel.WriteString16(number);
87 dataParcel.WriteInt32(extras.GetIntValue("accountId"));
88 dataParcel.WriteInt32(extras.GetIntValue("videoState"));
89 dataParcel.WriteInt32(extras.GetIntValue("dialScene"));
90 dataParcel.WriteInt32(extras.GetIntValue("dialType"));
91 dataParcel.WriteInt32(extras.GetIntValue("callType"));
92 auto remote = Remote();
93 if (remote == nullptr) {
94 TELEPHONY_LOGE("function Remote() return nullptr!");
95 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
96 }
97 int32_t error = remote->SendRequest(INTERFACE_DIAL_CALL, dataParcel, replyParcel, option);
98 if (error != TELEPHONY_SUCCESS) {
99 TELEPHONY_LOGE("function DialCall call failed! errCode:%{public}d", error);
100 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
101 }
102 return replyParcel.ReadInt32();
103 }
104
AnswerCall(int32_t callId,int32_t videoState)105 int32_t CallManagerServiceProxy::AnswerCall(int32_t callId, int32_t videoState)
106 {
107 MessageOption option;
108 MessageParcel dataParcel;
109 MessageParcel replyParcel;
110 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
111 TELEPHONY_LOGE("write descriptor fail");
112 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
113 }
114 dataParcel.WriteInt32(callId);
115 dataParcel.WriteInt32(videoState);
116 auto remote = Remote();
117 if (remote == nullptr) {
118 TELEPHONY_LOGE("function Remote() return nullptr!");
119 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
120 }
121 int32_t error = remote->SendRequest(INTERFACE_ANSWER_CALL, dataParcel, replyParcel, option);
122 if (error != TELEPHONY_SUCCESS) {
123 TELEPHONY_LOGE("function AnswerCall call failed! errCode:%{public}d", error);
124 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
125 }
126 return replyParcel.ReadInt32();
127 }
128
RejectCall(int32_t callId,bool rejectWithMessage,std::u16string textMessage)129 int32_t CallManagerServiceProxy::RejectCall(int32_t callId, bool rejectWithMessage, std::u16string textMessage)
130 {
131 MessageOption option;
132 MessageParcel dataParcel;
133 MessageParcel replyParcel;
134 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
135 TELEPHONY_LOGE("write descriptor fail");
136 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
137 }
138 dataParcel.WriteInt32(callId);
139 dataParcel.WriteBool(rejectWithMessage);
140 dataParcel.WriteString16(textMessage);
141 auto remote = Remote();
142 if (remote == nullptr) {
143 TELEPHONY_LOGE("function Remote() return nullptr!");
144 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
145 }
146 int32_t error = remote->SendRequest(INTERFACE_REJECT_CALL, dataParcel, replyParcel, option);
147 if (error != TELEPHONY_SUCCESS) {
148 TELEPHONY_LOGE("function RejectCall call failed! errCode:%{public}d", error);
149 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
150 }
151 return replyParcel.ReadInt32();
152 }
153
HangUpCall(int32_t callId)154 int32_t CallManagerServiceProxy::HangUpCall(int32_t callId)
155 {
156 MessageOption option;
157 MessageParcel dataParcel;
158 MessageParcel replyParcel;
159 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
160 TELEPHONY_LOGE("write descriptor fail");
161 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
162 }
163 dataParcel.WriteInt32(callId);
164 auto remote = Remote();
165 if (remote == nullptr) {
166 TELEPHONY_LOGE("function Remote() return nullptr!");
167 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
168 }
169 int32_t error = remote->SendRequest(INTERFACE_DISCONNECT_CALL, dataParcel, replyParcel, option);
170 if (error != TELEPHONY_SUCCESS) {
171 TELEPHONY_LOGE("function HangUpCall call failed! errCode:%{public}d", error);
172 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
173 }
174 return replyParcel.ReadInt32();
175 }
176
GetCallState()177 int32_t CallManagerServiceProxy::GetCallState()
178 {
179 MessageOption option;
180 MessageParcel dataParcel;
181 MessageParcel replyParcel;
182 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
183 TELEPHONY_LOGE("write descriptor fail");
184 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
185 }
186 auto remote = Remote();
187 if (remote == nullptr) {
188 TELEPHONY_LOGE("function Remote() return nullptr!");
189 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
190 }
191 int32_t error = remote->SendRequest(INTERFACE_GET_CALL_STATE, dataParcel, replyParcel, option);
192 if (error != TELEPHONY_SUCCESS) {
193 TELEPHONY_LOGE("function GetCallState! errCode:%{public}d", error);
194 return error;
195 }
196 return replyParcel.ReadInt32();
197 }
198
HoldCall(int32_t callId)199 int32_t CallManagerServiceProxy::HoldCall(int32_t callId)
200 {
201 MessageOption option;
202 MessageParcel dataParcel;
203 MessageParcel replyParcel;
204 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
205 TELEPHONY_LOGE("write descriptor fail");
206 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
207 }
208 dataParcel.WriteInt32(callId);
209 auto remote = Remote();
210 if (remote == nullptr) {
211 TELEPHONY_LOGE("function Remote() return nullptr!");
212 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
213 }
214 int32_t error = remote->SendRequest(INTERFACE_HOLD_CALL, dataParcel, replyParcel, option);
215 if (error != TELEPHONY_SUCCESS) {
216 TELEPHONY_LOGE("Function HoldCall call failed! errCode:%{public}d", error);
217 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
218 }
219 return replyParcel.ReadInt32();
220 }
221
UnHoldCall(int32_t callId)222 int32_t CallManagerServiceProxy::UnHoldCall(int32_t callId)
223 {
224 MessageOption option;
225 MessageParcel dataParcel;
226 MessageParcel replyParcel;
227 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
228 TELEPHONY_LOGE("write descriptor fail");
229 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
230 }
231 dataParcel.WriteInt32(callId);
232 auto remote = Remote();
233 if (remote == nullptr) {
234 TELEPHONY_LOGE("function Remote() return nullptr!");
235 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
236 }
237 int32_t error = remote->SendRequest(INTERFACE_UNHOLD_CALL, dataParcel, replyParcel, option);
238 if (error != TELEPHONY_SUCCESS) {
239 TELEPHONY_LOGE("Function UnHoldCall call failed! errCode:%{public}d", error);
240 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
241 }
242 return replyParcel.ReadInt32();
243 }
244
SwitchCall(int32_t callId)245 int32_t CallManagerServiceProxy::SwitchCall(int32_t callId)
246 {
247 MessageOption option;
248 MessageParcel dataParcel;
249 MessageParcel replyParcel;
250 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
251 TELEPHONY_LOGE("write descriptor fail");
252 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
253 }
254 dataParcel.WriteInt32(callId);
255 auto remote = Remote();
256 if (remote == nullptr) {
257 TELEPHONY_LOGE("function Remote() return nullptr!");
258 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
259 }
260 int32_t error = remote->SendRequest(INTERFACE_SWAP_CALL, dataParcel, replyParcel, option);
261 if (error != TELEPHONY_SUCCESS) {
262 TELEPHONY_LOGE("Function UnHoldCall call failed! errCode:%{public}d", error);
263 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
264 }
265 return replyParcel.ReadInt32();
266 }
267
HasCall()268 bool CallManagerServiceProxy::HasCall()
269 {
270 MessageOption option;
271 MessageParcel dataParcel;
272 MessageParcel replyParcel;
273 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
274 TELEPHONY_LOGE("write descriptor fail");
275 return false;
276 }
277 auto remote = Remote();
278 if (remote == nullptr) {
279 TELEPHONY_LOGE("function Remote() return nullptr!");
280 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
281 }
282 int32_t error = remote->SendRequest(INTERFACE_HAS_CALL, dataParcel, replyParcel, option);
283 if (error != TELEPHONY_SUCCESS) {
284 TELEPHONY_LOGE("Function HasCall! errCode:%{public}d", error);
285 return false;
286 }
287 return replyParcel.ReadBool();
288 }
289
IsNewCallAllowed(bool & enabled)290 int32_t CallManagerServiceProxy::IsNewCallAllowed(bool &enabled)
291 {
292 MessageOption option;
293 MessageParcel dataParcel;
294 MessageParcel replyParcel;
295 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
296 TELEPHONY_LOGE("write descriptor fail");
297 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
298 }
299 auto remote = Remote();
300 if (remote == nullptr) {
301 TELEPHONY_LOGE("function Remote() return nullptr!");
302 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
303 }
304 int32_t error = remote->SendRequest(INTERFACE_IS_NEW_CALL_ALLOWED, dataParcel, replyParcel, option);
305 if (error != TELEPHONY_SUCCESS) {
306 TELEPHONY_LOGE("Function IsNewCallAllowed! errCode:%{public}d", error);
307 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
308 }
309 int32_t result = replyParcel.ReadInt32();
310 if (result == TELEPHONY_ERR_SUCCESS) {
311 enabled = replyParcel.ReadBool();
312 }
313 return result;
314 }
315
SetMuted(bool isMute)316 int32_t CallManagerServiceProxy::SetMuted(bool isMute)
317 {
318 MessageOption option;
319 MessageParcel dataParcel;
320 MessageParcel replyParcel;
321 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
322 TELEPHONY_LOGE("write descriptor fail");
323 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
324 }
325 dataParcel.WriteBool(isMute);
326 auto remote = Remote();
327 if (remote == nullptr) {
328 TELEPHONY_LOGE("function Remote() return nullptr!");
329 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
330 }
331 int32_t error = remote->SendRequest(INTERFACE_SET_MUTE, dataParcel, replyParcel, option);
332 if (error != TELEPHONY_SUCCESS) {
333 TELEPHONY_LOGE("function SetMute failed! errCode:%{public}d", error);
334 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
335 }
336 return replyParcel.ReadInt32();
337 }
338
MuteRinger()339 int32_t CallManagerServiceProxy::MuteRinger()
340 {
341 MessageOption option;
342 MessageParcel dataParcel;
343 MessageParcel replyParcel;
344 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
345 TELEPHONY_LOGE("write descriptor fail");
346 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
347 }
348 auto remote = Remote();
349 if (remote == nullptr) {
350 TELEPHONY_LOGE("function Remote() return nullptr!");
351 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
352 }
353 int32_t error = remote->SendRequest(INTERFACE_MUTE_RINGER, dataParcel, replyParcel, option);
354 if (error != TELEPHONY_SUCCESS) {
355 TELEPHONY_LOGE("function MuteRinger failed! errCode:%{public}d", error);
356 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
357 }
358 return replyParcel.ReadInt32();
359 }
360
SetAudioDevice(const AudioDevice & audioDevice)361 int32_t CallManagerServiceProxy::SetAudioDevice(const AudioDevice &audioDevice)
362 {
363 MessageOption option;
364 MessageParcel dataParcel;
365 MessageParcel replyParcel;
366 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
367 TELEPHONY_LOGE("write descriptor fail");
368 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
369 }
370 dataParcel.WriteRawData((const void *)&audioDevice, sizeof(AudioDevice));
371 auto remote = Remote();
372 if (remote == nullptr) {
373 TELEPHONY_LOGE("function Remote() return nullptr!");
374 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
375 }
376 int32_t error = remote->SendRequest(INTERFACE_SET_AUDIO_DEVICE, dataParcel, replyParcel, option);
377 if (error != TELEPHONY_SUCCESS) {
378 TELEPHONY_LOGE("function SetAudioDevice failed! errCode:%{public}d", error);
379 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
380 }
381 return replyParcel.ReadInt32();
382 }
383
IsRinging(bool & enabled)384 int32_t CallManagerServiceProxy::IsRinging(bool &enabled)
385 {
386 MessageOption option;
387 MessageParcel dataParcel;
388 MessageParcel replyParcel;
389 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
390 TELEPHONY_LOGE("write descriptor fail");
391 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
392 }
393 auto remote = Remote();
394 if (remote == nullptr) {
395 TELEPHONY_LOGE("function Remote() return nullptr!");
396 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
397 }
398 int32_t error = remote->SendRequest(INTERFACE_IS_RINGING, dataParcel, replyParcel, option);
399 if (error != TELEPHONY_SUCCESS) {
400 TELEPHONY_LOGE("function IsRinging errCode:%{public}d", error);
401 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
402 }
403 int32_t result = replyParcel.ReadInt32();
404 if (result == TELEPHONY_ERR_SUCCESS) {
405 enabled = replyParcel.ReadBool();
406 }
407 return result;
408 }
409
IsInEmergencyCall(bool & enabled)410 int32_t CallManagerServiceProxy::IsInEmergencyCall(bool &enabled)
411 {
412 MessageOption option;
413 MessageParcel dataParcel;
414 MessageParcel replyParcel;
415 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
416 TELEPHONY_LOGE("write descriptor fail");
417 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
418 }
419 auto remote = Remote();
420 if (remote == nullptr) {
421 TELEPHONY_LOGE("function Remote() return nullptr!");
422 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
423 }
424 int32_t error = remote->SendRequest(INTERFACE_IS_EMERGENCY_CALL, dataParcel, replyParcel, option);
425 if (error != TELEPHONY_SUCCESS) {
426 TELEPHONY_LOGE("function IsInEmergencyCall errCode:%{public}d", error);
427 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
428 }
429 int32_t result = replyParcel.ReadInt32();
430 if (result == TELEPHONY_ERR_SUCCESS) {
431 enabled = replyParcel.ReadBool();
432 }
433 return result;
434 }
435
StartDtmf(int32_t callId,char str)436 int32_t CallManagerServiceProxy::StartDtmf(int32_t callId, char str)
437 {
438 MessageOption option;
439 MessageParcel dataParcel;
440 MessageParcel replyParcel;
441 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
442 TELEPHONY_LOGE("write descriptor fail");
443 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
444 }
445 auto remote = Remote();
446 if (remote == nullptr) {
447 TELEPHONY_LOGE("function Remote() return nullptr!");
448 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
449 }
450 dataParcel.WriteInt32(callId);
451 dataParcel.WriteInt8(str);
452 int32_t error =
453 remote->SendRequest(CallManagerInterfaceCode::INTERFACE_START_DTMF, dataParcel, replyParcel, option);
454 if (error != TELEPHONY_SUCCESS) {
455 TELEPHONY_LOGE("Function StartDtmf! errCode:%{public}d", error);
456 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
457 }
458 return replyParcel.ReadInt32();
459 }
460
StopDtmf(int32_t callId)461 int32_t CallManagerServiceProxy::StopDtmf(int32_t callId)
462 {
463 MessageOption option;
464 MessageParcel dataParcel;
465 MessageParcel replyParcel;
466 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
467 TELEPHONY_LOGE("write descriptor fail");
468 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
469 }
470 auto remote = Remote();
471 if (remote == nullptr) {
472 TELEPHONY_LOGE("function Remote() return nullptr!");
473 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
474 }
475 dataParcel.WriteInt32(callId);
476 int32_t error = remote->SendRequest(CallManagerInterfaceCode::INTERFACE_STOP_DTMF, dataParcel, replyParcel, option);
477 if (error != TELEPHONY_SUCCESS) {
478 TELEPHONY_LOGE("Function StopDtmf! errCode:%{public}d", error);
479 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
480 }
481 return replyParcel.ReadInt32();
482 }
483
PostDialProceed(int32_t callId,bool proceed)484 int32_t CallManagerServiceProxy::PostDialProceed(int32_t callId, bool proceed)
485 {
486 MessageOption option;
487 MessageParcel dataParcel;
488 MessageParcel replyParcel;
489 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
490 TELEPHONY_LOGE("WriteInterfaceToken fail");
491 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
492 }
493 auto remote = Remote();
494 if (remote == nullptr) {
495 TELEPHONY_LOGE("Remote() return nullptr!");
496 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
497 }
498 dataParcel.WriteInt32(callId);
499 dataParcel.WriteBool(proceed);
500 int32_t error =
501 remote->SendRequest(CallManagerInterfaceCode::INTERFACE_POST_DIAL_PROCEED, dataParcel, replyParcel, option);
502 if (error != TELEPHONY_SUCCESS) {
503 TELEPHONY_LOGE("Function PostDialProceed! errCode:%{public}d", error);
504 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
505 }
506 return replyParcel.ReadInt32();
507 }
508
GetCallWaiting(int32_t slotId)509 int32_t CallManagerServiceProxy::GetCallWaiting(int32_t slotId)
510 {
511 MessageOption option;
512 MessageParcel dataParcel;
513 MessageParcel replyParcel;
514 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
515 TELEPHONY_LOGE("write descriptor fail");
516 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
517 }
518 auto remote = Remote();
519 if (remote == nullptr) {
520 TELEPHONY_LOGE("function Remote() return nullptr!");
521 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
522 }
523 dataParcel.WriteInt32(slotId);
524 int32_t error =
525 remote->SendRequest(CallManagerInterfaceCode::INTERFACE_GET_CALL_WAITING, dataParcel, replyParcel, option);
526 if (error != TELEPHONY_SUCCESS) {
527 TELEPHONY_LOGE("Function GetCallWaiting! errCode:%{public}d", error);
528 return error;
529 }
530 return replyParcel.ReadInt32();
531 }
532
SetCallWaiting(int32_t slotId,bool activate)533 int32_t CallManagerServiceProxy::SetCallWaiting(int32_t slotId, bool activate)
534 {
535 MessageOption option;
536 MessageParcel dataParcel;
537 MessageParcel replyParcel;
538 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
539 TELEPHONY_LOGE("write descriptor fail");
540 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
541 }
542 auto remote = Remote();
543 if (remote == nullptr) {
544 TELEPHONY_LOGE("function Remote() return nullptr!");
545 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
546 }
547 dataParcel.WriteInt32(slotId);
548 dataParcel.WriteBool(activate);
549 int32_t error =
550 remote->SendRequest(CallManagerInterfaceCode::INTERFACE_SET_CALL_WAITING, dataParcel, replyParcel, option);
551 if (error != TELEPHONY_SUCCESS) {
552 TELEPHONY_LOGE("Function SetCallWaiting! errCode:%{public}d", error);
553 return error;
554 }
555 return replyParcel.ReadInt32();
556 }
557
GetCallRestriction(int32_t slotId,CallRestrictionType type)558 int32_t CallManagerServiceProxy::GetCallRestriction(int32_t slotId, CallRestrictionType type)
559 {
560 MessageOption option;
561 MessageParcel dataParcel;
562 MessageParcel replyParcel;
563 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
564 TELEPHONY_LOGE("write descriptor fail");
565 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
566 }
567 auto remote = Remote();
568 if (remote == nullptr) {
569 TELEPHONY_LOGE("function Remote() return nullptr!");
570 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
571 }
572 dataParcel.WriteInt32(slotId);
573 dataParcel.WriteInt32(static_cast<int32_t>(type));
574 int32_t error =
575 remote->SendRequest(CallManagerInterfaceCode::INTERFACE_GET_CALL_RESTRICTION, dataParcel, replyParcel, option);
576 if (error != TELEPHONY_SUCCESS) {
577 TELEPHONY_LOGE("Function GetCallRestriction! errCode:%{public}d", error);
578 return error;
579 }
580 return replyParcel.ReadInt32();
581 }
582
SetCallRestriction(int32_t slotId,CallRestrictionInfo & info)583 int32_t CallManagerServiceProxy::SetCallRestriction(int32_t slotId, CallRestrictionInfo &info)
584 {
585 MessageOption option;
586 MessageParcel dataParcel;
587 MessageParcel replyParcel;
588 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
589 TELEPHONY_LOGE("write descriptor fail");
590 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
591 }
592 auto remote = Remote();
593 if (remote == nullptr) {
594 TELEPHONY_LOGE("function Remote() return nullptr!");
595 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
596 }
597 dataParcel.WriteInt32(slotId);
598 dataParcel.WriteRawData((const void *)&info, sizeof(CallRestrictionInfo));
599 int32_t error =
600 remote->SendRequest(CallManagerInterfaceCode::INTERFACE_SET_CALL_RESTRICTION, dataParcel, replyParcel, option);
601 if (error != TELEPHONY_SUCCESS) {
602 TELEPHONY_LOGE("Function SetCallRestriction! errCode:%{public}d", error);
603 return error;
604 }
605 return replyParcel.ReadInt32();
606 }
607
SetCallRestrictionPassword(int32_t slotId,CallRestrictionType fac,const char * oldPassword,const char * newPassword)608 int32_t CallManagerServiceProxy::SetCallRestrictionPassword(
609 int32_t slotId, CallRestrictionType fac, const char *oldPassword, const char *newPassword)
610 {
611 MessageOption option;
612 MessageParcel dataParcel;
613 MessageParcel replyParcel;
614 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
615 TELEPHONY_LOGE("write descriptor fail");
616 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
617 }
618 auto remote = Remote();
619 if (remote == nullptr) {
620 TELEPHONY_LOGE("function Remote() return nullptr!");
621 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
622 }
623 if (oldPassword == nullptr || newPassword == nullptr || oldPassword[0] == '\0' || newPassword[0] == '\0') {
624 TELEPHONY_LOGE("oldPassword or newPassword is empty");
625 return TELEPHONY_ERR_ARGUMENT_INVALID;
626 }
627 dataParcel.WriteInt32(slotId);
628 dataParcel.WriteInt32(static_cast<int32_t>(fac));
629 dataParcel.WriteCString(oldPassword);
630 dataParcel.WriteCString(newPassword);
631 int32_t error = remote->SendRequest(CallManagerInterfaceCode::INTERFACE_SET_CALL_RESTRICTION_PASSWORD, dataParcel,
632 replyParcel, option);
633 if (error != TELEPHONY_SUCCESS) {
634 TELEPHONY_LOGE("Function SetCallRestrictionPassword! errCode:%{public}d", error);
635 return error;
636 }
637 return replyParcel.ReadInt32();
638 }
639
GetCallTransferInfo(int32_t slotId,CallTransferType type)640 int32_t CallManagerServiceProxy::GetCallTransferInfo(int32_t slotId, CallTransferType type)
641 {
642 MessageOption option;
643 MessageParcel dataParcel;
644 MessageParcel replyParcel;
645 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
646 TELEPHONY_LOGE("write descriptor fail");
647 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
648 }
649 auto remote = Remote();
650 if (remote == nullptr) {
651 TELEPHONY_LOGE("function Remote() return nullptr!");
652 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
653 }
654 dataParcel.WriteInt32(slotId);
655 dataParcel.WriteInt32(static_cast<int32_t>(type));
656 int32_t error =
657 remote->SendRequest(CallManagerInterfaceCode::INTERFACE_GET_CALL_TRANSFER, dataParcel, replyParcel, option);
658 if (error != TELEPHONY_SUCCESS) {
659 TELEPHONY_LOGE("Function GetCallTransfer! errCode:%{public}d", error);
660 return error;
661 }
662 return replyParcel.ReadInt32();
663 }
664
SetCallTransferInfo(int32_t slotId,CallTransferInfo & info)665 int32_t CallManagerServiceProxy::SetCallTransferInfo(int32_t slotId, CallTransferInfo &info)
666 {
667 MessageOption option;
668 MessageParcel dataParcel;
669 MessageParcel replyParcel;
670 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
671 TELEPHONY_LOGE("write descriptor fail");
672 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
673 }
674 auto remote = Remote();
675 if (remote == nullptr) {
676 TELEPHONY_LOGE("function Remote() return nullptr!");
677 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
678 }
679 dataParcel.WriteInt32(slotId);
680 dataParcel.WriteRawData((const void *)&info, sizeof(CallTransferInfo));
681 int32_t error =
682 remote->SendRequest(CallManagerInterfaceCode::INTERFACE_SET_CALL_TRANSFER, dataParcel, replyParcel, option);
683 if (error != TELEPHONY_SUCCESS) {
684 TELEPHONY_LOGE("Function SetCallTransfer! errCode:%{public}d", error);
685 return error;
686 }
687 return replyParcel.ReadInt32();
688 }
689
CanSetCallTransferTime(int32_t slotId,bool & result)690 int32_t CallManagerServiceProxy::CanSetCallTransferTime(int32_t slotId, bool &result)
691 {
692 MessageOption option;
693 MessageParcel dataParcel;
694 MessageParcel replyParcel;
695 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
696 TELEPHONY_LOGE("[slot%{public}d] write descriptor fail", slotId);
697 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
698 }
699 auto remote = Remote();
700 if (remote == nullptr) {
701 TELEPHONY_LOGE("[slot%{public}d] function Remote() return nullptr!", slotId);
702 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
703 }
704 if (!dataParcel.WriteInt32(slotId)) {
705 TELEPHONY_LOGE("[slot%{public}d] write slotId fail", slotId);
706 return TELEPHONY_ERR_WRITE_DATA_FAIL;
707 }
708 if (!dataParcel.WriteBool(result)) {
709 TELEPHONY_LOGE("[slot%{public}d] write result fail", slotId);
710 return TELEPHONY_ERR_WRITE_DATA_FAIL;
711 }
712 int32_t error = remote->SendRequest(CallManagerInterfaceCode::INTERFACE_CAN_SET_CALL_TRANSFER_TIME, dataParcel,
713 replyParcel, option);
714 if (error == ERR_NONE) {
715 result = replyParcel.ReadBool();
716 return replyParcel.ReadInt32();
717 }
718 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
719 }
720
SetCallPreferenceMode(int32_t slotId,int32_t mode)721 int32_t CallManagerServiceProxy::SetCallPreferenceMode(int32_t slotId, int32_t mode)
722 {
723 MessageOption option;
724 MessageParcel dataParcel;
725 MessageParcel replyParcel;
726 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
727 TELEPHONY_LOGE("write descriptor fail");
728 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
729 }
730 auto remote = Remote();
731 if (remote == nullptr) {
732 TELEPHONY_LOGE("function Remote() return nullptr!");
733 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
734 }
735 dataParcel.WriteInt32(slotId);
736 dataParcel.WriteInt32(mode);
737 int32_t error = remote->SendRequest(CallManagerInterfaceCode::INTERFACE_SETCALL_PREFERENCEMODE, dataParcel,
738 replyParcel, option);
739 if (error != TELEPHONY_SUCCESS) {
740 TELEPHONY_LOGE("Function SetCallPreferenceMode! errCode:%{public}d", error);
741 return error;
742 }
743 return replyParcel.ReadInt32();
744 }
745
StartRtt(int32_t callId,std::u16string & msg)746 int32_t CallManagerServiceProxy::StartRtt(int32_t callId, std::u16string &msg)
747 {
748 MessageOption option;
749 MessageParcel dataParcel;
750 MessageParcel replyParcel;
751 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
752 TELEPHONY_LOGE("write descriptor fail");
753 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
754 }
755 if (msg.empty()) {
756 TELEPHONY_LOGE("msg is empty");
757 return TELEPHONY_ERR_ARGUMENT_INVALID;
758 }
759 auto remote = Remote();
760 if (remote == nullptr) {
761 TELEPHONY_LOGE("function Remote() return nullptr!");
762 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
763 }
764 dataParcel.WriteInt32(callId);
765 dataParcel.WriteString16(msg);
766 int32_t error = remote->SendRequest(CallManagerInterfaceCode::INTERFACE_START_RTT, dataParcel, replyParcel, option);
767 if (error != TELEPHONY_SUCCESS) {
768 TELEPHONY_LOGE("Function StartRtt errCode:%{public}d", error);
769 return error;
770 }
771 return replyParcel.ReadInt32();
772 }
773
StopRtt(int32_t callId)774 int32_t CallManagerServiceProxy::StopRtt(int32_t callId)
775 {
776 MessageOption option;
777 MessageParcel dataParcel;
778 MessageParcel replyParcel;
779 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
780 TELEPHONY_LOGE("write descriptor fail");
781 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
782 }
783 auto remote = Remote();
784 if (remote == nullptr) {
785 TELEPHONY_LOGE("function Remote() return nullptr!");
786 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
787 }
788 dataParcel.WriteInt32(callId);
789 int32_t error = remote->SendRequest(CallManagerInterfaceCode::INTERFACE_STOP_RTT, dataParcel, replyParcel, option);
790 if (error != TELEPHONY_SUCCESS) {
791 TELEPHONY_LOGE("Function StopRtt errCode:%{public}d", error);
792 return error;
793 }
794 return replyParcel.ReadInt32();
795 }
796
CombineConference(int32_t mainCallId)797 int32_t CallManagerServiceProxy::CombineConference(int32_t mainCallId)
798 {
799 MessageOption option;
800 MessageParcel dataParcel;
801 MessageParcel replyParcel;
802 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
803 TELEPHONY_LOGE("write descriptor fail");
804 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
805 }
806 auto remote = Remote();
807 if (remote == nullptr) {
808 TELEPHONY_LOGE("function Remote() return nullptr!");
809 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
810 }
811 dataParcel.WriteInt32(mainCallId);
812 int32_t error = remote->SendRequest(INTERFACE_COMBINE_CONFERENCE, dataParcel, replyParcel, option);
813 if (error != TELEPHONY_SUCCESS) {
814 TELEPHONY_LOGE("Function CombineConference failed! errCode:%{public}d", error);
815 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
816 }
817 return replyParcel.ReadInt32();
818 }
819
SeparateConference(int32_t callId)820 int32_t CallManagerServiceProxy::SeparateConference(int32_t callId)
821 {
822 MessageOption option;
823 MessageParcel dataParcel;
824 MessageParcel replyParcel;
825 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
826 TELEPHONY_LOGE("write descriptor fail");
827 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
828 }
829 dataParcel.WriteInt32(callId);
830 auto remote = Remote();
831 if (remote == nullptr) {
832 TELEPHONY_LOGE("function Remote() return nullptr!");
833 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
834 }
835 int32_t error = remote->SendRequest(INTERFACE_SEPARATE_CONFERENCE, dataParcel, replyParcel, option);
836 if (error != TELEPHONY_SUCCESS) {
837 TELEPHONY_LOGE("Function SeparateConference call failed! errCode:%{public}d", error);
838 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
839 }
840 return replyParcel.ReadInt32();
841 }
842
KickOutFromConference(int32_t callId)843 int32_t CallManagerServiceProxy::KickOutFromConference(int32_t callId)
844 {
845 MessageOption option;
846 MessageParcel dataParcel;
847 MessageParcel replyParcel;
848 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
849 TELEPHONY_LOGE("write descriptor fail");
850 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
851 }
852 dataParcel.WriteInt32(callId);
853 auto remote = Remote();
854 if (remote == nullptr) {
855 TELEPHONY_LOGE("function Remote() return nullptr!");
856 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
857 }
858 int32_t error = remote->SendRequest(INTERFACE_KICK_OUT_CONFERENCE, dataParcel, replyParcel, option);
859 if (error != TELEPHONY_SUCCESS) {
860 TELEPHONY_LOGE("Function KickOutFromConference call failed! errCode:%{public}d", error);
861 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
862 }
863 return replyParcel.ReadInt32();
864 }
865
ControlCamera(std::u16string cameraId)866 int32_t CallManagerServiceProxy::ControlCamera(std::u16string cameraId)
867 {
868 MessageOption option;
869 MessageParcel dataParcel;
870 MessageParcel replyParcel;
871 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
872 TELEPHONY_LOGE("write descriptor fail");
873 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
874 }
875 dataParcel.WriteString16(cameraId);
876 auto remote = Remote();
877 if (remote == nullptr) {
878 TELEPHONY_LOGE("function Remote() return nullptr!");
879 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
880 }
881 int32_t error = remote->SendRequest(INTERFACE_CTRL_CAMERA, dataParcel, replyParcel, option);
882 if (error != TELEPHONY_SUCCESS) {
883 TELEPHONY_LOGE("Function CtrlCamera call failed! errCode:%{public}d", error);
884 return error;
885 }
886 return replyParcel.ReadInt32();
887 }
888
SetPreviewWindow(VideoWindow & window)889 int32_t CallManagerServiceProxy::SetPreviewWindow(VideoWindow &window)
890 {
891 MessageOption option;
892 MessageParcel dataParcel;
893 MessageParcel replyParcel;
894 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
895 TELEPHONY_LOGE("write descriptor fail");
896 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
897 }
898 dataParcel.WriteRawData((const void *)&window, sizeof(VideoWindow));
899 auto remote = Remote();
900 if (remote == nullptr) {
901 TELEPHONY_LOGE("function Remote() return nullptr!");
902 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
903 }
904 int32_t error = remote->SendRequest(INTERFACE_SET_PREVIEW_WINDOW, dataParcel, replyParcel, option);
905 if (error != TELEPHONY_SUCCESS) {
906 TELEPHONY_LOGE("Function SetPreviewWindow call failed! errCode:%{public}d", error);
907 return error;
908 }
909 return replyParcel.ReadInt32();
910 }
911
SetDisplayWindow(VideoWindow & window)912 int32_t CallManagerServiceProxy::SetDisplayWindow(VideoWindow &window)
913 {
914 MessageOption option;
915 MessageParcel dataParcel;
916 MessageParcel replyParcel;
917 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
918 TELEPHONY_LOGE("write descriptor fail");
919 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
920 }
921 dataParcel.WriteRawData((const void *)&window, sizeof(VideoWindow));
922 auto remote = Remote();
923 if (remote == nullptr) {
924 TELEPHONY_LOGE("function Remote() return nullptr!");
925 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
926 }
927 int32_t error = remote->SendRequest(INTERFACE_SET_DISPLAY_WINDOW, dataParcel, replyParcel, option);
928 if (error != TELEPHONY_SUCCESS) {
929 TELEPHONY_LOGE("Function SetDisplayWindow call failed! errCode:%{public}d", error);
930 return error;
931 }
932 return replyParcel.ReadInt32();
933 }
934
SetCameraZoom(float zoomRatio)935 int32_t CallManagerServiceProxy::SetCameraZoom(float zoomRatio)
936 {
937 MessageOption option;
938 MessageParcel dataParcel;
939 MessageParcel replyParcel;
940 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
941 TELEPHONY_LOGE("write descriptor fail");
942 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
943 }
944 dataParcel.WriteFloat(zoomRatio);
945 auto remote = Remote();
946 if (remote == nullptr) {
947 TELEPHONY_LOGE("function Remote() return nullptr!");
948 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
949 }
950 int32_t error = remote->SendRequest(INTERFACE_SET_CAMERA_ZOOM, dataParcel, replyParcel, option);
951 if (error != TELEPHONY_SUCCESS) {
952 TELEPHONY_LOGE("Function SetCameraZoom call failed! errCode:%{public}d", error);
953 return error;
954 }
955 return replyParcel.ReadInt32();
956 }
957
SetPausePicture(std::u16string path)958 int32_t CallManagerServiceProxy::SetPausePicture(std::u16string path)
959 {
960 MessageOption option;
961 MessageParcel dataParcel;
962 MessageParcel replyParcel;
963 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
964 TELEPHONY_LOGE("write descriptor fail");
965 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
966 }
967 if (path.empty()) {
968 TELEPHONY_LOGE("path is empty");
969 return TELEPHONY_ERR_ARGUMENT_INVALID;
970 }
971 dataParcel.WriteString16(path);
972 auto remote = Remote();
973 if (remote == nullptr) {
974 TELEPHONY_LOGE("function Remote() return nullptr!");
975 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
976 }
977 int32_t error = remote->SendRequest(INTERFACE_SET_PAUSE_IMAGE, dataParcel, replyParcel, option);
978 if (error != TELEPHONY_SUCCESS) {
979 TELEPHONY_LOGE("Function SetPausePicture call failed! errCode:%{public}d", error);
980 return error;
981 }
982 return replyParcel.ReadInt32();
983 }
984
SetDeviceDirection(int32_t rotation)985 int32_t CallManagerServiceProxy::SetDeviceDirection(int32_t rotation)
986 {
987 MessageOption option;
988 MessageParcel dataParcel;
989 MessageParcel replyParcel;
990 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
991 TELEPHONY_LOGE("write descriptor fail");
992 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
993 }
994 dataParcel.WriteInt32(rotation);
995 auto remote = Remote();
996 if (remote == nullptr) {
997 TELEPHONY_LOGE("function Remote() return nullptr!");
998 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
999 }
1000 int32_t error = remote->SendRequest(INTERFACE_SET_DEVICE_DIRECTION, dataParcel, replyParcel, option);
1001 if (error != TELEPHONY_SUCCESS) {
1002 TELEPHONY_LOGE("Function SetDeviceDirection call failed! errCode:%{public}d", error);
1003 return error;
1004 }
1005 return replyParcel.ReadInt32();
1006 }
1007
IsEmergencyPhoneNumber(std::u16string & number,int32_t slotId,bool & enabled)1008 int32_t CallManagerServiceProxy::IsEmergencyPhoneNumber(std::u16string &number, int32_t slotId, bool &enabled)
1009 {
1010 MessageOption option;
1011 MessageParcel dataParcel;
1012 MessageParcel replyParcel;
1013 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
1014 TELEPHONY_LOGE("write descriptor fail");
1015 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1016 }
1017 if (number.empty()) {
1018 TELEPHONY_LOGE("number is empty");
1019 return TELEPHONY_ERR_ARGUMENT_INVALID;
1020 }
1021 dataParcel.WriteString16(number);
1022 dataParcel.WriteInt32(slotId);
1023 auto remote = Remote();
1024 if (remote == nullptr) {
1025 TELEPHONY_LOGE("function Remote() return nullptr!");
1026 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1027 }
1028 int32_t error = remote->SendRequest(INTERFACE_IS_EMERGENCY_NUMBER, dataParcel, replyParcel, option);
1029 if (error != TELEPHONY_SUCCESS) {
1030 TELEPHONY_LOGE("Function IsEmergencyPhoneNumber call failed! errCode:%{public}d", error);
1031 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1032 }
1033 int32_t result = replyParcel.ReadInt32();
1034 if (result == TELEPHONY_SUCCESS) {
1035 enabled = replyParcel.ReadBool();
1036 }
1037 return result;
1038 }
1039
FormatPhoneNumber(std::u16string & number,std::u16string & countryCode,std::u16string & formatNumber)1040 int32_t CallManagerServiceProxy::FormatPhoneNumber(
1041 std::u16string &number, std::u16string &countryCode, std::u16string &formatNumber)
1042 {
1043 MessageOption option;
1044 MessageParcel dataParcel;
1045 MessageParcel replyParcel;
1046 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
1047 TELEPHONY_LOGE("write descriptor fail");
1048 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1049 }
1050 if (number.empty() || countryCode.empty()) {
1051 TELEPHONY_LOGE("number or countryCode is empty");
1052 return TELEPHONY_ERR_ARGUMENT_INVALID;
1053 }
1054 dataParcel.WriteString16(number);
1055 dataParcel.WriteString16(countryCode);
1056 auto remote = Remote();
1057 if (remote == nullptr) {
1058 TELEPHONY_LOGE("function Remote() return nullptr!");
1059 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1060 }
1061 int32_t error = remote->SendRequest(INTERFACE_IS_FORMAT_NUMBER, dataParcel, replyParcel, option);
1062 if (error != TELEPHONY_SUCCESS) {
1063 TELEPHONY_LOGE("Function FormatPhoneNumber call failed! errCode:%{public}d", error);
1064 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1065 }
1066 int32_t result = replyParcel.ReadInt32();
1067 if (result == TELEPHONY_SUCCESS) {
1068 formatNumber = replyParcel.ReadString16();
1069 }
1070 return result;
1071 }
1072
FormatPhoneNumberToE164(std::u16string & number,std::u16string & countryCode,std::u16string & formatNumber)1073 int32_t CallManagerServiceProxy::FormatPhoneNumberToE164(
1074 std::u16string &number, std::u16string &countryCode, std::u16string &formatNumber)
1075 {
1076 MessageOption option;
1077 MessageParcel dataParcel;
1078 MessageParcel replyParcel;
1079 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
1080 TELEPHONY_LOGE("write descriptor fail");
1081 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1082 }
1083 if (number.empty() || countryCode.empty()) {
1084 TELEPHONY_LOGE("number or countryCode is empty");
1085 return TELEPHONY_ERR_ARGUMENT_INVALID;
1086 }
1087 dataParcel.WriteString16(number);
1088 dataParcel.WriteString16(countryCode);
1089 auto remote = Remote();
1090 if (remote == nullptr) {
1091 TELEPHONY_LOGE("function Remote() return nullptr!");
1092 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1093 }
1094 int32_t error = remote->SendRequest(INTERFACE_IS_FORMAT_NUMBER_E164, dataParcel, replyParcel, option);
1095 if (error != TELEPHONY_SUCCESS) {
1096 TELEPHONY_LOGE("Function FormatPhoneNumberToE164 call failed! errCode:%{public}d", error);
1097 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1098 }
1099 int32_t result = replyParcel.ReadInt32();
1100 if (result == TELEPHONY_SUCCESS) {
1101 formatNumber = replyParcel.ReadString16();
1102 }
1103 return result;
1104 }
1105
GetMainCallId(int32_t callId,int32_t & mainCallId)1106 int32_t CallManagerServiceProxy::GetMainCallId(int32_t callId, int32_t &mainCallId)
1107 {
1108 MessageOption option;
1109 MessageParcel dataParcel;
1110 MessageParcel replyParcel;
1111 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
1112 TELEPHONY_LOGE("write descriptor fail");
1113 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1114 }
1115 dataParcel.WriteInt32(callId);
1116 auto remote = Remote();
1117 if (remote == nullptr) {
1118 TELEPHONY_LOGE("function Remote() return nullptr!");
1119 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1120 }
1121 int32_t error = remote->SendRequest(INTERFACE_GET_MAINID, dataParcel, replyParcel, option);
1122 if (error != TELEPHONY_SUCCESS) {
1123 TELEPHONY_LOGE("Function StartConference call failed! errCode:%{public}d", error);
1124 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1125 }
1126 int32_t result = replyParcel.ReadInt32();
1127 if (result == TELEPHONY_ERR_SUCCESS) {
1128 mainCallId = replyParcel.ReadInt32();
1129 }
1130 return result;
1131 }
1132
GetSubCallIdList(int32_t callId,std::vector<std::u16string> & callIdList)1133 int32_t CallManagerServiceProxy::GetSubCallIdList(int32_t callId, std::vector<std::u16string> &callIdList)
1134 {
1135 MessageOption option;
1136 MessageParcel dataParcel;
1137 MessageParcel replyParcel;
1138 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
1139 TELEPHONY_LOGE("write descriptor fail");
1140 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1141 }
1142 dataParcel.WriteInt32(callId);
1143 auto remote = Remote();
1144 if (remote == nullptr) {
1145 TELEPHONY_LOGE("function Remote() return nullptr!");
1146 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1147 }
1148 int32_t error = remote->SendRequest(INTERFACE_GET_SUBCALL_LIST_ID, dataParcel, replyParcel, option);
1149 if (error != TELEPHONY_SUCCESS) {
1150 TELEPHONY_LOGE("Function GetSubCallIdList call failed! errCode:%{public}d", error);
1151 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1152 }
1153 int32_t result = replyParcel.ReadInt32();
1154 if (result == TELEPHONY_ERR_SUCCESS) {
1155 replyParcel.ReadString16Vector(&callIdList);
1156 }
1157 return result;
1158 }
1159
GetCallIdListForConference(int32_t callId,std::vector<std::u16string> & callIdList)1160 int32_t CallManagerServiceProxy::GetCallIdListForConference(int32_t callId, std::vector<std::u16string> &callIdList)
1161 {
1162 MessageOption option;
1163 MessageParcel dataParcel;
1164 MessageParcel replyParcel;
1165 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
1166 TELEPHONY_LOGE("write descriptor fail");
1167 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1168 }
1169 dataParcel.WriteInt32(callId);
1170 auto remote = Remote();
1171 if (remote == nullptr) {
1172 TELEPHONY_LOGE("function Remote() return nullptr!");
1173 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1174 }
1175 int32_t error = remote->SendRequest(INTERFACE_GET_CALL_LIST_ID_FOR_CONFERENCE, dataParcel, replyParcel, option);
1176 if (error != TELEPHONY_SUCCESS) {
1177 TELEPHONY_LOGE("Function GetCallIdListForConference call failed! errCode:%{public}d", error);
1178 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1179 }
1180 int32_t result = replyParcel.ReadInt32();
1181 if (result == TELEPHONY_ERR_SUCCESS) {
1182 replyParcel.ReadString16Vector(&callIdList);
1183 }
1184 return result;
1185 }
1186
GetImsConfig(int32_t slotId,ImsConfigItem item)1187 int32_t CallManagerServiceProxy::GetImsConfig(int32_t slotId, ImsConfigItem item)
1188 {
1189 MessageOption option;
1190 MessageParcel dataParcel;
1191 MessageParcel replyParcel;
1192 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
1193 TELEPHONY_LOGE("write descriptor fail");
1194 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1195 }
1196 dataParcel.WriteInt32(slotId);
1197 dataParcel.WriteInt32(item);
1198 auto remote = Remote();
1199 if (remote == nullptr) {
1200 TELEPHONY_LOGE("function Remote() return nullptr!");
1201 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1202 }
1203 int32_t error = remote->SendRequest(INTERFACE_GET_IMS_CONFIG, dataParcel, replyParcel, option);
1204 if (error != TELEPHONY_SUCCESS) {
1205 TELEPHONY_LOGE("function GetImsConfig failed! errCode:%{public}d", error);
1206 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1207 }
1208 return replyParcel.ReadInt32();
1209 }
1210
SetImsConfig(int32_t slotId,ImsConfigItem item,std::u16string & value)1211 int32_t CallManagerServiceProxy::SetImsConfig(int32_t slotId, ImsConfigItem item, std::u16string &value)
1212 {
1213 MessageOption option;
1214 MessageParcel dataParcel;
1215 MessageParcel replyParcel;
1216 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
1217 TELEPHONY_LOGE("write descriptor fail");
1218 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1219 }
1220 dataParcel.WriteInt32(slotId);
1221 dataParcel.WriteInt32(item);
1222 dataParcel.WriteString16(value);
1223 auto remote = Remote();
1224 if (remote == nullptr) {
1225 TELEPHONY_LOGE("function Remote() return nullptr!");
1226 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1227 }
1228 int32_t error = remote->SendRequest(INTERFACE_SET_IMS_CONFIG, dataParcel, replyParcel, option);
1229 if (error != TELEPHONY_SUCCESS) {
1230 TELEPHONY_LOGE("function SetImsConfig failed! errCode:%{public}d", error);
1231 return error;
1232 }
1233 return replyParcel.ReadInt32();
1234 }
1235
GetImsFeatureValue(int32_t slotId,FeatureType type)1236 int32_t CallManagerServiceProxy::GetImsFeatureValue(int32_t slotId, FeatureType type)
1237 {
1238 MessageOption option;
1239 MessageParcel dataParcel;
1240 MessageParcel replyParcel;
1241 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
1242 TELEPHONY_LOGE("write descriptor fail");
1243 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1244 }
1245 dataParcel.WriteInt32(slotId);
1246 dataParcel.WriteInt32(type);
1247 auto remote = Remote();
1248 if (remote == nullptr) {
1249 TELEPHONY_LOGE("function Remote() return nullptr!");
1250 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1251 }
1252 int32_t error = remote->SendRequest(INTERFACE_GET_IMS_FEATURE_VALUE, dataParcel, replyParcel, option);
1253 if (error != TELEPHONY_SUCCESS) {
1254 TELEPHONY_LOGE("function GetImsFeatureValue failed! errCode:%{public}d", error);
1255 return error;
1256 }
1257 return replyParcel.ReadInt32();
1258 }
1259
SetImsFeatureValue(int32_t slotId,FeatureType type,int32_t value)1260 int32_t CallManagerServiceProxy::SetImsFeatureValue(int32_t slotId, FeatureType type, int32_t value)
1261 {
1262 MessageOption option;
1263 MessageParcel dataParcel;
1264 MessageParcel replyParcel;
1265 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
1266 TELEPHONY_LOGE("write descriptor fail");
1267 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1268 }
1269 dataParcel.WriteInt32(slotId);
1270 dataParcel.WriteInt32(type);
1271 dataParcel.WriteInt32(value);
1272 auto remote = Remote();
1273 if (remote == nullptr) {
1274 TELEPHONY_LOGE("function Remote() return nullptr!");
1275 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1276 }
1277 int32_t error = remote->SendRequest(INTERFACE_SET_IMS_FEATURE_VALUE, dataParcel, replyParcel, option);
1278 if (error != TELEPHONY_SUCCESS) {
1279 TELEPHONY_LOGE("function SetImsFeatureValue failed! errCode:%{public}d", error);
1280 return error;
1281 }
1282 return replyParcel.ReadInt32();
1283 }
1284
UpdateImsCallMode(int32_t callId,ImsCallMode mode)1285 int32_t CallManagerServiceProxy::UpdateImsCallMode(int32_t callId, ImsCallMode mode)
1286 {
1287 MessageOption option;
1288 MessageParcel dataParcel;
1289 MessageParcel replyParcel;
1290 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
1291 TELEPHONY_LOGE("write descriptor fail");
1292 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1293 }
1294 dataParcel.WriteInt32(callId);
1295 dataParcel.WriteUint32(mode);
1296 auto remote = Remote();
1297 if (remote == nullptr) {
1298 TELEPHONY_LOGE("function Remote() return nullptr!");
1299 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1300 }
1301 int32_t error = remote->SendRequest(INTERFACE_UPDATE_CALL_MEDIA_MODE, dataParcel, replyParcel, option);
1302 if (error != TELEPHONY_SUCCESS) {
1303 TELEPHONY_LOGE("function UpdateImsCallMode failed! errCode:%{public}d", error);
1304 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1305 }
1306 return replyParcel.ReadInt32();
1307 }
1308
EnableImsSwitch(int32_t slotId)1309 int32_t CallManagerServiceProxy::EnableImsSwitch(int32_t slotId)
1310 {
1311 MessageOption option;
1312 MessageParcel dataParcel;
1313 MessageParcel replyParcel;
1314 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
1315 TELEPHONY_LOGE("write descriptor fail");
1316 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1317 }
1318 dataParcel.WriteInt32(slotId);
1319 auto remote = Remote();
1320 if (remote == nullptr) {
1321 TELEPHONY_LOGE("function Remote() return nullptr!");
1322 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1323 }
1324 int32_t error = remote->SendRequest(INTERFACE_ENABLE_VOLTE, dataParcel, replyParcel, option);
1325 if (error != ERR_NONE) {
1326 TELEPHONY_LOGE("function EnableImsSwitch failed! errCode:%{public}d", error);
1327 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1328 }
1329 return replyParcel.ReadInt32();
1330 }
1331
DisableImsSwitch(int32_t slotId)1332 int32_t CallManagerServiceProxy::DisableImsSwitch(int32_t slotId)
1333 {
1334 MessageOption option;
1335 MessageParcel dataParcel;
1336 MessageParcel replyParcel;
1337 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
1338 TELEPHONY_LOGE("write descriptor fail");
1339 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1340 }
1341 dataParcel.WriteInt32(slotId);
1342 auto remote = Remote();
1343 if (remote == nullptr) {
1344 TELEPHONY_LOGE("function Remote() return nullptr!");
1345 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1346 }
1347 int32_t error = remote->SendRequest(INTERFACE_DISABLE_VOLTE, dataParcel, replyParcel, option);
1348 if (error != ERR_NONE) {
1349 TELEPHONY_LOGE("function DisableImsSwitch failed! errCode:%{public}d", error);
1350 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1351 }
1352 return replyParcel.ReadInt32();
1353 }
1354
IsImsSwitchEnabled(int32_t slotId,bool & enabled)1355 int32_t CallManagerServiceProxy::IsImsSwitchEnabled(int32_t slotId, bool &enabled)
1356 {
1357 MessageParcel dataParcel;
1358 MessageParcel replyParcel;
1359 MessageOption option;
1360 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
1361 TELEPHONY_LOGE("write descriptor fail");
1362 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1363 }
1364 dataParcel.WriteInt32(slotId);
1365 auto remote = Remote();
1366 if (remote == nullptr) {
1367 TELEPHONY_LOGE("function Remote() return nullptr!");
1368 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1369 }
1370 int32_t error = remote->SendRequest(INTERFACE_IS_VOLTE_ENABLED, dataParcel, replyParcel, option);
1371 if (error != ERR_NONE) {
1372 TELEPHONY_LOGE("function IsImsSwitchEnabled failed! errCode:%{public}d", error);
1373 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1374 }
1375 enabled = replyParcel.ReadBool();
1376 return replyParcel.ReadInt32();
1377 }
1378
SetVoNRState(int32_t slotId,int32_t state)1379 int32_t CallManagerServiceProxy::SetVoNRState(int32_t slotId, int32_t state)
1380 {
1381 MessageOption option;
1382 MessageParcel dataParcel;
1383 MessageParcel replyParcel;
1384 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
1385 TELEPHONY_LOGE("write descriptor fail");
1386 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1387 }
1388 dataParcel.WriteInt32(slotId);
1389 dataParcel.WriteInt32(state);
1390 auto remote = Remote();
1391 if (remote == nullptr) {
1392 TELEPHONY_LOGE("function Remote() return nullptr!");
1393 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1394 }
1395 int32_t error = remote->SendRequest(INTERFACE_SET_VONR_STATE, dataParcel, replyParcel, option);
1396 if (error != ERR_NONE) {
1397 TELEPHONY_LOGE("function SetVoNRState failed! errCode:%{public}d", error);
1398 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1399 }
1400 return replyParcel.ReadInt32();
1401 }
1402
GetVoNRState(int32_t slotId,int32_t & state)1403 int32_t CallManagerServiceProxy::GetVoNRState(int32_t slotId, int32_t &state)
1404 {
1405 MessageParcel dataParcel;
1406 MessageParcel replyParcel;
1407 MessageOption option;
1408 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
1409 TELEPHONY_LOGE("write descriptor fail");
1410 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1411 }
1412 dataParcel.WriteInt32(slotId);
1413 auto remote = Remote();
1414 if (remote == nullptr) {
1415 TELEPHONY_LOGE("function Remote() return nullptr!");
1416 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1417 }
1418 int32_t error = remote->SendRequest(INTERFACE_GET_VONR_STATE, dataParcel, replyParcel, option);
1419 if (error != ERR_NONE) {
1420 TELEPHONY_LOGE("function GetVoNRState failed! errCode:%{public}d", error);
1421 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1422 }
1423 state = replyParcel.ReadInt32();
1424 return replyParcel.ReadInt32();
1425 }
1426
JoinConference(int32_t callId,std::vector<std::u16string> & numberList)1427 int32_t CallManagerServiceProxy::JoinConference(int32_t callId, std::vector<std::u16string> &numberList)
1428 {
1429 MessageOption option;
1430 MessageParcel dataParcel;
1431 MessageParcel replyParcel;
1432 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
1433 TELEPHONY_LOGE("write descriptor fail");
1434 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1435 }
1436 dataParcel.WriteInt32(callId);
1437 dataParcel.WriteString16Vector(numberList);
1438 auto remote = Remote();
1439 if (remote == nullptr) {
1440 TELEPHONY_LOGE("function Remote() return nullptr!");
1441 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1442 }
1443 int32_t error = remote->SendRequest(INTERFACE_JOIN_CONFERENCE, dataParcel, replyParcel, option);
1444 if (error != TELEPHONY_SUCCESS) {
1445 TELEPHONY_LOGE("function JoinConference failed! errCode:%{public}d", error);
1446 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1447 }
1448 return replyParcel.ReadInt32();
1449 }
1450
ReportOttCallDetailsInfo(std::vector<OttCallDetailsInfo> & ottVec)1451 int32_t CallManagerServiceProxy::ReportOttCallDetailsInfo(std::vector<OttCallDetailsInfo> &ottVec)
1452 {
1453 MessageOption option;
1454 MessageParcel dataParcel;
1455 MessageParcel replyParcel;
1456 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
1457 TELEPHONY_LOGE("write descriptor fail");
1458 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1459 }
1460 if (ottVec.empty()) {
1461 TELEPHONY_LOGE("ottVec is empty");
1462 return TELEPHONY_ERR_ARGUMENT_INVALID;
1463 }
1464 dataParcel.WriteInt32(ottVec.size());
1465 std::vector<OttCallDetailsInfo>::iterator it = ottVec.begin();
1466 for (; it != ottVec.end(); ++it) {
1467 dataParcel.WriteRawData((const void *)&(*it), sizeof(OttCallDetailsInfo));
1468 }
1469 auto remote = Remote();
1470 if (remote == nullptr) {
1471 TELEPHONY_LOGE("function Remote() return nullptr!");
1472 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1473 }
1474 int32_t error = remote->SendRequest(INTERFACE_REPORT_OTT_CALL_DETAIL_INFO, dataParcel, replyParcel, option);
1475 if (error != TELEPHONY_SUCCESS) {
1476 TELEPHONY_LOGE("function ReportOttCallDetailsInfo failed! errCode:%{public}d", error);
1477 return error;
1478 }
1479 return replyParcel.ReadInt32();
1480 }
1481
ReportOttCallEventInfo(OttCallEventInfo & eventInfo)1482 int32_t CallManagerServiceProxy::ReportOttCallEventInfo(OttCallEventInfo &eventInfo)
1483 {
1484 MessageOption option;
1485 MessageParcel dataParcel;
1486 MessageParcel replyParcel;
1487 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
1488 TELEPHONY_LOGE("write descriptor fail");
1489 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1490 }
1491 dataParcel.WriteRawData((const void *)&eventInfo, sizeof(OttCallEventInfo));
1492 auto remote = Remote();
1493 if (remote == nullptr) {
1494 TELEPHONY_LOGE("function Remote() return nullptr!");
1495 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1496 }
1497 int32_t error = remote->SendRequest(INTERFACE_REPORT_OTT_CALL_EVENT_INFO, dataParcel, replyParcel, option);
1498 if (error != TELEPHONY_SUCCESS) {
1499 TELEPHONY_LOGE("function ReportOttCallDetailsInfo failed! errCode:%{public}d", error);
1500 return error;
1501 }
1502 return replyParcel.ReadInt32();
1503 }
1504
CloseUnFinishedUssd(int32_t slotId)1505 int32_t CallManagerServiceProxy::CloseUnFinishedUssd(int32_t slotId)
1506 {
1507 MessageOption option;
1508 MessageParcel dataParcel;
1509 MessageParcel replyParcel;
1510 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
1511 TELEPHONY_LOGE("write descriptor fail");
1512 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1513 }
1514 auto remote = Remote();
1515 if (remote == nullptr) {
1516 TELEPHONY_LOGE("function Remote() return nullptr!");
1517 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1518 }
1519 dataParcel.WriteInt32(slotId);
1520 int32_t error =
1521 remote->SendRequest(CallManagerInterfaceCode::INTERFACE_CLOSE_UNFINISHED_USSD, dataParcel, replyParcel, option);
1522 if (error != TELEPHONY_SUCCESS) {
1523 TELEPHONY_LOGE("Function CloseUnFinishedUssd! errCode:%{public}d", error);
1524 return error;
1525 }
1526 return replyParcel.ReadInt32();
1527 }
1528
InputDialerSpecialCode(const std::string & specialCode)1529 int32_t CallManagerServiceProxy::InputDialerSpecialCode(const std::string &specialCode)
1530 {
1531 MessageOption option;
1532 MessageParcel dataParcel;
1533 MessageParcel replyParcel;
1534 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
1535 TELEPHONY_LOGE("write descriptor fail");
1536 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1537 }
1538 auto remote = Remote();
1539 if (remote == nullptr) {
1540 TELEPHONY_LOGE("function Remote() return nullptr!");
1541 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1542 }
1543 dataParcel.WriteString(specialCode);
1544 int32_t error = remote->SendRequest(CallManagerInterfaceCode::INTERFACE_INPUT_DIALER_SPECIAL_CODE, dataParcel,
1545 replyParcel, option);
1546 if (error != TELEPHONY_SUCCESS) {
1547 TELEPHONY_LOGE("Function InputDialerSpecialCode! errCode:%{public}d", error);
1548 return error;
1549 }
1550 return replyParcel.ReadInt32();
1551 }
1552
RemoveMissedIncomingCallNotification()1553 int32_t CallManagerServiceProxy::RemoveMissedIncomingCallNotification()
1554 {
1555 MessageOption option;
1556 MessageParcel dataParcel;
1557 MessageParcel replyParcel;
1558 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
1559 TELEPHONY_LOGE("write descriptor fail");
1560 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1561 }
1562 auto remote = Remote();
1563 if (remote == nullptr) {
1564 TELEPHONY_LOGE("function Remote() return nullptr!");
1565 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1566 }
1567 int32_t error = remote->SendRequest(CallManagerInterfaceCode::INTERFACE_CANCEL_MISSED_INCOMING_CALL_NOTIFICATION,
1568 dataParcel, replyParcel, option);
1569 if (error != TELEPHONY_SUCCESS) {
1570 TELEPHONY_LOGE("Function RemoveMissedIncomingCallNotification! errCode:%{public}d", error);
1571 return error;
1572 }
1573 return replyParcel.ReadInt32();
1574 }
1575
GetProxyObjectPtr(CallManagerProxyType proxyType)1576 sptr<IRemoteObject> CallManagerServiceProxy::GetProxyObjectPtr(CallManagerProxyType proxyType)
1577 {
1578 MessageOption option;
1579 MessageParcel dataParcel;
1580 MessageParcel replyParcel;
1581 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
1582 TELEPHONY_LOGE("write descriptor fail");
1583 return nullptr;
1584 }
1585 dataParcel.WriteInt32(static_cast<int32_t>(proxyType));
1586 auto remote = Remote();
1587 if (remote == nullptr) {
1588 TELEPHONY_LOGE("function Remote() return nullptr!");
1589 return nullptr;
1590 }
1591 int32_t error = remote->SendRequest(INTERFACE_GET_PROXY_OBJECT_PTR, dataParcel, replyParcel, option);
1592 if (error != TELEPHONY_SUCCESS) {
1593 TELEPHONY_LOGE("function GetProxyObjectPtr failed! errCode:%{public}d", error);
1594 return nullptr;
1595 }
1596 return replyParcel.ReadRemoteObject();
1597 }
1598
ReportAudioDeviceInfo()1599 int32_t CallManagerServiceProxy::ReportAudioDeviceInfo()
1600 {
1601 MessageOption option;
1602 MessageParcel dataParcel;
1603 MessageParcel replyParcel;
1604
1605 if (!dataParcel.WriteInterfaceToken(CallManagerServiceProxy::GetDescriptor())) {
1606 TELEPHONY_LOGE("write descriptor fail");
1607 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1608 }
1609 auto remote = Remote();
1610 if (remote == nullptr) {
1611 TELEPHONY_LOGE("function Remote() return nullptr!");
1612 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1613 }
1614 int32_t error = remote->SendRequest(INTERFACE_REPORT_AUDIO_DEVICE_INFO, dataParcel, replyParcel, option);
1615 if (error != TELEPHONY_SUCCESS) {
1616 TELEPHONY_LOGE("function ReportAudioDeviceInfo errCode:%{public}d", error);
1617 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1618 }
1619 return replyParcel.ReadInt32();
1620 }
1621 } // namespace Telephony
1622 } // namespace OHOS
1623