diff options
| author | Ningyuan Wang <nywang@google.com> | 2016-12-02 15:09:53 -0800 |
|---|---|---|
| committer | Ningyuan Wang <nywang@google.com> | 2017-02-16 14:12:26 -0800 |
| commit | 495e5b35c9b7231574658f273f2aa061e46d0a08 (patch) | |
| tree | ed1876f32bc21179953da0618dd7251c2ee0b565 /server.cpp | |
| parent | b516002a75893408d9089c9443856968a84610fb (diff) | |
| download | platform_system_connectivity_wificond-495e5b35c9b7231574658f273f2aa061e46d0a08.tar.gz platform_system_connectivity_wificond-495e5b35c9b7231574658f273f2aa061e46d0a08.tar.bz2 platform_system_connectivity_wificond-495e5b35c9b7231574658f273f2aa061e46d0a08.zip | |
Monitor regulatory domain change
This adds the function of regulatory domain change monitoring
on wificond.
This also allows wificond to print the supported bands/channels
upon regulatory domain change.
This also adds the corresponding unit tests.
Bug: 35150708
Test: compile, unit tests, manual tests
Change-Id: Idbcf9ebf25f4e7be3b371ec3531b6b52303476e8
Diffstat (limited to 'server.cpp')
| -rw-r--r-- | server.cpp | 56 |
1 files changed, 53 insertions, 3 deletions
@@ -16,6 +16,8 @@ #include "wificond/server.h" +#include <sstream> + #include <android-base/logging.h> #include "wificond/net/netlink_utils.h" @@ -24,9 +26,6 @@ using android::binder::Status; using android::sp; using android::IBinder; -using std::string; -using std::vector; -using std::unique_ptr; using android::net::wifi::IApInterface; using android::net::wifi::IClientInterface; using android::net::wifi::IInterfaceEventCallback; @@ -38,6 +37,12 @@ using android::wifi_system::HostapdManager; using android::wifi_system::InterfaceTool; using android::wifi_system::SupplicantManager; +using std::placeholders::_1; +using std::string; +using std::stringstream; +using std::unique_ptr; +using std::vector; + namespace android { namespace wificond { @@ -164,6 +169,8 @@ Status Server::tearDownInterfaces() { } ap_interfaces_.clear(); + netlink_utils_->UnsubscribeRegDomainChange(wiphy_index_); + if (!driver_tool_->UnloadDriver()) { LOG(ERROR) << "Failed to unload WiFi driver!"; } @@ -234,6 +241,12 @@ bool Server::SetupInterfaceForMode(int mode, return false; } + netlink_utils_->SubscribeRegDomainChange( + wiphy_index_, + std::bind(&Server::OnRegDomainChanged, + this, + _1)); + if (!netlink_utils_->GetInterfaceInfo(wiphy_index_, interface_name, interface_index, @@ -253,6 +266,43 @@ bool Server::RefreshWiphyIndex() { return true; } +void Server::OnRegDomainChanged(std::string& country_code) { + if (country_code.empty()) { + LOG(INFO) << "Regulatory domain changed"; + } else { + LOG(INFO) << "Regulatory domain changed to country: " << country_code; + } + LogSupportedBands(); +} + +void Server::LogSupportedBands() { + BandInfo band_info; + ScanCapabilities scan_capabilities; + WiphyFeatures wiphy_features; + netlink_utils_->GetWiphyInfo(wiphy_index_, + &band_info, + &scan_capabilities, + &wiphy_features); + + stringstream ss; + for (unsigned int i = 0; i < band_info.band_2g.size(); i++) { + ss << " " << band_info.band_2g[i]; + } + LOG(INFO) << "2.4Ghz frequencies:"<< ss.str(); + ss.str(""); + + for (unsigned int i = 0; i < band_info.band_5g.size(); i++) { + ss << " " << band_info.band_5g[i]; + } + LOG(INFO) << "5Ghz non-DFS frequencies:"<< ss.str(); + ss.str(""); + + for (unsigned int i = 0; i < band_info.band_dfs.size(); i++) { + ss << " " << band_info.band_dfs[i]; + } + LOG(INFO) << "5Ghz DFS frequencies:"<< ss.str(); +} + void Server::BroadcastClientInterfaceReady( sp<IClientInterface> network_interface) { for (auto& it : interface_event_callbacks_) { |
