mirror of
https://gitee.com/openharmony/communication_wifi.git
synced 2024-12-18 20:40:11 +00:00
Modify the chance of get_station
Signed-off-by: xiaohoufei <xiaohoufei@huawei.com>
This commit is contained in:
parent
c3c87b5105
commit
23d9ce687c
@ -929,7 +929,6 @@ void WifiManager::CloseStaService(int instId)
|
||||
return;
|
||||
}
|
||||
if (WifiConfigCenter::GetInstance().GetPowerSleepState() == MODE_STATE_OPEN) {
|
||||
WIFI_LOGI("PowerSleep not close sta SA!");
|
||||
WifiManager::GetInstance().StopUnloadStaSaTimer();
|
||||
return;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
@ -65,6 +65,7 @@ namespace Wifi {
|
||||
|
||||
#define WPA_BLOCK_LIST_CLEAR_EVENT 0x4001
|
||||
#define WIFI_SVR_CMD_UPDATE_COUNTRY_CODE 0x4002
|
||||
#define WIFI_SCREEN_STATE_CHANGED_NOTIFY_EVENT 0x4003
|
||||
|
||||
#define BSSID_LEN 17
|
||||
#define KEY_LEN 128
|
||||
|
@ -588,6 +588,8 @@ void StaService::HandleScreenStatusChanged(int screenState)
|
||||
} else {
|
||||
pStaStateMachine->StopTimer(static_cast<int>(CMD_START_NETCHECK));
|
||||
}
|
||||
|
||||
pStaStateMachine->SendMessage(WIFI_SCREEN_STATE_CHANGED_NOTIFY_EVENT, screenState);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
@ -66,6 +66,7 @@ StaStateMachine::StaStateMachine(int instId)
|
||||
isWpsConnect(IsWpsConnected::WPS_INVALID),
|
||||
getIpSucNum(0),
|
||||
getIpFailNum(0),
|
||||
enableSignalPoll(true),
|
||||
isRoam(false),
|
||||
netNoWorkNum(0),
|
||||
pDhcpService(nullptr),
|
||||
@ -823,6 +824,7 @@ int StaStateMachine::InitStaSMHandleMap()
|
||||
staSmHandleFuncMap[CMD_START_NETCHECK] = &StaStateMachine::DealNetworkCheck;
|
||||
staSmHandleFuncMap[CMD_START_GET_DHCP_IP_TIMEOUT] = &StaStateMachine::DealGetDhcpIpTimeout;
|
||||
staSmHandleFuncMap[CMD_START_RENEWAL_TIMEOUT] = &StaStateMachine::DealRenewalTimeout;
|
||||
staSmHandleFuncMap[WIFI_SCREEN_STATE_CHANGED_NOTIFY_EVENT] = &StaStateMachine::DealScreenStateChangedEvent;
|
||||
return WIFI_OPT_SUCCESS;
|
||||
}
|
||||
|
||||
@ -912,7 +914,11 @@ void StaStateMachine::DealSignalPollResult(InternalMessage *msg)
|
||||
WifiSettings::GetInstance().SaveLinkedInfo(linkedInfo, m_instId);
|
||||
ConvertFreqToChannel();
|
||||
DealSignalPacketChanged(signalInfo.txPackets, signalInfo.rxPackets);
|
||||
StartTimer(static_cast<int>(CMD_SIGNAL_POLL), STA_SIGNAL_POLL_DELAY);
|
||||
|
||||
if (enableSignalPoll) {
|
||||
WIFI_LOGD("DealSignalPollResult, StartTimer for SIGNAL_POLL.\n");
|
||||
StartTimer(static_cast<int>(CMD_SIGNAL_POLL), STA_SIGNAL_POLL_DELAY);
|
||||
}
|
||||
}
|
||||
|
||||
void StaStateMachine::DealSignalPacketChanged(int txPackets, int rxPackets)
|
||||
@ -2570,6 +2576,28 @@ void StaStateMachine::DealGetDhcpIpTimeout(InternalMessage *msg)
|
||||
DisConnectProcess();
|
||||
}
|
||||
|
||||
void StaStateMachine::DealScreenStateChangedEvent(InternalMessage *msg)
|
||||
{
|
||||
if (msg == nullptr) {
|
||||
WIFI_LOGE("DealScreenStateChangedEvent InternalMessage msg is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
int screenState = msg->GetParam1();
|
||||
WIFI_LOGI("DealScreenStateChangedEvent, Receive msg: screenState=%{public}d", screenState);
|
||||
if (screenState == MODE_STATE_OPEN) {
|
||||
enableSignalPoll = true;
|
||||
StartTimer(static_cast<int>(CMD_SIGNAL_POLL), 0);
|
||||
}
|
||||
|
||||
if (screenState == MODE_STATE_CLOSE) {
|
||||
enableSignalPoll = false;
|
||||
StopTimer(static_cast<int>(CMD_SIGNAL_POLL));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* ------------------ state machine dhcp callback function ----------------- */
|
||||
|
||||
StaStateMachine::DhcpResultNotify::DhcpResultNotify(StaStateMachine *staStateMachine)
|
||||
|
@ -818,6 +818,14 @@ private:
|
||||
* @param networkId - networkId
|
||||
*/
|
||||
void OnWifiWpa3SelfCure(int failreason, int networkId);
|
||||
|
||||
/**
|
||||
* @Description : Deal screen state change event.
|
||||
*
|
||||
* @param msg - Message body received by the state machine[in]
|
||||
*/
|
||||
void DealScreenStateChangedEvent(InternalMessage *msg);
|
||||
|
||||
#ifndef OHOS_ARCH_LITE
|
||||
/**
|
||||
* @Description Subscribe system ability changed.
|
||||
@ -854,6 +862,7 @@ private:
|
||||
IsWpsConnected isWpsConnect;
|
||||
int getIpSucNum;
|
||||
int getIpFailNum;
|
||||
bool enableSignalPoll;
|
||||
bool isRoam;
|
||||
int netNoWorkNum;
|
||||
bool portalFlag;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "mock_wifi_sta_hal_interface.h"
|
||||
#include "mock_wifi_supplicant_hal_interface.h"
|
||||
#include "sta_define.h"
|
||||
#include "define.h"
|
||||
#include "sta_state_machine.h"
|
||||
#include "wifi_internal_msg.h"
|
||||
#include "wifi_msg.h"
|
||||
@ -1769,6 +1770,16 @@ public:
|
||||
{
|
||||
pStaStateMachine->InvokeOnStaRssiLevelChanged(level);
|
||||
}
|
||||
|
||||
void DealScreenStateChangedEventTest()
|
||||
{
|
||||
InternalMessage msg;
|
||||
pStaStateMachine->DealScreenStateChangedEvent(nullptr);
|
||||
msg.SetParam1(static_cast<int>(MODE_STATE_OPEN));
|
||||
pStaStateMachine->DealScreenStateChangedEvent(&msg);
|
||||
msg.SetParam1(static_cast<int>(MODE_STATE_CLOSE));
|
||||
pStaStateMachine->DealScreenStateChangedEvent(&msg);
|
||||
}
|
||||
};
|
||||
|
||||
HWTEST_F(StaStateMachineTest, DealConnectTimeOutCmd, TestSize.Level1)
|
||||
@ -2758,5 +2769,16 @@ HWTEST_F(StaStateMachineTest, InvokeOnStaRssiLevelChangedTest, TestSize.Level1)
|
||||
int rssi = -61;
|
||||
InvokeOnStaRssiLevelChanged(rssi);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: DealScreenStateChangedEventTest
|
||||
* @tc.desc: DealScreenStateChangedEvent()
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issue
|
||||
*/
|
||||
HWTEST_F(StaStateMachineTest, DealScreenStateChangedEventTest, TestSize.Level1)
|
||||
{
|
||||
DealScreenStateChangedEventTest();
|
||||
}
|
||||
} // namespace Wifi
|
||||
} // namespace OHOS
|
||||
|
Loading…
Reference in New Issue
Block a user