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