1 /*
2 * Copyright (C) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 #include "ims_call_stub.h"
16 #include "ipc_skeleton.h"
17
18 #include "telephony_log_wrapper.h"
19
20 namespace OHOS {
21 namespace Telephony {
22 const int32_t IMS_CAPABILITIES_MAX_SIZE = 10;
ImsCallStub()23 ImsCallStub::ImsCallStub()
24 {
25 InitFuncMap();
26 }
27
~ImsCallStub()28 ImsCallStub::~ImsCallStub() {}
29
InitFuncMap()30 void ImsCallStub::InitFuncMap()
31 {
32 InitDialFuncMap();
33 InitDtmfFuncMap();
34 InitConfigFuncMap();
35 InitVideoFuncMap();
36 InitSupplementFuncMap();
37 }
38
InitDialFuncMap()39 void ImsCallStub::InitDialFuncMap()
40 {
41 memberFuncMap_[IMS_DIAL] = [this](MessageParcel &data, MessageParcel &reply) { return OnDial(data, reply); };
42 memberFuncMap_[IMS_HANG_UP] = [this](MessageParcel &data, MessageParcel &reply) { return OnHangUp(data, reply); };
43 memberFuncMap_[IMS_REJECT_WITH_REASON] =
44 [this](MessageParcel &data, MessageParcel &reply) { return OnRejectWithReason(data, reply); };
45 memberFuncMap_[IMS_ANSWER] = [this](MessageParcel &data, MessageParcel &reply) { return OnAnswer(data, reply); };
46 memberFuncMap_[IMS_HOLD] = [this](MessageParcel &data, MessageParcel &reply) { return OnHoldCall(data, reply); };
47 memberFuncMap_[IMS_UN_HOLD] =
48 [this](MessageParcel &data, MessageParcel &reply) { return OnUnHoldCall(data, reply); };
49 memberFuncMap_[IMS_SWITCH] =
50 [this](MessageParcel &data, MessageParcel &reply) { return OnSwitchCall(data, reply); };
51 memberFuncMap_[IMS_COMBINE_CONFERENCE] =
52 [this](MessageParcel &data, MessageParcel &reply) { return OnCombineConference(data, reply); };
53 memberFuncMap_[IMS_INVITE_TO_CONFERENCE] =
54 [this](MessageParcel &data, MessageParcel &reply) { return OnInviteToConference(data, reply); };
55 memberFuncMap_[IMS_KICK_OUT_CONFERENCE] =
56 [this](MessageParcel &data, MessageParcel &reply) { return OnKickOutFromConference(data, reply); };
57 memberFuncMap_[IMS_UPDATE_CALL_MEDIA_MODE] =
58 [this](MessageParcel &data, MessageParcel &reply) { return OnUpdateImsCallMode(data, reply); };
59 memberFuncMap_[IMS_GET_CALL_DATA] =
60 [this](MessageParcel &data, MessageParcel &reply) { return OnGetImsCallsDataRequest(data, reply); };
61 memberFuncMap_[IMS_GET_LAST_CALL_FAIL_REASON] =
62 [this](MessageParcel &data, MessageParcel &reply) { return OnGetLastCallFailReason(data, reply); };
63 }
64
InitDtmfFuncMap()65 void ImsCallStub::InitDtmfFuncMap()
66 {
67 memberFuncMap_[IMS_START_DTMF] =
68 [this](MessageParcel &data, MessageParcel &reply) { return OnStartDtmf(data, reply); };
69 memberFuncMap_[IMS_SEND_DTMF] =
70 [this](MessageParcel &data, MessageParcel &reply) { return OnSendDtmf(data, reply); };
71 memberFuncMap_[IMS_STOP_DTMF] =
72 [this](MessageParcel &data, MessageParcel &reply) { return OnStopDtmf(data, reply); };
73 memberFuncMap_[IMS_START_RTT] =
74 [this](MessageParcel &data, MessageParcel &reply) { return OnStartRtt(data, reply); };
75 memberFuncMap_[IMS_STOP_RTT] = [this](MessageParcel &data, MessageParcel &reply) { return OnStopRtt(data, reply); };
76 }
77
InitConfigFuncMap()78 void ImsCallStub::InitConfigFuncMap()
79 {
80 memberFuncMap_[IMS_SET_DOMAIN_PREFERENCE_MODE] =
81 [this](MessageParcel &data, MessageParcel &reply) { return OnSetDomainPreferenceMode(data, reply); };
82 memberFuncMap_[IMS_GET_DOMAIN_PREFERENCE_MODE] =
83 [this](MessageParcel &data, MessageParcel &reply) { return OnGetDomainPreferenceMode(data, reply); };
84 memberFuncMap_[IMS_SET_SWITCH_STATUS] =
85 [this](MessageParcel &data, MessageParcel &reply) { return OnSetImsSwitchStatus(data, reply); };
86 memberFuncMap_[IMS_GET_SWITCH_STATUS] =
87 [this](MessageParcel &data, MessageParcel &reply) { return OnGetImsSwitchStatus(data, reply); };
88 memberFuncMap_[IMS_SET_IMS_CONFIG_STRING] =
89 [this](MessageParcel &data, MessageParcel &reply) { return OnSetImsConfigString(data, reply); };
90 memberFuncMap_[IMS_SET_IMS_CONFIG_INT] =
91 [this](MessageParcel &data, MessageParcel &reply) { return OnSetImsConfigInt(data, reply); };
92 memberFuncMap_[IMS_GET_IMS_CONFIG] =
93 [this](MessageParcel &data, MessageParcel &reply) { return OnGetImsConfig(data, reply); };
94 memberFuncMap_[IMS_SET_IMS_FEATURE] =
95 [this](MessageParcel &data, MessageParcel &reply) { return OnSetImsFeatureValue(data, reply); };
96 memberFuncMap_[IMS_GET_IMS_FEATURE] =
97 [this](MessageParcel &data, MessageParcel &reply) { return OnGetImsFeatureValue(data, reply); };
98 memberFuncMap_[IMS_SET_MUTE] = [this](MessageParcel &data, MessageParcel &reply) { return OnSetMute(data, reply); };
99 memberFuncMap_[IMS_GET_MUTE] = [this](MessageParcel &data, MessageParcel &reply) { return OnGetMute(data, reply); };
100 memberFuncMap_[IMS_UPDATE_CAPABILITY] =
101 [this](MessageParcel &data, MessageParcel &reply) { return OnUpdateImsCapabilities(data, reply); };
102 }
103
InitVideoFuncMap()104 void ImsCallStub::InitVideoFuncMap()
105 {
106 memberFuncMap_[IMS_CTRL_CAMERA] =
107 [this](MessageParcel &data, MessageParcel &reply) { return OnCtrlCamera(data, reply); };
108 memberFuncMap_[IMS_SET_PREVIEW_WINDOW] =
109 [this](MessageParcel &data, MessageParcel &reply) { return OnSetPreviewWindow(data, reply); };
110 memberFuncMap_[IMS_SET_DISPLAY_WINDOW] =
111 [this](MessageParcel &data, MessageParcel &reply) { return OnSetDisplayWindow(data, reply); };
112 memberFuncMap_[IMS_SET_CAMERA_ZOOM] =
113 [this](MessageParcel &data, MessageParcel &reply) { return OnSetCameraZoom(data, reply); };
114 memberFuncMap_[IMS_SET_PAUSE_IMAGE] =
115 [this](MessageParcel &data, MessageParcel &reply) { return OnSetPauseImage(data, reply); };
116 memberFuncMap_[IMS_SET_DEVICE_DIRECTION] =
117 [this](MessageParcel &data, MessageParcel &reply) { return OnSetDeviceDirection(data, reply); };
118 }
119
InitSupplementFuncMap()120 void ImsCallStub::InitSupplementFuncMap()
121 {
122 memberFuncMap_[IMS_SET_CLIP] = [this](MessageParcel &data, MessageParcel &reply) { return OnGetClip(data, reply); };
123 memberFuncMap_[IMS_GET_CLIP] = [this](MessageParcel &data, MessageParcel &reply) { return OnGetClip(data, reply); };
124 memberFuncMap_[IMS_SET_CLIR] = [this](MessageParcel &data, MessageParcel &reply) { return OnSetClir(data, reply); };
125 memberFuncMap_[IMS_GET_CLIR] = [this](MessageParcel &data, MessageParcel &reply) { return OnGetClir(data, reply); };
126 memberFuncMap_[IMS_SET_CALL_TRANSFER] =
127 [this](MessageParcel &data, MessageParcel &reply) { return OnSetCallTransfer(data, reply); };
128 memberFuncMap_[IMS_GET_CALL_TRANSFER] =
129 [this](MessageParcel &data, MessageParcel &reply) { return OnGetCallTransfer(data, reply); };
130 memberFuncMap_[IMS_SET_CALL_RESTRICTION] =
131 [this](MessageParcel &data, MessageParcel &reply) { return OnSetCallRestriction(data, reply); };
132 memberFuncMap_[IMS_GET_CALL_RESTRICTION] =
133 [this](MessageParcel &data, MessageParcel &reply) { return OnGetCallRestriction(data, reply); };
134 memberFuncMap_[IMS_SET_CALL_WAITING] =
135 [this](MessageParcel &data, MessageParcel &reply) { return OnSetCallWaiting(data, reply); };
136 memberFuncMap_[IMS_GET_CALL_WAITING] =
137 [this](MessageParcel &data, MessageParcel &reply) { return OnGetCallWaiting(data, reply); };
138 memberFuncMap_[IMS_SET_COLR] = [this](MessageParcel &data, MessageParcel &reply) { return OnSetColr(data, reply); };
139 memberFuncMap_[IMS_GET_COLR] = [this](MessageParcel &data, MessageParcel &reply) { return OnGetColr(data, reply); };
140 memberFuncMap_[IMS_SET_COLP] = [this](MessageParcel &data, MessageParcel &reply) { return OnSetColp(data, reply); };
141 memberFuncMap_[IMS_GET_COLP] = [this](MessageParcel &data, MessageParcel &reply) { return OnGetColp(data, reply); };
142
143 memberFuncMap_[IMS_CALL_REGISTER_CALLBACK] =
144 [this](MessageParcel &data, MessageParcel &reply) { return OnRegisterImsCallCallback(data, reply); };
145 }
146
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)147 int32_t ImsCallStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
148 {
149 std::u16string descriptor = ImsCallStub::GetDescriptor();
150 std::u16string remoteDescriptor = data.ReadInterfaceToken();
151 if (descriptor != remoteDescriptor) {
152 TELEPHONY_LOGE("descriptor checking fail!");
153 return TELEPHONY_ERR_DESCRIPTOR_MISMATCH;
154 }
155 TELEPHONY_LOGI("OnReceived, cmd = %{public}u", code);
156 auto itFunction = memberFuncMap_.find(code);
157 if (itFunction != memberFuncMap_.end()) {
158 auto memberFunc = itFunction->second;
159 if (memberFunc != nullptr) {
160 return memberFunc(data, reply);
161 }
162 }
163 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
164 }
165
OnDial(MessageParcel & data,MessageParcel & reply)166 int32_t ImsCallStub::OnDial(MessageParcel &data, MessageParcel &reply)
167 {
168 ImsCallInfo *callInfo = (ImsCallInfo *)data.ReadRawData(sizeof(ImsCallInfo));
169 int32_t dialResult = TELEPHONY_ERR_LOCAL_PTR_NULL;
170 if (callInfo == nullptr) {
171 TELEPHONY_LOGE("ImsCallInfo is nullptr");
172 reply.WriteInt32(dialResult);
173 return dialResult;
174 }
175 auto mode = static_cast<CLIRMode>(data.ReadInt32());
176
177 reply.WriteInt32(Dial(*callInfo, mode));
178 return TELEPHONY_SUCCESS;
179 }
180
OnHangUp(MessageParcel & data,MessageParcel & reply)181 int32_t ImsCallStub::OnHangUp(MessageParcel &data, MessageParcel &reply)
182 {
183 ImsCallInfo *callInfo = (ImsCallInfo *)data.ReadRawData(sizeof(ImsCallInfo));
184 int32_t hangUpResult = TELEPHONY_ERR_LOCAL_PTR_NULL;
185 if (callInfo == nullptr) {
186 TELEPHONY_LOGE("ImsCallInfo is nullptr");
187 reply.WriteInt32(hangUpResult);
188 return hangUpResult;
189 }
190 reply.WriteInt32(HangUp(*callInfo));
191 return TELEPHONY_SUCCESS;
192 }
193
OnRejectWithReason(MessageParcel & data,MessageParcel & reply)194 int32_t ImsCallStub::OnRejectWithReason(MessageParcel &data, MessageParcel &reply)
195 {
196 ImsCallInfo *callInfo = (ImsCallInfo *)data.ReadRawData(sizeof(ImsCallInfo));
197 int32_t onRejectResult = TELEPHONY_ERR_LOCAL_PTR_NULL;
198 if (callInfo == nullptr) {
199 TELEPHONY_LOGE("ImsCallInfo is nullptr");
200 reply.WriteInt32(onRejectResult);
201 return onRejectResult;
202 }
203 auto imsRejectReason = static_cast<ImsRejectReason>(data.ReadInt32());
204
205 reply.WriteInt32(RejectWithReason(*callInfo, imsRejectReason));
206 return TELEPHONY_SUCCESS;
207 }
208
OnAnswer(MessageParcel & data,MessageParcel & reply)209 int32_t ImsCallStub::OnAnswer(MessageParcel &data, MessageParcel &reply)
210 {
211 ImsCallInfo *callInfo = (ImsCallInfo *)data.ReadRawData(sizeof(ImsCallInfo));
212 int32_t answerResult = TELEPHONY_ERR_LOCAL_PTR_NULL;
213 if (callInfo == nullptr) {
214 TELEPHONY_LOGE("ImsCallInfo is nullptr");
215 reply.WriteInt32(answerResult);
216 return answerResult;
217 }
218 reply.WriteInt32(Answer(*callInfo));
219 return TELEPHONY_SUCCESS;
220 }
221
OnHoldCall(MessageParcel & data,MessageParcel & reply)222 int32_t ImsCallStub::OnHoldCall(MessageParcel &data, MessageParcel &reply)
223 {
224 int32_t slotId = data.ReadInt32();
225 int32_t callType = data.ReadInt32();
226 reply.WriteInt32(HoldCall(slotId, callType));
227 return TELEPHONY_SUCCESS;
228 }
229
OnUnHoldCall(MessageParcel & data,MessageParcel & reply)230 int32_t ImsCallStub::OnUnHoldCall(MessageParcel &data, MessageParcel &reply)
231 {
232 int32_t slotId = data.ReadInt32();
233 int32_t callType = data.ReadInt32();
234 reply.WriteInt32(UnHoldCall(slotId, callType));
235 return TELEPHONY_SUCCESS;
236 }
237
OnSwitchCall(MessageParcel & data,MessageParcel & reply)238 int32_t ImsCallStub::OnSwitchCall(MessageParcel &data, MessageParcel &reply)
239 {
240 int32_t slotId = data.ReadInt32();
241 int32_t callType = data.ReadInt32();
242 reply.WriteInt32(SwitchCall(slotId, callType));
243 return TELEPHONY_SUCCESS;
244 }
245
OnCombineConference(MessageParcel & data,MessageParcel & reply)246 int32_t ImsCallStub::OnCombineConference(MessageParcel &data, MessageParcel &reply)
247 {
248 int32_t slotId = data.ReadInt32();
249 reply.WriteInt32(CombineConference(slotId));
250 return TELEPHONY_SUCCESS;
251 }
252
OnInviteToConference(MessageParcel & data,MessageParcel & reply)253 int32_t ImsCallStub::OnInviteToConference(MessageParcel &data, MessageParcel &reply)
254 {
255 int32_t slotId = data.ReadInt32();
256 std::vector<std::string> numberList;
257 if (!data.ReadStringVector(&numberList)) {
258 TELEPHONY_LOGE("Read string vector failed!");
259 return TELEPHONY_ERR_FAIL;
260 }
261 reply.WriteInt32(InviteToConference(slotId, numberList));
262
263 return TELEPHONY_SUCCESS;
264 }
265
OnKickOutFromConference(MessageParcel & data,MessageParcel & reply)266 int32_t ImsCallStub::OnKickOutFromConference(MessageParcel &data, MessageParcel &reply)
267 {
268 int32_t slotId = data.ReadInt32();
269 int32_t kickoutCallIndex = data.ReadInt32();
270 if (!IsValidSlotId(slotId)) {
271 TELEPHONY_LOGE("invalid slotId[%{public}d]", slotId);
272 reply.WriteInt32(TELEPHONY_ERR_FAIL);
273 return TELEPHONY_ERR_SLOTID_INVALID;
274 }
275 reply.WriteInt32(KickOutFromConference(slotId, kickoutCallIndex));
276 return TELEPHONY_SUCCESS;
277 }
278
OnUpdateImsCallMode(MessageParcel & data,MessageParcel & reply)279 int32_t ImsCallStub::OnUpdateImsCallMode(MessageParcel &data, MessageParcel &reply)
280 {
281 ImsCallInfo *imsCallInfo = (ImsCallInfo *)data.ReadRawData(sizeof(ImsCallInfo));
282 int32_t result = TELEPHONY_ERR_LOCAL_PTR_NULL;
283 if (imsCallInfo == nullptr) {
284 TELEPHONY_LOGE("ImsCallInfo is nullptr");
285 reply.WriteInt32(result);
286 return result;
287 }
288 auto callMode = static_cast<ImsCallMode>(data.ReadInt32());
289
290 reply.WriteInt32(UpdateImsCallMode(*imsCallInfo, callMode));
291 return TELEPHONY_SUCCESS;
292 }
293
OnGetImsCallsDataRequest(MessageParcel & data,MessageParcel & reply)294 int32_t ImsCallStub::OnGetImsCallsDataRequest(MessageParcel &data, MessageParcel &reply)
295 {
296 int32_t slotId = data.ReadInt32();
297 int64_t lastCallsDataFlag = data.ReadInt64();
298 reply.WriteInt32(GetImsCallsDataRequest(slotId, lastCallsDataFlag));
299 return TELEPHONY_SUCCESS;
300 }
301
OnGetLastCallFailReason(MessageParcel & data,MessageParcel & reply)302 int32_t ImsCallStub::OnGetLastCallFailReason(MessageParcel &data, MessageParcel &reply)
303 {
304 int32_t slotId = data.ReadInt32();
305 reply.WriteInt32(GetLastCallFailReason(slotId));
306 return TELEPHONY_SUCCESS;
307 }
308
OnStartDtmf(MessageParcel & data,MessageParcel & reply)309 int32_t ImsCallStub::OnStartDtmf(MessageParcel &data, MessageParcel &reply)
310 {
311 int32_t slotId = data.ReadInt32();
312 const char cDtmfCode = data.ReadInt8();
313 int32_t index = data.ReadInt32();
314
315 reply.WriteInt32(StartDtmf(slotId, cDtmfCode, index));
316 return TELEPHONY_SUCCESS;
317 }
318
OnSendDtmf(MessageParcel & data,MessageParcel & reply)319 int32_t ImsCallStub::OnSendDtmf(MessageParcel &data, MessageParcel &reply)
320 {
321 int32_t slotId = data.ReadInt32();
322 const char cDtmfCode = data.ReadInt8();
323 int32_t index = data.ReadInt32();
324
325 reply.WriteInt32(SendDtmf(slotId, cDtmfCode, index));
326 return TELEPHONY_SUCCESS;
327 }
328
OnStopDtmf(MessageParcel & data,MessageParcel & reply)329 int32_t ImsCallStub::OnStopDtmf(MessageParcel &data, MessageParcel &reply)
330 {
331 int32_t slotId = data.ReadInt32();
332 int32_t index = data.ReadInt32();
333
334 reply.WriteInt32(StopDtmf(slotId, index));
335 return TELEPHONY_SUCCESS;
336 }
337
OnStartRtt(MessageParcel & data,MessageParcel & reply)338 int32_t ImsCallStub::OnStartRtt(MessageParcel &data, MessageParcel &reply)
339 {
340 int32_t slotId = data.ReadInt32();
341 const std::string msg = data.ReadString();
342 reply.WriteInt32(StartRtt(slotId, msg));
343
344 return TELEPHONY_SUCCESS;
345 }
346
OnStopRtt(MessageParcel & data,MessageParcel & reply)347 int32_t ImsCallStub::OnStopRtt(MessageParcel &data, MessageParcel &reply)
348 {
349 int32_t slotId = data.ReadInt32();
350
351 reply.WriteInt32(StopRtt(slotId));
352 return TELEPHONY_SUCCESS;
353 }
354
OnSetDomainPreferenceMode(MessageParcel & data,MessageParcel & reply)355 int32_t ImsCallStub::OnSetDomainPreferenceMode(MessageParcel &data, MessageParcel &reply)
356 {
357 int32_t slotId = data.ReadInt32();
358 int32_t mode = data.ReadInt32();
359
360 reply.WriteInt32(SetDomainPreferenceMode(slotId, mode));
361 return TELEPHONY_SUCCESS;
362 }
363
OnGetDomainPreferenceMode(MessageParcel & data,MessageParcel & reply)364 int32_t ImsCallStub::OnGetDomainPreferenceMode(MessageParcel &data, MessageParcel &reply)
365 {
366 int32_t slotId = data.ReadInt32();
367
368 reply.WriteInt32(GetDomainPreferenceMode(slotId));
369 return TELEPHONY_SUCCESS;
370 }
371
OnSetImsSwitchStatus(MessageParcel & data,MessageParcel & reply)372 int32_t ImsCallStub::OnSetImsSwitchStatus(MessageParcel &data, MessageParcel &reply)
373 {
374 int32_t slotId = data.ReadInt32();
375 int32_t active = data.ReadInt32();
376
377 reply.WriteInt32(SetImsSwitchStatus(slotId, active));
378 return TELEPHONY_SUCCESS;
379 }
380
OnGetImsSwitchStatus(MessageParcel & data,MessageParcel & reply)381 int32_t ImsCallStub::OnGetImsSwitchStatus(MessageParcel &data, MessageParcel &reply)
382 {
383 int32_t slotId = data.ReadInt32();
384
385 reply.WriteInt32(GetImsSwitchStatus(slotId));
386 return TELEPHONY_SUCCESS;
387 }
388
OnSetImsConfigInt(MessageParcel & data,MessageParcel & reply)389 int32_t ImsCallStub::OnSetImsConfigInt(MessageParcel &data, MessageParcel &reply)
390 {
391 auto item = static_cast<ImsConfigItem>(data.ReadInt32());
392 int32_t imsConfigValue = data.ReadInt32();
393
394 reply.WriteInt32(SetImsConfig(item, imsConfigValue));
395 return TELEPHONY_SUCCESS;
396 }
397
OnSetImsConfigString(MessageParcel & data,MessageParcel & reply)398 int32_t ImsCallStub::OnSetImsConfigString(MessageParcel &data, MessageParcel &reply)
399 {
400 auto imsConfigItem = static_cast<ImsConfigItem>(data.ReadInt32());
401 std::string imsConfigValue = data.ReadString();
402
403 reply.WriteInt32(SetImsConfig(imsConfigItem, imsConfigValue));
404 return TELEPHONY_SUCCESS;
405 }
406
OnGetImsConfig(MessageParcel & data,MessageParcel & reply)407 int32_t ImsCallStub::OnGetImsConfig(MessageParcel &data, MessageParcel &reply)
408 {
409 auto imsConfigItem = static_cast<ImsConfigItem>(data.ReadInt32());
410
411 reply.WriteInt32(GetImsConfig(imsConfigItem));
412 return TELEPHONY_SUCCESS;
413 }
414
OnSetImsFeatureValue(MessageParcel & data,MessageParcel & reply)415 int32_t ImsCallStub::OnSetImsFeatureValue(MessageParcel &data, MessageParcel &reply)
416 {
417 auto type = static_cast<FeatureType>(data.ReadInt32());
418 int32_t imsFeatureValue = data.ReadInt32();
419
420 reply.WriteInt32(SetImsFeatureValue(type, imsFeatureValue));
421
422 return TELEPHONY_SUCCESS;
423 }
424
OnGetImsFeatureValue(MessageParcel & data,MessageParcel & reply)425 int32_t ImsCallStub::OnGetImsFeatureValue(MessageParcel &data, MessageParcel &reply)
426 {
427 auto type = static_cast<FeatureType>(data.ReadInt32());
428
429 int32_t imsFeatureValue = ImsFeatureIntResult::IMS_FEATURE_INT_RESULT_UNKNOWN;
430 reply.WriteInt32(GetImsFeatureValue(type, imsFeatureValue));
431 reply.WriteInt32(imsFeatureValue);
432
433 return TELEPHONY_SUCCESS;
434 }
435
OnSetMute(MessageParcel & data,MessageParcel & reply)436 int32_t ImsCallStub::OnSetMute(MessageParcel &data, MessageParcel &reply)
437 {
438 int32_t slotId = data.ReadInt32();
439 int32_t mute = data.ReadInt32();
440 reply.WriteInt32(SetMute(slotId, mute));
441
442 return TELEPHONY_SUCCESS;
443 }
444
OnGetMute(MessageParcel & data,MessageParcel & reply)445 int32_t ImsCallStub::OnGetMute(MessageParcel &data, MessageParcel &reply)
446 {
447 int32_t slotId = data.ReadInt32();
448 reply.WriteInt32(GetMute(slotId));
449 return TELEPHONY_SUCCESS;
450 }
451
OnCtrlCamera(MessageParcel & data,MessageParcel & reply)452 int32_t ImsCallStub::OnCtrlCamera(MessageParcel &data, MessageParcel &reply)
453 {
454 const std::u16string cameraId = data.ReadString16();
455 auto callingPid = IPCSkeleton::GetCallingPid();
456 auto callingUid = IPCSkeleton::GetCallingUid();
457 reply.WriteInt32(CtrlCamera(cameraId, callingUid, callingPid));
458
459 return TELEPHONY_SUCCESS;
460 }
461
OnSetPreviewWindow(MessageParcel & data,MessageParcel & reply)462 int32_t ImsCallStub::OnSetPreviewWindow(MessageParcel &data, MessageParcel &reply)
463 {
464 int32_t previewWindowX = data.ReadInt32();
465 int32_t previewWindowY = data.ReadInt32();
466 int32_t previewWindowZ = data.ReadInt32();
467 int32_t width = data.ReadInt32();
468 int32_t height = data.ReadInt32();
469 reply.WriteInt32(SetPreviewWindow(previewWindowX, previewWindowY, previewWindowZ, width, height));
470
471 return TELEPHONY_SUCCESS;
472 }
473
OnSetDisplayWindow(MessageParcel & data,MessageParcel & reply)474 int32_t ImsCallStub::OnSetDisplayWindow(MessageParcel &data, MessageParcel &reply)
475 {
476 int32_t displayWindowX = data.ReadInt32();
477 int32_t displayWindowY = data.ReadInt32();
478 int32_t displayWindowZ = data.ReadInt32();
479 int32_t width = data.ReadInt32();
480 int32_t height = data.ReadInt32();
481 reply.WriteInt32(SetDisplayWindow(displayWindowX, displayWindowY, displayWindowZ, width, height));
482
483 return TELEPHONY_SUCCESS;
484 }
485
OnSetCameraZoom(MessageParcel & data,MessageParcel & reply)486 int32_t ImsCallStub::OnSetCameraZoom(MessageParcel &data, MessageParcel &reply)
487 {
488 float cameraZoomRatio = data.ReadFloat();
489 reply.WriteInt32(SetCameraZoom(cameraZoomRatio));
490
491 return TELEPHONY_SUCCESS;
492 }
493
OnSetPauseImage(MessageParcel & data,MessageParcel & reply)494 int32_t ImsCallStub::OnSetPauseImage(MessageParcel &data, MessageParcel &reply)
495 {
496 const std::u16string pauseImagePath = data.ReadString16();
497 reply.WriteInt32(SetPauseImage(pauseImagePath));
498 return TELEPHONY_SUCCESS;
499 }
500
OnSetDeviceDirection(MessageParcel & data,MessageParcel & reply)501 int32_t ImsCallStub::OnSetDeviceDirection(MessageParcel &data, MessageParcel &reply)
502 {
503 int32_t rotation = data.ReadInt32();
504 reply.WriteInt32(SetDeviceDirection(rotation));
505 return TELEPHONY_SUCCESS;
506 }
507
OnSetClip(MessageParcel & data,MessageParcel & reply)508 int32_t ImsCallStub::OnSetClip(MessageParcel &data, MessageParcel &reply)
509 {
510 int32_t slotId = data.ReadInt32();
511 int32_t action = data.ReadInt32();
512 reply.WriteInt32(SetClip(slotId, action));
513 return TELEPHONY_SUCCESS;
514 }
515
OnGetClip(MessageParcel & data,MessageParcel & reply)516 int32_t ImsCallStub::OnGetClip(MessageParcel &data, MessageParcel &reply)
517 {
518 int32_t slotId = data.ReadInt32();
519 reply.WriteInt32(GetClip(slotId));
520 return TELEPHONY_SUCCESS;
521 }
522
OnSetClir(MessageParcel & data,MessageParcel & reply)523 int32_t ImsCallStub::OnSetClir(MessageParcel &data, MessageParcel &reply)
524 {
525 int32_t slotId = data.ReadInt32();
526 int32_t action = data.ReadInt32();
527 reply.WriteInt32(SetClir(slotId, action));
528
529 return TELEPHONY_SUCCESS;
530 }
531
OnGetClir(MessageParcel & data,MessageParcel & reply)532 int32_t ImsCallStub::OnGetClir(MessageParcel &data, MessageParcel &reply)
533 {
534 int32_t slotId = data.ReadInt32();
535 reply.WriteInt32(GetClir(slotId));
536
537 return TELEPHONY_SUCCESS;
538 }
539
OnSetCallTransfer(MessageParcel & data,MessageParcel & reply)540 int32_t ImsCallStub::OnSetCallTransfer(MessageParcel &data, MessageParcel &reply)
541 {
542 int32_t slotId = data.ReadInt32();
543 int32_t reason = data.ReadInt32();
544 int32_t mode = data.ReadInt32();
545 const std::string transferNum = data.ReadString();
546 int32_t classType = data.ReadInt32();
547 reply.WriteInt32(SetCallTransfer(slotId, reason, mode, transferNum, classType));
548 return TELEPHONY_SUCCESS;
549 }
550
OnGetCallTransfer(MessageParcel & data,MessageParcel & reply)551 int32_t ImsCallStub::OnGetCallTransfer(MessageParcel &data, MessageParcel &reply)
552 {
553 int32_t slotId = data.ReadInt32();
554 int32_t reason = data.ReadInt32();
555 reply.WriteInt32(GetCallTransfer(slotId, reason));
556
557 return TELEPHONY_SUCCESS;
558 }
559
OnSetCallRestriction(MessageParcel & data,MessageParcel & reply)560 int32_t ImsCallStub::OnSetCallRestriction(MessageParcel &data, MessageParcel &reply)
561 {
562 int32_t slotId = data.ReadInt32();
563 const std::string fac = data.ReadString();
564 int32_t mode = data.ReadInt32();
565 const std::string pw = data.ReadString();
566 reply.WriteInt32(SetCallRestriction(slotId, fac, mode, pw));
567 return TELEPHONY_SUCCESS;
568 }
569
OnGetCallRestriction(MessageParcel & data,MessageParcel & reply)570 int32_t ImsCallStub::OnGetCallRestriction(MessageParcel &data, MessageParcel &reply)
571 {
572 int32_t slotId = data.ReadInt32();
573 const std::string fac = data.ReadString();
574 reply.WriteInt32(GetCallRestriction(slotId, fac));
575 return TELEPHONY_SUCCESS;
576 }
577
OnSetCallWaiting(MessageParcel & data,MessageParcel & reply)578 int32_t ImsCallStub::OnSetCallWaiting(MessageParcel &data, MessageParcel &reply)
579 {
580 int32_t slotId = data.ReadInt32();
581 bool activate = data.ReadBool();
582 int32_t classType = data.ReadInt32();
583 reply.WriteInt32(SetCallWaiting(slotId, activate, classType));
584 return TELEPHONY_SUCCESS;
585 }
586
OnGetCallWaiting(MessageParcel & data,MessageParcel & reply)587 int32_t ImsCallStub::OnGetCallWaiting(MessageParcel &data, MessageParcel &reply)
588 {
589 int32_t slotId = data.ReadInt32();
590 reply.WriteInt32(GetCallWaiting(slotId));
591 return TELEPHONY_SUCCESS;
592 }
593
OnSetColr(MessageParcel & data,MessageParcel & reply)594 int32_t ImsCallStub::OnSetColr(MessageParcel &data, MessageParcel &reply)
595 {
596 int32_t slotId = data.ReadInt32();
597 int32_t presentation = data.ReadInt32();
598 reply.WriteInt32(SetColr(slotId, presentation));
599 return TELEPHONY_SUCCESS;
600 }
601
OnGetColr(MessageParcel & data,MessageParcel & reply)602 int32_t ImsCallStub::OnGetColr(MessageParcel &data, MessageParcel &reply)
603 {
604 int32_t slotId = data.ReadInt32();
605 reply.WriteInt32(GetColr(slotId));
606 return TELEPHONY_SUCCESS;
607 }
608
OnSetColp(MessageParcel & data,MessageParcel & reply)609 int32_t ImsCallStub::OnSetColp(MessageParcel &data, MessageParcel &reply)
610 {
611 int32_t slotId = data.ReadInt32();
612 int32_t action = data.ReadInt32();
613 reply.WriteInt32(SetColp(slotId, action));
614 return TELEPHONY_SUCCESS;
615 }
616
OnGetColp(MessageParcel & data,MessageParcel & reply)617 int32_t ImsCallStub::OnGetColp(MessageParcel &data, MessageParcel &reply)
618 {
619 int32_t slotId = data.ReadInt32();
620 reply.WriteInt32(GetColp(slotId));
621 return TELEPHONY_SUCCESS;
622 }
623
OnRegisterImsCallCallback(MessageParcel & data,MessageParcel & reply)624 int32_t ImsCallStub::OnRegisterImsCallCallback(MessageParcel &data, MessageParcel &reply)
625 {
626 auto imsCallbackRemote = data.ReadRemoteObject();
627 int32_t result = TELEPHONY_ERR_LOCAL_PTR_NULL;
628 if (imsCallbackRemote == nullptr) {
629 TELEPHONY_LOGE("ImsCallInfo is nullptr");
630 reply.WriteInt32(result);
631 return result;
632 }
633 result = RegisterImsCallCallback(iface_cast<ImsCallCallbackInterface>(imsCallbackRemote));
634 reply.WriteInt32(result);
635 return TELEPHONY_SUCCESS;
636 }
637
OnUpdateImsCapabilities(MessageParcel & data,MessageParcel & reply)638 int32_t ImsCallStub::OnUpdateImsCapabilities(MessageParcel &data, MessageParcel &reply)
639 {
640 int32_t slotId = data.ReadInt32();
641 int32_t dataSize = data.ReadInt32();
642 if (dataSize < 0 || dataSize > IMS_CAPABILITIES_MAX_SIZE) {
643 TELEPHONY_LOGE("OnUpdateImsCapabilities size error");
644 return TELEPHONY_ERR_FAIL;
645 }
646 ImsCapability imsCapability;
647 ImsCapabilityList imsCapabilityList;
648 for (int i = 0; i < dataSize; i++) {
649 imsCapability.imsCapabilityType = static_cast<const ImsCapabilityType>(data.ReadInt32());
650 imsCapability.imsRadioTech = static_cast<const ImsRegTech>(data.ReadInt32());
651 imsCapability.enable = data.ReadBool();
652 imsCapabilityList.imsCapabilities.push_back(imsCapability);
653 }
654 reply.WriteInt32(UpdateImsCapabilities(slotId, imsCapabilityList));
655 return TELEPHONY_SUCCESS;
656 }
657 } // namespace Telephony
658 } // namespace OHOS
659