1 /*
2 * Copyright (C) 2025 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 "voip_call_manager_proxy.h"
17
18 #include "message_option.h"
19 #include "message_parcel.h"
20 #include "telephony_errors.h"
21 #include "telephony_log_wrapper.h"
22 #include "native_call_manager_hisysevent.h"
23
24 namespace OHOS {
25 namespace Telephony {
VoipCallManagerProxy(const sptr<IRemoteObject> & impl)26 VoipCallManagerProxy::VoipCallManagerProxy(const sptr<IRemoteObject> &impl)
27 : IRemoteProxy<IVoipCallManagerService>(impl)
28 {}
29
ReportIncomingCall(AppExecFwk::PacMap & extras,std::vector<uint8_t> & userProfile,ErrorReason & reason)30 int32_t VoipCallManagerProxy::ReportIncomingCall(
31 AppExecFwk::PacMap &extras, std::vector<uint8_t> &userProfile, ErrorReason &reason)
32 {
33 MessageParcel dataParcel;
34 if (!dataParcel.WriteInterfaceToken(VoipCallManagerProxy::GetDescriptor())) {
35 TELEPHONY_LOGE("write descriptor fail");
36 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
37 }
38 dataParcel.WriteString(extras.GetStringValue("callId"));
39 dataParcel.WriteInt32(extras.GetIntValue("voipCallType"));
40 dataParcel.WriteString(extras.GetStringValue("userName"));
41 dataParcel.WriteString(extras.GetStringValue("abilityName"));
42 dataParcel.WriteInt32(extras.GetIntValue("voipCallState"));
43 dataParcel.WriteBool(extras.GetBooleanValue("showBannerForIncomingCall"));
44 dataParcel.WriteBool(extras.GetBooleanValue("isConferenceCall"));
45 dataParcel.WriteBool(extras.GetBooleanValue("isVoiceAnswerSupported"));
46 if (!dataParcel.WriteUInt8Vector(userProfile)) {
47 TELEPHONY_LOGE("ReportIncomingCall userProfile write fail, size:%{public}u",
48 static_cast<uint32_t>(userProfile.size()));
49 }
50 auto remote = Remote();
51 if (remote == nullptr) {
52 TELEPHONY_LOGE("ReportIncomingCall Remote is null");
53 NativeCallManagerHisysevent::WriteVoipCallEvent(extras.GetStringValue("callId"), "",
54 static_cast<int32_t>(Scenario::VOIP_PROXY_IPC_CONNECTTING), TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL,
55 "remote is nullptr!", extras.GetIntValue("voipCallType"),
56 static_cast<int32_t>(VoipCallState::VOIP_CALL_STATE_INCOMING),
57 static_cast<int32_t>(CallDirection::CALL_DIRECTION_IN));
58 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
59 }
60 MessageOption option;
61 MessageParcel replyParcel;
62 int32_t error =
63 remote->SendRequest(static_cast<int32_t>(INTERFACE_REPORT_INCOMING_CALL), dataParcel, replyParcel, option);
64 if (error != TELEPHONY_SUCCESS) {
65 TELEPHONY_LOGE("function ReportIncomingCall call failed! errCode:%{public}d", error);
66 NativeCallManagerHisysevent::WriteVoipCallEvent(extras.GetStringValue("callId"), "",
67 static_cast<int32_t>(Scenario::VOIP_PROXY_IPC_CONNECTTING), error,
68 "IncomingCall call failed!", extras.GetIntValue("voipCallType"),
69 static_cast<int32_t>(VoipCallState::VOIP_CALL_STATE_INCOMING),
70 static_cast<int32_t>(CallDirection::CALL_DIRECTION_IN));
71 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
72 }
73 int32_t result = replyParcel.ReadInt32();
74 reason = static_cast<ErrorReason>(replyParcel.ReadInt32());
75 return result;
76 }
77
ReportIncomingCallError(AppExecFwk::PacMap & extras)78 int32_t VoipCallManagerProxy::ReportIncomingCallError(AppExecFwk::PacMap &extras)
79 {
80 MessageParcel dataParcel;
81 if (!dataParcel.WriteInterfaceToken(VoipCallManagerProxy::GetDescriptor())) {
82 TELEPHONY_LOGE("write descriptor fail");
83 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
84 }
85 dataParcel.WriteString(extras.GetStringValue("callId"));
86 dataParcel.WriteInt32(extras.GetIntValue("reportVoipCallFailedCause"));
87 auto remote = Remote();
88 if (remote == nullptr) {
89 TELEPHONY_LOGE("ReportIncomingCallError Remote is null");
90 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
91 }
92 MessageOption option;
93 MessageParcel replyParcel;
94 int32_t error = remote->SendRequest(
95 static_cast<int32_t>(INTERFACE_REPORT_INCOMING_CALL_ERROR), dataParcel, replyParcel, option);
96 if (error != TELEPHONY_SUCCESS) {
97 TELEPHONY_LOGE("function ReportIncomingCallError call failed! errCode:%{public}d", error);
98 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
99 }
100 return replyParcel.ReadInt32();
101 }
102
ReportCallStateChange(std::string callId,const VoipCallState & state,const VoipCallType & type)103 int32_t VoipCallManagerProxy::ReportCallStateChange(
104 std::string callId, const VoipCallState &state, const VoipCallType &type)
105 {
106 MessageParcel dataParcel;
107 if (!dataParcel.WriteInterfaceToken(VoipCallManagerProxy::GetDescriptor())) {
108 TELEPHONY_LOGE("write descriptor fail");
109 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
110 }
111 dataParcel.WriteString(callId);
112 dataParcel.WriteInt32(static_cast<int32_t>(state));
113 dataParcel.WriteInt32(static_cast<int32_t>(type));
114 auto remote = Remote();
115 if (remote == nullptr) {
116 TELEPHONY_LOGE("ReportCallStateChange Remote is null");
117 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
118 }
119 MessageOption option;
120 MessageParcel replyParcel;
121 int32_t error =
122 remote->SendRequest(static_cast<int32_t>(INTERFACE_REPORT_CALL_STATE_CHANGE), dataParcel, replyParcel, option);
123 if (error != TELEPHONY_SUCCESS) {
124 TELEPHONY_LOGE("function ReportCallStateChange call failed! errCode:%{public}d", error);
125 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
126 }
127 return replyParcel.ReadInt32();
128 }
129
ReportOutgoingCall(AppExecFwk::PacMap & extras,std::vector<uint8_t> & userProfile,ErrorReason & reason)130 int32_t VoipCallManagerProxy::ReportOutgoingCall(
131 AppExecFwk::PacMap &extras, std::vector<uint8_t> &userProfile, ErrorReason &reason)
132 {
133 MessageParcel dataParcel;
134 if (!dataParcel.WriteInterfaceToken(VoipCallManagerProxy::GetDescriptor())) {
135 TELEPHONY_LOGE("write descriptor fail");
136 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
137 }
138 dataParcel.WriteString(extras.GetStringValue("callId"));
139 dataParcel.WriteInt32(extras.GetIntValue("voipCallType"));
140 dataParcel.WriteString(extras.GetStringValue("userName"));
141 dataParcel.WriteString(extras.GetStringValue("abilityName"));
142 dataParcel.WriteInt32(extras.GetIntValue("voipCallState"));
143 dataParcel.WriteBool(extras.GetBooleanValue("showBannerForIncomingCall"));
144 dataParcel.WriteBool(extras.GetBooleanValue("isConferenceCall"));
145 dataParcel.WriteBool(extras.GetBooleanValue("isVoiceAnswerSupported"));
146 if (!dataParcel.WriteUInt8Vector(userProfile)) {
147 TELEPHONY_LOGE("ReportOutgoingCall userProfile write fail, size:%{public}u",
148 static_cast<uint32_t>(userProfile.size()));
149 }
150 auto remote = Remote();
151 if (remote == nullptr) {
152 TELEPHONY_LOGE("ReportOutgoingCall Remote is null");
153 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
154 }
155 MessageOption option;
156 MessageParcel replyParcel;
157 int32_t error =
158 remote->SendRequest(static_cast<int32_t>(INTERFACE_REPORT_OUTGOING_CALL), dataParcel, replyParcel, option);
159 if (error != TELEPHONY_SUCCESS) {
160 TELEPHONY_LOGE("function ReportOutgoingCall call failed! errCode:%{public}d", error);
161 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
162 }
163 int32_t result = replyParcel.ReadInt32();
164 reason = static_cast<ErrorReason>(replyParcel.ReadInt32());
165 return result;
166 }
167
RegisterCallBack(const sptr<IVoipCallManagerCallback> & callback)168 int32_t VoipCallManagerProxy::RegisterCallBack(const sptr<IVoipCallManagerCallback> &callback)
169 {
170 MessageParcel dataParcel;
171 if (!dataParcel.WriteInterfaceToken(VoipCallManagerProxy::GetDescriptor())) {
172 TELEPHONY_LOGE("write descriptor fail");
173 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
174 }
175 dataParcel.WriteRemoteObject(callback->AsObject().GetRefPtr());
176 auto remote = Remote();
177 if (remote == nullptr) {
178 TELEPHONY_LOGE("RegisterCallBack Remote is null");
179 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
180 }
181 MessageOption option;
182 MessageParcel replyParcel;
183 int32_t error =
184 remote->SendRequest(static_cast<int32_t>(INTERFACE_REGISTER_CALLBACK), dataParcel, replyParcel, option);
185 if (error != TELEPHONY_SUCCESS) {
186 TELEPHONY_LOGE("function RegisterCallBack call failed! errCode:%{public}d", error);
187 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
188 }
189 return replyParcel.ReadInt32();
190 }
191
UnRegisterCallBack()192 int32_t VoipCallManagerProxy::UnRegisterCallBack()
193 {
194 MessageParcel dataParcel;
195 if (!dataParcel.WriteInterfaceToken(VoipCallManagerProxy::GetDescriptor())) {
196 TELEPHONY_LOGE("write descriptor fail");
197 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
198 }
199 auto remote = Remote();
200 if (remote == nullptr) {
201 TELEPHONY_LOGE("UnRegisterCallBack Remote is null");
202 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
203 }
204 MessageOption option;
205 MessageParcel replyParcel;
206 int32_t error =
207 remote->SendRequest(static_cast<int32_t>(INTERFACE_UN_REGISTER_CALLBACK), dataParcel, replyParcel, option);
208 if (error != TELEPHONY_SUCCESS) {
209 TELEPHONY_LOGE("function UnRegisterCallBack call failed! errCode:%{public}d", error);
210 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
211 }
212 return replyParcel.ReadInt32();
213 }
214
ReportVoipIncomingCall(std::string callId,std::string bundleName,std::string processMode,int32_t uid)215 int32_t VoipCallManagerProxy::ReportVoipIncomingCall(
216 std::string callId, std::string bundleName, std::string processMode, int32_t uid)
217 {
218 MessageParcel dataParcel;
219 if (!dataParcel.WriteInterfaceToken(VoipCallManagerProxy::GetDescriptor())) {
220 TELEPHONY_LOGE("write descriptor fail");
221 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
222 }
223 dataParcel.WriteString(callId);
224 dataParcel.WriteString(bundleName);
225 dataParcel.WriteString(processMode);
226 dataParcel.WriteInt32(uid);
227 auto remote = Remote();
228 if (remote == nullptr) {
229 TELEPHONY_LOGE("ReportVoipIncomingCall Remote is null");
230 NativeCallManagerHisysevent::WriteVoipCallEvent(callId, bundleName,
231 static_cast<int32_t>(Scenario::VOIP_PROXY_IPC_CONNECTTING), TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL,
232 "voip remote is nullptr!", static_cast<int32_t>(VoipCallType::VOIP_CALL_VOICE),
233 static_cast<int32_t>(VoipCallState::VOIP_CALL_STATE_INCOMING),
234 static_cast<int32_t>(CallDirection::CALL_DIRECTION_IN));
235 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
236 }
237 MessageOption option;
238 MessageParcel replyParcel;
239 int32_t error =
240 remote->SendRequest(static_cast<int32_t>(INTERFACE_REPORT_VOIP_INCOMING_CALL), dataParcel, replyParcel, option);
241 if (error != TELEPHONY_SUCCESS) {
242 TELEPHONY_LOGE("function ReportVoipIncomingCall call failed! errCode:%{public}d", error);
243 NativeCallManagerHisysevent::WriteVoipCallEvent(callId, bundleName,
244 static_cast<int32_t>(Scenario::VOIP_PROXY_IPC_CONNECTTING), error,
245 "voipIncomingCall call failed!", static_cast<int32_t>(VoipCallType::VOIP_CALL_VOICE),
246 static_cast<int32_t>(VoipCallState::VOIP_CALL_STATE_INCOMING),
247 static_cast<int32_t>(CallDirection::CALL_DIRECTION_IN));
248 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
249 }
250 return replyParcel.ReadInt32();
251 }
252
ReportVoipCallExtensionId(std::string callId,std::string bundleName,std::string extensionId,int32_t uid)253 int32_t VoipCallManagerProxy::ReportVoipCallExtensionId(
254 std::string callId, std::string bundleName, std::string extensionId, int32_t uid)
255 {
256 MessageParcel dataParcel;
257 if (!dataParcel.WriteInterfaceToken(VoipCallManagerProxy::GetDescriptor())) {
258 TELEPHONY_LOGE("write descriptor fail");
259 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
260 }
261 dataParcel.WriteString(callId);
262 dataParcel.WriteString(bundleName);
263 dataParcel.WriteString(extensionId);
264 dataParcel.WriteInt32(uid);
265 auto remote = Remote();
266 if (remote == nullptr) {
267 TELEPHONY_LOGE("ReportVoipCallExtensionId Remote is null");
268 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
269 }
270 MessageOption option;
271 MessageParcel replyParcel;
272 int32_t error = remote->SendRequest(
273 static_cast<int32_t>(INTERFACE_REPORT_VOIP_CALL_EXTENSIONID), dataParcel, replyParcel, option);
274 if (error != TELEPHONY_SUCCESS) {
275 TELEPHONY_LOGE("function ReportVoipCallExtensionId call failed! errCode:%{public}d", error);
276 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
277 }
278 return replyParcel.ReadInt32();
279 }
280
Answer(const VoipCallEventInfo & events,int32_t videoState)281 int32_t VoipCallManagerProxy::Answer(const VoipCallEventInfo &events, int32_t videoState)
282 {
283 MessageParcel dataParcel;
284 if (!dataParcel.WriteInterfaceToken(VoipCallManagerProxy::GetDescriptor())) {
285 TELEPHONY_LOGE("write descriptor fail");
286 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
287 }
288 dataParcel.WriteString(events.voipCallId);
289 dataParcel.WriteString(events.bundleName);
290 dataParcel.WriteInt32(events.uid);
291 dataParcel.WriteInt32(videoState);
292 auto remote = Remote();
293 if (remote == nullptr) {
294 TELEPHONY_LOGE("Answer voip Remote is null");
295 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
296 }
297 MessageOption option;
298 MessageParcel replyParcel;
299 int32_t error = remote->SendRequest(
300 static_cast<int32_t>(INTERFACE_ANSWER_VOIP_CALL), dataParcel, replyParcel, option);
301 if (error != TELEPHONY_SUCCESS) {
302 TELEPHONY_LOGE("function Answer voip call failed! errCode:%{public}d", error);
303 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
304 }
305 return replyParcel.ReadInt32();
306 }
307
HangUp(const VoipCallEventInfo & events)308 int32_t VoipCallManagerProxy::HangUp(const VoipCallEventInfo &events)
309 {
310 MessageParcel dataParcel;
311 if (!dataParcel.WriteInterfaceToken(VoipCallManagerProxy::GetDescriptor())) {
312 TELEPHONY_LOGE("write descriptor fail");
313 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
314 }
315 dataParcel.WriteString(events.voipCallId);
316 dataParcel.WriteString(events.bundleName);
317 dataParcel.WriteInt32(events.uid);
318 dataParcel.WriteInt32(static_cast<int32_t>(events.errorReason));
319 auto remote = Remote();
320 if (remote == nullptr) {
321 TELEPHONY_LOGE("HangUp voip Remote is null");
322 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
323 }
324 MessageOption option;
325 MessageParcel replyParcel;
326 int32_t error = remote->SendRequest(
327 static_cast<int32_t>(INTERFACE_HANGUP_VOIP_CALL), dataParcel, replyParcel, option);
328 if (error != TELEPHONY_SUCCESS) {
329 TELEPHONY_LOGE("function HangUp voip call failed! errCode:%{public}d", error);
330 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
331 }
332 return replyParcel.ReadInt32();
333 }
334
Reject(const VoipCallEventInfo & events)335 int32_t VoipCallManagerProxy::Reject(const VoipCallEventInfo &events)
336 {
337 MessageParcel dataParcel;
338 if (!dataParcel.WriteInterfaceToken(VoipCallManagerProxy::GetDescriptor())) {
339 TELEPHONY_LOGE("write descriptor fail");
340 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
341 }
342 dataParcel.WriteString(events.voipCallId);
343 dataParcel.WriteString(events.bundleName);
344 dataParcel.WriteInt32(events.uid);
345 auto remote = Remote();
346 if (remote == nullptr) {
347 TELEPHONY_LOGE("Reject voip Remote is null");
348 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
349 }
350 MessageOption option;
351 MessageParcel replyParcel;
352 int32_t error = remote->SendRequest(
353 static_cast<int32_t>(INTERFACE_REJECT_VOIP_CALL), dataParcel, replyParcel, option);
354 if (error != TELEPHONY_SUCCESS) {
355 TELEPHONY_LOGE("function Reject voip call failed! errCode:%{public}d", error);
356 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
357 }
358 return replyParcel.ReadInt32();
359 }
360
RegisterCallManagerCallBack(const sptr<ICallStatusCallback> & callback)361 int32_t VoipCallManagerProxy::RegisterCallManagerCallBack(const sptr<ICallStatusCallback> &callback)
362 {
363 if (callback == nullptr) {
364 return TELEPHONY_ERR_ARGUMENT_INVALID;
365 }
366
367 MessageParcel dataParcel;
368 if (!dataParcel.WriteInterfaceToken(VoipCallManagerProxy::GetDescriptor())) {
369 TELEPHONY_LOGE("write descriptor fail");
370 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
371 }
372
373 dataParcel.WriteRemoteObject(callback->AsObject().GetRefPtr());
374 auto remote = Remote();
375 if (remote == nullptr) {
376 TELEPHONY_LOGE("RegisterCallManagerCallBack Remote is null");
377 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
378 }
379 MessageOption option;
380 MessageParcel replyParcel;
381 int32_t error = remote->SendRequest(
382 static_cast<int32_t>(INTERFACE_REGISTER_CALL_MANAGER_CALLBACK), dataParcel, replyParcel, option);
383 if (error != TELEPHONY_SUCCESS) {
384 TELEPHONY_LOGE("function RegisterCallManagerCallBack call failed! errCode:%{public}d", error);
385 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
386 }
387 return replyParcel.ReadInt32();
388 }
389
UnRegisterCallManagerCallBack()390 int32_t VoipCallManagerProxy::UnRegisterCallManagerCallBack()
391 {
392 MessageParcel dataParcel;
393 if (!dataParcel.WriteInterfaceToken(VoipCallManagerProxy::GetDescriptor())) {
394 TELEPHONY_LOGE("write descriptor fail");
395 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
396 }
397 auto remote = Remote();
398 if (remote == nullptr) {
399 TELEPHONY_LOGE("UnRegisterCallManagerCallBack Remote is null");
400 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
401 }
402 MessageOption option;
403 MessageParcel replyParcel;
404 int32_t error = remote->SendRequest(
405 static_cast<int32_t>(INTERFACE_UNREGISTER_CALL_MANAGER_CALLBACK), dataParcel, replyParcel, option);
406 if (error != TELEPHONY_SUCCESS) {
407 TELEPHONY_LOGE("function UnRegisterCallManagerCallBack call failed! errCode:%{public}d", error);
408 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
409 }
410 return replyParcel.ReadInt32();
411 }
412
UnloadVoipSa()413 int32_t VoipCallManagerProxy::UnloadVoipSa()
414 {
415 MessageParcel dataParcel;
416 if (!dataParcel.WriteInterfaceToken(VoipCallManagerProxy::GetDescriptor())) {
417 TELEPHONY_LOGE("write descriptor fail");
418 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
419 }
420 auto remote = Remote();
421 if (remote == nullptr) {
422 TELEPHONY_LOGE("UnloadVoipSa Remote is null");
423 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
424 }
425
426 MessageOption option;
427 MessageParcel replyParcel;
428 int32_t error =
429 remote->SendRequest(static_cast<int32_t>(INTERFACE_UNLOAD_VOIP_SA), dataParcel, replyParcel, option);
430 if (error != TELEPHONY_SUCCESS) {
431 TELEPHONY_LOGE("function UnloadVoipSa failed! errCode:%{public}d", error);
432 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
433 }
434 return replyParcel.ReadInt32();
435 }
436
SendCallUiEvent(std::string voipCallId,const CallAudioEvent & callAudioEvent)437 int32_t VoipCallManagerProxy::SendCallUiEvent(std::string voipCallId, const CallAudioEvent &callAudioEvent)
438 {
439 MessageParcel dataParcel;
440 if (!dataParcel.WriteInterfaceToken(VoipCallManagerProxy::GetDescriptor())) {
441 TELEPHONY_LOGE("write descriptor fail");
442 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
443 }
444 dataParcel.WriteString(voipCallId);
445 dataParcel.WriteInt32(static_cast<int32_t>(callAudioEvent));
446 auto remote = Remote();
447 if (remote == nullptr) {
448 TELEPHONY_LOGE("SendCallUiEvent Remote is null");
449 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
450 }
451 MessageOption option;
452 MessageParcel replyParcel;
453 int32_t error =
454 remote->SendRequest(static_cast<int32_t>(INTERFACE_SEND_CALL_UI_EVENT), dataParcel, replyParcel, option);
455 if (error != TELEPHONY_SUCCESS) {
456 TELEPHONY_LOGE("function SendCallUiEvent call failed! errCode:%{public}d", error);
457 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
458 }
459 return replyParcel.ReadInt32();
460 }
461
ReportCallAudioEventChange(std::string voipCallId,const CallAudioEvent & callAudioEvent)462 int32_t VoipCallManagerProxy::ReportCallAudioEventChange(std::string voipCallId, const CallAudioEvent &callAudioEvent)
463 {
464 MessageParcel dataParcel;
465 if (!dataParcel.WriteInterfaceToken(VoipCallManagerProxy::GetDescriptor())) {
466 TELEPHONY_LOGE("write descriptor fail");
467 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
468 }
469 dataParcel.WriteString(voipCallId);
470 dataParcel.WriteInt32(static_cast<int32_t>(callAudioEvent));
471 auto remote = Remote();
472 if (remote == nullptr) {
473 TELEPHONY_LOGE("ReportCallAudioEventChange Remote is null");
474 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
475 }
476 MessageOption option;
477 MessageParcel replyParcel;
478 int32_t error = remote->SendRequest(
479 static_cast<int32_t>(INTERFACE_REPORT_CALL_AUDIO_EVENT_CHANGE), dataParcel, replyParcel, option);
480 if (error != TELEPHONY_SUCCESS) {
481 TELEPHONY_LOGE("function ReportCallAudioEventChange call failed! errCode:%{public}d", error);
482 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
483 }
484 return replyParcel.ReadInt32();
485 }
486
487 } // namespace Telephony
488 } // namespace OHOS
489