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