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 "hril_call.h"
17
18 #include "hril_call_parcel.h"
19 #include "hril_notification.h"
20 #include "hril_request.h"
21
22 namespace OHOS {
23 namespace Telephony {
HRilCall(int32_t slotId,IHRilReporter & hrilReporter)24 HRilCall::HRilCall(int32_t slotId, IHRilReporter &hrilReporter) : HRilBase(slotId, hrilReporter)
25 {
26 AddCallNotificationToMap();
27 AddCallResponseToMap();
28 }
29
~HRilCall()30 HRilCall::~HRilCall()
31 {
32 callFuncs_ = nullptr;
33 }
34
IsCallResponse(uint32_t code)35 bool HRilCall::IsCallResponse(uint32_t code)
36 {
37 return ((code >= HREQ_CALL_BASE) && (code < HREQ_SMS_BASE));
38 }
39
IsCallNotification(uint32_t code)40 bool HRilCall::IsCallNotification(uint32_t code)
41 {
42 return ((code >= HNOTI_CALL_BASE) && (code < HNOTI_SMS_BASE));
43 }
44
IsCallRespOrNotify(uint32_t code)45 bool HRilCall::IsCallRespOrNotify(uint32_t code)
46 {
47 return IsCallResponse(code) || IsCallNotification(code);
48 }
49
AddCallNotificationToMap()50 void HRilCall::AddCallNotificationToMap()
51 {
52 // Notification
53 notiMemberFuncMap_[HNOTI_CALL_STATE_UPDATED] = &HRilCall::CallStateUpdated;
54 notiMemberFuncMap_[HNOTI_CALL_USSD_REPORT] = &HRilCall::CallUssdNotice;
55 notiMemberFuncMap_[HNOTI_CALL_SRVCC_STATUS_REPORT] = &HRilCall::CallSrvccStatusNotice;
56 notiMemberFuncMap_[HNOTI_CALL_RINGBACK_VOICE_REPORT] = &HRilCall::CallRingbackVoiceNotice;
57 notiMemberFuncMap_[HNOTI_CALL_EMERGENCY_NUMBER_REPORT] = &HRilCall::CallEmergencyNotice;
58 notiMemberFuncMap_[HNOTI_CALL_SS_REPORT] = &HRilCall::CallSsNotice;
59 notiMemberFuncMap_[HNOTI_CALL_RSRVCC_STATUS_REPORT] = &HRilCall::CallRsrvccStatusNotify;
60 }
61
AddCallResponseToMap()62 void HRilCall::AddCallResponseToMap()
63 {
64 // Response
65 respMemberFuncMap_[HREQ_CALL_GET_CALL_LIST] = &HRilCall::GetCallListResponse;
66 respMemberFuncMap_[HREQ_CALL_DIAL] = &HRilCall::DialResponse;
67 respMemberFuncMap_[HREQ_CALL_HANGUP] = &HRilCall::HangupResponse;
68 respMemberFuncMap_[HREQ_CALL_REJECT] = &HRilCall::RejectResponse;
69 respMemberFuncMap_[HREQ_CALL_ANSWER] = &HRilCall::AnswerResponse;
70 respMemberFuncMap_[HREQ_CALL_HOLD_CALL] = &HRilCall::HoldCallResponse;
71 respMemberFuncMap_[HREQ_CALL_UNHOLD_CALL] = &HRilCall::UnHoldCallResponse;
72 respMemberFuncMap_[HREQ_CALL_SWITCH_CALL] = &HRilCall::SwitchCallResponse;
73 respMemberFuncMap_[HREQ_CALL_GET_CLIP] = &HRilCall::GetClipResponse;
74 respMemberFuncMap_[HREQ_CALL_SET_CLIP] = &HRilCall::SetClipResponse;
75 respMemberFuncMap_[HREQ_CALL_COMBINE_CONFERENCE] = &HRilCall::CombineConferenceResponse;
76 respMemberFuncMap_[HREQ_CALL_SEPARATE_CONFERENCE] = &HRilCall::SeparateConferenceResponse;
77 respMemberFuncMap_[HREQ_CALL_CALL_SUPPLEMENT] = &HRilCall::CallSupplementResponse;
78 respMemberFuncMap_[HREQ_CALL_GET_CALL_WAITING] = &HRilCall::GetCallWaitingResponse;
79 respMemberFuncMap_[HREQ_CALL_SET_CALL_WAITING] = &HRilCall::SetCallWaitingResponse;
80 respMemberFuncMap_[HREQ_CALL_GET_CALL_TRANSFER_INFO] = &HRilCall::GetCallTransferInfoResponse;
81 respMemberFuncMap_[HREQ_CALL_SET_CALL_TRANSFER_INFO] = &HRilCall::SetCallTransferInfoResponse;
82 respMemberFuncMap_[HREQ_CALL_GET_CALL_RESTRICTION] = &HRilCall::GetCallRestrictionResponse;
83 respMemberFuncMap_[HREQ_CALL_SET_CALL_RESTRICTION] = &HRilCall::SetCallRestrictionResponse;
84 respMemberFuncMap_[HREQ_CALL_GET_CLIR] = &HRilCall::GetClirResponse;
85 respMemberFuncMap_[HREQ_CALL_SET_CLIR] = &HRilCall::SetClirResponse;
86 respMemberFuncMap_[HREQ_CALL_START_DTMF] = &HRilCall::StartDtmfResponse;
87 respMemberFuncMap_[HREQ_CALL_SEND_DTMF] = &HRilCall::SendDtmfResponse;
88 respMemberFuncMap_[HREQ_CALL_STOP_DTMF] = &HRilCall::StopDtmfResponse;
89 respMemberFuncMap_[HREQ_CALL_GET_CALL_PREFERENCE] = &HRilCall::GetCallPreferenceModeResponse;
90 respMemberFuncMap_[HREQ_CALL_SET_CALL_PREFERENCE] = &HRilCall::SetCallPreferenceModeResponse;
91 respMemberFuncMap_[HREQ_CALL_SET_USSD] = &HRilCall::SetUssdResponse;
92 respMemberFuncMap_[HREQ_CALL_GET_USSD] = &HRilCall::GetUssdResponse;
93 respMemberFuncMap_[HREQ_CALL_SET_MUTE] = &HRilCall::SetMuteResponse;
94 respMemberFuncMap_[HREQ_CALL_GET_MUTE] = &HRilCall::GetMuteResponse;
95 respMemberFuncMap_[HREQ_CALL_GET_EMERGENCY_LIST] = &HRilCall::GetEmergencyCallListResponse;
96 respMemberFuncMap_[HREQ_CALL_SET_EMERGENCY_LIST] = &HRilCall::SetEmergencyCallListResponse;
97 respMemberFuncMap_[HREQ_CALL_GET_FAIL_REASON] = &HRilCall::GetCallFailReasonResponse;
98 respMemberFuncMap_[HREQ_CALL_SET_BARRING_PASSWORD] = &HRilCall::SetBarringPasswordResponse;
99 respMemberFuncMap_[HREQ_CALL_CLOSE_UNFINISHED_USSD] = &HRilCall::CloseUnFinishedUssdResponse;
100 respMemberFuncMap_[HREQ_SET_VONR_SWITCH] = &HRilCall::SetVonrSwitchResponse;
101 }
102
GetCallList(int32_t serialId)103 int32_t HRilCall::GetCallList(int32_t serialId)
104 {
105 return RequestVendor(serialId, HREQ_CALL_GET_CALL_LIST, callFuncs_, &HRilCallReq::GetCallList);
106 }
107
Dial(int32_t serialId,const OHOS::HDI::Ril::V1_1::DialInfo & dialInfo)108 int32_t HRilCall::Dial(int32_t serialId, const OHOS::HDI::Ril::V1_1::DialInfo &dialInfo)
109 {
110 HRilDial dial = {};
111 dial.address = StringToCString(dialInfo.address);
112 dial.clir = dialInfo.clir;
113 return RequestVendor(serialId, HREQ_CALL_DIAL, callFuncs_, &HRilCallReq::Dial, &dial, sizeof(HRilDial));
114 }
115
Hangup(int32_t serialId,int32_t gsmIndex)116 int32_t HRilCall::Hangup(int32_t serialId, int32_t gsmIndex)
117 {
118 uint32_t data = gsmIndex;
119 return RequestVendor(serialId, HREQ_CALL_HANGUP, callFuncs_, &HRilCallReq::Hangup, &data, sizeof(uint32_t));
120 }
121
Reject(int32_t serialId)122 int32_t HRilCall::Reject(int32_t serialId)
123 {
124 return RequestVendor(serialId, HREQ_CALL_REJECT, callFuncs_, &HRilCallReq::Reject);
125 }
126
Answer(int32_t serialId)127 int32_t HRilCall::Answer(int32_t serialId)
128 {
129 return RequestVendor(serialId, HREQ_CALL_ANSWER, callFuncs_, &HRilCallReq::Answer);
130 }
131
HoldCall(int32_t serialId)132 int32_t HRilCall::HoldCall(int32_t serialId)
133 {
134 return RequestVendor(serialId, HREQ_CALL_HOLD_CALL, callFuncs_, &HRilCallReq::HoldCall);
135 }
136
UnHoldCall(int32_t serialId)137 int32_t HRilCall::UnHoldCall(int32_t serialId)
138 {
139 return RequestVendor(serialId, HREQ_CALL_UNHOLD_CALL, callFuncs_, &HRilCallReq::UnHoldCall);
140 }
141
SwitchCall(int32_t serialId)142 int32_t HRilCall::SwitchCall(int32_t serialId)
143 {
144 return RequestVendor(serialId, HREQ_CALL_SWITCH_CALL, callFuncs_, &HRilCallReq::SwitchCall);
145 }
146
CombineConference(int32_t serialId,int32_t callType)147 int32_t HRilCall::CombineConference(int32_t serialId, int32_t callType)
148 {
149 return RequestVendor(
150 serialId, HREQ_CALL_COMBINE_CONFERENCE, callFuncs_, &HRilCallReq::CombineConference, callType);
151 }
152
SeparateConference(int32_t serialId,int32_t callIndex,int32_t callType)153 int32_t HRilCall::SeparateConference(int32_t serialId, int32_t callIndex, int32_t callType)
154 {
155 return RequestVendor(
156 serialId, HREQ_CALL_SEPARATE_CONFERENCE, callFuncs_, &HRilCallReq::SeparateConference, callIndex, callType);
157 }
158
CallSupplement(int32_t serialId,int32_t type)159 int32_t HRilCall::CallSupplement(int32_t serialId, int32_t type)
160 {
161 return RequestVendor(serialId, HREQ_CALL_CALL_SUPPLEMENT, callFuncs_, &HRilCallReq::CallSupplement, type);
162 }
163
GetClip(int32_t serialId)164 int32_t HRilCall::GetClip(int32_t serialId)
165 {
166 return RequestVendor(serialId, HREQ_CALL_GET_CLIP, callFuncs_, &HRilCallReq::GetClip);
167 }
168
SetClip(int32_t serialId,int32_t action)169 int32_t HRilCall::SetClip(int32_t serialId, int32_t action)
170 {
171 return RequestVendor(serialId, HREQ_CALL_SET_CLIP, callFuncs_, &HRilCallReq::SetClip, action);
172 }
173
GetClir(int32_t serialId)174 int32_t HRilCall::GetClir(int32_t serialId)
175 {
176 return RequestVendor(serialId, HREQ_CALL_GET_CLIR, callFuncs_, &HRilCallReq::GetClir);
177 }
178
SetClir(int32_t serialId,int32_t action)179 int32_t HRilCall::SetClir(int32_t serialId, int32_t action)
180 {
181 return RequestVendor(serialId, HREQ_CALL_SET_CLIR, callFuncs_, &HRilCallReq::SetClir, action);
182 }
183
GetCallRestriction(int32_t serialId,const std::string & fac)184 int32_t HRilCall::GetCallRestriction(int32_t serialId, const std::string &fac)
185 {
186 return RequestVendor(
187 serialId, HREQ_CALL_GET_CALL_RESTRICTION, callFuncs_, &HRilCallReq::GetCallRestriction, StringToCString(fac));
188 }
189
SetCallRestriction(int32_t serialId,const OHOS::HDI::Ril::V1_1::CallRestrictionInfo & callRestrictionInfo)190 int32_t HRilCall::SetCallRestriction(
191 int32_t serialId, const OHOS::HDI::Ril::V1_1::CallRestrictionInfo &callRestrictionInfo)
192 {
193 CallRestrictionInfo info = {};
194 info.fac = StringToCString(callRestrictionInfo.fac);
195 info.mode = callRestrictionInfo.mode;
196 info.password = StringToCString(callRestrictionInfo.password);
197 return RequestVendor(serialId, HREQ_CALL_SET_CALL_RESTRICTION, callFuncs_, &HRilCallReq::SetCallRestriction, info);
198 }
199
GetCallWaiting(int32_t serialId)200 int32_t HRilCall::GetCallWaiting(int32_t serialId)
201 {
202 return RequestVendor(serialId, HREQ_CALL_GET_CALL_WAITING, callFuncs_, &HRilCallReq::GetCallWaiting);
203 }
204
SetCallWaiting(int32_t serialId,int32_t activate)205 int32_t HRilCall::SetCallWaiting(int32_t serialId, int32_t activate)
206 {
207 return RequestVendor(serialId, HREQ_CALL_SET_CALL_WAITING, callFuncs_, &HRilCallReq::SetCallWaiting, activate);
208 }
209
GetCallTransferInfo(int32_t serialId,int32_t reason)210 int32_t HRilCall::GetCallTransferInfo(int32_t serialId, int32_t reason)
211 {
212 return RequestVendor(
213 serialId, HREQ_CALL_GET_CALL_TRANSFER_INFO, callFuncs_, &HRilCallReq::GetCallTransferInfo, reason);
214 }
215
SetCallTransferInfo(int32_t serialId,const OHOS::HDI::Ril::V1_1::CallForwardSetInfo & callForwardSetInfo)216 int32_t HRilCall::SetCallTransferInfo(
217 int32_t serialId, const OHOS::HDI::Ril::V1_1::CallForwardSetInfo &callForwardSetInfo)
218 {
219 HRilCFInfo cFInfo = {};
220 cFInfo.number = StringToCString(callForwardSetInfo.number);
221 cFInfo.reason = callForwardSetInfo.reason;
222 cFInfo.mode = callForwardSetInfo.mode;
223 cFInfo.classx = callForwardSetInfo.classx;
224 return RequestVendor(
225 serialId, HREQ_CALL_SET_CALL_TRANSFER_INFO, callFuncs_, &HRilCallReq::SetCallTransferInfo, cFInfo);
226 }
227
GetCallPreferenceMode(int32_t serialId)228 int32_t HRilCall::GetCallPreferenceMode(int32_t serialId)
229 {
230 return RequestVendor(
231 serialId, HREQ_CALL_GET_CALL_PREFERENCE, callFuncs_, &HRilCallReq::GetCallPreferenceMode);
232 }
233
SetCallPreferenceMode(int32_t serialId,int32_t mode)234 int32_t HRilCall::SetCallPreferenceMode(int32_t serialId, int32_t mode)
235 {
236 return RequestVendor(
237 serialId, HREQ_CALL_SET_CALL_PREFERENCE, callFuncs_, &HRilCallReq::SetCallPreferenceMode, mode);
238 }
239
SetUssd(int32_t serialId,const std::string & str)240 int32_t HRilCall::SetUssd(int32_t serialId, const std::string &str)
241 {
242 return RequestVendor(
243 serialId, HREQ_CALL_SET_USSD, callFuncs_, &HRilCallReq::SetUssd, StringToCString(str));
244 }
245
GetUssd(int32_t serialId)246 int32_t HRilCall::GetUssd(int32_t serialId)
247 {
248 return RequestVendor(serialId, HREQ_CALL_GET_USSD, callFuncs_, &HRilCallReq::GetUssd);
249 }
250
SetMute(int32_t serialId,int32_t mute)251 int32_t HRilCall::SetMute(int32_t serialId, int32_t mute)
252 {
253 return RequestVendor(serialId, HREQ_CALL_SET_MUTE, callFuncs_, &HRilCallReq::SetMute, mute);
254 }
255
GetMute(int32_t serialId)256 int32_t HRilCall::GetMute(int32_t serialId)
257 {
258 return RequestVendor(serialId, HREQ_CALL_GET_MUTE, callFuncs_, &HRilCallReq::GetMute);
259 }
260
GetCallFailReason(int32_t serialId)261 int32_t HRilCall::GetCallFailReason(int32_t serialId)
262 {
263 return RequestVendor(serialId, HREQ_CALL_GET_FAIL_REASON, callFuncs_, &HRilCallReq::GetCallFailReason);
264 }
265
GetEmergencyCallList(int32_t serialId)266 int32_t HRilCall::GetEmergencyCallList(int32_t serialId)
267 {
268 return RequestVendor(serialId, HREQ_CALL_GET_EMERGENCY_LIST, callFuncs_, &HRilCallReq::GetEmergencyCallList);
269 }
270
SetBarringPassword(int32_t serialId,const OHOS::HDI::Ril::V1_1::SetBarringInfo & setBarringInfo)271 int32_t HRilCall::SetBarringPassword(int32_t serialId, const OHOS::HDI::Ril::V1_1::SetBarringInfo &setBarringInfo)
272 {
273 HRilSetBarringInfo info = {};
274 info.fac = StringToCString(setBarringInfo.fac);
275 info.oldPassword = StringToCString(setBarringInfo.oldPassword);
276 info.newPassword = StringToCString(setBarringInfo.newPassword);
277 return RequestVendor(
278 serialId, HREQ_CALL_SET_BARRING_PASSWORD, callFuncs_, &HRilCallReq::SetBarringPassword, info);
279 }
280
StartDtmf(int32_t serialId,const OHOS::HDI::Ril::V1_1::DtmfInfo & dtmfInfo)281 int32_t HRilCall::StartDtmf(int32_t serialId, const OHOS::HDI::Ril::V1_1::DtmfInfo &dtmfInfo)
282 {
283 CallDtmfInfo info = {};
284 info.callId = dtmfInfo.callId;
285 info.dtmfKey = StringToCString(dtmfInfo.dtmfKey);
286 return RequestVendor(serialId, HREQ_CALL_START_DTMF, callFuncs_, &HRilCallReq::StartDtmf, info);
287 }
288
SendDtmf(int32_t serialId,const OHOS::HDI::Ril::V1_1::DtmfInfo & dtmfInfo)289 int32_t HRilCall::SendDtmf(int32_t serialId, const OHOS::HDI::Ril::V1_1::DtmfInfo &dtmfInfo)
290 {
291 CallDtmfInfo info = {};
292 info.callId = dtmfInfo.callId;
293 info.dtmfKey = StringToCString(dtmfInfo.dtmfKey);
294 info.onLength = dtmfInfo.onLength;
295 info.offLength = dtmfInfo.offLength;
296 info.stringLength = dtmfInfo.stringLength;
297 return RequestVendor(serialId, HREQ_CALL_SEND_DTMF, callFuncs_, &HRilCallReq::SendDtmf, info);
298 }
299
StopDtmf(int32_t serialId,const OHOS::HDI::Ril::V1_1::DtmfInfo & dtmfInfo)300 int32_t HRilCall::StopDtmf(int32_t serialId, const OHOS::HDI::Ril::V1_1::DtmfInfo &dtmfInfo)
301 {
302 CallDtmfInfo info = {};
303 info.callId = dtmfInfo.callId;
304 info.dtmfKey = StringToCString(dtmfInfo.dtmfKey);
305 return RequestVendor(serialId, HREQ_CALL_STOP_DTMF, callFuncs_, &HRilCallReq::StopDtmf, info);
306 }
307
CloseUnFinishedUssd(int32_t serialId)308 int32_t HRilCall::CloseUnFinishedUssd(int32_t serialId)
309 {
310 return RequestVendor(serialId, HREQ_CALL_CLOSE_UNFINISHED_USSD, callFuncs_, &HRilCallReq::CloseUnFinishedUssd);
311 }
312
SetVonrSwitch(int32_t serialId,int32_t status)313 int32_t HRilCall::SetVonrSwitch(int32_t serialId, int32_t status)
314 {
315 return RequestVendor(serialId, HREQ_SET_VONR_SWITCH, callFuncs_, &HRilCallReq::SetVonrSwitch, status);
316 }
317
BuildICallList(HDI::Ril::V1_1::CallInfoList & callInfoList,const void * response,size_t responseLen)318 void HRilCall::BuildICallList(
319 HDI::Ril::V1_1::CallInfoList &callInfoList, const void *response, size_t responseLen)
320 {
321 size_t num = responseLen / sizeof(HRilCallInfo);
322 HDI::Ril::V1_1::CallInfo callInfo;
323 callInfoList.callSize = num;
324 for (size_t i = 0; i < num; i++) {
325 HRilCallInfo *curPtr = ((HRilCallInfo *)response + i);
326 if (curPtr != nullptr) {
327 callInfo.index = curPtr->index;
328 callInfo.dir = curPtr->dir;
329 callInfo.state = curPtr->state;
330 callInfo.mode = curPtr->mode;
331 callInfo.mpty = curPtr->mpty;
332 callInfo.voiceDomain = curPtr->voiceDomain;
333 callInfo.callType = curPtr->callType;
334 callInfo.number = (curPtr->number == nullptr) ? "" : curPtr->number;
335 callInfo.type = curPtr->type;
336 callInfo.alpha = (curPtr->alpha == nullptr) ? "" : curPtr->alpha;
337 callInfoList.calls.push_back(callInfo);
338 } else {
339 TELEPHONY_LOGE("BuildCallList: Invalid curPtr");
340 break;
341 }
342 }
343 }
344
GetCallListResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)345 int32_t HRilCall::GetCallListResponse(
346 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
347 {
348 if ((response == nullptr && responseLen != 0) || (responseLen % sizeof(HRilCallInfo)) != 0) {
349 TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen);
350 return HRIL_ERR_INVALID_PARAMETER;
351 }
352 HDI::Ril::V1_1::CallInfoList callList = {};
353 if (response != nullptr) {
354 BuildICallList(callList, response, responseLen);
355 }
356 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::GetCallListResponse, callList);
357 }
358
DialResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)359 int32_t HRilCall::DialResponse(
360 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
361 {
362 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::DialResponse);
363 }
364
HangupResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)365 int32_t HRilCall::HangupResponse(
366 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
367 {
368 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::HangupResponse);
369 }
370
RejectResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)371 int32_t HRilCall::RejectResponse(
372 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
373 {
374 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::RejectResponse);
375 }
376
AnswerResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)377 int32_t HRilCall::AnswerResponse(
378 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
379 {
380 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::AnswerResponse);
381 }
382
HoldCallResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)383 int32_t HRilCall::HoldCallResponse(
384 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
385 {
386 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::HoldCallResponse);
387 }
388
GetClipResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)389 int32_t HRilCall::GetClipResponse(
390 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
391 {
392 if ((response == nullptr && responseLen != 0) || (responseLen % sizeof(HRilGetClipResult)) != 0) {
393 TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen);
394 return HRIL_ERR_INVALID_PARAMETER;
395 }
396 HDI::Ril::V1_1::GetClipResult getClipResult = {};
397 getClipResult.result = static_cast<int32_t>(responseInfo.error);
398 if (response != nullptr) {
399 const HRilGetClipResult *pGetClip = static_cast<const HRilGetClipResult *>(response);
400 getClipResult.action = pGetClip->action;
401 getClipResult.clipStat = pGetClip->clipStat;
402 }
403 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::GetClipResponse, getClipResult);
404 }
405
SetClipResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)406 int32_t HRilCall::SetClipResponse(
407 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
408 {
409 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::SetClipResponse);
410 }
411
UnHoldCallResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)412 int32_t HRilCall::UnHoldCallResponse(
413 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
414 {
415 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::UnHoldCallResponse);
416 }
417
SwitchCallResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)418 int32_t HRilCall::SwitchCallResponse(
419 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
420 {
421 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::SwitchCallResponse);
422 }
423
CombineConferenceResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)424 int32_t HRilCall::CombineConferenceResponse(
425 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
426 {
427 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::CombineConferenceResponse);
428 }
429
SeparateConferenceResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)430 int32_t HRilCall::SeparateConferenceResponse(
431 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
432 {
433 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::SeparateConferenceResponse);
434 }
435
CallSupplementResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)436 int32_t HRilCall::CallSupplementResponse(
437 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
438 {
439 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::CallSupplementResponse);
440 }
441
GetCallWaitingResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)442 int32_t HRilCall::GetCallWaitingResponse(
443 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
444 {
445 if ((response == nullptr && responseLen != 0) || (responseLen % sizeof(HRilCallWaitResult)) != 0) {
446 TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen);
447 return HRIL_ERR_INVALID_PARAMETER;
448 }
449 HDI::Ril::V1_1::CallWaitResult callWaitResult = {};
450 callWaitResult.result = static_cast<int32_t>(responseInfo.error);
451 if (response != nullptr) {
452 const HRilCallWaitResult *result = static_cast<const HRilCallWaitResult *>(response);
453 callWaitResult.status = result->status;
454 callWaitResult.classCw = result->classCw;
455 }
456 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::GetCallWaitingResponse, callWaitResult);
457 }
458
SetCallWaitingResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)459 int32_t HRilCall::SetCallWaitingResponse(
460 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
461 {
462 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::SetCallWaitingResponse);
463 }
464
GetCallTransferInfoResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)465 int32_t HRilCall::GetCallTransferInfoResponse(
466 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
467 {
468 if ((response == nullptr && responseLen != 0) || (responseLen % sizeof(HRilCFQueryInfo)) != 0) {
469 TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen);
470 return HRIL_ERR_INVALID_PARAMETER;
471 }
472 HDI::Ril::V1_1::CallForwardQueryInfoList cFQueryList = {};
473 if (response != nullptr) {
474 BuildICallForwardQueryInfoList(cFQueryList, responseInfo, response, responseLen);
475 }
476 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::GetCallTransferInfoResponse, cFQueryList);
477 }
478
BuildICallForwardQueryInfoList(HDI::Ril::V1_1::CallForwardQueryInfoList & cFQueryList,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)479 void HRilCall::BuildICallForwardQueryInfoList(HDI::Ril::V1_1::CallForwardQueryInfoList &cFQueryList,
480 HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
481 {
482 size_t num = responseLen / sizeof(HRilCFQueryInfo);
483 HDI::Ril::V1_1::CallForwardQueryResult cFQueryResult;
484 cFQueryList.callSize = num;
485 for (size_t i = 0; i < num; i++) {
486 HRilCFQueryInfo *curPtr = ((HRilCFQueryInfo *)response + i);
487 if (curPtr != nullptr) {
488 cFQueryResult.result = static_cast<int32_t>(responseInfo.error);
489 cFQueryResult.serial = responseInfo.serial;
490 cFQueryResult.status = curPtr->status;
491 cFQueryResult.classx = curPtr->classx;
492 cFQueryResult.type = curPtr->type;
493 cFQueryResult.number = ((curPtr->number == nullptr) ? "" : curPtr->number);
494 cFQueryResult.reason = curPtr->reason;
495 cFQueryResult.time = curPtr->time;
496 cFQueryList.calls.push_back(cFQueryResult);
497 } else {
498 TELEPHONY_LOGE("BuildICallForwardQueryInfoList: Invalid curPtr");
499 break;
500 }
501 }
502 }
503
SetCallTransferInfoResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)504 int32_t HRilCall::SetCallTransferInfoResponse(
505 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
506 {
507 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::SetCallTransferInfoResponse);
508 }
509
GetClirResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)510 int32_t HRilCall::GetClirResponse(
511 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
512 {
513 if ((response == nullptr && responseLen != 0) || (responseLen % sizeof(HRilGetCallClirResult)) != 0) {
514 TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen);
515 return HRIL_ERR_INVALID_PARAMETER;
516 }
517 HDI::Ril::V1_1::GetClirResult getClirResult = {};
518 getClirResult.result = static_cast<int32_t>(responseInfo.error);
519 if (response != nullptr) {
520 const HRilGetCallClirResult *pGetClir = static_cast<const HRilGetCallClirResult *>(response);
521 getClirResult.action = pGetClir->action;
522 getClirResult.clirStat = pGetClir->clirStat;
523 }
524 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::GetClirResponse, getClirResult);
525 }
526
SetClirResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)527 int32_t HRilCall::SetClirResponse(
528 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
529 {
530 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::SetClirResponse);
531 }
532
GetCallRestrictionResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)533 int32_t HRilCall::GetCallRestrictionResponse(
534 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
535 {
536 if ((response == nullptr && responseLen != 0) || (responseLen % sizeof(HRilCallRestrictionResult)) != 0) {
537 TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen);
538 return HRIL_ERR_INVALID_PARAMETER;
539 }
540 HDI::Ril::V1_1::CallRestrictionResult resultT = {};
541 resultT.result = static_cast<int32_t>(responseInfo.error);
542 if (response != nullptr) {
543 const HRilCallRestrictionResult *result = static_cast<const HRilCallRestrictionResult *>(response);
544 resultT.status = result->status;
545 resultT.classCw = result->classCw;
546 }
547 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::GetCallRestrictionResponse, resultT);
548 }
549
SetCallRestrictionResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)550 int32_t HRilCall::SetCallRestrictionResponse(
551 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
552 {
553 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::SetCallRestrictionResponse);
554 }
555
SetBarringPasswordResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)556 int32_t HRilCall::SetBarringPasswordResponse(
557 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
558 {
559 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::SetBarringPasswordResponse);
560 }
561
StartDtmfResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)562 int32_t HRilCall::StartDtmfResponse(
563 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
564 {
565 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::StartDtmfResponse);
566 }
567
SendDtmfResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)568 int32_t HRilCall::SendDtmfResponse(
569 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
570 {
571 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::SendDtmfResponse);
572 }
573
StopDtmfResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)574 int32_t HRilCall::StopDtmfResponse(
575 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
576 {
577 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::StopDtmfResponse);
578 }
579
GetCallPreferenceModeResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)580 int32_t HRilCall::GetCallPreferenceModeResponse(
581 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
582 {
583 if ((response == nullptr && responseLen != 0) || (responseLen % sizeof(int32_t)) != 0) {
584 TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen);
585 return HRIL_ERR_INVALID_PARAMETER;
586 }
587 int32_t mode = 0;
588 if (response != nullptr) {
589 mode = *((int32_t *)response);
590 }
591 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::GetCallPreferenceModeResponse, mode);
592 }
593
SetCallPreferenceModeResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)594 int32_t HRilCall::SetCallPreferenceModeResponse(
595 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
596 {
597 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::SetCallPreferenceModeResponse);
598 }
599
SetUssdResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)600 int32_t HRilCall::SetUssdResponse(
601 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
602 {
603 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::SetUssdResponse);
604 }
605
GetMuteResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)606 int32_t HRilCall::GetMuteResponse(
607 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
608 {
609 if ((response == nullptr && responseLen != 0) || (responseLen % sizeof(int32_t)) != 0) {
610 TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen);
611 return HRIL_ERR_INVALID_PARAMETER;
612 }
613 int32_t mute = 0;
614 if (response != nullptr) {
615 mute = *((int32_t *)response);
616 }
617 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::GetMuteResponse, mute);
618 }
619
SetMuteResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)620 int32_t HRilCall::SetMuteResponse(
621 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
622 {
623 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::SetMuteResponse);
624 }
625
GetUssdResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)626 int32_t HRilCall::GetUssdResponse(
627 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
628 {
629 if ((response == nullptr && responseLen != 0) || (responseLen % sizeof(int32_t)) != 0) {
630 TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen);
631 return HRIL_ERR_INVALID_PARAMETER;
632 }
633 int32_t cusd = 0;
634 if (response != nullptr) {
635 cusd = *((int32_t *)response);
636 }
637 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::GetUssdResponse, cusd);
638 }
639
GetCallFailReasonResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)640 int32_t HRilCall::GetCallFailReasonResponse(
641 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
642 {
643 if ((response == nullptr && responseLen != 0) || (responseLen % sizeof(int32_t)) != 0) {
644 TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen);
645 return HRIL_ERR_INVALID_PARAMETER;
646 }
647 int32_t callFail = HRIL_ERR_CALL_CAUSE;
648 if (response != nullptr) {
649 callFail = *((int32_t *)response);
650 }
651 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::GetCallFailReasonResponse, callFail);
652 }
653
BuildIEmergencyCallList(HDI::Ril::V1_1::EmergencyInfoList & emergencyCallInfoList,const void * response,size_t responseLen)654 void HRilCall::BuildIEmergencyCallList(
655 HDI::Ril::V1_1::EmergencyInfoList &emergencyCallInfoList, const void *response, size_t responseLen)
656 {
657 size_t num = responseLen / sizeof(HRilEmergencyInfo);
658 HDI::Ril::V1_1::EmergencyCall callInfo;
659 emergencyCallInfoList.callSize = num;
660 for (size_t i = 0; i < num; i++) {
661 HRilEmergencyInfo *curPtr = ((HRilEmergencyInfo *)response + i);
662 if (curPtr != nullptr) {
663 callInfo.index = curPtr->index;
664 callInfo.total = curPtr->total;
665 callInfo.eccNum = (curPtr->eccNum == nullptr) ? "" : curPtr->eccNum;
666 callInfo.eccType = static_cast<OHOS::HDI::Ril::V1_1::EccType>(curPtr->category);
667 callInfo.simpresent = static_cast<OHOS::HDI::Ril::V1_1::SimpresentType>(curPtr->simpresent);
668 callInfo.mcc = (curPtr->mcc == nullptr) ? "" : curPtr->mcc;
669 callInfo.abnormalService = static_cast<OHOS::HDI::Ril::V1_1::AbnormalServiceType>(curPtr->abnormalService);
670 emergencyCallInfoList.calls.push_back(callInfo);
671 } else {
672 TELEPHONY_LOGE("BuildIEmergencyCallList: Invalid curPtr");
673 break;
674 }
675 }
676 }
677
GetEmergencyCallListResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)678 int32_t HRilCall::GetEmergencyCallListResponse(
679 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
680 {
681 if ((response == nullptr && responseLen != 0) || (responseLen % sizeof(HRilEmergencyInfo)) != 0) {
682 TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen);
683 return HRIL_ERR_INVALID_PARAMETER;
684 }
685 HDI::Ril::V1_1::EmergencyInfoList callList = {};
686 if (response != nullptr) {
687 BuildIEmergencyCallList(callList, response, responseLen);
688 }
689 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::GetEmergencyCallListResponse, callList);
690 }
691
SetEmergencyCallList(int32_t serialId,const OHOS::HDI::Ril::V1_1::EmergencyInfoList & emergencyInfoList)692 int32_t HRilCall::SetEmergencyCallList(
693 int32_t serialId, const OHOS::HDI::Ril::V1_1::EmergencyInfoList &emergencyInfoList)
694 {
695 auto size = emergencyInfoList.calls.size();
696 std::unique_ptr<HRilEmergencyInfo[]> emergencyInfoCalls = std::make_unique<HRilEmergencyInfo[]>(size);
697 CopyToHRilEmergencyInfoArray(emergencyInfoCalls.get(), emergencyInfoList.calls);
698 return RequestVendor(serialId, HREQ_CALL_SET_EMERGENCY_LIST, callFuncs_, &HRilCallReq::SetEmergencyCallList,
699 emergencyInfoCalls.get(), size);
700 }
701
CopyToHRilEmergencyInfoArray(HRilEmergencyInfo * emergencyInfoCalls,std::vector<HDI::Ril::V1_1::EmergencyCall> calls)702 void HRilCall::CopyToHRilEmergencyInfoArray(
703 HRilEmergencyInfo *emergencyInfoCalls, std::vector<HDI::Ril::V1_1::EmergencyCall> calls)
704 {
705 for (unsigned int i = 0; i < calls.size(); i++) {
706 auto call = calls.at(i);
707 emergencyInfoCalls[i].index = call.index;
708 emergencyInfoCalls[i].total = call.total;
709 char *eccNum = new char[call.eccNum.size() + 1];
710 if (strcpy_s(eccNum, call.eccNum.size() + 1, call.eccNum.c_str()) == EOK) {
711 emergencyInfoCalls[i].eccNum = eccNum;
712 } else {
713 delete[] eccNum;
714 eccNum = nullptr;
715 }
716 emergencyInfoCalls[i].category = static_cast<int32_t>(call.eccType);
717 emergencyInfoCalls[i].simpresent = call.simpresent;
718 char *mcc = new char[call.mcc.size() + 1];
719 if (strcpy_s(mcc, call.mcc.size() + 1, call.mcc.c_str()) == EOK) {
720 emergencyInfoCalls[i].mcc = mcc;
721 } else {
722 delete[] mcc;
723 mcc = nullptr;
724 }
725 emergencyInfoCalls[i].abnormalService = call.abnormalService;
726 }
727 }
728
SetEmergencyCallListResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)729 int32_t HRilCall::SetEmergencyCallListResponse(
730 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
731 {
732 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::SetEmergencyCallListResponse);
733 }
734
CloseUnFinishedUssdResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)735 int32_t HRilCall::CloseUnFinishedUssdResponse(
736 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
737 {
738 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::CloseUnFinishedUssdResponse);
739 }
740
SetVonrSwitchResponse(int32_t requestNum,HRilRadioResponseInfo & responseInfo,const void * response,size_t responseLen)741 int32_t HRilCall::SetVonrSwitchResponse(
742 int32_t requestNum, HRilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
743 {
744 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::SetVonrSwitchResponse);
745 }
746
CallStateUpdated(int32_t notifyType,const HRilErrNumber error,const void * response,size_t responseLen)747 int32_t HRilCall::CallStateUpdated(
748 int32_t notifyType, const HRilErrNumber error, const void *response, size_t responseLen)
749 {
750 return Notify(notifyType, error, &HDI::Ril::V1_1::IRilCallback::CallStateUpdated);
751 }
752
CallUssdNotice(int32_t notifyType,const HRilErrNumber error,const void * response,size_t responseLen)753 int32_t HRilCall::CallUssdNotice(
754 int32_t notifyType, const HRilErrNumber error, const void *response, size_t responseLen)
755 {
756 if ((response == nullptr) || (responseLen % sizeof(HRilUssdNoticeInfo)) != 0) {
757 TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen);
758 return HRIL_ERR_INVALID_PARAMETER;
759 }
760 HDI::Ril::V1_1::UssdNoticeInfo ussdNoticeInfo = {};
761 const HRilUssdNoticeInfo *hUssdNoticeInfo = reinterpret_cast<const HRilUssdNoticeInfo *>(response);
762 ussdNoticeInfo.type = hUssdNoticeInfo->m;
763 ussdNoticeInfo.message = hUssdNoticeInfo->str == nullptr ? "" : hUssdNoticeInfo->str;
764 return Notify(notifyType, error, &HDI::Ril::V1_1::IRilCallback::CallUssdNotice, ussdNoticeInfo);
765 }
766
CallSsNotice(int32_t notifyType,const HRilErrNumber error,const void * response,size_t responseLen)767 int32_t HRilCall::CallSsNotice(int32_t notifyType, const HRilErrNumber error, const void *response, size_t responseLen)
768 {
769 if ((response == nullptr) || (responseLen % sizeof(HRilSsNoticeInfo)) != 0) {
770 TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen);
771 return HRIL_ERR_INVALID_PARAMETER;
772 }
773 HDI::Ril::V1_1::SsNoticeInfo ssNoticeInfo = {};
774 const HRilSsNoticeInfo *hSsNoticeInfo = reinterpret_cast<const HRilSsNoticeInfo *>(response);
775 ssNoticeInfo.serviceType = hSsNoticeInfo->serviceType;
776 ssNoticeInfo.requestType = hSsNoticeInfo->requestType;
777 ssNoticeInfo.serviceClass = hSsNoticeInfo->serviceClass;
778 ssNoticeInfo.result = hSsNoticeInfo->result;
779 return Notify(notifyType, error, &HDI::Ril::V1_1::IRilCallback::CallSsNotice, ssNoticeInfo);
780 }
781
CallSrvccStatusNotice(int32_t notifyType,HRilErrNumber error,const void * response,size_t responseLen)782 int32_t HRilCall::CallSrvccStatusNotice(
783 int32_t notifyType, HRilErrNumber error, const void *response, size_t responseLen)
784 {
785 if ((response == nullptr) || (responseLen % sizeof(HRilCallSrvccStatus)) != 0) {
786 TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen);
787 return HRIL_ERR_INVALID_PARAMETER;
788 }
789 HDI::Ril::V1_1::SrvccStatus srvccStatus = {};
790 const HRilCallSrvccStatus *hSrvccStatus = reinterpret_cast<const HRilCallSrvccStatus *>(response);
791 srvccStatus.status = hSrvccStatus->status;
792 return Notify(notifyType, error, &HDI::Ril::V1_1::IRilCallback::CallSrvccStatusNotice, srvccStatus);
793 }
794
CallRingbackVoiceNotice(int32_t notifyType,HRilErrNumber error,const void * response,size_t responseLen)795 int32_t HRilCall::CallRingbackVoiceNotice(
796 int32_t notifyType, HRilErrNumber error, const void *response, size_t responseLen)
797 {
798 if ((response == nullptr) || (responseLen % sizeof(int32_t)) != 0) {
799 TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen);
800 return HRIL_ERR_INVALID_PARAMETER;
801 }
802 HDI::Ril::V1_1::RingbackVoice ringbackVoice = {};
803 const int32_t *ringbackVoiceFlag = reinterpret_cast<const int32_t *>(response);
804 ringbackVoice.status = *ringbackVoiceFlag;
805 return Notify(notifyType, error, &HDI::Ril::V1_1::IRilCallback::CallRingbackVoiceNotice, ringbackVoice);
806 }
807
CallEmergencyNotice(int32_t notifyType,const HRilErrNumber error,const void * response,size_t responseLen)808 int32_t HRilCall::CallEmergencyNotice(
809 int32_t notifyType, const HRilErrNumber error, const void *response, size_t responseLen)
810 {
811 if (response == nullptr || responseLen == 0 || (responseLen % sizeof(HRilEmergencyInfo)) != 0) {
812 TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen);
813 return HRIL_ERR_INVALID_PARAMETER;
814 }
815 HDI::Ril::V1_1::EmergencyInfoList callList = {};
816 BuildIEmergencyCallList(callList, response, responseLen);
817 return Notify(notifyType, error, &HDI::Ril::V1_1::IRilCallback::CallEmergencyNotice, callList);
818 }
819
CallRsrvccStatusNotify(int32_t notifyType,HRilErrNumber error,const void * response,size_t responseLen)820 int32_t HRilCall::CallRsrvccStatusNotify(
821 int32_t notifyType, HRilErrNumber error, const void *response, size_t responseLen)
822 {
823 return Notify(notifyType, error, &HDI::Ril::V1_1::IRilCallback::CallRsrvccStatusNotify);
824 }
825
RegisterCallFuncs(const HRilCallReq * callFuncs)826 void HRilCall::RegisterCallFuncs(const HRilCallReq *callFuncs)
827 {
828 callFuncs_ = callFuncs;
829 }
830 } // namespace Telephony
831 } // namespace OHOS
832