111fccf17Sopenharmony_ci/*
211fccf17Sopenharmony_ci * Copyright (C) 2021-2022 Huawei Device Co., Ltd.
311fccf17Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
411fccf17Sopenharmony_ci * you may not use this file except in compliance with the License.
511fccf17Sopenharmony_ci * You may obtain a copy of the License at
611fccf17Sopenharmony_ci *
711fccf17Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
811fccf17Sopenharmony_ci *
911fccf17Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1011fccf17Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1111fccf17Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1211fccf17Sopenharmony_ci * See the License for the specific language governing permissions and
1311fccf17Sopenharmony_ci * limitations under the License.
1411fccf17Sopenharmony_ci */
1511fccf17Sopenharmony_ci
1611fccf17Sopenharmony_ci#include "hril_call.h"
1711fccf17Sopenharmony_ci
1811fccf17Sopenharmony_ci#include "hril_notification.h"
1911fccf17Sopenharmony_ci#include "hril_request.h"
2011fccf17Sopenharmony_ci
2111fccf17Sopenharmony_cinamespace OHOS {
2211fccf17Sopenharmony_cinamespace Telephony {
2311fccf17Sopenharmony_ciHRilCall::HRilCall(int32_t slotId) : HRilBase(slotId)
2411fccf17Sopenharmony_ci{
2511fccf17Sopenharmony_ci    AddCallNotificationToMap();
2611fccf17Sopenharmony_ci    AddCallBasicResponseToMap();
2711fccf17Sopenharmony_ci    AddCallSupplementResponseToMap();
2811fccf17Sopenharmony_ci    AddCallAdditionalResponseToMap();
2911fccf17Sopenharmony_ci}
3011fccf17Sopenharmony_ci
3111fccf17Sopenharmony_ciHRilCall::~HRilCall()
3211fccf17Sopenharmony_ci{
3311fccf17Sopenharmony_ci    callFuncs_ = nullptr;
3411fccf17Sopenharmony_ci}
3511fccf17Sopenharmony_ci
3611fccf17Sopenharmony_cibool HRilCall::IsCallResponse(uint32_t code)
3711fccf17Sopenharmony_ci{
3811fccf17Sopenharmony_ci    return ((code >= HREQ_CALL_BASE) && (code < HREQ_SMS_BASE));
3911fccf17Sopenharmony_ci}
4011fccf17Sopenharmony_ci
4111fccf17Sopenharmony_cibool HRilCall::IsCallNotification(uint32_t code)
4211fccf17Sopenharmony_ci{
4311fccf17Sopenharmony_ci    return ((code >= HNOTI_CALL_BASE) && (code < HNOTI_SMS_BASE));
4411fccf17Sopenharmony_ci}
4511fccf17Sopenharmony_ci
4611fccf17Sopenharmony_cibool HRilCall::IsCallRespOrNotify(uint32_t code)
4711fccf17Sopenharmony_ci{
4811fccf17Sopenharmony_ci    return IsCallResponse(code) || IsCallNotification(code);
4911fccf17Sopenharmony_ci}
5011fccf17Sopenharmony_ci
5111fccf17Sopenharmony_civoid HRilCall::AddCallNotificationToMap()
5211fccf17Sopenharmony_ci{
5311fccf17Sopenharmony_ci    // Notification
5411fccf17Sopenharmony_ci    notiMemberFuncMap_[HNOTI_CALL_STATE_UPDATED] =
5511fccf17Sopenharmony_ci        [this](int32_t notifyType, HRilErrNumber error, const void *response,
5611fccf17Sopenharmony_ci        size_t responseLen) { return CallStateUpdated(notifyType, error, response, responseLen); };
5711fccf17Sopenharmony_ci    notiMemberFuncMap_[HNOTI_CALL_USSD_REPORT] =
5811fccf17Sopenharmony_ci        [this](int32_t notifyType, HRilErrNumber error, const void *response,
5911fccf17Sopenharmony_ci        size_t responseLen) { return CallUssdNotice(notifyType, error, response, responseLen); };
6011fccf17Sopenharmony_ci    notiMemberFuncMap_[HNOTI_CALL_SRVCC_STATUS_REPORT] =
6111fccf17Sopenharmony_ci        [this](int32_t notifyType, HRilErrNumber error, const void *response,
6211fccf17Sopenharmony_ci        size_t responseLen) { return CallSrvccStatusNotice(notifyType, error, response, responseLen); };
6311fccf17Sopenharmony_ci    notiMemberFuncMap_[HNOTI_CALL_RINGBACK_VOICE_REPORT] =
6411fccf17Sopenharmony_ci        [this](int32_t notifyType, HRilErrNumber error, const void *response,
6511fccf17Sopenharmony_ci        size_t responseLen) { return CallRingbackVoiceNotice(notifyType, error, response, responseLen); };
6611fccf17Sopenharmony_ci    notiMemberFuncMap_[HNOTI_CALL_EMERGENCY_NUMBER_REPORT] =
6711fccf17Sopenharmony_ci        [this](int32_t notifyType, HRilErrNumber error, const void *response,
6811fccf17Sopenharmony_ci        size_t responseLen) { return CallEmergencyNotice(notifyType, error, response, responseLen); };
6911fccf17Sopenharmony_ci    notiMemberFuncMap_[HNOTI_CALL_SS_REPORT] =
7011fccf17Sopenharmony_ci        [this](int32_t notifyType, HRilErrNumber error, const void *response,
7111fccf17Sopenharmony_ci        size_t responseLen) { return CallSsNotice(notifyType, error, response, responseLen); };
7211fccf17Sopenharmony_ci    notiMemberFuncMap_[HNOTI_CALL_RSRVCC_STATUS_REPORT] =
7311fccf17Sopenharmony_ci        [this](int32_t notifyType, HRilErrNumber error, const void *response,
7411fccf17Sopenharmony_ci        size_t responseLen) { return CallRsrvccStatusNotify(notifyType, error, response, responseLen); };
7511fccf17Sopenharmony_ci}
7611fccf17Sopenharmony_ci
7711fccf17Sopenharmony_civoid HRilCall::AddCallBasicResponseToMap()
7811fccf17Sopenharmony_ci{
7911fccf17Sopenharmony_ci    // Response
8011fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_GET_CALL_LIST] =
8111fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
8211fccf17Sopenharmony_ci        size_t responseLen) { return GetCallListResponse(requestNum, responseInfo, response, responseLen); };
8311fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_DIAL] =
8411fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
8511fccf17Sopenharmony_ci        size_t responseLen) { return DialResponse(requestNum, responseInfo, response, responseLen); };
8611fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_HANGUP] =
8711fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
8811fccf17Sopenharmony_ci        size_t responseLen) { return HangupResponse(requestNum, responseInfo, response, responseLen); };
8911fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_REJECT] =
9011fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
9111fccf17Sopenharmony_ci        size_t responseLen) { return RejectResponse(requestNum, responseInfo, response, responseLen); };
9211fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_ANSWER] =
9311fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
9411fccf17Sopenharmony_ci        size_t responseLen) { return AnswerResponse(requestNum, responseInfo, response, responseLen); };
9511fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_HOLD_CALL] =
9611fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
9711fccf17Sopenharmony_ci        size_t responseLen) { return HoldCallResponse(requestNum, responseInfo, response, responseLen); };
9811fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_UNHOLD_CALL] =
9911fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
10011fccf17Sopenharmony_ci        size_t responseLen) { return UnHoldCallResponse(requestNum, responseInfo, response, responseLen); };
10111fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_SWITCH_CALL] =
10211fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
10311fccf17Sopenharmony_ci        size_t responseLen) { return SwitchCallResponse(requestNum, responseInfo, response, responseLen); };
10411fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_COMBINE_CONFERENCE] =
10511fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
10611fccf17Sopenharmony_ci        size_t responseLen) { return CombineConferenceResponse(requestNum, responseInfo, response, responseLen); };
10711fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_SEPARATE_CONFERENCE] =
10811fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
10911fccf17Sopenharmony_ci        size_t responseLen) { return SeparateConferenceResponse(requestNum, responseInfo, response, responseLen); };
11011fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_GET_EMERGENCY_LIST] =
11111fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
11211fccf17Sopenharmony_ci        size_t responseLen) { return GetEmergencyCallListResponse(requestNum, responseInfo, response, responseLen); };
11311fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_SET_EMERGENCY_LIST] =
11411fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
11511fccf17Sopenharmony_ci        size_t responseLen) { return SetEmergencyCallListResponse(requestNum, responseInfo, response, responseLen); };
11611fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_GET_FAIL_REASON] =
11711fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
11811fccf17Sopenharmony_ci        size_t responseLen) { return GetCallFailReasonResponse(requestNum, responseInfo, response, responseLen); };
11911fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_SET_BARRING_PASSWORD] =
12011fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
12111fccf17Sopenharmony_ci        size_t responseLen) { return SetBarringPasswordResponse(requestNum, responseInfo, response, responseLen); };
12211fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_CLOSE_UNFINISHED_USSD] =
12311fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
12411fccf17Sopenharmony_ci        size_t responseLen) { return CloseUnFinishedUssdResponse(requestNum, responseInfo, response, responseLen); };
12511fccf17Sopenharmony_ci}
12611fccf17Sopenharmony_ci
12711fccf17Sopenharmony_civoid HRilCall::AddCallSupplementResponseToMap()
12811fccf17Sopenharmony_ci{
12911fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_GET_CLIP] =
13011fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
13111fccf17Sopenharmony_ci        size_t responseLen) { return GetClipResponse(requestNum, responseInfo, response, responseLen); };
13211fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_SET_CLIP] =
13311fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
13411fccf17Sopenharmony_ci        size_t responseLen) { return SetClipResponse(requestNum, responseInfo, response, responseLen); };
13511fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_CALL_SUPPLEMENT] =
13611fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
13711fccf17Sopenharmony_ci        size_t responseLen) { return CallSupplementResponse(requestNum, responseInfo, response, responseLen); };
13811fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_GET_CALL_WAITING] =
13911fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
14011fccf17Sopenharmony_ci        size_t responseLen) { return GetCallWaitingResponse(requestNum, responseInfo, response, responseLen); };
14111fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_SET_CALL_WAITING] =
14211fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
14311fccf17Sopenharmony_ci        size_t responseLen) { return SetCallWaitingResponse(requestNum, responseInfo, response, responseLen); };
14411fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_GET_CALL_TRANSFER_INFO] =
14511fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
14611fccf17Sopenharmony_ci        size_t responseLen) { return GetCallTransferInfoResponse(requestNum, responseInfo, response, responseLen); };
14711fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_SET_CALL_TRANSFER_INFO] =
14811fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
14911fccf17Sopenharmony_ci        size_t responseLen) { return SetCallTransferInfoResponse(requestNum, responseInfo, response, responseLen); };
15011fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_GET_CALL_RESTRICTION] =
15111fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
15211fccf17Sopenharmony_ci        size_t responseLen) { return GetCallRestrictionResponse(requestNum, responseInfo, response, responseLen); };
15311fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_SET_CALL_RESTRICTION] =
15411fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
15511fccf17Sopenharmony_ci        size_t responseLen) { return SetCallRestrictionResponse(requestNum, responseInfo, response, responseLen); };
15611fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_GET_CLIR] =
15711fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
15811fccf17Sopenharmony_ci        size_t responseLen) { return GetClirResponse(requestNum, responseInfo, response, responseLen); };
15911fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_SET_CLIR] =
16011fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
16111fccf17Sopenharmony_ci        size_t responseLen) { return SetClirResponse(requestNum, responseInfo, response, responseLen); };
16211fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_GET_CALL_PREFERENCE] =
16311fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
16411fccf17Sopenharmony_ci        size_t responseLen) { return GetCallPreferenceModeResponse(requestNum, responseInfo, response, responseLen); };
16511fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_SET_CALL_PREFERENCE] =
16611fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
16711fccf17Sopenharmony_ci        size_t responseLen) { return SetCallPreferenceModeResponse(requestNum, responseInfo, response, responseLen); };
16811fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_SET_USSD] =
16911fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
17011fccf17Sopenharmony_ci        size_t responseLen) { return SetUssdResponse(requestNum, responseInfo, response, responseLen); };
17111fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_GET_USSD] =
17211fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
17311fccf17Sopenharmony_ci        size_t responseLen) { return GetUssdResponse(requestNum, responseInfo, response, responseLen); };
17411fccf17Sopenharmony_ci}
17511fccf17Sopenharmony_ci
17611fccf17Sopenharmony_civoid HRilCall::AddCallAdditionalResponseToMap()
17711fccf17Sopenharmony_ci{
17811fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_START_DTMF] =
17911fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
18011fccf17Sopenharmony_ci        size_t responseLen) { return StartDtmfResponse(requestNum, responseInfo, response, responseLen); };
18111fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_SEND_DTMF] =
18211fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
18311fccf17Sopenharmony_ci        size_t responseLen) { return SendDtmfResponse(requestNum, responseInfo, response, responseLen); };
18411fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_STOP_DTMF] =
18511fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
18611fccf17Sopenharmony_ci        size_t responseLen) { return StopDtmfResponse(requestNum, responseInfo, response, responseLen); };
18711fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_SET_MUTE] =
18811fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
18911fccf17Sopenharmony_ci        size_t responseLen) { return SetMuteResponse(requestNum, responseInfo, response, responseLen); };
19011fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_CALL_GET_MUTE] =
19111fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
19211fccf17Sopenharmony_ci        size_t responseLen) { return GetMuteResponse(requestNum, responseInfo, response, responseLen); };
19311fccf17Sopenharmony_ci    respMemberFuncMap_[HREQ_SET_VONR_SWITCH] =
19411fccf17Sopenharmony_ci        [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response,
19511fccf17Sopenharmony_ci        size_t responseLen) { return SetVonrSwitchResponse(requestNum, responseInfo, response, responseLen); };
19611fccf17Sopenharmony_ci}
19711fccf17Sopenharmony_ci
19811fccf17Sopenharmony_ciint32_t HRilCall::GetCallList(int32_t serialId)
19911fccf17Sopenharmony_ci{
20011fccf17Sopenharmony_ci    return RequestVendor(serialId, HREQ_CALL_GET_CALL_LIST, callFuncs_, &HRilCallReq::GetCallList);
20111fccf17Sopenharmony_ci}
20211fccf17Sopenharmony_ci
20311fccf17Sopenharmony_ciint32_t HRilCall::Dial(int32_t serialId, const OHOS::HDI::Ril::V1_1::DialInfo &dialInfo)
20411fccf17Sopenharmony_ci{
20511fccf17Sopenharmony_ci    HRilDial dial = {};
20611fccf17Sopenharmony_ci    dial.address = StringToCString(dialInfo.address);
20711fccf17Sopenharmony_ci    dial.clir = dialInfo.clir;
20811fccf17Sopenharmony_ci    return RequestVendor(serialId, HREQ_CALL_DIAL, callFuncs_, &HRilCallReq::Dial, &dial, sizeof(HRilDial));
20911fccf17Sopenharmony_ci}
21011fccf17Sopenharmony_ci
21111fccf17Sopenharmony_ciint32_t HRilCall::Hangup(int32_t serialId, int32_t gsmIndex)
21211fccf17Sopenharmony_ci{
21311fccf17Sopenharmony_ci    uint32_t data = gsmIndex;
21411fccf17Sopenharmony_ci    return RequestVendor(serialId, HREQ_CALL_HANGUP, callFuncs_, &HRilCallReq::Hangup, &data, sizeof(uint32_t));
21511fccf17Sopenharmony_ci}
21611fccf17Sopenharmony_ci
21711fccf17Sopenharmony_ciint32_t HRilCall::Reject(int32_t serialId)
21811fccf17Sopenharmony_ci{
21911fccf17Sopenharmony_ci    return RequestVendor(serialId, HREQ_CALL_REJECT, callFuncs_, &HRilCallReq::Reject);
22011fccf17Sopenharmony_ci}
22111fccf17Sopenharmony_ci
22211fccf17Sopenharmony_ciint32_t HRilCall::Answer(int32_t serialId)
22311fccf17Sopenharmony_ci{
22411fccf17Sopenharmony_ci    return RequestVendor(serialId, HREQ_CALL_ANSWER, callFuncs_, &HRilCallReq::Answer);
22511fccf17Sopenharmony_ci}
22611fccf17Sopenharmony_ci
22711fccf17Sopenharmony_ciint32_t HRilCall::HoldCall(int32_t serialId)
22811fccf17Sopenharmony_ci{
22911fccf17Sopenharmony_ci    return RequestVendor(serialId, HREQ_CALL_HOLD_CALL, callFuncs_, &HRilCallReq::HoldCall);
23011fccf17Sopenharmony_ci}
23111fccf17Sopenharmony_ci
23211fccf17Sopenharmony_ciint32_t HRilCall::UnHoldCall(int32_t serialId)
23311fccf17Sopenharmony_ci{
23411fccf17Sopenharmony_ci    return RequestVendor(serialId, HREQ_CALL_UNHOLD_CALL, callFuncs_, &HRilCallReq::UnHoldCall);
23511fccf17Sopenharmony_ci}
23611fccf17Sopenharmony_ci
23711fccf17Sopenharmony_ciint32_t HRilCall::SwitchCall(int32_t serialId)
23811fccf17Sopenharmony_ci{
23911fccf17Sopenharmony_ci    return RequestVendor(serialId, HREQ_CALL_SWITCH_CALL, callFuncs_, &HRilCallReq::SwitchCall);
24011fccf17Sopenharmony_ci}
24111fccf17Sopenharmony_ci
24211fccf17Sopenharmony_ciint32_t HRilCall::CombineConference(int32_t serialId, int32_t callType)
24311fccf17Sopenharmony_ci{
24411fccf17Sopenharmony_ci    return RequestVendor(
24511fccf17Sopenharmony_ci        serialId, HREQ_CALL_COMBINE_CONFERENCE, callFuncs_, &HRilCallReq::CombineConference, callType);
24611fccf17Sopenharmony_ci}
24711fccf17Sopenharmony_ci
24811fccf17Sopenharmony_ciint32_t HRilCall::SeparateConference(int32_t serialId, int32_t callIndex, int32_t callType)
24911fccf17Sopenharmony_ci{
25011fccf17Sopenharmony_ci    return RequestVendor(
25111fccf17Sopenharmony_ci        serialId, HREQ_CALL_SEPARATE_CONFERENCE, callFuncs_, &HRilCallReq::SeparateConference, callIndex, callType);
25211fccf17Sopenharmony_ci}
25311fccf17Sopenharmony_ci
25411fccf17Sopenharmony_ciint32_t HRilCall::CallSupplement(int32_t serialId, int32_t type)
25511fccf17Sopenharmony_ci{
25611fccf17Sopenharmony_ci    return RequestVendor(serialId, HREQ_CALL_CALL_SUPPLEMENT, callFuncs_, &HRilCallReq::CallSupplement, type);
25711fccf17Sopenharmony_ci}
25811fccf17Sopenharmony_ci
25911fccf17Sopenharmony_ciint32_t HRilCall::GetClip(int32_t serialId)
26011fccf17Sopenharmony_ci{
26111fccf17Sopenharmony_ci    return RequestVendor(serialId, HREQ_CALL_GET_CLIP, callFuncs_, &HRilCallReq::GetClip);
26211fccf17Sopenharmony_ci}
26311fccf17Sopenharmony_ci
26411fccf17Sopenharmony_ciint32_t HRilCall::SetClip(int32_t serialId, int32_t action)
26511fccf17Sopenharmony_ci{
26611fccf17Sopenharmony_ci    return RequestVendor(serialId, HREQ_CALL_SET_CLIP, callFuncs_, &HRilCallReq::SetClip, action);
26711fccf17Sopenharmony_ci}
26811fccf17Sopenharmony_ci
26911fccf17Sopenharmony_ciint32_t HRilCall::GetClir(int32_t serialId)
27011fccf17Sopenharmony_ci{
27111fccf17Sopenharmony_ci    return RequestVendor(serialId, HREQ_CALL_GET_CLIR, callFuncs_, &HRilCallReq::GetClir);
27211fccf17Sopenharmony_ci}
27311fccf17Sopenharmony_ci
27411fccf17Sopenharmony_ciint32_t HRilCall::SetClir(int32_t serialId, int32_t action)
27511fccf17Sopenharmony_ci{
27611fccf17Sopenharmony_ci    return RequestVendor(serialId, HREQ_CALL_SET_CLIR, callFuncs_, &HRilCallReq::SetClir, action);
27711fccf17Sopenharmony_ci}
27811fccf17Sopenharmony_ci
27911fccf17Sopenharmony_ciint32_t HRilCall::GetCallRestriction(int32_t serialId, const std::string &fac)
28011fccf17Sopenharmony_ci{
28111fccf17Sopenharmony_ci    return RequestVendor(
28211fccf17Sopenharmony_ci        serialId, HREQ_CALL_GET_CALL_RESTRICTION, callFuncs_, &HRilCallReq::GetCallRestriction, StringToCString(fac));
28311fccf17Sopenharmony_ci}
28411fccf17Sopenharmony_ci
28511fccf17Sopenharmony_ciint32_t HRilCall::SetCallRestriction(
28611fccf17Sopenharmony_ci    int32_t serialId, const OHOS::HDI::Ril::V1_1::CallRestrictionInfo &callRestrictionInfo)
28711fccf17Sopenharmony_ci{
28811fccf17Sopenharmony_ci    CallRestrictionInfo info = {};
28911fccf17Sopenharmony_ci    info.fac = StringToCString(callRestrictionInfo.fac);
29011fccf17Sopenharmony_ci    info.mode = callRestrictionInfo.mode;
29111fccf17Sopenharmony_ci    info.password = StringToCString(callRestrictionInfo.password);
29211fccf17Sopenharmony_ci    return RequestVendor(serialId, HREQ_CALL_SET_CALL_RESTRICTION, callFuncs_, &HRilCallReq::SetCallRestriction, info);
29311fccf17Sopenharmony_ci}
29411fccf17Sopenharmony_ci
29511fccf17Sopenharmony_ciint32_t HRilCall::GetCallWaiting(int32_t serialId)
29611fccf17Sopenharmony_ci{
29711fccf17Sopenharmony_ci    return RequestVendor(serialId, HREQ_CALL_GET_CALL_WAITING, callFuncs_, &HRilCallReq::GetCallWaiting);
29811fccf17Sopenharmony_ci}
29911fccf17Sopenharmony_ci
30011fccf17Sopenharmony_ciint32_t HRilCall::SetCallWaiting(int32_t serialId, int32_t activate)
30111fccf17Sopenharmony_ci{
30211fccf17Sopenharmony_ci    return RequestVendor(serialId, HREQ_CALL_SET_CALL_WAITING, callFuncs_, &HRilCallReq::SetCallWaiting, activate);
30311fccf17Sopenharmony_ci}
30411fccf17Sopenharmony_ci
30511fccf17Sopenharmony_ciint32_t HRilCall::GetCallTransferInfo(int32_t serialId, int32_t reason)
30611fccf17Sopenharmony_ci{
30711fccf17Sopenharmony_ci    return RequestVendor(
30811fccf17Sopenharmony_ci        serialId, HREQ_CALL_GET_CALL_TRANSFER_INFO, callFuncs_, &HRilCallReq::GetCallTransferInfo, reason);
30911fccf17Sopenharmony_ci}
31011fccf17Sopenharmony_ci
31111fccf17Sopenharmony_ciint32_t HRilCall::SetCallTransferInfo(
31211fccf17Sopenharmony_ci    int32_t serialId, const OHOS::HDI::Ril::V1_1::CallForwardSetInfo &callForwardSetInfo)
31311fccf17Sopenharmony_ci{
31411fccf17Sopenharmony_ci    HRilCFInfo cFInfo = {};
31511fccf17Sopenharmony_ci    cFInfo.number = StringToCString(callForwardSetInfo.number);
31611fccf17Sopenharmony_ci    cFInfo.reason = callForwardSetInfo.reason;
31711fccf17Sopenharmony_ci    cFInfo.mode = callForwardSetInfo.mode;
31811fccf17Sopenharmony_ci    cFInfo.classx = callForwardSetInfo.classx;
31911fccf17Sopenharmony_ci    return RequestVendor(
32011fccf17Sopenharmony_ci        serialId, HREQ_CALL_SET_CALL_TRANSFER_INFO, callFuncs_, &HRilCallReq::SetCallTransferInfo, cFInfo);
32111fccf17Sopenharmony_ci}
32211fccf17Sopenharmony_ci
32311fccf17Sopenharmony_ciint32_t HRilCall::GetCallPreferenceMode(int32_t serialId)
32411fccf17Sopenharmony_ci{
32511fccf17Sopenharmony_ci    return RequestVendor(
32611fccf17Sopenharmony_ci        serialId, HREQ_CALL_GET_CALL_PREFERENCE, callFuncs_, &HRilCallReq::GetCallPreferenceMode);
32711fccf17Sopenharmony_ci}
32811fccf17Sopenharmony_ci
32911fccf17Sopenharmony_ciint32_t HRilCall::SetCallPreferenceMode(int32_t serialId, int32_t mode)
33011fccf17Sopenharmony_ci{
33111fccf17Sopenharmony_ci    return RequestVendor(
33211fccf17Sopenharmony_ci        serialId, HREQ_CALL_SET_CALL_PREFERENCE, callFuncs_, &HRilCallReq::SetCallPreferenceMode, mode);
33311fccf17Sopenharmony_ci}
33411fccf17Sopenharmony_ci
33511fccf17Sopenharmony_ciint32_t HRilCall::SetUssd(int32_t serialId, const std::string &str)
33611fccf17Sopenharmony_ci{
33711fccf17Sopenharmony_ci    return RequestVendor(
33811fccf17Sopenharmony_ci        serialId, HREQ_CALL_SET_USSD, callFuncs_, &HRilCallReq::SetUssd, StringToCString(str));
33911fccf17Sopenharmony_ci}
34011fccf17Sopenharmony_ci
34111fccf17Sopenharmony_ciint32_t HRilCall::GetUssd(int32_t serialId)
34211fccf17Sopenharmony_ci{
34311fccf17Sopenharmony_ci    return RequestVendor(serialId, HREQ_CALL_GET_USSD, callFuncs_, &HRilCallReq::GetUssd);
34411fccf17Sopenharmony_ci}
34511fccf17Sopenharmony_ci
34611fccf17Sopenharmony_ciint32_t HRilCall::SetMute(int32_t serialId, int32_t mute)
34711fccf17Sopenharmony_ci{
34811fccf17Sopenharmony_ci    return RequestVendor(serialId, HREQ_CALL_SET_MUTE, callFuncs_, &HRilCallReq::SetMute, mute);
34911fccf17Sopenharmony_ci}
35011fccf17Sopenharmony_ci
35111fccf17Sopenharmony_ciint32_t HRilCall::GetMute(int32_t serialId)
35211fccf17Sopenharmony_ci{
35311fccf17Sopenharmony_ci    return RequestVendor(serialId, HREQ_CALL_GET_MUTE, callFuncs_, &HRilCallReq::GetMute);
35411fccf17Sopenharmony_ci}
35511fccf17Sopenharmony_ci
35611fccf17Sopenharmony_ciint32_t HRilCall::GetCallFailReason(int32_t serialId)
35711fccf17Sopenharmony_ci{
35811fccf17Sopenharmony_ci    return RequestVendor(serialId, HREQ_CALL_GET_FAIL_REASON, callFuncs_, &HRilCallReq::GetCallFailReason);
35911fccf17Sopenharmony_ci}
36011fccf17Sopenharmony_ci
36111fccf17Sopenharmony_ciint32_t HRilCall::GetEmergencyCallList(int32_t serialId)
36211fccf17Sopenharmony_ci{
36311fccf17Sopenharmony_ci    return RequestVendor(serialId, HREQ_CALL_GET_EMERGENCY_LIST, callFuncs_, &HRilCallReq::GetEmergencyCallList);
36411fccf17Sopenharmony_ci}
36511fccf17Sopenharmony_ci
36611fccf17Sopenharmony_ciint32_t HRilCall::SetBarringPassword(int32_t serialId, const OHOS::HDI::Ril::V1_1::SetBarringInfo &setBarringInfo)
36711fccf17Sopenharmony_ci{
36811fccf17Sopenharmony_ci    HRilSetBarringInfo info = {};
36911fccf17Sopenharmony_ci    info.fac = StringToCString(setBarringInfo.fac);
37011fccf17Sopenharmony_ci    info.oldPassword = StringToCString(setBarringInfo.oldPassword);
37111fccf17Sopenharmony_ci    info.newPassword = StringToCString(setBarringInfo.newPassword);
37211fccf17Sopenharmony_ci    return RequestVendor(
37311fccf17Sopenharmony_ci        serialId, HREQ_CALL_SET_BARRING_PASSWORD, callFuncs_, &HRilCallReq::SetBarringPassword, info);
37411fccf17Sopenharmony_ci}
37511fccf17Sopenharmony_ci
37611fccf17Sopenharmony_ciint32_t HRilCall::StartDtmf(int32_t serialId, const OHOS::HDI::Ril::V1_1::DtmfInfo &dtmfInfo)
37711fccf17Sopenharmony_ci{
37811fccf17Sopenharmony_ci    CallDtmfInfo info = {};
37911fccf17Sopenharmony_ci    info.callId = dtmfInfo.callId;
38011fccf17Sopenharmony_ci    info.dtmfKey = StringToCString(dtmfInfo.dtmfKey);
38111fccf17Sopenharmony_ci    return RequestVendor(serialId, HREQ_CALL_START_DTMF, callFuncs_, &HRilCallReq::StartDtmf, info);
38211fccf17Sopenharmony_ci}
38311fccf17Sopenharmony_ci
38411fccf17Sopenharmony_ciint32_t HRilCall::SendDtmf(int32_t serialId, const OHOS::HDI::Ril::V1_1::DtmfInfo &dtmfInfo)
38511fccf17Sopenharmony_ci{
38611fccf17Sopenharmony_ci    CallDtmfInfo info = {};
38711fccf17Sopenharmony_ci    info.callId = dtmfInfo.callId;
38811fccf17Sopenharmony_ci    info.dtmfKey = StringToCString(dtmfInfo.dtmfKey);
38911fccf17Sopenharmony_ci    info.onLength = dtmfInfo.onLength;
39011fccf17Sopenharmony_ci    info.offLength = dtmfInfo.offLength;
39111fccf17Sopenharmony_ci    info.stringLength = dtmfInfo.stringLength;
39211fccf17Sopenharmony_ci    return RequestVendor(serialId, HREQ_CALL_SEND_DTMF, callFuncs_, &HRilCallReq::SendDtmf, info);
39311fccf17Sopenharmony_ci}
39411fccf17Sopenharmony_ci
39511fccf17Sopenharmony_ciint32_t HRilCall::StopDtmf(int32_t serialId, const OHOS::HDI::Ril::V1_1::DtmfInfo &dtmfInfo)
39611fccf17Sopenharmony_ci{
39711fccf17Sopenharmony_ci    CallDtmfInfo info = {};
39811fccf17Sopenharmony_ci    info.callId = dtmfInfo.callId;
39911fccf17Sopenharmony_ci    info.dtmfKey = StringToCString(dtmfInfo.dtmfKey);
40011fccf17Sopenharmony_ci    return RequestVendor(serialId, HREQ_CALL_STOP_DTMF, callFuncs_, &HRilCallReq::StopDtmf, info);
40111fccf17Sopenharmony_ci}
40211fccf17Sopenharmony_ci
40311fccf17Sopenharmony_ciint32_t HRilCall::CloseUnFinishedUssd(int32_t serialId)
40411fccf17Sopenharmony_ci{
40511fccf17Sopenharmony_ci    return RequestVendor(serialId, HREQ_CALL_CLOSE_UNFINISHED_USSD, callFuncs_, &HRilCallReq::CloseUnFinishedUssd);
40611fccf17Sopenharmony_ci}
40711fccf17Sopenharmony_ci
40811fccf17Sopenharmony_ciint32_t HRilCall::SetVonrSwitch(int32_t serialId, int32_t status)
40911fccf17Sopenharmony_ci{
41011fccf17Sopenharmony_ci    return RequestVendor(serialId, HREQ_SET_VONR_SWITCH, callFuncs_, &HRilCallReq::SetVonrSwitch, status);
41111fccf17Sopenharmony_ci}
41211fccf17Sopenharmony_ci
41311fccf17Sopenharmony_civoid HRilCall::BuildICallList(
41411fccf17Sopenharmony_ci    HDI::Ril::V1_1::CallInfoList &callInfoList, const void *response, size_t responseLen)
41511fccf17Sopenharmony_ci{
41611fccf17Sopenharmony_ci    size_t num = responseLen / sizeof(HRilCallInfo);
41711fccf17Sopenharmony_ci    HDI::Ril::V1_1::CallInfo callInfo;
41811fccf17Sopenharmony_ci    callInfoList.callSize = num;
41911fccf17Sopenharmony_ci    for (size_t i = 0; i < num; i++) {
42011fccf17Sopenharmony_ci        HRilCallInfo *curPtr = ((HRilCallInfo *)response + i);
42111fccf17Sopenharmony_ci        if (curPtr != nullptr) {
42211fccf17Sopenharmony_ci            callInfo.index = curPtr->index;
42311fccf17Sopenharmony_ci            callInfo.dir = curPtr->dir;
42411fccf17Sopenharmony_ci            callInfo.state = curPtr->state;
42511fccf17Sopenharmony_ci            callInfo.mode = curPtr->mode;
42611fccf17Sopenharmony_ci            callInfo.mpty = curPtr->mpty;
42711fccf17Sopenharmony_ci            callInfo.voiceDomain = curPtr->voiceDomain;
42811fccf17Sopenharmony_ci            callInfo.callType = curPtr->callType;
42911fccf17Sopenharmony_ci            callInfo.number = (curPtr->number == nullptr) ? "" : curPtr->number;
43011fccf17Sopenharmony_ci            callInfo.type = curPtr->type;
43111fccf17Sopenharmony_ci            callInfo.alpha = (curPtr->alpha == nullptr) ? "" : curPtr->alpha;
43211fccf17Sopenharmony_ci            callInfoList.calls.push_back(callInfo);
43311fccf17Sopenharmony_ci        } else {
43411fccf17Sopenharmony_ci            TELEPHONY_LOGE("BuildCallList: Invalid curPtr");
43511fccf17Sopenharmony_ci            break;
43611fccf17Sopenharmony_ci        }
43711fccf17Sopenharmony_ci    }
43811fccf17Sopenharmony_ci}
43911fccf17Sopenharmony_ci
44011fccf17Sopenharmony_ciint32_t HRilCall::GetCallListResponse(
44111fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
44211fccf17Sopenharmony_ci{
44311fccf17Sopenharmony_ci    if ((response == nullptr && responseLen != 0) || (responseLen % sizeof(HRilCallInfo)) != 0) {
44411fccf17Sopenharmony_ci        TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen);
44511fccf17Sopenharmony_ci        return HRIL_ERR_INVALID_PARAMETER;
44611fccf17Sopenharmony_ci    }
44711fccf17Sopenharmony_ci    HDI::Ril::V1_1::CallInfoList callList = {};
44811fccf17Sopenharmony_ci    if (response != nullptr) {
44911fccf17Sopenharmony_ci        BuildICallList(callList, response, responseLen);
45011fccf17Sopenharmony_ci    }
45111fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::GetCallListResponse, callList);
45211fccf17Sopenharmony_ci}
45311fccf17Sopenharmony_ci
45411fccf17Sopenharmony_ciint32_t HRilCall::DialResponse(
45511fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
45611fccf17Sopenharmony_ci{
45711fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::DialResponse);
45811fccf17Sopenharmony_ci}
45911fccf17Sopenharmony_ci
46011fccf17Sopenharmony_ciint32_t HRilCall::HangupResponse(
46111fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
46211fccf17Sopenharmony_ci{
46311fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::HangupResponse);
46411fccf17Sopenharmony_ci}
46511fccf17Sopenharmony_ci
46611fccf17Sopenharmony_ciint32_t HRilCall::RejectResponse(
46711fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
46811fccf17Sopenharmony_ci{
46911fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::RejectResponse);
47011fccf17Sopenharmony_ci}
47111fccf17Sopenharmony_ci
47211fccf17Sopenharmony_ciint32_t HRilCall::AnswerResponse(
47311fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
47411fccf17Sopenharmony_ci{
47511fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::AnswerResponse);
47611fccf17Sopenharmony_ci}
47711fccf17Sopenharmony_ci
47811fccf17Sopenharmony_ciint32_t HRilCall::HoldCallResponse(
47911fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
48011fccf17Sopenharmony_ci{
48111fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::HoldCallResponse);
48211fccf17Sopenharmony_ci}
48311fccf17Sopenharmony_ci
48411fccf17Sopenharmony_ciint32_t HRilCall::GetClipResponse(
48511fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
48611fccf17Sopenharmony_ci{
48711fccf17Sopenharmony_ci    if ((response == nullptr && responseLen != 0) || (responseLen % sizeof(HRilGetClipResult)) != 0) {
48811fccf17Sopenharmony_ci        TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen);
48911fccf17Sopenharmony_ci        return HRIL_ERR_INVALID_PARAMETER;
49011fccf17Sopenharmony_ci    }
49111fccf17Sopenharmony_ci    HDI::Ril::V1_1::GetClipResult getClipResult = {};
49211fccf17Sopenharmony_ci    getClipResult.result = static_cast<int32_t>(responseInfo.error);
49311fccf17Sopenharmony_ci    if (response != nullptr) {
49411fccf17Sopenharmony_ci        const HRilGetClipResult *pGetClip = static_cast<const HRilGetClipResult *>(response);
49511fccf17Sopenharmony_ci        getClipResult.action = pGetClip->action;
49611fccf17Sopenharmony_ci        getClipResult.clipStat = pGetClip->clipStat;
49711fccf17Sopenharmony_ci    }
49811fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::GetClipResponse, getClipResult);
49911fccf17Sopenharmony_ci}
50011fccf17Sopenharmony_ci
50111fccf17Sopenharmony_ciint32_t HRilCall::SetClipResponse(
50211fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
50311fccf17Sopenharmony_ci{
50411fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::SetClipResponse);
50511fccf17Sopenharmony_ci}
50611fccf17Sopenharmony_ci
50711fccf17Sopenharmony_ciint32_t HRilCall::UnHoldCallResponse(
50811fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
50911fccf17Sopenharmony_ci{
51011fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::UnHoldCallResponse);
51111fccf17Sopenharmony_ci}
51211fccf17Sopenharmony_ci
51311fccf17Sopenharmony_ciint32_t HRilCall::SwitchCallResponse(
51411fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
51511fccf17Sopenharmony_ci{
51611fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::SwitchCallResponse);
51711fccf17Sopenharmony_ci}
51811fccf17Sopenharmony_ci
51911fccf17Sopenharmony_ciint32_t HRilCall::CombineConferenceResponse(
52011fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
52111fccf17Sopenharmony_ci{
52211fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::CombineConferenceResponse);
52311fccf17Sopenharmony_ci}
52411fccf17Sopenharmony_ci
52511fccf17Sopenharmony_ciint32_t HRilCall::SeparateConferenceResponse(
52611fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
52711fccf17Sopenharmony_ci{
52811fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::SeparateConferenceResponse);
52911fccf17Sopenharmony_ci}
53011fccf17Sopenharmony_ci
53111fccf17Sopenharmony_ciint32_t HRilCall::CallSupplementResponse(
53211fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
53311fccf17Sopenharmony_ci{
53411fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::CallSupplementResponse);
53511fccf17Sopenharmony_ci}
53611fccf17Sopenharmony_ci
53711fccf17Sopenharmony_ciint32_t HRilCall::GetCallWaitingResponse(
53811fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
53911fccf17Sopenharmony_ci{
54011fccf17Sopenharmony_ci    if ((response == nullptr && responseLen != 0) || (responseLen % sizeof(HRilCallWaitResult)) != 0) {
54111fccf17Sopenharmony_ci        TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen);
54211fccf17Sopenharmony_ci        return HRIL_ERR_INVALID_PARAMETER;
54311fccf17Sopenharmony_ci    }
54411fccf17Sopenharmony_ci    HDI::Ril::V1_1::CallWaitResult callWaitResult = {};
54511fccf17Sopenharmony_ci    callWaitResult.result = static_cast<int32_t>(responseInfo.error);
54611fccf17Sopenharmony_ci    if (response != nullptr) {
54711fccf17Sopenharmony_ci        const HRilCallWaitResult *result = static_cast<const HRilCallWaitResult *>(response);
54811fccf17Sopenharmony_ci        callWaitResult.status = result->status;
54911fccf17Sopenharmony_ci        callWaitResult.classCw = result->classCw;
55011fccf17Sopenharmony_ci    }
55111fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::GetCallWaitingResponse, callWaitResult);
55211fccf17Sopenharmony_ci}
55311fccf17Sopenharmony_ci
55411fccf17Sopenharmony_ciint32_t HRilCall::SetCallWaitingResponse(
55511fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
55611fccf17Sopenharmony_ci{
55711fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::SetCallWaitingResponse);
55811fccf17Sopenharmony_ci}
55911fccf17Sopenharmony_ci
56011fccf17Sopenharmony_ciint32_t HRilCall::GetCallTransferInfoResponse(
56111fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
56211fccf17Sopenharmony_ci{
56311fccf17Sopenharmony_ci    if ((response == nullptr && responseLen != 0) || (responseLen % sizeof(HRilCFQueryInfo)) != 0) {
56411fccf17Sopenharmony_ci        TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen);
56511fccf17Sopenharmony_ci        return HRIL_ERR_INVALID_PARAMETER;
56611fccf17Sopenharmony_ci    }
56711fccf17Sopenharmony_ci    HDI::Ril::V1_1::CallForwardQueryInfoList cFQueryList = {};
56811fccf17Sopenharmony_ci    if (response != nullptr) {
56911fccf17Sopenharmony_ci        BuildICallForwardQueryInfoList(cFQueryList, responseInfo, response, responseLen);
57011fccf17Sopenharmony_ci    }
57111fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::GetCallTransferInfoResponse, cFQueryList);
57211fccf17Sopenharmony_ci}
57311fccf17Sopenharmony_ci
57411fccf17Sopenharmony_civoid HRilCall::BuildICallForwardQueryInfoList(HDI::Ril::V1_1::CallForwardQueryInfoList &cFQueryList,
57511fccf17Sopenharmony_ci    HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
57611fccf17Sopenharmony_ci{
57711fccf17Sopenharmony_ci    size_t num = responseLen / sizeof(HRilCFQueryInfo);
57811fccf17Sopenharmony_ci    HDI::Ril::V1_1::CallForwardQueryResult cFQueryResult;
57911fccf17Sopenharmony_ci    cFQueryList.callSize = num;
58011fccf17Sopenharmony_ci    for (size_t i = 0; i < num; i++) {
58111fccf17Sopenharmony_ci        HRilCFQueryInfo *curPtr = ((HRilCFQueryInfo *)response + i);
58211fccf17Sopenharmony_ci        if (curPtr != nullptr) {
58311fccf17Sopenharmony_ci            cFQueryResult.result = static_cast<int32_t>(responseInfo.error);
58411fccf17Sopenharmony_ci            cFQueryResult.serial = responseInfo.serial;
58511fccf17Sopenharmony_ci            cFQueryResult.status = curPtr->status;
58611fccf17Sopenharmony_ci            cFQueryResult.classx = curPtr->classx;
58711fccf17Sopenharmony_ci            cFQueryResult.type = curPtr->type;
58811fccf17Sopenharmony_ci            cFQueryResult.number = ((curPtr->number == nullptr) ? "" : curPtr->number);
58911fccf17Sopenharmony_ci            cFQueryResult.reason = curPtr->reason;
59011fccf17Sopenharmony_ci            cFQueryResult.time = curPtr->time;
59111fccf17Sopenharmony_ci            cFQueryList.calls.push_back(cFQueryResult);
59211fccf17Sopenharmony_ci        } else {
59311fccf17Sopenharmony_ci            TELEPHONY_LOGE("BuildICallForwardQueryInfoList: Invalid curPtr");
59411fccf17Sopenharmony_ci            break;
59511fccf17Sopenharmony_ci        }
59611fccf17Sopenharmony_ci    }
59711fccf17Sopenharmony_ci}
59811fccf17Sopenharmony_ci
59911fccf17Sopenharmony_ciint32_t HRilCall::SetCallTransferInfoResponse(
60011fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
60111fccf17Sopenharmony_ci{
60211fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::SetCallTransferInfoResponse);
60311fccf17Sopenharmony_ci}
60411fccf17Sopenharmony_ci
60511fccf17Sopenharmony_ciint32_t HRilCall::GetClirResponse(
60611fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
60711fccf17Sopenharmony_ci{
60811fccf17Sopenharmony_ci    if ((response == nullptr && responseLen != 0) || (responseLen % sizeof(HRilGetCallClirResult)) != 0) {
60911fccf17Sopenharmony_ci        TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen);
61011fccf17Sopenharmony_ci        return HRIL_ERR_INVALID_PARAMETER;
61111fccf17Sopenharmony_ci    }
61211fccf17Sopenharmony_ci    HDI::Ril::V1_1::GetClirResult getClirResult = {};
61311fccf17Sopenharmony_ci    getClirResult.result = static_cast<int32_t>(responseInfo.error);
61411fccf17Sopenharmony_ci    if (response != nullptr) {
61511fccf17Sopenharmony_ci        const HRilGetCallClirResult *pGetClir = static_cast<const HRilGetCallClirResult *>(response);
61611fccf17Sopenharmony_ci        getClirResult.action = pGetClir->action;
61711fccf17Sopenharmony_ci        getClirResult.clirStat = pGetClir->clirStat;
61811fccf17Sopenharmony_ci    }
61911fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::GetClirResponse, getClirResult);
62011fccf17Sopenharmony_ci}
62111fccf17Sopenharmony_ci
62211fccf17Sopenharmony_ciint32_t HRilCall::SetClirResponse(
62311fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
62411fccf17Sopenharmony_ci{
62511fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::SetClirResponse);
62611fccf17Sopenharmony_ci}
62711fccf17Sopenharmony_ci
62811fccf17Sopenharmony_ciint32_t HRilCall::GetCallRestrictionResponse(
62911fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
63011fccf17Sopenharmony_ci{
63111fccf17Sopenharmony_ci    if ((response == nullptr && responseLen != 0) || (responseLen % sizeof(HRilCallRestrictionResult)) != 0) {
63211fccf17Sopenharmony_ci        TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen);
63311fccf17Sopenharmony_ci        return HRIL_ERR_INVALID_PARAMETER;
63411fccf17Sopenharmony_ci    }
63511fccf17Sopenharmony_ci    HDI::Ril::V1_1::CallRestrictionResult resultT = {};
63611fccf17Sopenharmony_ci    resultT.result = static_cast<int32_t>(responseInfo.error);
63711fccf17Sopenharmony_ci    if (response != nullptr) {
63811fccf17Sopenharmony_ci        const HRilCallRestrictionResult *result = static_cast<const HRilCallRestrictionResult *>(response);
63911fccf17Sopenharmony_ci        resultT.status = result->status;
64011fccf17Sopenharmony_ci        resultT.classCw = result->classCw;
64111fccf17Sopenharmony_ci    }
64211fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::GetCallRestrictionResponse, resultT);
64311fccf17Sopenharmony_ci}
64411fccf17Sopenharmony_ci
64511fccf17Sopenharmony_ciint32_t HRilCall::SetCallRestrictionResponse(
64611fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
64711fccf17Sopenharmony_ci{
64811fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::SetCallRestrictionResponse);
64911fccf17Sopenharmony_ci}
65011fccf17Sopenharmony_ci
65111fccf17Sopenharmony_ciint32_t HRilCall::SetBarringPasswordResponse(
65211fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
65311fccf17Sopenharmony_ci{
65411fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::SetBarringPasswordResponse);
65511fccf17Sopenharmony_ci}
65611fccf17Sopenharmony_ci
65711fccf17Sopenharmony_ciint32_t HRilCall::StartDtmfResponse(
65811fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
65911fccf17Sopenharmony_ci{
66011fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::StartDtmfResponse);
66111fccf17Sopenharmony_ci}
66211fccf17Sopenharmony_ci
66311fccf17Sopenharmony_ciint32_t HRilCall::SendDtmfResponse(
66411fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
66511fccf17Sopenharmony_ci{
66611fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::SendDtmfResponse);
66711fccf17Sopenharmony_ci}
66811fccf17Sopenharmony_ci
66911fccf17Sopenharmony_ciint32_t HRilCall::StopDtmfResponse(
67011fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
67111fccf17Sopenharmony_ci{
67211fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::StopDtmfResponse);
67311fccf17Sopenharmony_ci}
67411fccf17Sopenharmony_ci
67511fccf17Sopenharmony_ciint32_t HRilCall::GetCallPreferenceModeResponse(
67611fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
67711fccf17Sopenharmony_ci{
67811fccf17Sopenharmony_ci    if ((response == nullptr && responseLen != 0) || (responseLen % sizeof(int32_t)) != 0) {
67911fccf17Sopenharmony_ci        TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen);
68011fccf17Sopenharmony_ci        return HRIL_ERR_INVALID_PARAMETER;
68111fccf17Sopenharmony_ci    }
68211fccf17Sopenharmony_ci    int32_t mode = 0;
68311fccf17Sopenharmony_ci    if (response != nullptr) {
68411fccf17Sopenharmony_ci        mode = *((int32_t *)response);
68511fccf17Sopenharmony_ci    }
68611fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::GetCallPreferenceModeResponse, mode);
68711fccf17Sopenharmony_ci}
68811fccf17Sopenharmony_ci
68911fccf17Sopenharmony_ciint32_t HRilCall::SetCallPreferenceModeResponse(
69011fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
69111fccf17Sopenharmony_ci{
69211fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::SetCallPreferenceModeResponse);
69311fccf17Sopenharmony_ci}
69411fccf17Sopenharmony_ci
69511fccf17Sopenharmony_ciint32_t HRilCall::SetUssdResponse(
69611fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
69711fccf17Sopenharmony_ci{
69811fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::SetUssdResponse);
69911fccf17Sopenharmony_ci}
70011fccf17Sopenharmony_ci
70111fccf17Sopenharmony_ciint32_t HRilCall::GetMuteResponse(
70211fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
70311fccf17Sopenharmony_ci{
70411fccf17Sopenharmony_ci    if ((response == nullptr && responseLen != 0) || (responseLen % sizeof(int32_t)) != 0) {
70511fccf17Sopenharmony_ci        TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen);
70611fccf17Sopenharmony_ci        return HRIL_ERR_INVALID_PARAMETER;
70711fccf17Sopenharmony_ci    }
70811fccf17Sopenharmony_ci    int32_t mute = 0;
70911fccf17Sopenharmony_ci    if (response != nullptr) {
71011fccf17Sopenharmony_ci        mute = *((int32_t *)response);
71111fccf17Sopenharmony_ci    }
71211fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::GetMuteResponse, mute);
71311fccf17Sopenharmony_ci}
71411fccf17Sopenharmony_ci
71511fccf17Sopenharmony_ciint32_t HRilCall::SetMuteResponse(
71611fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
71711fccf17Sopenharmony_ci{
71811fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::SetMuteResponse);
71911fccf17Sopenharmony_ci}
72011fccf17Sopenharmony_ci
72111fccf17Sopenharmony_ciint32_t HRilCall::GetUssdResponse(
72211fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
72311fccf17Sopenharmony_ci{
72411fccf17Sopenharmony_ci    if ((response == nullptr && responseLen != 0) || (responseLen % sizeof(int32_t)) != 0) {
72511fccf17Sopenharmony_ci        TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen);
72611fccf17Sopenharmony_ci        return HRIL_ERR_INVALID_PARAMETER;
72711fccf17Sopenharmony_ci    }
72811fccf17Sopenharmony_ci    int32_t cusd = 0;
72911fccf17Sopenharmony_ci    if (response != nullptr) {
73011fccf17Sopenharmony_ci        cusd = *((int32_t *)response);
73111fccf17Sopenharmony_ci    }
73211fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::GetUssdResponse, cusd);
73311fccf17Sopenharmony_ci}
73411fccf17Sopenharmony_ci
73511fccf17Sopenharmony_ciint32_t HRilCall::GetCallFailReasonResponse(
73611fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
73711fccf17Sopenharmony_ci{
73811fccf17Sopenharmony_ci    if ((response == nullptr && responseLen != 0) || (responseLen % sizeof(int32_t)) != 0) {
73911fccf17Sopenharmony_ci        TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen);
74011fccf17Sopenharmony_ci        return HRIL_ERR_INVALID_PARAMETER;
74111fccf17Sopenharmony_ci    }
74211fccf17Sopenharmony_ci    int32_t callFail = HRIL_ERR_CALL_CAUSE;
74311fccf17Sopenharmony_ci    if (response != nullptr) {
74411fccf17Sopenharmony_ci        callFail = *((int32_t *)response);
74511fccf17Sopenharmony_ci    }
74611fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::GetCallFailReasonResponse, callFail);
74711fccf17Sopenharmony_ci}
74811fccf17Sopenharmony_ci
74911fccf17Sopenharmony_civoid HRilCall::BuildIEmergencyCallList(
75011fccf17Sopenharmony_ci    HDI::Ril::V1_1::EmergencyInfoList &emergencyCallInfoList, const void *response, size_t responseLen)
75111fccf17Sopenharmony_ci{
75211fccf17Sopenharmony_ci    size_t num = responseLen / sizeof(HRilEmergencyInfo);
75311fccf17Sopenharmony_ci    HDI::Ril::V1_1::EmergencyCall callInfo;
75411fccf17Sopenharmony_ci    emergencyCallInfoList.callSize = num;
75511fccf17Sopenharmony_ci    for (size_t i = 0; i < num; i++) {
75611fccf17Sopenharmony_ci        HRilEmergencyInfo *curPtr = ((HRilEmergencyInfo *)response + i);
75711fccf17Sopenharmony_ci        if (curPtr != nullptr) {
75811fccf17Sopenharmony_ci            callInfo.index = curPtr->index;
75911fccf17Sopenharmony_ci            callInfo.total = curPtr->total;
76011fccf17Sopenharmony_ci            callInfo.eccNum = (curPtr->eccNum == nullptr) ? "" : curPtr->eccNum;
76111fccf17Sopenharmony_ci            callInfo.eccType = static_cast<OHOS::HDI::Ril::V1_1::EccType>(curPtr->category);
76211fccf17Sopenharmony_ci            callInfo.simpresent = static_cast<OHOS::HDI::Ril::V1_1::SimpresentType>(curPtr->simpresent);
76311fccf17Sopenharmony_ci            callInfo.mcc = (curPtr->mcc == nullptr) ? "" : curPtr->mcc;
76411fccf17Sopenharmony_ci            callInfo.abnormalService = static_cast<OHOS::HDI::Ril::V1_1::AbnormalServiceType>(curPtr->abnormalService);
76511fccf17Sopenharmony_ci            emergencyCallInfoList.calls.push_back(callInfo);
76611fccf17Sopenharmony_ci        } else {
76711fccf17Sopenharmony_ci            TELEPHONY_LOGE("BuildIEmergencyCallList: Invalid curPtr");
76811fccf17Sopenharmony_ci            break;
76911fccf17Sopenharmony_ci        }
77011fccf17Sopenharmony_ci    }
77111fccf17Sopenharmony_ci}
77211fccf17Sopenharmony_ci
77311fccf17Sopenharmony_ciint32_t HRilCall::GetEmergencyCallListResponse(
77411fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
77511fccf17Sopenharmony_ci{
77611fccf17Sopenharmony_ci    if ((response == nullptr && responseLen != 0) || (responseLen % sizeof(HRilEmergencyInfo)) != 0) {
77711fccf17Sopenharmony_ci        TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen);
77811fccf17Sopenharmony_ci        return HRIL_ERR_INVALID_PARAMETER;
77911fccf17Sopenharmony_ci    }
78011fccf17Sopenharmony_ci    HDI::Ril::V1_1::EmergencyInfoList callList = {};
78111fccf17Sopenharmony_ci    if (response != nullptr) {
78211fccf17Sopenharmony_ci        BuildIEmergencyCallList(callList, response, responseLen);
78311fccf17Sopenharmony_ci    }
78411fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::GetEmergencyCallListResponse, callList);
78511fccf17Sopenharmony_ci}
78611fccf17Sopenharmony_ci
78711fccf17Sopenharmony_ciint32_t HRilCall::SetEmergencyCallList(
78811fccf17Sopenharmony_ci    int32_t serialId, const OHOS::HDI::Ril::V1_1::EmergencyInfoList &emergencyInfoList)
78911fccf17Sopenharmony_ci{
79011fccf17Sopenharmony_ci    auto size = emergencyInfoList.calls.size();
79111fccf17Sopenharmony_ci    std::unique_ptr<HRilEmergencyInfo[]> emergencyInfoCalls = std::make_unique<HRilEmergencyInfo[]>(size);
79211fccf17Sopenharmony_ci    CopyToHRilEmergencyInfoArray(emergencyInfoCalls.get(), emergencyInfoList.calls);
79311fccf17Sopenharmony_ci    return RequestVendor(serialId, HREQ_CALL_SET_EMERGENCY_LIST, callFuncs_, &HRilCallReq::SetEmergencyCallList,
79411fccf17Sopenharmony_ci        emergencyInfoCalls.get(), size);
79511fccf17Sopenharmony_ci}
79611fccf17Sopenharmony_ci
79711fccf17Sopenharmony_civoid HRilCall::CopyToHRilEmergencyInfoArray(
79811fccf17Sopenharmony_ci    HRilEmergencyInfo *emergencyInfoCalls, std::vector<HDI::Ril::V1_1::EmergencyCall> calls)
79911fccf17Sopenharmony_ci{
80011fccf17Sopenharmony_ci    for (unsigned int i = 0; i < calls.size(); i++) {
80111fccf17Sopenharmony_ci        auto call = calls.at(i);
80211fccf17Sopenharmony_ci        emergencyInfoCalls[i].index = call.index;
80311fccf17Sopenharmony_ci        emergencyInfoCalls[i].total = call.total;
80411fccf17Sopenharmony_ci        char *eccNum = new char[call.eccNum.size() + 1];
80511fccf17Sopenharmony_ci        if (strcpy_s(eccNum, call.eccNum.size() + 1, call.eccNum.c_str()) == EOK) {
80611fccf17Sopenharmony_ci            emergencyInfoCalls[i].eccNum = eccNum;
80711fccf17Sopenharmony_ci        } else {
80811fccf17Sopenharmony_ci            delete[] eccNum;
80911fccf17Sopenharmony_ci            eccNum = nullptr;
81011fccf17Sopenharmony_ci        }
81111fccf17Sopenharmony_ci        emergencyInfoCalls[i].category = static_cast<int32_t>(call.eccType);
81211fccf17Sopenharmony_ci        emergencyInfoCalls[i].simpresent = call.simpresent;
81311fccf17Sopenharmony_ci        char *mcc = new char[call.mcc.size() + 1];
81411fccf17Sopenharmony_ci        if (strcpy_s(mcc, call.mcc.size() + 1, call.mcc.c_str()) == EOK) {
81511fccf17Sopenharmony_ci            emergencyInfoCalls[i].mcc = mcc;
81611fccf17Sopenharmony_ci        } else {
81711fccf17Sopenharmony_ci            delete[] mcc;
81811fccf17Sopenharmony_ci            mcc = nullptr;
81911fccf17Sopenharmony_ci        }
82011fccf17Sopenharmony_ci        emergencyInfoCalls[i].abnormalService = call.abnormalService;
82111fccf17Sopenharmony_ci    }
82211fccf17Sopenharmony_ci}
82311fccf17Sopenharmony_ci
82411fccf17Sopenharmony_ciint32_t HRilCall::SetEmergencyCallListResponse(
82511fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
82611fccf17Sopenharmony_ci{
82711fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::SetEmergencyCallListResponse);
82811fccf17Sopenharmony_ci}
82911fccf17Sopenharmony_ci
83011fccf17Sopenharmony_ciint32_t HRilCall::CloseUnFinishedUssdResponse(
83111fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
83211fccf17Sopenharmony_ci{
83311fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::CloseUnFinishedUssdResponse);
83411fccf17Sopenharmony_ci}
83511fccf17Sopenharmony_ci
83611fccf17Sopenharmony_ciint32_t HRilCall::SetVonrSwitchResponse(
83711fccf17Sopenharmony_ci    int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen)
83811fccf17Sopenharmony_ci{
83911fccf17Sopenharmony_ci    return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::SetVonrSwitchResponse);
84011fccf17Sopenharmony_ci}
84111fccf17Sopenharmony_ci
84211fccf17Sopenharmony_ciint32_t HRilCall::CallStateUpdated(
84311fccf17Sopenharmony_ci    int32_t notifyType, const HRilErrNumber error, const void *response, size_t responseLen)
84411fccf17Sopenharmony_ci{
84511fccf17Sopenharmony_ci    return Notify(notifyType, error, &HDI::Ril::V1_1::IRilCallback::CallStateUpdated);
84611fccf17Sopenharmony_ci}
84711fccf17Sopenharmony_ci
84811fccf17Sopenharmony_ciint32_t HRilCall::CallUssdNotice(
84911fccf17Sopenharmony_ci    int32_t notifyType, const HRilErrNumber error, const void *response, size_t responseLen)
85011fccf17Sopenharmony_ci{
85111fccf17Sopenharmony_ci    if ((response == nullptr) || (responseLen % sizeof(HRilUssdNoticeInfo)) != 0) {
85211fccf17Sopenharmony_ci        TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen);
85311fccf17Sopenharmony_ci        return HRIL_ERR_INVALID_PARAMETER;
85411fccf17Sopenharmony_ci    }
85511fccf17Sopenharmony_ci    HDI::Ril::V1_1::UssdNoticeInfo ussdNoticeInfo = {};
85611fccf17Sopenharmony_ci    const HRilUssdNoticeInfo *hUssdNoticeInfo = reinterpret_cast<const HRilUssdNoticeInfo *>(response);
85711fccf17Sopenharmony_ci    ussdNoticeInfo.type = hUssdNoticeInfo->m;
85811fccf17Sopenharmony_ci    ussdNoticeInfo.message = hUssdNoticeInfo->str == nullptr ? "" : hUssdNoticeInfo->str;
85911fccf17Sopenharmony_ci    return Notify(notifyType, error, &HDI::Ril::V1_1::IRilCallback::CallUssdNotice, ussdNoticeInfo);
86011fccf17Sopenharmony_ci}
86111fccf17Sopenharmony_ci
86211fccf17Sopenharmony_ciint32_t HRilCall::CallSsNotice(int32_t notifyType, const HRilErrNumber error, const void *response, size_t responseLen)
86311fccf17Sopenharmony_ci{
86411fccf17Sopenharmony_ci    if ((response == nullptr) || (responseLen % sizeof(HRilSsNoticeInfo)) != 0) {
86511fccf17Sopenharmony_ci        TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen);
86611fccf17Sopenharmony_ci        return HRIL_ERR_INVALID_PARAMETER;
86711fccf17Sopenharmony_ci    }
86811fccf17Sopenharmony_ci    HDI::Ril::V1_1::SsNoticeInfo ssNoticeInfo = {};
86911fccf17Sopenharmony_ci    const HRilSsNoticeInfo *hSsNoticeInfo = reinterpret_cast<const HRilSsNoticeInfo *>(response);
87011fccf17Sopenharmony_ci    ssNoticeInfo.serviceType = hSsNoticeInfo->serviceType;
87111fccf17Sopenharmony_ci    ssNoticeInfo.requestType = hSsNoticeInfo->requestType;
87211fccf17Sopenharmony_ci    ssNoticeInfo.serviceClass = hSsNoticeInfo->serviceClass;
87311fccf17Sopenharmony_ci    ssNoticeInfo.result = hSsNoticeInfo->result;
87411fccf17Sopenharmony_ci    return Notify(notifyType, error, &HDI::Ril::V1_1::IRilCallback::CallSsNotice, ssNoticeInfo);
87511fccf17Sopenharmony_ci}
87611fccf17Sopenharmony_ci
87711fccf17Sopenharmony_ciint32_t HRilCall::CallSrvccStatusNotice(
87811fccf17Sopenharmony_ci    int32_t notifyType, HRilErrNumber error, const void *response, size_t responseLen)
87911fccf17Sopenharmony_ci{
88011fccf17Sopenharmony_ci    if ((response == nullptr) || (responseLen % sizeof(HRilCallSrvccStatus)) != 0) {
88111fccf17Sopenharmony_ci        TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen);
88211fccf17Sopenharmony_ci        return HRIL_ERR_INVALID_PARAMETER;
88311fccf17Sopenharmony_ci    }
88411fccf17Sopenharmony_ci    HDI::Ril::V1_1::SrvccStatus srvccStatus = {};
88511fccf17Sopenharmony_ci    const HRilCallSrvccStatus *hSrvccStatus = reinterpret_cast<const HRilCallSrvccStatus *>(response);
88611fccf17Sopenharmony_ci    srvccStatus.status = hSrvccStatus->status;
88711fccf17Sopenharmony_ci    return Notify(notifyType, error, &HDI::Ril::V1_1::IRilCallback::CallSrvccStatusNotice, srvccStatus);
88811fccf17Sopenharmony_ci}
88911fccf17Sopenharmony_ci
89011fccf17Sopenharmony_ciint32_t HRilCall::CallRingbackVoiceNotice(
89111fccf17Sopenharmony_ci    int32_t notifyType, HRilErrNumber error, const void *response, size_t responseLen)
89211fccf17Sopenharmony_ci{
89311fccf17Sopenharmony_ci    if ((response == nullptr) || (responseLen % sizeof(int32_t)) != 0) {
89411fccf17Sopenharmony_ci        TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen);
89511fccf17Sopenharmony_ci        return HRIL_ERR_INVALID_PARAMETER;
89611fccf17Sopenharmony_ci    }
89711fccf17Sopenharmony_ci    HDI::Ril::V1_1::RingbackVoice ringbackVoice = {};
89811fccf17Sopenharmony_ci    const int32_t *ringbackVoiceFlag = reinterpret_cast<const int32_t *>(response);
89911fccf17Sopenharmony_ci    ringbackVoice.status = *ringbackVoiceFlag;
90011fccf17Sopenharmony_ci    return Notify(notifyType, error, &HDI::Ril::V1_1::IRilCallback::CallRingbackVoiceNotice, ringbackVoice);
90111fccf17Sopenharmony_ci}
90211fccf17Sopenharmony_ci
90311fccf17Sopenharmony_ciint32_t HRilCall::CallEmergencyNotice(
90411fccf17Sopenharmony_ci    int32_t notifyType, const HRilErrNumber error, const void *response, size_t responseLen)
90511fccf17Sopenharmony_ci{
90611fccf17Sopenharmony_ci    if (response == nullptr || responseLen == 0 || (responseLen % sizeof(HRilEmergencyInfo)) != 0) {
90711fccf17Sopenharmony_ci        TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen);
90811fccf17Sopenharmony_ci        return HRIL_ERR_INVALID_PARAMETER;
90911fccf17Sopenharmony_ci    }
91011fccf17Sopenharmony_ci    HDI::Ril::V1_1::EmergencyInfoList callList = {};
91111fccf17Sopenharmony_ci    BuildIEmergencyCallList(callList, response, responseLen);
91211fccf17Sopenharmony_ci    return Notify(notifyType, error, &HDI::Ril::V1_1::IRilCallback::CallEmergencyNotice, callList);
91311fccf17Sopenharmony_ci}
91411fccf17Sopenharmony_ci
91511fccf17Sopenharmony_ciint32_t HRilCall::CallRsrvccStatusNotify(
91611fccf17Sopenharmony_ci    int32_t notifyType, HRilErrNumber error, const void *response, size_t responseLen)
91711fccf17Sopenharmony_ci{
91811fccf17Sopenharmony_ci    return Notify(notifyType, error, &HDI::Ril::V1_1::IRilCallback::CallRsrvccStatusNotify);
91911fccf17Sopenharmony_ci}
92011fccf17Sopenharmony_ci
92111fccf17Sopenharmony_civoid HRilCall::RegisterCallFuncs(const HRilCallReq *callFuncs)
92211fccf17Sopenharmony_ci{
92311fccf17Sopenharmony_ci    callFuncs_ = callFuncs;
92411fccf17Sopenharmony_ci}
92511fccf17Sopenharmony_ci} // namespace Telephony
92611fccf17Sopenharmony_ci} // namespace OHOS
927