diff --git a/wifi/interfaces/inner_api/wifi_msg.h b/wifi/interfaces/inner_api/wifi_msg.h index b80be0f22217262d9f1b869f355d11fc5c5c05b9..1e8852fb6b1289ee97870c1630c984386f4819bd 100644 --- a/wifi/interfaces/inner_api/wifi_msg.h +++ b/wifi/interfaces/inner_api/wifi_msg.h @@ -1061,6 +1061,7 @@ enum class WifiSelfcureType { RESET_SELFCURE_SUCC, RAND_MAC_REASSOC_SELFCURE_SUCC, MULTI_GATEWAY_SELFCURE_SUCC, + RENEW_DHCP_SELFCURE_SUCC, }; enum class Wifi3VapConflictType { diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/iself_cure_service.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/iself_cure_service.h index e4d68a933b58d339961a71df8a2463ed72c8d5e1..dceb9a0966ca1ab8ffdc33485fe773a7731b2fc4 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/iself_cure_service.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/iself_cure_service.h @@ -92,6 +92,18 @@ public: * @return bool - true: have done selfcure or no need to do, false: selfcure not finish */ virtual bool IsWifiSelfcureDone() = 0; + + /** + * @Description Check if Selfcure state, + * + * @param bssid - string - bssid info + */ + virtual void NotifyWifiRoamingCompleted(std::string bssid) = 0; + + /** + * @Description notify selfcure ip config completed + */ + virtual void NotifyIpConfigCompleted() = 0; }; } // namespace Wifi } // namespace OHOS diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_common.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_common.h index bcb341d379ae26a536182ed6f8fc71268a1bd79b..10ba4778aad81fa82ddeaf7d91832005308c3044 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_common.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_common.h @@ -70,6 +70,7 @@ namespace Wifi { #define WIFI_CURE_RESET_LEVEL_MULTI_GATEWAY 210 #define WIFI_CURE_RESET_LEVEL_HIGH_RESET_WIFI_ON 211 +#define WIFI_CURE_RESET_LEVEL_RENEW_DHCP 212 #define WIFI_CURE_INTERNET_FAILED_RAND_MAC 300 #define WIFI_CURE_INTERNET_FAILED_TYPE_GATEWAY 302 @@ -90,6 +91,7 @@ namespace Wifi { #define WIFI_CURE_CMD_STOP_SELF_CURE 316 #define WIFI_CURE_CMD_FORCE_STOP_SELF_CURE 317 #define WIFI_CURE_DISCONNECT_TIMEOUT 318 +#define WIFI_CURE_INTERNET_FAILED_TYPE_ROAMING 319 #define SELFCURE_FAIL_LENGTH 12 #define SELFCURE_HISTORY_LENGTH 14 diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_interface.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_interface.cpp index 23095c4ca9332bd896d80b7b558c0a6ff9ce08e9..d99b67018ba2f85155a1e26b6c5bdc2382a06bc5 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_interface.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_interface.cpp @@ -189,5 +189,29 @@ void SelfCureInterface::DealRssiLevelChanged(int rssi, int instId) } pSelfCureService->HandleRssiLevelChanged(rssi); } + +void SelfCureInterface::NotifyWifiRoamingCompleted(std::string bssid) +{ + std::lock_guard lock(mutex); + if (pSelfCureService == nullptr) { + WIFI_LOGI("pSelfCureService is null"); + return; + } + if (bssid.empty()) { + WIFI_LOGI("bssid is null"); + return; + } + pSelfCureService->NotifyWifiRoamingCompleted(bssid); +} + +void SelfCureInterface::NotifyIpConfigCompleted() +{ + std::lock_guard lock(mutex); + if (pSelfCureService == nullptr) { + WIFI_LOGI("pSelfCureService is null"); + return; + } + pSelfCureService->NotifyIpConfigCompleted(); +} } // namespace Wifi } // namespace OHOS diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_interface.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_interface.h index 2ce8820b25c494078374c12ea90571a6a6ef0703..dc9e9b38cfe4b3e003a640f0697a96752c58b9af 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_interface.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_interface.h @@ -126,6 +126,18 @@ public: * @return bool - true: have done selfcure or no need to do, false: selfcure not finish */ bool IsWifiSelfcureDone() override; + + /** + * @Description Check if Selfcure state, + * + * @param bssid - string - bssid info + */ + void NotifyWifiRoamingCompleted(std::string bssid) override; + + /** + * @Description notify selfcure ip config completed + */ + void NotifyIpConfigCompleted() override; private: std::mutex mutex; std::vector mSelfCureCallback; diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_msg.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_msg.h index c2eacec60b5834cf9daadc46e3dec3dbcb3e3ad1..846095d8b24a31bd1764c87e3dbf968b971fdce8 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_msg.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_msg.h @@ -63,8 +63,16 @@ struct WifiSelfCureHistoryInfo { /* record last reset connect failed milliseconds */ int64_t lastResetSelfCureConnectFailedTs; + + /* record renew dhcp connect failed count */ + int renewDhcpSelfCureConnectFailedCnt; + + /* record last renew dhcp connect failed milliseconds */ + int64_t lastRenewDhcpSelfCureConnectFailedTs; WifiSelfCureHistoryInfo() { + renewDhcpSelfCureConnectFailedCnt = 0; + lastRenewDhcpSelfCureConnectFailedTs = 0; staticIpSelfCureFailedCnt = 0; lastStaticIpSelfCureFailedTs = 0; reassocSelfCureFailedCnt = 0; @@ -83,6 +91,8 @@ struct WifiSelfCureHistoryInfo { std::string GetSelfCureHistory() { std::string internetSelfCureHistory; + internetSelfCureHistory.append(std::to_string(renewDhcpSelfCureConnectFailedCnt) + "|"); + internetSelfCureHistory.append(std::to_string(lastRenewDhcpSelfCureConnectFailedTs) + "|"); internetSelfCureHistory.append(std::to_string(staticIpSelfCureFailedCnt) + "|"); internetSelfCureHistory.append(std::to_string(lastStaticIpSelfCureFailedTs) + "|"); internetSelfCureHistory.append(std::to_string(reassocSelfCureFailedCnt) + "|"); @@ -128,6 +138,7 @@ enum class SelfCureType { SCE_TYPE_RANDMAC = 6, SCE_TYPE_RESET = 7, SCE_TYPE_RESET_WIFI_ON = 8, + SCE_TYPE_RENEW_DHCP = 9, }; enum SelfCureState { diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_service.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_service.cpp index e512a77fec68c09659200b2262a36a36d5a233d1..69e503e40299df40a5333efc82af40c300b4988d 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_service.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_service.cpp @@ -223,5 +223,29 @@ void SelfCureService::P2pEnhanceStateChange(const std::string &ifName, int32_t s WifiConfigCenter::GetInstance().SetP2pEnhanceState(p2pEnhanceState); } } + +void SelfCureService::NotifyWifiRoamingCompleted(std::string bssid) +{ + WIFI_LOGI("enter NotifyWifiRoamingCompleted"); + if (pSelfCureStateMachine == nullptr) { + WIFI_LOGE("%{public}s pSelfCureStateMachine is null.", __FUNCTION__); + return; + } + if (bssid.empty()) { + WIFI_LOGE("bssid is null"); + return; + } + pSelfCureStateMachine->SendMessage(WIFI_CURE_CMD_NETWORK_ROAMING_DETECT, bssid); +} + +void SelfCureService::NotifyIpConfigCompleted() +{ + WIFI_LOGI("enter NotifyIpConfigCompleted"); + if (pSelfCureStateMachine == nullptr) { + WIFI_LOGE("%{public}s pSelfCureStateMachine is null.", __FUNCTION__); + return; + } + pSelfCureStateMachine->SendMessage(WIFI_CURE_CMD_IP_CONFIG_COMPLETED); +} } //namespace Wifi } //namespace OHOS \ No newline at end of file diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_service.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_service.h index ad7f8e1de949f21c2a03022b3541f3de68604de2..1e242181ee9e3cecd7e9e9a8f5f3fe069016ad2a 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_service.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_service.h @@ -43,6 +43,8 @@ public: void StopSelfCureWifi(int32_t status); bool CheckSelfCureWifiResult(int event); bool IsWifiSelfcureDone(); + void NotifyWifiRoamingCompleted(std::string bssid); + void NotifyIpConfigCompleted(); private: void RegisterP2pEnhanceCallback(); void P2pEnhanceStateChange(const std::string &ifName, int32_t state, int32_t frequency); diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_state_machine.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_state_machine.cpp index a376b5251b306bae20002682cbd9b0e06ab16a9f..0b5b5095c7324b449598afa2a77f6cfd9402f48e 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_state_machine.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_state_machine.cpp @@ -46,7 +46,7 @@ const uint32_t WIFI_SINGLE_ITEM_BYTE_LEN = 8; const uint32_t WIFI_SINGLE_MAC_LEN = 6; const uint32_t WIFI_MAX_BLA_LIST_NUM = 16; const uint32_t DHCP_OFFER_COUNT = 2; -const std::string INIT_SELFCURE_HISTORY = "0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0"; +const std::string INIT_SELFCURE_HISTORY = "0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0"; const std::string COUNTRY_CODE_CN = "460"; SelfCureStateMachine::SelfCureStateMachine(int instId) @@ -319,12 +319,16 @@ int SelfCureStateMachine::ConnectedMonitorState::InitSelfCureCmsHandleMap() selfCureCmsHandleFuncMap_[WIFI_CURE_CMD_DNS_FAILED_MONITOR] = [this](InternalMessagePtr msg) { this->HandleDnsFailedMonitor(msg); }; + selfCureCmsHandleFuncMap_[WIFI_CURE_CMD_NETWORK_ROAMING_DETECT] = [this](InternalMessagePtr msg) { + this->HandleRoamingDetected(msg); + }; return WIFI_OPT_SUCCESS; } void SelfCureStateMachine::ConnectedMonitorState::TransitionToSelfCureState(int reason) { - if (isMobileHotspot_ || pSelfCureStateMachine_->IsCustNetworkSelfCure()) { + if ((isMobileHotspot_ || pSelfCureStateMachine_->IsCustNetworkSelfCure()) && + reason != WIFI_CURE_INTERNET_FAILED_TYPE_ROAMING) { WIFI_LOGW("transitionToSelfCureState, don't support SCE, do nothing"); return; } @@ -500,6 +504,34 @@ void SelfCureStateMachine::ConnectedMonitorState::HandleDnsFailedMonitor(Interna } } +void SelfCureStateMachine::ConnectedMonitorState::HandleRoamingDetected(InternalMessagePtr msg) +{ + WIFI_LOGI("enter HandleRoamingDetected"); + if (msg == nullptr) { + WIFI_LOGE("%{public}s msg is nullper", __FUNCTION__); + return; + } + std::string currentBssid; + msg->GetMessageObj(currentBssid); + if ((!currentBssid.empty()) && (lastConnectedBssid_ == currentBssid)) { + WIFI_LOGW("HandleRoamingDetected, but bssid is unchanged, ignore it"); + return; + } + if (isUserSetStaticIpConfig_) { + WIFI_LOGW("ip is staticip"); + return; + } + if ((!isHasInternetRecently_) && (!isPortalUnthenEver_) && (!pSelfCureStateMachine_->isInternetUnknown_)) { + WIFI_LOGW("no internet access always"); + return; + } + if (!pSelfCureStateMachine_->CanArpReachable()) { + WIFI_LOGI("arp is unreachable"); + pSelfCureStateMachine_->selfCureReason_ = WIFI_CURE_INTERNET_FAILED_TYPE_ROAMING; + TransitionToSelfCureState(WIFI_CURE_INTERNET_FAILED_TYPE_ROAMING); + } +} + bool SelfCureStateMachine::ConnectedMonitorState::IsNeedSelfCure() { if (pSelfCureStateMachine_->GetCurrentRssi() < MIN_VAL_LEVEL_3) { @@ -910,6 +942,15 @@ int SelfCureStateMachine::InternetSelfCureState::InitSelfCureIssHandleMap() selfCureIssHandleFuncMap_[WIFI_CURE_CMD_SELF_CURE_FAILED] = [this](InternalMessagePtr msg) { this->HandleSelfCureResultFailed(msg); }; + selfCureIssHandleFuncMap_[WIFI_CURE_CMD_IP_CONFIG_TIMEOUT] = [this](InternalMessagePtr msg) { + this->HandleRenewDhcpFailed(msg); + }; + selfCureIssHandleFuncMap_[WIFI_CURE_CMD_NETWORK_ROAMING_DETECT] = [this](InternalMessagePtr msg) { + this->HandleInRoamingDetected(msg); + }; + selfCureIssHandleFuncMap_[WIFI_CURE_CMD_IP_CONFIG_COMPLETED] = [this](InternalMessagePtr msg) { + this->HandleIpStateCompleted(msg); + }; return WIFI_OPT_SUCCESS; } @@ -1033,7 +1074,8 @@ void SelfCureStateMachine::InternetSelfCureState::SelectSelfCureByFailedReason(i } if (isUserSetStaticIpConfig_ && ((internetFailedType == WIFI_CURE_INTERNET_FAILED_TYPE_DNS) || - (internetFailedType == WIFI_CURE_INTERNET_FAILED_TYPE_GATEWAY))) { + (internetFailedType == WIFI_CURE_INTERNET_FAILED_TYPE_GATEWAY) || + (internetFailedType == WIFI_CURE_INTERNET_FAILED_TYPE_ROAMING))) { HandleInternetFailedAndUserSetStaticIp(internetFailedType); return; } @@ -1110,7 +1152,13 @@ int SelfCureStateMachine::InternetSelfCureState::SelectBestSelfCureSolutionExt(i selfCureHistoryInfo_, WIFI_CURE_RESET_LEVEL_MIDDLE_REASSOC)) { bestSelfCureLevel = WIFI_CURE_RESET_LEVEL_MIDDLE_REASSOC; - } + } else if ((internetFailedType == WIFI_CURE_INTERNET_FAILED_TYPE_ROAMING) && + (!HasBeenTested(WIFI_CURE_RESET_LEVEL_RENEW_DHCP) || + ((HasBeenTested(WIFI_CURE_RESET_LEVEL_RENEW_DHCP)) && (renewDhcpCount_ == 1))) && + (!pSelfCureStateMachine_->isSelfCureOnGoing_) && + (!(isDelayedReassocSelfCure_ || isDelayedResetSelfCure_))) { + bestSelfCureLevel = WIFI_CURE_RESET_LEVEL_RENEW_DHCP; +} return bestSelfCureLevel; } @@ -1128,6 +1176,8 @@ void SelfCureStateMachine::InternetSelfCureState::SelfCureWifiLink(int requestCu SelfCureForRandMacReassoc(requestCureLevel); } else if (requestCureLevel == WIFI_CURE_RESET_LEVEL_HIGH_RESET) { SelfCureForReset(requestCureLevel); + } else if (requestCureLevel == WIFI_CURE_RESET_LEVEL_RENEW_DHCP) { + SelfCureForReset(requestCureLevel); } } @@ -1328,6 +1378,29 @@ void SelfCureStateMachine::InternetSelfCureState::HandleSelfCureResultFailed(Int pSelfCureStateMachine_->SwitchState(pSelfCureStateMachine_->pDisconnectedMonitorState_); } +void SelfCureStateMachine::InternetSelfCureState::HandleRenewDhcpFailed(InternalMessagePtr msg) +{ + WIFI_LOGI("ip config timeout"); + pSelfCureStateMachine_->UpdateSelfcureState(WIFI_CURE_RESET_LEVEL_RENEW_DHCP, false); + pSelfCureStateMachine_->SwitchState(pSelfCureStateMachine_->pNoInternetState_); +} + +void SelfCureStateMachine::InternetSelfCureState::HandleInRoamingDetected(InternalMessagePtr msg) +{ + WIFI_LOGI("enter HandleInRoamingDetected"); + if (!pSelfCureStateMachine_->CanArpReachable()) { + WIFI_LOGI("arp is unreachable"); + pSelfCureStateMachine_->SendMessage(WIFI_CURE_CMD_SELF_CURE_WIFI_LINK, WIFI_CURE_RESET_LEVEL_RENEW_DHCP); + } +} + +void SelfCureStateMachine::InternetSelfCureState::HandleIpStateCompleted(InternalMessagePtr msg) +{ + WIFI_LOGI("CMD_IP_CONFIG_TIMEOUT msg removed because of ip config success"); + pSelfCureStateMachine_->StopTimer(WIFI_CURE_CMD_IP_CONFIG_TIMEOUT); + pSelfCureStateMachine_->SendMessage(WIFI_CURE_CMD_INTERNET_RECOVERY_CONFIRM, IP_CONFIG_CONFIRM_DELAYED_MS); +} + void SelfCureStateMachine::InternetSelfCureState::SelfCureForRandMacReassoc(int requestCureLevel) { if ((currentRssi_ < MIN_VAL_LEVEL_3) || pSelfCureStateMachine_->IfP2pConnected() || @@ -1396,6 +1469,33 @@ void SelfCureStateMachine::InternetSelfCureState::SelfCureForReset(int requestCu wifiControllerMachine->SelfcureResetWifi(pSelfCureStateMachine_->instId_); } +void SelfCureStateMachine::InternetSelfCureState::SelfCureForRenewDhcp(int requestCureLevel) +{ + if (isUserSetStaticIpConfig_) { + WIFI_LOGW("ip is staticip"); + return; + } + if ((!isHasInternetRecently_) && (!isPortalUnthenEver_) && (!pSelfCureStateMachine_->isInternetUnknown_)) { + WIFI_LOGW("no internet access always"); + return; + } + WIFI_LOGI("begin to self cure for internet access: RenewDhcp"); + pSelfCureStateMachine_->UpdateSelfcureState(WIFI_CURE_RESET_LEVEL_RENEW_DHCP, true); + testedSelfCureLevel_.push_back(requestCureLevel); + renewDhcpCount_ += 1; + IStaService *pStaService = WifiServiceManager::GetInstance().GetStaServiceInst(0); + if (pStaService == nullptr) { + WIFI_LOGE("Get pStaService failed!"); + return; + } + if (pStaService->StartRenewDhcp() != WIFI_OPT_SUCCESS) { + WIFI_LOGE("StartRenewDhcp failed!"); + return; + } + WriteWifiSelfcureHisysevent(static_cast(WifiSelfcureType::ROAMING_ABNORMAL)); + pSelfCureStateMachine_->MessageExecutedLater(WIFI_CURE_CMD_IP_CONFIG_TIMEOUT, DHCP_RENEW_TIMEOUT_MS); +} + bool SelfCureStateMachine::InternetSelfCureState::SelectedSelfCureAcceptable() { if (currentAbnormalType_ == WIFI_CURE_INTERNET_FAILED_TYPE_DNS || @@ -1538,6 +1638,8 @@ void SelfCureStateMachine::InternetSelfCureState::HandleHttpReachableAfterSelfCu WriteWifiSelfcureHisysevent(static_cast(WifiSelfcureType::RESET_SELFCURE_SUCC)); } else if (currentCureLevel == WIFI_CURE_RESET_LEVEL_RAND_MAC_REASSOC) { WriteWifiSelfcureHisysevent(static_cast(WifiSelfcureType::RAND_MAC_REASSOC_SELFCURE_SUCC)); + } else if (currentCureLevel == WIFI_CURE_RESET_LEVEL_RENEW_DHCP) { + WriteWifiSelfcureHisysevent(static_cast(WifiSelfcureType::RENEW_DHCP_SELFCURE_SUCC)); } } @@ -1818,6 +1920,9 @@ void SelfCureStateMachine::NoInternetState::GoInState() pSelfCureStateMachine_->UpdateSelfcureState(WIFI_CURE_RESET_LEVEL_IDLE, false); pSelfCureStateMachine_->MessageExecutedLater(CMD_INTERNET_STATUS_DETECT_INTERVAL, NO_INTERNET_DETECT_INTERVAL_MS); + WifiLinkedInfo linkedInfo; + WifiConfigCenter::GetInstance().GetLinkedInfo(linkedInfo); + lastConnectedBssid_ = linkedInfo.bssid; } void SelfCureStateMachine::NoInternetState::GoOutState() @@ -1859,6 +1964,10 @@ bool SelfCureStateMachine::NoInternetState::ExecuteStateMsg(InternalMessagePtr m ret = EXECUTED; HandleArpFailedDetected(msg); break; + case WIFI_CURE_CMD_NETWORK_ROAMING_DETECT: + ret = EXECUTED; + HandleNoIntStaRoamingDetected(msg); + break; default: WIFI_LOGD("NoInternetState-msgCode=%{public}d not handled.\n", msg->GetMessageName()); break; @@ -1888,6 +1997,26 @@ void SelfCureStateMachine::NoInternetState::HandleArpFailedDetected(InternalMess } } +void SelfCureStateMachine::NoInternetState::HandleNoIntStaRoamingDetected(InternalMessagePtr msg) +{ + WIFI_LOGI("enter HandleNoIntStaRoamingDetected"); + if (msg == nullptr) { + WIFI_LOGE("HandleNoIntStaRoamingDetected, msg is nullptr"); + return; + } + std::string currentBssid; + msg->GetMessageObj(currentBssid); + if ((!currentBssid.empty()) && (lastConnectedBssid_ == currentBssid)) { + WIFI_LOGW("HandleNoIntStaRoamingDetected, but bssid is unchanged, ignore it"); + return; + } + if (!pSelfCureStateMachine_->CanArpReachable()) { + WIFI_LOGI("arp is unreachable"); + pSelfCureStateMachine_->selfCureReason_ = WIFI_CURE_INTERNET_FAILED_TYPE_ROAMING; + pSelfCureStateMachine_->SwitchState(pSelfCureStateMachine_->pInternetSelfCureState_); + } +} + void SelfCureStateMachine::SendBlaListToDriver(int blaListType) { AgeOutWifiCategoryBlack(blaListType); diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_state_machine.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_state_machine.h index 2312cf5c63cd11db79ea5e22f365a9e554a7b4bc..0686429d337fd090eb95679feb0e3e4b82f41784 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_state_machine.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_state_machine.h @@ -129,6 +129,7 @@ public: void HandleGatewayChanged(InternalMessagePtr msg); bool IsGatewayChanged(); void HandleDnsFailedMonitor(InternalMessagePtr msg); + void HandleRoamingDetected(InternalMessagePtr msg); bool IsNeedSelfCure(); }; @@ -219,6 +220,9 @@ public: void HandleArpFailedDetected(InternalMessagePtr msg); void HandleHttpReachableRecv(InternalMessagePtr msg); void HandleSelfCureResultFailed(InternalMessagePtr msg); + void HandleRenewDhcpFailed(InternalMessagePtr msg); + void HandleInRoamingDetected(InternalMessagePtr msg); + void HandleIpStateCompleted(InternalMessagePtr msg); void SelectSelfCureByFailedReason(int internetFailedType); int SelectBestSelfCureSolution(int internetFailedType); int SelectBestSelfCureSolutionExt(int internetFailedType); @@ -240,6 +244,7 @@ public: void SelfcureForMultiGateway(InternalMessagePtr msg); bool IsNeedMultiGatewaySelfcure(); void SelfCureForStaticIp(int requestCureLevel); + void SelfCureForRenewDhcp(int requestCureLevel); void RequestUseStaticIpConfig(IpInfo &dhcpResult); IpInfo GetNextTestDhcpResults(); IpInfo GetRecordDhcpResults(); @@ -284,6 +289,8 @@ public: bool ExecuteStateMsg(InternalMessagePtr msg) override; private: + std::string lastConnectedBssid_; + void HandleNoIntStaRoamingDetected(InternalMessagePtr msg); void HandleArpFailedDetected(InternalMessagePtr msg); SelfCureStateMachine *pSelfCureStateMachine_; }; diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_utils.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_utils.cpp index ee1337eef4721e6bd3685416c98aa1018262c758..e3f633d8a95e3916e0e6c148f1f90e811de645b2 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_utils.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_utils.cpp @@ -147,6 +147,9 @@ int32_t SelfCureUtils::GetSelfCureType(int32_t currentCureLevel) case WIFI_CURE_RESET_LEVEL_HIGH_RESET_WIFI_ON: ret = SelfCureType::SCE_TYPE_RESET_WIFI_ON; break; + case WIFI_CURE_RESET_LEVEL_RENEW_DHCP: + ret = SelfCureType::SCE_TYPE_RENEW_DHCP; + break; default: break; } @@ -241,6 +244,14 @@ void SelfCureUtils::UpdateSelfCureHistoryInfo(WifiSelfCureHistoryInfo &historyIn historyInfo.resetSelfCureFailedCnt += 1; historyInfo.lastResetSelfCureFailedTs = currentMs; } + } else if (requestCureLevel == WIFI_CURE_RESET_LEVEL_RENEW_DHCP) { + if (success) { + historyInfo.renewDhcpSelfCureConnectFailedCnt = 0; + historyInfo.lastRenewDhcpSelfCureConnectFailedTs = 0; + } else { + historyInfo.renewDhcpSelfCureConnectFailedCnt += 1; + historyInfo.lastRenewDhcpSelfCureConnectFailedTs = currentMs; + } } } @@ -273,6 +284,14 @@ void SelfCureUtils::UpdateSelfCureConnectHistoryInfo(WifiSelfCureHistoryInfo &hi historyInfo.resetSelfCureConnectFailedCnt += 1; historyInfo.lastResetSelfCureConnectFailedTs = currentMs; } + } else if (requestCureLevel == WIFI_CURE_RESET_LEVEL_RENEW_DHCP) { + if (success) { + historyInfo.renewDhcpSelfCureConnectFailedCnt = 0; + historyInfo.lastRenewDhcpSelfCureConnectFailedTs = 0; + } else { + historyInfo.renewDhcpSelfCureConnectFailedCnt += 1; + historyInfo.lastRenewDhcpSelfCureConnectFailedTs = currentMs; + } } } diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/ista_service.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/ista_service.h index ac4bb9cf19944616725560b097e6bffa8555bc40..5e1a52d4817e73280c4976ee3e4b84005fc4634b 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/ista_service.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/ista_service.h @@ -112,6 +112,13 @@ public: * @Return success: WIFI_OPT_SUCCESS fail: WIFI_OPT_FAILED */ virtual ErrCode ReAssociate() = 0; + + /** + * @Description ReAssociate network + * + * @Return success: WIFI_OPT_SUCCESS fail: WIFI_OPT_FAILED + */ + virtual ErrCode StartRenewDhcp() = 0; /** * @Description Add a specified candidate hotspot configuration. diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_define.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_define.h index b946fb8a9cf56163e8d34c17538947f43b246382..1e5a97ab03811d2bea8afffead33f53093ff3ad5 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_define.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_define.h @@ -38,6 +38,7 @@ namespace Wifi { #define WIFI_SVR_COM_STA_HILINK_DELIVER_MAC 0x200D #define WIFI_SVR_COM_STA_HILINK_TRIGGER_WPS 0x200E #define WIFI_SVR_COM_STA_NETWORK_REMOVED 0x200F +#define WIFI_SVR_COM_STA_RENEW_DHCP_NETWORK 0x2010 #define WIFI_SVR_CMD_STA_ERROR 0x3001 #define WIFI_SVR_CMD_STA_SUP_CONNECTION_EVENT 0x3002 diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_interface.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_interface.cpp index 39d23e6da5e5b50af3c2197a2e5531cce27bbc94..0acd45a995a7549916cf9e0b960e4154b6c7a3f0 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_interface.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_interface.cpp @@ -152,6 +152,18 @@ ErrCode StaInterface::ReAssociate() return WIFI_OPT_SUCCESS; } +ErrCode StaInterface::StartRenewDhcp() +{ + LOGI("Enter StartRenewDhcp.\n"); + std::lock_guard lock(mutex); + CHECK_NULL_AND_RETURN(pStaService, WIFI_OPT_FAILED); + if (pStaService->StartRenewDhcp() != WIFI_OPT_SUCCESS) { + LOGE("StartRenewDhcp failed.\n"); + return WIFI_OPT_FAILED; + } + return WIFI_OPT_SUCCESS; +} + ErrCode StaInterface::Disconnect() { LOGI("Enter Disconnect.\n"); diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_interface.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_interface.h index 4eaf960328f73da4bc82e4fc6bb77fb05f72c7fa..37641269798a6fe881995b24d45dde5153b8a975 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_interface.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_interface.h @@ -110,6 +110,13 @@ public: * @Return success: WIFI_OPT_SUCCESS fail: WIFI_OPT_FAILED */ virtual ErrCode ReAssociate() override; + + /** + * @Description StartRenewDhcp network + * + * @Return success: WIFI_OPT_SUCCESS fail: WIFI_OPT_FAILED + */ + virtual ErrCode StartRenewDhcp() override; /** * @Description Add a specified candidate hotspot configuration. * diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_service.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_service.cpp index 9b648d8d3776b256c6efb2dc7990151d5d8d2fc1..8992e8b83bf805eae7e8427e82024939327f85e4 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_service.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_service.cpp @@ -658,6 +658,14 @@ ErrCode StaService::ReAssociate() const return WIFI_OPT_SUCCESS; } +ErrCode StaService::StartRenewDhcp() const +{ + WIFI_LOGI("Enter StartRenewDhcp.\n"); + CHECK_NULL_AND_RETURN(pStaStateMachine, WIFI_OPT_FAILED); + pStaStateMachine->SendMessage(WIFI_SVR_COM_STA_RENEW_DHCP_NETWORK); + return WIFI_OPT_SUCCESS; +} + ErrCode StaService::EnableDeviceConfig(int networkId, bool attemptEnable) const { WIFI_LOGI("Enter EnableDeviceConfig, networkid is %{public}d", networkId); diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_service.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_service.h index 8c7b981bd8d2beeb83a11deee079384d9b34269e..36a2b368e7450cb7960ad846084478a3be74bf32 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_service.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_service.h @@ -116,6 +116,14 @@ public: * @Return success: WIFI_OPT_SUCCESS fail: WIFI_OPT_FAILED */ virtual ErrCode ReAssociate() const; + + /** + * @Description StartRenewDhcp network + * + * @Return success: WIFI_OPT_SUCCESS fail: WIFI_OPT_FAILED + */ + virtual ErrCode StartRenewDhcp() const; + /** * @Description Add a specified candidate hotspot configuration. * diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_state_machine.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_state_machine.cpp index c28db3bc4eb5f545bdb5ab0efee1b734fe0f1a55..753631b6a76544002cf101da62f5cf2e891ed868 100755 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_state_machine.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_state_machine.cpp @@ -702,6 +702,9 @@ int StaStateMachine::LinkState::InitStaSMHandleMap() staSmHandleFuncMap[WIFI_SVR_CMD_STA_REASSOCIATE_NETWORK] = [this](InternalMessagePtr msg) { return this->pStaStateMachine->DealReassociateCmd(msg); }; + staSmHandleFuncMap[WIFI_SVR_COM_STA_RENEW_DHCP_NETWORK] = [this](InternalMessagePtr msg) { + return this->DealRenewDhcp(msg); + }; staSmHandleFuncMap[WIFI_SCREEN_STATE_CHANGED_NOTIFY_EVENT] = [this](InternalMessagePtr msg) { return this->pStaStateMachine->DealScreenStateChangedEvent(msg); }; @@ -1432,6 +1435,11 @@ void StaStateMachine::ApLinkedState::HandleNetWorkConnectionEvent(InternalMessag pStaStateMachine->linkedInfo.detailedState = DetailedState::CONNECTED; WifiConfigCenter::GetInstance().SaveLinkedInfo(pStaStateMachine->linkedInfo, pStaStateMachine->m_instId); pStaStateMachine->InvokeOnStaConnChanged(OperateResState::CONNECT_AP_CONNECTED, pStaStateMachine->linkedInfo); +#ifdef FEATURE_SELF_CURE_SUPPORT + if (pStaStateMachine->selfCureService_ != nullptr) { + pStaStateMachine->selfCureService_->NotifyWifiRoamingCompleted(bssid); + } +#else if (!pStaStateMachine->CanArpReachable()) { WIFI_LOGI("Arp not reachable, start to dhcp."); WriteWifiSelfcureHisysevent(static_cast(WifiSelfcureType::ROAMING_ABNORMAL)); @@ -1439,6 +1447,7 @@ void StaStateMachine::ApLinkedState::HandleNetWorkConnectionEvent(InternalMessag } else { WIFI_LOGI("Arp reachable, stay in linked state."); } +#endif } void StaStateMachine::ApLinkedState::HandleStaBssidChangedEvent(InternalMessagePtr msg) @@ -2463,6 +2472,9 @@ void StaStateMachine::LinkedState::GoInState() pStaStateMachine->SaveDiscReason(DisconnectedReason::DISC_REASON_DEFAULT); pStaStateMachine->SaveLinkstate(ConnState::CONNECTED, DetailedState::CONNECTED); pStaStateMachine->InvokeOnStaConnChanged(OperateResState::CONNECT_AP_CONNECTED, pStaStateMachine->linkedInfo); + if (pStaStateMachine->selfCureService_ != nullptr) { + pStaStateMachine->selfCureService_->NotifyIpConfigCompleted(); + } return; } @@ -2774,6 +2786,11 @@ bool StaStateMachine::ApRoamingState::HandleNetworkConnectionEvent(InternalMessa pStaStateMachine->StopTimer(static_cast(CMD_AP_ROAMING_TIMEOUT_CHECK)); pStaStateMachine->StopTimer(static_cast(CMD_NETWORK_CONNECT_TIMEOUT)); pStaStateMachine->AfterApLinkedprocess(bssid); +#ifdef FEATURE_SELF_CURE_SUPPORT + if (pStaStateMachine->selfCureService_ != nullptr) { + pStaStateMachine->selfCureService_->NotifyWifiRoamingCompleted(bssid); + } +#else if (!pStaStateMachine->CanArpReachable()) { WIFI_LOGI("Arp is not reachable"); WriteWifiSelfcureHisysevent(static_cast(WifiSelfcureType::ROAMING_ABNORMAL)); @@ -2783,6 +2800,7 @@ bool StaStateMachine::ApRoamingState::HandleNetworkConnectionEvent(InternalMessa WIFI_LOGI("Arp is reachable"); pStaStateMachine->SwitchState(pStaStateMachine->pLinkedState); } +#endif return ret; } @@ -4245,6 +4263,16 @@ void StaStateMachine::DealReassociateCmd(InternalMessagePtr msg) } } +void StaStateMachine::LinkState::DealRenewDhcp(InternalMessagePtr msg) +{ + WIFI_LOGI("enter DealRenewDhcp.\n"); + if (msg == nullptr) { + WIFI_LOGE("msg is null\n"); + return; + } + pStaStateMachine->SwitchState(pStaStateMachine->pGetIpState); +} + void StaStateMachine::UserSelectConnectToNetwork(WifiDeviceConfig& deviceConfig, std::string& ifaceName) { WIFI_LOGI("SetBssid userSelectBssid=%{public}s", MacAnonymize(deviceConfig.userSelectBssid).c_str()); diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_state_machine.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_state_machine.h index 09b84c86ba3e39d25a4df0591d8b2753a6105a6a..76087962f9e3516789ca814e1cda053de31af665 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_state_machine.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_state_machine.h @@ -234,6 +234,7 @@ public: void DealWpaStateChange(InternalMessagePtr msg); void DealMloStateChange(InternalMessagePtr msg); void DealWpaCustomEapAuthEvent(InternalMessagePtr msg); + void DealRenewDhcp(InternalMessagePtr msg); }; /** * @Description Definition of member function of SeparatedState class in StaStateMachine. diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/Mock/mock_sta_interface.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/Mock/mock_sta_interface.cpp index e180d7e1ad9db4cfd00dad03f6831a6f176d5ac8..7a95732f0bf82f151424e7a256148716963eefeb 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/Mock/mock_sta_interface.cpp +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/Mock/mock_sta_interface.cpp @@ -83,6 +83,12 @@ ErrCode StaInterface::ReAssociate() return WIFI_OPT_SUCCESS; } +ErrCode StaInterface::StartRenewDhcp() +{ + LOGI("Enter StartRenewDhcp.\n"); + return WIFI_OPT_SUCCESS; +} + ErrCode StaInterface::Disconnect() { LOGI("Enter Disconnect.\n"); diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/Mock/mock_sta_service.h b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/Mock/mock_sta_service.h index d639b779c2e77c40e691efa06c074783453b7691..dcf6b6cc9fde128f15b61c4dcec61ca542d9696e 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/Mock/mock_sta_service.h +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/Mock/mock_sta_service.h @@ -32,6 +32,7 @@ public: MOCK_CONST_METHOD0(ReConnect, ErrCode()); MOCK_CONST_METHOD0(Disconnect, ErrCode()); MOCK_CONST_METHOD0(ReAssociate, ErrCode()); + MOCK_CONST_METHOD0(StartRenewDhcp, ErrCode()); MOCK_CONST_METHOD1(AddDeviceConfig, int(const WifiDeviceConfig &config)); MOCK_CONST_METHOD1(UpdateDeviceConfig, int(const WifiDeviceConfig &config)); MOCK_CONST_METHOD1(RemoveDevice, ErrCode(int networkId)); diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/self_cure_interface_test.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/self_cure_interface_test.cpp index 7060a23a7af8d71a1ac7db7e0869852dd426c887..d976a79054b6009048603a2b24dfe65ce2cd75f0 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/self_cure_interface_test.cpp +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/self_cure_interface_test.cpp @@ -114,6 +114,21 @@ public: pSelfCureInterface->pSelfCureService = nullptr; EXPECT_FALSE(pSelfCureInterface->IsWifiSelfcureDone()); } + + void NotifyWifiRoamingCompletedTest() + { + std::string bssid = "0.0.0.0"; + pSelfCureInterface->NotifyWifiRoamingCompleted(bssid); + pSelfCureInterface->pSelfCureService = nullptr; + pSelfCureInterface->NotifyWifiRoamingCompleted(bssid); + } + + void NotifyIpConfigCompletedTest() + { + pSelfCureInterface->NotifyIpConfigCompleted(); + pSelfCureInterface->pSelfCureService = nullptr; + pSelfCureInterface->NotifyIpConfigCompleted(); + } }; HWTEST_F(SelfCureInterfaceTest, IsWifiSelfcureDoneTest_01, TestSize.Level1) @@ -150,6 +165,18 @@ HWTEST_F(SelfCureInterfaceTest, DealRssiLevelChangedTest, TestSize.Level1) EXPECT_FALSE(g_errLog.find("service is null") != std::string::npos); } +HWTEST_F(SelfCureInterfaceTest, NotifyWifiRoamingCompletedTest, TestSize.Level1) +{ + NotifyWifiRoamingCompletedTest(); + EXPECT_FALSE(g_errLog.find("service is null") != std::string::npos); +} + +HWTEST_F(SelfCureInterfaceTest, NotifyIpConfigCompletedTest, TestSize.Level1) +{ + NotifyIpConfigCompletedTest(); + EXPECT_FALSE(g_errLog.find("service is null") != std::string::npos); +} + HWTEST_F(SelfCureInterfaceTest, NotifyInternetFailureDetectedTest, TestSize.Level1) { int forceNoHttpCheck = 0; diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/self_cure_service_test.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/self_cure_service_test.cpp index b16c5dce962f28afb97f148865400e8e9ee6254f..30bc83c4a759cac6914e5f1f3d4038b9bc9d6c1a 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/self_cure_service_test.cpp +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/self_cure_service_test.cpp @@ -222,5 +222,17 @@ HWTEST_F(SelfCureServiceTest, CheckSelfCureWifiResultTest, TestSize.Level1) EXPECT_FALSE(g_errLog.find("service is null") != std::string::npos); } +HWTEST_F(SelfCureServiceTest, NotifyWifiRoamingCompletedTest, TestSize.Level1) +{ + std::string bssid = "0.0.0.0"; + pSelfCureService->NotifyWifiRoamingCompleted(bssid); + EXPECT_FALSE(g_errLog.find("service is null") != std::string::npos); +} + +HWTEST_F(SelfCureServiceTest, NotifyIpConfigCompletedTest, TestSize.Level1) +{ + pSelfCureService->NotifyIpConfigCompleted(); + EXPECT_FALSE(g_errLog.find("service is null") != std::string::npos); +} } // namespace Wifi } // namespace OHOS \ No newline at end of file diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/self_cure_state_machine_test.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/self_cure_state_machine_test.cpp index 784e4c08b3a23ff99c94596cf11210fbb92100e3..dfcfec1a0af81803b61a6f4f3af68892f7ac98a4 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/self_cure_state_machine_test.cpp +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/self_cure_state_machine_test.cpp @@ -650,6 +650,8 @@ public: pSelfCureStateMachine_->pInternetSelfCureState_->SelectSelfCureByFailedReason(internetFailedType); internetFailedType = WIFI_CURE_INTERNET_FAILED_TYPE_TCP; pSelfCureStateMachine_->pInternetSelfCureState_->SelectSelfCureByFailedReason(internetFailedType); + internetFailedType = WIFI_CURE_INTERNET_FAILED_TYPE_ROAMING; + pSelfCureStateMachine_->pInternetSelfCureState_->SelectSelfCureByFailedReason(internetFailedType); pSelfCureStateMachine_->pInternetSelfCureState_->selfCureHistoryInfo_.resetSelfCureFailedCnt = SELFCURE_FAILED_CNT; @@ -715,6 +717,8 @@ public: pSelfCureStateMachine_->pInternetSelfCureState_->SelfCureWifiLink(requestCureLevel); requestCureLevel = WIFI_CURE_RESET_LEVEL_HIGH_RESET; pSelfCureStateMachine_->pInternetSelfCureState_->SelfCureWifiLink(requestCureLevel); + requestCureLevel = WIFI_CURE_RESET_LEVEL_RENEW_DHCP; + pSelfCureStateMachine_->pInternetSelfCureState_->SelfCureWifiLink(requestCureLevel); } void SelfCureForStaticIpTest() @@ -785,6 +789,19 @@ public: pSelfCureStateMachine_->pInternetSelfCureState_->SelfCureForReassoc(requestCureLevel); } + void SelfCureForRenewDhcpTest() + { + LOGI("Enter SelfCureForRenewDhcpTest"); + int requestCureLevel = WIFI_CURE_RESET_LEVEL_RENEW_DHCP; + pSelfCureStateMachine_->pInternetSelfCureState_->SelfCureForReassoc(requestCureLevel); + + EXPECT_CALL(*pMockStaService, ReAssociate()).WillRepeatedly(Return(WIFI_OPT_FAILED)); + pSelfCureStateMachine_->pInternetSelfCureState_->SelfCureForReassoc(requestCureLevel); + + EXPECT_CALL(*pMockStaService, ReAssociate()).WillRepeatedly(Return(WIFI_OPT_SUCCESS)); + pSelfCureStateMachine_->pInternetSelfCureState_->SelfCureForReassoc(requestCureLevel); + } + void IsNeedMultiGatewaySelfcureTest() { LOGI("Enter IsNeedMultiGatewaySelfcureTest"); @@ -2087,6 +2104,11 @@ HWTEST_F(SelfCureStateMachineTest, HandleSelfCureResultFailedTest, TestSize.Leve HandleSelfCureResultFailedTest(); } +HWTEST_F(SelfCureStateMachineTest, SelfCureForRenewDhcpTest, TestSize.Level1) +{ + SelfCureForReassocTest(); +} + HWTEST_F(SelfCureStateMachineTest, SelfcureForMultiGatewayTest, TestSize.Level1) { SelfcureForMultiGatewayTest(); diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_interface_test.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_interface_test.cpp index 85fd03610aa3785cef1a3e5ff33a72ef6f2ba476..629aed95cbbd56d90cf64b95b7617317a3d2480d 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_interface_test.cpp +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_interface_test.cpp @@ -139,6 +139,20 @@ public: EXPECT_TRUE(pStaInterface->ReAssociate() == WIFI_OPT_FAILED); } + void StartRenewDhcpSuceess() + { + WifiDeviceConfig config; + EXPECT_CALL(*pMockStaService, ReAssociate()).WillRepeatedly(Return(WIFI_OPT_SUCCESS)); + EXPECT_TRUE(pStaInterface->StartRenewDhcp() == WIFI_OPT_SUCCESS); + } + + void StartRenewDhcpFail1() + { + WifiDeviceConfig config; + EXPECT_CALL(*pMockStaService, ReAssociate()).WillRepeatedly(Return(WIFI_OPT_FAILED)); + EXPECT_TRUE(pStaInterface->StartRenewDhcp() == WIFI_OPT_FAILED); + } + void DisconnectSuceess() { WifiDeviceConfig config; @@ -508,6 +522,16 @@ HWTEST_F(StaInterfaceTest, ReAssociateFail1, TestSize.Level1) ReAssociateFail1(); } +HWTEST_F(StaInterfaceTest, StartRenewDhcpSuceess, TestSize.Level1) +{ + StartRenewDhcpSuceess(); +} + +HWTEST_F(StaInterfaceTest, StartRenewDhcpFail1, TestSize.Level1) +{ + StartRenewDhcpFail1(); +} + HWTEST_F(StaInterfaceTest, DisconnectSuceess, TestSize.Level1) { DisconnectSuceess();