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 #include "telephony_cust_wrapper.h"
23
24 #include "message_option.h"
25 #include "message_parcel.h"
26
27 #include "call_control_manager.h"
28
29 #ifdef HICOLLIE_ENABLE
30 #include "xcollie/xcollie.h"
31 #include "xcollie/xcollie_define.h"
32 #define XCOLLIE_TIMEOUT_SECONDS 30
33 #endif
34
35 namespace OHOS {
36 namespace Telephony {
37 const int32_t MAX_CALLS_NUM = 5;
38
CallManagerServiceStub()39 CallManagerServiceStub::CallManagerServiceStub()
40 {
41 InitCallBasicRequest();
42 InitCallUtilsRequest();
43 InitCallConferenceRequest();
44 InitCallDtmfRequest();
45 InitCallSupplementRequest();
46 initCallConferenceExRequest();
47 InitCallMultimediaRequest();
48 InitImsServiceRequest();
49 InitOttServiceRequest();
50 InitVoipOperationRequest();
51 InitBluetoothOperationRequest();
52 memberFuncMap_[INTERFACE_GET_PROXY_OBJECT_PTR] =
53 [this](MessageParcel &data, MessageParcel &reply) { return OnGetProxyObjectPtr(data, reply); };
54 }
55
~CallManagerServiceStub()56 CallManagerServiceStub::~CallManagerServiceStub()
57 {
58 memberFuncMap_.clear();
59 }
60
InitCallBasicRequest()61 void CallManagerServiceStub::InitCallBasicRequest()
62 {
63 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_REGISTER_CALLBACK)] =
64 [this](MessageParcel &data, MessageParcel &reply) { return OnRegisterCallBack(data, reply); };
65 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_UNREGISTER_CALLBACK)] =
66 [this](MessageParcel &data, MessageParcel &reply) { return OnUnRegisterCallBack(data, reply); };
67 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_DIAL_CALL)] =
68 [this](MessageParcel &data, MessageParcel &reply) { return OnDialCall(data, reply); };
69 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_MAKE_CALL)] =
70 [this](MessageParcel &data, MessageParcel &reply) { return OnMakeCall(data, reply); };
71 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_ANSWER_CALL)] =
72 [this](MessageParcel &data, MessageParcel &reply) { return OnAcceptCall(data, reply); };
73 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_REJECT_CALL)] =
74 [this](MessageParcel &data, MessageParcel &reply) { return OnRejectCall(data, reply); };
75 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_HOLD_CALL)] =
76 [this](MessageParcel &data, MessageParcel &reply) { return OnHoldCall(data, reply); };
77 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_UNHOLD_CALL)] =
78 [this](MessageParcel &data, MessageParcel &reply) { return OnUnHoldCall(data, reply); };
79 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_DISCONNECT_CALL)] =
80 [this](MessageParcel &data, MessageParcel &reply) { return OnHangUpCall(data, reply); };
81 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_GET_CALL_STATE)] =
82 [this](MessageParcel &data, MessageParcel &reply) { return OnGetCallState(data, reply); };
83 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_SWAP_CALL)] =
84 [this](MessageParcel &data, MessageParcel &reply) { return OnSwitchCall(data, reply); };
85 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_INPUT_DIALER_SPECIAL_CODE)] =
86 [this](MessageParcel &data, MessageParcel &reply) { return OnInputDialerSpecialCode(data, reply); };
87 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_SEND_CALLUI_EVENT)] =
88 [this](MessageParcel &data, MessageParcel &reply) { return OnSendCallUiEvent(data, reply); };
89 }
90
InitCallUtilsRequest()91 void CallManagerServiceStub::InitCallUtilsRequest()
92 {
93 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_HAS_CALL)] =
94 [this](MessageParcel &data, MessageParcel &reply) { return OnHasCall(data, reply); };
95 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_IS_NEW_CALL_ALLOWED)] =
96 [this](MessageParcel &data, MessageParcel &reply) { return OnIsNewCallAllowed(data, reply); };
97 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_IS_RINGING)] =
98 [this](MessageParcel &data, MessageParcel &reply) { return OnIsRinging(data, reply); };
99 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_IS_EMERGENCY_CALL)] =
100 [this](MessageParcel &data, MessageParcel &reply) { return OnIsInEmergencyCall(data, reply); };
101 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_IS_EMERGENCY_NUMBER)] =
102 [this](MessageParcel &data, MessageParcel &reply) { return OnIsEmergencyPhoneNumber(data, reply); };
103 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_IS_FORMAT_NUMBER)] =
104 [this](MessageParcel &data, MessageParcel &reply) { return OnFormatPhoneNumber(data, reply); };
105 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_IS_FORMAT_NUMBER_E164)] =
106 [this](MessageParcel &data, MessageParcel &reply) { return OnFormatPhoneNumberToE164(data, reply); };
107 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_CANCEL_MISSED_INCOMING_CALL_NOTIFICATION)] =
108 [this](
109 MessageParcel &data, MessageParcel &reply) { return OnRemoveMissedIncomingCallNotification(data, reply); };
110 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_OBSERVER_ON_CALL_DETAILS_CHANGE)] =
111 [this](MessageParcel &data, MessageParcel &reply) { return OnObserverOnCallDetailsChange(data, reply); };
112 }
113
InitCallConferenceRequest()114 void CallManagerServiceStub::InitCallConferenceRequest()
115 {
116 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_COMBINE_CONFERENCE)] =
117 [this](MessageParcel &data, MessageParcel &reply) { return OnCombineConference(data, reply); };
118 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_SEPARATE_CONFERENCE)] =
119 [this](MessageParcel &data, MessageParcel &reply) { return OnSeparateConference(data, reply); };
120 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_JOIN_CONFERENCE)] =
121 [this](MessageParcel &data, MessageParcel &reply) { return OnJoinConference(data, reply); };
122 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_KICK_OUT_CONFERENCE)] =
123 [this](MessageParcel &data, MessageParcel &reply) { return OnKickOutFromConference(data, reply); };
124 }
125
InitCallDtmfRequest()126 void CallManagerServiceStub::InitCallDtmfRequest()
127 {
128 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_START_DTMF)] =
129 [this](MessageParcel &data, MessageParcel &reply) { return OnStartDtmf(data, reply); };
130 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_STOP_DTMF)] =
131 [this](MessageParcel &data, MessageParcel &reply) { return OnStopDtmf(data, reply); };
132 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_POST_DIAL_PROCEED)] =
133 [this](MessageParcel &data, MessageParcel &reply) { return OnPostDialProceed(data, reply); };
134 }
135
InitCallSupplementRequest()136 void CallManagerServiceStub::InitCallSupplementRequest()
137 {
138 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_GET_CALL_WAITING)] =
139 [this](MessageParcel &data, MessageParcel &reply) { return OnGetCallWaiting(data, reply); };
140 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_SET_CALL_WAITING)] =
141 [this](MessageParcel &data, MessageParcel &reply) { return OnSetCallWaiting(data, reply); };
142 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_GET_CALL_RESTRICTION)] =
143 [this](MessageParcel &data, MessageParcel &reply) { return OnGetCallRestriction(data, reply); };
144 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_SET_CALL_RESTRICTION)] =
145 [this](MessageParcel &data, MessageParcel &reply) { return OnSetCallRestriction(data, reply); };
146 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_SET_CALL_RESTRICTION_PASSWORD)] =
147 [this](MessageParcel &data, MessageParcel &reply) { return OnSetCallRestrictionPassword(data, reply); };
148 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_GET_CALL_TRANSFER)] =
149 [this](MessageParcel &data, MessageParcel &reply) { return OnGetTransferNumber(data, reply); };
150 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_SET_CALL_TRANSFER)] =
151 [this](MessageParcel &data, MessageParcel &reply) { return OnSetTransferNumber(data, reply); };
152 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_CAN_SET_CALL_TRANSFER_TIME)] =
153 [this](MessageParcel &data, MessageParcel &reply) { return OnCanSetCallTransferTime(data, reply); };
154 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_CLOSE_UNFINISHED_USSD)] =
155 [this](MessageParcel &data, MessageParcel &reply) { return OnCloseUnFinishedUssd(data, reply); };
156 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_SEND_USSD_RESPONSE)] =
157 [this](MessageParcel &data, MessageParcel &reply) { return OnSendUssdResponse(data, reply); };
158 }
159
initCallConferenceExRequest()160 void CallManagerServiceStub::initCallConferenceExRequest()
161 {
162 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_GET_MAINID)] =
163 [this](MessageParcel &data, MessageParcel &reply) { return OnGetMainCallId(data, reply); };
164 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_GET_SUBCALL_LIST_ID)] =
165 [this](MessageParcel &data, MessageParcel &reply) { return OnGetSubCallIdList(data, reply); };
166 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_GET_CALL_LIST_ID_FOR_CONFERENCE)] =
167 [this](MessageParcel &data, MessageParcel &reply) { return OnGetCallIdListForConference(data, reply); };
168 }
169
InitCallMultimediaRequest()170 void CallManagerServiceStub::InitCallMultimediaRequest()
171 {
172 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_SET_MUTE)] =
173 [this](MessageParcel &data, MessageParcel &reply) { return OnSetMute(data, reply); };
174 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_MUTE_RINGER)] =
175 [this](MessageParcel &data, MessageParcel &reply) { return OnMuteRinger(data, reply); };
176 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_SET_AUDIO_DEVICE)] =
177 [this](MessageParcel &data, MessageParcel &reply) { return OnSetAudioDevice(data, reply); };
178 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_CTRL_CAMERA)] =
179 [this](MessageParcel &data, MessageParcel &reply) { return OnControlCamera(data, reply); };
180 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_SET_PREVIEW_WINDOW)] =
181 [this](MessageParcel &data, MessageParcel &reply) { return OnSetPreviewWindow(data, reply); };
182 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_SET_DISPLAY_WINDOW)] =
183 [this](MessageParcel &data, MessageParcel &reply) { return OnSetDisplayWindow(data, reply); };
184 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_SET_CAMERA_ZOOM)] =
185 [this](MessageParcel &data, MessageParcel &reply) { return OnSetCameraZoom(data, reply); };
186 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_SET_PAUSE_IMAGE)] =
187 [this](MessageParcel &data, MessageParcel &reply) { return OnSetPausePicture(data, reply); };
188 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_SET_DEVICE_DIRECTION)] =
189 [this](MessageParcel &data, MessageParcel &reply) { return OnSetDeviceDirection(data, reply); };
190 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_UPDATE_CALL_MEDIA_MODE)] =
191 [this](MessageParcel &data, MessageParcel &reply) { return OnUpdateCallMediaMode(data, reply); };
192 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_REPORT_AUDIO_DEVICE_INFO)] =
193 [this](MessageParcel &data, MessageParcel &reply) { return OnReportAudioDeviceInfo(data, reply); };
194 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_CANCEL_CALL_UPGRADE)] =
195 [this](MessageParcel &data, MessageParcel &reply) { return OnCancelCallUpgrade(data, reply); };
196 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_REQUEST_CAMERA_CAPABILITIES)] =
197 [this](MessageParcel &data, MessageParcel &reply) { return OnRequestCameraCapabilities(data, reply); };
198 }
199
InitImsServiceRequest()200 void CallManagerServiceStub::InitImsServiceRequest()
201 {
202 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_SETCALL_PREFERENCEMODE)] =
203 [this](MessageParcel &data, MessageParcel &reply) { return OnSetCallPreferenceMode(data, reply); };
204 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_GET_IMS_CONFIG)] =
205 [this](MessageParcel &data, MessageParcel &reply) { return OnGetImsConfig(data, reply); };
206 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_SET_IMS_CONFIG)] =
207 [this](MessageParcel &data, MessageParcel &reply) { return OnSetImsConfig(data, reply); };
208 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_GET_IMS_FEATURE_VALUE)] =
209 [this](MessageParcel &data, MessageParcel &reply) { return OnGetImsFeatureValue(data, reply); };
210 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_SET_IMS_FEATURE_VALUE)] =
211 [this](MessageParcel &data, MessageParcel &reply) { return OnSetImsFeatureValue(data, reply); };
212 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_ENABLE_VOLTE)] =
213 [this](MessageParcel &data, MessageParcel &reply) { return OnEnableVoLte(data, reply); };
214 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_DISABLE_VOLTE)] =
215 [this](MessageParcel &data, MessageParcel &reply) { return OnDisableVoLte(data, reply); };
216 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_IS_VOLTE_ENABLED)] =
217 [this](MessageParcel &data, MessageParcel &reply) { return OnIsVoLteEnabled(data, reply); };
218 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_SET_VONR_STATE)] =
219 [this](MessageParcel &data, MessageParcel &reply) { return OnSetVoNRState(data, reply); };
220 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_GET_VONR_STATE)] =
221 [this](MessageParcel &data, MessageParcel &reply) { return OnGetVoNRState(data, reply); };
222 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_START_RTT)] =
223 [this](MessageParcel &data, MessageParcel &reply) { return OnStartRtt(data, reply); };
224 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_STOP_RTT)] =
225 [this](MessageParcel &data, MessageParcel &reply) { return OnStopRtt(data, reply); };
226 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_SET_VOIP_CALL_STATE)] =
227 [this](MessageParcel &data, MessageParcel &reply) { return OnSetVoIPCallState(data, reply); };
228 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_GET_VOIP_CALL_STATE)] =
229 [this](MessageParcel &data, MessageParcel &reply) { return OnGetVoIPCallState(data, reply); };
230 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_SET_VOIP_CALL_INFO)] =
231 [this](MessageParcel &data, MessageParcel &reply) { return OnSetVoIPCallInfo(data, reply); };
232 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_GET_VOIP_CALL_INFO)] =
233 [this](MessageParcel &data, MessageParcel &reply) { return OnGetVoIPCallInfo(data, reply); };
234 }
235
InitOttServiceRequest()236 void CallManagerServiceStub::InitOttServiceRequest()
237 {
238 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_REPORT_OTT_CALL_DETAIL_INFO)] =
239 [this](MessageParcel &data, MessageParcel &reply) { return OnReportOttCallDetailsInfo(data, reply); };
240 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_REPORT_OTT_CALL_EVENT_INFO)] =
241 [this](MessageParcel &data, MessageParcel &reply) { return OnReportOttCallEventInfo(data, reply); };
242 }
243
InitVoipOperationRequest()244 void CallManagerServiceStub::InitVoipOperationRequest()
245 {
246 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_VOIP_REGISTER_CALLBACK)] =
247 [this](MessageParcel &data, MessageParcel &reply) { return OnRegisterVoipCallManagerCallback(data, reply); };
248 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_VOIP_UNREGISTER_CALLBACK)] =
249 [this](MessageParcel &data, MessageParcel &reply) { return OnUnRegisterVoipCallManagerCallback(data, reply); };
250 }
251
InitBluetoothOperationRequest()252 void CallManagerServiceStub::InitBluetoothOperationRequest()
253 {
254 memberFuncMap_[static_cast<int32_t>(CallManagerInterfaceCode::INTERFACE_BLUETOOTH_REGISTER_CALLBACKPTR)] =
255 [this](MessageParcel &data, MessageParcel &reply) {
256 return OnRegisterBluetoothCallManagerCallbackPtr(data, reply);
257 };
258 }
259
OnRegisterVoipCallManagerCallback(MessageParcel & data,MessageParcel & reply)260 int32_t CallManagerServiceStub::OnRegisterVoipCallManagerCallback(MessageParcel &data, MessageParcel &reply)
261 {
262 int32_t result = RegisterVoipCallManagerCallback();
263 TELEPHONY_LOGI("OnRegisterVoipCallManagerCallback result:%{public}d", result);
264 if (!reply.WriteInt32(result)) {
265 TELEPHONY_LOGE("OnRegisterVoipCallManagerCallback write reply failed.");
266 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
267 }
268
269 return TELEPHONY_SUCCESS;
270 }
271
OnUnRegisterVoipCallManagerCallback(MessageParcel & data,MessageParcel & reply)272 int32_t CallManagerServiceStub::OnUnRegisterVoipCallManagerCallback(MessageParcel &data, MessageParcel &reply)
273 {
274 int32_t result = TELEPHONY_ERR_FAIL;
275 result = UnRegisterVoipCallManagerCallback();
276 if (!reply.WriteInt32(result)) {
277 TELEPHONY_LOGE("fail to write parcel");
278 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
279 }
280 return result;
281 }
282
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)283 int32_t CallManagerServiceStub::OnRemoteRequest(
284 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
285 {
286 std::u16string myDescriptor = CallManagerServiceStub::GetDescriptor();
287 std::u16string remoteDescriptor = data.ReadInterfaceToken();
288 if (myDescriptor != remoteDescriptor) {
289 TELEPHONY_LOGE("descriptor checked fail !");
290 return TELEPHONY_ERR_DESCRIPTOR_MISMATCH;
291 }
292 TELEPHONY_LOGD("OnReceived, cmd = %{public}u", code);
293 auto itFunc = memberFuncMap_.find(code);
294 if (itFunc != memberFuncMap_.end()) {
295 auto memberFunc = itFunc->second;
296 if (memberFunc != nullptr) {
297 int32_t idTimer = SetTimer(code);
298 int32_t result = memberFunc(data, reply);
299 CancelTimer(idTimer);
300 return result;
301 }
302 }
303 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
304 }
305
OnRegisterCallBack(MessageParcel & data,MessageParcel & reply)306 int32_t CallManagerServiceStub::OnRegisterCallBack(MessageParcel &data, MessageParcel &reply)
307 {
308 int32_t result = TELEPHONY_ERR_FAIL;
309 sptr<IRemoteObject> remote = data.ReadRemoteObject();
310 if (remote == nullptr) {
311 TELEPHONY_LOGE("callback ptr is nullptr.");
312 reply.WriteInt32(result);
313 return result;
314 }
315 sptr<ICallAbilityCallback> callback = iface_cast<ICallAbilityCallback>(remote);
316 result = RegisterCallBack(callback);
317 reply.WriteInt32(result);
318 return result;
319 }
320
OnUnRegisterCallBack(MessageParcel & data,MessageParcel & reply)321 int32_t CallManagerServiceStub::OnUnRegisterCallBack(MessageParcel &data, MessageParcel &reply)
322 {
323 int32_t result = TELEPHONY_ERR_FAIL;
324 result = UnRegisterCallBack();
325 if (!reply.WriteInt32(result)) {
326 TELEPHONY_LOGE("fail to write parcel");
327 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
328 }
329 return result;
330 }
331
OnObserverOnCallDetailsChange(MessageParcel & data,MessageParcel & reply)332 int32_t CallManagerServiceStub::OnObserverOnCallDetailsChange(MessageParcel &data, MessageParcel &reply)
333 {
334 int32_t result = TELEPHONY_ERR_FAIL;
335 result = ObserverOnCallDetailsChange();
336 if (!reply.WriteInt32(result)) {
337 TELEPHONY_LOGE("fail to write parcel");
338 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
339 }
340 return result;
341 }
342
OnDialCall(MessageParcel & data,MessageParcel & reply)343 int32_t CallManagerServiceStub::OnDialCall(MessageParcel &data, MessageParcel &reply)
344 {
345 int32_t result = TELEPHONY_ERR_FAIL;
346 AppExecFwk::PacMap dialInfo;
347 std::u16string callNumber = data.ReadString16();
348 dialInfo.PutIntValue("accountId", data.ReadInt32());
349 dialInfo.PutIntValue("videoState", data.ReadInt32());
350 dialInfo.PutIntValue("dialScene", data.ReadInt32());
351 dialInfo.PutIntValue("dialType", data.ReadInt32());
352 dialInfo.PutIntValue("callType", data.ReadInt32());
353 dialInfo.PutStringValue("extraParams", data.ReadString());
354 dialInfo.PutStringValue("bundleName", data.ReadString());
355 if (callNumber.length() > ACCOUNT_NUMBER_MAX_LENGTH) {
356 TELEPHONY_LOGE("the account number length exceeds the limit");
357 return CALL_ERR_NUMBER_OUT_OF_RANGE;
358 }
359 if (TELEPHONY_CUST_WRAPPER.isChangeDialNumberToTwEmc_ != nullptr
360 && TELEPHONY_CUST_WRAPPER.isChangeDialNumberToTwEmc_(callNumber, dialInfo.GetIntValue("accountId"))) {
361 TELEPHONY_LOGI("changed dial num to tw emc");
362 }
363 result = DialCall(callNumber, dialInfo);
364 TELEPHONY_LOGI("result:%{public}d", result);
365 if (!reply.WriteInt32(result)) {
366 TELEPHONY_LOGE("fail to write parcel");
367 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
368 }
369 return result;
370 }
371
OnMakeCall(MessageParcel & data,MessageParcel & reply)372 int32_t CallManagerServiceStub::OnMakeCall(MessageParcel &data, MessageParcel &reply)
373 {
374 int32_t result = TELEPHONY_ERR_FAIL;
375 AppExecFwk::PacMap dialInfo;
376 std::string callNumber = data.ReadString();
377 if (callNumber.length() > ACCOUNT_NUMBER_MAX_LENGTH) {
378 TELEPHONY_LOGE("the account number length exceeds the limit");
379 return CALL_ERR_NUMBER_OUT_OF_RANGE;
380 }
381 result = MakeCall(callNumber);
382 TELEPHONY_LOGI("result:%{public}d", result);
383 if (!reply.WriteInt32(result)) {
384 TELEPHONY_LOGE("fail to write parcel");
385 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
386 }
387 return result;
388 }
389
OnAcceptCall(MessageParcel & data,MessageParcel & reply)390 int32_t CallManagerServiceStub::OnAcceptCall(MessageParcel &data, MessageParcel &reply)
391 {
392 int32_t callId = data.ReadInt32();
393 int32_t videoState = data.ReadInt32();
394 int32_t result = AnswerCall(callId, videoState);
395 TELEPHONY_LOGI("result:%{public}d", result);
396 if (!reply.WriteInt32(result)) {
397 TELEPHONY_LOGE("fail to write parcel");
398 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
399 }
400 return result;
401 }
402
OnRejectCall(MessageParcel & data,MessageParcel & reply)403 int32_t CallManagerServiceStub::OnRejectCall(MessageParcel &data, MessageParcel &reply)
404 {
405 int32_t callId = data.ReadInt32();
406 bool isSendSms = data.ReadBool();
407 std::u16string content = data.ReadString16();
408 int32_t result = RejectCall(callId, isSendSms, content);
409 TELEPHONY_LOGI("result:%{public}d", result);
410 if (!reply.WriteInt32(result)) {
411 TELEPHONY_LOGE("fail to write parcel");
412 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
413 }
414 return result;
415 }
416
OnHangUpCall(MessageParcel & data,MessageParcel & reply)417 int32_t CallManagerServiceStub::OnHangUpCall(MessageParcel &data, MessageParcel &reply)
418 {
419 int32_t callId = data.ReadInt32();
420 int32_t result = HangUpCall(callId);
421 TELEPHONY_LOGI("result:%{public}d", result);
422 if (!reply.WriteInt32(result)) {
423 TELEPHONY_LOGE("fail to write parcel");
424 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
425 }
426 return result;
427 }
428
OnGetCallState(MessageParcel & data,MessageParcel & reply)429 int32_t CallManagerServiceStub::OnGetCallState(MessageParcel &data, MessageParcel &reply)
430 {
431 int32_t result = GetCallState();
432 TELEPHONY_LOGD("result:%{public}d", result);
433 if (!reply.WriteInt32(result)) {
434 TELEPHONY_LOGE("fail to write parcel");
435 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
436 }
437 return TELEPHONY_SUCCESS;
438 }
439
OnHoldCall(MessageParcel & data,MessageParcel & reply)440 int32_t CallManagerServiceStub::OnHoldCall(MessageParcel &data, MessageParcel &reply)
441 {
442 int32_t callId = data.ReadInt32();
443 int32_t result = HoldCall(callId);
444 TELEPHONY_LOGI("result:%{public}d", result);
445 if (!reply.WriteInt32(result)) {
446 TELEPHONY_LOGE("fail to write parcel");
447 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
448 }
449 return result;
450 }
451
OnUnHoldCall(MessageParcel & data,MessageParcel & reply)452 int32_t CallManagerServiceStub::OnUnHoldCall(MessageParcel &data, MessageParcel &reply)
453 {
454 int32_t callId = data.ReadInt32();
455 int32_t result = UnHoldCall(callId);
456 TELEPHONY_LOGI("result:%{public}d", result);
457 if (!reply.WriteInt32(result)) {
458 TELEPHONY_LOGE("fail to write parcel");
459 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
460 }
461 return result;
462 }
463
OnSwitchCall(MessageParcel & data,MessageParcel & reply)464 int32_t CallManagerServiceStub::OnSwitchCall(MessageParcel &data, MessageParcel &reply)
465 {
466 int32_t callId = data.ReadInt32();
467 int32_t result = SwitchCall(callId);
468 TELEPHONY_LOGI("result:%{public}d", result);
469 if (!reply.WriteInt32(result)) {
470 TELEPHONY_LOGE("fail to write parcel");
471 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
472 }
473 return result;
474 }
475
OnHasCall(MessageParcel & data,MessageParcel & reply)476 int32_t CallManagerServiceStub::OnHasCall(MessageParcel &data, MessageParcel &reply)
477 {
478 bool result = HasCall();
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 exit(1);
1433 };
1434 idTimer = HiviewDFX::XCollie::GetInstance().SetTimer(
1435 collieName, XCOLLIE_TIMEOUT_SECONDS, TimerCallback, nullptr, flag);
1436 TELEPHONY_LOGD("SetTimer id: %{public}d, name: %{public}s.", idTimer, collieStr.c_str());
1437 }
1438 return idTimer;
1439 #else
1440 TELEPHONY_LOGD("No HICOLLIE_ENABLE");
1441 return -1;
1442 #endif
1443 }
1444
CancelTimer(int32_t id)1445 void CallManagerServiceStub::CancelTimer(int32_t id)
1446 {
1447 #ifdef HICOLLIE_ENABLE
1448 if (id == HiviewDFX::INVALID_ID) {
1449 return;
1450 }
1451 TELEPHONY_LOGD("CancelTimer id: %{public}d.", id);
1452 HiviewDFX::XCollie::GetInstance().CancelTimer(id);
1453 #else
1454 return;
1455 #endif
1456 }
1457
OnRegisterBluetoothCallManagerCallbackPtr(MessageParcel & data,MessageParcel & reply)1458 int32_t CallManagerServiceStub::OnRegisterBluetoothCallManagerCallbackPtr(MessageParcel &data, MessageParcel &reply)
1459 {
1460 std::string macAddress = data.ReadString();
1461 sptr<ICallStatusCallback> callback = RegisterBluetoothCallManagerCallbackPtr(macAddress);
1462 if (callback == nullptr) {
1463 TELEPHONY_LOGE("OnRegisterBluetoothCallManagerCallbackPtr fail.");
1464 return TELEPHONY_ERR_FAIL;
1465 }
1466 sptr<IRemoteObject> objectPtr = callback->AsObject().GetRefPtr();
1467 if (objectPtr == nullptr) {
1468 TELEPHONY_LOGE("RegisterBluetoothCallManagerCallbackPtr faild!");
1469 }
1470 if (!reply.WriteRemoteObject(objectPtr)) {
1471 TELEPHONY_LOGE("OnRegisterBluetoothCallManagerCallbackPtr fail to write parcel");
1472 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1473 }
1474 return TELEPHONY_SUCCESS;
1475 }
1476
OnSendUssdResponse(MessageParcel & data,MessageParcel & reply)1477 int32_t CallManagerServiceStub::OnSendUssdResponse(MessageParcel &data, MessageParcel &reply)
1478 {
1479 int32_t result = TELEPHONY_ERR_FAIL;
1480 int32_t slotId = data.ReadInt32();
1481 std::string content = data.ReadString();
1482 result = SendUssdResponse(slotId, content);
1483 TELEPHONY_LOGI("result:%{public}d", result);
1484 if (!reply.WriteInt32(result)) {
1485 TELEPHONY_LOGE("fail to write parcel");
1486 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
1487 }
1488 return result;
1489 }
1490 } // namespace Telephony
1491 } // namespace OHOS
1492