diff --git a/services/control/include/cellular_call_config.h b/services/control/include/cellular_call_config.h index 2da0c080ac6eef661880d2433311c633f1d762a5..9ca10c82537a7f1ec06b696836c1203b6ea5c6c0 100755 --- a/services/control/include/cellular_call_config.h +++ b/services/control/include/cellular_call_config.h @@ -462,6 +462,8 @@ public: bool IsReadyToCall(int32_t slotId); + int32_t GetAllEccListCount(); + private: static void InitDefaultOperatorConfig(); EmergencyCall BuildDefaultEmergencyCall(const std::string &number, SimpresentType simType); diff --git a/services/control/src/cellular_call_config.cpp b/services/control/src/cellular_call_config.cpp index 58fa5b20078e87fb51fc0a9f98ea4d56e351e083..c21997afc30110335d137b96f4b50dbebfd216b3 100755 --- a/services/control/src/cellular_call_config.cpp +++ b/services/control/src/cellular_call_config.cpp @@ -1020,5 +1020,10 @@ bool CellularCallConfig::IsReadyToCall(int32_t slotId) } return readyToCall_[slotId]; } + +int32_t CellularCallConfig::GetAllEccListCount() +{ + return allEccList_.size(); +} } // namespace Telephony } // namespace OHOS diff --git a/services/manager/include/cellular_call_service.h b/services/manager/include/cellular_call_service.h index 746631ce8bc89f6d3d308096dd76ec487ad617b1..a2b300e074f2dc1e494753f422cc985168c1ce1f 100755 --- a/services/manager/include/cellular_call_service.h +++ b/services/manager/include/cellular_call_service.h @@ -543,6 +543,8 @@ public: */ int32_t CloseUnFinishedUssd(int32_t slotId) override; + int32_t GetEmergencyNumberList(std::vector> &allEccList) override; + int32_t ClearAllCalls(const std::vector &infos) override; /** diff --git a/services/manager/include/cellular_call_stub.h b/services/manager/include/cellular_call_stub.h index b5c687ab235661da2f607ea7a1e68fdb5b0f5599..e804d9c254cf80370ee3b6791baf2fc2bebd29c7 100755 --- a/services/manager/include/cellular_call_stub.h +++ b/services/manager/include/cellular_call_stub.h @@ -496,6 +496,8 @@ private: */ int32_t OnCloseUnFinishedUssdInner(MessageParcel &data, MessageParcel &reply); + int32_t OnGetEmergencyNumberListInner(MessageParcel &data, MessageParcel &reply); + /** * @brief clear all call if cellular call service restart * diff --git a/services/manager/src/cellular_call_service.cpp b/services/manager/src/cellular_call_service.cpp index 2a5e4b4b0a9414d562003ebecd850e8b70c02c55..b06da91bd23b67f70cac0e115fe02a322d7456b9 100755 --- a/services/manager/src/cellular_call_service.cpp +++ b/services/manager/src/cellular_call_service.cpp @@ -25,6 +25,7 @@ #include "ims_call_client.h" #include "module_service_utils.h" #include "radio_event.h" +#include "securec.h" #include "string_ex.h" #include "system_ability_definition.h" @@ -1202,6 +1203,29 @@ int32_t CellularCallService::CloseUnFinishedUssd(int32_t slotId) return cellularCallSupplement.CloseUnFinishedUssd(slotId); } +int32_t CellularCallService::GetEmergencyNumberList(std::vector> &allEccList) +{ + CellularCallConfig config; + allEccList.assign(config.GetAllEccListCount(), std::vector()); + for (int index = 0; index < allEccList.size(); index++) { + std::vector eccList = config.GetEccCallList(index); + for (int32_t indexInner = 0; indexInner < eccList.size(); indexInner++) { + EmergencyNumber emergencyNumber; + if (strcpy_s(emergencyNumber.eccNum, ECC_NUM_MAX_LEN, eccList[indexInner].eccNum.c_str())) { + TELEPHONY_LOGE("strcpy_s fail"); + return TELEPHONY_ERR_STRCPY_FAIL; + } + if (strcpy_s(emergencyNumber.mcc, ECC_NUM_MAX_LEN, eccList[indexInner].mcc.c_str())) { + TELEPHONY_LOGE("strcpy_s fail"); + return TELEPHONY_ERR_STRCPY_FAIL; + } + emergencyNumber.emergencyCallType = static_cast(eccList[indexInner].eccType); + allEccList[index].push_back(emergencyNumber); + } + } + return TELEPHONY_SUCCESS; +} + int32_t CellularCallService::SetControl(const CellularCallInfo &info) { if (info.callType == CallType::TYPE_CS) { diff --git a/services/manager/src/cellular_call_stub.cpp b/services/manager/src/cellular_call_stub.cpp index f38b12d225244a32418f6eb2ff35e461be5b5519..8022e5ed3b878a5a372189bf05ec848922879773 100755 --- a/services/manager/src/cellular_call_stub.cpp +++ b/services/manager/src/cellular_call_stub.cpp @@ -126,6 +126,8 @@ void CellularCallStub::InitConfigFuncMap() requestFuncMap_[CellularCallInterfaceCode::GET_IMS_FEATURE] = &CellularCallStub::OnGetImsFeatureValueInner; requestFuncMap_[CellularCallInterfaceCode::SET_MUTE] = &CellularCallStub::OnSetMuteInner; requestFuncMap_[CellularCallInterfaceCode::GET_MUTE] = &CellularCallStub::OnGetMuteInner; + requestFuncMap_[CellularCallInterfaceCode::Get_EMERGENCY_NUMBER_LIST] = + &CellularCallStub::OnGetEmergencyNumberListInner; } void CellularCallStub::InitVideoFuncMap() @@ -1090,6 +1092,31 @@ int32_t CellularCallStub::OnCloseUnFinishedUssdInner(MessageParcel &data, Messag return TELEPHONY_SUCCESS; } +int32_t CellularCallStub::OnGetEmergencyNumberListInner(MessageParcel &data, MessageParcel &reply) +{ + std::vector> allEccList; + int32_t ret = GetEmergencyNumberList(allEccList); + if (!reply.WriteInt32(ret)) { + TELEPHONY_LOGE("fail to write ret"); + return TELEPHONY_ERR_WRITE_DATA_FAIL; + } + if (ret != TELEPHONY_SUCCESS) { + return ret; + } + int32_t allEccListVecNum = allEccList.size(); + reply.WriteInt32(allEccListVecNum); + for (int32_t i = 0; i < allEccListVecNum; i++) { + int32_t eccListNum = allEccList[i].size(); + reply.WriteInt32(eccListNum); + } + for (int32_t index = 0; index < allEccListVecNum; index++) { + for (int32_t indexInner = 0; indexInner < allEccList[index].size(); indexInner++) { + reply.WriteRawData(static_cast(&allEccList[index][indexInner]), sizeof(EmergencyNumber)); + } + } + return TELEPHONY_SUCCESS; +} + int32_t CellularCallStub::OnClearAllCallsInner(MessageParcel &data, MessageParcel &reply) { TELEPHONY_LOGI("CellularCallStub::OnClearAllCallsInner entry");