• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_ability_callback_proxy.h"
17 
18 #include "call_manager_errors.h"
19 #include "message_option.h"
20 #include "message_parcel.h"
21 #include "call_manager_utils.h"
22 
23 namespace OHOS {
24 namespace Telephony {
CallAbilityCallbackProxy(const sptr<IRemoteObject> & impl)25 CallAbilityCallbackProxy::CallAbilityCallbackProxy(const sptr<IRemoteObject> &impl)
26     : IRemoteProxy<ICallAbilityCallback>(impl)
27 {}
28 
OnCallDetailsChange(const CallAttributeInfo & info)29 int32_t CallAbilityCallbackProxy::OnCallDetailsChange(const CallAttributeInfo &info)
30 {
31     MessageParcel dataParcel;
32     MessageParcel replyParcel;
33     MessageOption option(MessageOption::TF_ASYNC);
34     if (!dataParcel.WriteInterfaceToken(CallAbilityCallbackProxy::GetDescriptor())) {
35         TELEPHONY_LOGE("write descriptor fail");
36         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
37     }
38     CallManagerUtils::WriteCallAttributeInfo(info, dataParcel);
39     if (Remote() == nullptr) {
40         TELEPHONY_LOGE("function Remote() return nullptr!");
41         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
42     }
43     int32_t error =
44         Remote()->SendRequest(static_cast<uint32_t>(CallManagerCallAbilityInterfaceCode::UPDATE_CALL_STATE_INFO),
45         dataParcel, replyParcel, option);
46     if (error != TELEPHONY_SUCCESS) {
47         TELEPHONY_LOGD("update call state info errcode: %{public}d", error);
48         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
49     }
50     return replyParcel.ReadInt32();
51 }
52 
OnMeeTimeDetailsChange(const CallAttributeInfo & info)53 int32_t CallAbilityCallbackProxy::OnMeeTimeDetailsChange(const CallAttributeInfo &info)
54 {
55     MessageParcel dataParcel;
56     MessageParcel replyParcel;
57     MessageOption option(MessageOption::TF_ASYNC);
58     if (!dataParcel.WriteInterfaceToken(CallAbilityCallbackProxy::GetDescriptor())) {
59         TELEPHONY_LOGE("write descriptor fail");
60         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
61     }
62     CallManagerUtils::WriteCallAttributeInfo(info, dataParcel);
63     if (Remote() == nullptr) {
64         TELEPHONY_LOGE("function Remote() return nullptr!");
65         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
66     }
67     int32_t error =
68         Remote()->SendRequest(static_cast<uint32_t>(CallManagerCallAbilityInterfaceCode::UPDATE_MEETIME_STATE_INFO),
69         dataParcel, replyParcel, option);
70     if (error != TELEPHONY_SUCCESS) {
71         TELEPHONY_LOGE("update meeTime state info errcode: %{public}d", error);
72         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
73     }
74     return replyParcel.ReadInt32();
75 }
76 
OnCallEventChange(const CallEventInfo & info)77 int32_t CallAbilityCallbackProxy::OnCallEventChange(const CallEventInfo &info)
78 {
79     MessageParcel dataParcel;
80     MessageParcel replyParcel;
81     MessageOption option(MessageOption::TF_ASYNC);
82     if (!dataParcel.WriteInterfaceToken(CallAbilityCallbackProxy::GetDescriptor())) {
83         TELEPHONY_LOGE("write descriptor fail");
84         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
85     }
86     int32_t length = sizeof(CallEventInfo);
87     dataParcel.WriteInt32(length);
88     dataParcel.WriteRawData((const void *)&info, length);
89     if (Remote() == nullptr) {
90         TELEPHONY_LOGE("function Remote() return nullptr!");
91         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
92     }
93     int32_t error = Remote()->SendRequest(static_cast<uint32_t>(CallManagerCallAbilityInterfaceCode::UPDATE_CALL_EVENT),
94         dataParcel, replyParcel, option);
95     if (error != TELEPHONY_SUCCESS) {
96         TELEPHONY_LOGE("update call event failed, error: %{public}d", error);
97         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
98     }
99     return replyParcel.ReadInt32();
100 }
101 
OnCallDisconnectedCause(const DisconnectedDetails & details)102 int32_t CallAbilityCallbackProxy::OnCallDisconnectedCause(const DisconnectedDetails &details)
103 {
104     MessageParcel dataParcel;
105     MessageParcel replyParcel;
106     MessageOption option(MessageOption::TF_ASYNC);
107     if (!dataParcel.WriteInterfaceToken(CallAbilityCallbackProxy::GetDescriptor())) {
108         TELEPHONY_LOGE("write descriptor fail");
109         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
110     }
111     if (!dataParcel.WriteInt32(static_cast<int32_t>(details.reason))) {
112         TELEPHONY_LOGE("write reason fail");
113         return TELEPHONY_ERR_WRITE_DATA_FAIL;
114     }
115     if (!dataParcel.WriteString(details.message)) {
116         TELEPHONY_LOGE("write message fail");
117         return TELEPHONY_ERR_WRITE_DATA_FAIL;
118     }
119     if (Remote() == nullptr) {
120         TELEPHONY_LOGE("function Remote() return nullptr!");
121         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
122     }
123     int32_t error = Remote()->SendRequest(
124         static_cast<uint32_t>(CallManagerCallAbilityInterfaceCode::UPDATE_CALL_DISCONNECTED_CAUSE), dataParcel,
125         replyParcel, option);
126     if (error != TELEPHONY_SUCCESS) {
127         TELEPHONY_LOGD("report call disconnected cause errcode: %{public}d", error);
128         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
129     }
130     return replyParcel.ReadInt32();
131 }
132 
OnReportAsyncResults(CallResultReportId reportId,AppExecFwk::PacMap & resultInfo)133 int32_t CallAbilityCallbackProxy::OnReportAsyncResults(CallResultReportId reportId, AppExecFwk::PacMap &resultInfo)
134 {
135     MessageParcel dataParcel;
136     MessageParcel replyParcel;
137     MessageOption option(MessageOption::TF_ASYNC);
138     if (!dataParcel.WriteInterfaceToken(CallAbilityCallbackProxy::GetDescriptor())) {
139         TELEPHONY_LOGE("write descriptor fail");
140         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
141     }
142     PackDataParcel(reportId, resultInfo, dataParcel);
143     if (Remote() == nullptr) {
144         TELEPHONY_LOGE("function Remote() return nullptr!");
145         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
146     }
147     int32_t error = Remote()->SendRequest(
148         static_cast<uint32_t>(CallManagerCallAbilityInterfaceCode::UPDATE_CALL_ASYNC_RESULT_REQUEST), dataParcel,
149         replyParcel, option);
150     if (error != TELEPHONY_SUCCESS) {
151         TELEPHONY_LOGE("report async results failed, error: %{public}d", error);
152         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
153     }
154     return replyParcel.ReadInt32();
155 }
156 
OnReportMmiCodeResult(const MmiCodeInfo & info)157 int32_t CallAbilityCallbackProxy::OnReportMmiCodeResult(const MmiCodeInfo &info)
158 {
159     MessageParcel dataParcel;
160     MessageParcel replyParcel;
161     MessageOption option(MessageOption::TF_ASYNC);
162     if (!dataParcel.WriteInterfaceToken(CallAbilityCallbackProxy::GetDescriptor())) {
163         TELEPHONY_LOGE("write descriptor fail");
164         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
165     }
166     int32_t length = sizeof(MmiCodeInfo);
167     dataParcel.WriteInt32(length);
168     dataParcel.WriteRawData((const void *)&info, length);
169     if (Remote() == nullptr) {
170         TELEPHONY_LOGE("function Remote() return nullptr!");
171         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
172     }
173     int32_t error = Remote()->SendRequest(static_cast<uint32_t>(
174         CallManagerCallAbilityInterfaceCode::UPDATE_MMI_CODE_RESULT_REQUEST), dataParcel,
175         replyParcel, option);
176     if (error != TELEPHONY_SUCCESS) {
177         TELEPHONY_LOGE("report async results failed, error: %{public}d", error);
178         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
179     }
180     return replyParcel.ReadInt32();
181 }
182 
PackDataParcel(CallResultReportId reportId,AppExecFwk::PacMap & resultInfo,MessageParcel & dataParcel)183 void CallAbilityCallbackProxy::PackDataParcel(
184     CallResultReportId reportId, AppExecFwk::PacMap &resultInfo, MessageParcel &dataParcel)
185 {
186     dataParcel.WriteInt32(static_cast<int32_t>(reportId));
187     dataParcel.WriteInt32(resultInfo.GetIntValue("result"));
188     switch (reportId) {
189         case CallResultReportId::GET_CALL_WAITING_REPORT_ID:
190         case CallResultReportId::GET_CALL_RESTRICTION_REPORT_ID:
191             dataParcel.WriteInt32(resultInfo.GetIntValue("status"));
192             dataParcel.WriteInt32(resultInfo.GetIntValue("classCw"));
193             break;
194         case CallResultReportId::GET_CALL_TRANSFER_REPORT_ID:
195             dataParcel.WriteInt32(resultInfo.GetIntValue("status"));
196             dataParcel.WriteInt32(resultInfo.GetIntValue("classx"));
197             dataParcel.WriteString(resultInfo.GetStringValue("number"));
198             dataParcel.WriteInt32(resultInfo.GetIntValue("type"));
199             dataParcel.WriteInt32(resultInfo.GetIntValue("reason"));
200             break;
201         case CallResultReportId::GET_CALL_CLIP_ID:
202             dataParcel.WriteInt32(resultInfo.GetIntValue("action"));
203             dataParcel.WriteInt32(resultInfo.GetIntValue("clipStat"));
204             break;
205         case CallResultReportId::GET_CALL_CLIR_ID:
206             dataParcel.WriteInt32(resultInfo.GetIntValue("action"));
207             dataParcel.WriteInt32(resultInfo.GetIntValue("clirStat"));
208             break;
209         case CallResultReportId::GET_IMS_CONFIG_REPORT_ID:
210         case CallResultReportId::GET_IMS_FEATURE_VALUE_REPORT_ID:
211             dataParcel.WriteInt32(resultInfo.GetIntValue("value"));
212             break;
213         case CallResultReportId::START_RTT_REPORT_ID:
214             dataParcel.WriteInt32(resultInfo.GetIntValue("active"));
215             break;
216         case CallResultReportId::STOP_RTT_REPORT_ID:
217             dataParcel.WriteInt32(resultInfo.GetIntValue("inactive"));
218             break;
219         default:
220             break;
221     }
222 }
223 
OnOttCallRequest(OttCallRequestId requestId,AppExecFwk::PacMap & info)224 int32_t CallAbilityCallbackProxy::OnOttCallRequest(OttCallRequestId requestId, AppExecFwk::PacMap &info)
225 {
226     MessageParcel dataParcel;
227     MessageParcel replyParcel;
228     MessageOption option(MessageOption::TF_ASYNC);
229     if (!dataParcel.WriteInterfaceToken(CallAbilityCallbackProxy::GetDescriptor())) {
230         TELEPHONY_LOGE("write descriptor fail");
231         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
232     }
233     dataParcel.WriteInt32(static_cast<int32_t>(requestId));
234     dataParcel.WriteString(info.GetStringValue("phoneNumber"));
235     dataParcel.WriteString(info.GetStringValue("bundleName"));
236     dataParcel.WriteInt32(info.GetIntValue("videoState"));
237     switch (requestId) {
238         case OttCallRequestId::OTT_REQUEST_INVITE_TO_CONFERENCE:
239             if (info.GetIntValue("listCnt") > 0) {
240                 dataParcel.WriteString(info.GetStringValue("number"));
241             }
242             break;
243         case OttCallRequestId::OTT_REQUEST_UPDATE_CALL_MEDIA_MODE:
244             dataParcel.WriteInt32(info.GetIntValue("callMediaMode"));
245             break;
246         default:
247             break;
248     }
249     if (Remote() == nullptr) {
250         TELEPHONY_LOGE("function Remote() return nullptr!");
251         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
252     }
253     int32_t error =
254         Remote()->SendRequest(static_cast<uint32_t>(CallManagerCallAbilityInterfaceCode::REPORT_OTT_CALL_REQUEST),
255         dataParcel, replyParcel, option);
256     if (error != TELEPHONY_SUCCESS) {
257         TELEPHONY_LOGE("report ott call request failed, error: %{public}d", error);
258         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
259     }
260     return replyParcel.ReadInt32();
261 }
262 
OnReportAudioDeviceChange(const AudioDeviceInfo & info)263 int32_t CallAbilityCallbackProxy::OnReportAudioDeviceChange(const AudioDeviceInfo &info)
264 {
265     MessageParcel dataParcel;
266     MessageParcel replyParcel;
267     MessageOption option(MessageOption::TF_ASYNC);
268     if (!dataParcel.WriteInterfaceToken(CallAbilityCallbackProxy::GetDescriptor())) {
269         TELEPHONY_LOGE("write descriptor fail");
270         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
271     }
272     size_t audioDeviceListLength = info.audioDeviceList.size();
273     dataParcel.WriteInt32(static_cast<int32_t>(audioDeviceListLength));
274     for (auto &audioDevice : info.audioDeviceList) {
275         dataParcel.WriteRawData((const void *)&audioDevice, sizeof(AudioDevice));
276     }
277     dataParcel.WriteRawData((const void *)&info.currentAudioDevice, sizeof(AudioDevice));
278     dataParcel.WriteBool(info.isMuted);
279     dataParcel.WriteInt32(info.callId);
280 
281     TELEPHONY_LOGD("audioDeviceListLength=%{public}zu", audioDeviceListLength);
282     if (Remote() == nullptr) {
283         TELEPHONY_LOGE("function Remote() return nullptr!");
284         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
285     }
286     int32_t error = Remote()->SendRequest(
287         static_cast<uint32_t>(CallManagerCallAbilityInterfaceCode::UPDATE_AUDIO_DEVICE_CHANGE_RESULT_REQUEST),
288         dataParcel, replyParcel, option);
289     if (error != TELEPHONY_SUCCESS) {
290         TELEPHONY_LOGD("report audio device info errcode: %{public}d", error);
291         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
292     }
293     return replyParcel.ReadInt32();
294 }
295 
OnReportPostDialDelay(const std::string & str)296 int32_t CallAbilityCallbackProxy::OnReportPostDialDelay(const std::string &str)
297 {
298     MessageParcel dataParcel;
299     MessageParcel replyParcel;
300     MessageOption option(MessageOption::TF_ASYNC);
301     if (!dataParcel.WriteInterfaceToken(CallAbilityCallbackProxy::GetDescriptor())) {
302         TELEPHONY_LOGE("WriteInterfaceToken fail");
303         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
304     }
305     dataParcel.WriteString(str);
306     if (Remote() == nullptr) {
307         TELEPHONY_LOGE("Remote() return nullptr!");
308         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
309     }
310     int32_t error = Remote()->SendRequest(
311         static_cast<uint32_t>(CallManagerCallAbilityInterfaceCode::REPORT_POST_DIAL_DELAY),
312         dataParcel, replyParcel, option);
313     if (error != TELEPHONY_SUCCESS) {
314         TELEPHONY_LOGE("report post-dial wait failed, error: %{public}d", error);
315         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
316     }
317     return replyParcel.ReadInt32();
318 }
319 
OnReportImsCallModeChange(const CallMediaModeInfo & imsCallModeInfo)320 int32_t CallAbilityCallbackProxy::OnReportImsCallModeChange(const CallMediaModeInfo &imsCallModeInfo)
321 {
322     MessageParcel dataParcel;
323     MessageParcel replyParcel;
324     MessageOption option(MessageOption::TF_ASYNC);
325     if (!dataParcel.WriteInterfaceToken(CallAbilityCallbackProxy::GetDescriptor())) {
326         TELEPHONY_LOGE("write descriptor fail");
327         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
328     }
329     int32_t length = sizeof(CallMediaModeInfo);
330     dataParcel.WriteInt32(length);
331     dataParcel.WriteRawData((const void *)&imsCallModeInfo, length);
332     if (Remote() == nullptr) {
333         TELEPHONY_LOGE("function Remote() return nullptr!");
334         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
335     }
336     int32_t error = Remote()->SendRequest(static_cast<uint32_t>(
337         CallManagerCallAbilityInterfaceCode::UPDATE_IMS_CALL_MODE_RECEIVE), dataParcel,
338         replyParcel, option);
339     if (error != TELEPHONY_SUCCESS) {
340         TELEPHONY_LOGD("report async results errcode: %{public}d", error);
341         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
342     }
343     return replyParcel.ReadInt32();
344 }
345 
OnReportCallSessionEventChange(const CallSessionEvent & callSessionEventOptions)346 int32_t CallAbilityCallbackProxy::OnReportCallSessionEventChange(
347     const CallSessionEvent &callSessionEventOptions)
348 {
349     MessageParcel dataParcel;
350     MessageParcel replyParcel;
351     MessageOption option(MessageOption::TF_ASYNC);
352     if (!dataParcel.WriteInterfaceToken(CallAbilityCallbackProxy::GetDescriptor())) {
353         TELEPHONY_LOGE("write descriptor fail");
354         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
355     }
356     int32_t length = sizeof(CallSessionEvent);
357     dataParcel.WriteInt32(length);
358     dataParcel.WriteRawData((const void *)&callSessionEventOptions, length);
359     if (Remote() == nullptr) {
360         TELEPHONY_LOGE("function Remote() return nullptr!");
361         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
362     }
363     int32_t error = Remote()->SendRequest(static_cast<uint32_t>(
364         CallManagerCallAbilityInterfaceCode::CALL_SESSION_EVENT_CHANGE), dataParcel,
365         replyParcel, option);
366     if (error != TELEPHONY_SUCCESS) {
367         TELEPHONY_LOGD("report async results errcode: %{public}d", error);
368         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
369     }
370     return replyParcel.ReadInt32();
371 }
372 
OnReportPeerDimensionsChange(const PeerDimensionsDetail & peerDimensionsDetail)373 int32_t CallAbilityCallbackProxy::OnReportPeerDimensionsChange(const PeerDimensionsDetail &peerDimensionsDetail)
374 {
375     MessageParcel dataParcel;
376     MessageParcel replyParcel;
377     MessageOption option(MessageOption::TF_ASYNC);
378     if (!dataParcel.WriteInterfaceToken(CallAbilityCallbackProxy::GetDescriptor())) {
379         TELEPHONY_LOGE("write descriptor fail");
380         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
381     }
382     int32_t length = sizeof(PeerDimensionsDetail);
383     dataParcel.WriteInt32(length);
384     dataParcel.WriteRawData((const void *)&peerDimensionsDetail, length);
385     if (Remote() == nullptr) {
386         TELEPHONY_LOGE("function Remote() return nullptr!");
387         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
388     }
389     int32_t error = Remote()->SendRequest(static_cast<uint32_t>(
390         CallManagerCallAbilityInterfaceCode::PEERD_DIMENSIONS_CHANGE), dataParcel,
391         replyParcel, option);
392     if (error != TELEPHONY_SUCCESS) {
393         TELEPHONY_LOGE("report async results failed, error: %{public}d", error);
394         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
395     }
396     return replyParcel.ReadInt32();
397 }
398 
OnReportCallDataUsageChange(const int64_t dataUsage)399 int32_t CallAbilityCallbackProxy::OnReportCallDataUsageChange(const int64_t dataUsage)
400 {
401     MessageParcel dataParcel;
402     MessageParcel replyParcel;
403     MessageOption option(MessageOption::TF_ASYNC);
404     if (!dataParcel.WriteInterfaceToken(CallAbilityCallbackProxy::GetDescriptor())) {
405         TELEPHONY_LOGE("write descriptor fail");
406         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
407     }
408     dataParcel.WriteInt64(dataUsage);
409     if (Remote() == nullptr) {
410         TELEPHONY_LOGE("function Remote() return nullptr!");
411         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
412     }
413     int32_t error = Remote()->SendRequest(static_cast<uint32_t>(
414         CallManagerCallAbilityInterfaceCode::CALL_DATA_USAGE_CHANGE), dataParcel,
415         replyParcel, option);
416     if (error != TELEPHONY_SUCCESS) {
417         TELEPHONY_LOGE("report async results failed, error: %{public}d", error);
418         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
419     }
420     return replyParcel.ReadInt32();
421 }
422 
OnReportCameraCapabilities(const CameraCapabilities & cameraCapabilities)423 int32_t CallAbilityCallbackProxy::OnReportCameraCapabilities(const CameraCapabilities &cameraCapabilities)
424 {
425     MessageParcel dataParcel;
426     MessageParcel replyParcel;
427     MessageOption option(MessageOption::TF_ASYNC);
428     if (!dataParcel.WriteInterfaceToken(CallAbilityCallbackProxy::GetDescriptor())) {
429         TELEPHONY_LOGE("write descriptor fail");
430         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
431     }
432     int32_t length = sizeof(CameraCapabilities);
433     dataParcel.WriteInt32(length);
434     dataParcel.WriteRawData((const void *)&cameraCapabilities, length);
435     if (Remote() == nullptr) {
436         TELEPHONY_LOGE("function Remote() return nullptr!");
437         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
438     }
439     int32_t error = Remote()->SendRequest(static_cast<uint32_t>(
440         CallManagerCallAbilityInterfaceCode::CAMERA_CAPABILITIES_CHANGE), dataParcel,
441         replyParcel, option);
442     if (error != TELEPHONY_SUCCESS) {
443         TELEPHONY_LOGE("report async results failed, error: %{public}d", error);
444         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
445     }
446     return replyParcel.ReadInt32();
447 }
448 
OnPhoneStateChange(int32_t numActive,int32_t numHeld,int32_t callState,const std::string & number)449 int32_t CallAbilityCallbackProxy::OnPhoneStateChange(int32_t numActive, int32_t numHeld, int32_t callState,
450     const std::string &number)
451 {
452     MessageParcel dataParcel;
453     MessageParcel replyParcel;
454     MessageOption option(MessageOption::TF_ASYNC);
455     if (!dataParcel.WriteInterfaceToken(CallAbilityCallbackProxy::GetDescriptor())) {
456         TELEPHONY_LOGE("write descriptor fail");
457         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
458     }
459     dataParcel.WriteInt32(numActive);
460     dataParcel.WriteInt32(numHeld);
461     dataParcel.WriteInt32(callState);
462     dataParcel.WriteString(number);
463     if (Remote() == nullptr) {
464         TELEPHONY_LOGE("function Remote() return nullptr!");
465         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
466     }
467     int32_t error = Remote()->SendRequest(static_cast<uint32_t>(
468         CallManagerCallAbilityInterfaceCode::UPDATE_PHONE_STATE), dataParcel,
469         replyParcel, option);
470     if (error != TELEPHONY_SUCCESS) {
471         TELEPHONY_LOGE("report async results failed, error: %{public}d", error);
472         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
473     }
474     return replyParcel.ReadInt32();
475 }
476 } // namespace Telephony
477 } // namespace OHOS
478