!3254 when network recover, update Accept Unvalidated state

Merge pull request !3254 from yinyongbin/master
This commit is contained in:
openharmony_ci 2024-11-19 10:12:07 +00:00 committed by Gitee
commit 41ce37dd70
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
7 changed files with 27 additions and 7 deletions

View File

@ -3530,6 +3530,7 @@ void StaStateMachine::HandleNetCheckResult(SystemNetWorkState netState, const st
StartDetectTimer(DETECT_TYPE_PERIODIC);
}
#ifndef OHOS_ARCH_LITE
UpdateAcceptUnvalidatedState();
WifiNotificationUtil::GetInstance().CancelWifiNotification(
WifiNotificationId::WIFI_PORTAL_NOTIFICATION_ID);
#endif
@ -3575,6 +3576,10 @@ void StaStateMachine::HandleNetCheckResult(SystemNetWorkState netState, const st
#ifndef OHOS_ARCH_LITE
void StaStateMachine::SyncDeviceEverConnectedState(bool hasNet)
{
if (IsFactoryMode()) {
WIFI_LOGI("factory version, no need to pop up diag");
return;
}
WifiLinkedInfo linkedInfo;
WifiConfigCenter::GetInstance().GetLinkedInfo(linkedInfo);
int networkId = linkedInfo.networkId;
@ -3591,6 +3596,20 @@ void StaStateMachine::SyncDeviceEverConnectedState(bool hasNet)
}
#endif
#ifndef OHOS_ARCH_LITE
void StaStateMachine::UpdateAcceptUnvalidatedState()
{
WifiLinkedInfo linkedInfo;
WifiConfigCenter::GetInstance().GetLinkedInfo(linkedInfo);
int networkId = linkedInfo.networkId;
if (WifiSettings::GetInstance().GetAcceptUnvalidated(networkId)) {
WIFI_LOGI("network is recover, change the value of AcceptUnvalidated to false");
WifiSettings::GetInstance().SetAcceptUnvalidated(networkId, false);
WifiSettings::GetInstance().SyncDeviceConfig();
}
}
#endif
void StaStateMachine::HandleArpCheckResult(StaArpState arpState)
{
}

View File

@ -141,8 +141,6 @@ enum PortalState {
EXPERIED
};
/* Signal levels are classified into: 0 1 2 3 4 ,the max is 4. */
constexpr int MAX_LEVEL = 4;
const std::string WPA_BSSID_ANY = "any";
class StaStateMachine : public StateMachine {
@ -555,6 +553,7 @@ public:
void SetEnhanceService(IEnhanceService* enhanceService);
void SetSelfCureService(ISelfCureService *selfCureService);
void SyncDeviceEverConnectedState(bool hasNet);
void UpdateAcceptUnvalidatedState();
#endif
bool SetMacToHal(const std::string &currentMac, const std::string &realMac, int instId);

View File

@ -881,7 +881,7 @@ void NotificationEventSubscriber::OnReceiveWlanKeepConnected(const OHOS::EventFw
if (code == 1) { // The user clicks the use button.
WifiNetAgent::GetInstance().RestoreWifiConnection();
WIFI_LOGI("change the value of AcceptUnvalidated to true");
WifiSettings::GetInstance().SetAcceptUnvalidated(networkId);
WifiSettings::GetInstance().SetAcceptUnvalidated(networkId, true);
WifiSettings::GetInstance().SyncDeviceConfig();
}
}

View File

@ -348,14 +348,14 @@ int WifiSettings::SetDeviceEverConnected(int networkId)
return 0;
}
int WifiSettings::SetAcceptUnvalidated(int networkId)
int WifiSettings::SetAcceptUnvalidated(int networkId, bool state)
{
std::unique_lock<std::mutex> lock(mStaMutex);
auto iter = mWifiDeviceConfig.find(networkId);
if (iter == mWifiDeviceConfig.end()) {
return -1;
}
iter->second.acceptUnvalidated = true;
iter->second.acceptUnvalidated = state;
return 0;
}

View File

@ -132,7 +132,7 @@ public:
int SetDeviceEverConnected(int networkId);
int SetAcceptUnvalidated(int networkId);
int SetAcceptUnvalidated(int networkId, bool state);
bool GetDeviceEverConnected(int networkId);

View File

@ -260,7 +260,7 @@
"OHOS::Wifi::WifiSettings::SetDeviceRandomizedMacSuccessEver(int)";
"OHOS::Wifi::WifiSettings::SetDeviceEverConnected(int)";
"OHOS::Wifi::WifiSettings::GetPackageName(std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>)";
"OHOS::Wifi::WifiSettings::SetAcceptUnvalidated(int)";
"OHOS::Wifi::WifiSettings::SetAcceptUnvalidated(int, bool)";
"OHOS::Wifi::WifiSettings::GetDeviceEverConnected(int)";
"OHOS::Wifi::WifiSettings::GetAcceptUnvalidated(int)";
"OHOS::Wifi::WifiSettings::GetCandidateConfig(int, std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>> const&, std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>> const&, OHOS::Wifi::WifiDeviceConfig&)";

View File

@ -93,6 +93,7 @@ public:
virtual int GetHotspotConfig(HotspotConfig &config, int id) = 0;
virtual bool GetDeviceEverConnected(int networkId) = 0;
virtual int SetDeviceEverConnected(int networkId) = 0;
virtual int SetAcceptUnvalidated(int networkId, bool state) = 0;
virtual bool GetAcceptUnvalidated(int networkId) = 0;
};
@ -168,6 +169,7 @@ public:
MOCK_METHOD2(GetHotspotConfig, int(HotspotConfig &config, int id));
MOCK_METHOD1(GetDeviceEverConnected, bool(int networkId));
MOCK_METHOD1(SetDeviceEverConnected, int(int networkId));
MOCK_METHOD2(SetAcceptUnvalidated, int(int networkId, bool state));
MOCK_METHOD1(GetAcceptUnvalidated, bool(int networkId));
};
} // namespace OHOS