111fccf17Sopenharmony_ci/*
211fccf17Sopenharmony_ci * Copyright (C) 2021-2024 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 "at_call.h"
1711fccf17Sopenharmony_ci
1811fccf17Sopenharmony_ci#include "hril_notification.h"
1911fccf17Sopenharmony_ci#include "securec.h"
2011fccf17Sopenharmony_ci#include "vendor_report.h"
2111fccf17Sopenharmony_ci#include "vendor_util.h"
2211fccf17Sopenharmony_ci
2311fccf17Sopenharmony_ci#undef DEFAULT_TIMEOUT
2411fccf17Sopenharmony_ci#define DEFAULT_TIMEOUT 5000
2511fccf17Sopenharmony_ci#define DEFAULT_TIMEOUT_CLCK 50000
2611fccf17Sopenharmony_ci
2711fccf17Sopenharmony_ciCallNotify g_callNotifyTab[] = {
2811fccf17Sopenharmony_ci    {"^CCALLSTATE:", ReportCallStateUpdated},
2911fccf17Sopenharmony_ci    {"+CUSD:", ReportCallUssdNotice},
3011fccf17Sopenharmony_ci    {"+CIREPH:", ReportSrvccStatusUpdate},
3111fccf17Sopenharmony_ci    {"^CSCHANNELINFO:", ReportCsChannelInfo},
3211fccf17Sopenharmony_ci    {"^XLEMA:", ReportEmergencyNumberList},
3311fccf17Sopenharmony_ci};
3411fccf17Sopenharmony_ci
3511fccf17Sopenharmony_cistatic int32_t lastCcCause = HRIL_ERR_CALL_CAUSE;
3611fccf17Sopenharmony_cistatic const int32_t MAX_CALL_NUM = 100;
3711fccf17Sopenharmony_ci
3811fccf17Sopenharmony_cistatic void OnCallReportErrorMessages(const ReqDataInfo *requestInfo, int32_t err, ResponseInfo *pResponse)
3911fccf17Sopenharmony_ci{
4011fccf17Sopenharmony_ci    int32_t errorNo = HRIL_ERR_SUCCESS;
4111fccf17Sopenharmony_ci    ModemReportErrorInfo errInfo = GetReportErrorInfo(pResponse);
4211fccf17Sopenharmony_ci    errorNo = (err != HRIL_ERR_SUCCESS) ? err : errInfo.errorNo;
4311fccf17Sopenharmony_ci    TELEPHONY_LOGW("Report error! ret:%{public}d", errorNo);
4411fccf17Sopenharmony_ci    FreeResponseInfo(pResponse);
4511fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(requestInfo, errorNo, HRIL_RESPONSE, 0);
4611fccf17Sopenharmony_ci    reportInfo.modemErrInfo = errInfo;
4711fccf17Sopenharmony_ci    OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
4811fccf17Sopenharmony_ci}
4911fccf17Sopenharmony_ci
5011fccf17Sopenharmony_cistatic int32_t ParseDiffPart(int32_t isAllInfo, char **pLine, HRilCallInfo *outCall)
5111fccf17Sopenharmony_ci{
5211fccf17Sopenharmony_ci    if (outCall == NULL) {
5311fccf17Sopenharmony_ci        return HRIL_ERR_NULL_POINT;
5411fccf17Sopenharmony_ci    }
5511fccf17Sopenharmony_ci    int32_t tmp = 0;
5611fccf17Sopenharmony_ci    if (isAllInfo) {
5711fccf17Sopenharmony_ci        if (NextInt(pLine, &outCall->voiceDomain) < 0) {
5811fccf17Sopenharmony_ci            return HRIL_ERR_NULL_POINT;
5911fccf17Sopenharmony_ci        }
6011fccf17Sopenharmony_ci        if (NextInt(pLine, &outCall->callType) < 0) {
6111fccf17Sopenharmony_ci            return HRIL_ERR_NULL_POINT;
6211fccf17Sopenharmony_ci        }
6311fccf17Sopenharmony_ci        NextInt(pLine, &tmp); // ignore
6411fccf17Sopenharmony_ci    } else {
6511fccf17Sopenharmony_ci        outCall->voiceDomain = INT_DEFAULT_VALUE;
6611fccf17Sopenharmony_ci        outCall->callType = INT_DEFAULT_VALUE;
6711fccf17Sopenharmony_ci    }
6811fccf17Sopenharmony_ci    return 0;
6911fccf17Sopenharmony_ci}
7011fccf17Sopenharmony_ci
7111fccf17Sopenharmony_cistatic int32_t CallCmdCLCC(const char *lineCmd, HRilCallInfo *outCall)
7211fccf17Sopenharmony_ci{
7311fccf17Sopenharmony_ci    char *pLine = (char *)lineCmd;
7411fccf17Sopenharmony_ci    int32_t state;
7511fccf17Sopenharmony_ci    int32_t mode;
7611fccf17Sopenharmony_ci
7711fccf17Sopenharmony_ci    if (pLine == NULL || outCall == NULL) {
7811fccf17Sopenharmony_ci        TELEPHONY_LOGE("src or desc pointer is null.");
7911fccf17Sopenharmony_ci        return HRIL_ERR_NULL_POINT;
8011fccf17Sopenharmony_ci    }
8111fccf17Sopenharmony_ci    int32_t isAllInfo = ReportStrWith(pLine, "^CLCC:");
8211fccf17Sopenharmony_ci    if (SkipATPrefix(&pLine) < 0) {
8311fccf17Sopenharmony_ci        return HRIL_ERR_NULL_POINT;
8411fccf17Sopenharmony_ci    }
8511fccf17Sopenharmony_ci    if (NextInt(&pLine, &outCall->index) < 0) {
8611fccf17Sopenharmony_ci        return HRIL_ERR_NULL_POINT;
8711fccf17Sopenharmony_ci    }
8811fccf17Sopenharmony_ci    if (NextInt(&pLine, &outCall->dir) < 0) {
8911fccf17Sopenharmony_ci        return HRIL_ERR_NULL_POINT;
9011fccf17Sopenharmony_ci    }
9111fccf17Sopenharmony_ci    if (NextInt(&pLine, &state) < 0) {
9211fccf17Sopenharmony_ci        return HRIL_ERR_NULL_POINT;
9311fccf17Sopenharmony_ci    }
9411fccf17Sopenharmony_ci    outCall->state = (HRilCallState)state;
9511fccf17Sopenharmony_ci    if (NextInt(&pLine, &mode) < 0) {
9611fccf17Sopenharmony_ci        return HRIL_ERR_NULL_POINT;
9711fccf17Sopenharmony_ci    }
9811fccf17Sopenharmony_ci    outCall->mode = (HRilCallMode)mode;
9911fccf17Sopenharmony_ci    if (NextInt(&pLine, &outCall->mpty) < 0) {
10011fccf17Sopenharmony_ci        return HRIL_ERR_NULL_POINT;
10111fccf17Sopenharmony_ci    }
10211fccf17Sopenharmony_ci    if (ParseDiffPart(isAllInfo, &pLine, outCall)) {
10311fccf17Sopenharmony_ci        return HRIL_ERR_NULL_POINT;
10411fccf17Sopenharmony_ci    }
10511fccf17Sopenharmony_ci    if (NextStr(&pLine, &outCall->number) < 0) {
10611fccf17Sopenharmony_ci        return HRIL_ERR_NULL_POINT;
10711fccf17Sopenharmony_ci    }
10811fccf17Sopenharmony_ci    if (NextInt(&pLine, &outCall->type) < 0) {
10911fccf17Sopenharmony_ci        return HRIL_ERR_NULL_POINT;
11011fccf17Sopenharmony_ci    }
11111fccf17Sopenharmony_ci
11211fccf17Sopenharmony_ci    if (pLine != NULL) { // The data returned by some modules does not have this alpha data.
11311fccf17Sopenharmony_ci        if (NextStr(&pLine, &outCall->alpha) < 0) {
11411fccf17Sopenharmony_ci            return HRIL_ERR_NULL_POINT;
11511fccf17Sopenharmony_ci        }
11611fccf17Sopenharmony_ci    }
11711fccf17Sopenharmony_ci    return HRIL_ERR_SUCCESS;
11811fccf17Sopenharmony_ci}
11911fccf17Sopenharmony_ci
12011fccf17Sopenharmony_civoid ReportCallStateUpdated(const char *str)
12111fccf17Sopenharmony_ci{
12211fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
12311fccf17Sopenharmony_ci    char *pStr = (char *)str;
12411fccf17Sopenharmony_ci    int callId = 0;
12511fccf17Sopenharmony_ci    int voiceDomain = 0;
12611fccf17Sopenharmony_ci    int state = 0;
12711fccf17Sopenharmony_ci    ReqDataInfo requestInfo = {0};
12811fccf17Sopenharmony_ci    ModemReportErrorInfo errInfo = InitModemReportErrorInfo();
12911fccf17Sopenharmony_ci
13011fccf17Sopenharmony_ci    if (SkipATPrefix(&pStr) < 0) {
13111fccf17Sopenharmony_ci        err = HRIL_ERR_INVALID_MODEM_PARAMETER;
13211fccf17Sopenharmony_ci    }
13311fccf17Sopenharmony_ci    if (NextInt(&pStr, &callId) < 0) {
13411fccf17Sopenharmony_ci        err = HRIL_ERR_INVALID_MODEM_PARAMETER;
13511fccf17Sopenharmony_ci    }
13611fccf17Sopenharmony_ci    if (NextInt(&pStr, &state) < 0) {
13711fccf17Sopenharmony_ci        err = HRIL_ERR_INVALID_MODEM_PARAMETER;
13811fccf17Sopenharmony_ci    }
13911fccf17Sopenharmony_ci    if (NextInt(&pStr, &voiceDomain) < 0) {
14011fccf17Sopenharmony_ci        err = HRIL_ERR_INVALID_MODEM_PARAMETER;
14111fccf17Sopenharmony_ci    }
14211fccf17Sopenharmony_ci
14311fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(&requestInfo, err, HRIL_NOTIFICATION, HNOTI_CALL_STATE_UPDATED);
14411fccf17Sopenharmony_ci    reportInfo.modemErrInfo = errInfo;
14511fccf17Sopenharmony_ci    OnCallReport(GetSlotId(NULL), reportInfo, NULL, 0);
14611fccf17Sopenharmony_ci}
14711fccf17Sopenharmony_ci
14811fccf17Sopenharmony_civoid ReportSrvccStatusUpdate(const char *str)
14911fccf17Sopenharmony_ci{
15011fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
15111fccf17Sopenharmony_ci    char *pStr = (char *)str;
15211fccf17Sopenharmony_ci    HRilCallSrvccStatus srvccStatus = {0};
15311fccf17Sopenharmony_ci    ReqDataInfo requestInfo = {0};
15411fccf17Sopenharmony_ci    ModemReportErrorInfo errInfo = InitModemReportErrorInfo();
15511fccf17Sopenharmony_ci
15611fccf17Sopenharmony_ci    if (SkipATPrefix(&pStr) < 0) {
15711fccf17Sopenharmony_ci        err = HRIL_ERR_INVALID_MODEM_PARAMETER;
15811fccf17Sopenharmony_ci    }
15911fccf17Sopenharmony_ci    if (err == HRIL_ERR_SUCCESS && NextInt(&pStr, &srvccStatus.status) < 0) {
16011fccf17Sopenharmony_ci        err = HRIL_ERR_INVALID_MODEM_PARAMETER;
16111fccf17Sopenharmony_ci    }
16211fccf17Sopenharmony_ci
16311fccf17Sopenharmony_ci    struct ReportInfo reportInfo =
16411fccf17Sopenharmony_ci        CreateReportInfo(&requestInfo, err, HRIL_NOTIFICATION, HNOTI_CALL_SRVCC_STATUS_REPORT);
16511fccf17Sopenharmony_ci    reportInfo.modemErrInfo = errInfo;
16611fccf17Sopenharmony_ci    OnCallReport(GetSlotId(NULL), reportInfo, (const uint8_t *)&srvccStatus, sizeof(HRilCallSrvccStatus));
16711fccf17Sopenharmony_ci}
16811fccf17Sopenharmony_ci
16911fccf17Sopenharmony_civoid ReportCsChannelInfo(const char *str)
17011fccf17Sopenharmony_ci{
17111fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
17211fccf17Sopenharmony_ci    char *pStr = (char *)str;
17311fccf17Sopenharmony_ci    HRilCallCsChannelInfo csChannelInfo = {0};
17411fccf17Sopenharmony_ci    ReqDataInfo requestInfo = {0};
17511fccf17Sopenharmony_ci    ModemReportErrorInfo errInfo = InitModemReportErrorInfo();
17611fccf17Sopenharmony_ci    /* 0 network alerting; 1 local alerting */
17711fccf17Sopenharmony_ci    int32_t ringbackVoiceFlag = 0;
17811fccf17Sopenharmony_ci
17911fccf17Sopenharmony_ci    if (SkipATPrefix(&pStr) < 0) {
18011fccf17Sopenharmony_ci        err = HRIL_ERR_INVALID_MODEM_PARAMETER;
18111fccf17Sopenharmony_ci    }
18211fccf17Sopenharmony_ci    if (err == HRIL_ERR_SUCCESS && NextInt(&pStr, &csChannelInfo.status) < 0) {
18311fccf17Sopenharmony_ci        err = HRIL_ERR_INVALID_MODEM_PARAMETER;
18411fccf17Sopenharmony_ci    }
18511fccf17Sopenharmony_ci    if (err == HRIL_ERR_SUCCESS && NextInt(&pStr, &csChannelInfo.voiceDomain) < 0) {
18611fccf17Sopenharmony_ci        err = HRIL_ERR_INVALID_MODEM_PARAMETER;
18711fccf17Sopenharmony_ci    }
18811fccf17Sopenharmony_ci
18911fccf17Sopenharmony_ci    ringbackVoiceFlag = !csChannelInfo.status;
19011fccf17Sopenharmony_ci    struct ReportInfo reportInfo =
19111fccf17Sopenharmony_ci        CreateReportInfo(&requestInfo, err, HRIL_NOTIFICATION, HNOTI_CALL_RINGBACK_VOICE_REPORT);
19211fccf17Sopenharmony_ci    reportInfo.modemErrInfo = errInfo;
19311fccf17Sopenharmony_ci    OnCallReport(GetSlotId(NULL), reportInfo, (const uint8_t *)&ringbackVoiceFlag, sizeof(int32_t));
19411fccf17Sopenharmony_ci}
19511fccf17Sopenharmony_ci
19611fccf17Sopenharmony_ciint32_t IsCallNoticeCmd(const char *str)
19711fccf17Sopenharmony_ci{
19811fccf17Sopenharmony_ci    int32_t tabSize = sizeof(g_callNotifyTab) / sizeof(CallNotify);
19911fccf17Sopenharmony_ci    for (int32_t i = 0; i < tabSize; i++) {
20011fccf17Sopenharmony_ci        if (ReportStrWith(str, g_callNotifyTab[i].cmd)) {
20111fccf17Sopenharmony_ci            return 1;
20211fccf17Sopenharmony_ci        }
20311fccf17Sopenharmony_ci    }
20411fccf17Sopenharmony_ci    return 0;
20511fccf17Sopenharmony_ci}
20611fccf17Sopenharmony_ci
20711fccf17Sopenharmony_civoid CallReportInfoProcess(const char *str)
20811fccf17Sopenharmony_ci{
20911fccf17Sopenharmony_ci    int32_t tabSize = sizeof(g_callNotifyTab) / sizeof(CallNotify);
21011fccf17Sopenharmony_ci    for (int32_t i = 0; i < tabSize; i++) {
21111fccf17Sopenharmony_ci        if (ReportStrWith(str, g_callNotifyTab[i].cmd)) {
21211fccf17Sopenharmony_ci            g_callNotifyTab[i].function(str);
21311fccf17Sopenharmony_ci            break;
21411fccf17Sopenharmony_ci        }
21511fccf17Sopenharmony_ci    }
21611fccf17Sopenharmony_ci}
21711fccf17Sopenharmony_ci
21811fccf17Sopenharmony_civoid ReportEmergencyNumberList(const char *str)
21911fccf17Sopenharmony_ci{
22011fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
22111fccf17Sopenharmony_ci    char *pStr = (char *)str;
22211fccf17Sopenharmony_ci    HRilEmergencyInfo pEmergencyInfo = {0};
22311fccf17Sopenharmony_ci    ReqDataInfo requestInfo = {0};
22411fccf17Sopenharmony_ci    ModemReportErrorInfo errInfo = InitModemReportErrorInfo();
22511fccf17Sopenharmony_ci
22611fccf17Sopenharmony_ci    if (SkipATPrefix(&pStr) < 0) {
22711fccf17Sopenharmony_ci        err = HRIL_ERR_INVALID_MODEM_PARAMETER;
22811fccf17Sopenharmony_ci    }
22911fccf17Sopenharmony_ci    if (NextInt(&pStr, &pEmergencyInfo.index) < 0) {
23011fccf17Sopenharmony_ci        err = HRIL_ERR_INVALID_MODEM_PARAMETER;
23111fccf17Sopenharmony_ci    }
23211fccf17Sopenharmony_ci    if (NextInt(&pStr, &pEmergencyInfo.total) < 0) {
23311fccf17Sopenharmony_ci        err = HRIL_ERR_INVALID_MODEM_PARAMETER;
23411fccf17Sopenharmony_ci    }
23511fccf17Sopenharmony_ci    if (NextStr(&pStr, &pEmergencyInfo.eccNum) < 0) {
23611fccf17Sopenharmony_ci        err = HRIL_ERR_INVALID_MODEM_PARAMETER;
23711fccf17Sopenharmony_ci    }
23811fccf17Sopenharmony_ci    if (NextInt(&pStr, &pEmergencyInfo.category) < 0) {
23911fccf17Sopenharmony_ci        err = HRIL_ERR_INVALID_MODEM_PARAMETER;
24011fccf17Sopenharmony_ci    }
24111fccf17Sopenharmony_ci    if (NextInt(&pStr, &pEmergencyInfo.simpresent) < 0) {
24211fccf17Sopenharmony_ci        err = HRIL_ERR_INVALID_MODEM_PARAMETER;
24311fccf17Sopenharmony_ci    }
24411fccf17Sopenharmony_ci    if (NextStr(&pStr, &pEmergencyInfo.mcc) < 0) {
24511fccf17Sopenharmony_ci        err = HRIL_ERR_INVALID_MODEM_PARAMETER;
24611fccf17Sopenharmony_ci    }
24711fccf17Sopenharmony_ci    if (NextInt(&pStr, &pEmergencyInfo.abnormalService) < 0) {
24811fccf17Sopenharmony_ci        err = HRIL_ERR_INVALID_MODEM_PARAMETER;
24911fccf17Sopenharmony_ci    }
25011fccf17Sopenharmony_ci
25111fccf17Sopenharmony_ci    struct ReportInfo reportInfo =
25211fccf17Sopenharmony_ci        CreateReportInfo(&requestInfo, err, HRIL_NOTIFICATION, HNOTI_CALL_EMERGENCY_NUMBER_REPORT);
25311fccf17Sopenharmony_ci    reportInfo.modemErrInfo = errInfo;
25411fccf17Sopenharmony_ci    OnCallReport(GetSlotId(NULL), reportInfo, (const uint8_t *)&pEmergencyInfo, sizeof(pEmergencyInfo));
25511fccf17Sopenharmony_ci}
25611fccf17Sopenharmony_ci
25711fccf17Sopenharmony_civoid ReportCallUssdNotice(const char *str)
25811fccf17Sopenharmony_ci{
25911fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
26011fccf17Sopenharmony_ci    char *pStr = (char *)str;
26111fccf17Sopenharmony_ci    HRilUssdNoticeInfo ussdNoticeInfo = {0};
26211fccf17Sopenharmony_ci    ReqDataInfo requestInfo = {0};
26311fccf17Sopenharmony_ci    ModemReportErrorInfo errInfo = InitModemReportErrorInfo();
26411fccf17Sopenharmony_ci
26511fccf17Sopenharmony_ci    if (SkipATPrefix(&pStr) < 0) {
26611fccf17Sopenharmony_ci        err = HRIL_ERR_INVALID_MODEM_PARAMETER;
26711fccf17Sopenharmony_ci    }
26811fccf17Sopenharmony_ci    if (NextInt(&pStr, &ussdNoticeInfo.m) < 0) {
26911fccf17Sopenharmony_ci        err = HRIL_ERR_INVALID_MODEM_PARAMETER;
27011fccf17Sopenharmony_ci    }
27111fccf17Sopenharmony_ci    if (NextStr(&pStr, &ussdNoticeInfo.str) < 0) {
27211fccf17Sopenharmony_ci        err = HRIL_ERR_INVALID_MODEM_PARAMETER;
27311fccf17Sopenharmony_ci    }
27411fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(&requestInfo, err, HRIL_NOTIFICATION, HNOTI_CALL_USSD_REPORT);
27511fccf17Sopenharmony_ci    reportInfo.modemErrInfo = errInfo;
27611fccf17Sopenharmony_ci    OnCallReport(GetSlotId(NULL), reportInfo, (const uint8_t *)&ussdNoticeInfo, sizeof(HRilUssdNoticeInfo));
27711fccf17Sopenharmony_ci}
27811fccf17Sopenharmony_ci
27911fccf17Sopenharmony_cistatic int32_t InitCallListCmdBuffer(const ResponseInfo *pResponse, int32_t *callNum, HRilCallInfo **pCalls)
28011fccf17Sopenharmony_ci{
28111fccf17Sopenharmony_ci    int32_t ret;
28211fccf17Sopenharmony_ci    int32_t callNumTmp = 0;
28311fccf17Sopenharmony_ci    Line *pLine = NULL;
28411fccf17Sopenharmony_ci    HRilCallInfo *pCallsTmp = NULL;
28511fccf17Sopenharmony_ci
28611fccf17Sopenharmony_ci    if (pResponse == NULL || pCalls == NULL || callNum == NULL) {
28711fccf17Sopenharmony_ci        TELEPHONY_LOGE("params: %{public}p,%{public}p,%{public}p", pResponse, callNum, pCalls);
28811fccf17Sopenharmony_ci        return HRIL_ERR_NULL_POINT;
28911fccf17Sopenharmony_ci    }
29011fccf17Sopenharmony_ci
29111fccf17Sopenharmony_ci    *callNum = 0;
29211fccf17Sopenharmony_ci    *pCalls = NULL;
29311fccf17Sopenharmony_ci
29411fccf17Sopenharmony_ci    for (pLine = pResponse->head; pLine != NULL; pLine = pLine->next) {
29511fccf17Sopenharmony_ci        callNumTmp++;
29611fccf17Sopenharmony_ci    }
29711fccf17Sopenharmony_ci    if (!callNumTmp) {
29811fccf17Sopenharmony_ci        callNumTmp++; // Malloc size cannot be 0.
29911fccf17Sopenharmony_ci    }
30011fccf17Sopenharmony_ci    if (callNumTmp > MAX_CALL_NUM) {
30111fccf17Sopenharmony_ci        TELEPHONY_LOGE("callNumTmp is invalid");
30211fccf17Sopenharmony_ci        return HRIL_ERR_INVALID_PARAMETER;
30311fccf17Sopenharmony_ci    }
30411fccf17Sopenharmony_ci    pCallsTmp = (HRilCallInfo *)malloc(callNumTmp * sizeof(HRilCallInfo));
30511fccf17Sopenharmony_ci    if (pCallsTmp == NULL) {
30611fccf17Sopenharmony_ci        TELEPHONY_LOGE("ReqGetCallList malloc pCalls failure");
30711fccf17Sopenharmony_ci        return HRIL_ERR_MEMORY_FULL;
30811fccf17Sopenharmony_ci    }
30911fccf17Sopenharmony_ci    ret = memset_s(pCallsTmp, callNumTmp * sizeof(HRilCallInfo), 0, callNumTmp * sizeof(HRilCallInfo));
31011fccf17Sopenharmony_ci    if (ret != EOK) {
31111fccf17Sopenharmony_ci        TELEPHONY_LOGE("memset_s is failed!");
31211fccf17Sopenharmony_ci        free(pCallsTmp);
31311fccf17Sopenharmony_ci        pCallsTmp = NULL;
31411fccf17Sopenharmony_ci        return ret;
31511fccf17Sopenharmony_ci    }
31611fccf17Sopenharmony_ci
31711fccf17Sopenharmony_ci    *pCalls = pCallsTmp;
31811fccf17Sopenharmony_ci    *callNum = callNumTmp;
31911fccf17Sopenharmony_ci
32011fccf17Sopenharmony_ci    return HRIL_ERR_SUCCESS;
32111fccf17Sopenharmony_ci}
32211fccf17Sopenharmony_ci
32311fccf17Sopenharmony_ciint32_t BuildCallInfoList(const ReqDataInfo *requestInfo, ResponseInfo *response)
32411fccf17Sopenharmony_ci{
32511fccf17Sopenharmony_ci    int32_t ret = 0;
32611fccf17Sopenharmony_ci    int32_t callNum = 0;
32711fccf17Sopenharmony_ci    int32_t validCallNum = 0;
32811fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
32911fccf17Sopenharmony_ci    Line *pLine = NULL;
33011fccf17Sopenharmony_ci    ResponseInfo *pResponse = response;
33111fccf17Sopenharmony_ci    HRilCallInfo *pCalls = NULL;
33211fccf17Sopenharmony_ci
33311fccf17Sopenharmony_ci    if (pResponse == NULL || requestInfo == NULL) {
33411fccf17Sopenharmony_ci        TELEPHONY_LOGE("response or requestInfo is null.");
33511fccf17Sopenharmony_ci        return HRIL_ERR_NULL_POINT;
33611fccf17Sopenharmony_ci    }
33711fccf17Sopenharmony_ci    if (pResponse->success == 0) {
33811fccf17Sopenharmony_ci        TELEPHONY_LOGE("send cmd return ERROR");
33911fccf17Sopenharmony_ci        err = HRIL_ERR_GENERIC_FAILURE;
34011fccf17Sopenharmony_ci    }
34111fccf17Sopenharmony_ci
34211fccf17Sopenharmony_ci    ret = InitCallListCmdBuffer(pResponse, &callNum, &pCalls);
34311fccf17Sopenharmony_ci    if (ret != HRIL_ERR_SUCCESS) {
34411fccf17Sopenharmony_ci        TELEPHONY_LOGE("init command failed: %{public}d", ret);
34511fccf17Sopenharmony_ci        return ret;
34611fccf17Sopenharmony_ci    }
34711fccf17Sopenharmony_ci
34811fccf17Sopenharmony_ci    for (pLine = pResponse->head; pLine != NULL && validCallNum < callNum; pLine = pLine->next) {
34911fccf17Sopenharmony_ci        ret = CallCmdCLCC(pLine->data, pCalls + validCallNum);
35011fccf17Sopenharmony_ci        if (ret != 0) {
35111fccf17Sopenharmony_ci            TELEPHONY_LOGE("Parse CLCC data is fail. ret:%{public}d", ret);
35211fccf17Sopenharmony_ci            continue;
35311fccf17Sopenharmony_ci        }
35411fccf17Sopenharmony_ci        validCallNum++;
35511fccf17Sopenharmony_ci    }
35611fccf17Sopenharmony_ci
35711fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
35811fccf17Sopenharmony_ci    OnCallReport(GetSlotId(requestInfo), reportInfo, (const uint8_t *)pCalls, sizeof(HRilCallInfo) * validCallNum);
35911fccf17Sopenharmony_ci    FreeResponseInfo(pResponse);
36011fccf17Sopenharmony_ci    free(pCalls);
36111fccf17Sopenharmony_ci    return HRIL_ERR_SUCCESS;
36211fccf17Sopenharmony_ci}
36311fccf17Sopenharmony_ci
36411fccf17Sopenharmony_civoid ReqGetCallList(const ReqDataInfo *requestInfo)
36511fccf17Sopenharmony_ci{
36611fccf17Sopenharmony_ci    int32_t ret;
36711fccf17Sopenharmony_ci    ResponseInfo *pResponse = NULL;
36811fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
36911fccf17Sopenharmony_ci    long timeOut = DEFAULT_TIMEOUT;
37011fccf17Sopenharmony_ci
37111fccf17Sopenharmony_ci    ret = SendCommandLock("AT+CLCC", "+CLCC:", timeOut, &pResponse);
37211fccf17Sopenharmony_ci    if (ret || (pResponse != NULL && !pResponse->success)) {
37311fccf17Sopenharmony_ci        err = ret ? ret : err;
37411fccf17Sopenharmony_ci        TELEPHONY_LOGE("cmd send failed, err:%{public}d", err);
37511fccf17Sopenharmony_ci        if (err < HRIL_ERR_SUCCESS) {
37611fccf17Sopenharmony_ci            err = HRIL_ERR_GENERIC_FAILURE;
37711fccf17Sopenharmony_ci        }
37811fccf17Sopenharmony_ci        OnCallReportErrorMessages(requestInfo, err, pResponse);
37911fccf17Sopenharmony_ci        return;
38011fccf17Sopenharmony_ci    }
38111fccf17Sopenharmony_ci    err = BuildCallInfoList(requestInfo, pResponse);
38211fccf17Sopenharmony_ci    if (err != HRIL_ERR_SUCCESS) {
38311fccf17Sopenharmony_ci        if (err < HRIL_ERR_SUCCESS) {
38411fccf17Sopenharmony_ci            err = HRIL_ERR_GENERIC_FAILURE;
38511fccf17Sopenharmony_ci        }
38611fccf17Sopenharmony_ci        TELEPHONY_LOGE("Build Call Info List is failed.");
38711fccf17Sopenharmony_ci        OnCallReportErrorMessages(requestInfo, err, pResponse);
38811fccf17Sopenharmony_ci    }
38911fccf17Sopenharmony_ci}
39011fccf17Sopenharmony_ci
39111fccf17Sopenharmony_civoid ReqDial(const ReqDataInfo *requestInfo, const HRilDial *data, size_t dataLen)
39211fccf17Sopenharmony_ci{
39311fccf17Sopenharmony_ci    HRilDial *pDial = NULL;
39411fccf17Sopenharmony_ci    char cmd[MAX_CMD_LENGTH] = {0};
39511fccf17Sopenharmony_ci    const char *clir = NULL;
39611fccf17Sopenharmony_ci    int32_t ret;
39711fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
39811fccf17Sopenharmony_ci    ResponseInfo *pResponse = NULL;
39911fccf17Sopenharmony_ci
40011fccf17Sopenharmony_ci    if (data == NULL) {
40111fccf17Sopenharmony_ci        TELEPHONY_LOGE("data is null!!!");
40211fccf17Sopenharmony_ci        return;
40311fccf17Sopenharmony_ci    }
40411fccf17Sopenharmony_ci
40511fccf17Sopenharmony_ci    pDial = (HRilDial *)data;
40611fccf17Sopenharmony_ci    switch (pDial->clir) {
40711fccf17Sopenharmony_ci        case CALL_CLIR_INVOCATION:
40811fccf17Sopenharmony_ci            clir = "I";
40911fccf17Sopenharmony_ci            break; /* invocation */
41011fccf17Sopenharmony_ci        case CALL_CLIR_SUPPRESSION:
41111fccf17Sopenharmony_ci            clir = "i";
41211fccf17Sopenharmony_ci            break; /* suppression */
41311fccf17Sopenharmony_ci        case CALL_CLIR_SUBSCRIPTION_DEFAULT:
41411fccf17Sopenharmony_ci        default:
41511fccf17Sopenharmony_ci            clir = "";
41611fccf17Sopenharmony_ci            break; /* subscription default */
41711fccf17Sopenharmony_ci    }
41811fccf17Sopenharmony_ci
41911fccf17Sopenharmony_ci    ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "ATD%s%s;", pDial->address, clir);
42011fccf17Sopenharmony_ci    if (ret < 0) {
42111fccf17Sopenharmony_ci        TELEPHONY_LOGE("GenerateCommand is failed!");
42211fccf17Sopenharmony_ci        OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
42311fccf17Sopenharmony_ci        return;
42411fccf17Sopenharmony_ci    }
42511fccf17Sopenharmony_ci    ret = SendCommandLock(cmd, NULL, 0, &pResponse);
42611fccf17Sopenharmony_ci    if (ret != 0) {
42711fccf17Sopenharmony_ci        err = HRIL_ERR_CMD_SEND_FAILURE;
42811fccf17Sopenharmony_ci        TELEPHONY_LOGE("ATD send failed");
42911fccf17Sopenharmony_ci    } else {
43011fccf17Sopenharmony_ci        if (pResponse == NULL || !pResponse->success) {
43111fccf17Sopenharmony_ci            TELEPHONY_LOGE("ReqDial return ERROR");
43211fccf17Sopenharmony_ci            err = HRIL_ERR_CMD_NO_CARRIER;
43311fccf17Sopenharmony_ci        }
43411fccf17Sopenharmony_ci    }
43511fccf17Sopenharmony_ci
43611fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
43711fccf17Sopenharmony_ci    OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
43811fccf17Sopenharmony_ci    FreeResponseInfo(pResponse);
43911fccf17Sopenharmony_ci}
44011fccf17Sopenharmony_ci
44111fccf17Sopenharmony_civoid ReqHangup(const ReqDataInfo *requestInfo, const uint32_t *data, size_t dataLen)
44211fccf17Sopenharmony_ci{
44311fccf17Sopenharmony_ci    const int32_t *pLine = NULL;
44411fccf17Sopenharmony_ci    int32_t ret;
44511fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
44611fccf17Sopenharmony_ci    char cmd[MAX_CMD_LENGTH] = {0};
44711fccf17Sopenharmony_ci    ResponseInfo *pResponse = NULL;
44811fccf17Sopenharmony_ci
44911fccf17Sopenharmony_ci    if (data == NULL) {
45011fccf17Sopenharmony_ci        TELEPHONY_LOGE("data is null!!!");
45111fccf17Sopenharmony_ci        return;
45211fccf17Sopenharmony_ci    }
45311fccf17Sopenharmony_ci    pLine = (const int32_t *)data;
45411fccf17Sopenharmony_ci    ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT+CHLD=1%d", pLine[0]);
45511fccf17Sopenharmony_ci    if (ret < 0) {
45611fccf17Sopenharmony_ci        TELEPHONY_LOGE("GenerateCommand is failed!");
45711fccf17Sopenharmony_ci        OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
45811fccf17Sopenharmony_ci        return;
45911fccf17Sopenharmony_ci    }
46011fccf17Sopenharmony_ci    ret = SendCommandLock(cmd, NULL, 0, &pResponse);
46111fccf17Sopenharmony_ci    if (ret != HRIL_ERR_SUCCESS || pResponse == NULL || !pResponse->success) {
46211fccf17Sopenharmony_ci        TELEPHONY_LOGE("AT+CHLD send failed");
46311fccf17Sopenharmony_ci        err = HRIL_ERR_GENERIC_FAILURE;
46411fccf17Sopenharmony_ci    }
46511fccf17Sopenharmony_ci
46611fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
46711fccf17Sopenharmony_ci    OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
46811fccf17Sopenharmony_ci    FreeResponseInfo(pResponse);
46911fccf17Sopenharmony_ci}
47011fccf17Sopenharmony_ci
47111fccf17Sopenharmony_civoid ReqReject(const ReqDataInfo *requestInfo)
47211fccf17Sopenharmony_ci{
47311fccf17Sopenharmony_ci    ResponseInfo *pResponse = NULL;
47411fccf17Sopenharmony_ci    int32_t ret;
47511fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
47611fccf17Sopenharmony_ci
47711fccf17Sopenharmony_ci    ret = SendCommandLock("ATH", NULL, 0, &pResponse);
47811fccf17Sopenharmony_ci    if (ret != HRIL_ERR_SUCCESS || pResponse == NULL || !pResponse->success) {
47911fccf17Sopenharmony_ci        TELEPHONY_LOGE("ATH send failed");
48011fccf17Sopenharmony_ci        err = HRIL_ERR_GENERIC_FAILURE;
48111fccf17Sopenharmony_ci    }
48211fccf17Sopenharmony_ci
48311fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
48411fccf17Sopenharmony_ci    OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
48511fccf17Sopenharmony_ci    FreeResponseInfo(pResponse);
48611fccf17Sopenharmony_ci}
48711fccf17Sopenharmony_ci
48811fccf17Sopenharmony_civoid ReqAnswer(const ReqDataInfo *requestInfo)
48911fccf17Sopenharmony_ci{
49011fccf17Sopenharmony_ci    int32_t ret;
49111fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
49211fccf17Sopenharmony_ci    ResponseInfo *pResponse = NULL;
49311fccf17Sopenharmony_ci
49411fccf17Sopenharmony_ci    ret = SendCommandLock("ATA", NULL, 0, &pResponse);
49511fccf17Sopenharmony_ci    if (ret != HRIL_ERR_SUCCESS || pResponse == NULL || !pResponse->success) {
49611fccf17Sopenharmony_ci        err = HRIL_ERR_GENERIC_FAILURE;
49711fccf17Sopenharmony_ci    }
49811fccf17Sopenharmony_ci
49911fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
50011fccf17Sopenharmony_ci    OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
50111fccf17Sopenharmony_ci    FreeResponseInfo(pResponse);
50211fccf17Sopenharmony_ci}
50311fccf17Sopenharmony_ci
50411fccf17Sopenharmony_ci// Calling line identification presentation
50511fccf17Sopenharmony_civoid ReqGetClip(const ReqDataInfo *requestInfo)
50611fccf17Sopenharmony_ci{
50711fccf17Sopenharmony_ci    HRilGetClipResult result = {0};
50811fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
50911fccf17Sopenharmony_ci    ResponseInfo *pResponse = NULL;
51011fccf17Sopenharmony_ci
51111fccf17Sopenharmony_ci    err = SendCommandLock("AT+CLIP?", "+CLIP", 0, &pResponse);
51211fccf17Sopenharmony_ci    if (err == HRIL_ERR_SUCCESS) {
51311fccf17Sopenharmony_ci        if (pResponse == NULL || !pResponse->success) {
51411fccf17Sopenharmony_ci            TELEPHONY_LOGE("CLIP return ERROR");
51511fccf17Sopenharmony_ci            err = HRIL_ERR_GENERIC_FAILURE;
51611fccf17Sopenharmony_ci        } else {
51711fccf17Sopenharmony_ci            if (pResponse->head != NULL) {
51811fccf17Sopenharmony_ci                char *line = pResponse->head->data;
51911fccf17Sopenharmony_ci                SkipATPrefix(&line);
52011fccf17Sopenharmony_ci                NextInt(&line, &result.action);
52111fccf17Sopenharmony_ci                NextInt(&line, &result.clipStat);
52211fccf17Sopenharmony_ci            } else {
52311fccf17Sopenharmony_ci                TELEPHONY_LOGE("ERROR: ReqGetClip pResponse->head is null");
52411fccf17Sopenharmony_ci                err = HRIL_ERR_GENERIC_FAILURE;
52511fccf17Sopenharmony_ci            }
52611fccf17Sopenharmony_ci        }
52711fccf17Sopenharmony_ci        struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
52811fccf17Sopenharmony_ci        OnCallReport(GetSlotId(requestInfo), reportInfo, (const uint8_t *)&result, sizeof(result));
52911fccf17Sopenharmony_ci        FreeResponseInfo(pResponse);
53011fccf17Sopenharmony_ci    } else {
53111fccf17Sopenharmony_ci        TELEPHONY_LOGE("ReqGetClip send failed");
53211fccf17Sopenharmony_ci        struct ReportInfo reportInfo = CreateReportInfo(requestInfo, HRIL_ERR_CMD_SEND_FAILURE, HRIL_RESPONSE, 0);
53311fccf17Sopenharmony_ci        OnCallReport(GetSlotId(requestInfo), reportInfo, (const uint8_t *)&result, 0);
53411fccf17Sopenharmony_ci    }
53511fccf17Sopenharmony_ci}
53611fccf17Sopenharmony_ci
53711fccf17Sopenharmony_civoid ReqSetClip(const ReqDataInfo *requestInfo, int32_t action)
53811fccf17Sopenharmony_ci{
53911fccf17Sopenharmony_ci    char cmd[MAX_CMD_LENGTH] = {0};
54011fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
54111fccf17Sopenharmony_ci    ResponseInfo *pResponse = NULL;
54211fccf17Sopenharmony_ci
54311fccf17Sopenharmony_ci    int32_t ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT+CLIP=%d", action);
54411fccf17Sopenharmony_ci    if (ret < 0) {
54511fccf17Sopenharmony_ci        TELEPHONY_LOGE("GenerateCommand is failed!");
54611fccf17Sopenharmony_ci        OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
54711fccf17Sopenharmony_ci        return;
54811fccf17Sopenharmony_ci    }
54911fccf17Sopenharmony_ci    err = SendCommandLock(cmd, NULL, 0, &pResponse);
55011fccf17Sopenharmony_ci    if (err == HRIL_ERR_SUCCESS) {
55111fccf17Sopenharmony_ci        if (pResponse == NULL || !pResponse->success) {
55211fccf17Sopenharmony_ci            TELEPHONY_LOGE("ReqSetClip return ERROR");
55311fccf17Sopenharmony_ci            err = HRIL_ERR_GENERIC_FAILURE;
55411fccf17Sopenharmony_ci        }
55511fccf17Sopenharmony_ci
55611fccf17Sopenharmony_ci        FreeResponseInfo(pResponse);
55711fccf17Sopenharmony_ci    } else {
55811fccf17Sopenharmony_ci        TELEPHONY_LOGE("ReqSetClip send failed");
55911fccf17Sopenharmony_ci        err = HRIL_ERR_GENERIC_FAILURE;
56011fccf17Sopenharmony_ci    }
56111fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
56211fccf17Sopenharmony_ci    OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
56311fccf17Sopenharmony_ci}
56411fccf17Sopenharmony_ci
56511fccf17Sopenharmony_civoid ReqGetClir(const ReqDataInfo *requestInfo)
56611fccf17Sopenharmony_ci{
56711fccf17Sopenharmony_ci    HRilGetCallClirResult result = {0};
56811fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
56911fccf17Sopenharmony_ci    ResponseInfo *pResponse = NULL;
57011fccf17Sopenharmony_ci
57111fccf17Sopenharmony_ci    err = SendCommandLock("AT+CLIR?", "+CLIR", 0, &pResponse);
57211fccf17Sopenharmony_ci    if (err == HRIL_ERR_SUCCESS) {
57311fccf17Sopenharmony_ci        if (pResponse == NULL || !pResponse->success) {
57411fccf17Sopenharmony_ci            TELEPHONY_LOGE("CLIR return ERROR");
57511fccf17Sopenharmony_ci            err = HRIL_ERR_GENERIC_FAILURE;
57611fccf17Sopenharmony_ci        } else {
57711fccf17Sopenharmony_ci            if (pResponse->head != NULL) {
57811fccf17Sopenharmony_ci                char *line = pResponse->head->data;
57911fccf17Sopenharmony_ci                SkipATPrefix(&line);
58011fccf17Sopenharmony_ci                NextInt(&line, &result.action);
58111fccf17Sopenharmony_ci                NextInt(&line, &result.clirStat);
58211fccf17Sopenharmony_ci            } else {
58311fccf17Sopenharmony_ci                TELEPHONY_LOGE("ERROR: ReqGetClir pResponse->head is null");
58411fccf17Sopenharmony_ci                err = HRIL_ERR_GENERIC_FAILURE;
58511fccf17Sopenharmony_ci            }
58611fccf17Sopenharmony_ci        }
58711fccf17Sopenharmony_ci        struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
58811fccf17Sopenharmony_ci        OnCallReport(GetSlotId(requestInfo), reportInfo, (const uint8_t *)&result, sizeof(result));
58911fccf17Sopenharmony_ci        FreeResponseInfo(pResponse);
59011fccf17Sopenharmony_ci    } else {
59111fccf17Sopenharmony_ci        TELEPHONY_LOGE("ReqGetClir send failed");
59211fccf17Sopenharmony_ci        err = HRIL_ERR_CMD_SEND_FAILURE;
59311fccf17Sopenharmony_ci        OnCallReportErrorMessages(requestInfo, err, pResponse);
59411fccf17Sopenharmony_ci    }
59511fccf17Sopenharmony_ci}
59611fccf17Sopenharmony_ci
59711fccf17Sopenharmony_civoid ReqSetClir(const ReqDataInfo *requestInfo, int32_t action)
59811fccf17Sopenharmony_ci{
59911fccf17Sopenharmony_ci    char cmd[MAX_CMD_LENGTH] = {0};
60011fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
60111fccf17Sopenharmony_ci    ResponseInfo *pResponse = NULL;
60211fccf17Sopenharmony_ci
60311fccf17Sopenharmony_ci    int32_t ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT+CLIR=%d", action);
60411fccf17Sopenharmony_ci    if (ret < 0) {
60511fccf17Sopenharmony_ci        TELEPHONY_LOGE("GenerateCommand is failed!");
60611fccf17Sopenharmony_ci        OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
60711fccf17Sopenharmony_ci        return;
60811fccf17Sopenharmony_ci    }
60911fccf17Sopenharmony_ci    err = SendCommandLock(cmd, NULL, 0, &pResponse);
61011fccf17Sopenharmony_ci    if (err != HRIL_ERR_SUCCESS || pResponse == NULL || !pResponse->success) {
61111fccf17Sopenharmony_ci        TELEPHONY_LOGE("ReqSetClir send failed");
61211fccf17Sopenharmony_ci        err = HRIL_ERR_GENERIC_FAILURE;
61311fccf17Sopenharmony_ci    }
61411fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
61511fccf17Sopenharmony_ci    OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
61611fccf17Sopenharmony_ci    FreeResponseInfo(pResponse);
61711fccf17Sopenharmony_ci}
61811fccf17Sopenharmony_ci
61911fccf17Sopenharmony_civoid ReqStartDtmf(const ReqDataInfo *requestInfo, CallDtmfInfo info)
62011fccf17Sopenharmony_ci{
62111fccf17Sopenharmony_ci    char cmd[MAX_CMD_LENGTH] = {0};
62211fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
62311fccf17Sopenharmony_ci    ResponseInfo *pResponse = NULL;
62411fccf17Sopenharmony_ci
62511fccf17Sopenharmony_ci    int32_t ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT^DTMF=%d,%c,1,0", info.callId, info.dtmfKey[0]);
62611fccf17Sopenharmony_ci    if (ret < 0) {
62711fccf17Sopenharmony_ci        TELEPHONY_LOGE("GenerateCommand is failed!");
62811fccf17Sopenharmony_ci        OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
62911fccf17Sopenharmony_ci        return;
63011fccf17Sopenharmony_ci    }
63111fccf17Sopenharmony_ci    err = SendCommandLock(cmd, NULL, 0, &pResponse);
63211fccf17Sopenharmony_ci    if (err != HRIL_ERR_SUCCESS || pResponse == NULL || !pResponse->success) {
63311fccf17Sopenharmony_ci        TELEPHONY_LOGE("ReqStartDtmf send failed");
63411fccf17Sopenharmony_ci        err = HRIL_ERR_GENERIC_FAILURE;
63511fccf17Sopenharmony_ci    }
63611fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
63711fccf17Sopenharmony_ci    OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
63811fccf17Sopenharmony_ci    FreeResponseInfo(pResponse);
63911fccf17Sopenharmony_ci}
64011fccf17Sopenharmony_ci
64111fccf17Sopenharmony_civoid ReqSendDtmf(const ReqDataInfo *requestInfo, CallDtmfInfo info)
64211fccf17Sopenharmony_ci{
64311fccf17Sopenharmony_ci    char cmd[MAX_CMD_LENGTH] = {0};
64411fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
64511fccf17Sopenharmony_ci    ResponseInfo *pResponse = NULL;
64611fccf17Sopenharmony_ci    int32_t stringLength = 0;
64711fccf17Sopenharmony_ci    int32_t ret;
64811fccf17Sopenharmony_ci
64911fccf17Sopenharmony_ci    if (info.dtmfKey == NULL) {
65011fccf17Sopenharmony_ci        err = HRIL_ERR_NULL_POINT;
65111fccf17Sopenharmony_ci        OnCallReportErrorMessages(requestInfo, err, NULL);
65211fccf17Sopenharmony_ci        return;
65311fccf17Sopenharmony_ci    }
65411fccf17Sopenharmony_ci
65511fccf17Sopenharmony_ci    for (stringLength = 0; stringLength < info.stringLength; stringLength++) {
65611fccf17Sopenharmony_ci        ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT^DTMF=%d,%c,%d,%d", info.callId, info.dtmfKey[stringLength],
65711fccf17Sopenharmony_ci            info.onLength, info.offLength);
65811fccf17Sopenharmony_ci        if (ret < 0) {
65911fccf17Sopenharmony_ci            TELEPHONY_LOGE("GenerateCommand is failed!");
66011fccf17Sopenharmony_ci            continue;
66111fccf17Sopenharmony_ci        }
66211fccf17Sopenharmony_ci        err = SendCommandLock(cmd, NULL, 0, &pResponse);
66311fccf17Sopenharmony_ci        if (err != HRIL_ERR_SUCCESS || pResponse == NULL || !pResponse->success) {
66411fccf17Sopenharmony_ci            TELEPHONY_LOGE("ReqSendDtmf send failed");
66511fccf17Sopenharmony_ci            err = HRIL_ERR_GENERIC_FAILURE;
66611fccf17Sopenharmony_ci            break;
66711fccf17Sopenharmony_ci        }
66811fccf17Sopenharmony_ci    }
66911fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
67011fccf17Sopenharmony_ci    OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
67111fccf17Sopenharmony_ci    FreeResponseInfo(pResponse);
67211fccf17Sopenharmony_ci}
67311fccf17Sopenharmony_ci
67411fccf17Sopenharmony_civoid ReqStopDtmf(const ReqDataInfo *requestInfo, CallDtmfInfo info)
67511fccf17Sopenharmony_ci{
67611fccf17Sopenharmony_ci    char cmd[MAX_CMD_LENGTH] = {0};
67711fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
67811fccf17Sopenharmony_ci    ResponseInfo *pResponse = NULL;
67911fccf17Sopenharmony_ci
68011fccf17Sopenharmony_ci    int32_t ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT^DTMF=%d,%c,0,0", info.callId, info.dtmfKey[0]);
68111fccf17Sopenharmony_ci    if (ret < 0) {
68211fccf17Sopenharmony_ci        TELEPHONY_LOGE("GenerateCommand is failed!");
68311fccf17Sopenharmony_ci        OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
68411fccf17Sopenharmony_ci        return;
68511fccf17Sopenharmony_ci    }
68611fccf17Sopenharmony_ci    err = SendCommandLock(cmd, NULL, 0, &pResponse);
68711fccf17Sopenharmony_ci    if (err != HRIL_ERR_SUCCESS || pResponse == NULL || !pResponse->success) {
68811fccf17Sopenharmony_ci        TELEPHONY_LOGE("ReqStopDtmf send failed");
68911fccf17Sopenharmony_ci        err = HRIL_ERR_GENERIC_FAILURE;
69011fccf17Sopenharmony_ci    }
69111fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
69211fccf17Sopenharmony_ci    OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
69311fccf17Sopenharmony_ci    FreeResponseInfo(pResponse);
69411fccf17Sopenharmony_ci}
69511fccf17Sopenharmony_ci
69611fccf17Sopenharmony_cistatic void HoldCallAndUnHoldCallAtSend(const ReqDataInfo *requestInfo)
69711fccf17Sopenharmony_ci{
69811fccf17Sopenharmony_ci    int32_t ret;
69911fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
70011fccf17Sopenharmony_ci    ResponseInfo *pResponse = NULL;
70111fccf17Sopenharmony_ci
70211fccf17Sopenharmony_ci    ret = SendCommandLock("AT+CHLD=2", NULL, 0, &pResponse);
70311fccf17Sopenharmony_ci    if (ret != HRIL_ERR_SUCCESS || pResponse == NULL || !pResponse->success) {
70411fccf17Sopenharmony_ci        TELEPHONY_LOGE("ATA send failed");
70511fccf17Sopenharmony_ci        err = HRIL_ERR_GENERIC_FAILURE;
70611fccf17Sopenharmony_ci    }
70711fccf17Sopenharmony_ci
70811fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
70911fccf17Sopenharmony_ci    OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
71011fccf17Sopenharmony_ci    FreeResponseInfo(pResponse);
71111fccf17Sopenharmony_ci}
71211fccf17Sopenharmony_ci
71311fccf17Sopenharmony_civoid ReqHoldCall(const ReqDataInfo *requestInfo)
71411fccf17Sopenharmony_ci{
71511fccf17Sopenharmony_ci    HoldCallAndUnHoldCallAtSend(requestInfo);
71611fccf17Sopenharmony_ci}
71711fccf17Sopenharmony_ci
71811fccf17Sopenharmony_civoid ReqUnHoldCall(const ReqDataInfo *requestInfo)
71911fccf17Sopenharmony_ci{
72011fccf17Sopenharmony_ci    HoldCallAndUnHoldCallAtSend(requestInfo);
72111fccf17Sopenharmony_ci}
72211fccf17Sopenharmony_ci
72311fccf17Sopenharmony_civoid ReqSwitchCall(const ReqDataInfo *requestInfo)
72411fccf17Sopenharmony_ci{
72511fccf17Sopenharmony_ci    HoldCallAndUnHoldCallAtSend(requestInfo);
72611fccf17Sopenharmony_ci}
72711fccf17Sopenharmony_ci
72811fccf17Sopenharmony_civoid ReqCombineConference(const ReqDataInfo *requestInfo, int32_t callType)
72911fccf17Sopenharmony_ci{
73011fccf17Sopenharmony_ci    char cmd[MAX_CMD_LENGTH] = {0};
73111fccf17Sopenharmony_ci    int32_t ret = 0;
73211fccf17Sopenharmony_ci    int32_t count = 3;
73311fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
73411fccf17Sopenharmony_ci
73511fccf17Sopenharmony_ci    /* call type
73611fccf17Sopenharmony_ci     * 0: Voice call
73711fccf17Sopenharmony_ci     * 1: Video call: send one-way video, two-way voice
73811fccf17Sopenharmony_ci     * 2: Video call: one-way receiving video, two-way voice
73911fccf17Sopenharmony_ci     * 3: Video call: two-way video, two-way voice
74011fccf17Sopenharmony_ci     */
74111fccf17Sopenharmony_ci    ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT+CHLD=3");
74211fccf17Sopenharmony_ci    if (ret < 0) {
74311fccf17Sopenharmony_ci        TELEPHONY_LOGE("GenerateCommand is failed!");
74411fccf17Sopenharmony_ci        OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
74511fccf17Sopenharmony_ci        return;
74611fccf17Sopenharmony_ci    }
74711fccf17Sopenharmony_ci    // "Adds a held call to the conversation"
74811fccf17Sopenharmony_ci    if (callType >= 0 && callType <= count) {
74911fccf17Sopenharmony_ci        long timeout = DEFAULT_TIMEOUT;
75011fccf17Sopenharmony_ci        ret = SendCommandLock(cmd, NULL, timeout, NULL);
75111fccf17Sopenharmony_ci        if (ret != HRIL_ERR_SUCCESS) {
75211fccf17Sopenharmony_ci            TELEPHONY_LOGE("ATA send failed");
75311fccf17Sopenharmony_ci            err = HRIL_ERR_CMD_SEND_FAILURE;
75411fccf17Sopenharmony_ci        }
75511fccf17Sopenharmony_ci    } else {
75611fccf17Sopenharmony_ci        TELEPHONY_LOGE("onRequest HREQ_CALL_COMBINE_CONFERENCE args error!!! \n");
75711fccf17Sopenharmony_ci        err = HRIL_ERR_INVALID_PARAMETER;
75811fccf17Sopenharmony_ci    }
75911fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
76011fccf17Sopenharmony_ci    OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
76111fccf17Sopenharmony_ci}
76211fccf17Sopenharmony_ci
76311fccf17Sopenharmony_civoid ReqSeparateConference(const ReqDataInfo *requestInfo, int32_t callIndex, int32_t callType)
76411fccf17Sopenharmony_ci{
76511fccf17Sopenharmony_ci    char cmd[MAX_CMD_LENGTH] = {0};
76611fccf17Sopenharmony_ci    int32_t ret = 0;
76711fccf17Sopenharmony_ci    int32_t count = 3;
76811fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
76911fccf17Sopenharmony_ci    ResponseInfo *pResponse = NULL;
77011fccf17Sopenharmony_ci
77111fccf17Sopenharmony_ci    // Make sure that party is in a valid range.
77211fccf17Sopenharmony_ci    // (Note: The Telephony middle layer imposes a range of 1 to 7.
77311fccf17Sopenharmony_ci    // It's sufficient for us to just make sure it's single digit.)
77411fccf17Sopenharmony_ci    if ((callIndex > 0) && (callType >= 0 && callType <= count)) {
77511fccf17Sopenharmony_ci        ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT+CHLD=2%d", callIndex);
77611fccf17Sopenharmony_ci        if (ret < 0) {
77711fccf17Sopenharmony_ci            TELEPHONY_LOGE("GenerateCommand is failed!");
77811fccf17Sopenharmony_ci            OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
77911fccf17Sopenharmony_ci            return;
78011fccf17Sopenharmony_ci        }
78111fccf17Sopenharmony_ci        ret = SendCommandLock(cmd, NULL, 0, &pResponse);
78211fccf17Sopenharmony_ci        if (ret != HRIL_ERR_SUCCESS) {
78311fccf17Sopenharmony_ci            TELEPHONY_LOGE("ATA send failed");
78411fccf17Sopenharmony_ci            err = HRIL_ERR_CMD_SEND_FAILURE;
78511fccf17Sopenharmony_ci        } else {
78611fccf17Sopenharmony_ci            if (pResponse == NULL || !pResponse->success) {
78711fccf17Sopenharmony_ci                TELEPHONY_LOGE("ATA send failed");
78811fccf17Sopenharmony_ci                err = HRIL_ERR_GENERIC_FAILURE;
78911fccf17Sopenharmony_ci            }
79011fccf17Sopenharmony_ci        }
79111fccf17Sopenharmony_ci    } else {
79211fccf17Sopenharmony_ci        TELEPHONY_LOGE("onRequest req split args error!!!");
79311fccf17Sopenharmony_ci        err = HRIL_ERR_INVALID_PARAMETER;
79411fccf17Sopenharmony_ci    }
79511fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
79611fccf17Sopenharmony_ci    OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
79711fccf17Sopenharmony_ci    FreeResponseInfo(pResponse);
79811fccf17Sopenharmony_ci}
79911fccf17Sopenharmony_ci
80011fccf17Sopenharmony_civoid ReqCallSupplement(const ReqDataInfo *requestInfo, int32_t type)
80111fccf17Sopenharmony_ci{
80211fccf17Sopenharmony_ci    char cmd[MAX_CMD_LENGTH] = {0};
80311fccf17Sopenharmony_ci    int32_t ret = 0;
80411fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
80511fccf17Sopenharmony_ci    ResponseInfo *pResponse = NULL;
80611fccf17Sopenharmony_ci
80711fccf17Sopenharmony_ci    switch (type) {
80811fccf17Sopenharmony_ci        case TYPE_HANG_UP_HOLD_WAIT: {
80911fccf17Sopenharmony_ci            ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT+CHLD=0");
81011fccf17Sopenharmony_ci            if (ret < 0) {
81111fccf17Sopenharmony_ci                TELEPHONY_LOGE("GenerateCommand is failed!");
81211fccf17Sopenharmony_ci                OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
81311fccf17Sopenharmony_ci                return;
81411fccf17Sopenharmony_ci            }
81511fccf17Sopenharmony_ci            break;
81611fccf17Sopenharmony_ci        }
81711fccf17Sopenharmony_ci        case TYPE_HANG_UP_ACTIVE: {
81811fccf17Sopenharmony_ci            ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT+CHLD=1");
81911fccf17Sopenharmony_ci            if (ret < 0) {
82011fccf17Sopenharmony_ci                TELEPHONY_LOGE("GenerateCommand is failed!");
82111fccf17Sopenharmony_ci                OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
82211fccf17Sopenharmony_ci                return;
82311fccf17Sopenharmony_ci            }
82411fccf17Sopenharmony_ci            break;
82511fccf17Sopenharmony_ci        }
82611fccf17Sopenharmony_ci        default: {
82711fccf17Sopenharmony_ci            TELEPHONY_LOGW("ReqCallSupplement warring, type is invalid");
82811fccf17Sopenharmony_ci            struct ReportInfo reportInfo = CreateReportInfo(requestInfo, HRIL_ERR_INVALID_PARAMETER, HRIL_RESPONSE, 0);
82911fccf17Sopenharmony_ci            OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
83011fccf17Sopenharmony_ci            FreeResponseInfo(pResponse);
83111fccf17Sopenharmony_ci            return;
83211fccf17Sopenharmony_ci        }
83311fccf17Sopenharmony_ci    }
83411fccf17Sopenharmony_ci
83511fccf17Sopenharmony_ci    const long timeout = 3000;
83611fccf17Sopenharmony_ci    ret = SendCommandLock(cmd, NULL, timeout, &pResponse);
83711fccf17Sopenharmony_ci    if (ret != HRIL_ERR_SUCCESS) {
83811fccf17Sopenharmony_ci        TELEPHONY_LOGE("ReqCallSupplement cmd send failed");
83911fccf17Sopenharmony_ci        err = HRIL_ERR_CMD_SEND_FAILURE;
84011fccf17Sopenharmony_ci    } else {
84111fccf17Sopenharmony_ci        if (pResponse == NULL || !pResponse->success) {
84211fccf17Sopenharmony_ci            TELEPHONY_LOGE("cmd send return error");
84311fccf17Sopenharmony_ci            err = HRIL_ERR_GENERIC_FAILURE;
84411fccf17Sopenharmony_ci        }
84511fccf17Sopenharmony_ci    }
84611fccf17Sopenharmony_ci
84711fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
84811fccf17Sopenharmony_ci    OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
84911fccf17Sopenharmony_ci    FreeResponseInfo(pResponse);
85011fccf17Sopenharmony_ci}
85111fccf17Sopenharmony_ci
85211fccf17Sopenharmony_civoid ReqGetCallWaiting(const ReqDataInfo *requestInfo)
85311fccf17Sopenharmony_ci{
85411fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
85511fccf17Sopenharmony_ci    ResponseInfo *pResponse = NULL;
85611fccf17Sopenharmony_ci    HRilCallWaitResult hrilCallWaitResult = {0};
85711fccf17Sopenharmony_ci    char *line = NULL;
85811fccf17Sopenharmony_ci    const long timeout = 80000;
85911fccf17Sopenharmony_ci    err = SendCommandLock("AT+CCWA=1,2,1", "+CCWA:", timeout, &pResponse);
86011fccf17Sopenharmony_ci    if (err != HRIL_ERR_SUCCESS) {
86111fccf17Sopenharmony_ci        TELEPHONY_LOGE("ReqGetCallWaiting return, CCWA send failed");
86211fccf17Sopenharmony_ci        err = HRIL_ERR_CMD_SEND_FAILURE;
86311fccf17Sopenharmony_ci        struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
86411fccf17Sopenharmony_ci        OnCallReport(
86511fccf17Sopenharmony_ci            GetSlotId(requestInfo), reportInfo, (const uint8_t *)&hrilCallWaitResult, sizeof(HRilCallWaitResult));
86611fccf17Sopenharmony_ci        return;
86711fccf17Sopenharmony_ci    }
86811fccf17Sopenharmony_ci    if (pResponse == NULL || !pResponse->success) {
86911fccf17Sopenharmony_ci        TELEPHONY_LOGE("Get CCWA return ERROR");
87011fccf17Sopenharmony_ci        err = HRIL_ERR_GENERIC_FAILURE;
87111fccf17Sopenharmony_ci    } else {
87211fccf17Sopenharmony_ci        if (pResponse->head != NULL) {
87311fccf17Sopenharmony_ci            line = pResponse->head->data;
87411fccf17Sopenharmony_ci            SkipATPrefix(&line);
87511fccf17Sopenharmony_ci            NextInt(&line, &hrilCallWaitResult.status);
87611fccf17Sopenharmony_ci            NextInt(&line, &hrilCallWaitResult.classCw);
87711fccf17Sopenharmony_ci        } else {
87811fccf17Sopenharmony_ci            TELEPHONY_LOGE("ERROR: ReqGetCallWaiting pResponse->head is null");
87911fccf17Sopenharmony_ci            err = HRIL_ERR_GENERIC_FAILURE;
88011fccf17Sopenharmony_ci        }
88111fccf17Sopenharmony_ci    }
88211fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
88311fccf17Sopenharmony_ci    OnCallReport(GetSlotId(requestInfo), reportInfo, (const uint8_t *)&hrilCallWaitResult, sizeof(HRilCallWaitResult));
88411fccf17Sopenharmony_ci    FreeResponseInfo(pResponse);
88511fccf17Sopenharmony_ci}
88611fccf17Sopenharmony_ci
88711fccf17Sopenharmony_civoid ReqSetCallWaiting(const ReqDataInfo *requestInfo, int32_t active)
88811fccf17Sopenharmony_ci{
88911fccf17Sopenharmony_ci    char cmd[MAX_CMD_LENGTH] = {0};
89011fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
89111fccf17Sopenharmony_ci    ResponseInfo *pResponse = NULL;
89211fccf17Sopenharmony_ci    const long timeout = 500;
89311fccf17Sopenharmony_ci
89411fccf17Sopenharmony_ci    int32_t ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT+CCWA=1,%d,1", active);
89511fccf17Sopenharmony_ci    if (ret < 0) {
89611fccf17Sopenharmony_ci        TELEPHONY_LOGE("GenerateCommand is failed!");
89711fccf17Sopenharmony_ci        OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
89811fccf17Sopenharmony_ci        return;
89911fccf17Sopenharmony_ci    }
90011fccf17Sopenharmony_ci    err = SendCommandLock(cmd, NULL, timeout, &pResponse);
90111fccf17Sopenharmony_ci    if (err != HRIL_ERR_SUCCESS) {
90211fccf17Sopenharmony_ci        TELEPHONY_LOGE("ReqSetCallWaiting return, CCWA send failed");
90311fccf17Sopenharmony_ci        err = HRIL_ERR_CMD_SEND_FAILURE;
90411fccf17Sopenharmony_ci    } else {
90511fccf17Sopenharmony_ci        if (pResponse == NULL || !pResponse->success) {
90611fccf17Sopenharmony_ci            err = HRIL_ERR_GENERIC_FAILURE;
90711fccf17Sopenharmony_ci        }
90811fccf17Sopenharmony_ci    }
90911fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
91011fccf17Sopenharmony_ci    OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
91111fccf17Sopenharmony_ci    FreeResponseInfo(pResponse);
91211fccf17Sopenharmony_ci}
91311fccf17Sopenharmony_ci
91411fccf17Sopenharmony_civoid ReqSetCallTransferInfo(const ReqDataInfo *requestInfo, HRilCFInfo info)
91511fccf17Sopenharmony_ci{
91611fccf17Sopenharmony_ci    int32_t numType;
91711fccf17Sopenharmony_ci    const int32_t NUM_F = 145;
91811fccf17Sopenharmony_ci    const int32_t NUM_S = 129;
91911fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
92011fccf17Sopenharmony_ci    ResponseInfo *pResponse = NULL;
92111fccf17Sopenharmony_ci    char cmd[MAX_CMD_LENGTH] = {0};
92211fccf17Sopenharmony_ci
92311fccf17Sopenharmony_ci    if (info.reason > CALL_FORWARD_REASON_ALL_CCF || info.mode > CALL_FORWARD_MODE_ERASURE) {
92411fccf17Sopenharmony_ci        TELEPHONY_LOGE("ReqSetCallTransferInfo call forwarding parameter err!!");
92511fccf17Sopenharmony_ci        struct ReportInfo reportInfo = CreateReportInfo(requestInfo, HRIL_ERR_INVALID_PARAMETER, HRIL_RESPONSE, 0);
92611fccf17Sopenharmony_ci        OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
92711fccf17Sopenharmony_ci        return;
92811fccf17Sopenharmony_ci    }
92911fccf17Sopenharmony_ci
93011fccf17Sopenharmony_ci    if (info.number != NULL && info.number[0] == '+') {
93111fccf17Sopenharmony_ci        numType = NUM_F;
93211fccf17Sopenharmony_ci    } else {
93311fccf17Sopenharmony_ci        numType = NUM_S;
93411fccf17Sopenharmony_ci    }
93511fccf17Sopenharmony_ci
93611fccf17Sopenharmony_ci    int32_t ret = GenerateCommand(
93711fccf17Sopenharmony_ci        cmd, MAX_CMD_LENGTH, "AT+CCFC=%d,%d,\"%s\",%d,%d", info.reason, info.mode, info.number, numType, info.classx);
93811fccf17Sopenharmony_ci    if (ret < 0) {
93911fccf17Sopenharmony_ci        TELEPHONY_LOGE("GenerateCommand is failed!");
94011fccf17Sopenharmony_ci        OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
94111fccf17Sopenharmony_ci        return;
94211fccf17Sopenharmony_ci    }
94311fccf17Sopenharmony_ci    err = SendCommandLock(cmd, NULL, 0, &pResponse);
94411fccf17Sopenharmony_ci    if (err != HRIL_ERR_SUCCESS) {
94511fccf17Sopenharmony_ci        TELEPHONY_LOGE("CCFC send failed");
94611fccf17Sopenharmony_ci        err = HRIL_ERR_CMD_SEND_FAILURE;
94711fccf17Sopenharmony_ci    } else {
94811fccf17Sopenharmony_ci        if (pResponse == NULL || !pResponse->success) {
94911fccf17Sopenharmony_ci            err = HRIL_ERR_GENERIC_FAILURE;
95011fccf17Sopenharmony_ci        }
95111fccf17Sopenharmony_ci    }
95211fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
95311fccf17Sopenharmony_ci    OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
95411fccf17Sopenharmony_ci    FreeResponseInfo(pResponse);
95511fccf17Sopenharmony_ci}
95611fccf17Sopenharmony_ci
95711fccf17Sopenharmony_civoid ReqGetCallTransferInfo(const ReqDataInfo *requestInfo, int32_t reason)
95811fccf17Sopenharmony_ci{
95911fccf17Sopenharmony_ci    char cmd[MAX_CMD_LENGTH] = {0};
96011fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
96111fccf17Sopenharmony_ci    ResponseInfo *pResponse = NULL;
96211fccf17Sopenharmony_ci    HRilCFQueryInfo queryInfo = {0};
96311fccf17Sopenharmony_ci    char *line = NULL;
96411fccf17Sopenharmony_ci
96511fccf17Sopenharmony_ci    if (reason > CALL_FORWARD_REASON_ALL_CCF) {
96611fccf17Sopenharmony_ci        TELEPHONY_LOGE("ReqGetCallTransferInfo call forwarding parameter err!!");
96711fccf17Sopenharmony_ci        struct ReportInfo reportInfo = CreateReportInfo(requestInfo, HRIL_ERR_INVALID_PARAMETER, HRIL_RESPONSE, 0);
96811fccf17Sopenharmony_ci        OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
96911fccf17Sopenharmony_ci        return;
97011fccf17Sopenharmony_ci    }
97111fccf17Sopenharmony_ci    int32_t ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT+CCFC=%d,2", reason);
97211fccf17Sopenharmony_ci    if (ret < 0) {
97311fccf17Sopenharmony_ci        TELEPHONY_LOGE("GenerateCommand is failed!");
97411fccf17Sopenharmony_ci        OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
97511fccf17Sopenharmony_ci        return;
97611fccf17Sopenharmony_ci    }
97711fccf17Sopenharmony_ci    err = SendCommandLock(cmd, "+CCFC", 0, &pResponse);
97811fccf17Sopenharmony_ci    if (err != HRIL_ERR_SUCCESS) {
97911fccf17Sopenharmony_ci        TELEPHONY_LOGE("CCFC send failed");
98011fccf17Sopenharmony_ci        err = HRIL_ERR_CMD_SEND_FAILURE;
98111fccf17Sopenharmony_ci    } else if (pResponse != NULL) {
98211fccf17Sopenharmony_ci        if (!pResponse->success) {
98311fccf17Sopenharmony_ci            TELEPHONY_LOGE("CCFC send and return ERROR");
98411fccf17Sopenharmony_ci            err = HRIL_ERR_GENERIC_FAILURE;
98511fccf17Sopenharmony_ci        } else {
98611fccf17Sopenharmony_ci            if (pResponse->head) {
98711fccf17Sopenharmony_ci                line = pResponse->head->data;
98811fccf17Sopenharmony_ci                SkipATPrefix(&line);
98911fccf17Sopenharmony_ci                NextInt(&line, &queryInfo.status);
99011fccf17Sopenharmony_ci                NextInt(&line, &queryInfo.classx);
99111fccf17Sopenharmony_ci                NextStr(&line, &queryInfo.number);
99211fccf17Sopenharmony_ci                NextInt(&line, &queryInfo.type);
99311fccf17Sopenharmony_ci            } else {
99411fccf17Sopenharmony_ci                TELEPHONY_LOGE("ERROR: ReqGetCallTransferInfo pResponse->head is null");
99511fccf17Sopenharmony_ci                err = HRIL_ERR_GENERIC_FAILURE;
99611fccf17Sopenharmony_ci            }
99711fccf17Sopenharmony_ci        }
99811fccf17Sopenharmony_ci    } else {
99911fccf17Sopenharmony_ci        TELEPHONY_LOGE("ERROR: ReqGetCallTransferInfo pResponse is null");
100011fccf17Sopenharmony_ci        err = HRIL_ERR_GENERIC_FAILURE;
100111fccf17Sopenharmony_ci    }
100211fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
100311fccf17Sopenharmony_ci    OnCallReport(GetSlotId(requestInfo), reportInfo, (const uint8_t *)&queryInfo, sizeof(queryInfo));
100411fccf17Sopenharmony_ci    FreeResponseInfo(pResponse);
100511fccf17Sopenharmony_ci}
100611fccf17Sopenharmony_ci
100711fccf17Sopenharmony_civoid ReqGetCallRestriction(const ReqDataInfo *requestInfo, const char *fac)
100811fccf17Sopenharmony_ci{
100911fccf17Sopenharmony_ci    long long timeOut = DEFAULT_TIMEOUT_CLCK;
101011fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
101111fccf17Sopenharmony_ci    ResponseInfo *pResponse = NULL;
101211fccf17Sopenharmony_ci    HRilCallRestrictionResult result = {0};
101311fccf17Sopenharmony_ci    char *line = NULL;
101411fccf17Sopenharmony_ci    char cmd[MAX_CMD_LENGTH] = {0};
101511fccf17Sopenharmony_ci
101611fccf17Sopenharmony_ci    int32_t ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT+CLCK=\"%s\",2", fac);
101711fccf17Sopenharmony_ci    if (ret < 0) {
101811fccf17Sopenharmony_ci        TELEPHONY_LOGE("GenerateCommand is failed!");
101911fccf17Sopenharmony_ci        OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
102011fccf17Sopenharmony_ci        return;
102111fccf17Sopenharmony_ci    }
102211fccf17Sopenharmony_ci    err = SendCommandLock(cmd, "+CLCK:", timeOut, &pResponse);
102311fccf17Sopenharmony_ci    if (err != HRIL_ERR_SUCCESS) {
102411fccf17Sopenharmony_ci        TELEPHONY_LOGE("CLCK send failed err = %{public}d", err);
102511fccf17Sopenharmony_ci        err = HRIL_ERR_CMD_SEND_FAILURE;
102611fccf17Sopenharmony_ci    } else if (pResponse != NULL) {
102711fccf17Sopenharmony_ci        if (!pResponse->success) {
102811fccf17Sopenharmony_ci            TELEPHONY_LOGE("ERROR: ReqGetCallRestriction return ERROR");
102911fccf17Sopenharmony_ci            err = HRIL_ERR_GENERIC_FAILURE;
103011fccf17Sopenharmony_ci        } else {
103111fccf17Sopenharmony_ci            if (pResponse->head) {
103211fccf17Sopenharmony_ci                line = pResponse->head->data;
103311fccf17Sopenharmony_ci                SkipATPrefix(&line);
103411fccf17Sopenharmony_ci                NextInt(&line, &result.status);
103511fccf17Sopenharmony_ci                NextInt(&line, &result.classCw);
103611fccf17Sopenharmony_ci            } else {
103711fccf17Sopenharmony_ci                TELEPHONY_LOGE("ERROR: ReqGetCallRestriction pResponse->head is null");
103811fccf17Sopenharmony_ci                err = HRIL_ERR_GENERIC_FAILURE;
103911fccf17Sopenharmony_ci            }
104011fccf17Sopenharmony_ci        }
104111fccf17Sopenharmony_ci    } else {
104211fccf17Sopenharmony_ci        TELEPHONY_LOGE("ERROR: ReqGetCallRestriction pResponse is null");
104311fccf17Sopenharmony_ci        err = HRIL_ERR_GENERIC_FAILURE;
104411fccf17Sopenharmony_ci    }
104511fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
104611fccf17Sopenharmony_ci    OnCallReport(GetSlotId(requestInfo), reportInfo, (const uint8_t *)&result, sizeof(HRilCallRestrictionResult));
104711fccf17Sopenharmony_ci    FreeResponseInfo(pResponse);
104811fccf17Sopenharmony_ci}
104911fccf17Sopenharmony_ci
105011fccf17Sopenharmony_civoid ReqSetCallRestriction(const ReqDataInfo *requestInfo, CallRestrictionInfo info)
105111fccf17Sopenharmony_ci{
105211fccf17Sopenharmony_ci    long long timeOut = DEFAULT_TIMEOUT;
105311fccf17Sopenharmony_ci    char cmd[MAX_CMD_LENGTH] = {0};
105411fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
105511fccf17Sopenharmony_ci    ResponseInfo *pResponse = NULL;
105611fccf17Sopenharmony_ci
105711fccf17Sopenharmony_ci    int32_t ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT+CLCK=\"%s\",%d,\"%s\"", info.fac, info.mode, info.password);
105811fccf17Sopenharmony_ci    if (ret < 0) {
105911fccf17Sopenharmony_ci        TELEPHONY_LOGE("GenerateCommand is failed!");
106011fccf17Sopenharmony_ci        OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
106111fccf17Sopenharmony_ci        return;
106211fccf17Sopenharmony_ci    }
106311fccf17Sopenharmony_ci    err = SendCommandLock(cmd, NULL, timeOut, &pResponse);
106411fccf17Sopenharmony_ci    if (err != HRIL_ERR_SUCCESS) {
106511fccf17Sopenharmony_ci        TELEPHONY_LOGE("CLCK send failed");
106611fccf17Sopenharmony_ci        err = HRIL_ERR_CMD_SEND_FAILURE;
106711fccf17Sopenharmony_ci    } else {
106811fccf17Sopenharmony_ci        if (pResponse == NULL || !pResponse->success) {
106911fccf17Sopenharmony_ci            err = HRIL_ERR_GENERIC_FAILURE;
107011fccf17Sopenharmony_ci        }
107111fccf17Sopenharmony_ci    }
107211fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
107311fccf17Sopenharmony_ci    OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
107411fccf17Sopenharmony_ci    FreeResponseInfo(pResponse);
107511fccf17Sopenharmony_ci}
107611fccf17Sopenharmony_ci
107711fccf17Sopenharmony_civoid ReqSetBarringPassword(const ReqDataInfo *requestInfo, HRilSetBarringInfo info)
107811fccf17Sopenharmony_ci{
107911fccf17Sopenharmony_ci    long long timeOut = DEFAULT_TIMEOUT;
108011fccf17Sopenharmony_ci    char cmd[MAX_CMD_LENGTH] = { 0 };
108111fccf17Sopenharmony_ci    ResponseInfo *pResponse = NULL;
108211fccf17Sopenharmony_ci
108311fccf17Sopenharmony_ci    int32_t ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT+CPWD=\"%s\",\"%s\",\"%s\"", info.fac,
108411fccf17Sopenharmony_ci        info.oldPassword, info.newPassword);
108511fccf17Sopenharmony_ci    if (ret < 0) {
108611fccf17Sopenharmony_ci        TELEPHONY_LOGE("GenerateCommand is failed!");
108711fccf17Sopenharmony_ci        OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
108811fccf17Sopenharmony_ci        return;
108911fccf17Sopenharmony_ci    }
109011fccf17Sopenharmony_ci    int32_t err = SendCommandLock(cmd, NULL, timeOut, &pResponse);
109111fccf17Sopenharmony_ci    if (err != HRIL_ERR_SUCCESS) {
109211fccf17Sopenharmony_ci        TELEPHONY_LOGE("CPWD send failed");
109311fccf17Sopenharmony_ci        err = HRIL_ERR_CMD_SEND_FAILURE;
109411fccf17Sopenharmony_ci    } else if (pResponse != NULL) {
109511fccf17Sopenharmony_ci        if (!pResponse->success) {
109611fccf17Sopenharmony_ci            TELEPHONY_LOGE("ERROR: ReqSetBarringPassword return ERROR");
109711fccf17Sopenharmony_ci            err = HRIL_ERR_GENERIC_FAILURE;
109811fccf17Sopenharmony_ci        }
109911fccf17Sopenharmony_ci    } else {
110011fccf17Sopenharmony_ci        TELEPHONY_LOGE("ERROR: ReqSetBarringPassword pResponse is null");
110111fccf17Sopenharmony_ci        err = HRIL_ERR_GENERIC_FAILURE;
110211fccf17Sopenharmony_ci    }
110311fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
110411fccf17Sopenharmony_ci    OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
110511fccf17Sopenharmony_ci    FreeResponseInfo(pResponse);
110611fccf17Sopenharmony_ci}
110711fccf17Sopenharmony_ci
110811fccf17Sopenharmony_civoid ReqGetCallPreferenceMode(const ReqDataInfo *requestInfo)
110911fccf17Sopenharmony_ci{
111011fccf17Sopenharmony_ci    char *line = NULL;
111111fccf17Sopenharmony_ci    int32_t mode = VENDOR_FAIL;
111211fccf17Sopenharmony_ci    int32_t ret = VENDOR_FAIL;
111311fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
111411fccf17Sopenharmony_ci    ResponseInfo *pResponse = NULL;
111511fccf17Sopenharmony_ci
111611fccf17Sopenharmony_ci    ModemReportErrorInfo errInfo = InitModemReportErrorInfo();
111711fccf17Sopenharmony_ci    ret = SendCommandLock("AT+CEVDP?", "+CEVDP:", 0, &pResponse);
111811fccf17Sopenharmony_ci    if (ret || pResponse == NULL || !pResponse->success) {
111911fccf17Sopenharmony_ci        err = (ret != HRIL_ERR_SUCCESS) ? HRIL_ERR_CMD_SEND_FAILURE : err;
112011fccf17Sopenharmony_ci        TELEPHONY_LOGE("cmd send failed, err:%{public}d", err);
112111fccf17Sopenharmony_ci        OnCallReportErrorMessages(requestInfo, err, pResponse);
112211fccf17Sopenharmony_ci        return;
112311fccf17Sopenharmony_ci    }
112411fccf17Sopenharmony_ci    if (pResponse->head) {
112511fccf17Sopenharmony_ci        line = pResponse->head->data;
112611fccf17Sopenharmony_ci        err = SkipATPrefix(&line);
112711fccf17Sopenharmony_ci        if (err == 0) {
112811fccf17Sopenharmony_ci            err = NextInt(&line, &mode);
112911fccf17Sopenharmony_ci            TELEPHONY_LOGI("mode:%{public}d", mode);
113011fccf17Sopenharmony_ci        } else {
113111fccf17Sopenharmony_ci            TELEPHONY_LOGE("response error");
113211fccf17Sopenharmony_ci        }
113311fccf17Sopenharmony_ci    } else {
113411fccf17Sopenharmony_ci        TELEPHONY_LOGE("ERROR: pResponse->head is null");
113511fccf17Sopenharmony_ci        err = HRIL_ERR_GENERIC_FAILURE;
113611fccf17Sopenharmony_ci    }
113711fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
113811fccf17Sopenharmony_ci    reportInfo.modemErrInfo = errInfo;
113911fccf17Sopenharmony_ci    OnCallReport(GetSlotId(requestInfo), reportInfo, (const uint8_t *)&mode, sizeof(mode));
114011fccf17Sopenharmony_ci    FreeResponseInfo(pResponse);
114111fccf17Sopenharmony_ci}
114211fccf17Sopenharmony_ci
114311fccf17Sopenharmony_civoid ReqSetCallPreferenceMode(const ReqDataInfo *requestInfo, int32_t mode)
114411fccf17Sopenharmony_ci{
114511fccf17Sopenharmony_ci    int32_t ret = VENDOR_FAIL;
114611fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
114711fccf17Sopenharmony_ci    int32_t value = HRIL_CALL_MODE_CS_1ST_PS_2ND;
114811fccf17Sopenharmony_ci    char cmd[MAX_CMD_LENGTH] = {0};
114911fccf17Sopenharmony_ci    ResponseInfo *pResponse = NULL;
115011fccf17Sopenharmony_ci
115111fccf17Sopenharmony_ci    ModemReportErrorInfo errInfo = InitModemReportErrorInfo();
115211fccf17Sopenharmony_ci    value = mode;
115311fccf17Sopenharmony_ci    ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT+CEVDP=%d", value);
115411fccf17Sopenharmony_ci    if (ret < 0) {
115511fccf17Sopenharmony_ci        TELEPHONY_LOGE("GenerateCommand is failed!");
115611fccf17Sopenharmony_ci        OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
115711fccf17Sopenharmony_ci        return;
115811fccf17Sopenharmony_ci    }
115911fccf17Sopenharmony_ci    ret = SendCommandLock(cmd, NULL, 0, &pResponse);
116011fccf17Sopenharmony_ci    if (ret || (pResponse != NULL && !pResponse->success)) {
116111fccf17Sopenharmony_ci        errInfo = GetReportErrorInfo(pResponse);
116211fccf17Sopenharmony_ci        err = errInfo.errorNo;
116311fccf17Sopenharmony_ci        TELEPHONY_LOGE("cmd send failed, err:%{public}d", ret ? ret : err);
116411fccf17Sopenharmony_ci    }
116511fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
116611fccf17Sopenharmony_ci    reportInfo.modemErrInfo = errInfo;
116711fccf17Sopenharmony_ci    OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
116811fccf17Sopenharmony_ci    FreeResponseInfo(pResponse);
116911fccf17Sopenharmony_ci}
117011fccf17Sopenharmony_ci
117111fccf17Sopenharmony_civoid ReqSetUssd(const ReqDataInfo *requestInfo, const char *str)
117211fccf17Sopenharmony_ci{
117311fccf17Sopenharmony_ci    int32_t ret;
117411fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
117511fccf17Sopenharmony_ci    char cmd[MAX_CMD_LENGTH] = {0};
117611fccf17Sopenharmony_ci    ResponseInfo *pResponse = NULL;
117711fccf17Sopenharmony_ci    ModemReportErrorInfo errInfo = {};
117811fccf17Sopenharmony_ci
117911fccf17Sopenharmony_ci    ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT+CUSD=1, \"% s\" , 15", str);
118011fccf17Sopenharmony_ci    if (ret < 0) {
118111fccf17Sopenharmony_ci        TELEPHONY_LOGE("GenerateCommand is failed!");
118211fccf17Sopenharmony_ci        OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
118311fccf17Sopenharmony_ci        return;
118411fccf17Sopenharmony_ci    }
118511fccf17Sopenharmony_ci    ret = SendCommandLock(cmd, NULL, 0, &pResponse);
118611fccf17Sopenharmony_ci    if (ret || (pResponse != NULL && !pResponse->success)) {
118711fccf17Sopenharmony_ci        errInfo = GetReportErrorInfo(pResponse);
118811fccf17Sopenharmony_ci        err = errInfo.errorNo;
118911fccf17Sopenharmony_ci        TELEPHONY_LOGE("cmd send failed, err:%{public}d", ret ? ret : err);
119011fccf17Sopenharmony_ci    }
119111fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
119211fccf17Sopenharmony_ci    reportInfo.modemErrInfo = errInfo;
119311fccf17Sopenharmony_ci    OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
119411fccf17Sopenharmony_ci    FreeResponseInfo(pResponse);
119511fccf17Sopenharmony_ci}
119611fccf17Sopenharmony_ci
119711fccf17Sopenharmony_civoid ReqCloseUnFinishedUssd(const ReqDataInfo *requestInfo)
119811fccf17Sopenharmony_ci{
119911fccf17Sopenharmony_ci    int32_t ret;
120011fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
120111fccf17Sopenharmony_ci    ResponseInfo *pResponse = NULL;
120211fccf17Sopenharmony_ci    ModemReportErrorInfo errInfo = {};
120311fccf17Sopenharmony_ci
120411fccf17Sopenharmony_ci    ret = SendCommandLock("AT+CUSD=2", NULL, 0, &pResponse);
120511fccf17Sopenharmony_ci    if (ret || (pResponse != NULL && !pResponse->success)) {
120611fccf17Sopenharmony_ci        errInfo = GetReportErrorInfo(pResponse);
120711fccf17Sopenharmony_ci        err = errInfo.errorNo;
120811fccf17Sopenharmony_ci        TELEPHONY_LOGE("cmd send failed, err:%{public}d", ret ? ret : err);
120911fccf17Sopenharmony_ci    }
121011fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
121111fccf17Sopenharmony_ci    reportInfo.modemErrInfo = errInfo;
121211fccf17Sopenharmony_ci    OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
121311fccf17Sopenharmony_ci    FreeResponseInfo(pResponse);
121411fccf17Sopenharmony_ci}
121511fccf17Sopenharmony_ci
121611fccf17Sopenharmony_civoid ReqGetUssd(const ReqDataInfo *requestInfo)
121711fccf17Sopenharmony_ci{
121811fccf17Sopenharmony_ci    int32_t ret;
121911fccf17Sopenharmony_ci    char *line = NULL;
122011fccf17Sopenharmony_ci    int32_t cusd = 0;
122111fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
122211fccf17Sopenharmony_ci    ResponseInfo *pResponse = NULL;
122311fccf17Sopenharmony_ci    ModemReportErrorInfo errInfo = {};
122411fccf17Sopenharmony_ci
122511fccf17Sopenharmony_ci    ret = SendCommandLock("AT+CUSD?", "+CUSD:", 0, &pResponse);
122611fccf17Sopenharmony_ci    if (ret || pResponse == NULL || !pResponse->success) {
122711fccf17Sopenharmony_ci        err = ret ? ret : err;
122811fccf17Sopenharmony_ci        TELEPHONY_LOGE("cmd send failed, err:%{public}d", err);
122911fccf17Sopenharmony_ci        OnCallReportErrorMessages(requestInfo, err, pResponse);
123011fccf17Sopenharmony_ci        return;
123111fccf17Sopenharmony_ci    }
123211fccf17Sopenharmony_ci    if (pResponse->head) {
123311fccf17Sopenharmony_ci        line = pResponse->head->data;
123411fccf17Sopenharmony_ci        err = SkipATPrefix(&line);
123511fccf17Sopenharmony_ci        if (err == 0) {
123611fccf17Sopenharmony_ci            err = NextInt(&line, &cusd);
123711fccf17Sopenharmony_ci            TELEPHONY_LOGI("+CUSD:%{public}d", cusd);
123811fccf17Sopenharmony_ci        } else {
123911fccf17Sopenharmony_ci            TELEPHONY_LOGE("response error");
124011fccf17Sopenharmony_ci        }
124111fccf17Sopenharmony_ci    } else {
124211fccf17Sopenharmony_ci        TELEPHONY_LOGE("ERROR: pResponse->head is null");
124311fccf17Sopenharmony_ci        err = HRIL_ERR_GENERIC_FAILURE;
124411fccf17Sopenharmony_ci    }
124511fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
124611fccf17Sopenharmony_ci    reportInfo.modemErrInfo = errInfo;
124711fccf17Sopenharmony_ci    OnCallReport(GetSlotId(requestInfo), reportInfo, (const uint8_t *)&cusd, sizeof(cusd));
124811fccf17Sopenharmony_ci    FreeResponseInfo(pResponse);
124911fccf17Sopenharmony_ci}
125011fccf17Sopenharmony_ci
125111fccf17Sopenharmony_civoid ReqSetMute(const ReqDataInfo *requestInfo, int32_t mute)
125211fccf17Sopenharmony_ci{
125311fccf17Sopenharmony_ci    int32_t ret;
125411fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
125511fccf17Sopenharmony_ci    char cmd[MAX_CMD_LENGTH] = {0};
125611fccf17Sopenharmony_ci    ResponseInfo *pResponse = NULL;
125711fccf17Sopenharmony_ci    ModemReportErrorInfo errInfo = {};
125811fccf17Sopenharmony_ci
125911fccf17Sopenharmony_ci    ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT+CMUT=%d ", mute);
126011fccf17Sopenharmony_ci    if (ret < 0) {
126111fccf17Sopenharmony_ci        TELEPHONY_LOGE("GenerateCommand is failed!");
126211fccf17Sopenharmony_ci        OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
126311fccf17Sopenharmony_ci        return;
126411fccf17Sopenharmony_ci    }
126511fccf17Sopenharmony_ci    ret = SendCommandLock(cmd, NULL, 0, &pResponse);
126611fccf17Sopenharmony_ci    if (ret || (pResponse != NULL && !pResponse->success)) {
126711fccf17Sopenharmony_ci        errInfo = GetReportErrorInfo(pResponse);
126811fccf17Sopenharmony_ci        err = errInfo.errorNo;
126911fccf17Sopenharmony_ci        TELEPHONY_LOGE("cmd send failed, err:%{public}d", ret ? ret : err);
127011fccf17Sopenharmony_ci    }
127111fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
127211fccf17Sopenharmony_ci    reportInfo.modemErrInfo = errInfo;
127311fccf17Sopenharmony_ci    OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
127411fccf17Sopenharmony_ci    FreeResponseInfo(pResponse);
127511fccf17Sopenharmony_ci}
127611fccf17Sopenharmony_ci
127711fccf17Sopenharmony_civoid ReqGetMute(const ReqDataInfo *requestInfo)
127811fccf17Sopenharmony_ci{
127911fccf17Sopenharmony_ci    int32_t ret;
128011fccf17Sopenharmony_ci    char *line = NULL;
128111fccf17Sopenharmony_ci    int32_t mute = 0;
128211fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
128311fccf17Sopenharmony_ci    ResponseInfo *pResponse = NULL;
128411fccf17Sopenharmony_ci    ModemReportErrorInfo errInfo = {};
128511fccf17Sopenharmony_ci
128611fccf17Sopenharmony_ci    ret = SendCommandLock("AT+CMUT?", "+CMUT:", 0, &pResponse);
128711fccf17Sopenharmony_ci    if (ret || pResponse == NULL || !pResponse->success) {
128811fccf17Sopenharmony_ci        err = ret ? ret : err;
128911fccf17Sopenharmony_ci        TELEPHONY_LOGE("cmd send failed, err:%{public}d", err);
129011fccf17Sopenharmony_ci        OnCallReportErrorMessages(requestInfo, err, pResponse);
129111fccf17Sopenharmony_ci        return;
129211fccf17Sopenharmony_ci    }
129311fccf17Sopenharmony_ci    if (pResponse->head) {
129411fccf17Sopenharmony_ci        line = pResponse->head->data;
129511fccf17Sopenharmony_ci        err = SkipATPrefix(&line);
129611fccf17Sopenharmony_ci        if (err == 0) {
129711fccf17Sopenharmony_ci            err = NextInt(&line, &mute);
129811fccf17Sopenharmony_ci            TELEPHONY_LOGI("+CMUT:%{public}d", mute);
129911fccf17Sopenharmony_ci        } else {
130011fccf17Sopenharmony_ci            TELEPHONY_LOGE("response error");
130111fccf17Sopenharmony_ci        }
130211fccf17Sopenharmony_ci    } else {
130311fccf17Sopenharmony_ci        TELEPHONY_LOGE("ERROR: pResponse->head is null");
130411fccf17Sopenharmony_ci        err = HRIL_ERR_GENERIC_FAILURE;
130511fccf17Sopenharmony_ci    }
130611fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
130711fccf17Sopenharmony_ci    reportInfo.modemErrInfo = errInfo;
130811fccf17Sopenharmony_ci    OnCallReport(GetSlotId(requestInfo), reportInfo, (const uint8_t *)&mute, sizeof(mute));
130911fccf17Sopenharmony_ci    FreeResponseInfo(pResponse);
131011fccf17Sopenharmony_ci}
131111fccf17Sopenharmony_ci
131211fccf17Sopenharmony_cistatic int32_t CallCmdXLEMA(const char *lineCmd, HRilEmergencyInfo *outCall)
131311fccf17Sopenharmony_ci{
131411fccf17Sopenharmony_ci    char *pLine = (char *)lineCmd;
131511fccf17Sopenharmony_ci
131611fccf17Sopenharmony_ci    if (pLine == NULL || outCall == NULL) {
131711fccf17Sopenharmony_ci        TELEPHONY_LOGE("src or desc pointer is null.");
131811fccf17Sopenharmony_ci        return HRIL_ERR_NULL_POINT;
131911fccf17Sopenharmony_ci    }
132011fccf17Sopenharmony_ci
132111fccf17Sopenharmony_ci    if (SkipATPrefix(&pLine) < 0) {
132211fccf17Sopenharmony_ci        return HRIL_ERR_NULL_POINT;
132311fccf17Sopenharmony_ci    }
132411fccf17Sopenharmony_ci    if (NextInt(&pLine, &outCall->index) < 0) {
132511fccf17Sopenharmony_ci        return HRIL_ERR_NULL_POINT;
132611fccf17Sopenharmony_ci    }
132711fccf17Sopenharmony_ci    if (NextInt(&pLine, &outCall->total) < 0) {
132811fccf17Sopenharmony_ci        return HRIL_ERR_NULL_POINT;
132911fccf17Sopenharmony_ci    }
133011fccf17Sopenharmony_ci    if (NextStr(&pLine, &outCall->eccNum) < 0) {
133111fccf17Sopenharmony_ci        return HRIL_ERR_NULL_POINT;
133211fccf17Sopenharmony_ci    }
133311fccf17Sopenharmony_ci    if (NextInt(&pLine, &outCall->category) < 0) {
133411fccf17Sopenharmony_ci        return HRIL_ERR_NULL_POINT;
133511fccf17Sopenharmony_ci    }
133611fccf17Sopenharmony_ci    if (NextInt(&pLine, &outCall->simpresent) < 0) {
133711fccf17Sopenharmony_ci        return HRIL_ERR_NULL_POINT;
133811fccf17Sopenharmony_ci    }
133911fccf17Sopenharmony_ci    if (NextStr(&pLine, &outCall->mcc) < 0) {
134011fccf17Sopenharmony_ci        return HRIL_ERR_NULL_POINT;
134111fccf17Sopenharmony_ci    }
134211fccf17Sopenharmony_ci    if (NextInt(&pLine, &outCall->abnormalService) < 0) {
134311fccf17Sopenharmony_ci        return HRIL_ERR_NULL_POINT;
134411fccf17Sopenharmony_ci    }
134511fccf17Sopenharmony_ci    return HRIL_ERR_SUCCESS;
134611fccf17Sopenharmony_ci}
134711fccf17Sopenharmony_ci
134811fccf17Sopenharmony_cistatic int32_t InitGetEmergencyCallList(const ResponseInfo *pResponse, int32_t *callNum,
134911fccf17Sopenharmony_ci    HRilEmergencyInfo **pEmergencyCalls)
135011fccf17Sopenharmony_ci{
135111fccf17Sopenharmony_ci    int32_t ret;
135211fccf17Sopenharmony_ci    int32_t callNumTmp = 0;
135311fccf17Sopenharmony_ci    Line *pLine = NULL;
135411fccf17Sopenharmony_ci    HRilEmergencyInfo *pEmergencyCallsTmp = NULL;
135511fccf17Sopenharmony_ci
135611fccf17Sopenharmony_ci    if (pResponse == NULL || pEmergencyCalls == NULL || callNum == NULL) {
135711fccf17Sopenharmony_ci        TELEPHONY_LOGE("params: %{public}p,%{public}p,%{public}p", pResponse, callNum, pEmergencyCalls);
135811fccf17Sopenharmony_ci        return HRIL_ERR_NULL_POINT;
135911fccf17Sopenharmony_ci    }
136011fccf17Sopenharmony_ci
136111fccf17Sopenharmony_ci    *callNum = 0;
136211fccf17Sopenharmony_ci    *pEmergencyCalls = NULL;
136311fccf17Sopenharmony_ci
136411fccf17Sopenharmony_ci    for (pLine = pResponse->head; pLine != NULL; pLine = pLine->next) {
136511fccf17Sopenharmony_ci        callNumTmp++;
136611fccf17Sopenharmony_ci    }
136711fccf17Sopenharmony_ci    if (!callNumTmp) {
136811fccf17Sopenharmony_ci        callNumTmp++; // Malloc size cannot be 0.
136911fccf17Sopenharmony_ci    }
137011fccf17Sopenharmony_ci    pEmergencyCallsTmp = (HRilEmergencyInfo *)malloc(callNumTmp * sizeof(HRilEmergencyInfo));
137111fccf17Sopenharmony_ci    if (pEmergencyCallsTmp == NULL) {
137211fccf17Sopenharmony_ci        TELEPHONY_LOGE("ReqGetCallList malloc pCalls failure");
137311fccf17Sopenharmony_ci        return HRIL_ERR_MEMORY_FULL;
137411fccf17Sopenharmony_ci    }
137511fccf17Sopenharmony_ci    ret = memset_s(
137611fccf17Sopenharmony_ci        pEmergencyCallsTmp, callNumTmp * sizeof(HRilEmergencyInfo), 0, callNumTmp * sizeof(HRilEmergencyInfo));
137711fccf17Sopenharmony_ci    if (ret != EOK) {
137811fccf17Sopenharmony_ci        TELEPHONY_LOGE("memset_s is failed!");
137911fccf17Sopenharmony_ci        free(pEmergencyCallsTmp);
138011fccf17Sopenharmony_ci        pEmergencyCallsTmp = NULL;
138111fccf17Sopenharmony_ci        return ret;
138211fccf17Sopenharmony_ci    }
138311fccf17Sopenharmony_ci
138411fccf17Sopenharmony_ci    *pEmergencyCalls = pEmergencyCallsTmp;
138511fccf17Sopenharmony_ci    *callNum = callNumTmp;
138611fccf17Sopenharmony_ci
138711fccf17Sopenharmony_ci    return HRIL_ERR_SUCCESS;
138811fccf17Sopenharmony_ci}
138911fccf17Sopenharmony_ci
139011fccf17Sopenharmony_ciint32_t BuildGetEmergencyCallList(const ReqDataInfo *requestInfo, ResponseInfo *response)
139111fccf17Sopenharmony_ci{
139211fccf17Sopenharmony_ci    int32_t ret = 0;
139311fccf17Sopenharmony_ci    int32_t callNum = 0;
139411fccf17Sopenharmony_ci    int32_t validCallNum = 0;
139511fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
139611fccf17Sopenharmony_ci    Line *pLine = NULL;
139711fccf17Sopenharmony_ci    ResponseInfo *pResponse = response;
139811fccf17Sopenharmony_ci    HRilEmergencyInfo *pEmergencyCalls = NULL;
139911fccf17Sopenharmony_ci
140011fccf17Sopenharmony_ci    if (pResponse == NULL || requestInfo == NULL) {
140111fccf17Sopenharmony_ci        TELEPHONY_LOGE("response or requestInfo is null.");
140211fccf17Sopenharmony_ci        return HRIL_ERR_NULL_POINT;
140311fccf17Sopenharmony_ci    }
140411fccf17Sopenharmony_ci    if (pResponse->success == 0) {
140511fccf17Sopenharmony_ci        TELEPHONY_LOGE("send cmd return ERROR");
140611fccf17Sopenharmony_ci        err = HRIL_ERR_GENERIC_FAILURE;
140711fccf17Sopenharmony_ci    }
140811fccf17Sopenharmony_ci
140911fccf17Sopenharmony_ci    ret = InitGetEmergencyCallList(pResponse, &callNum, &pEmergencyCalls);
141011fccf17Sopenharmony_ci    if (ret != HRIL_ERR_SUCCESS) {
141111fccf17Sopenharmony_ci        TELEPHONY_LOGE("init command failed: %{public}d", ret);
141211fccf17Sopenharmony_ci        return ret;
141311fccf17Sopenharmony_ci    }
141411fccf17Sopenharmony_ci
141511fccf17Sopenharmony_ci    for (pLine = pResponse->head; pLine != NULL && validCallNum < callNum; pLine = pLine->next) {
141611fccf17Sopenharmony_ci        ret = CallCmdXLEMA(pLine->data, pEmergencyCalls + validCallNum);
141711fccf17Sopenharmony_ci        if (ret != 0) {
141811fccf17Sopenharmony_ci            TELEPHONY_LOGE("Parse CLCC data is fail. ret:%{public}d", ret);
141911fccf17Sopenharmony_ci            continue;
142011fccf17Sopenharmony_ci        }
142111fccf17Sopenharmony_ci        validCallNum++;
142211fccf17Sopenharmony_ci    }
142311fccf17Sopenharmony_ci
142411fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
142511fccf17Sopenharmony_ci    OnCallReport(
142611fccf17Sopenharmony_ci        GetSlotId(requestInfo), reportInfo, (const uint8_t *)pEmergencyCalls, sizeof(HRilEmergencyInfo) * validCallNum);
142711fccf17Sopenharmony_ci    FreeResponseInfo(pResponse);
142811fccf17Sopenharmony_ci    free(pEmergencyCalls);
142911fccf17Sopenharmony_ci    return HRIL_ERR_SUCCESS;
143011fccf17Sopenharmony_ci}
143111fccf17Sopenharmony_ci
143211fccf17Sopenharmony_civoid ReqGetEmergencyCallList(const ReqDataInfo *requestInfo)
143311fccf17Sopenharmony_ci{
143411fccf17Sopenharmony_ci    int32_t ret;
143511fccf17Sopenharmony_ci    ResponseInfo *pResponse = NULL;
143611fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
143711fccf17Sopenharmony_ci    long timeOut = DEFAULT_TIMEOUT;
143811fccf17Sopenharmony_ci
143911fccf17Sopenharmony_ci    ret = SendCommandLock("AT^XLEMA?", "^XLEMA:", timeOut, &pResponse);
144011fccf17Sopenharmony_ci    if (ret || (pResponse != NULL && !pResponse->success)) {
144111fccf17Sopenharmony_ci        err = (ret != HRIL_ERR_SUCCESS) ? HRIL_ERR_CMD_SEND_FAILURE : err;
144211fccf17Sopenharmony_ci        TELEPHONY_LOGE("cmd send failed, err:%{public}d", err);
144311fccf17Sopenharmony_ci        OnCallReportErrorMessages(requestInfo, err, pResponse);
144411fccf17Sopenharmony_ci        return;
144511fccf17Sopenharmony_ci    }
144611fccf17Sopenharmony_ci    err = BuildGetEmergencyCallList(requestInfo, pResponse);
144711fccf17Sopenharmony_ci    if (err != HRIL_ERR_SUCCESS) {
144811fccf17Sopenharmony_ci        TELEPHONY_LOGE("Build Call Info List is failed.");
144911fccf17Sopenharmony_ci        OnCallReportErrorMessages(requestInfo, err, pResponse);
145011fccf17Sopenharmony_ci    }
145111fccf17Sopenharmony_ci}
145211fccf17Sopenharmony_ci
145311fccf17Sopenharmony_civoid ReqSetEmergencyCallList(const ReqDataInfo *requestInfo, HRilEmergencyInfo *emergencyInfo, const int len)
145411fccf17Sopenharmony_ci{
145511fccf17Sopenharmony_ci    TELEPHONY_LOGI("ReqSetEmergencyCallList start");
145611fccf17Sopenharmony_ci    int32_t ret = 0;
145711fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
145811fccf17Sopenharmony_ci    char cmd[MAX_CMD_LENGTH] = {0};
145911fccf17Sopenharmony_ci    ResponseInfo *pResponse = NULL;
146011fccf17Sopenharmony_ci    ModemReportErrorInfo errInfo = {};
146111fccf17Sopenharmony_ci    for (int i = 0; i  < len; i++) {
146211fccf17Sopenharmony_ci        ret = GenerateCommand(cmd, MAX_CMD_LENGTH, "AT^NVM=%d,%d,\"%s\",%d,%d,%s,%d", emergencyInfo[i].index,
146311fccf17Sopenharmony_ci            emergencyInfo[i].total, emergencyInfo[i].eccNum, emergencyInfo[i].category, emergencyInfo[i].simpresent,
146411fccf17Sopenharmony_ci            emergencyInfo[i].mcc, emergencyInfo[i].abnormalService);
146511fccf17Sopenharmony_ci        if (ret < 0) {
146611fccf17Sopenharmony_ci            TELEPHONY_LOGE("GenerateCommand is failed!");
146711fccf17Sopenharmony_ci            OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
146811fccf17Sopenharmony_ci            return;
146911fccf17Sopenharmony_ci        }
147011fccf17Sopenharmony_ci        ret = SendCommandLock(cmd, NULL, 0, &pResponse);
147111fccf17Sopenharmony_ci        if (ret || (pResponse != NULL && !pResponse->success)) {
147211fccf17Sopenharmony_ci            errInfo = GetReportErrorInfo(pResponse);
147311fccf17Sopenharmony_ci            err = errInfo.errorNo;
147411fccf17Sopenharmony_ci            TELEPHONY_LOGE("cmd send failed, err:%{public}d", ret ? ret : err);
147511fccf17Sopenharmony_ci        }
147611fccf17Sopenharmony_ci    }
147711fccf17Sopenharmony_ci    TELEPHONY_LOGI("ReqSetEmergencyCallList end");
147811fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
147911fccf17Sopenharmony_ci    reportInfo.modemErrInfo = errInfo;
148011fccf17Sopenharmony_ci    OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
148111fccf17Sopenharmony_ci    FreeResponseInfo(pResponse);
148211fccf17Sopenharmony_ci}
148311fccf17Sopenharmony_ci
148411fccf17Sopenharmony_civoid ReqGetCallFailReason(const ReqDataInfo *requestInfo)
148511fccf17Sopenharmony_ci{
148611fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
148711fccf17Sopenharmony_ci    ResponseInfo *pResponse = NULL;
148811fccf17Sopenharmony_ci    ModemReportErrorInfo errInfo = {};
148911fccf17Sopenharmony_ci
149011fccf17Sopenharmony_ci    if (lastCcCause == HRIL_ERR_CALL_CAUSE) {
149111fccf17Sopenharmony_ci        TELEPHONY_LOGE("lastCcCause is none!");
149211fccf17Sopenharmony_ci        OnCallReportErrorMessages(requestInfo, HRIL_ERR_GENERIC_FAILURE, NULL);
149311fccf17Sopenharmony_ci        return;
149411fccf17Sopenharmony_ci    }
149511fccf17Sopenharmony_ci
149611fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
149711fccf17Sopenharmony_ci    reportInfo.modemErrInfo = errInfo;
149811fccf17Sopenharmony_ci    OnCallReport(GetSlotId(requestInfo), reportInfo, (const uint8_t *)&lastCcCause, sizeof(lastCcCause));
149911fccf17Sopenharmony_ci    FreeResponseInfo(pResponse);
150011fccf17Sopenharmony_ci}
150111fccf17Sopenharmony_ci
150211fccf17Sopenharmony_civoid ReqSetVonrSwitch(const ReqDataInfo *requestInfo, int32_t status)
150311fccf17Sopenharmony_ci{
150411fccf17Sopenharmony_ci    int32_t err = HRIL_ERR_SUCCESS;
150511fccf17Sopenharmony_ci    ResponseInfo *pResponse = NULL;
150611fccf17Sopenharmony_ci
150711fccf17Sopenharmony_ci    struct ReportInfo reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0);
150811fccf17Sopenharmony_ci    OnCallReport(GetSlotId(requestInfo), reportInfo, NULL, 0);
150911fccf17Sopenharmony_ci    FreeResponseInfo(pResponse);
151011fccf17Sopenharmony_ci}
1511