diff --git a/services/control/include/cellular_call_config.h b/services/control/include/cellular_call_config.h index 2da0c080ac6eef661880d2433311c633f1d762a5..c8c89f37dd8168fbecb0693a509a67d4e4cb5415 100755 --- a/services/control/include/cellular_call_config.h +++ b/services/control/include/cellular_call_config.h @@ -488,6 +488,7 @@ private: void SaveVoNRState(int32_t slotId, int32_t state); int32_t ObtainVoNRState(int32_t slotId); void UpdateEccNumberList(int32_t slotId); + bool IsHomeNetRegister(int32_t slotId, std::string hplmn); private: static std::map modeTempMap_; @@ -498,7 +499,8 @@ private: static std::map> allEccList_; static std::map simState_; static std::map curPlmn_; - static std::map serviceState_; + static std::map psServiceState_; + static std::map csServiceState_; std::mutex mutex_; static std::mutex operatorMutex_; ConfigRequest configRequest_; diff --git a/services/control/src/cellular_call_config.cpp b/services/control/src/cellular_call_config.cpp index b70631c5e726a413cd9e77b62f730ce55c7d6f12..5516d7d5832d12f4a1c9417cf10ddf4f3cf84dee 100755 --- a/services/control/src/cellular_call_config.cpp +++ b/services/control/src/cellular_call_config.cpp @@ -72,7 +72,8 @@ std::vector CellularCallConfig::eccList3gppNoSim_; std::map> CellularCallConfig::allEccList_; std::map CellularCallConfig::simState_; std::map CellularCallConfig::curPlmn_; -std::map CellularCallConfig::serviceState_; +std::map CellularCallConfig::psServiceState_; +std::map CellularCallConfig::csServiceState_; std::map CellularCallConfig::readyToCall_; bool CellularCallConfig::isOperatorConfigInit_ = false; @@ -97,7 +98,9 @@ void CellularCallConfig::InitDefaultOperatorConfig() CellularCallConfig::forceVolteSwitchOn_.insert(std::pair(i, false)); CellularCallConfig::readyToCall_.insert(std::pair(i, true)); CellularCallConfig::vonrSwithStatus_.insert(std::pair(i, VONR_SWITCH_VALUE_UNKNOWN)); - CellularCallConfig::serviceState_.insert(std::pair(i, + CellularCallConfig::psServiceState_.insert(std::pair(i, + RegServiceState::REG_STATE_UNKNOWN)); + CellularCallConfig::csServiceState_.insert(std::pair(i, RegServiceState::REG_STATE_UNKNOWN)); } } @@ -242,12 +245,14 @@ void CellularCallConfig::HandleNetworkStateChange(int32_t slotId) { TELEPHONY_LOGI("CellularCallConfig::HandleNetworkStateChange entry, slotId: %{public}d", slotId); ModuleServiceUtils moduleUtils; - RegServiceState regState = moduleUtils.GetPsRegState(slotId); - if (serviceState_[slotId] == regState) { + RegServiceState psRegState = moduleUtils.GetPsRegState(slotId); + RegServiceState csRegState = moduleUtils.GetCsRegState(slotId); + if (psServiceState_[slotId] == psRegState && csServiceState_[slotId] == csRegState) { TELEPHONY_LOGI("serviceState is not change, slotId: %{public}d", slotId); return; } - serviceState_[slotId] = regState; + psServiceState_[slotId] = psRegState; + csServiceState_[slotId] = csRegState; CheckAndUpdateSimState(slotId); UpdateEccNumberList(slotId); } @@ -258,14 +263,8 @@ void CellularCallConfig::UpdateEccNumberList(int32_t slotId) CoreManagerInner::GetInstance().GetSimOperatorNumeric(slotId, u16Hplmn); std::string hplmn = Str16ToStr8(u16Hplmn); std::vector callList; - int32_t roamingState = CoreManagerInner::GetInstance().GetPsRoamingState(slotId); - bool isRoaming = roamingState > static_cast(RoamingType::ROAMING_STATE_UNKNOWN) && - roamingState <= static_cast(RoamingType::ROAMING_STATE_INTERNATIONAL); - ModuleServiceUtils moduleUtils; - bool isNetworkInService = moduleUtils.GetPsRegState(slotId) == RegServiceState::REG_STATE_IN_SERVICE; - bool isHomeNetRegister = !hplmn.empty() && isNetworkInService && !isRoaming; std::vector eccVec; - if (isHomeNetRegister && simState_[slotId] == SIM_PRESENT) { + if (simState_[slotId] == SIM_PRESENT && IsHomeNetRegister(slotId, hplmn)) { OperatorConfig operatorConfig; CoreManagerInner::GetInstance().GetOperatorConfigs(slotId, operatorConfig); callList = operatorConfig.stringArrayValue[KEY_EMERGENCY_CALL_STRING_ARRAY]; @@ -710,9 +709,9 @@ void CellularCallConfig::InitModeActive() eccList3gppNoSim_.clear(); allEccList_.clear(); eccList3gppHasSim_.push_back(BuildDefaultEmergencyCall("112", SimpresentType::TYPE_HAS_CARD)); - eccList3gppHasSim_.push_back(BuildDefaultEmergencyCall("991", SimpresentType::TYPE_HAS_CARD)); + eccList3gppHasSim_.push_back(BuildDefaultEmergencyCall("911", SimpresentType::TYPE_HAS_CARD)); eccList3gppNoSim_.push_back(BuildDefaultEmergencyCall("112", SimpresentType::TYPE_NO_CARD)); - eccList3gppNoSim_.push_back(BuildDefaultEmergencyCall("991", SimpresentType::TYPE_NO_CARD)); + eccList3gppNoSim_.push_back(BuildDefaultEmergencyCall("911", SimpresentType::TYPE_NO_CARD)); eccList3gppNoSim_.push_back(BuildDefaultEmergencyCall("000", SimpresentType::TYPE_NO_CARD)); eccList3gppNoSim_.push_back(BuildDefaultEmergencyCall("08", SimpresentType::TYPE_NO_CARD)); eccList3gppNoSim_.push_back(BuildDefaultEmergencyCall("110", SimpresentType::TYPE_NO_CARD)); @@ -762,10 +761,14 @@ void CellularCallConfig::MergeEccCallList(int32_t slotId) std::u16string u16Hplmn = u""; CoreManagerInner::GetInstance().GetSimOperatorNumeric(slotId, u16Hplmn); std::string hplmn = Str16ToStr8(u16Hplmn); - int32_t roamingState = CoreManagerInner::GetInstance().GetPsRoamingState(slotId); - bool isRoaming = roamingState > static_cast(RoamingType::ROAMING_STATE_UNKNOWN) && - roamingState <= static_cast(RoamingType::ROAMING_STATE_INTERNATIONAL); - if (hasSim && !isRoaming && !hplmn.empty()) { + int32_t psRoamingState = CoreManagerInner::GetInstance().GetPsRoamingState(slotId); + bool isPsRoaming = psRoamingState > static_cast(RoamingType::ROAMING_STATE_UNKNOWN) && + psRoamingState <= static_cast(RoamingType::ROAMING_STATE_INTERNATIONAL); + int32_t csRoamingState = static_cast(RoamingType::ROAMING_STATE_UNKNOWN); + CoreManagerInner::GetInstance().GetCsRoamingState(slotId, csRoamingState); + bool isCsRoaming = csRoamingState > static_cast(RoamingType::ROAMING_STATE_UNKNOWN) && + csRoamingState <= static_cast(RoamingType::ROAMING_STATE_INTERNATIONAL); + if (hasSim && !isPsRoaming && !isCsRoaming && !hplmn.empty()) { std::vector eccVec; DelayedSingleton::GetInstance()->QueryEccList(hplmn, eccVec); if (!eccVec.empty()) { @@ -1018,5 +1021,21 @@ bool CellularCallConfig::IsReadyToCall(int32_t slotId) } return readyToCall_[slotId]; } + +bool CellularCallConfig::IsHomeNetRegister(int32_t slotId, std::string hplmn) +{ + int32_t psRoamingState = CoreManagerInner::GetInstance().GetPsRoamingState(slotId); + bool isPsRoaming = psRoamingState > static_cast(RoamingType::ROAMING_STATE_UNKNOWN) && + psRoamingState <= static_cast(RoamingType::ROAMING_STATE_INTERNATIONAL); + int32_t csRoamingState = static_cast(RoamingType::ROAMING_STATE_UNKNOWN); + CoreManagerInner::GetInstance().GetCsRoamingState(slotId, csRoamingState); + bool isCsRoaming = csRoamingState > static_cast(RoamingType::ROAMING_STATE_UNKNOWN) && + csRoamingState <= static_cast(RoamingType::ROAMING_STATE_INTERNATIONAL); + ModuleServiceUtils moduleUtils; + bool isNetworkInService = moduleUtils.GetPsRegState(slotId) == RegServiceState::REG_STATE_IN_SERVICE || + moduleUtils.GetCsRegState(slotId) == RegServiceState::REG_STATE_IN_SERVICE; + bool isHomeNetRegister = !hplmn.empty() && isNetworkInService && !isPsRoaming && !isCsRoaming; + return isHomeNetRegister; +} } // namespace Telephony } // namespace OHOS diff --git a/services/manager/src/cellular_call_handler.cpp b/services/manager/src/cellular_call_handler.cpp index b40e2da80efdb75e7b8bfc77e4c674efb3b312dd..01287dd476fc0d56d587bb831271b07b4e1c789f 100755 --- a/services/manager/src/cellular_call_handler.cpp +++ b/services/manager/src/cellular_call_handler.cpp @@ -129,6 +129,8 @@ void CellularCallHandler::InitActiveReportFuncMap() requestFuncMap_[RadioEvent::RADIO_RESIDENT_NETWORK_CHANGE] = &CellularCallHandler::ResidentNetworkChangeReport; requestFuncMap_[RadioEvent::RADIO_PS_CONNECTION_ATTACHED] = &CellularCallHandler::NetworkStateChangeReport; requestFuncMap_[RadioEvent::RADIO_PS_CONNECTION_DETACHED] = &CellularCallHandler::NetworkStateChangeReport; + requestFuncMap_[RadioEvent::RADIO_CS_CONNECTION_ATTACHED] = &CellularCallHandler::NetworkStateChangeReport; + requestFuncMap_[RadioEvent::RADIO_CS_CONNECTION_DETACHED] = &CellularCallHandler::NetworkStateChangeReport; requestFuncMap_[RadioEvent::RADIO_RIL_ADAPTER_HOST_DIED] = &CellularCallHandler::OnRilAdapterHostDied; #ifdef CALL_MANAGER_AUTO_START_OPTIMIZE requestFuncMap_[RadioEvent::RADIO_GET_STATUS] = &CellularCallHandler::GetRadioStateProcess; diff --git a/services/manager/src/cellular_call_service.cpp b/services/manager/src/cellular_call_service.cpp index 9810a2f4987624ca8b1f6c56bf035405e8200370..ed385992cb1b825cc9091d1e85084a87d48a4553 100755 --- a/services/manager/src/cellular_call_service.cpp +++ b/services/manager/src/cellular_call_service.cpp @@ -178,6 +178,8 @@ void CellularCallService::HandlerResetUnRegister() coreInner.UnRegisterCoreNotify(slot, handler, RadioEvent::RADIO_RESIDENT_NETWORK_CHANGE); coreInner.UnRegisterCoreNotify(slot, handler, RadioEvent::RADIO_PS_CONNECTION_ATTACHED); coreInner.UnRegisterCoreNotify(slot, handler, RadioEvent::RADIO_PS_CONNECTION_DETACHED); + coreInner.UnRegisterCoreNotify(slot, handler, RadioEvent::RADIO_CS_CONNECTION_ATTACHED); + coreInner.UnRegisterCoreNotify(slot, handler, RadioEvent::RADIO_CS_CONNECTION_DETACHED); coreInner.UnRegisterCoreNotify(slot, handler, RadioEvent::RADIO_RIL_ADAPTER_HOST_DIED); #ifdef CALL_MANAGER_AUTO_START_OPTIMIZE coreInner.UnRegisterCoreNotify(slot, handler, RadioEvent::RADIO_STATE_CHANGED); @@ -214,6 +216,8 @@ void CellularCallService::RegisterCoreServiceHandler() coreInner.RegisterCoreNotify(slot, handler, RadioEvent::RADIO_RESIDENT_NETWORK_CHANGE, nullptr); coreInner.RegisterCoreNotify(slot, handler, RadioEvent::RADIO_PS_CONNECTION_ATTACHED, nullptr); coreInner.RegisterCoreNotify(slot, handler, RadioEvent::RADIO_PS_CONNECTION_DETACHED, nullptr); + coreInner.RegisterCoreNotify(slot, handler, RadioEvent::RADIO_CS_CONNECTION_ATTACHED, nullptr); + coreInner.RegisterCoreNotify(slot, handler, RadioEvent::RADIO_CS_CONNECTION_DETACHED, nullptr); coreInner.RegisterCoreNotify(slot, handler, RadioEvent::RADIO_RIL_ADAPTER_HOST_DIED, nullptr); #ifdef CALL_MANAGER_AUTO_START_OPTIMIZE coreInner.RegisterCoreNotify(slot, handler, RadioEvent::RADIO_STATE_CHANGED, nullptr); diff --git a/test/unittest/cstest/cs_test.cpp b/test/unittest/cstest/cs_test.cpp index a0d5ae92b67d17ed0c52a1f1cc04fafa4beffae2..d27464a0515715472d5cb9a3b33824bf7a98fe43 100755 --- a/test/unittest/cstest/cs_test.cpp +++ b/test/unittest/cstest/cs_test.cpp @@ -2663,13 +2663,21 @@ HWTEST_F(CsTest, cellular_call_ModuleServiceUtils_0001, Function | MediumTest | */ HWTEST_F(CsTest, cellular_call_CellularCallConfig_0001, Function | MediumTest | Level3) { - CellularCallConfig CellularCallConfig; + CellularCallConfig cellularCallConfig; bool isReadyToCall = false; bool csType = 0; - CellularCallConfig.SetReadyToCall(SIM1_SLOTID, isReadyToCall); + cellularCallConfig.SetReadyToCall(SIM1_SLOTID, isReadyToCall); CellularCallCallback cellularCallCallback; cellularCallCallback.SetReadyToCall(SIM1_SLOTID, csType, isReadyToCall); - EXPECT_EQ(CellularCallConfig.IsReadyToCall(SIM1_SLOTID), TELEPHONY_SUCCESS); + cellularCallConfig.HandleSimStateChanged(SIM1_SLOTID); + std::string plmn = "46000"; + cellularCallConfig.HandleResidentNetworkChange(SIM1_SLOTID, plmn); + cellularCallConfig.HandleNetworkStateChange(SIM1_SLOTID); + cellularCallConfig.UpdateEccNumberList(SIM1_SLOTID); + cellularCallConfig.MergeEccCallList(SIM1_SLOTID); + EmergencyInfoList eccList; + cellularCallConfig.UpdateEmergencyCallFromRadio(SIM1_SLOTID, eccList); + EXPECT_EQ(cellularCallConfig.IsReadyToCall(SIM1_SLOTID), TELEPHONY_SUCCESS); } } // namespace Telephony } // namespace OHOS