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