wificond: Handle NL80211_CMD_CH_SWITCH_NOTIFY

Add support to handle NL80211_CMD_CH_SWITCH_NOTIFY
mainly to update association frequency.

Bug: 155941506
Bug: 156588935
Test: Manual-Verified that channel is updated upon handling CSA.
Test: system/connectivity/wificond/runtests.sh

Signed-off-by: Purushottam Kushwaha <quic_pkushwah@quicinc.com>
Change-Id: I239c9e6ea0a082a909f9fe9caa007784ffab9112
This commit is contained in:
Purushottam Kushwaha 2020-05-14 18:34:27 +05:30 committed by Sunil Ravi
parent 24b56e91f2
commit 76fc67a6af
3 changed files with 21 additions and 0 deletions

View File

@ -40,6 +40,8 @@ using std::string;
using std::unique_ptr;
using std::vector;
using namespace std::placeholders;
namespace android {
namespace wificond {
@ -131,6 +133,9 @@ ClientInterfaceImpl::ClientInterfaceImpl(
}
});
netlink_utils_->SubscribeChannelSwitchEvent(interface_index_,
std::bind(&ClientInterfaceImpl::OnChannelSwitchEvent, this, _1));
if (!netlink_utils_->GetWiphyInfo(wiphy_index_,
&band_info_,
&scan_capabilities_,
@ -154,6 +159,7 @@ ClientInterfaceImpl::~ClientInterfaceImpl() {
scanner_->Invalidate();
netlink_utils_->UnsubscribeFrameTxStatusEvent(interface_index_);
netlink_utils_->UnsubscribeMlmeEvent(interface_index_);
netlink_utils_->UnsubscribeChannelSwitchEvent(interface_index_);
if_tool_->SetUpState(interface_name_.c_str(), false);
}
@ -251,6 +257,16 @@ bool ClientInterfaceImpl::RefreshAssociateFreq() {
return false;
}
bool ClientInterfaceImpl::OnChannelSwitchEvent(uint32_t frequency) {
if(!frequency) {
LOG(ERROR) << "Frequency value is null";
return false;
}
LOG(INFO) << "New channel on frequency: " << frequency;
associate_freq_ = frequency;
return true;
}
bool ClientInterfaceImpl::IsAssociated() const {
return is_associated_;
}

View File

@ -88,6 +88,7 @@ class ClientInterfaceImpl {
private:
bool RefreshAssociateFreq();
bool OnChannelSwitchEvent(uint32_t frequency);
const uint32_t wiphy_index_;
const std::string interface_name_;

View File

@ -77,6 +77,8 @@ class ClientInterfaceImplTest : public ::testing::Test {
OnFrameTxStatusEventHandler handler) {
frame_tx_status_event_handler_ = handler;
});
EXPECT_CALL(*netlink_utils_,
SubscribeChannelSwitchEvent(kTestInterfaceIndex, _));
client_interface_.reset(new ClientInterfaceImpl{
kTestWiphyIndex,
kTestInterfaceName,
@ -92,6 +94,8 @@ class ClientInterfaceImplTest : public ::testing::Test {
UnsubscribeMlmeEvent(kTestInterfaceIndex));
EXPECT_CALL(*netlink_utils_,
UnsubscribeFrameTxStatusEvent(kTestInterfaceIndex));
EXPECT_CALL(*netlink_utils_,
UnsubscribeChannelSwitchEvent(kTestInterfaceIndex));
}
unique_ptr<NiceMock<MockInterfaceTool>> if_tool_{