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