Signed-off-by: yangpengfei <yangpengfei34@huawei.com>
This commit is contained in:
yangpengfei 2024-11-19 13:36:40 +00:00 committed by Gitee
parent 967e7159c4
commit 39c18a795d
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 21 additions and 15 deletions

View File

@ -45,6 +45,14 @@ protected:
void GetCandidatesFromSubNetworkSelector() override;
};
class SuggestionNetworkTracker final: public CompositeNetworkSelector {
public:
SuggestionNetworkTracker();
protected:
bool Nominate(NetworkCandidate &networkCandidate) override;
void GetCandidatesFromSubNetworkSelector() override;
};
class SimpleFilterNetworkSelector : public SimpleNetworkSelector, public SimpleWifiFilter {
public:
explicit SimpleFilterNetworkSelector(const std::string &networkSelectorName);

View File

@ -32,6 +32,7 @@
#include "wifi_config_center.h"
#include "external_wifi_filter_builder_manager.h"
#include "external_wifi_common_builder_manager.h"
#include "block_connect_service.h"
DEFINE_WIFILOG_LABEL("StaService");
@ -640,12 +641,10 @@ ErrCode StaService::EnableDeviceConfig(int networkId, bool attemptEnable) const
WIFI_LOGI("Enter EnableDeviceConfig, networkid is %{public}d", networkId);
/* Update wifi status. */
if (WifiSettings::GetInstance().SetDeviceState(networkId, (int)WifiDeviceConfigStatus::ENABLED, attemptEnable) <
0) {
if (!BlockConnectService::GetInstance().EnableNetworkSelectStatus(networkId)) {
WIFI_LOGE("Enable device config failed!");
return WIFI_OPT_FAILED;
}
WifiSettings::GetInstance().SyncDeviceConfig();
return WIFI_OPT_SUCCESS;
}
@ -653,11 +652,11 @@ ErrCode StaService::DisableDeviceConfig(int networkId) const
{
WIFI_LOGI("Enter DisableDeviceConfig, networkid is %{public}d", networkId);
if (WifiSettings::GetInstance().SetDeviceState(networkId, (int)WifiDeviceConfigStatus::DISABLED) < 0) {
if (!BlockConnectService::GetInstance().UpdateNetworkSelectStatus(networkId,
DisabledReason::DISABLED_BY_WIFI_MANAGER)) {
WIFI_LOGE("Disable device config failed!");
return WIFI_OPT_FAILED;
}
WifiSettings::GetInstance().SyncDeviceConfig();
return WIFI_OPT_SUCCESS;
}

View File

@ -24,6 +24,7 @@
#include "wifi_msg.h"
#include "wifi_internal_msg.h"
#include "wifi_error_no.h"
#include "mock_block_connect_service.h"
using ::testing::_;
using ::testing::AtLeast;
@ -397,9 +398,8 @@ void StaServiceTest::StaServiceEnableDeviceConfigSuccess()
{
int networkId = NETWORK_ID;
bool attemptEnable = true;
EXPECT_CALL(WifiSettings::GetInstance(),
SetDeviceState(networkId, (int)WifiDeviceConfigStatus::ENABLED, attemptEnable))
.WillRepeatedly(Return(0));
EXPECT_CALL(BlockConnectService::GetInstance(),
EnableNetworkSelectStatus(networkId)).WillRepeatedly(Return(0));
EXPECT_TRUE(pStaService->EnableDeviceConfig(networkId, attemptEnable) == WIFI_OPT_SUCCESS);
}
@ -407,9 +407,8 @@ void StaServiceTest::StaServiceEnableDeviceConfigFail1()
{
int networkId = NETWORK_ID;
bool attemptEnable = true;
EXPECT_CALL(WifiSettings::GetInstance(),
SetDeviceState(networkId, (int)WifiDeviceConfigStatus::ENABLED, attemptEnable))
.WillRepeatedly(Return(-1));
EXPECT_CALL(BlockConnectService::GetInstance(),
EnableNetworkSelectStatus(networkId)).WillRepeatedly(Return(-1));
EXPECT_TRUE(pStaService->EnableDeviceConfig(networkId, attemptEnable) == WIFI_OPT_FAILED);
}
@ -424,8 +423,8 @@ void StaServiceTest::StaServiceDisableDeviceConfigSuccess()
{
int networkId = NETWORK_ID;
bool attemptEnable = false;
EXPECT_CALL(WifiSettings::GetInstance(),
SetDeviceState(networkId, (int)WifiDeviceConfigStatus::DISABLED, attemptEnable))
EXPECT_CALL(BlockConnectService::GetInstance(),
UpdateNetworkSelectStatus(networkId, DisabledReason::DISABLED_BY_WIFI_MANAGER))
.WillRepeatedly(Return(0));
EXPECT_TRUE(pStaService->DisableDeviceConfig(networkId) == WIFI_OPT_SUCCESS);
}
@ -434,8 +433,8 @@ void StaServiceTest::StaServiceDisableDeviceConfigFail1()
{
int networkId = NETWORK_ID;
bool attemptEnable = false;
EXPECT_CALL(WifiSettings::GetInstance(),
SetDeviceState(networkId, (int)WifiDeviceConfigStatus::DISABLED, attemptEnable))
EXPECT_CALL(BlockConnectService::GetInstance(),
UpdateNetworkSelectStatus(networkId, DisabledReason::DISABLED_BY_WIFI_MANAGER))
.WillRepeatedly(Return(-1));
EXPECT_TRUE(pStaService->DisableDeviceConfig(networkId) == WIFI_OPT_FAILED);
}