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