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