• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021-2023 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 "cellular_call_stub.h"
17 
18 #include "call_manager_errors.h"
19 #include "call_status_callback_proxy.h"
20 #include "emergency_utils.h"
21 #include "ipc_skeleton.h"
22 #include "i_call_status_callback.h"
23 #include "telephony_log_wrapper.h"
24 #include "telephony_permission.h"
25 
26 namespace OHOS {
27 namespace Telephony {
28 const int32_t MAX_SIZE = 10;
29 const int32_t MAX_ECC_SIZE = 1000;
30 const int32_t FOUNDATION_UID = 5523;
31 const int32_t MAX_CALL_NUM = 10;
32 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)33 int32_t CellularCallStub::OnRemoteRequest(
34     uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
35 {
36     std::u16string myDescriptor = CellularCallStub::GetDescriptor();
37     std::u16string remoteDescriptor = data.ReadInterfaceToken();
38     if (myDescriptor != remoteDescriptor) {
39         TELEPHONY_LOGE("descriptor checked fail");
40         return TELEPHONY_ERR_DESCRIPTOR_MISMATCH;
41     }
42 
43     auto itFunc = requestFuncMap_.find(static_cast<CellularCallInterfaceCode>(code));
44     if (itFunc != requestFuncMap_.end()) {
45         auto callingUid = IPCSkeleton::GetCallingUid();
46         if (callingUid != FOUNDATION_UID &&
47             !TelephonyPermission::CheckPermission(Permission::CONNECT_CELLULAR_CALL_SERVICE)) {
48             TELEPHONY_LOGE("Check permission failed, no CONNECT_CELLULAR_CALL_SERVICE permisson.");
49             return TELEPHONY_ERR_PERMISSION_ERR;
50         }
51         auto requestFunc = itFunc->second;
52         if (requestFunc != nullptr) {
53             return (this->*requestFunc)(data, reply);
54         }
55     }
56     TELEPHONY_LOGI("CellularCallStub::OnRemoteRequest, default case, need check.");
57     return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
58 }
59 
CellularCallStub()60 CellularCallStub::CellularCallStub()
61 {
62     TELEPHONY_LOGI("CellularCallStub::CellularCallStub");
63     InitFuncMap();
64 }
65 
~CellularCallStub()66 CellularCallStub::~CellularCallStub()
67 {
68     TELEPHONY_LOGI("CellularCallStub::~CellularCallStub");
69     requestFuncMap_.clear();
70 }
71 
InitFuncMap()72 void CellularCallStub::InitFuncMap()
73 {
74     InitDialFuncMap();
75     InitDtmfFuncMap();
76     InitConfigFuncMap();
77     InitVideoFuncMap();
78     InitSupplementFuncMap();
79 }
80 
InitDialFuncMap()81 void CellularCallStub::InitDialFuncMap()
82 {
83     requestFuncMap_[CellularCallInterfaceCode::DIAL] = &CellularCallStub::OnDialInner;
84     requestFuncMap_[CellularCallInterfaceCode::HANG_UP] = &CellularCallStub::OnHangUpInner;
85     requestFuncMap_[CellularCallInterfaceCode::REJECT] = &CellularCallStub::OnRejectInner;
86     requestFuncMap_[CellularCallInterfaceCode::ANSWER] = &CellularCallStub::OnAnswerInner;
87     requestFuncMap_[CellularCallInterfaceCode::EMERGENCY_CALL] = &CellularCallStub::OnIsEmergencyPhoneNumberInner;
88     requestFuncMap_[CellularCallInterfaceCode::SET_EMERGENCY_CALL_LIST] = &CellularCallStub::OnSetEmergencyCallList;
89     requestFuncMap_[CellularCallInterfaceCode::HOLD_CALL] = &CellularCallStub::OnHoldCallInner;
90     requestFuncMap_[CellularCallInterfaceCode::UN_HOLD_CALL] = &CellularCallStub::OnUnHoldCallInner;
91     requestFuncMap_[CellularCallInterfaceCode::SWITCH_CALL] = &CellularCallStub::OnSwitchCallInner;
92     requestFuncMap_[CellularCallInterfaceCode::COMBINE_CONFERENCE] = &CellularCallStub::OnCombineConferenceInner;
93     requestFuncMap_[CellularCallInterfaceCode::SEPARATE_CONFERENCE] = &CellularCallStub::OnSeparateConferenceInner;
94     requestFuncMap_[CellularCallInterfaceCode::INVITE_TO_CONFERENCE] = &CellularCallStub::OnInviteToConferenceInner;
95     requestFuncMap_[CellularCallInterfaceCode::KICK_OUT_CONFERENCE] = &CellularCallStub::OnKickOutFromConferenceInner;
96     requestFuncMap_[CellularCallInterfaceCode::HANG_UP_ALL_CONNECTION] = &CellularCallStub::OnHangUpAllConnectionInner;
97     requestFuncMap_[CellularCallInterfaceCode::SET_READY_TO_CALL] = &CellularCallStub::OnSetReadyToCallInner;
98     requestFuncMap_[CellularCallInterfaceCode::CLEAR_ALL_CALLS] = &CellularCallStub::OnClearAllCallsInner;
99 }
100 
InitDtmfFuncMap()101 void CellularCallStub::InitDtmfFuncMap()
102 {
103     requestFuncMap_[CellularCallInterfaceCode::START_DTMF] = &CellularCallStub::OnStartDtmfInner;
104     requestFuncMap_[CellularCallInterfaceCode::STOP_DTMF] = &CellularCallStub::OnStopDtmfInner;
105     requestFuncMap_[CellularCallInterfaceCode::POST_DIAL_PROCEED] = &CellularCallStub::OnPostDialProceedInner;
106     requestFuncMap_[CellularCallInterfaceCode::SEND_DTMF] = &CellularCallStub::OnSendDtmfInner;
107     requestFuncMap_[CellularCallInterfaceCode::START_RTT] = &CellularCallStub::OnStartRttInner;
108     requestFuncMap_[CellularCallInterfaceCode::STOP_RTT] = &CellularCallStub::OnStopRttInner;
109 }
110 
InitConfigFuncMap()111 void CellularCallStub::InitConfigFuncMap()
112 {
113     requestFuncMap_[CellularCallInterfaceCode::SET_DOMAIN_PREFERENCE_MODE] =
114         &CellularCallStub::OnSetDomainPreferenceModeInner;
115     requestFuncMap_[CellularCallInterfaceCode::GET_DOMAIN_PREFERENCE_MODE] =
116         &CellularCallStub::OnGetDomainPreferenceModeInner;
117     requestFuncMap_[CellularCallInterfaceCode::SET_IMS_SWITCH_STATUS] = &CellularCallStub::OnSetImsSwitchStatusInner;
118     requestFuncMap_[CellularCallInterfaceCode::GET_IMS_SWITCH_STATUS] = &CellularCallStub::OnGetImsSwitchStatusInner;
119     requestFuncMap_[CellularCallInterfaceCode::SET_VONR_SWITCH_STATUS] = &CellularCallStub::OnSetVoNRStateInner;
120     requestFuncMap_[CellularCallInterfaceCode::GET_VONR_SWITCH_STATUS] = &CellularCallStub::OnGetVoNRStateInner;
121     requestFuncMap_[CellularCallInterfaceCode::SET_IMS_CONFIG_STRING] = &CellularCallStub::OnSetImsConfigStringInner;
122     requestFuncMap_[CellularCallInterfaceCode::SET_IMS_CONFIG_INT] = &CellularCallStub::OnSetImsConfigIntInner;
123     requestFuncMap_[CellularCallInterfaceCode::GET_IMS_CONFIG] = &CellularCallStub::OnGetImsConfigInner;
124     requestFuncMap_[CellularCallInterfaceCode::SET_IMS_FEATURE] = &CellularCallStub::OnSetImsFeatureValueInner;
125     requestFuncMap_[CellularCallInterfaceCode::GET_IMS_FEATURE] = &CellularCallStub::OnGetImsFeatureValueInner;
126     requestFuncMap_[CellularCallInterfaceCode::SET_MUTE] = &CellularCallStub::OnSetMuteInner;
127     requestFuncMap_[CellularCallInterfaceCode::GET_MUTE] = &CellularCallStub::OnGetMuteInner;
128 }
129 
InitVideoFuncMap()130 void CellularCallStub::InitVideoFuncMap()
131 {
132     requestFuncMap_[CellularCallInterfaceCode::CTRL_CAMERA] = &CellularCallStub::OnControlCameraInner;
133     requestFuncMap_[CellularCallInterfaceCode::SET_PREVIEW_WINDOW] = &CellularCallStub::OnSetPreviewWindowInner;
134     requestFuncMap_[CellularCallInterfaceCode::SET_DISPLAY_WINDOW] = &CellularCallStub::OnSetDisplayWindowInner;
135     requestFuncMap_[CellularCallInterfaceCode::SET_CAMERA_ZOOM] = &CellularCallStub::OnSetCameraZoomInner;
136     requestFuncMap_[CellularCallInterfaceCode::SET_PAUSE_IMAGE] = &CellularCallStub::OnSetPausePictureInner;
137     requestFuncMap_[CellularCallInterfaceCode::SET_DEVICE_DIRECTION] = &CellularCallStub::OnSetDeviceDirectionInner;
138     requestFuncMap_[CellularCallInterfaceCode::SEND_CALL_MEDIA_MODE_REQUEST] =
139         &CellularCallStub::OnSendUpdateCallMediaModeRequestInner;
140     requestFuncMap_[CellularCallInterfaceCode::SEND_CALL_MEDIA_MODE_RESPONSE] =
141         &CellularCallStub::OnSendUpdateCallMediaModeResponseInner;
142     requestFuncMap_[CellularCallInterfaceCode::CANCEL_CALL_UPGRADE] = &CellularCallStub::OnCancelCallUpgradeInner;
143     requestFuncMap_[CellularCallInterfaceCode::REQUEST_CAMERA_CAPABILITY] =
144         &CellularCallStub::OnRequestCameraCapabilitiesInner;
145 }
146 
InitSupplementFuncMap()147 void CellularCallStub::InitSupplementFuncMap()
148 {
149     requestFuncMap_[CellularCallInterfaceCode::SET_CALL_TRANSFER] = &CellularCallStub::OnSetCallTransferInner;
150     requestFuncMap_[CellularCallInterfaceCode::GET_CALL_TRANSFER] = &CellularCallStub::OnGetCallTransferInner;
151     requestFuncMap_[CellularCallInterfaceCode::CAN_SET_CALL_TRANSFER_TIME] =
152         &CellularCallStub::OnCanSetCallTransferTimeInner;
153     requestFuncMap_[CellularCallInterfaceCode::SET_CALL_WAITING] = &CellularCallStub::OnSetCallWaitingInner;
154     requestFuncMap_[CellularCallInterfaceCode::GET_CALL_WAITING] = &CellularCallStub::OnGetCallWaitingInner;
155     requestFuncMap_[CellularCallInterfaceCode::SET_CALL_RESTRICTION] = &CellularCallStub::OnSetCallRestrictionInner;
156     requestFuncMap_[CellularCallInterfaceCode::GET_CALL_RESTRICTION] = &CellularCallStub::OnGetCallRestrictionInner;
157     requestFuncMap_[CellularCallInterfaceCode::SET_CALL_RESTRICTION_PWD] =
158         &CellularCallStub::OnSetCallRestrictionPasswordInner;
159     requestFuncMap_[CellularCallInterfaceCode::REGISTER_CALLBACK] = &CellularCallStub::OnRegisterCallBackInner;
160     requestFuncMap_[CellularCallInterfaceCode::UNREGISTER_CALLBACK] = &CellularCallStub::OnUnRegisterCallBackInner;
161     requestFuncMap_[CellularCallInterfaceCode::CLOSE_UNFINISHED_USSD] = &CellularCallStub::OnCloseUnFinishedUssdInner;
162 }
163 
OnDialInner(MessageParcel & data,MessageParcel & reply)164 int32_t CellularCallStub::OnDialInner(MessageParcel &data, MessageParcel &reply)
165 {
166     TELEPHONY_LOGI("CellularCallStub::OnDialInner entry");
167     int32_t size = data.ReadInt32();
168     size = ((size > MAX_SIZE) ? 0 : size);
169     if (size <= 0) {
170         TELEPHONY_LOGE("CellularCallStub::OnRemoteRequest data size error");
171         return TELEPHONY_ERR_FAIL;
172     }
173     auto pCallInfo = (CellularCallInfo *)data.ReadRawData(sizeof(CellularCallInfo));
174     if (pCallInfo == nullptr) {
175         TELEPHONY_LOGE("OnDialInner return, pCallInfo is nullptr.");
176         return TELEPHONY_ERR_ARGUMENT_INVALID;
177     }
178 
179     reply.WriteInt32(Dial(*pCallInfo));
180     return TELEPHONY_SUCCESS;
181 }
182 
OnHangUpInner(MessageParcel & data,MessageParcel & reply)183 int32_t CellularCallStub::OnHangUpInner(MessageParcel &data, MessageParcel &reply)
184 {
185     TELEPHONY_LOGI("CellularCallStub::OnHangUpInner entry");
186     int32_t size = data.ReadInt32();
187     size = ((size > MAX_SIZE) ? 0 : size);
188     if (size <= 0) {
189         TELEPHONY_LOGE("CellularCallStub::OnRemoteRequest data size error");
190         return TELEPHONY_ERR_FAIL;
191     }
192     auto pCallInfo = (CellularCallInfo *)data.ReadRawData(sizeof(CellularCallInfo));
193     if (pCallInfo == nullptr) {
194         TELEPHONY_LOGE("OnHangUpInner return, pCallInfo is nullptr.");
195         return TELEPHONY_ERR_ARGUMENT_INVALID;
196     }
197     auto type = static_cast<CallSupplementType>(data.ReadInt32());
198 
199     reply.WriteInt32(HangUp(*pCallInfo, type));
200     return TELEPHONY_SUCCESS;
201 }
202 
OnRejectInner(MessageParcel & data,MessageParcel & reply)203 int32_t CellularCallStub::OnRejectInner(MessageParcel &data, MessageParcel &reply)
204 {
205     TELEPHONY_LOGI("CellularCallStub::OnRejectInner entry");
206     int32_t size = data.ReadInt32();
207     size = ((size > MAX_SIZE) ? 0 : size);
208     if (size <= 0) {
209         TELEPHONY_LOGE("CellularCallStub::OnRemoteRequest data size error");
210         return TELEPHONY_ERR_FAIL;
211     }
212     auto pCallInfo = (CellularCallInfo *)data.ReadRawData(sizeof(CellularCallInfo));
213     if (pCallInfo == nullptr) {
214         TELEPHONY_LOGE("OnRejectInner return, pCallInfo is nullptr.");
215         return TELEPHONY_ERR_ARGUMENT_INVALID;
216     }
217 
218     reply.WriteInt32(Reject(*pCallInfo));
219     return TELEPHONY_SUCCESS;
220 }
221 
OnAnswerInner(MessageParcel & data,MessageParcel & reply)222 int32_t CellularCallStub::OnAnswerInner(MessageParcel &data, MessageParcel &reply)
223 {
224     TELEPHONY_LOGI("CellularCallStub::OnAnswerInner entry");
225     int32_t size = data.ReadInt32();
226     size = ((size > MAX_SIZE) ? 0 : size);
227     if (size <= 0) {
228         TELEPHONY_LOGE("CellularCallStub::OnRemoteRequest data size error");
229         return TELEPHONY_ERR_FAIL;
230     }
231     auto pCallInfo = (CellularCallInfo *)data.ReadRawData(sizeof(CellularCallInfo));
232     if (pCallInfo == nullptr) {
233         TELEPHONY_LOGE("OnAnswerInner return, pCallInfo is nullptr.");
234         return TELEPHONY_ERR_ARGUMENT_INVALID;
235     }
236 
237     reply.WriteInt32(Answer(*pCallInfo));
238     return TELEPHONY_SUCCESS;
239 }
240 
OnIsEmergencyPhoneNumberInner(MessageParcel & data,MessageParcel & reply)241 int32_t CellularCallStub::OnIsEmergencyPhoneNumberInner(MessageParcel &data, MessageParcel &reply)
242 {
243     TELEPHONY_LOGD("CellularCallStub::OnIsEmergencyPhoneNumberInner entry.");
244     int32_t size = data.ReadInt32();
245     size = ((size > MAX_SIZE) ? 0 : size);
246     if (size <= 0) {
247         TELEPHONY_LOGE("CellularCallStub::OnIsEmergencyPhoneNumberInner data size error");
248         return TELEPHONY_ERR_FAIL;
249     }
250     int32_t slotId = data.ReadInt32();
251     std::string phoneNum = data.ReadString();
252     bool enabled = false;
253     int32_t ret = IsEmergencyPhoneNumber(slotId, phoneNum, enabled);
254     if (!reply.WriteInt32(ret)) {
255         TELEPHONY_LOGE("fail to write ret");
256         return TELEPHONY_ERR_WRITE_DATA_FAIL;
257     }
258     if (ret != TELEPHONY_SUCCESS) {
259         return ret;
260     }
261     if (!reply.WriteBool(enabled)) {
262         TELEPHONY_LOGE("fail to write enabled");
263         return TELEPHONY_ERR_WRITE_DATA_FAIL;
264     }
265     return TELEPHONY_SUCCESS;
266 }
267 
OnSetEmergencyCallList(MessageParcel & data,MessageParcel & reply)268 int32_t CellularCallStub::OnSetEmergencyCallList(MessageParcel &data, MessageParcel &reply)
269 {
270     TELEPHONY_LOGI("CellularCallStub::OnSetEmergencyCallList entry.");
271     int32_t size = data.ReadInt32();
272     size = ((size > MAX_SIZE) ? 0 : size);
273     if (size <= 0) {
274         TELEPHONY_LOGE("CellularCallStub::OnSetEmergencyCallList data size error");
275         return TELEPHONY_ERR_FAIL;
276     }
277     int32_t slotId = data.ReadInt32();
278     int32_t len = data.ReadInt32();
279     if (len <= 0 || len >= MAX_ECC_SIZE) {
280         TELEPHONY_LOGE("CellularCallStub::OnSetEmergencyCallList ecc size error");
281         return TELEPHONY_ERR_FAIL;
282     }
283     std::vector<EmergencyCall> eccVec;
284     for (int i = 0; i < len; i++) {
285         EmergencyCall emergencyCall;
286         emergencyCall.eccNum = data.ReadString();
287         emergencyCall.mcc = data.ReadString();
288         emergencyCall.eccType = static_cast<EccType>(data.ReadInt32());
289         emergencyCall.simpresent = static_cast<SimpresentType>(data.ReadInt32());
290         emergencyCall.abnormalService = static_cast<AbnormalServiceType>(data.ReadInt32());
291         eccVec.push_back(emergencyCall);
292     }
293     for (auto ecc : eccVec) {
294         TELEPHONY_LOGE("OnSetEmergencyCallList, data: eccNum %{public}s mcc %{public}s",
295             ecc.eccNum.c_str(), ecc.mcc.c_str());
296     }
297     reply.WriteInt32(SetEmergencyCallList(slotId, eccVec));
298     return TELEPHONY_SUCCESS;
299 }
300 
OnRegisterCallBackInner(MessageParcel & data,MessageParcel & reply)301 int32_t CellularCallStub::OnRegisterCallBackInner(MessageParcel &data, MessageParcel &reply)
302 {
303     TELEPHONY_LOGI("CellularCallStub::OnRegisterCallBackInner entry.");
304     int32_t size = data.ReadInt32();
305     size = ((size > MAX_SIZE) ? 0 : size);
306     if (size <= 0) {
307         TELEPHONY_LOGE("CellularCallStub::OnRemoteRequest data size error");
308         return TELEPHONY_ERR_FAIL;
309     }
310 
311     int32_t result = TELEPHONY_ERR_LOCAL_PTR_NULL;
312     auto remote = data.ReadRemoteObject();
313     if (remote == nullptr) {
314         TELEPHONY_LOGE("CellularCallStub::OnRegisterCallBackInner return, remote is nullptr.");
315         reply.WriteInt32(result);
316         return result;
317     }
318     result = RegisterCallManagerCallBack(iface_cast<ICallStatusCallback>(remote));
319 
320     reply.WriteInt32(result);
321     return TELEPHONY_SUCCESS;
322 }
323 
OnUnRegisterCallBackInner(MessageParcel & data,MessageParcel & reply)324 int32_t CellularCallStub::OnUnRegisterCallBackInner(MessageParcel &data, MessageParcel &reply)
325 {
326     TELEPHONY_LOGI("CellularCallStub::OnUnRegisterCallBackInner entry.");
327     int32_t size = data.ReadInt32();
328     size = ((size > MAX_SIZE) ? 0 : size);
329     if (size <= 0) {
330         TELEPHONY_LOGE("CellularCallStub::OnRemoteRequest data size error");
331         return TELEPHONY_ERR_FAIL;
332     }
333     int32_t result = UnRegisterCallManagerCallBack();
334 
335     reply.WriteInt32(result);
336     return result;
337 }
338 
OnHoldCallInner(MessageParcel & data,MessageParcel & reply)339 int32_t CellularCallStub::OnHoldCallInner(MessageParcel &data, MessageParcel &reply)
340 {
341     TELEPHONY_LOGI("CellularCallStub::OnHoldCallInner entry");
342     int32_t size = data.ReadInt32();
343     size = ((size > MAX_SIZE) ? 0 : size);
344     if (size <= 0) {
345         TELEPHONY_LOGE("CellularCallStub::OnRemoteRequest data size error");
346         return TELEPHONY_ERR_FAIL;
347     }
348     auto pCallInfo = (CellularCallInfo *)data.ReadRawData(sizeof(CellularCallInfo));
349     if (pCallInfo == nullptr) {
350         TELEPHONY_LOGE("OnHoldCallInner return, pCallInfo is nullptr.");
351         return TELEPHONY_ERR_ARGUMENT_INVALID;
352     }
353 
354     reply.WriteInt32(HoldCall(*pCallInfo));
355     return TELEPHONY_SUCCESS;
356 }
357 
OnUnHoldCallInner(MessageParcel & data,MessageParcel & reply)358 int32_t CellularCallStub::OnUnHoldCallInner(MessageParcel &data, MessageParcel &reply)
359 {
360     TELEPHONY_LOGI("CellularCallStub::OnUnHoldCallInner entry");
361     int32_t size = data.ReadInt32();
362     size = ((size > MAX_SIZE) ? 0 : size);
363     if (size <= 0) {
364         TELEPHONY_LOGE("CellularCallStub::OnRemoteRequest data size error");
365         return TELEPHONY_ERR_FAIL;
366     }
367     auto pCallInfo = (CellularCallInfo *)data.ReadRawData(sizeof(CellularCallInfo));
368     if (pCallInfo == nullptr) {
369         TELEPHONY_LOGE("OnUnHoldCallInner return, pCallInfo is nullptr.");
370         return TELEPHONY_ERR_ARGUMENT_INVALID;
371     }
372 
373     reply.WriteInt32(UnHoldCall(*pCallInfo));
374     return TELEPHONY_SUCCESS;
375 }
376 
OnSwitchCallInner(MessageParcel & data,MessageParcel & reply)377 int32_t CellularCallStub::OnSwitchCallInner(MessageParcel &data, MessageParcel &reply)
378 {
379     TELEPHONY_LOGI("CellularCallStub::OnSwitchCallInner entry");
380     int32_t size = data.ReadInt32();
381     size = ((size > MAX_SIZE) ? 0 : size);
382     if (size <= 0) {
383         TELEPHONY_LOGE("CellularCallStub::OnRemoteRequest data size error");
384         return TELEPHONY_ERR_FAIL;
385     }
386     auto pCallInfo = (CellularCallInfo *)data.ReadRawData(sizeof(CellularCallInfo));
387     if (pCallInfo == nullptr) {
388         TELEPHONY_LOGE("OnSwitchCallInner return, pCallInfo is nullptr.");
389         return TELEPHONY_ERR_ARGUMENT_INVALID;
390     }
391 
392     reply.WriteInt32(SwitchCall(*pCallInfo));
393     return TELEPHONY_SUCCESS;
394 }
395 
OnCombineConferenceInner(MessageParcel & data,MessageParcel & reply)396 int32_t CellularCallStub::OnCombineConferenceInner(MessageParcel &data, MessageParcel &reply)
397 {
398     TELEPHONY_LOGI("CellularCallStub::OnCombineConferenceInner entry");
399     int32_t size = data.ReadInt32();
400     size = ((size > MAX_SIZE) ? 0 : size);
401     if (size <= 0) {
402         TELEPHONY_LOGE("CellularCallStub::OnCombineConferenceInner data size error");
403         return TELEPHONY_ERR_FAIL;
404     }
405     auto pCallInfo = (CellularCallInfo *)data.ReadRawData(sizeof(CellularCallInfo));
406     if (pCallInfo == nullptr) {
407         TELEPHONY_LOGE("OnCombineConferenceInner return, pCallInfo is nullptr.");
408         return TELEPHONY_ERR_ARGUMENT_INVALID;
409     }
410 
411     reply.WriteInt32(CombineConference(*pCallInfo));
412     return TELEPHONY_SUCCESS;
413 }
414 
OnSeparateConferenceInner(MessageParcel & data,MessageParcel & reply)415 int32_t CellularCallStub::OnSeparateConferenceInner(MessageParcel &data, MessageParcel &reply)
416 {
417     TELEPHONY_LOGI("CellularCallStub::OnSeparateConferenceInner entry");
418     int32_t size = data.ReadInt32();
419     size = ((size > MAX_SIZE) ? 0 : size);
420     if (size <= 0) {
421         TELEPHONY_LOGE("CellularCallStub::OnSeparateConferenceInner data size error");
422         return TELEPHONY_ERR_FAIL;
423     }
424 
425     auto pCallInfo = (CellularCallInfo *)data.ReadRawData(sizeof(CellularCallInfo));
426     if (pCallInfo == nullptr) {
427         TELEPHONY_LOGE("OnSeparateConferenceInner return, pCallInfo is nullptr.");
428         return TELEPHONY_ERR_ARGUMENT_INVALID;
429     }
430 
431     reply.WriteInt32(SeparateConference(*pCallInfo));
432     return TELEPHONY_SUCCESS;
433 }
434 
OnInviteToConferenceInner(MessageParcel & data,MessageParcel & reply)435 int32_t CellularCallStub::OnInviteToConferenceInner(MessageParcel &data, MessageParcel &reply)
436 {
437     TELEPHONY_LOGI("CellularCallStub::OnInviteToConferenceInner entry");
438     int32_t size = data.ReadInt32();
439     size = ((size > MAX_SIZE) ? 0 : size);
440     if (size <= 0) {
441         TELEPHONY_LOGE("CellularCallStub::OnInviteToConferenceInner data size error");
442         return TELEPHONY_ERR_FAIL;
443     }
444 
445     int32_t slotId = data.ReadInt32();
446     std::vector<std::string> numberList;
447     bool bRead = data.ReadStringVector(&numberList);
448     if (!bRead) {
449         TELEPHONY_LOGE("InviteToConferenceInner return, read fail.");
450         return TELEPHONY_ERR_ARGUMENT_INVALID;
451     }
452     reply.WriteInt32(InviteToConference(slotId, numberList));
453     return TELEPHONY_SUCCESS;
454 }
455 
OnKickOutFromConferenceInner(MessageParcel & data,MessageParcel & reply)456 int32_t CellularCallStub::OnKickOutFromConferenceInner(MessageParcel &data, MessageParcel &reply)
457 {
458     TELEPHONY_LOGI("CellularCallStub::OnKickOutFromConferenceInner entry");
459     int32_t size = data.ReadInt32();
460     size = ((size > MAX_SIZE) ? 0 : size);
461     if (size <= 0) {
462         TELEPHONY_LOGE("CellularCallStub::OnKickOutFromConferenceInner data size error");
463         return TELEPHONY_ERR_FAIL;
464     }
465 
466     auto pCallInfo = (CellularCallInfo *)data.ReadRawData(sizeof(CellularCallInfo));
467     if (pCallInfo == nullptr) {
468         TELEPHONY_LOGE("OnKickOutFromConferenceInner return, pCallInfo is nullptr.");
469         return TELEPHONY_ERR_ARGUMENT_INVALID;
470     }
471     reply.WriteInt32(KickOutFromConference(*pCallInfo));
472     return TELEPHONY_SUCCESS;
473 }
474 
OnHangUpAllConnectionInner(MessageParcel & data,MessageParcel & reply)475 int32_t CellularCallStub::OnHangUpAllConnectionInner(MessageParcel &data, MessageParcel &reply)
476 {
477     TELEPHONY_LOGI("CellularCallStub::OnHangUpAllConnectionInner entry");
478     int32_t size = data.ReadInt32();
479     size = ((size > MAX_SIZE) ? 0 : size);
480     if (size <= 0) {
481         TELEPHONY_LOGE("OnHangUpAllConnectionInner data size error");
482         return TELEPHONY_ERR_FAIL;
483     }
484 
485     reply.WriteInt32(HangUpAllConnection());
486     return TELEPHONY_SUCCESS;
487 }
488 
OnSetReadyToCallInner(MessageParcel & data,MessageParcel & reply)489 int32_t CellularCallStub::OnSetReadyToCallInner(MessageParcel &data, MessageParcel &reply)
490 {
491     int32_t slotId = data.ReadInt32();
492     int32_t callType = data.ReadInt32();
493     bool isReadyToCall = data.ReadBool();
494     int32_t error = SetReadyToCall(slotId, callType, isReadyToCall);
495     if (!reply.WriteInt32(error)) {
496         TELEPHONY_LOGE("OnSetReadyToCallInner WriteInt32 fail");
497         return TELEPHONY_ERR_WRITE_REPLY_FAIL;
498     }
499     return TELEPHONY_SUCCESS;
500 }
501 
OnSendUpdateCallMediaModeRequestInner(MessageParcel & data,MessageParcel & reply)502 int32_t CellularCallStub::OnSendUpdateCallMediaModeRequestInner(MessageParcel &data, MessageParcel &reply)
503 {
504     TELEPHONY_LOGI("CellularCallStub::OnSendUpdateCallMediaModeRequestInner entry");
505     int32_t size = data.ReadInt32();
506     size = ((size > MAX_SIZE) ? 0 : size);
507     if (size <= 0) {
508         TELEPHONY_LOGE("OnSendUpdateCallMediaModeRequestInner data size error");
509         return TELEPHONY_ERR_FAIL;
510     }
511     auto pCallInfo = (CellularCallInfo *)data.ReadRawData(sizeof(CellularCallInfo));
512     if (pCallInfo == nullptr) {
513         TELEPHONY_LOGE("OnSendUpdateCallMediaModeRequestInner return, pCallInfo is nullptr.");
514         return TELEPHONY_ERR_ARGUMENT_INVALID;
515     }
516     auto mode = static_cast<ImsCallMode>(data.ReadInt32());
517 
518     reply.WriteInt32(SendUpdateCallMediaModeRequest(*pCallInfo, mode));
519     return TELEPHONY_SUCCESS;
520 }
521 
OnSendUpdateCallMediaModeResponseInner(MessageParcel & data,MessageParcel & reply)522 int32_t CellularCallStub::OnSendUpdateCallMediaModeResponseInner(MessageParcel &data, MessageParcel &reply)
523 {
524     TELEPHONY_LOGI("CellularCallStub::OnSendUpdateCallMediaModeResponseInner entry");
525     int32_t size = data.ReadInt32();
526     size = ((size > MAX_SIZE) ? 0 : size);
527     if (size <= 0) {
528         TELEPHONY_LOGE("OnSendUpdateCallMediaModeResponseInner data size error");
529         return TELEPHONY_ERR_FAIL;
530     }
531     auto pCallInfo = (CellularCallInfo *)data.ReadRawData(sizeof(CellularCallInfo));
532     if (pCallInfo == nullptr) {
533         TELEPHONY_LOGE("OnSendUpdateCallMediaModeResponseInner return, pCallInfo is nullptr.");
534         return TELEPHONY_ERR_ARGUMENT_INVALID;
535     }
536     auto mode = static_cast<ImsCallMode>(data.ReadInt32());
537 
538     reply.WriteInt32(SendUpdateCallMediaModeResponse(*pCallInfo, mode));
539     return TELEPHONY_SUCCESS;
540 }
541 
OnCancelCallUpgradeInner(MessageParcel & data,MessageParcel & reply)542 int32_t CellularCallStub::OnCancelCallUpgradeInner(MessageParcel &data, MessageParcel &reply)
543 {
544     TELEPHONY_LOGI("CellularCallStub::OnCancelCallUpgradeInner entry");
545     int32_t size = data.ReadInt32();
546     size = ((size > MAX_SIZE) ? 0 : size);
547     if (size <= 0) {
548         TELEPHONY_LOGE("OnCancelCallUpgradeInner data size error");
549         return TELEPHONY_ERR_FAIL;
550     }
551     int32_t slotId = data.ReadInt32();
552     int32_t callIndex = data.ReadInt32();
553     reply.WriteInt32(CancelCallUpgrade(slotId, callIndex));
554     return TELEPHONY_SUCCESS;
555 }
556 
OnRequestCameraCapabilitiesInner(MessageParcel & data,MessageParcel & reply)557 int32_t CellularCallStub::OnRequestCameraCapabilitiesInner(MessageParcel &data, MessageParcel &reply)
558 {
559     TELEPHONY_LOGI("CellularCallStub::OnRequestCameraCapabilitiesInner entry");
560     int32_t size = data.ReadInt32();
561     size = ((size > MAX_SIZE) ? 0 : size);
562     if (size <= 0) {
563         TELEPHONY_LOGE("OnRequestCameraCapabilitiesInner data size error");
564         return TELEPHONY_ERR_FAIL;
565     }
566     int32_t slotId = data.ReadInt32();
567     int32_t callIndex = data.ReadInt32();
568     reply.WriteInt32(RequestCameraCapabilities(slotId, callIndex));
569     return TELEPHONY_SUCCESS;
570 }
571 
OnStartDtmfInner(MessageParcel & data,MessageParcel & reply)572 int32_t CellularCallStub::OnStartDtmfInner(MessageParcel &data, MessageParcel &reply)
573 {
574     TELEPHONY_LOGI("CellularCallStub::OnStartDtmfInner entry");
575     int32_t size = data.ReadInt32();
576     size = ((size > MAX_SIZE) ? 0 : size);
577     if (size <= 0) {
578         TELEPHONY_LOGE("CellularCallStub::OnStartDtmfInner data size error");
579         return TELEPHONY_ERR_FAIL;
580     }
581 
582     char pDtmf = data.ReadInt8();
583     auto pCallInfo = (CellularCallInfo *)data.ReadRawData(sizeof(CellularCallInfo));
584     if (pCallInfo == nullptr) {
585         TELEPHONY_LOGE("OnStartDtmfInner return, pCallInfo is nullptr.");
586         return TELEPHONY_ERR_ARGUMENT_INVALID;
587     }
588 
589     reply.WriteInt32(StartDtmf(pDtmf, *pCallInfo));
590     return TELEPHONY_SUCCESS;
591 }
592 
OnStopDtmfInner(MessageParcel & data,MessageParcel & reply)593 int32_t CellularCallStub::OnStopDtmfInner(MessageParcel &data, MessageParcel &reply)
594 {
595     TELEPHONY_LOGI("CellularCallStub::OnStopDtmfInner entry");
596     int32_t size = data.ReadInt32();
597     size = ((size > MAX_SIZE) ? 0 : size);
598     if (size <= 0) {
599         TELEPHONY_LOGE("CellularCallStub::OnStopDtmfInner data size error");
600         return TELEPHONY_ERR_FAIL;
601     }
602 
603     auto pCallInfo = (CellularCallInfo *)data.ReadRawData(sizeof(CellularCallInfo));
604     if (pCallInfo == nullptr) {
605         TELEPHONY_LOGE("OnStopDtmfInner return, pCallInfo is nullptr.");
606         return TELEPHONY_ERR_ARGUMENT_INVALID;
607     }
608 
609     reply.WriteInt32(StopDtmf(*pCallInfo));
610     return TELEPHONY_SUCCESS;
611 }
612 
OnPostDialProceedInner(MessageParcel & data,MessageParcel & reply)613 int32_t CellularCallStub::OnPostDialProceedInner(MessageParcel &data, MessageParcel &reply)
614 {
615     TELEPHONY_LOGI("CellularCallStub::OnPostDialProceedInner entry");
616     int32_t size = data.ReadInt32();
617     size = ((size > MAX_SIZE) ? 0 : size);
618     if (size <= 0) {
619         TELEPHONY_LOGE("CellularCallStub::OnPostDialProceedInner data size error");
620         return TELEPHONY_ERR_FAIL;
621     }
622 
623     auto info = (CellularCallInfo *)data.ReadRawData(sizeof(CellularCallInfo));
624     if (info == nullptr) {
625         TELEPHONY_LOGE("OnStopDtmfInner return, info is nullptr.");
626         return TELEPHONY_ERR_ARGUMENT_INVALID;
627     }
628     bool proceed = data.ReadBool();
629 
630     reply.WriteInt32(PostDialProceed(*info, proceed));
631     return TELEPHONY_SUCCESS;
632 }
633 
OnSendDtmfInner(MessageParcel & data,MessageParcel & reply)634 int32_t CellularCallStub::OnSendDtmfInner(MessageParcel &data, MessageParcel &reply)
635 {
636     TELEPHONY_LOGI("CellularCallStub::OnSendDtmfInner entry");
637     int32_t size = data.ReadInt32();
638     size = ((size > MAX_SIZE) ? 0 : size);
639     if (size <= 0) {
640         TELEPHONY_LOGE("CellularCallStub::OnSendDtmfInner data size error");
641         return TELEPHONY_ERR_FAIL;
642     }
643 
644     char pDtmf = data.ReadInt8();
645     auto pCallInfo = (CellularCallInfo *)data.ReadRawData(sizeof(CellularCallInfo));
646     if (pCallInfo == nullptr) {
647         TELEPHONY_LOGE("OnSendDtmfInner return, pCallInfo is nullptr.");
648         return TELEPHONY_ERR_ARGUMENT_INVALID;
649     }
650 
651     reply.WriteInt32(SendDtmf(pDtmf, *pCallInfo));
652     return TELEPHONY_SUCCESS;
653 }
654 
OnStartRttInner(MessageParcel & data,MessageParcel & reply)655 int32_t CellularCallStub::OnStartRttInner(MessageParcel &data, MessageParcel &reply)
656 {
657     TELEPHONY_LOGI("CellularCallStub::OnStartRttInner entry");
658     int32_t size = data.ReadInt32();
659     size = ((size > MAX_SIZE) ? 0 : size);
660     if (size <= 0) {
661         TELEPHONY_LOGE("CellularCallStub::OnStartRttInner data size error");
662         return TELEPHONY_ERR_FAIL;
663     }
664     int32_t slotId = data.ReadInt32();
665     std::string msg = data.ReadString();
666 
667     reply.WriteInt32(StartRtt(slotId, msg));
668     return TELEPHONY_SUCCESS;
669 }
670 
OnStopRttInner(MessageParcel & data,MessageParcel & reply)671 int32_t CellularCallStub::OnStopRttInner(MessageParcel &data, MessageParcel &reply)
672 {
673     TELEPHONY_LOGI("CellularCallStub::OnStopRttInner entry");
674     int32_t size = data.ReadInt32();
675     size = ((size > MAX_SIZE) ? 0 : size);
676     if (size <= 0) {
677         TELEPHONY_LOGE("CellularCallStub::OnStopRttInner data size error");
678         return TELEPHONY_ERR_FAIL;
679     }
680     int32_t slotId = data.ReadInt32();
681 
682     reply.WriteInt32(StopRtt(slotId));
683     return TELEPHONY_SUCCESS;
684 }
685 
OnSetCallTransferInner(MessageParcel & data,MessageParcel & reply)686 int32_t CellularCallStub::OnSetCallTransferInner(MessageParcel &data, MessageParcel &reply)
687 {
688     TELEPHONY_LOGI("CellularCallStub::OnSetCallTransferInner entry");
689     int32_t size = data.ReadInt32();
690     size = ((size > MAX_SIZE) ? 0 : size);
691     if (size <= 0) {
692         TELEPHONY_LOGE("CellularCallStub::OnSetCallTransferInner data size error");
693         return TELEPHONY_ERR_FAIL;
694     }
695     int32_t slotId = data.ReadInt32();
696     auto pCTInfo = (CallTransferInfo *)data.ReadRawData(sizeof(CallTransferInfo));
697     if (pCTInfo == nullptr) {
698         TELEPHONY_LOGE("OnSetCallTransferInner return, pCTInfo is nullptr.");
699         return TELEPHONY_ERR_ARGUMENT_INVALID;
700     }
701 
702     reply.WriteInt32(SetCallTransferInfo(slotId, *pCTInfo));
703     return TELEPHONY_SUCCESS;
704 }
705 
OnCanSetCallTransferTimeInner(MessageParcel & data,MessageParcel & reply)706 int32_t CellularCallStub::OnCanSetCallTransferTimeInner(MessageParcel &data, MessageParcel &reply)
707 {
708     TELEPHONY_LOGI("entry");
709     int32_t size = data.ReadInt32();
710     size = ((size > MAX_SIZE) ? 0 : size);
711     if (size <= 0) {
712         TELEPHONY_LOGE("data size error");
713         return TELEPHONY_ERR_FAIL;
714     }
715     int32_t slotId = data.ReadInt32();
716     bool result = data.ReadBool();
717 
718     int32_t callResult = CanSetCallTransferTime(slotId, result);
719     reply.WriteBool(result);
720     reply.WriteInt32(callResult);
721     return TELEPHONY_SUCCESS;
722 }
723 
OnGetCallTransferInner(MessageParcel & data,MessageParcel & reply)724 int32_t CellularCallStub::OnGetCallTransferInner(MessageParcel &data, MessageParcel &reply)
725 {
726     TELEPHONY_LOGI("CellularCallStub::OnGetCallTransferInner entry");
727     int32_t size = data.ReadInt32();
728     size = ((size > MAX_SIZE) ? 0 : size);
729     if (size <= 0) {
730         TELEPHONY_LOGE("CellularCallStub::OnGetCallTransferInner data size error");
731         return TELEPHONY_ERR_FAIL;
732     }
733     int32_t slotId = data.ReadInt32();
734     auto type = static_cast<CallTransferType>(data.ReadInt32());
735 
736     reply.WriteInt32(GetCallTransferInfo(slotId, type));
737     return TELEPHONY_SUCCESS;
738 }
739 
OnSetCallWaitingInner(MessageParcel & data,MessageParcel & reply)740 int32_t CellularCallStub::OnSetCallWaitingInner(MessageParcel &data, MessageParcel &reply)
741 {
742     TELEPHONY_LOGI("CellularCallStub::OnSetCallWaitingInner entry");
743     int32_t size = data.ReadInt32();
744     size = ((size > MAX_SIZE) ? 0 : size);
745     if (size <= 0) {
746         TELEPHONY_LOGE("CellularCallStub::OnSetCallWaitingInner data size error");
747         return TELEPHONY_ERR_FAIL;
748     }
749     int32_t slotId = data.ReadInt32();
750     bool enable = data.ReadBool();
751 
752     reply.WriteInt32(SetCallWaiting(slotId, enable));
753     return TELEPHONY_SUCCESS;
754 }
755 
OnGetCallWaitingInner(MessageParcel & data,MessageParcel & reply)756 int32_t CellularCallStub::OnGetCallWaitingInner(MessageParcel &data, MessageParcel &reply)
757 {
758     TELEPHONY_LOGI("CellularCallStub::OnGetCallWaitingInner entry");
759     int32_t size = data.ReadInt32();
760     size = ((size > MAX_SIZE) ? 0 : size);
761     if (size <= 0) {
762         TELEPHONY_LOGE("CellularCallStub::OnGetCallWaitingInner data size error");
763         return TELEPHONY_ERR_FAIL;
764     }
765     int32_t slotId = data.ReadInt32();
766     TELEPHONY_LOGI("CellularCallStub::OnGetCallWaitingInner data.ReadInt32()");
767     reply.WriteInt32(GetCallWaiting(slotId));
768     return TELEPHONY_SUCCESS;
769 }
770 
OnSetCallRestrictionInner(MessageParcel & data,MessageParcel & reply)771 int32_t CellularCallStub::OnSetCallRestrictionInner(MessageParcel &data, MessageParcel &reply)
772 {
773     TELEPHONY_LOGI("CellularCallStub::OnSetCallRestrictionInner entry");
774     int32_t size = data.ReadInt32();
775     size = ((size > MAX_SIZE) ? 0 : size);
776     if (size <= 0) {
777         TELEPHONY_LOGE("CellularCallStub::OnSetCallRestrictionInner data size error");
778         return TELEPHONY_ERR_FAIL;
779     }
780     int32_t slotId = data.ReadInt32();
781     auto pCRInfo = (CallRestrictionInfo *)data.ReadRawData(sizeof(CallRestrictionInfo));
782     if (pCRInfo == nullptr) {
783         TELEPHONY_LOGE("OnSetCallRestrictionInner return, pCRInfo is nullptr.");
784         return TELEPHONY_ERR_ARGUMENT_INVALID;
785     }
786 
787     reply.WriteInt32(SetCallRestriction(slotId, *pCRInfo));
788     return TELEPHONY_SUCCESS;
789 }
790 
OnGetCallRestrictionInner(MessageParcel & data,MessageParcel & reply)791 int32_t CellularCallStub::OnGetCallRestrictionInner(MessageParcel &data, MessageParcel &reply)
792 {
793     TELEPHONY_LOGI("CellularCallStub::OnGetCallRestrictionInner entry");
794     int32_t size = data.ReadInt32();
795     size = ((size > MAX_SIZE) ? 0 : size);
796     if (size <= 0) {
797         TELEPHONY_LOGE("CellularCallStub::OnGetCallRestrictionInner data size error");
798         return TELEPHONY_ERR_FAIL;
799     }
800     int32_t slotId = data.ReadInt32();
801     auto facType = static_cast<CallRestrictionType>(data.ReadInt32());
802 
803     reply.WriteInt32(GetCallRestriction(slotId, facType));
804     return TELEPHONY_SUCCESS;
805 }
806 
OnSetCallRestrictionPasswordInner(MessageParcel & data,MessageParcel & reply)807 int32_t CellularCallStub::OnSetCallRestrictionPasswordInner(MessageParcel &data, MessageParcel &reply)
808 {
809     int32_t size = data.ReadInt32();
810     size = ((size > MAX_SIZE) ? 0 : size);
811     if (size <= 0) {
812         TELEPHONY_LOGE("data size error");
813         return TELEPHONY_ERR_FAIL;
814     }
815     int32_t slotId = data.ReadInt32();
816     auto facType = static_cast<CallRestrictionType>(data.ReadInt32());
817     auto oldPassword = data.ReadCString();
818     auto newPassword = data.ReadCString();
819 
820     reply.WriteInt32(SetCallRestrictionPassword(slotId, facType, oldPassword, newPassword));
821     return TELEPHONY_SUCCESS;
822 }
823 
OnSetDomainPreferenceModeInner(MessageParcel & data,MessageParcel & reply)824 int32_t CellularCallStub::OnSetDomainPreferenceModeInner(MessageParcel &data, MessageParcel &reply)
825 {
826     TELEPHONY_LOGI("CellularCallStub::OnSetDomainPreferenceModeInner entry");
827     int32_t size = data.ReadInt32();
828     size = ((size > MAX_SIZE) ? 0 : size);
829     if (size <= 0) {
830         TELEPHONY_LOGE("CellularCallStub::OnSetDomainPreferenceModeInner data size error");
831         return TELEPHONY_ERR_FAIL;
832     }
833     int32_t slotId = data.ReadInt32();
834     int32_t mode = data.ReadInt32();
835 
836     reply.WriteInt32(SetDomainPreferenceMode(slotId, mode));
837     return TELEPHONY_SUCCESS;
838 }
839 
OnGetDomainPreferenceModeInner(MessageParcel & data,MessageParcel & reply)840 int32_t CellularCallStub::OnGetDomainPreferenceModeInner(MessageParcel &data, MessageParcel &reply)
841 {
842     TELEPHONY_LOGI("CellularCallStub::OnGetDomainPreferenceModeInner entry");
843     int32_t size = data.ReadInt32();
844     size = ((size > MAX_SIZE) ? 0 : size);
845     if (size <= 0) {
846         TELEPHONY_LOGE("CellularCallStub::OnGetDomainPreferenceModeInner data size error");
847         return TELEPHONY_ERR_FAIL;
848     }
849     int32_t slotId = data.ReadInt32();
850 
851     reply.WriteInt32(GetDomainPreferenceMode(slotId));
852     return TELEPHONY_SUCCESS;
853 }
854 
OnSetImsSwitchStatusInner(MessageParcel & data,MessageParcel & reply)855 int32_t CellularCallStub::OnSetImsSwitchStatusInner(MessageParcel &data, MessageParcel &reply)
856 {
857     TELEPHONY_LOGI("CellularCallStub::OnSetImsSwitchStatusInner entry");
858     int32_t size = data.ReadInt32();
859     size = ((size > MAX_SIZE) ? 0 : size);
860     if (size <= 0) {
861         TELEPHONY_LOGE("CellularCallStub::OnSetImsSwitchStatusInner data size error");
862         return TELEPHONY_ERR_FAIL;
863     }
864     int32_t slotId = data.ReadInt32();
865     bool active = data.ReadBool();
866 
867     reply.WriteInt32(SetImsSwitchStatus(slotId, active));
868     return TELEPHONY_SUCCESS;
869 }
870 
OnGetImsSwitchStatusInner(MessageParcel & data,MessageParcel & reply)871 int32_t CellularCallStub::OnGetImsSwitchStatusInner(MessageParcel &data, MessageParcel &reply)
872 {
873     TELEPHONY_LOGI("CellularCallStub::OnGetImsSwitchStatusInner entry");
874     int32_t size = data.ReadInt32();
875     size = ((size > MAX_SIZE) ? 0 : size);
876     if (size <= 0) {
877         TELEPHONY_LOGE("CellularCallStub::OnGetImsSwitchStatusInner data size error");
878         return TELEPHONY_ERR_FAIL;
879     }
880     int32_t slotId = data.ReadInt32();
881     bool enabled;
882     int32_t result = GetImsSwitchStatus(slotId, enabled);
883     reply.WriteBool(enabled);
884     reply.WriteInt32(result);
885     return TELEPHONY_SUCCESS;
886 }
887 
OnSetVoNRStateInner(MessageParcel & data,MessageParcel & reply)888 int32_t CellularCallStub::OnSetVoNRStateInner(MessageParcel &data, MessageParcel &reply)
889 {
890     TELEPHONY_LOGI("CellularCallStub::OnSetVoNRSwitchStatusInner entry");
891     int32_t size = data.ReadInt32();
892     size = ((size > MAX_SIZE) ? 0 : size);
893     if (size <= 0) {
894         TELEPHONY_LOGE("CellularCallStub::OnSetVoNRSwitchStatusInner data size error");
895         return TELEPHONY_ERR_FAIL;
896     }
897     int32_t slotId = data.ReadInt32();
898     int32_t state = data.ReadInt32();
899     reply.WriteInt32(SetVoNRState(slotId, state));
900     return TELEPHONY_SUCCESS;
901 }
902 
OnGetVoNRStateInner(MessageParcel & data,MessageParcel & reply)903 int32_t CellularCallStub::OnGetVoNRStateInner(MessageParcel &data, MessageParcel &reply)
904 {
905     TELEPHONY_LOGI("CellularCallStub::OnGetVoNRSwitchStatusInner entry");
906     int32_t size = data.ReadInt32();
907     size = ((size > MAX_SIZE) ? 0 : size);
908     if (size <= 0) {
909         TELEPHONY_LOGE("CellularCallStub::OnGetVoNRSwitchStatusInner data size error");
910         return TELEPHONY_ERR_FAIL;
911     }
912     int32_t slotId = data.ReadInt32();
913     int32_t state;
914     int32_t result = GetVoNRState(slotId, state);
915     reply.WriteInt32(state);
916     reply.WriteInt32(result);
917     return TELEPHONY_SUCCESS;
918 }
919 
OnSetImsConfigStringInner(MessageParcel & data,MessageParcel & reply)920 int32_t CellularCallStub::OnSetImsConfigStringInner(MessageParcel &data, MessageParcel &reply)
921 {
922     TELEPHONY_LOGI("CellularCallStub::OnSetImsConfigStringInner entry");
923     int32_t size = data.ReadInt32();
924     size = ((size > MAX_SIZE) ? 0 : size);
925     if (size <= 0) {
926         TELEPHONY_LOGE("CellularCallStub::OnSetImsConfigStringInner data size error");
927         return TELEPHONY_ERR_FAIL;
928     }
929     int32_t slotId = data.ReadInt32();
930     auto item = static_cast<ImsConfigItem>(data.ReadInt32());
931     std::string value = data.ReadString();
932 
933     reply.WriteInt32(SetImsConfig(slotId, item, value));
934     return TELEPHONY_SUCCESS;
935 }
936 
OnSetImsConfigIntInner(MessageParcel & data,MessageParcel & reply)937 int32_t CellularCallStub::OnSetImsConfigIntInner(MessageParcel &data, MessageParcel &reply)
938 {
939     TELEPHONY_LOGI("CellularCallStub::OnSetImsConfigIntInner entry");
940     int32_t size = data.ReadInt32();
941     size = ((size > MAX_SIZE) ? 0 : size);
942     if (size <= 0) {
943         TELEPHONY_LOGE("CellularCallStub::OnSetImsConfigIntInner data size error");
944         return TELEPHONY_ERR_FAIL;
945     }
946     int32_t slotId = data.ReadInt32();
947     auto item = static_cast<ImsConfigItem>(data.ReadInt32());
948     int32_t value = data.ReadInt32();
949 
950     reply.WriteInt32(SetImsConfig(slotId, item, value));
951     return TELEPHONY_SUCCESS;
952 }
953 
OnGetImsConfigInner(MessageParcel & data,MessageParcel & reply)954 int32_t CellularCallStub::OnGetImsConfigInner(MessageParcel &data, MessageParcel &reply)
955 {
956     TELEPHONY_LOGI("CellularCallStub::OnGetImsConfigInner entry");
957     int32_t size = data.ReadInt32();
958     size = ((size > MAX_SIZE) ? 0 : size);
959     if (size <= 0) {
960         TELEPHONY_LOGE("CellularCallStub::OnGetImsConfigInner data size error");
961         return TELEPHONY_ERR_FAIL;
962     }
963     int32_t slotId = data.ReadInt32();
964     auto item = static_cast<ImsConfigItem>(data.ReadInt32());
965 
966     reply.WriteInt32(GetImsConfig(slotId, item));
967     return TELEPHONY_SUCCESS;
968 }
969 
OnSetImsFeatureValueInner(MessageParcel & data,MessageParcel & reply)970 int32_t CellularCallStub::OnSetImsFeatureValueInner(MessageParcel &data, MessageParcel &reply)
971 {
972     TELEPHONY_LOGI("CellularCallStub::OnSetImsFeatureValueInner entry");
973     int32_t size = data.ReadInt32();
974     size = ((size > MAX_SIZE) ? 0 : size);
975     if (size <= 0) {
976         TELEPHONY_LOGE("CellularCallStub::OnSetImsFeatureValueInner data size error");
977         return TELEPHONY_ERR_FAIL;
978     }
979     int32_t slotId = data.ReadInt32();
980     auto type = static_cast<FeatureType>(data.ReadInt32());
981     int32_t value = data.ReadInt32();
982 
983     reply.WriteInt32(SetImsFeatureValue(slotId, type, value));
984     return TELEPHONY_SUCCESS;
985 }
986 
OnGetImsFeatureValueInner(MessageParcel & data,MessageParcel & reply)987 int32_t CellularCallStub::OnGetImsFeatureValueInner(MessageParcel &data, MessageParcel &reply)
988 {
989     TELEPHONY_LOGI("CellularCallStub::OnGetImsFeatureValueInner entry");
990     int32_t size = data.ReadInt32();
991     size = ((size > MAX_SIZE) ? 0 : size);
992     if (size <= 0) {
993         TELEPHONY_LOGE("CellularCallStub::OnGetImsFeatureValueInner data size error");
994         return TELEPHONY_ERR_FAIL;
995     }
996     int32_t slotId = data.ReadInt32();
997     auto type = static_cast<FeatureType>(data.ReadInt32());
998 
999     reply.WriteInt32(GetImsFeatureValue(slotId, type));
1000     return TELEPHONY_SUCCESS;
1001 }
1002 
OnControlCameraInner(MessageParcel & data,MessageParcel & reply)1003 int32_t CellularCallStub::OnControlCameraInner(MessageParcel &data, MessageParcel &reply)
1004 {
1005     TELEPHONY_LOGI("CellularCallStub::OnControlCameraInner entry");
1006     int32_t size = data.ReadInt32();
1007     size = ((size > MAX_SIZE) ? 0 : size);
1008     if (size <= 0) {
1009         TELEPHONY_LOGE("CellularCallStub::OnControlCameraInner data size error");
1010         return TELEPHONY_ERR_FAIL;
1011     }
1012     int32_t slotId = data.ReadInt32();
1013     int32_t callIndex = data.ReadInt32();
1014     std::string cameraId = data.ReadString();
1015     reply.WriteInt32(ControlCamera(slotId, callIndex, cameraId));
1016     return TELEPHONY_SUCCESS;
1017 }
1018 
OnSetPreviewWindowInner(MessageParcel & data,MessageParcel & reply)1019 int32_t CellularCallStub::OnSetPreviewWindowInner(MessageParcel &data, MessageParcel &reply)
1020 {
1021     TELEPHONY_LOGI("CellularCallStub::OnSetPreviewWindowInner entry");
1022     int32_t size = data.ReadInt32();
1023     size = ((size > MAX_SIZE) ? 0 : size);
1024     if (size <= 0) {
1025         TELEPHONY_LOGE("CellularCallStub::OnSetPreviewWindowInner data size error");
1026         return TELEPHONY_ERR_FAIL;
1027     }
1028     int32_t slotId = data.ReadInt32();
1029     int32_t callIndex = data.ReadInt32();
1030     const std::string surfaceID = data.ReadString();
1031     sptr<Surface> surface = nullptr;
1032     sptr<IRemoteObject> object = data.ReadRemoteObject();
1033     if (object != nullptr) {
1034         sptr<IBufferProducer> producer = iface_cast<IBufferProducer>(object);
1035         surface = Surface::CreateSurfaceAsProducer(producer);
1036     }
1037     TELEPHONY_LOGI("surfaceId:%{public}s", surfaceID.c_str());
1038     reply.WriteInt32(SetPreviewWindow(slotId, callIndex, surfaceID, surface));
1039     return TELEPHONY_SUCCESS;
1040 }
1041 
OnSetDisplayWindowInner(MessageParcel & data,MessageParcel & reply)1042 int32_t CellularCallStub::OnSetDisplayWindowInner(MessageParcel &data, MessageParcel &reply)
1043 {
1044     TELEPHONY_LOGI("CellularCallStub::OnSetDisplayWindowInner entry");
1045     int32_t size = data.ReadInt32();
1046     size = ((size > MAX_SIZE) ? 0 : size);
1047     if (size <= 0) {
1048         TELEPHONY_LOGE("CellularCallStub::OnSetDisplayWindowInner data size error");
1049         return TELEPHONY_ERR_FAIL;
1050     }
1051     int32_t slotId = data.ReadInt32();
1052     int32_t callIndex = data.ReadInt32();
1053     const std::string surfaceID = data.ReadString();
1054     sptr<Surface> surface = nullptr;
1055     sptr<IRemoteObject> object = data.ReadRemoteObject();
1056     if (object != nullptr) {
1057         sptr<IBufferProducer> producer = iface_cast<IBufferProducer>(object);
1058         surface = Surface::CreateSurfaceAsProducer(producer);
1059     }
1060     TELEPHONY_LOGI("surfaceId:%{public}s", surfaceID.c_str());
1061     reply.WriteInt32(SetDisplayWindow(slotId, callIndex, surfaceID, surface));
1062     return TELEPHONY_SUCCESS;
1063 }
1064 
OnSetCameraZoomInner(MessageParcel & data,MessageParcel & reply)1065 int32_t CellularCallStub::OnSetCameraZoomInner(MessageParcel &data, MessageParcel &reply)
1066 {
1067     TELEPHONY_LOGI("CellularCallStub::OnSetCameraZoomInner entry");
1068     int32_t size = data.ReadInt32();
1069     size = ((size > MAX_SIZE) ? 0 : size);
1070     if (size <= 0) {
1071         TELEPHONY_LOGE("CellularCallStub::OnSetCameraZoomInner data size error");
1072         return TELEPHONY_ERR_FAIL;
1073     }
1074     float zoomRatio = data.ReadFloat();
1075 
1076     reply.WriteInt32(SetCameraZoom(zoomRatio));
1077     return TELEPHONY_SUCCESS;
1078 }
1079 
OnSetPausePictureInner(MessageParcel & data,MessageParcel & reply)1080 int32_t CellularCallStub::OnSetPausePictureInner(MessageParcel &data, MessageParcel &reply)
1081 {
1082     TELEPHONY_LOGI("CellularCallStub::OnSetPausePictureInner entry");
1083     int32_t size = data.ReadInt32();
1084     size = ((size > MAX_SIZE) ? 0 : size);
1085     if (size <= 0) {
1086         TELEPHONY_LOGE("CellularCallStub::OnSetPausePictureInner data size error");
1087         return TELEPHONY_ERR_FAIL;
1088     }
1089     int32_t slotId = data.ReadInt32();
1090     int32_t callIndex = data.ReadInt32();
1091     std::string imagePath = data.ReadString();
1092     reply.WriteInt32(SetPausePicture(slotId, callIndex, imagePath));
1093     return TELEPHONY_SUCCESS;
1094 }
1095 
OnSetDeviceDirectionInner(MessageParcel & data,MessageParcel & reply)1096 int32_t CellularCallStub::OnSetDeviceDirectionInner(MessageParcel &data, MessageParcel &reply)
1097 {
1098     TELEPHONY_LOGI("CellularCallStub::OnSetDeviceDirectionInner entry");
1099     int32_t size = data.ReadInt32();
1100     size = ((size > MAX_SIZE) ? 0 : size);
1101     if (size <= 0) {
1102         TELEPHONY_LOGE("CellularCallStub::OnSetDeviceDirectionInner data size error");
1103         return TELEPHONY_ERR_FAIL;
1104     }
1105     int32_t slotId = data.ReadInt32();
1106     int32_t callIndex = data.ReadInt32();
1107     int32_t rotation = data.ReadInt32();
1108     reply.WriteInt32(SetDeviceDirection(slotId, callIndex, rotation));
1109     return TELEPHONY_SUCCESS;
1110 }
1111 
OnSetMuteInner(MessageParcel & data,MessageParcel & reply)1112 int32_t CellularCallStub::OnSetMuteInner(MessageParcel &data, MessageParcel &reply)
1113 {
1114     TELEPHONY_LOGI("CellularCallStub::OnSetMuteInner entry");
1115     int32_t size = data.ReadInt32();
1116     size = ((size > MAX_SIZE) ? 0 : size);
1117     if (size <= 0) {
1118         TELEPHONY_LOGE("CellularCallStub::OnSetMuteInner data size error");
1119         return TELEPHONY_ERR_FAIL;
1120     }
1121     int32_t slotId = data.ReadInt32();
1122     int32_t mute = data.ReadInt32();
1123 
1124     reply.WriteInt32(SetMute(slotId, mute));
1125     return TELEPHONY_SUCCESS;
1126 }
1127 
OnGetMuteInner(MessageParcel & data,MessageParcel & reply)1128 int32_t CellularCallStub::OnGetMuteInner(MessageParcel &data, MessageParcel &reply)
1129 {
1130     TELEPHONY_LOGI("CellularCallStub::OnGetMuteInner entry");
1131     int32_t size = data.ReadInt32();
1132     size = ((size > MAX_SIZE) ? 0 : size);
1133     if (size <= 0) {
1134         TELEPHONY_LOGE("CellularCallStub::OnGetMuteInner data size error");
1135         return TELEPHONY_ERR_FAIL;
1136     }
1137     int32_t slotId = data.ReadInt32();
1138 
1139     reply.WriteInt32(GetMute(slotId));
1140     return TELEPHONY_SUCCESS;
1141 }
1142 
OnCloseUnFinishedUssdInner(MessageParcel & data,MessageParcel & reply)1143 int32_t CellularCallStub::OnCloseUnFinishedUssdInner(MessageParcel &data, MessageParcel &reply)
1144 {
1145     TELEPHONY_LOGI("CellularCallStub::OnCloseUnFinishedUssdInner entry");
1146     int32_t size = data.ReadInt32();
1147     size = ((size > MAX_SIZE) ? 0 : size);
1148     if (size <= 0) {
1149         TELEPHONY_LOGE("CellularCallStub::OnCloseUnFinishedUssdInner data size error");
1150         return TELEPHONY_ERR_FAIL;
1151     }
1152     int32_t slotId = data.ReadInt32();
1153 
1154     reply.WriteInt32(CloseUnFinishedUssd(slotId));
1155     return TELEPHONY_SUCCESS;
1156 }
1157 
OnClearAllCallsInner(MessageParcel & data,MessageParcel & reply)1158 int32_t CellularCallStub::OnClearAllCallsInner(MessageParcel &data, MessageParcel &reply)
1159 {
1160     TELEPHONY_LOGI("CellularCallStub::OnClearAllCallsInner entry");
1161     int32_t size = data.ReadInt32();
1162     if (size <= 0 || size > MAX_CALL_NUM) {
1163         TELEPHONY_LOGE("data size error");
1164         return TELEPHONY_ERR_ARGUMENT_INVALID;
1165     }
1166     std::vector<CellularCallInfo> callInfos;
1167     for (int32_t i = 0; i < size; i++) {
1168         CellularCallInfo *callInfo = (CellularCallInfo *)data.ReadRawData(sizeof(CellularCallInfo));
1169         if (callInfo != nullptr) {
1170             callInfos.push_back(*callInfo);
1171         }
1172     }
1173     reply.WriteInt32(ClearAllCalls(callInfos));
1174     return TELEPHONY_SUCCESS;
1175 }
1176 } // namespace Telephony
1177 } // namespace OHOS
1178