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