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