1 /*
2 * Copyright (C) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "call_status_callback_stub.h"
17
18 #include <securec.h>
19
20 #include "call_manager_errors.h"
21 #include "telephony_log_wrapper.h"
22
23 namespace OHOS {
24 namespace Telephony {
CallStatusCallbackStub()25 CallStatusCallbackStub::CallStatusCallbackStub()
26 {
27 memberFuncMap_[UPDATE_CALL_INFO] = &CallStatusCallbackStub::OnUpdateCallReportInfo;
28 memberFuncMap_[UPDATE_CALLS_INFO] = &CallStatusCallbackStub::OnUpdateCallsReportInfo;
29 memberFuncMap_[UPDATE_DISCONNECTED_CAUSE] = &CallStatusCallbackStub::OnUpdateDisconnectedCause;
30 memberFuncMap_[UPDATE_EVENT_RESULT_INFO] = &CallStatusCallbackStub::OnUpdateEventReport;
31 memberFuncMap_[UPDATE_RBT_PLAY_INFO] = &CallStatusCallbackStub::OnUpdateRBTPlayInfo;
32 memberFuncMap_[START_DTMF] = &CallStatusCallbackStub::OnStartDtmfResult;
33 memberFuncMap_[STOP_DTMF] = &CallStatusCallbackStub::OnStopDtmfResult;
34 memberFuncMap_[SEND_USSD] = &CallStatusCallbackStub::OnSendUssdResult;
35 memberFuncMap_[GET_IMS_CALL_DATA] = &CallStatusCallbackStub::OnGetImsCallDataResult;
36 memberFuncMap_[UPDATE_GET_WAITING] = &CallStatusCallbackStub::OnUpdateGetWaitingResult;
37 memberFuncMap_[UPDATE_SET_WAITING] = &CallStatusCallbackStub::OnUpdateSetWaitingResult;
38 memberFuncMap_[UPDATE_GET_RESTRICTION] = &CallStatusCallbackStub::OnUpdateGetRestrictionResult;
39 memberFuncMap_[UPDATE_SET_RESTRICTION] = &CallStatusCallbackStub::OnUpdateSetRestrictionResult;
40 memberFuncMap_[UPDATE_GET_TRANSFER] = &CallStatusCallbackStub::OnUpdateGetTransferResult;
41 memberFuncMap_[UPDATE_SET_TRANSFER] = &CallStatusCallbackStub::OnUpdateSetTransferResult;
42 memberFuncMap_[UPDATE_GET_CALL_CLIP] = &CallStatusCallbackStub::OnUpdateGetCallClipResult;
43 memberFuncMap_[UPDATE_GET_CALL_CLIR] = &CallStatusCallbackStub::OnUpdateGetCallClirResult;
44 memberFuncMap_[UPDATE_SET_CALL_CLIR] = &CallStatusCallbackStub::OnUpdateSetCallClirResult;
45 memberFuncMap_[GET_VOLTE_SWITCH_STATUS] = &CallStatusCallbackStub::OnGetVoLteStatusResult;
46 memberFuncMap_[SET_VOLTE_SWITCH_STATUS] = &CallStatusCallbackStub::OnSetVoLteStatusResult;
47 memberFuncMap_[GET_IMS_CONFIG] = &CallStatusCallbackStub::OnGetImsConfigResult;
48 memberFuncMap_[SET_IMS_CONFIG] = &CallStatusCallbackStub::OnSetImsConfigResult;
49 memberFuncMap_[GET_IMS_FEATURE_VALUE] = &CallStatusCallbackStub::OnGetImsFeatureValueResult;
50 memberFuncMap_[SET_IMS_FEATURE_VALUE] = &CallStatusCallbackStub::OnSetImsFeatureValueResult;
51 memberFuncMap_[GET_LTE_ENHANCE_MODE] = &CallStatusCallbackStub::OnGetLteEnhanceModeResult;
52 memberFuncMap_[SET_LTE_ENHANCE_MODE] = &CallStatusCallbackStub::OnSetLteEnhanceModeResult;
53 memberFuncMap_[RECEIVE_UPDATE_MEDIA_MODE_RESPONSE] = &CallStatusCallbackStub::OnReceiveUpdateMediaModeResponse;
54 memberFuncMap_[UPDATE_STARTRTT_STATUS] = &CallStatusCallbackStub::OnStartRttResult;
55 memberFuncMap_[UPDATE_STOPRTT_STATUS] = &CallStatusCallbackStub::OnStopRttResult;
56 memberFuncMap_[INVITE_TO_CONFERENCE] = &CallStatusCallbackStub::OnInviteToConferenceResult;
57 }
58
~CallStatusCallbackStub()59 CallStatusCallbackStub::~CallStatusCallbackStub()
60 {
61 memberFuncMap_.clear();
62 }
63
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)64 int32_t CallStatusCallbackStub::OnRemoteRequest(
65 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
66 {
67 std::u16string myDescriptor = CallStatusCallbackStub::GetDescriptor();
68 std::u16string remoteDescriptor = data.ReadInterfaceToken();
69 if (myDescriptor != remoteDescriptor) {
70 TELEPHONY_LOGE("descriptor checked failed");
71 return TELEPHONY_ERR_DESCRIPTOR_MISMATCH;
72 }
73 TELEPHONY_LOGI("OnReceived, cmd = %{public}u", code);
74 auto itFunc = memberFuncMap_.find(code);
75 if (itFunc != memberFuncMap_.end()) {
76 auto memberFunc = itFunc->second;
77 if (memberFunc != nullptr) {
78 return (this->*memberFunc)(data, reply);
79 }
80 }
81 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
82 }
83
OnUpdateCallReportInfo(MessageParcel & data,MessageParcel & reply)84 int32_t CallStatusCallbackStub::OnUpdateCallReportInfo(MessageParcel &data, MessageParcel &reply)
85 {
86 int32_t result = TELEPHONY_ERR_FAIL;
87 const CallReportInfo *parcelPtr = nullptr;
88 if (!data.ContainFileDescriptors()) {
89 TELEPHONY_LOGW("sent raw data is less than 32k");
90 }
91 int32_t len = data.ReadInt32();
92 if (len <= TELEPHONY_SUCCESS) {
93 TELEPHONY_LOGE("Invalid parameter, len = %{public}d", len);
94 return TELEPHONY_ERR_ARGUMENT_INVALID;
95 }
96 if ((parcelPtr = reinterpret_cast<const CallReportInfo *>(data.ReadRawData(len))) == nullptr) {
97 TELEPHONY_LOGE("reading raw data failed, length = %d", len);
98 return TELEPHONY_ERR_LOCAL_PTR_NULL;
99 }
100
101 result = UpdateCallReportInfo(*parcelPtr);
102 if (!reply.WriteInt32(result)) {
103 TELEPHONY_LOGE("writing parcel failed");
104 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
105 }
106 return TELEPHONY_SUCCESS;
107 }
108
OnUpdateCallsReportInfo(MessageParcel & data,MessageParcel & reply)109 int32_t CallStatusCallbackStub::OnUpdateCallsReportInfo(MessageParcel &data, MessageParcel &reply)
110 {
111 int32_t result = TELEPHONY_ERR_FAIL;
112 if (!data.ContainFileDescriptors()) {
113 TELEPHONY_LOGW("sent raw data is less than 32k");
114 }
115 int32_t cnt = data.ReadInt32();
116 if (cnt <= 0) {
117 TELEPHONY_LOGE("invalid parameter, cnt = %{public}d", cnt);
118 return TELEPHONY_ERR_ARGUMENT_INVALID;
119 }
120 TELEPHONY_LOGI("call list size:%{public}d", cnt);
121 CallsReportInfo callReportInfo;
122 int32_t len = 0;
123 const CallReportInfo *parcelPtr = nullptr;
124 for (int32_t i = 0; i < cnt; i++) {
125 len = data.ReadInt32();
126 if (len <= 0) {
127 TELEPHONY_LOGE("invalid parameter, len = %d", len);
128 return TELEPHONY_ERR_ARGUMENT_INVALID;
129 }
130 if ((parcelPtr = reinterpret_cast<const CallReportInfo *>(data.ReadRawData(len))) == nullptr) {
131 TELEPHONY_LOGE("reading raw data failed, length = %d", len);
132 if (reply.WriteInt32(0)) {
133 TELEPHONY_LOGE("writing parcel failed");
134 }
135 return TELEPHONY_ERR_LOCAL_PTR_NULL;
136 }
137 callReportInfo.callVec.push_back(*parcelPtr);
138 TELEPHONY_LOGI("accountId:%{public}d,state:%{public}d", parcelPtr->accountId, parcelPtr->state);
139 }
140 callReportInfo.slotId = data.ReadInt32();
141 TELEPHONY_LOGI("slotId:%{public}d", callReportInfo.slotId);
142 result = UpdateCallsReportInfo(callReportInfo);
143 if (!reply.WriteInt32(result)) {
144 TELEPHONY_LOGE("writing parcel failed");
145 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
146 }
147 return TELEPHONY_SUCCESS;
148 }
149
OnUpdateDisconnectedCause(MessageParcel & data,MessageParcel & reply)150 int32_t CallStatusCallbackStub::OnUpdateDisconnectedCause(MessageParcel &data, MessageParcel &reply)
151 {
152 int32_t result = TELEPHONY_ERR_FAIL;
153 if (!data.ContainFileDescriptors()) {
154 TELEPHONY_LOGW("sent raw data is less than 32k");
155 }
156 DisconnectedDetails cause = static_cast<DisconnectedDetails>(data.ReadInt32());
157 result = UpdateDisconnectedCause(cause);
158 if (!reply.WriteInt32(result)) {
159 TELEPHONY_LOGE("writing parcel failed");
160 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
161 }
162 return TELEPHONY_SUCCESS;
163 }
164
OnUpdateEventReport(MessageParcel & data,MessageParcel & reply)165 int32_t CallStatusCallbackStub::OnUpdateEventReport(MessageParcel &data, MessageParcel &reply)
166 {
167 int32_t result = TELEPHONY_ERR_FAIL;
168 const CellularCallEventInfo *parcelPtr = nullptr;
169 if (!data.ContainFileDescriptors()) {
170 TELEPHONY_LOGW("sent raw data is less than 32k");
171 }
172 int32_t len = data.ReadInt32();
173 if (len <= TELEPHONY_SUCCESS) {
174 TELEPHONY_LOGE("Invalid parameter, len = %{public}d", len);
175 return TELEPHONY_ERR_ARGUMENT_INVALID;
176 }
177 if ((parcelPtr = reinterpret_cast<const CellularCallEventInfo *>(data.ReadRawData(len))) == nullptr) {
178 TELEPHONY_LOGE("reading raw data failed, length = %d", len);
179 return TELEPHONY_ERR_LOCAL_PTR_NULL;
180 }
181 result = UpdateEventResultInfo(*parcelPtr);
182 if (!reply.WriteInt32(result)) {
183 TELEPHONY_LOGE("writing parcel failed");
184 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
185 }
186 return TELEPHONY_SUCCESS;
187 }
188
OnUpdateRBTPlayInfo(MessageParcel & data,MessageParcel & reply)189 int32_t CallStatusCallbackStub::OnUpdateRBTPlayInfo(MessageParcel &data, MessageParcel &reply)
190 {
191 int32_t result = TELEPHONY_ERR_FAIL;
192 if (!data.ContainFileDescriptors()) {
193 TELEPHONY_LOGW("sent raw data is less than 32k");
194 }
195 RBTPlayInfo rbtInfo = static_cast<RBTPlayInfo>(data.ReadInt32());
196 result = UpdateRBTPlayInfo(rbtInfo);
197 if (!reply.WriteInt32(result)) {
198 TELEPHONY_LOGE("writing parcel failed");
199 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
200 }
201 return TELEPHONY_SUCCESS;
202 }
203
OnUpdateGetWaitingResult(MessageParcel & data,MessageParcel & reply)204 int32_t CallStatusCallbackStub::OnUpdateGetWaitingResult(MessageParcel &data, MessageParcel &reply)
205 {
206 int32_t result = TELEPHONY_ERR_FAIL;
207 const CallWaitResponse *parcelPtr = nullptr;
208 if (!data.ContainFileDescriptors()) {
209 TELEPHONY_LOGW("sent raw data is less than 32k");
210 }
211 int32_t len = data.ReadInt32();
212 if (len <= TELEPHONY_SUCCESS) {
213 TELEPHONY_LOGE("Invalid parameter, len = %{public}d", len);
214 return TELEPHONY_ERR_ARGUMENT_INVALID;
215 }
216 if ((parcelPtr = reinterpret_cast<const CallWaitResponse *>(data.ReadRawData(len))) == nullptr) {
217 TELEPHONY_LOGE("reading raw data failed, length = %d", len);
218 return TELEPHONY_ERR_LOCAL_PTR_NULL;
219 }
220 result = UpdateGetWaitingResult(*parcelPtr);
221 if (!reply.WriteInt32(result)) {
222 TELEPHONY_LOGE("writing parcel failed");
223 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
224 }
225 return TELEPHONY_SUCCESS;
226 }
227
OnUpdateSetWaitingResult(MessageParcel & data,MessageParcel & reply)228 int32_t CallStatusCallbackStub::OnUpdateSetWaitingResult(MessageParcel &data, MessageParcel &reply)
229 {
230 int32_t result = TELEPHONY_ERR_FAIL;
231 if (!data.ContainFileDescriptors()) {
232 TELEPHONY_LOGW("sent raw data is less than 32k");
233 }
234 int32_t callWaitResult = data.ReadInt32();
235 result = UpdateSetWaitingResult(callWaitResult);
236 if (!reply.WriteInt32(result)) {
237 TELEPHONY_LOGE("writing parcel failed");
238 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
239 }
240 return TELEPHONY_SUCCESS;
241 }
242
OnUpdateGetRestrictionResult(MessageParcel & data,MessageParcel & reply)243 int32_t CallStatusCallbackStub::OnUpdateGetRestrictionResult(MessageParcel &data, MessageParcel &reply)
244 {
245 int32_t result = TELEPHONY_ERR_FAIL;
246 const CallRestrictionResponse *parcelPtr = nullptr;
247 if (!data.ContainFileDescriptors()) {
248 TELEPHONY_LOGW("sent raw data is less than 32k");
249 }
250 int32_t len = data.ReadInt32();
251 if (len <= TELEPHONY_SUCCESS) {
252 TELEPHONY_LOGE("Invalid parameter, len = %{public}d", len);
253 return TELEPHONY_ERR_ARGUMENT_INVALID;
254 }
255 if ((parcelPtr = reinterpret_cast<const CallRestrictionResponse *>(data.ReadRawData(len))) == nullptr) {
256 TELEPHONY_LOGE("reading raw data failed, length = %d", len);
257 return TELEPHONY_ERR_LOCAL_PTR_NULL;
258 }
259 result = UpdateGetRestrictionResult(*parcelPtr);
260 if (!reply.WriteInt32(result)) {
261 TELEPHONY_LOGE("writing parcel failed");
262 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
263 }
264 return TELEPHONY_SUCCESS;
265 }
266
OnUpdateSetRestrictionResult(MessageParcel & data,MessageParcel & reply)267 int32_t CallStatusCallbackStub::OnUpdateSetRestrictionResult(MessageParcel &data, MessageParcel &reply)
268 {
269 int32_t error = TELEPHONY_ERR_FAIL;
270 int32_t result = TELEPHONY_ERR_FAIL;
271 if (!data.ContainFileDescriptors()) {
272 TELEPHONY_LOGW("sent raw data is less than 32k");
273 }
274 result = data.ReadInt32();
275 error = UpdateSetRestrictionResult(result);
276 if (!reply.WriteInt32(error)) {
277 TELEPHONY_LOGE("writing parcel failed");
278 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
279 }
280 return TELEPHONY_SUCCESS;
281 }
282
OnUpdateGetTransferResult(MessageParcel & data,MessageParcel & reply)283 int32_t CallStatusCallbackStub::OnUpdateGetTransferResult(MessageParcel &data, MessageParcel &reply)
284 {
285 int32_t result = TELEPHONY_ERR_FAIL;
286 const CallTransferResponse *parcelPtr = nullptr;
287 if (!data.ContainFileDescriptors()) {
288 TELEPHONY_LOGW("sent raw data is less than 32k");
289 }
290 int32_t len = data.ReadInt32();
291 if (len <= TELEPHONY_SUCCESS) {
292 TELEPHONY_LOGE("Invalid parameter, len = %{public}d", len);
293 return TELEPHONY_ERR_ARGUMENT_INVALID;
294 }
295 if ((parcelPtr = reinterpret_cast<const CallTransferResponse *>(data.ReadRawData(len))) == nullptr) {
296 TELEPHONY_LOGE("reading raw data failed, length = %d", len);
297 return TELEPHONY_ERR_LOCAL_PTR_NULL;
298 }
299 result = UpdateGetTransferResult(*parcelPtr);
300 if (!reply.WriteInt32(result)) {
301 TELEPHONY_LOGE("writing parcel failed");
302 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
303 }
304 return TELEPHONY_SUCCESS;
305 }
306
OnUpdateSetTransferResult(MessageParcel & data,MessageParcel & reply)307 int32_t CallStatusCallbackStub::OnUpdateSetTransferResult(MessageParcel &data, MessageParcel &reply)
308 {
309 int32_t error = TELEPHONY_ERR_FAIL;
310 int32_t result = TELEPHONY_ERR_FAIL;
311 if (!data.ContainFileDescriptors()) {
312 TELEPHONY_LOGW("sent raw data is less than 32k");
313 }
314 result = data.ReadInt32();
315 error = UpdateSetTransferResult(result);
316 if (!reply.WriteInt32(error)) {
317 TELEPHONY_LOGE("writing parcel failed");
318 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
319 }
320 return TELEPHONY_SUCCESS;
321 }
322
OnUpdateGetCallClipResult(MessageParcel & data,MessageParcel & reply)323 int32_t CallStatusCallbackStub::OnUpdateGetCallClipResult(MessageParcel &data, MessageParcel &reply)
324 {
325 int32_t result = TELEPHONY_ERR_FAIL;
326 const ClipResponse *parcelPtr = nullptr;
327 if (!data.ContainFileDescriptors()) {
328 TELEPHONY_LOGW("sent raw data is less than 32k");
329 }
330 int32_t len = data.ReadInt32();
331 if (len <= TELEPHONY_SUCCESS) {
332 TELEPHONY_LOGE("Invalid parameter, len = %{public}d", len);
333 return TELEPHONY_ERR_ARGUMENT_INVALID;
334 }
335 if ((parcelPtr = reinterpret_cast<const ClipResponse *>(data.ReadRawData(len))) == nullptr) {
336 TELEPHONY_LOGE("reading raw data failed, length = %d", len);
337 return TELEPHONY_ERR_LOCAL_PTR_NULL;
338 }
339 result = UpdateGetCallClipResult(*parcelPtr);
340 if (!reply.WriteInt32(result)) {
341 TELEPHONY_LOGE("writing parcel failed");
342 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
343 }
344 return TELEPHONY_SUCCESS;
345 }
346
OnUpdateGetCallClirResult(MessageParcel & data,MessageParcel & reply)347 int32_t CallStatusCallbackStub::OnUpdateGetCallClirResult(MessageParcel &data, MessageParcel &reply)
348 {
349 int32_t result = TELEPHONY_ERR_FAIL;
350 if (!data.ContainFileDescriptors()) {
351 TELEPHONY_LOGW("sent raw data is less than 32k");
352 }
353 const ClirResponse *parcelPtr = nullptr;
354 int32_t len = data.ReadInt32();
355 if (len <= TELEPHONY_SUCCESS) {
356 TELEPHONY_LOGE("Invalid parameter, len = %{public}d", len);
357 return TELEPHONY_ERR_ARGUMENT_INVALID;
358 }
359 if ((parcelPtr = reinterpret_cast<const ClirResponse *>(data.ReadRawData(len))) == nullptr) {
360 TELEPHONY_LOGE("reading raw data failed, length = %d", len);
361 return TELEPHONY_ERR_LOCAL_PTR_NULL;
362 }
363 result = UpdateGetCallClirResult(*parcelPtr);
364 if (!reply.WriteInt32(result)) {
365 TELEPHONY_LOGE("writing parcel failed");
366 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
367 }
368 return TELEPHONY_SUCCESS;
369 }
370
OnUpdateSetCallClirResult(MessageParcel & data,MessageParcel & reply)371 int32_t CallStatusCallbackStub::OnUpdateSetCallClirResult(MessageParcel &data, MessageParcel &reply)
372 {
373 int32_t error = TELEPHONY_ERR_FAIL;
374 int32_t result = TELEPHONY_ERR_FAIL;
375 if (!data.ContainFileDescriptors()) {
376 TELEPHONY_LOGW("sent raw data is less than 32k");
377 }
378 result = data.ReadInt32();
379 error = UpdateSetCallClirResult(result);
380 if (!reply.WriteInt32(error)) {
381 TELEPHONY_LOGE("writing parcel failed");
382 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
383 }
384 return TELEPHONY_SUCCESS;
385 }
386
OnGetVoLteStatusResult(MessageParcel & data,MessageParcel & reply)387 int32_t CallStatusCallbackStub::OnGetVoLteStatusResult(MessageParcel &data, MessageParcel &reply)
388 {
389 int32_t error = TELEPHONY_ERR_FAIL;
390 if (!data.ContainFileDescriptors()) {
391 TELEPHONY_LOGW("sent raw data is less than 32k");
392 }
393 const LteImsSwitchResponse *parcelPtr = nullptr;
394 int32_t len = data.ReadInt32();
395 if (len <= TELEPHONY_SUCCESS) {
396 TELEPHONY_LOGE("Invalid parameter, len = %{public}d", len);
397 return TELEPHONY_ERR_ARGUMENT_INVALID;
398 }
399 if ((parcelPtr = reinterpret_cast<const LteImsSwitchResponse *>(data.ReadRawData(len))) == nullptr) {
400 TELEPHONY_LOGE("reading raw data failed, length = %d", len);
401 return TELEPHONY_ERR_LOCAL_PTR_NULL;
402 }
403 error = GetVoLteStatusResult(*parcelPtr);
404 if (!reply.WriteInt32(error)) {
405 TELEPHONY_LOGE("writing parcel failed");
406 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
407 }
408 return TELEPHONY_SUCCESS;
409 }
410
OnSetVoLteStatusResult(MessageParcel & data,MessageParcel & reply)411 int32_t CallStatusCallbackStub::OnSetVoLteStatusResult(MessageParcel &data, MessageParcel &reply)
412 {
413 int32_t error = TELEPHONY_ERR_FAIL;
414 if (!data.ContainFileDescriptors()) {
415 TELEPHONY_LOGW("sent raw data is less than 32k");
416 }
417 const LteImsSwitchResponse *parcelPtr = nullptr;
418 int32_t len = data.ReadInt32();
419 if (len <= TELEPHONY_SUCCESS) {
420 TELEPHONY_LOGE("Invalid parameter, len = %{public}d", len);
421 return TELEPHONY_ERR_ARGUMENT_INVALID;
422 }
423 if ((parcelPtr = reinterpret_cast<const LteImsSwitchResponse *>(data.ReadRawData(len))) == nullptr) {
424 TELEPHONY_LOGE("reading raw data failed, length = %d", len);
425 return TELEPHONY_ERR_LOCAL_PTR_NULL;
426 }
427 error = SetVoLteStatusResult(*parcelPtr);
428 if (!reply.WriteInt32(error)) {
429 TELEPHONY_LOGE("writing parcel failed");
430 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
431 }
432 return TELEPHONY_SUCCESS;
433 }
434
OnStartRttResult(MessageParcel & data,MessageParcel & reply)435 int32_t CallStatusCallbackStub::OnStartRttResult(MessageParcel &data, MessageParcel &reply)
436 {
437 int32_t error = TELEPHONY_ERR_FAIL;
438 int32_t result = TELEPHONY_ERR_FAIL;
439 if (!data.ContainFileDescriptors()) {
440 TELEPHONY_LOGW("sent raw data is less than 32k");
441 }
442 result = data.ReadInt32();
443 error = StartRttResult(result);
444 if (!reply.WriteInt32(error)) {
445 TELEPHONY_LOGE("writing parcel failed");
446 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
447 }
448 return TELEPHONY_SUCCESS;
449 }
450
OnStopRttResult(MessageParcel & data,MessageParcel & reply)451 int32_t CallStatusCallbackStub::OnStopRttResult(MessageParcel &data, MessageParcel &reply)
452 {
453 int32_t error = TELEPHONY_ERR_FAIL;
454 int32_t result = TELEPHONY_ERR_FAIL;
455 if (!data.ContainFileDescriptors()) {
456 TELEPHONY_LOGW("sent raw data is less than 32k");
457 }
458 result = data.ReadInt32();
459 error = StopRttResult(result);
460 if (!reply.WriteInt32(error)) {
461 TELEPHONY_LOGE("writing parcel failed");
462 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
463 }
464 return TELEPHONY_SUCCESS;
465 }
466
OnGetImsConfigResult(MessageParcel & data,MessageParcel & reply)467 int32_t CallStatusCallbackStub::OnGetImsConfigResult(MessageParcel &data, MessageParcel &reply)
468 {
469 int32_t error = TELEPHONY_ERR_FAIL;
470 if (!data.ContainFileDescriptors()) {
471 TELEPHONY_LOGW("sent raw data is less than 32k");
472 }
473 const GetImsConfigResponse *parcelPtr = nullptr;
474 int32_t len = data.ReadInt32();
475 if (len <= TELEPHONY_SUCCESS) {
476 TELEPHONY_LOGE("Invalid parameter, len = %{public}d", len);
477 return TELEPHONY_ERR_ARGUMENT_INVALID;
478 }
479 if ((parcelPtr = reinterpret_cast<const GetImsConfigResponse *>(data.ReadRawData(len))) == nullptr) {
480 TELEPHONY_LOGE("reading raw data failed, length = %d", len);
481 return TELEPHONY_ERR_LOCAL_PTR_NULL;
482 }
483 error = GetImsConfigResult(*parcelPtr);
484 if (!reply.WriteInt32(error)) {
485 TELEPHONY_LOGE("writing parcel failed");
486 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
487 }
488 return TELEPHONY_SUCCESS;
489 }
490
OnSetImsConfigResult(MessageParcel & data,MessageParcel & reply)491 int32_t CallStatusCallbackStub::OnSetImsConfigResult(MessageParcel &data, MessageParcel &reply)
492 {
493 int32_t error = TELEPHONY_ERR_FAIL;
494 int32_t result = TELEPHONY_ERR_FAIL;
495 if (!data.ContainFileDescriptors()) {
496 TELEPHONY_LOGW("sent raw data is less than 32k");
497 }
498 result = data.ReadInt32();
499 error = SetImsConfigResult(result);
500 if (!reply.WriteInt32(error)) {
501 TELEPHONY_LOGE("writing parcel failed");
502 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
503 }
504 return TELEPHONY_SUCCESS;
505 }
506
OnGetImsFeatureValueResult(MessageParcel & data,MessageParcel & reply)507 int32_t CallStatusCallbackStub::OnGetImsFeatureValueResult(MessageParcel &data, MessageParcel &reply)
508 {
509 int32_t error = TELEPHONY_ERR_FAIL;
510 if (!data.ContainFileDescriptors()) {
511 TELEPHONY_LOGW("sent raw data is less than 32k");
512 }
513 const GetImsFeatureValueResponse *parcelPtr = nullptr;
514 int32_t len = data.ReadInt32();
515 if (len <= TELEPHONY_SUCCESS) {
516 TELEPHONY_LOGE("Invalid parameter, len = %{public}d", len);
517 return TELEPHONY_ERR_ARGUMENT_INVALID;
518 }
519 if ((parcelPtr = reinterpret_cast<const GetImsFeatureValueResponse *>(data.ReadRawData(len))) == nullptr) {
520 TELEPHONY_LOGE("reading raw data failed, length = %d", len);
521 return TELEPHONY_ERR_LOCAL_PTR_NULL;
522 }
523 error = GetImsFeatureValueResult(*parcelPtr);
524 if (!reply.WriteInt32(error)) {
525 TELEPHONY_LOGE("writing parcel failed");
526 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
527 }
528 return TELEPHONY_SUCCESS;
529 }
530
OnSetImsFeatureValueResult(MessageParcel & data,MessageParcel & reply)531 int32_t CallStatusCallbackStub::OnSetImsFeatureValueResult(MessageParcel &data, MessageParcel &reply)
532 {
533 int32_t error = TELEPHONY_ERR_FAIL;
534 int32_t result = TELEPHONY_ERR_FAIL;
535 if (!data.ContainFileDescriptors()) {
536 TELEPHONY_LOGW("sent raw data is less than 32k");
537 }
538 result = data.ReadInt32();
539 error = SetImsFeatureValueResult(result);
540 if (!reply.WriteInt32(error)) {
541 TELEPHONY_LOGE("writing parcel failed");
542 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
543 }
544 return TELEPHONY_SUCCESS;
545 }
546
OnGetLteEnhanceModeResult(MessageParcel & data,MessageParcel & reply)547 int32_t CallStatusCallbackStub::OnGetLteEnhanceModeResult(MessageParcel &data, MessageParcel &reply)
548 {
549 int32_t error = TELEPHONY_ERR_FAIL;
550 if (!data.ContainFileDescriptors()) {
551 TELEPHONY_LOGW("sent raw data is less than 32k");
552 }
553 const GetLteEnhanceModeResponse *parcelPtr = nullptr;
554 int32_t len = data.ReadInt32();
555 if (len <= TELEPHONY_SUCCESS) {
556 TELEPHONY_LOGE("Invalid parameter, len = %{public}d", len);
557 return TELEPHONY_ERR_ARGUMENT_INVALID;
558 }
559 if ((parcelPtr = reinterpret_cast<const GetLteEnhanceModeResponse *>(data.ReadRawData(len))) == nullptr) {
560 TELEPHONY_LOGE("reading raw data failed, length = %d", len);
561 return TELEPHONY_ERR_LOCAL_PTR_NULL;
562 }
563 error = GetLteEnhanceModeResult(*parcelPtr);
564 if (!reply.WriteInt32(error)) {
565 TELEPHONY_LOGE("writing parcel failed");
566 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
567 }
568 return TELEPHONY_SUCCESS;
569 }
570
OnSetLteEnhanceModeResult(MessageParcel & data,MessageParcel & reply)571 int32_t CallStatusCallbackStub::OnSetLteEnhanceModeResult(MessageParcel &data, MessageParcel &reply)
572 {
573 int32_t error = TELEPHONY_ERR_FAIL;
574 int32_t result = TELEPHONY_ERR_FAIL;
575 if (!data.ContainFileDescriptors()) {
576 TELEPHONY_LOGW("sent raw data is less than 32k");
577 }
578 result = data.ReadInt32();
579 error = SetLteEnhanceModeResult(result);
580 if (!reply.WriteInt32(error)) {
581 TELEPHONY_LOGE("writing parcel failed");
582 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
583 }
584 return TELEPHONY_SUCCESS;
585 }
586
OnReceiveUpdateMediaModeResponse(MessageParcel & data,MessageParcel & reply)587 int32_t CallStatusCallbackStub::OnReceiveUpdateMediaModeResponse(MessageParcel &data, MessageParcel &reply)
588 {
589 int32_t error = TELEPHONY_ERR_FAIL;
590 if (!data.ContainFileDescriptors()) {
591 TELEPHONY_LOGW("sent raw data is less than 32k");
592 }
593 const CallMediaModeResponse *parcelPtr = nullptr;
594 int32_t len = data.ReadInt32();
595 if (len <= TELEPHONY_SUCCESS) {
596 TELEPHONY_LOGE("Invalid parameter, len = %{public}d", len);
597 return TELEPHONY_ERR_ARGUMENT_INVALID;
598 }
599 if ((parcelPtr = reinterpret_cast<const CallMediaModeResponse *>(data.ReadRawData(len))) == nullptr) {
600 TELEPHONY_LOGE("reading raw data failed, length = %d", len);
601 return TELEPHONY_ERR_LOCAL_PTR_NULL;
602 }
603 error = ReceiveUpdateCallMediaModeResponse(*parcelPtr);
604 if (!reply.WriteInt32(error)) {
605 TELEPHONY_LOGE("writing parcel failed");
606 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
607 }
608 return TELEPHONY_SUCCESS;
609 }
610
OnInviteToConferenceResult(MessageParcel & data,MessageParcel & reply)611 int32_t CallStatusCallbackStub::OnInviteToConferenceResult(MessageParcel &data, MessageParcel &reply)
612 {
613 int32_t error = TELEPHONY_ERR_FAIL;
614 int32_t result = TELEPHONY_ERR_FAIL;
615 if (!data.ContainFileDescriptors()) {
616 TELEPHONY_LOGW("sent raw data is less than 32k");
617 }
618 result = data.ReadInt32();
619 error = InviteToConferenceResult(result);
620 if (!reply.WriteInt32(error)) {
621 TELEPHONY_LOGE("writing parcel failed");
622 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
623 }
624 return TELEPHONY_SUCCESS;
625 }
626
OnStartDtmfResult(MessageParcel & data,MessageParcel & reply)627 int32_t CallStatusCallbackStub::OnStartDtmfResult(MessageParcel &data, MessageParcel &reply)
628 {
629 int32_t error = TELEPHONY_ERR_FAIL;
630 int32_t result = TELEPHONY_ERR_FAIL;
631 if (!data.ContainFileDescriptors()) {
632 TELEPHONY_LOGW("sent raw data is less than 32k");
633 }
634 result = data.ReadInt32();
635 error = StartDtmfResult(result);
636 if (!reply.WriteInt32(error)) {
637 TELEPHONY_LOGE("writing parcel failed");
638 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
639 }
640 return TELEPHONY_SUCCESS;
641 }
642
OnStopDtmfResult(MessageParcel & data,MessageParcel & reply)643 int32_t CallStatusCallbackStub::OnStopDtmfResult(MessageParcel &data, MessageParcel &reply)
644 {
645 int32_t error = TELEPHONY_ERR_FAIL;
646 int32_t result = TELEPHONY_ERR_FAIL;
647 if (!data.ContainFileDescriptors()) {
648 TELEPHONY_LOGW("sent raw data is less than 32k");
649 }
650 result = data.ReadInt32();
651 error = StopDtmfResult(result);
652 if (!reply.WriteInt32(error)) {
653 TELEPHONY_LOGE("writing parcel failed");
654 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
655 }
656 return TELEPHONY_SUCCESS;
657 }
658
OnSendUssdResult(MessageParcel & data,MessageParcel & reply)659 int32_t CallStatusCallbackStub::OnSendUssdResult(MessageParcel &data, MessageParcel &reply)
660 {
661 int32_t error = TELEPHONY_ERR_FAIL;
662 int32_t result = TELEPHONY_ERR_FAIL;
663 if (!data.ContainFileDescriptors()) {
664 TELEPHONY_LOGW("sent raw data is less than 32k");
665 }
666 result = data.ReadInt32();
667 error = SendUssdResult(result);
668 if (!reply.WriteInt32(error)) {
669 TELEPHONY_LOGE("writing parcel failed");
670 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
671 }
672 return TELEPHONY_SUCCESS;
673 }
674
OnGetImsCallDataResult(MessageParcel & data,MessageParcel & reply)675 int32_t CallStatusCallbackStub::OnGetImsCallDataResult(MessageParcel &data, MessageParcel &reply)
676 {
677 int32_t error = TELEPHONY_ERR_FAIL;
678 int32_t result = TELEPHONY_ERR_FAIL;
679 if (!data.ContainFileDescriptors()) {
680 TELEPHONY_LOGW("sent raw data is less than 32k");
681 }
682 result = data.ReadInt32();
683 error = GetImsCallDataResult(result);
684 if (!reply.WriteInt32(error)) {
685 TELEPHONY_LOGE("writing parcel failed");
686 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
687 }
688 return TELEPHONY_SUCCESS;
689 }
690 } // namespace Telephony
691 } // namespace OHOS
692