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