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 "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;
26 const int32_t MAX_CALL_NUM = 10;
CallStatusCallbackStub()27 CallStatusCallbackStub::CallStatusCallbackStub()
28 {
29 memberFuncMap_[static_cast<uint32_t>(UPDATE_CALL_INFO)] = &CallStatusCallbackStub::OnUpdateCallReportInfo;
30 memberFuncMap_[static_cast<uint32_t>(UPDATE_CALLS_INFO)] = &CallStatusCallbackStub::OnUpdateCallsReportInfo;
31 memberFuncMap_[static_cast<uint32_t>(UPDATE_DISCONNECTED_CAUSE)] =
32 &CallStatusCallbackStub::OnUpdateDisconnectedCause;
33 memberFuncMap_[static_cast<uint32_t>(UPDATE_EVENT_RESULT_INFO)] = &CallStatusCallbackStub::OnUpdateEventReport;
34 memberFuncMap_[static_cast<uint32_t>(UPDATE_RBT_PLAY_INFO)] = &CallStatusCallbackStub::OnUpdateRBTPlayInfo;
35 memberFuncMap_[static_cast<uint32_t>(START_DTMF)] = &CallStatusCallbackStub::OnStartDtmfResult;
36 memberFuncMap_[static_cast<uint32_t>(STOP_DTMF)] = &CallStatusCallbackStub::OnStopDtmfResult;
37 memberFuncMap_[static_cast<uint32_t>(SEND_USSD)] = &CallStatusCallbackStub::OnSendUssdResult;
38 memberFuncMap_[static_cast<uint32_t>(GET_IMS_CALL_DATA)] = &CallStatusCallbackStub::OnGetImsCallDataResult;
39 memberFuncMap_[static_cast<uint32_t>(UPDATE_GET_WAITING)] = &CallStatusCallbackStub::OnUpdateGetWaitingResult;
40 memberFuncMap_[static_cast<uint32_t>(UPDATE_SET_WAITING)] = &CallStatusCallbackStub::OnUpdateSetWaitingResult;
41 memberFuncMap_[static_cast<uint32_t>(UPDATE_GET_RESTRICTION)] =
42 &CallStatusCallbackStub::OnUpdateGetRestrictionResult;
43 memberFuncMap_[static_cast<uint32_t>(UPDATE_SET_RESTRICTION)] =
44 &CallStatusCallbackStub::OnUpdateSetRestrictionResult;
45 memberFuncMap_[static_cast<uint32_t>(UPDATE_SET_RESTRICTION_PWD)] =
46 &CallStatusCallbackStub::OnUpdateSetRestrictionPasswordResult;
47 memberFuncMap_[static_cast<uint32_t>(UPDATE_GET_TRANSFER)] = &CallStatusCallbackStub::OnUpdateGetTransferResult;
48 memberFuncMap_[static_cast<uint32_t>(UPDATE_SET_TRANSFER)] = &CallStatusCallbackStub::OnUpdateSetTransferResult;
49 memberFuncMap_[static_cast<uint32_t>(UPDATE_GET_CALL_CLIP)] = &CallStatusCallbackStub::OnUpdateGetCallClipResult;
50 memberFuncMap_[static_cast<uint32_t>(UPDATE_GET_CALL_CLIR)] = &CallStatusCallbackStub::OnUpdateGetCallClirResult;
51 memberFuncMap_[static_cast<uint32_t>(UPDATE_SET_CALL_CLIR)] = &CallStatusCallbackStub::OnUpdateSetCallClirResult;
52 memberFuncMap_[static_cast<uint32_t>(GET_IMS_CONFIG)] = &CallStatusCallbackStub::OnGetImsConfigResult;
53 memberFuncMap_[static_cast<uint32_t>(SET_IMS_CONFIG)] = &CallStatusCallbackStub::OnSetImsConfigResult;
54 memberFuncMap_[static_cast<uint32_t>(GET_IMS_FEATURE_VALUE)] = &CallStatusCallbackStub::OnGetImsFeatureValueResult;
55 memberFuncMap_[static_cast<uint32_t>(SET_IMS_FEATURE_VALUE)] = &CallStatusCallbackStub::OnSetImsFeatureValueResult;
56 memberFuncMap_[static_cast<uint32_t>(RECEIVE_UPDATE_MEDIA_MODE_RESPONSE)] =
57 &CallStatusCallbackStub::OnReceiveImsCallModeResponse;
58 memberFuncMap_[static_cast<uint32_t>(RECEIVE_UPDATE_MEDIA_MODE_REQUEST)] =
59 &CallStatusCallbackStub::OnReceiveImsCallModeRequest;
60 memberFuncMap_[static_cast<uint32_t>(UPDATE_STARTRTT_STATUS)] = &CallStatusCallbackStub::OnStartRttResult;
61 memberFuncMap_[static_cast<uint32_t>(UPDATE_STOPRTT_STATUS)] = &CallStatusCallbackStub::OnStopRttResult;
62 memberFuncMap_[static_cast<uint32_t>(INVITE_TO_CONFERENCE)] = &CallStatusCallbackStub::OnInviteToConferenceResult;
63 memberFuncMap_[static_cast<uint32_t>(MMI_CODE_INFO_RESPONSE)] = &CallStatusCallbackStub::OnSendMmiCodeResult;
64 memberFuncMap_[static_cast<uint32_t>(CLOSE_UNFINISHED_USSD)] = &CallStatusCallbackStub::OnCloseUnFinishedUssdResult;
65 memberFuncMap_[static_cast<uint32_t>(POST_DIAL_CHAR)] = &CallStatusCallbackStub::OnPostDialNextChar;
66 memberFuncMap_[static_cast<uint32_t>(POST_DIAL_DELAY)] = &CallStatusCallbackStub::OnReportPostDialDelay;
67 memberFuncMap_[static_cast<uint32_t>(CALL_SESSION_EVENT)] = &CallStatusCallbackStub::OnCallSessionEventChange;
68 memberFuncMap_[static_cast<uint32_t>(PEER_DIMENSION_CHANGE)] = &CallStatusCallbackStub::OnPeerDimensionsChange;
69 memberFuncMap_[static_cast<uint32_t>(CALL_DATA_USAGE)] = &CallStatusCallbackStub::OnCallDataUsageChange;
70 memberFuncMap_[static_cast<uint32_t>(CAMERA_CAPBILITIES_CHANGE)] =
71 &CallStatusCallbackStub::OnCameraCapabilitiesChange;
72 }
73
~CallStatusCallbackStub()74 CallStatusCallbackStub::~CallStatusCallbackStub()
75 {
76 memberFuncMap_.clear();
77 }
78
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)79 int32_t CallStatusCallbackStub::OnRemoteRequest(
80 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
81 {
82 std::u16string myDescriptor = CallStatusCallbackStub::GetDescriptor();
83 std::u16string remoteDescriptor = data.ReadInterfaceToken();
84 if (myDescriptor != remoteDescriptor) {
85 TELEPHONY_LOGE("descriptor checked failed");
86 return TELEPHONY_ERR_DESCRIPTOR_MISMATCH;
87 }
88 TELEPHONY_LOGI("OnReceived, cmd = %{public}u", code);
89 auto itFunc = memberFuncMap_.find(code);
90 if (itFunc != memberFuncMap_.end()) {
91 auto memberFunc = itFunc->second;
92 if (memberFunc != nullptr) {
93 return (this->*memberFunc)(data, reply);
94 }
95 }
96 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
97 }
98
OnUpdateCallReportInfo(MessageParcel & data,MessageParcel & reply)99 int32_t CallStatusCallbackStub::OnUpdateCallReportInfo(MessageParcel &data, MessageParcel &reply)
100 {
101 int32_t result = TELEPHONY_ERR_FAIL;
102 CallReportInfo parcelPtr;
103 if (!data.ContainFileDescriptors()) {
104 TELEPHONY_LOGW("sent raw data is less than 32k");
105 }
106 parcelPtr.index = data.ReadInt32();
107 strncpy_s(parcelPtr.accountNum, kMaxNumberLen + 1, data.ReadCString(), kMaxNumberLen + 1);
108 parcelPtr.accountId = data.ReadInt32();
109 parcelPtr.callType = static_cast<CallType>(data.ReadInt32());
110 parcelPtr.callMode = static_cast<VideoStateType>(data.ReadInt32());
111 parcelPtr.state = static_cast<TelCallState>(data.ReadInt32());
112 parcelPtr.voiceDomain = data.ReadInt32();
113 parcelPtr.mpty = data.ReadInt32();
114 parcelPtr.crsType = data.ReadInt32();
115 parcelPtr.originalCallType = data.ReadInt32();
116 if (parcelPtr.callType == CallType::TYPE_VOIP) {
117 parcelPtr.voipCallInfo.voipCallId = data.ReadString();
118 parcelPtr.voipCallInfo.userName = data.ReadString();
119 parcelPtr.voipCallInfo.abilityName = data.ReadString();
120 parcelPtr.voipCallInfo.extensionId = data.ReadString();
121 parcelPtr.voipCallInfo.voipBundleName = data.ReadString();
122 std::vector<uint8_t> userProfile = {};
123 data.ReadUInt8Vector(&userProfile);
124 (parcelPtr.voipCallInfo.userProfile).assign(userProfile.begin(), userProfile.end());
125 }
126 result = UpdateCallReportInfo(parcelPtr);
127 if (!reply.WriteInt32(result)) {
128 TELEPHONY_LOGE("writing parcel failed");
129 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
130 }
131 return TELEPHONY_SUCCESS;
132 }
133
OnUpdateCallsReportInfo(MessageParcel & data,MessageParcel & reply)134 int32_t CallStatusCallbackStub::OnUpdateCallsReportInfo(MessageParcel &data, MessageParcel &reply)
135 {
136 int32_t result = TELEPHONY_ERR_FAIL;
137 if (!data.ContainFileDescriptors()) {
138 TELEPHONY_LOGW("sent raw data is less than 32k");
139 }
140 int32_t cnt = data.ReadInt32();
141 if (cnt <= 0 || cnt > MAX_CALL_NUM) {
142 TELEPHONY_LOGE("invalid parameter, cnt = %{public}d", cnt);
143 return TELEPHONY_ERR_ARGUMENT_INVALID;
144 }
145 TELEPHONY_LOGI("call list size:%{public}d", cnt);
146 CallsReportInfo callReportInfo;
147 CallReportInfo parcelPtr;
148 for (int32_t i = 0; i < cnt; i++) {
149 parcelPtr.index = data.ReadInt32();
150 strncpy_s(parcelPtr.accountNum, kMaxNumberLen + 1, data.ReadCString(), kMaxNumberLen + 1);
151 parcelPtr.accountId = data.ReadInt32();
152 parcelPtr.callType = static_cast<CallType>(data.ReadInt32());
153 parcelPtr.callMode = static_cast<VideoStateType>(data.ReadInt32());
154 parcelPtr.state = static_cast<TelCallState>(data.ReadInt32());
155 parcelPtr.voiceDomain = data.ReadInt32();
156 parcelPtr.mpty = data.ReadInt32();
157 parcelPtr.crsType = data.ReadInt32();
158 parcelPtr.originalCallType = data.ReadInt32();
159 if (parcelPtr.callType == CallType::TYPE_VOIP) {
160 parcelPtr.voipCallInfo.voipCallId = data.ReadString();
161 parcelPtr.voipCallInfo.userName = data.ReadString();
162 parcelPtr.voipCallInfo.abilityName = data.ReadString();
163 parcelPtr.voipCallInfo.extensionId = data.ReadString();
164 parcelPtr.voipCallInfo.voipBundleName = data.ReadString();
165 std::vector<uint8_t> userProfile = {};
166 data.ReadUInt8Vector(&userProfile);
167 (parcelPtr.voipCallInfo.userProfile).assign(userProfile.begin(), userProfile.end());
168 }
169 callReportInfo.callVec.push_back(parcelPtr);
170 TELEPHONY_LOGI("accountId:%{public}d,state:%{public}d", parcelPtr.accountId, parcelPtr.state);
171 }
172 callReportInfo.slotId = data.ReadInt32();
173 TELEPHONY_LOGI("slotId:%{public}d", callReportInfo.slotId);
174 result = UpdateCallsReportInfo(callReportInfo);
175 if (!reply.WriteInt32(result)) {
176 TELEPHONY_LOGE("writing parcel failed");
177 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
178 }
179 return TELEPHONY_SUCCESS;
180 }
181
OnUpdateDisconnectedCause(MessageParcel & data,MessageParcel & reply)182 int32_t CallStatusCallbackStub::OnUpdateDisconnectedCause(MessageParcel &data, MessageParcel &reply)
183 {
184 int32_t result = TELEPHONY_ERR_FAIL;
185 if (!data.ContainFileDescriptors()) {
186 TELEPHONY_LOGW("sent raw data is less than 32k");
187 }
188 DisconnectedDetails dcDetails;
189 dcDetails.reason = static_cast<DisconnectedReason>(data.ReadInt32());
190 dcDetails.message = data.ReadString();
191 result = UpdateDisconnectedCause(dcDetails);
192 if (!reply.WriteInt32(result)) {
193 TELEPHONY_LOGE("writing parcel failed");
194 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
195 }
196 return TELEPHONY_SUCCESS;
197 }
198
OnUpdateEventReport(MessageParcel & data,MessageParcel & reply)199 int32_t CallStatusCallbackStub::OnUpdateEventReport(MessageParcel &data, MessageParcel &reply)
200 {
201 int32_t result = TELEPHONY_ERR_FAIL;
202 const CellularCallEventInfo *parcelPtr = nullptr;
203 if (!data.ContainFileDescriptors()) {
204 TELEPHONY_LOGW("sent raw data is less than 32k");
205 }
206 int32_t len = data.ReadInt32();
207 if (len <= 0 || len >= MAX_LEN) {
208 TELEPHONY_LOGE("Invalid parameter, len = %{public}d", len);
209 return TELEPHONY_ERR_ARGUMENT_INVALID;
210 }
211 if ((parcelPtr = reinterpret_cast<const CellularCallEventInfo *>(data.ReadRawData(len))) == nullptr) {
212 TELEPHONY_LOGE("reading raw data failed, length = %d", len);
213 return TELEPHONY_ERR_LOCAL_PTR_NULL;
214 }
215 result = UpdateEventResultInfo(*parcelPtr);
216 if (!reply.WriteInt32(result)) {
217 TELEPHONY_LOGE("writing parcel failed");
218 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
219 }
220 return TELEPHONY_SUCCESS;
221 }
222
OnUpdateRBTPlayInfo(MessageParcel & data,MessageParcel & reply)223 int32_t CallStatusCallbackStub::OnUpdateRBTPlayInfo(MessageParcel &data, MessageParcel &reply)
224 {
225 int32_t result = TELEPHONY_ERR_FAIL;
226 if (!data.ContainFileDescriptors()) {
227 TELEPHONY_LOGW("sent raw data is less than 32k");
228 }
229 RBTPlayInfo rbtInfo = static_cast<RBTPlayInfo>(data.ReadInt32());
230 result = UpdateRBTPlayInfo(rbtInfo);
231 if (!reply.WriteInt32(result)) {
232 TELEPHONY_LOGE("writing parcel failed");
233 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
234 }
235 return TELEPHONY_SUCCESS;
236 }
237
OnUpdateGetWaitingResult(MessageParcel & data,MessageParcel & reply)238 int32_t CallStatusCallbackStub::OnUpdateGetWaitingResult(MessageParcel &data, MessageParcel &reply)
239 {
240 int32_t result = TELEPHONY_ERR_FAIL;
241 const CallWaitResponse *parcelPtr = nullptr;
242 if (!data.ContainFileDescriptors()) {
243 TELEPHONY_LOGW("sent raw data is less than 32k");
244 }
245 int32_t len = data.ReadInt32();
246 if (len <= 0 || len >= MAX_LEN) {
247 TELEPHONY_LOGE("Invalid parameter, len = %{public}d", len);
248 return TELEPHONY_ERR_ARGUMENT_INVALID;
249 }
250 if ((parcelPtr = reinterpret_cast<const CallWaitResponse *>(data.ReadRawData(len))) == nullptr) {
251 TELEPHONY_LOGE("reading raw data failed, length = %d", len);
252 return TELEPHONY_ERR_LOCAL_PTR_NULL;
253 }
254 result = UpdateGetWaitingResult(*parcelPtr);
255 if (!reply.WriteInt32(result)) {
256 TELEPHONY_LOGE("writing parcel failed");
257 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
258 }
259 return TELEPHONY_SUCCESS;
260 }
261
OnUpdateSetWaitingResult(MessageParcel & data,MessageParcel & reply)262 int32_t CallStatusCallbackStub::OnUpdateSetWaitingResult(MessageParcel &data, MessageParcel &reply)
263 {
264 int32_t result = TELEPHONY_ERR_FAIL;
265 if (!data.ContainFileDescriptors()) {
266 TELEPHONY_LOGW("sent raw data is less than 32k");
267 }
268 int32_t callWaitResult = data.ReadInt32();
269 result = UpdateSetWaitingResult(callWaitResult);
270 if (!reply.WriteInt32(result)) {
271 TELEPHONY_LOGE("writing parcel failed");
272 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
273 }
274 return TELEPHONY_SUCCESS;
275 }
276
OnUpdateGetRestrictionResult(MessageParcel & data,MessageParcel & reply)277 int32_t CallStatusCallbackStub::OnUpdateGetRestrictionResult(MessageParcel &data, MessageParcel &reply)
278 {
279 int32_t result = TELEPHONY_ERR_FAIL;
280 const CallRestrictionResponse *parcelPtr = nullptr;
281 if (!data.ContainFileDescriptors()) {
282 TELEPHONY_LOGW("sent raw data is less than 32k");
283 }
284 int32_t len = data.ReadInt32();
285 if (len <= 0 || len >= MAX_LEN) {
286 TELEPHONY_LOGE("Invalid parameter, len = %{public}d", len);
287 return TELEPHONY_ERR_ARGUMENT_INVALID;
288 }
289 if ((parcelPtr = reinterpret_cast<const CallRestrictionResponse *>(data.ReadRawData(len))) == nullptr) {
290 TELEPHONY_LOGE("reading raw data failed, length = %d", len);
291 return TELEPHONY_ERR_LOCAL_PTR_NULL;
292 }
293 result = UpdateGetRestrictionResult(*parcelPtr);
294 if (!reply.WriteInt32(result)) {
295 TELEPHONY_LOGE("writing parcel failed");
296 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
297 }
298 return TELEPHONY_SUCCESS;
299 }
300
OnUpdateSetRestrictionResult(MessageParcel & data,MessageParcel & reply)301 int32_t CallStatusCallbackStub::OnUpdateSetRestrictionResult(MessageParcel &data, MessageParcel &reply)
302 {
303 int32_t error = TELEPHONY_ERR_FAIL;
304 int32_t result = TELEPHONY_ERR_FAIL;
305 if (!data.ContainFileDescriptors()) {
306 TELEPHONY_LOGW("sent raw data is less than 32k");
307 }
308 result = data.ReadInt32();
309 error = UpdateSetRestrictionResult(result);
310 if (!reply.WriteInt32(error)) {
311 TELEPHONY_LOGE("writing parcel failed");
312 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
313 }
314 return TELEPHONY_SUCCESS;
315 }
316
OnUpdateSetRestrictionPasswordResult(MessageParcel & data,MessageParcel & reply)317 int32_t CallStatusCallbackStub::OnUpdateSetRestrictionPasswordResult(MessageParcel &data, MessageParcel &reply)
318 {
319 int32_t error = TELEPHONY_ERR_FAIL;
320 int32_t result = TELEPHONY_ERR_FAIL;
321 if (!data.ContainFileDescriptors()) {
322 TELEPHONY_LOGW("sent raw data is less than 32k");
323 }
324 result = data.ReadInt32();
325 error = UpdateSetRestrictionPasswordResult(result);
326 if (!reply.WriteInt32(error)) {
327 TELEPHONY_LOGE("writing parcel failed");
328 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
329 }
330 return TELEPHONY_SUCCESS;
331 }
332
OnUpdateGetTransferResult(MessageParcel & data,MessageParcel & reply)333 int32_t CallStatusCallbackStub::OnUpdateGetTransferResult(MessageParcel &data, MessageParcel &reply)
334 {
335 int32_t result = TELEPHONY_ERR_FAIL;
336 const CallTransferResponse *parcelPtr = nullptr;
337 if (!data.ContainFileDescriptors()) {
338 TELEPHONY_LOGW("sent raw data is less than 32k");
339 }
340 int32_t len = data.ReadInt32();
341 if (len <= 0 || len >= MAX_LEN) {
342 TELEPHONY_LOGE("Invalid parameter, len = %{public}d", len);
343 return TELEPHONY_ERR_ARGUMENT_INVALID;
344 }
345 if ((parcelPtr = reinterpret_cast<const CallTransferResponse *>(data.ReadRawData(len))) == nullptr) {
346 TELEPHONY_LOGE("reading raw data failed, length = %d", len);
347 return TELEPHONY_ERR_LOCAL_PTR_NULL;
348 }
349 result = UpdateGetTransferResult(*parcelPtr);
350 if (!reply.WriteInt32(result)) {
351 TELEPHONY_LOGE("writing parcel failed");
352 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
353 }
354 return TELEPHONY_SUCCESS;
355 }
356
OnUpdateSetTransferResult(MessageParcel & data,MessageParcel & reply)357 int32_t CallStatusCallbackStub::OnUpdateSetTransferResult(MessageParcel &data, MessageParcel &reply)
358 {
359 int32_t error = TELEPHONY_ERR_FAIL;
360 int32_t result = TELEPHONY_ERR_FAIL;
361 if (!data.ContainFileDescriptors()) {
362 TELEPHONY_LOGW("sent raw data is less than 32k");
363 }
364 result = data.ReadInt32();
365 error = UpdateSetTransferResult(result);
366 if (!reply.WriteInt32(error)) {
367 TELEPHONY_LOGE("writing parcel failed");
368 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
369 }
370 return TELEPHONY_SUCCESS;
371 }
372
OnUpdateGetCallClipResult(MessageParcel & data,MessageParcel & reply)373 int32_t CallStatusCallbackStub::OnUpdateGetCallClipResult(MessageParcel &data, MessageParcel &reply)
374 {
375 int32_t result = TELEPHONY_ERR_FAIL;
376 const ClipResponse *parcelPtr = nullptr;
377 if (!data.ContainFileDescriptors()) {
378 TELEPHONY_LOGW("sent raw data is less than 32k");
379 }
380 int32_t len = data.ReadInt32();
381 if (len <= 0 || len >= MAX_LEN) {
382 TELEPHONY_LOGE("Invalid parameter, len = %{public}d", len);
383 return TELEPHONY_ERR_ARGUMENT_INVALID;
384 }
385 if ((parcelPtr = reinterpret_cast<const ClipResponse *>(data.ReadRawData(len))) == nullptr) {
386 TELEPHONY_LOGE("reading raw data failed, length = %d", len);
387 return TELEPHONY_ERR_LOCAL_PTR_NULL;
388 }
389 result = UpdateGetCallClipResult(*parcelPtr);
390 if (!reply.WriteInt32(result)) {
391 TELEPHONY_LOGE("writing parcel failed");
392 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
393 }
394 return TELEPHONY_SUCCESS;
395 }
396
OnUpdateGetCallClirResult(MessageParcel & data,MessageParcel & reply)397 int32_t CallStatusCallbackStub::OnUpdateGetCallClirResult(MessageParcel &data, MessageParcel &reply)
398 {
399 int32_t result = TELEPHONY_ERR_FAIL;
400 if (!data.ContainFileDescriptors()) {
401 TELEPHONY_LOGW("sent raw data is less than 32k");
402 }
403 const ClirResponse *parcelPtr = nullptr;
404 int32_t len = data.ReadInt32();
405 if (len <= 0 || len >= MAX_LEN) {
406 TELEPHONY_LOGE("Invalid parameter, len = %{public}d", len);
407 return TELEPHONY_ERR_ARGUMENT_INVALID;
408 }
409 if ((parcelPtr = reinterpret_cast<const ClirResponse *>(data.ReadRawData(len))) == nullptr) {
410 TELEPHONY_LOGE("reading raw data failed, length = %d", len);
411 return TELEPHONY_ERR_LOCAL_PTR_NULL;
412 }
413 result = UpdateGetCallClirResult(*parcelPtr);
414 if (!reply.WriteInt32(result)) {
415 TELEPHONY_LOGE("writing parcel failed");
416 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
417 }
418 return TELEPHONY_SUCCESS;
419 }
420
OnUpdateSetCallClirResult(MessageParcel & data,MessageParcel & reply)421 int32_t CallStatusCallbackStub::OnUpdateSetCallClirResult(MessageParcel &data, MessageParcel &reply)
422 {
423 int32_t error = TELEPHONY_ERR_FAIL;
424 int32_t result = TELEPHONY_ERR_FAIL;
425 if (!data.ContainFileDescriptors()) {
426 TELEPHONY_LOGW("sent raw data is less than 32k");
427 }
428 result = data.ReadInt32();
429 error = UpdateSetCallClirResult(result);
430 if (!reply.WriteInt32(error)) {
431 TELEPHONY_LOGE("writing parcel failed");
432 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
433 }
434 return TELEPHONY_SUCCESS;
435 }
436
OnStartRttResult(MessageParcel & data,MessageParcel & reply)437 int32_t CallStatusCallbackStub::OnStartRttResult(MessageParcel &data, MessageParcel &reply)
438 {
439 int32_t error = TELEPHONY_ERR_FAIL;
440 int32_t result = TELEPHONY_ERR_FAIL;
441 if (!data.ContainFileDescriptors()) {
442 TELEPHONY_LOGW("sent raw data is less than 32k");
443 }
444 result = data.ReadInt32();
445 error = StartRttResult(result);
446 if (!reply.WriteInt32(error)) {
447 TELEPHONY_LOGE("writing parcel failed");
448 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
449 }
450 return TELEPHONY_SUCCESS;
451 }
452
OnStopRttResult(MessageParcel & data,MessageParcel & reply)453 int32_t CallStatusCallbackStub::OnStopRttResult(MessageParcel &data, MessageParcel &reply)
454 {
455 int32_t error = TELEPHONY_ERR_FAIL;
456 int32_t result = TELEPHONY_ERR_FAIL;
457 if (!data.ContainFileDescriptors()) {
458 TELEPHONY_LOGW("sent raw data is less than 32k");
459 }
460 result = data.ReadInt32();
461 error = StopRttResult(result);
462 if (!reply.WriteInt32(error)) {
463 TELEPHONY_LOGE("writing parcel failed");
464 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
465 }
466 return TELEPHONY_SUCCESS;
467 }
468
OnGetImsConfigResult(MessageParcel & data,MessageParcel & reply)469 int32_t CallStatusCallbackStub::OnGetImsConfigResult(MessageParcel &data, MessageParcel &reply)
470 {
471 int32_t error = TELEPHONY_ERR_FAIL;
472 if (!data.ContainFileDescriptors()) {
473 TELEPHONY_LOGW("sent raw data is less than 32k");
474 }
475 const GetImsConfigResponse *parcelPtr = nullptr;
476 int32_t len = data.ReadInt32();
477 if (len <= 0 || len >= MAX_LEN) {
478 TELEPHONY_LOGE("Invalid parameter, len = %{public}d", len);
479 return TELEPHONY_ERR_ARGUMENT_INVALID;
480 }
481 if ((parcelPtr = reinterpret_cast<const GetImsConfigResponse *>(data.ReadRawData(len))) == nullptr) {
482 TELEPHONY_LOGE("reading raw data failed, length = %d", len);
483 return TELEPHONY_ERR_LOCAL_PTR_NULL;
484 }
485 error = GetImsConfigResult(*parcelPtr);
486 if (!reply.WriteInt32(error)) {
487 TELEPHONY_LOGE("writing parcel failed");
488 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
489 }
490 return TELEPHONY_SUCCESS;
491 }
492
OnSetImsConfigResult(MessageParcel & data,MessageParcel & reply)493 int32_t CallStatusCallbackStub::OnSetImsConfigResult(MessageParcel &data, MessageParcel &reply)
494 {
495 int32_t error = TELEPHONY_ERR_FAIL;
496 int32_t result = TELEPHONY_ERR_FAIL;
497 if (!data.ContainFileDescriptors()) {
498 TELEPHONY_LOGW("sent raw data is less than 32k");
499 }
500 result = data.ReadInt32();
501 error = SetImsConfigResult(result);
502 if (!reply.WriteInt32(error)) {
503 TELEPHONY_LOGE("writing parcel failed");
504 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
505 }
506 return TELEPHONY_SUCCESS;
507 }
508
OnGetImsFeatureValueResult(MessageParcel & data,MessageParcel & reply)509 int32_t CallStatusCallbackStub::OnGetImsFeatureValueResult(MessageParcel &data, MessageParcel &reply)
510 {
511 int32_t error = TELEPHONY_ERR_FAIL;
512 if (!data.ContainFileDescriptors()) {
513 TELEPHONY_LOGW("sent raw data is less than 32k");
514 }
515 const GetImsFeatureValueResponse *parcelPtr = nullptr;
516 int32_t len = data.ReadInt32();
517 if (len <= 0 || len >= MAX_LEN) {
518 TELEPHONY_LOGE("Invalid parameter, len = %{public}d", len);
519 return TELEPHONY_ERR_ARGUMENT_INVALID;
520 }
521 if ((parcelPtr = reinterpret_cast<const GetImsFeatureValueResponse *>(data.ReadRawData(len))) == nullptr) {
522 TELEPHONY_LOGE("reading raw data failed, length = %d", len);
523 return TELEPHONY_ERR_LOCAL_PTR_NULL;
524 }
525 error = GetImsFeatureValueResult(*parcelPtr);
526 if (!reply.WriteInt32(error)) {
527 TELEPHONY_LOGE("writing parcel failed");
528 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
529 }
530 return TELEPHONY_SUCCESS;
531 }
532
OnSetImsFeatureValueResult(MessageParcel & data,MessageParcel & reply)533 int32_t CallStatusCallbackStub::OnSetImsFeatureValueResult(MessageParcel &data, MessageParcel &reply)
534 {
535 int32_t error = TELEPHONY_ERR_FAIL;
536 int32_t result = TELEPHONY_ERR_FAIL;
537 if (!data.ContainFileDescriptors()) {
538 TELEPHONY_LOGW("sent raw data is less than 32k");
539 }
540 result = data.ReadInt32();
541 error = SetImsFeatureValueResult(result);
542 if (!reply.WriteInt32(error)) {
543 TELEPHONY_LOGE("writing parcel failed");
544 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
545 }
546 return TELEPHONY_SUCCESS;
547 }
548
OnReceiveImsCallModeRequest(MessageParcel & data,MessageParcel & reply)549 int32_t CallStatusCallbackStub::OnReceiveImsCallModeRequest(MessageParcel &data, MessageParcel &reply)
550 {
551 int32_t error = TELEPHONY_ERR_FAIL;
552 if (!data.ContainFileDescriptors()) {
553 TELEPHONY_LOGW("sent raw data is less than 32k");
554 }
555 const CallModeReportInfo *parcelPtr = nullptr;
556 int32_t len = data.ReadInt32();
557 if (len <= 0 || len >= MAX_LEN) {
558 TELEPHONY_LOGE("Invalid parameter, len = %{public}d", len);
559 return TELEPHONY_ERR_ARGUMENT_INVALID;
560 }
561 if ((parcelPtr = reinterpret_cast<const CallModeReportInfo *>(data.ReadRawData(len))) == nullptr) {
562 TELEPHONY_LOGE("reading raw data failed, length = %d", len);
563 return TELEPHONY_ERR_LOCAL_PTR_NULL;
564 }
565 error = ReceiveUpdateCallMediaModeRequest(*parcelPtr);
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
OnReceiveImsCallModeResponse(MessageParcel & data,MessageParcel & reply)573 int32_t CallStatusCallbackStub::OnReceiveImsCallModeResponse(MessageParcel &data, MessageParcel &reply)
574 {
575 int32_t error = TELEPHONY_ERR_FAIL;
576 if (!data.ContainFileDescriptors()) {
577 TELEPHONY_LOGW("sent raw data is less than 32k");
578 }
579 const CallModeReportInfo *parcelPtr = nullptr;
580 int32_t len = data.ReadInt32();
581 if (len <= 0 || len >= MAX_LEN) {
582 TELEPHONY_LOGE("Invalid parameter, len = %{public}d", len);
583 return TELEPHONY_ERR_ARGUMENT_INVALID;
584 }
585 if ((parcelPtr = reinterpret_cast<const CallModeReportInfo *>(data.ReadRawData(len))) == nullptr) {
586 TELEPHONY_LOGE("reading raw data failed, length = %d", len);
587 return TELEPHONY_ERR_LOCAL_PTR_NULL;
588 }
589 error = ReceiveUpdateCallMediaModeResponse(*parcelPtr);
590 if (!reply.WriteInt32(error)) {
591 TELEPHONY_LOGE("writing parcel failed");
592 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
593 }
594 return TELEPHONY_SUCCESS;
595 }
596
OnInviteToConferenceResult(MessageParcel & data,MessageParcel & reply)597 int32_t CallStatusCallbackStub::OnInviteToConferenceResult(MessageParcel &data, MessageParcel &reply)
598 {
599 int32_t error = TELEPHONY_ERR_FAIL;
600 int32_t result = TELEPHONY_ERR_FAIL;
601 if (!data.ContainFileDescriptors()) {
602 TELEPHONY_LOGW("sent raw data is less than 32k");
603 }
604 result = data.ReadInt32();
605 error = InviteToConferenceResult(result);
606 if (!reply.WriteInt32(error)) {
607 TELEPHONY_LOGE("writing parcel failed");
608 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
609 }
610 return TELEPHONY_SUCCESS;
611 }
612
OnStartDtmfResult(MessageParcel & data,MessageParcel & reply)613 int32_t CallStatusCallbackStub::OnStartDtmfResult(MessageParcel &data, MessageParcel &reply)
614 {
615 int32_t error = TELEPHONY_ERR_FAIL;
616 int32_t result = TELEPHONY_ERR_FAIL;
617 if (!data.ContainFileDescriptors()) {
618 TELEPHONY_LOGW("sent raw data is less than 32k");
619 }
620 result = data.ReadInt32();
621 error = StartDtmfResult(result);
622 if (!reply.WriteInt32(error)) {
623 TELEPHONY_LOGE("writing parcel failed");
624 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
625 }
626 return TELEPHONY_SUCCESS;
627 }
628
OnStopDtmfResult(MessageParcel & data,MessageParcel & reply)629 int32_t CallStatusCallbackStub::OnStopDtmfResult(MessageParcel &data, MessageParcel &reply)
630 {
631 int32_t error = TELEPHONY_ERR_FAIL;
632 int32_t result = TELEPHONY_ERR_FAIL;
633 if (!data.ContainFileDescriptors()) {
634 TELEPHONY_LOGW("sent raw data is less than 32k");
635 }
636 result = data.ReadInt32();
637 error = StopDtmfResult(result);
638 if (!reply.WriteInt32(error)) {
639 TELEPHONY_LOGE("writing parcel failed");
640 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
641 }
642 return TELEPHONY_SUCCESS;
643 }
644
OnSendUssdResult(MessageParcel & data,MessageParcel & reply)645 int32_t CallStatusCallbackStub::OnSendUssdResult(MessageParcel &data, MessageParcel &reply)
646 {
647 int32_t error = TELEPHONY_ERR_FAIL;
648 int32_t result = TELEPHONY_ERR_FAIL;
649 if (!data.ContainFileDescriptors()) {
650 TELEPHONY_LOGW("sent raw data is less than 32k");
651 }
652 result = data.ReadInt32();
653 error = SendUssdResult(result);
654 if (!reply.WriteInt32(error)) {
655 TELEPHONY_LOGE("writing parcel failed");
656 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
657 }
658 return TELEPHONY_SUCCESS;
659 }
660
OnSendMmiCodeResult(MessageParcel & data,MessageParcel & reply)661 int32_t CallStatusCallbackStub::OnSendMmiCodeResult(MessageParcel &data, MessageParcel &reply)
662 {
663 int32_t result = TELEPHONY_ERR_FAIL;
664 const MmiCodeInfo *parcelPtr = nullptr;
665 if (!data.ContainFileDescriptors()) {
666 TELEPHONY_LOGW("sent raw data is less than 32k");
667 }
668 int32_t len = data.ReadInt32();
669 if (len <= 0 || len >= MAX_LEN) {
670 TELEPHONY_LOGE("Invalid parameter, len = %{public}d", len);
671 return TELEPHONY_ERR_ARGUMENT_INVALID;
672 }
673 if ((parcelPtr = reinterpret_cast<const MmiCodeInfo *>(data.ReadRawData(len))) == nullptr) {
674 TELEPHONY_LOGE("reading raw data failed, length = %d", len);
675 return TELEPHONY_ERR_LOCAL_PTR_NULL;
676 }
677
678 result = SendMmiCodeResult(*parcelPtr);
679 if (!reply.WriteInt32(result)) {
680 TELEPHONY_LOGE("writing parcel failed");
681 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
682 }
683 return TELEPHONY_SUCCESS;
684 }
685
OnGetImsCallDataResult(MessageParcel & data,MessageParcel & reply)686 int32_t CallStatusCallbackStub::OnGetImsCallDataResult(MessageParcel &data, MessageParcel &reply)
687 {
688 int32_t error = TELEPHONY_ERR_FAIL;
689 int32_t result = TELEPHONY_ERR_FAIL;
690 if (!data.ContainFileDescriptors()) {
691 TELEPHONY_LOGW("sent raw data is less than 32k");
692 }
693 result = data.ReadInt32();
694 error = GetImsCallDataResult(result);
695 if (!reply.WriteInt32(error)) {
696 TELEPHONY_LOGE("writing parcel failed");
697 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
698 }
699 return TELEPHONY_SUCCESS;
700 }
701
OnCloseUnFinishedUssdResult(MessageParcel & data,MessageParcel & reply)702 int32_t CallStatusCallbackStub::OnCloseUnFinishedUssdResult(MessageParcel &data, MessageParcel &reply)
703 {
704 int32_t error = TELEPHONY_ERR_FAIL;
705 int32_t result = TELEPHONY_ERR_FAIL;
706 if (!data.ContainFileDescriptors()) {
707 TELEPHONY_LOGW("sent raw data is less than 32k");
708 }
709 result = data.ReadInt32();
710 error = CloseUnFinishedUssdResult(result);
711 if (!reply.WriteInt32(error)) {
712 TELEPHONY_LOGE("writing parcel failed");
713 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
714 }
715 return TELEPHONY_SUCCESS;
716 }
717
OnPostDialNextChar(MessageParcel & data,MessageParcel & reply)718 int32_t CallStatusCallbackStub::OnPostDialNextChar(MessageParcel &data, MessageParcel &reply)
719 {
720 int32_t error = TELEPHONY_ERR_FAIL;
721 if (!data.ContainFileDescriptors()) {
722 TELEPHONY_LOGW("sent raw data is less than 32k");
723 }
724 std::string c = data.ReadString();
725 error = ReportPostDialChar(c);
726 if (!reply.WriteInt32(error)) {
727 TELEPHONY_LOGE("writing parcel failed");
728 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
729 }
730 return TELEPHONY_SUCCESS;
731 }
732
OnReportPostDialDelay(MessageParcel & data,MessageParcel & reply)733 int32_t CallStatusCallbackStub::OnReportPostDialDelay(MessageParcel &data, MessageParcel &reply)
734 {
735 int32_t error = TELEPHONY_ERR_FAIL;
736 if (!data.ContainFileDescriptors()) {
737 TELEPHONY_LOGW("sent raw data is less than 32k");
738 }
739 std::string remainPostDial = data.ReadString();
740 error = ReportPostDialDelay(remainPostDial);
741 if (!reply.WriteInt32(error)) {
742 TELEPHONY_LOGE("writing parcel failed");
743 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
744 }
745 return TELEPHONY_SUCCESS;
746 }
747
OnCallSessionEventChange(MessageParcel & data,MessageParcel & reply)748 int32_t CallStatusCallbackStub::OnCallSessionEventChange(MessageParcel &data, MessageParcel &reply)
749 {
750 int32_t error = TELEPHONY_ERR_FAIL;
751 if (!data.ContainFileDescriptors()) {
752 TELEPHONY_LOGW("sent raw data is less than 32k");
753 }
754 const CallSessionReportInfo *parcelPtr = nullptr;
755 int32_t len = data.ReadInt32();
756 if (len <= 0 || len >= MAX_LEN) {
757 TELEPHONY_LOGE("Invalid parameter, len = %{public}d", len);
758 return TELEPHONY_ERR_ARGUMENT_INVALID;
759 }
760 if ((parcelPtr = reinterpret_cast<const CallSessionReportInfo *>(data.ReadRawData(len))) == nullptr) {
761 TELEPHONY_LOGE("reading raw data failed, length = %d", len);
762 return TELEPHONY_ERR_LOCAL_PTR_NULL;
763 }
764 error = HandleCallSessionEventChanged(*parcelPtr);
765 if (!reply.WriteInt32(error)) {
766 TELEPHONY_LOGE("writing parcel failed");
767 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
768 }
769 return TELEPHONY_SUCCESS;
770 }
771
OnPeerDimensionsChange(MessageParcel & data,MessageParcel & reply)772 int32_t CallStatusCallbackStub::OnPeerDimensionsChange(MessageParcel &data, MessageParcel &reply)
773 {
774 int32_t error = TELEPHONY_ERR_FAIL;
775 if (!data.ContainFileDescriptors()) {
776 TELEPHONY_LOGW("sent raw data is less than 32k");
777 }
778 const PeerDimensionsReportInfo *parcelPtr = nullptr;
779 int32_t len = data.ReadInt32();
780 if (len <= 0 || len >= MAX_LEN) {
781 TELEPHONY_LOGE("Invalid parameter, len = %{public}d", len);
782 return TELEPHONY_ERR_ARGUMENT_INVALID;
783 }
784 if ((parcelPtr = reinterpret_cast<const PeerDimensionsReportInfo *>(data.ReadRawData(len))) == nullptr) {
785 TELEPHONY_LOGE("reading raw data failed, length = %d", len);
786 return TELEPHONY_ERR_LOCAL_PTR_NULL;
787 }
788 error = HandlePeerDimensionsChanged(*parcelPtr);
789 if (!reply.WriteInt32(error)) {
790 TELEPHONY_LOGE("writing parcel failed");
791 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
792 }
793 return TELEPHONY_SUCCESS;
794 }
795
OnCallDataUsageChange(MessageParcel & data,MessageParcel & reply)796 int32_t CallStatusCallbackStub::OnCallDataUsageChange(MessageParcel &data, MessageParcel &reply)
797 {
798 int32_t error = TELEPHONY_ERR_FAIL;
799 if (!data.ContainFileDescriptors()) {
800 TELEPHONY_LOGW("sent raw data is less than 32k");
801 }
802 int64_t result = data.ReadInt64();
803 error = HandleCallDataUsageChanged(result);
804 if (!reply.WriteInt32(error)) {
805 TELEPHONY_LOGE("writing parcel failed");
806 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
807 }
808 return TELEPHONY_SUCCESS;
809 }
810
OnCameraCapabilitiesChange(MessageParcel & data,MessageParcel & reply)811 int32_t CallStatusCallbackStub::OnCameraCapabilitiesChange(MessageParcel &data, MessageParcel &reply)
812 {
813 int32_t error = TELEPHONY_ERR_FAIL;
814 if (!data.ContainFileDescriptors()) {
815 TELEPHONY_LOGW("sent raw data is less than 32k");
816 }
817 const CameraCapabilitiesReportInfo *parcelPtr = nullptr;
818 int32_t len = data.ReadInt32();
819 if (len <= 0 || len >= MAX_LEN) {
820 TELEPHONY_LOGE("Invalid parameter, len = %{public}d", len);
821 return TELEPHONY_ERR_ARGUMENT_INVALID;
822 }
823 if ((parcelPtr = reinterpret_cast<const CameraCapabilitiesReportInfo *>(data.ReadRawData(len))) == nullptr) {
824 TELEPHONY_LOGE("reading raw data failed, length = %d", len);
825 return TELEPHONY_ERR_LOCAL_PTR_NULL;
826 }
827 error = HandleCameraCapabilitiesChanged(*parcelPtr);
828 if (!reply.WriteInt32(error)) {
829 TELEPHONY_LOGE("writing parcel failed");
830 return TELEPHONY_ERR_WRITE_REPLY_FAIL;
831 }
832 return TELEPHONY_SUCCESS;
833 }
834 } // namespace Telephony
835 } // namespace OHOS
836