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