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