From 7589fd4a43a66b80e89774523dd81d92580328a6 Mon Sep 17 00:00:00 2001 From: Xianru Chen Date: Tue, 25 Mar 2025 04:31:30 +0800 Subject: [PATCH 1/3] ussd feature Signed-off-by: Xianru Chen --- services/common/include/mmi_code_message.h | 29 +++ services/control/src/control_base.cpp | 2 +- .../manager/include/cellular_call_handler.h | 1 + .../manager/include/cellular_call_service.h | 9 + services/manager/include/cellular_call_stub.h | 10 + .../manager/src/cellular_call_handler.cpp | 54 +++-- .../manager/src/cellular_call_service.cpp | 10 + services/manager/src/cellular_call_stub.cpp | 28 +++ .../utils/include/cellular_call_supplement.h | 27 ++- services/utils/include/mmi_code_utils.h | 4 + .../utils/src/cellular_call_supplement.cpp | 221 ++++++++++++++---- services/utils/src/mmi_code_utils.cpp | 50 ++++ test/unittest/imstest/zero_branch1_test.cpp | 20 ++ test/unittest/imstest/zero_branch_test.cpp | 28 +-- 14 files changed, 412 insertions(+), 81 deletions(-) diff --git a/services/common/include/mmi_code_message.h b/services/common/include/mmi_code_message.h index e463a95b..b73797ee 100644 --- a/services/common/include/mmi_code_message.h +++ b/services/common/include/mmi_code_message.h @@ -134,6 +134,35 @@ const std::string CLIR_DEFAULT_ON_NEXT_OFF = "Caller ID defaults to restricted. const std::string CLIR_DEFAULT_OFF_NEXT_OFF = "Caller ID defaults to not restricted. Next call: Not restricted"; const std::string CLIR_DEFAULT_OFF_NEXT_ON = "Caller ID defaults to not restricted. Next call: Restricted"; +const int32_t SUB_TYPE_QUERY = 0; +const int32_t SUB_TYPE_ACTICE = 1; +const int32_t SUB_TYPE_DEACTIVE = 2; + +// Call waiting +const int32_t SC_WAIT = 43; + +// Call waiting +const int32_t SC_CFU = 21; +const int32_t SC_CFB = 67; +const int32_t SC_CFNRy = 61; +const int32_t SC_CFNR = 62; + +// Call Barring +const int32_t SC_BAOC = 33; +const int32_t SC_BAOIC = 331; +const int32_t SC_BAOICxH = 332; +const int32_t SC_BAIC = 35; +const int32_t SC_BAICr = 351; + +// Called line presention +const int32_t SC_CLIP = 30; +const int32_t SC_CLIR = 31; +const int32_t SC_COLP = 76; +const int32_t SC_COLR = 77; + +// called USSD +const int32_t SC_USSD = 10001; + /** * Create get call waiting result message * diff --git a/services/control/src/control_base.cpp b/services/control/src/control_base.cpp index ba83647f..429abc8b 100755 --- a/services/control/src/control_base.cpp +++ b/services/control/src/control_base.cpp @@ -84,7 +84,7 @@ bool ControlBase::IsNeedExecuteMMI(int32_t slotId, std::string &phoneString, CLI TELEPHONY_LOGI("IsNeedExecuteMMI return, isn't need to execute mmi"); return false; } - if (mmiCodeUtils->GetMMIData().serviceCode == "30" && !mmiCodeUtils->GetMMIData().dialString.empty()) { + if (!mmiCodeUtils->GetMMIData().serviceCode.empty() && !mmiCodeUtils->GetMMIData().dialString.empty()) { TELEPHONY_LOGI("IsNeedExecuteMMI, handle additional CLIR mode"); if (mmiCodeUtils->GetMMIData().actionString == "*") { phoneString = mmiCodeUtils->GetMMIData().dialString; diff --git a/services/manager/include/cellular_call_handler.h b/services/manager/include/cellular_call_handler.h index 6f469b1b..c3b3dbc4 100755 --- a/services/manager/include/cellular_call_handler.h +++ b/services/manager/include/cellular_call_handler.h @@ -228,6 +228,7 @@ private: void SetCallRestrictionResponse(const AppExecFwk::InnerEvent::Pointer &event); void SetBarringPasswordResponse(const AppExecFwk::InnerEvent::Pointer &event); int32_t ConfirmAndRemoveSsRequestCommand(int32_t index, int32_t &flag); + int32_t ConfirmAndRemoveSsRequestCommand(int32_t index, int32_t &flag, int32_t &action); void SendUssdResponse(const AppExecFwk::InnerEvent::Pointer &event); void SendUnlockPinPukResponse(const AppExecFwk::InnerEvent::Pointer &event); void CloseUnFinishedUssdResponse(const AppExecFwk::InnerEvent::Pointer &event); diff --git a/services/manager/include/cellular_call_service.h b/services/manager/include/cellular_call_service.h index 159e2499..ccaa9153 100755 --- a/services/manager/include/cellular_call_service.h +++ b/services/manager/include/cellular_call_service.h @@ -673,6 +673,15 @@ public: void StartCallManagerService(); #endif + /** + * Send ussd response to modem + * + * @param slotId + * @param content the content need send to modem + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t SendUssdResponse(int32_t slotId, const std::string &content) override; + private: /** * Init service diff --git a/services/manager/include/cellular_call_stub.h b/services/manager/include/cellular_call_stub.h index 231966d6..fa8aa617 100755 --- a/services/manager/include/cellular_call_stub.h +++ b/services/manager/include/cellular_call_stub.h @@ -551,6 +551,16 @@ private: int32_t OnSetEmergencyCallList(MessageParcel &data, MessageParcel &reply); + /** + * Send ussd response to modem + * + * @brief Send ussd response to modem + * @param slotId[in], The slot id + * @param content the content need send to modem + * @return Returns TELEPHONY_SUCCESS on success, others on failure. + */ + int32_t OnSendUssdResponse(MessageParcel &data, MessageParcel &reply); + private: using RequestFuncType = std::function; std::map requestFuncMap_; diff --git a/services/manager/src/cellular_call_handler.cpp b/services/manager/src/cellular_call_handler.cpp index ab93eff2..2f3a6f4a 100755 --- a/services/manager/src/cellular_call_handler.cpp +++ b/services/manager/src/cellular_call_handler.cpp @@ -1431,7 +1431,8 @@ void CellularCallHandler::SetCallWaitingResponse(const AppExecFwk::InnerEvent::P return; } int32_t flag = SS_FROM_MMI_CODE; - int32_t ret = ConfirmAndRemoveSsRequestCommand(result->index, flag); + int32_t action = INVALID_INDEX; + int32_t ret = ConfirmAndRemoveSsRequestCommand(result->index, flag, action); if (ret != TELEPHONY_SUCCESS) { return; } @@ -1439,7 +1440,7 @@ void CellularCallHandler::SetCallWaitingResponse(const AppExecFwk::InnerEvent::P if (result->result != TELEPHONY_SUCCESS) { result->result = TELEPHONY_ERR_RIL_CMD_FAIL; } - supplement.EventSetCallWaiting(result->result, result->message, flag); + supplement.EventSetCallWaiting(result->result, result->message, flag, action); } void CellularCallHandler::GetClirResponse(const AppExecFwk::InnerEvent::Pointer &event) @@ -1466,12 +1467,13 @@ void CellularCallHandler::SetClirResponse(const AppExecFwk::InnerEvent::Pointer return; } int32_t flag = SS_FROM_MMI_CODE; - int32_t ret = ConfirmAndRemoveSsRequestCommand(result->index, flag); + int32_t action = INVALID_INDEX; + int32_t ret = ConfirmAndRemoveSsRequestCommand(result->index, flag, action); if (ret != TELEPHONY_SUCCESS) { return; } CellularCallSupplement supplement; - supplement.EventSetClir(result->result, result->message, flag); + supplement.EventSetClir(result->result, result->message, flag, action); } void CellularCallHandler::GetClipResponse(const AppExecFwk::InnerEvent::Pointer &event) @@ -1498,12 +1500,13 @@ void CellularCallHandler::SetClipResponse(const AppExecFwk::InnerEvent::Pointer return; } int32_t flag = SS_FROM_MMI_CODE; - int32_t ret = ConfirmAndRemoveSsRequestCommand(result->index, flag); + int32_t action = INVALID_INDEX; + int32_t ret = ConfirmAndRemoveSsRequestCommand(result->index, flag, action); if (ret != TELEPHONY_SUCCESS) { return; } CellularCallSupplement supplement; - supplement.EventSetClip(result->result, result->message, flag); + supplement.EventSetClip(result->result, result->message, flag, action); } void CellularCallHandler::GetColrResponse(const AppExecFwk::InnerEvent::Pointer &event) @@ -1530,12 +1533,13 @@ void CellularCallHandler::SetColrResponse(const AppExecFwk::InnerEvent::Pointer return; } int32_t flag = SS_FROM_MMI_CODE; - int32_t ret = ConfirmAndRemoveSsRequestCommand(result->index, flag); + int32_t action = INVALID_INDEX; + int32_t ret = ConfirmAndRemoveSsRequestCommand(result->index, flag, action); if (ret != TELEPHONY_SUCCESS) { return; } CellularCallSupplement supplement; - supplement.EventSetColr(result->result, result->message, flag); + supplement.EventSetColr(result->result, result->message, flag, action); } void CellularCallHandler::GetColpResponse(const AppExecFwk::InnerEvent::Pointer &event) @@ -1562,12 +1566,13 @@ void CellularCallHandler::SetColpResponse(const AppExecFwk::InnerEvent::Pointer return; } int32_t flag = SS_FROM_MMI_CODE; - int32_t ret = ConfirmAndRemoveSsRequestCommand(result->index, flag); + int32_t action = INVALID_INDEX; + int32_t ret = ConfirmAndRemoveSsRequestCommand(result->index, flag, action); if (ret != TELEPHONY_SUCCESS) { return; } CellularCallSupplement supplement; - supplement.EventSetColp(result->result, result->message, flag); + supplement.EventSetColp(result->result, result->message, flag, action); } void CellularCallHandler::GetCallTransferResponse(const AppExecFwk::InnerEvent::Pointer &event) @@ -1599,7 +1604,8 @@ void CellularCallHandler::SetCallTransferInfoResponse(const AppExecFwk::InnerEve return; } int32_t flag = SS_FROM_MMI_CODE; - int32_t ret = ConfirmAndRemoveSsRequestCommand(result->index, flag); + int32_t action = INVALID_INDEX; + int32_t ret = ConfirmAndRemoveSsRequestCommand(result->index, flag, action); if (ret != TELEPHONY_SUCCESS) { return; } @@ -1616,7 +1622,7 @@ void CellularCallHandler::SetCallTransferInfoResponse(const AppExecFwk::InnerEve } else { result->result = TELEPHONY_ERR_RIL_CMD_FAIL; } - supplement.EventSetCallTransferInfo(result->result, result->message, flag); + supplement.EventSetCallTransferInfo(result->result, result->message, flag, action); } void CellularCallHandler::GetCallRestrictionResponse(const AppExecFwk::InnerEvent::Pointer &event) @@ -1643,7 +1649,8 @@ void CellularCallHandler::SetCallRestrictionResponse(const AppExecFwk::InnerEven return; } int32_t flag = SS_FROM_MMI_CODE; - int32_t ret = ConfirmAndRemoveSsRequestCommand(result->index, flag); + int32_t action = INVALID_INDEX; + int32_t ret = ConfirmAndRemoveSsRequestCommand(result->index, flag, action); if (ret != TELEPHONY_SUCCESS) { return; } @@ -1651,7 +1658,7 @@ void CellularCallHandler::SetCallRestrictionResponse(const AppExecFwk::InnerEven if (result->result != TELEPHONY_SUCCESS) { result->result = TELEPHONY_ERR_RIL_CMD_FAIL; } - supplement.EventSetCallRestriction(result->result, result->message, flag); + supplement.EventSetCallRestriction(result->result, result->message, flag, action); } void CellularCallHandler::SetBarringPasswordResponse(const AppExecFwk::InnerEvent::Pointer &event) @@ -1767,6 +1774,25 @@ int32_t CellularCallHandler::ConfirmAndRemoveSsRequestCommand(int32_t index, int return TELEPHONY_SUCCESS; } +int32_t CellularCallHandler::ConfirmAndRemoveSsRequestCommand(int32_t index, int32_t &flag, int32_t &action) +{ + if (index == INVALID_INDEX) { + // -1 mean this command index wasn't come from app, so don't need report result + TELEPHONY_LOGI("[slot%{public}d] index is invalid, nothing need to do", slotId_); + return TELEPHONY_ERROR; + } + std::lock_guard lock(mutex_); + auto itor = utCommandMap_.find(index); + if (itor == utCommandMap_.end()) { + TELEPHONY_LOGE("[slot%{public}d] the index(%{public}d) in utCommandMap_ haven't been found", slotId_, index); + return TELEPHONY_ERROR; + } + flag = itor->second->flag; + action = itor->second->action; + utCommandMap_.erase(index); + return TELEPHONY_SUCCESS; +} + int32_t CellularCallHandler::GetSsRequestCommand(int32_t index, SsRequestCommand &ss) { std::lock_guard lock(mutex_); diff --git a/services/manager/src/cellular_call_service.cpp b/services/manager/src/cellular_call_service.cpp index c3115ae7..868be417 100755 --- a/services/manager/src/cellular_call_service.cpp +++ b/services/manager/src/cellular_call_service.cpp @@ -1636,5 +1636,15 @@ bool CellularCallService::isRadioOnFlag(int32_t slotId) { return isRadioOn_[slotId]; } + +int32_t CellularCallService::SendUssdResponse(int32_t slotId, const std::string &content) +{ + if (!IsValidSlotId(slotId)) { + TELEPHONY_LOGE("CellularCallService::SendUssdResponse return, invalid slot id"); + return CALL_ERR_INVALID_SLOT_ID; + } + CellularCallSupplement supplement; + return supplement.SendUssd(slotId, content); +} } // namespace Telephony } // namespace OHOS diff --git a/services/manager/src/cellular_call_stub.cpp b/services/manager/src/cellular_call_stub.cpp index abd20c17..30698b76 100755 --- a/services/manager/src/cellular_call_stub.cpp +++ b/services/manager/src/cellular_call_stub.cpp @@ -216,6 +216,8 @@ void CellularCallStub::InitSupplementFuncMap() [this](MessageParcel &data, MessageParcel &reply) { return OnCloseUnFinishedUssdInner(data, reply); }; requestFuncMap_[CellularCallInterfaceCode::GET_VIDEO_CALL_WAITING] = [this](MessageParcel &data, MessageParcel &reply) { return OnGetVideoCallWaitingInner(data, reply); }; + requestFuncMap_[CellularCallInterfaceCode::SEND_USSD_RESPONSE] = + [this](MessageParcel &data, MessageParcel &reply) { return OnSendUssdResponse(data, reply); }; } int32_t CellularCallStub::OnDialInner(MessageParcel &data, MessageParcel &reply) @@ -1265,5 +1267,31 @@ int32_t CellularCallStub::OnClearAllCallsInner(MessageParcel &data, MessageParce reply.WriteInt32(ClearAllCalls(callInfos)); return TELEPHONY_SUCCESS; } + +int32_t CellularCallStub::OnSendUssdResponse(MessageParcel &data, MessageParcel &reply) +{ + TELEPHONY_LOGI("CellularCallStub::OnSendUssdResponse entry"); + int32_t size = data.ReadInt32(); + if (size <= 0 || size > MAX_CALL_NUM) { + TELEPHONY_LOGE("data size error"); + return TELEPHONY_ERR_FAIL; + } + int32_t slotId = data.ReadInt32(); + std::string content = data.ReadString(); + bool enable = false; + int32_t ret = SendUssdResponse(slotId, content); + if (!reply.WriteInt32(ret)) { + TELEPHONY_LOGE("fail to write ret"); + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (ret != TELEPHONY_SUCCESS) { + return ret; + } + if (!reply.WriteBool(enable)) { + TELEPHONY_LOGE("fail to write enabled"); + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + return TELEPHONY_SUCCESS; +} } // namespace Telephony } // namespace OHOS diff --git a/services/utils/include/cellular_call_supplement.h b/services/utils/include/cellular_call_supplement.h index 355afe64..0ddabf99 100644 --- a/services/utils/include/cellular_call_supplement.h +++ b/services/utils/include/cellular_call_supplement.h @@ -19,13 +19,14 @@ #include #include "cellular_call_data_struct.h" -#include "tel_ril_call_parcel.h" -#include "tel_ril_types.h" #include "ims_call_types.h" +#include "mmi_code_utils.h" #include "module_service_utils.h" #include "supplement_request_cs.h" #include "supplement_request_ims.h" #include "telephony_log_wrapper.h" +#include "tel_ril_call_parcel.h" +#include "tel_ril_types.h" namespace OHOS { namespace Telephony { @@ -306,9 +307,10 @@ public: * @param result * @param message the remain message for user which come from network * @param flag, {@code SS_FROM_MMI_CODE} mean the request action come from dial api + * @param action, query,active or deactive * {@code SS_FROM_SETTING_MENU} means the request action come from setting app. */ - void EventSetClip(int32_t result, const std::string &message, int32_t flag); + void EventSetClip(int32_t result, const std::string &message, int32_t flag, int32_t action); /** * Get clir result @@ -330,9 +332,10 @@ public: * @param result * @param message the remain message for user which come from network * @param flag, {@code SS_FROM_MMI_CODE} mean the request action come from dial api + * @param action, query,active or deactive * {@code SS_FROM_SETTING_MENU} means the request action come from setting app. */ - void EventSetClir(int32_t result, const std::string &message, int32_t flag); + void EventSetClir(int32_t result, const std::string &message, int32_t flag, int32_t action); /** * Get colr result @@ -354,9 +357,10 @@ public: * @param result * @param message the remain message for user which come from network * @param flag, {@code SS_FROM_MMI_CODE} mean the request action come from dial api + * @param action, query,active or deactive * {@code SS_FROM_SETTING_MENU} means the request action come from setting app. */ - void EventSetColr(int32_t result, const std::string &message, int32_t flag); + void EventSetColr(int32_t result, const std::string &message, int32_t flag, int32_t action); /** * Get colp result @@ -378,9 +382,10 @@ public: * @param result * @param message the remain message for user which come from network * @param flag, {@code SS_FROM_MMI_CODE} mean the request action come from dial api + * @param action, query,active or deactive * {@code SS_FROM_SETTING_MENU} means the request action come from setting app. */ - void EventSetColp(int32_t result, const std::string &message, int32_t flag); + void EventSetColp(int32_t result, const std::string &message, int32_t flag, int32_t action); /** * Get call restriction result @@ -402,9 +407,10 @@ public: * @param result * @param message the remain message for user which come from network * @param flag, {@code SS_FROM_MMI_CODE} mean the request action come from dial api + * @param action, query,active or deactive * {@code SS_FROM_SETTING_MENU} means the request action come from setting app. */ - void EventSetCallRestriction(int32_t result, const std::string &message, int32_t flag); + void EventSetCallRestriction(int32_t result, const std::string &message, int32_t flag, int32_t action); /** * Set call restriction password result @@ -438,9 +444,10 @@ public: * @param result * @param message the remain message for user which come from network * @param flag, {@code SS_FROM_MMI_CODE} mean the request action come from dial api + * @param action, query,active or deactive * {@code SS_FROM_SETTING_MENU} means the request action come from setting app. */ - void EventSetCallWaiting(int32_t result, const std::string &message, int32_t flag); + void EventSetCallWaiting(int32_t result, const std::string &message, int32_t flag, int32_t action); /** * Get call transfer result @@ -463,9 +470,10 @@ public: * @param result * @param message the remain message for user which come from network * @param flag, {@code SS_FROM_MMI_CODE} mean the request action come from dial api + * @param action, query,active or deactive * {@code SS_FROM_SETTING_MENU} means the request action come from setting app. */ - void EventSetCallTransferInfo(int32_t result, const std::string &message, int32_t flag); + void EventSetCallTransferInfo(int32_t result, const std::string &message, int32_t flag, int32_t action); /** * Send ussd result @@ -595,6 +603,7 @@ private: void BuildCallForwardQueryInfo(const CallForwardQueryResult &queryResult, const std::string &message, int32_t flag); void ReportMmiCodeMessage(int32_t result, const std::string successMsg, const std::string failedMsg); bool IsVaildPinOrPuk(std::string newPinOrPuk, std::string newPinOrPukCheck); + void ReportMmiCodeMessage(const MmiCodeInfo &mmiCodeInfo); private: SupplementRequestCs supplementRequestCs_; diff --git a/services/utils/include/mmi_code_utils.h b/services/utils/include/mmi_code_utils.h index de9c9e62..0c69412e 100644 --- a/services/utils/include/mmi_code_utils.h +++ b/services/utils/include/mmi_code_utils.h @@ -63,6 +63,10 @@ public: */ MMIData GetMMIData(); + bool IsShortCode(const std::string &analyseString); + + bool HasCellularCallExist(); + private: /** * RegexMatchMmi diff --git a/services/utils/src/cellular_call_supplement.cpp b/services/utils/src/cellular_call_supplement.cpp index a24adb87..b95278a3 100644 --- a/services/utils/src/cellular_call_supplement.cpp +++ b/services/utils/src/cellular_call_supplement.cpp @@ -36,8 +36,7 @@ const int32_t DEACTIVATE_ACTION = 2; const int32_t USSD_MODE_NOTIFY = 0; const int32_t USSD_MODE_REQUEST = 1; const int32_t USSD_MODE_NW_RELEASE = 2; -const int32_t USSD_SUCCESS = 0; -const int32_t USSD_FAILED = 1; +const int32_t USSD_FAILED = 2; const int32_t RESULT_SUCCESS = 0; const int32_t MMI_CODE_FAILED = 1; const int32_t PIN_PUK_MIN = 4; @@ -165,12 +164,12 @@ void CellularCallSupplement::HandleColr(int32_t slotId, const MMIData &mmiData) int32_t index; handler->RequestSsRequestCommandIndex(index); if (mmiData.actionString == activate) { - utCommand->action = NUM_PRESENTATION_ALLOWED; + utCommand->action = ACTIVATE_ACTION; if (NeedUseImsToHandle(slotId)) { result = supplementRequestIms_.SetColrRequest(slotId, NUM_PRESENTATION_ALLOWED, index); } } else if (mmiData.actionString == deactivate) { - utCommand->action = NUM_PRESENTATION_RESTRICTED; + utCommand->action = DEACTIVATE_ACTION; if (NeedUseImsToHandle(slotId)) { result = supplementRequestIms_.SetColrRequest(slotId, NUM_PRESENTATION_RESTRICTED, index); } @@ -396,6 +395,7 @@ void CellularCallSupplement::HandleSetCallTransfer(int32_t slotId, int32_t servi auto utCommand = std::make_shared(); utCommand->cfReason = cause; utCommand->cfAction = static_cast(callTransferAction); + utCommand->action = static_cast(callTransferAction); utCommand->number = phoneNumber; int32_t index; handler->RequestSsRequestCommandIndex(index); @@ -559,6 +559,7 @@ void CellularCallSupplement::HandleCallWaiting(int32_t slotId, const MMIData &mm handler->RequestSsRequestCommandIndex(index); if (mmiData.actionString == activate || mmiData.actionString == deactivate) { utCommand->enable = mmiData.actionString == activate; + utCommand->action = mmiData.actionString == activate; if (NeedUseImsToHandle(slotId)) { result = supplementRequestIms_.SetCallWaitingRequest(slotId, mmiData.actionString == activate, classType, index); @@ -604,14 +605,23 @@ void CellularCallSupplement::EventGetCallWaiting( if (flag == SS_FROM_MMI_CODE) { std::string successMessage = GET_CALL_WAITING_SUCCESS; CreateGetCallWaitingResultMessage(successMessage, callWaitResponse); - ReportMmiCodeMessage( - callWaitResponse.result, successMessage, message.empty() ? GET_CALL_WAITING_FAILED : message); + MmiCodeInfo mmiCodeInfo; + mmiCodeInfo.result = callWaitResponse.result; + if (strcpy_s(mmiCodeInfo.message, sizeof(mmiCodeInfo.message), message.c_str()) != EOK) { + TELEPHONY_LOGE("strcpy_s fial"); + } + mmiCodeInfo.mmiCodeType = SC_WAIT; + mmiCodeInfo.action = SUB_TYPE_QUERY; + mmiCodeInfo.status = waitingInfo.status; + mmiCodeInfo.classCw = waitingInfo.classCw; + ReportMmiCodeMessage(mmiCodeInfo); } else { callRegister->ReportGetWaitingResult(callWaitResponse); } } -void CellularCallSupplement::EventSetCallWaiting(int32_t result, const std::string &message, int32_t flag) +void CellularCallSupplement::EventSetCallWaiting(int32_t result, + const std::string &message, int32_t flag, int32_t action) { auto callRegister = DelayedSingleton::GetInstance(); if (callRegister == nullptr) { @@ -619,7 +629,15 @@ void CellularCallSupplement::EventSetCallWaiting(int32_t result, const std::stri return; } if (flag == SS_FROM_MMI_CODE) { - ReportMmiCodeMessage(result, SET_CALL_WAITING_SUCCESS, message.empty() ? SET_CALL_WAITING_FAILED : message); + MmiCodeInfo mmiCodeInfo; + mmiCodeInfo.result = result; + if (strcpy_s(mmiCodeInfo.message, sizeof(mmiCodeInfo.message), message.c_str()) != EOK) { + TELEPHONY_LOGE("strcpy_s fial"); + } + mmiCodeInfo.mmiCodeType = SC_WAIT; + mmiCodeInfo.action = action ? SUB_TYPE_ACTICE : SUB_TYPE_DEACTIVE; + + ReportMmiCodeMessage(mmiCodeInfo); } else { callRegister->ReportSetWaitingResult(result); } @@ -686,7 +704,18 @@ void CellularCallSupplement::BuildCallForwardQueryInfo( if (flag == SS_FROM_MMI_CODE) { std::string successMessage = GET_CALL_TRANSFER_SUCCESS; CreateGetCallTransferResultMessage(successMessage, response); - ReportMmiCodeMessage(queryResult.result, successMessage, message.empty() ? GET_CALL_TRANSFER_FAILED : message); + MmiCodeInfo mmiCodeInfo; + mmiCodeInfo.mmiCodeType = SC_CFU; + mmiCodeInfo.action = SUB_TYPE_QUERY; + mmiCodeInfo.result = queryResult.result; + mmiCodeInfo.classCw = queryResult.classx; + mmiCodeInfo.reason = queryResult.reason; + mmiCodeInfo.status = queryResult.status; + if (strcpy_s(mmiCodeInfo.message, sizeof(mmiCodeInfo.message), message.c_str()) != EOK) { + TELEPHONY_LOGE("strcpy_s fial"); + } + mmiCodeInfo.time = queryResult.time; + ReportMmiCodeMessage(mmiCodeInfo); } else { auto callRegister = DelayedSingleton::GetInstance(); if (callRegister == nullptr) { @@ -697,7 +726,8 @@ void CellularCallSupplement::BuildCallForwardQueryInfo( } } -void CellularCallSupplement::EventSetCallTransferInfo(int32_t result, const std::string &message, int32_t flag) +void CellularCallSupplement::EventSetCallTransferInfo(int32_t result, const std::string &message, int32_t flag, + int32_t action) { auto callRegister = DelayedSingleton::GetInstance(); if (callRegister == nullptr) { @@ -706,7 +736,14 @@ void CellularCallSupplement::EventSetCallTransferInfo(int32_t result, const std: } if (flag == SS_FROM_MMI_CODE) { - ReportMmiCodeMessage(result, SET_CALL_TRANSFER_SUCCESS, message.empty() ? SET_CALL_TRANSFER_FAILED : message); + MmiCodeInfo mmiCodeInfo; + mmiCodeInfo.result = result; + if (strcpy_s(mmiCodeInfo.message, sizeof(mmiCodeInfo.message), message.c_str()) != EOK) { + TELEPHONY_LOGE("strcpy_s fial"); + } + mmiCodeInfo.mmiCodeType = SC_CFU; + mmiCodeInfo.action = action ? SUB_TYPE_ACTICE : SUB_TYPE_DEACTIVE; + ReportMmiCodeMessage(mmiCodeInfo); } else { callRegister->ReportSetTransferResult(result); } @@ -734,15 +771,22 @@ void CellularCallSupplement::EventGetCallRestriction( if (flag == SS_FROM_MMI_CODE) { std::string successMessage = GET_CALL_RESTRICTION_SUCCESS; - CreateSuppSvcQueryResultMessage(successMessage, response.result, response.status); - ReportMmiCodeMessage( - result.result.result, successMessage, message.empty() ? GET_CALL_RESTRICTION_FAILED : message); + MmiCodeInfo mmiCodeInfo; + mmiCodeInfo.result = response.result; + mmiCodeInfo.mmiCodeType = SC_CLIP; + mmiCodeInfo.action = SUB_TYPE_QUERY; + mmiCodeInfo.status = response.status; + if (strcpy_s(mmiCodeInfo.message, sizeof(mmiCodeInfo.message), message.c_str()) != EOK) { + TELEPHONY_LOGE("strcpy_s fial"); + } + ReportMmiCodeMessage(mmiCodeInfo); } else { callRegister->ReportGetRestrictionResult(response); } } -void CellularCallSupplement::EventSetCallRestriction(int32_t result, const std::string &message, int32_t flag) +void CellularCallSupplement::EventSetCallRestriction(int32_t result, const std::string &message, int32_t flag, + int32_t action) { auto callRegister = DelayedSingleton::GetInstance(); if (callRegister == nullptr) { @@ -750,8 +794,14 @@ void CellularCallSupplement::EventSetCallRestriction(int32_t result, const std:: return; } if (flag == SS_FROM_MMI_CODE) { - ReportMmiCodeMessage( - result, SET_CALL_RESTRICTION_SUCCESS, message.empty() ? SET_CALL_RESTRICTION_FAILED : message); + MmiCodeInfo mmiCodeInfo; + mmiCodeInfo.result = result; + mmiCodeInfo.mmiCodeType = SC_CLIP; + mmiCodeInfo.action = action ? SUB_TYPE_ACTICE : SUB_TYPE_DEACTIVE; + if (strcpy_s(mmiCodeInfo.message, sizeof(mmiCodeInfo.message), message.c_str()) != EOK) { + TELEPHONY_LOGE("strcpy_s fial"); + } + ReportMmiCodeMessage(mmiCodeInfo); } else { callRegister->ReportSetRestrictionResult(result); } @@ -765,8 +815,14 @@ void CellularCallSupplement::EventSetBarringPassword(int32_t result, const std:: return; } if (flag == SS_FROM_MMI_CODE) { - ReportMmiCodeMessage( - result, SET_SET_BARRING_PASSWORD_SUCCESS, message.empty() ? SET_SET_BARRING_PASSWORD_FAILED : message); + MmiCodeInfo mmiCodeInfo; + mmiCodeInfo.result = result; + mmiCodeInfo.mmiCodeType = SC_BAOC; + mmiCodeInfo.action = SUB_TYPE_ACTICE; + if (strcpy_s(mmiCodeInfo.message, sizeof(mmiCodeInfo.message), message.c_str()) != EOK) { + TELEPHONY_LOGE("strcpy_s fial"); + } + ReportMmiCodeMessage(mmiCodeInfo); } else { callRegister->ReportSetBarringPasswordResult(result); } @@ -941,6 +997,7 @@ int32_t CellularCallSupplement::SetCallWaiting(int32_t slotId, bool activate) utCommand->flag = SS_FROM_SETTING_MENU; utCommand->classType = classType; utCommand->enable = activate; + utCommand->action = activate; int32_t index; if (NeedUseImsToHandle(slotId)) { handler->RequestSsRequestCommandIndex(index); @@ -1022,6 +1079,7 @@ int32_t CellularCallSupplement::SetCallRestriction(int32_t slotId, const CallRes utCommand->flag = SS_FROM_SETTING_MENU; utCommand->facility = fac; utCommand->enable = static_cast(cRInfo.mode); + utCommand->action = static_cast(cRInfo.mode); size_t cpyLen = strlen(info.c_str()) + 1; size_t maxCpyLen = sizeof(utCommand->password); if (strcpy_s(utCommand->password, cpyLen > maxCpyLen ? maxCpyLen : cpyLen, info.c_str()) != EOK) { @@ -1192,17 +1250,31 @@ void CellularCallSupplement::EventGetClip(const GetClipResult &getClipResult, co if (flag == SS_FROM_MMI_CODE) { std::string successMessage = GET_CLIP_SUCCESS; - CreateSuppSvcQueryResultMessage(successMessage, clipResponse.result, clipResponse.clipStat); - ReportMmiCodeMessage(clipResponse.result, successMessage, message.empty() ? GET_CLIP_FAILED : message); + MmiCodeInfo mmiCodeInfo; + mmiCodeInfo.result = clipResponse.result; + if (strcpy_s(mmiCodeInfo.message, sizeof(mmiCodeInfo.message), successMessage.c_str()) != EOK) { + TELEPHONY_LOGE("strcpy_s fail."); + } + mmiCodeInfo.mmiCodeType = SC_CLIP; + mmiCodeInfo.action = SUB_TYPE_QUERY; + mmiCodeInfo.status = clipResponse.clipStat; + ReportMmiCodeMessage(mmiCodeInfo); } else { callRegister->ReportGetClipResult(clipResponse); } } -void CellularCallSupplement::EventSetClip(int32_t result, const std::string &message, int32_t flag) +void CellularCallSupplement::EventSetClip(int32_t result, const std::string &message, int32_t flag, int32_t action) { if (flag == SS_FROM_MMI_CODE) { - ReportMmiCodeMessage(result, SET_CLIP_SUCCESS, message.empty() ? SET_CLIP_FAILED : message); + MmiCodeInfo mmiCodeInfo; + mmiCodeInfo.result = result; + if (strcpy_s(mmiCodeInfo.message, sizeof(mmiCodeInfo.message), message.c_str()) != EOK) { + TELEPHONY_LOGE("strcpy_s fail."); + } + mmiCodeInfo.mmiCodeType = SC_CLIP; + mmiCodeInfo.action = action == ACTIVATE_ACTION ? SUB_TYPE_ACTICE : SUB_TYPE_DEACTIVE; + ReportMmiCodeMessage(mmiCodeInfo); } else { TELEPHONY_LOGE("report the result of GetColp failed since the flag %{public}d was wrong", flag); } @@ -1225,14 +1297,22 @@ void CellularCallSupplement::EventGetClir(const GetClirResult &result, const std } if (flag == SS_FROM_MMI_CODE) { std::string successMessage = GET_CLIR_SUCCESS; - CreateGetClirResultMessage(successMessage, response); - ReportMmiCodeMessage(response.result, successMessage, message.empty() ? GET_CLIR_FAILED : message); + MmiCodeInfo mmiCodeInfo; + mmiCodeInfo.result = response.result; + if (strcpy_s(mmiCodeInfo.message, sizeof(mmiCodeInfo.message), successMessage.c_str()) != EOK) { + TELEPHONY_LOGE("strcpy_s fail."); + } + mmiCodeInfo.mmiCodeType = SC_CLIR; + mmiCodeInfo.action = SUB_TYPE_QUERY; + mmiCodeInfo.status = response.clirStat; + mmiCodeInfo.classCw = response.action; + ReportMmiCodeMessage(mmiCodeInfo); } else { callRegister->ReportGetClirResult(response); } } -void CellularCallSupplement::EventSetClir(int32_t result, const std::string &message, int32_t flag) +void CellularCallSupplement::EventSetClir(int32_t result, const std::string &message, int32_t flag, int32_t action) { auto callRegister = DelayedSingleton::GetInstance(); if (callRegister == nullptr) { @@ -1240,7 +1320,14 @@ void CellularCallSupplement::EventSetClir(int32_t result, const std::string &mes return; } if (flag == SS_FROM_MMI_CODE) { - ReportMmiCodeMessage(result, SET_CLIR_SUCCESS, message.empty() ? SET_CLIR_FAILED : message); + MmiCodeInfo mmiCodeInfo; + mmiCodeInfo.result = result; + if (strcpy_s(mmiCodeInfo.message, sizeof(mmiCodeInfo.message), message.c_str()) != EOK) { + TELEPHONY_LOGE("strcpy_s fail."); + } + mmiCodeInfo.mmiCodeType = SC_CLIR; + mmiCodeInfo.action = action == ACTIVATE_ACTION ? SUB_TYPE_ACTICE : SUB_TYPE_DEACTIVE; + ReportMmiCodeMessage(mmiCodeInfo); } else { callRegister->ReportSetClirResult(result); } @@ -1257,17 +1344,31 @@ void CellularCallSupplement::EventGetColr(const GetColrResult &result, const std response.colrStat = result.colrStat; if (flag == SS_FROM_MMI_CODE) { std::string successMessage = GET_COLR_SUCCESS; - CreateSuppSvcQueryResultMessage(successMessage, response.result, response.colrStat); - ReportMmiCodeMessage(response.result, successMessage, message.empty() ? GET_COLR_FAILED : message); + MmiCodeInfo mmiCodeInfo; + mmiCodeInfo.result = response.result; + if (strcpy_s(mmiCodeInfo.message, sizeof(mmiCodeInfo.message), successMessage.c_str()) != EOK) { + TELEPHONY_LOGE("strcpy_s fail."); + } + mmiCodeInfo.mmiCodeType = SC_COLR; + mmiCodeInfo.action = SUB_TYPE_QUERY; + mmiCodeInfo.status = response.colrStat; + ReportMmiCodeMessage(mmiCodeInfo); } else { TELEPHONY_LOGE("report the result of GetColp failed since the flag %{public}d was wrong", flag); } } -void CellularCallSupplement::EventSetColr(int32_t result, const std::string &message, int32_t flag) +void CellularCallSupplement::EventSetColr(int32_t result, const std::string &message, int32_t flag, int32_t action) { if (flag == SS_FROM_MMI_CODE) { - ReportMmiCodeMessage(result, SET_COLR_SUCCESS, message.empty() ? SET_COLR_FAILED : message); + MmiCodeInfo mmiCodeInfo; + mmiCodeInfo.result = result; + if (strcpy_s(mmiCodeInfo.message, sizeof(mmiCodeInfo.message), message.c_str()) != EOK) { + TELEPHONY_LOGE("strcpy_s fail."); + } + mmiCodeInfo.mmiCodeType = SC_COLR; + mmiCodeInfo.action = action == ACTIVATE_ACTION ? SUB_TYPE_ACTICE : SUB_TYPE_DEACTIVE; + ReportMmiCodeMessage(mmiCodeInfo); } else { TELEPHONY_LOGE("report the result of GetColp failed since the flag %{public}d was wrong", flag); } @@ -1284,17 +1385,31 @@ void CellularCallSupplement::EventGetColp(const GetColpResult &result, const std response.colpStat = result.colpStat; if (flag == SS_FROM_MMI_CODE) { std::string successMessage = GET_COLP_SUCCESS; - CreateSuppSvcQueryResultMessage(successMessage, response.result, response.colpStat); - ReportMmiCodeMessage(response.result, successMessage, message.empty() ? GET_COLP_FAILED : message); + MmiCodeInfo mmiCodeInfo; + mmiCodeInfo.result = response.result; + if (strcpy_s(mmiCodeInfo.message, sizeof(mmiCodeInfo.message), successMessage.c_str()) != EOK) { + TELEPHONY_LOGE("strcpy_s fail."); + } + mmiCodeInfo.mmiCodeType = SC_COLP; + mmiCodeInfo.action = SUB_TYPE_QUERY; + mmiCodeInfo.status = response.colpStat; + ReportMmiCodeMessage(mmiCodeInfo); } else { TELEPHONY_LOGE("report the result of GetColp failed since the flag %{public}d was wrong", flag); } } -void CellularCallSupplement::EventSetColp(int32_t result, const std::string &message, int32_t flag) +void CellularCallSupplement::EventSetColp(int32_t result, const std::string &message, int32_t flag, int32_t action) { if (flag == SS_FROM_MMI_CODE) { - ReportMmiCodeMessage(result, SET_COLP_SUCCESS, message.empty() ? SET_COLP_FAILED : message); + MmiCodeInfo mmiCodeInfo; + mmiCodeInfo.result = result; + if (strcpy_s(mmiCodeInfo.message, sizeof(mmiCodeInfo.message), message.c_str()) != EOK) { + TELEPHONY_LOGE("strcpy_s fail."); + } + mmiCodeInfo.mmiCodeType = SC_COLP; + mmiCodeInfo.action = action == ACTIVATE_ACTION ? SUB_TYPE_ACTICE : SUB_TYPE_DEACTIVE; + ReportMmiCodeMessage(mmiCodeInfo); } else { TELEPHONY_LOGE("report the result of GetColp failed since the flag %{public}d was wrong", flag); } @@ -1302,15 +1417,16 @@ void CellularCallSupplement::EventSetColp(int32_t result, const std::string &mes int32_t CellularCallSupplement::SendUssd(int32_t slotId, const std::string &msg) { - if (!PhoneTypeGsmOrNot(slotId)) { - ReportMmiCodeMessage(MMI_CODE_FAILED, "", GENERIC_FAILURE); - TELEPHONY_LOGE("[slot%{public}d] network type is not supported!", slotId); - return CALL_ERR_UNSUPPORTED_NETWORK_TYPE; - } int32_t result = TELEPHONY_SUCCESS; result = supplementRequestCs_.SendUssdRequest(slotId, msg); if (result != TELEPHONY_SUCCESS) { - ReportMmiCodeMessage(MMI_CODE_FAILED, "", GENERIC_FAILURE); + MmiCodeInfo mmiCodeInfo; + mmiCodeInfo.result = USSD_FAILED; + mmiCodeInfo.mmiCodeType = SC_USSD; + if (strcpy_s(mmiCodeInfo.message, sizeof(mmiCodeInfo.message), GENERIC_FAILURE.c_str()) != EOK) { + TELEPHONY_LOGE("strcpy_s fail."); + } + ReportMmiCodeMessage(mmiCodeInfo); } return result; } @@ -1323,7 +1439,13 @@ void CellularCallSupplement::EventSendUssd(const RadioResponseInfo &responseInfo return; } callRegister->ReportSendUssdResult(static_cast(responseInfo.error)); - ReportMmiCodeMessage(static_cast(responseInfo.error), SEND_USSD_SUCCESS, INVALID_MMI_CODE); + if (responseInfo.error == ErrType::NONE) { + return; + } + MmiCodeInfo mmiCodeInfo; + mmiCodeInfo.result = USSD_FAILED; + mmiCodeInfo.mmiCodeType = SC_USSD; + ReportMmiCodeMessage(mmiCodeInfo); } void CellularCallSupplement::EventSsNotify(SsNoticeInfo &ssNoticeInfo) @@ -1411,6 +1533,8 @@ void CellularCallSupplement::EventUssdNotify(UssdNoticeInfo &ussdNoticeInfo, int TELEPHONY_EXT_WRAPPER.unescapeHtmlCode_(slotId, ussdNoticeInfo.str); } MmiCodeInfo mmiCodeInfo; + mmiCodeInfo.mmiCodeType = SC_USSD; + mmiCodeInfo.action = slotId; bool isUssdError = ussdNoticeInfo.m != USSD_MODE_NOTIFY && ussdNoticeInfo.m != USSD_MODE_REQUEST; if (TELEPHONY_EXT_WRAPPER.isUssdReleaseMsgFiltered_ != nullptr) { if (TELEPHONY_EXT_WRAPPER.isUssdReleaseMsgFiltered_(slotId)) { @@ -1419,7 +1543,7 @@ void CellularCallSupplement::EventUssdNotify(UssdNoticeInfo &ussdNoticeInfo, int } } if (!isUssdError && !ussdNoticeInfo.str.empty()) { - mmiCodeInfo.result = USSD_SUCCESS; + mmiCodeInfo.result = ussdNoticeInfo.m; if (strcpy_s(mmiCodeInfo.message, sizeof(mmiCodeInfo.message), ussdNoticeInfo.str.c_str()) != EOK) { TELEPHONY_LOGE("strcpy_s ussdNoticeInfo.str fail."); return; @@ -1431,6 +1555,7 @@ void CellularCallSupplement::EventUssdNotify(UssdNoticeInfo &ussdNoticeInfo, int return; } } else { + mmiCodeInfo.result = USSD_FAILED; TELEPHONY_LOGE("Invaild ussd notify."); } @@ -1600,5 +1725,15 @@ void CellularCallSupplement::EventCloseUnFinishedUssd(const RadioResponseInfo &r } callRegister->ReportCloseUnFinishedUssdResult(result); } + +void CellularCallSupplement::ReportMmiCodeMessage(const MmiCodeInfo &mmiCodeInfo) +{ + auto callRegister = DelayedSingleton::GetInstance(); + if (callRegister == nullptr) { + TELEPHONY_LOGE("callRegister is null."); + return; + } + callRegister->ReportMmiCodeResult(mmiCodeInfo); +} } // namespace Telephony } // namespace OHOS diff --git a/services/utils/src/mmi_code_utils.cpp b/services/utils/src/mmi_code_utils.cpp index 182f65c9..07ff08ed 100644 --- a/services/utils/src/mmi_code_utils.cpp +++ b/services/utils/src/mmi_code_utils.cpp @@ -17,7 +17,9 @@ #include +#include "cellular_call_service.h" #include "cellular_call_supplement.h" +#include "core_manager_inner.h" #include "standardize_utils.h" #include "telephony_log_wrapper.h" @@ -212,6 +214,9 @@ bool MMICodeUtils::ExecuteMmiCode(int32_t slotId) bool MMICodeUtils::RegexMatchMmi(const std::string &analyseString) { + if (IsShortCode(analyseString)) { + return true; + } std::string symbols = "((\\*|#|\\*#|\\*\\*|##)(\\d{2,3})(\\*([^*#]*)(\\*([^*#]*)(\\*([^*#]*)(\\*([^*#]*))?)?)?)?#)(.*)"; std::regex pattern(symbols); @@ -262,5 +267,50 @@ MMIData MMICodeUtils::GetMMIData() { return mmiData_; } + +bool MMICodeUtils::IsShortCode(const std::string &analyseString) +{ + std::string symbols = "^(?!1\\d)\\d{2}"; + if (HasCellularCallExist()) { + symbols = "\\d{1,2}"; + } + TELEPHONY_LOGI("IsShortCode HasCellularCallExist = %{public}d", HasCellularCallExist()); + std::regex shortCodePattern(symbols); + std::smatch shortCodeResult; + if (regex_match(analyseString, shortCodeResult, shortCodePattern)) { + TELEPHONY_LOGI("IsShortCode: shortCodeResult true"); + mmiData_.fullString = analyseString; + return true; + } + return false; +} + +bool MMICodeUtils::HasCellularCallExist() +{ + int32_t simCount = CoreManagerInner::GetInstance().GetMaxSimCount(); + if (simCount == 0) { + return false; + } + auto serviceInstance = DelayedSingleton::GetInstance(); + if (serviceInstance == nullptr) { + TELEPHONY_LOGE("serviceInstance is null"); + return false; + } + for (int32_t i = 0; i < simCount; i++) { + auto imsControl = serviceInstance->GetImsControl(i); + if (imsControl != nullptr && !imsControl->GetConnectionMap().empty()) { + return true; + } + auto csControl = serviceInstance->GetCsControl(i); + if (csControl != nullptr && !csControl->GetConnectionMap().empty()) { + return true; + } + auto satelliteControl = serviceInstance->GetSatelliteControl(i); + if (satelliteControl != nullptr && !satelliteControl->GetConnectionMap().empty()) { + return true; + } + } + return false; +} } // namespace Telephony } // namespace OHOS diff --git a/test/unittest/imstest/zero_branch1_test.cpp b/test/unittest/imstest/zero_branch1_test.cpp index 9e12c148..7624c6e4 100644 --- a/test/unittest/imstest/zero_branch1_test.cpp +++ b/test/unittest/imstest/zero_branch1_test.cpp @@ -418,6 +418,10 @@ HWTEST_F(ZeroBranch1Test, Telephony_CellularCallStub_005, Function | MediumTest MessageParcel clearCallsData; MakeCallInfoParcelData(false, clearCallsData); ASSERT_EQ(callStub.OnClearAllCallsInner(clearCallsData, reply), TELEPHONY_SUCCESS); + MessageParcel ussdData; + ussdData.WriteInt32(0); + ussdData.WriteString("1"); + ASSERT_EQ(callStub.OnSendUssdResponse(ussdData, reply), TELEPHONY_SUCCESS); } /** @@ -725,6 +729,7 @@ HWTEST_F(ZeroBranch1Test, Telephony_CellularCallService_004, Function | MediumTe cellularCall.UnRegisterCallManagerCallBack(); cellularCall.HandlerResetUnRegister(); cellularCall.OnStop(); + cellularCall.SendUssdResponse(0, "1"); ASSERT_EQ(callback, nullptr); } @@ -968,6 +973,21 @@ HWTEST_F(ZeroBranch1Test, Telephony_MmiCodeUtils_001, Function | MediumTest | Le mmiCodeUtils.mmiData_.fullString.clear(); mmiCodeUtils.mmiData_.dialString = "11111#"; ASSERT_FALSE(mmiCodeUtils.RegexMatchMmi("111111#")); + std::string dialStr = ""; + ASSERT_FALSE(mmiCodeUtils.IsNeedExecuteMMI(dialStr, enable)); + std::string dialStr = "12"; + ASSERT_FALSE(mmiCodeUtils.IsNeedExecuteMMI(dialStr, enable)); + std::string dialStr = "33"; + ASSERT_FALSE(mmiCodeUtils.IsNeedExecuteMMI(dialStr, enable)); + std::string dialStr = "*21*10086#"; + ASSERT_FALSE(mmiCodeUtils.IsNeedExecuteMMI(dialStr, enable)); + mmiCodeUtils.GetMMIData(); + std::string dialStr = "10086"; + ASSERT_FALSE(mmiCodeUtils.IsNeedExecuteMMI(dialStr, enable)); + std::string dialStr = "*30#10086"; + ASSERT_FALSE(mmiCodeUtils.IsNeedExecuteMMI(dialStr, enable)); + std::string dialStr = "*33##123#"; + ASSERT_FALSE(mmiCodeUtils.IsNeedExecuteMMI(dialStr, enable)); } /** diff --git a/test/unittest/imstest/zero_branch_test.cpp b/test/unittest/imstest/zero_branch_test.cpp index 8dcacb35..28afd360 100644 --- a/test/unittest/imstest/zero_branch_test.cpp +++ b/test/unittest/imstest/zero_branch_test.cpp @@ -318,18 +318,18 @@ HWTEST_F(ZeroBranchTest, Telephony_CellularCallSupplement_002, Function | Medium std::string message = ""; callSup.EventGetClip(getClipResult, message, 0); callSup.EventGetClip(getClipResult, message, 1); - callSup.EventSetClip(0, message, 0); - callSup.EventSetClip(0, message, 1); + callSup.EventSetClip(0, message, 0, 1); + callSup.EventSetClip(0, message, 1, 1); GetClirResult getClirResult; callSup.EventGetClir(getClirResult, message, 0); callSup.EventGetClir(getClirResult, message, 1); - callSup.EventSetClir(0, message, 0); - callSup.EventSetClir(0, message, 1); + callSup.EventSetClir(0, message, 0, 1); + callSup.EventSetClir(0, message, 1, 1); GetColrResult getColrResult; callSup.EventGetColr(getColrResult, message, 0); callSup.EventGetColr(getColrResult, message, 1); - callSup.EventSetColr(0, message, 0); - callSup.EventSetColr(0, message, 1); + callSup.EventSetColr(0, message, 0, 1); + callSup.EventSetColr(0, message, 1, 1); ASSERT_TRUE(mmiDataPin.actionString.empty()); } @@ -346,8 +346,8 @@ HWTEST_F(ZeroBranchTest, Telephony_CellularCallSupplement_003, Function | Medium std::string message = ""; callSup.EventGetColp(getColpResult, message, 0); callSup.EventGetColp(getColpResult, message, 1); - callSup.EventSetColp(0, message, 0); - callSup.EventSetColp(0, message, 1); + callSup.EventSetColp(0, message, 0, 1); + callSup.EventSetColp(0, message, 1, 1); CallRestrictionResult callResResult; callSup.EventGetCallRestriction(callResResult, message, 0); callSup.EventGetCallRestriction(callResResult, message, 1); @@ -355,12 +355,12 @@ HWTEST_F(ZeroBranchTest, Telephony_CellularCallSupplement_003, Function | Medium callSup.EventGetCallRestriction(callResResult, message, 0); callResResult.result.result = 1; callSup.EventGetCallRestriction(callResResult, message, 0); - callSup.EventSetCallRestriction(0, message, 0); - callSup.EventSetCallRestriction(0, message, 1); + callSup.EventSetCallRestriction(0, message, 0, 1); + callSup.EventSetCallRestriction(0, message, 1, 1); callSup.EventSetBarringPassword(0, message, 0); callSup.EventSetBarringPassword(0, message, 1); - callSup.EventSetCallWaiting(0, message, 0); - callSup.EventSetCallWaiting(0, message, 1); + callSup.EventSetCallWaiting(0, message, 0, 1); + callSup.EventSetCallWaiting(0, message, 1, 1); CallForwardQueryInfoList cFQueryList; callSup.EventGetCallTransferInfo(cFQueryList, message, 0); CallForwardQueryResult queryResult; @@ -372,8 +372,8 @@ HWTEST_F(ZeroBranchTest, Telephony_CellularCallSupplement_003, Function | Medium callSup.BuildCallForwardQueryInfo(queryResult, message, 0); queryResult.reason = 2; callSup.BuildCallForwardQueryInfo(queryResult, message, 0); - callSup.EventSetCallTransferInfo(0, message, 0); - callSup.EventSetCallTransferInfo(0, message, 1); + callSup.EventSetCallTransferInfo(0, message, 0, 1); + callSup.EventSetCallTransferInfo(0, message, 1, 1); RadioResponseInfo responseInfo; callSup.EventSendUssd(responseInfo); SsNoticeInfo ssNoticeInfo; -- Gitee From b0f721216ca65c4377570778892accd649aaa39f Mon Sep 17 00:00:00 2001 From: Xianru Chen Date: Tue, 25 Mar 2025 05:23:52 +0800 Subject: [PATCH 2/3] ussd feature Signed-off-by: Xianru Chen --- test/unittest/imstest/zero_branch1_test.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/unittest/imstest/zero_branch1_test.cpp b/test/unittest/imstest/zero_branch1_test.cpp index 7624c6e4..53304e39 100644 --- a/test/unittest/imstest/zero_branch1_test.cpp +++ b/test/unittest/imstest/zero_branch1_test.cpp @@ -974,20 +974,20 @@ HWTEST_F(ZeroBranch1Test, Telephony_MmiCodeUtils_001, Function | MediumTest | Le mmiCodeUtils.mmiData_.dialString = "11111#"; ASSERT_FALSE(mmiCodeUtils.RegexMatchMmi("111111#")); std::string dialStr = ""; - ASSERT_FALSE(mmiCodeUtils.IsNeedExecuteMMI(dialStr, enable)); + ASSERT_FALSE(mmiCodeUtils.IsNeedExecuteMmi(dialStr, enable)); std::string dialStr = "12"; - ASSERT_FALSE(mmiCodeUtils.IsNeedExecuteMMI(dialStr, enable)); + ASSERT_FALSE(mmiCodeUtils.IsNeedExecuteMmi(dialStr, enable)); std::string dialStr = "33"; - ASSERT_FALSE(mmiCodeUtils.IsNeedExecuteMMI(dialStr, enable)); + ASSERT_FALSE(mmiCodeUtils.IsNeedExecuteMmi(dialStr, enable)); std::string dialStr = "*21*10086#"; - ASSERT_FALSE(mmiCodeUtils.IsNeedExecuteMMI(dialStr, enable)); + ASSERT_FALSE(mmiCodeUtils.IsNeedExecuteMmi(dialStr, enable)); mmiCodeUtils.GetMMIData(); std::string dialStr = "10086"; - ASSERT_FALSE(mmiCodeUtils.IsNeedExecuteMMI(dialStr, enable)); + ASSERT_FALSE(mmiCodeUtils.IsNeedExecuteMmi(dialStr, enable)); std::string dialStr = "*30#10086"; - ASSERT_FALSE(mmiCodeUtils.IsNeedExecuteMMI(dialStr, enable)); + ASSERT_FALSE(mmiCodeUtils.IsNeedExecuteMmi(dialStr, enable)); std::string dialStr = "*33##123#"; - ASSERT_FALSE(mmiCodeUtils.IsNeedExecuteMMI(dialStr, enable)); + ASSERT_FALSE(mmiCodeUtils.IsNeedExecuteMmi(dialStr, enable)); } /** -- Gitee From c20a0f8f58fbefb77cae3e87102e1102812cf90b Mon Sep 17 00:00:00 2001 From: Xianru Chen Date: Tue, 25 Mar 2025 05:55:08 +0800 Subject: [PATCH 3/3] ussd feature Signed-off-by: Xianru Chen --- test/unittest/imstest/zero_branch1_test.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/unittest/imstest/zero_branch1_test.cpp b/test/unittest/imstest/zero_branch1_test.cpp index 53304e39..cac92748 100644 --- a/test/unittest/imstest/zero_branch1_test.cpp +++ b/test/unittest/imstest/zero_branch1_test.cpp @@ -975,18 +975,18 @@ HWTEST_F(ZeroBranch1Test, Telephony_MmiCodeUtils_001, Function | MediumTest | Le ASSERT_FALSE(mmiCodeUtils.RegexMatchMmi("111111#")); std::string dialStr = ""; ASSERT_FALSE(mmiCodeUtils.IsNeedExecuteMmi(dialStr, enable)); - std::string dialStr = "12"; + dialStr = "12"; ASSERT_FALSE(mmiCodeUtils.IsNeedExecuteMmi(dialStr, enable)); - std::string dialStr = "33"; + dialStr = "33"; ASSERT_FALSE(mmiCodeUtils.IsNeedExecuteMmi(dialStr, enable)); - std::string dialStr = "*21*10086#"; + dialStr = "*21*10086#"; ASSERT_FALSE(mmiCodeUtils.IsNeedExecuteMmi(dialStr, enable)); mmiCodeUtils.GetMMIData(); - std::string dialStr = "10086"; + dialStr = "10086"; ASSERT_FALSE(mmiCodeUtils.IsNeedExecuteMmi(dialStr, enable)); - std::string dialStr = "*30#10086"; + dialStr = "*30#10086"; ASSERT_FALSE(mmiCodeUtils.IsNeedExecuteMmi(dialStr, enable)); - std::string dialStr = "*33##123#"; + dialStr = "*33##123#"; ASSERT_FALSE(mmiCodeUtils.IsNeedExecuteMmi(dialStr, enable)); } -- Gitee