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