summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2021-06-05 23:09:18 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2021-06-05 23:09:18 +0000
commit642ddb08a443e29dea380c35ce9556c7c00ee473 (patch)
treea441316048ecc98aefc696fe7f87042b17e314f8
parenteebc30f3affb8f9d3be2bc224b12bbc2991a63ca (diff)
parent723416e2f4612083f7c7f4f8d92e261d5b3dcad2 (diff)
downloadwificond-642ddb08a443e29dea380c35ce9556c7c00ee473.tar.gz
Snap for 7430067 from 723416e2f4612083f7c7f4f8d92e261d5b3dcad2 to sc-d1-release
Change-Id: I82a7219892436884634e771654bad1d489d2df56
-rw-r--r--server.cpp41
1 files changed, 22 insertions, 19 deletions
diff --git a/server.cpp b/server.cpp
index e3b41e9..9668bce 100644
--- a/server.cpp
+++ b/server.cpp
@@ -67,35 +67,18 @@ Server::Server(unique_ptr<InterfaceTool> if_tool,
}
Status Server::registerWificondEventCallback(const sp<IWificondEventCallback>& callback) {
- uint32_t wiphy_index;
for (const auto& it : wificond_event_callbacks_) {
if (IInterface::asBinder(callback) == IInterface::asBinder(it)) {
LOG(WARNING) << "Ignore duplicate wificond event callback registration";
return Status::ok();
}
}
- // TODO: It may need to handle multi-chips case to get multi-wiphy index and
- // register corresponding callback.
- if (netlink_utils_->GetWiphyIndex(&wiphy_index)) {
- LOG(INFO) << "SubscribeRegDomainChange on wiphy_index:" << wiphy_index;
- netlink_utils_->SubscribeRegDomainChange(
- wiphy_index,
- std::bind(&Server::OnRegDomainChanged,
- this,
- _1,
- _2));
- }
LOG(INFO) << "New wificond event callback registered";
wificond_event_callbacks_.push_back(callback);
return Status::ok();
}
Status Server::unregisterWificondEventCallback(const sp<IWificondEventCallback>& callback) {
- uint32_t wiphy_index;
- if (netlink_utils_->GetWiphyIndex(&wiphy_index)) {
- LOG(INFO) << "UnSubscribeRegDomainChange on wiphy_index:" << wiphy_index;
- netlink_utils_->UnsubscribeRegDomainChange(wiphy_index);
- }
for (auto it = wificond_event_callbacks_.begin();
it != wificond_event_callbacks_.end();
it++) {
@@ -156,8 +139,12 @@ Status Server::createApInterface(const std::string& iface_name,
*created_interface = ap_interface->GetBinder();
BroadcastApInterfaceReady(ap_interface->GetBinder());
ap_interfaces_[iface_name] = std::move(ap_interface);
+ if (hasNoIfaceForWiphyIndex(wiphy_index)) {
+ UpdateBandWiphyIndexMap(wiphy_index);
+ } else {
+ LOG(INFO) << "Band info for wiphy_index " << wiphy_index << " already available";
+ }
iface_to_wiphy_index_map_[iface_name] = wiphy_index;
-
return Status::ok();
}
@@ -173,8 +160,14 @@ Status Server::tearDownApInterface(const std::string& iface_name,
const auto iter_wi = iface_to_wiphy_index_map_.find(iface_name);
if (iter_wi != iface_to_wiphy_index_map_.end()) {
+ int wiphy_index = iter_wi->second;
LOG(INFO) << "tearDownApInterface: erasing wiphy_index for iface_name " << iface_name;
iface_to_wiphy_index_map_.erase(iter_wi);
+ if (hasNoIfaceForWiphyIndex(wiphy_index)) {
+ EraseBandWiphyIndexMap(wiphy_index);
+ } else {
+ LOG(INFO) << "Band info for wiphy_index " << wiphy_index << " retained";
+ }
}
return Status::ok();
@@ -259,6 +252,7 @@ Status Server::tearDownInterfaces() {
MarkDownAllInterfaces();
for (auto& it : iface_to_wiphy_index_map_) {
+ netlink_utils_->UnsubscribeRegDomainChange(it.second);
EraseBandWiphyIndexMap(it.second);
}
iface_to_wiphy_index_map_.clear();
@@ -465,6 +459,14 @@ bool Server::SetupInterface(const std::string& iface_name,
LOG(ERROR) << "Failed to get wiphy index";
return false;
}
+ // TODO: It may need to handle multi-chips case to get multi-wiphy index and
+ // register corresponding callback.
+ netlink_utils_->SubscribeRegDomainChange(
+ *wiphy_index,
+ std::bind(&Server::OnRegDomainChanged,
+ this,
+ _1,
+ _2));
debug_interfaces_.clear();
if (!netlink_utils_->GetInterfaces(*wiphy_index, &debug_interfaces_)) {
@@ -487,7 +489,8 @@ void Server::OnRegDomainChanged(uint32_t wiphy_index, std::string& country_code)
if (country_code.empty()) {
LOG(INFO) << "Regulatory domain changed";
} else {
- LOG(INFO) << "Regulatory domain changed to country: " << country_code;
+ LOG(INFO) << "Regulatory domain changed to country: " << country_code
+ << " on wiphy_index: " << wiphy_index;
BroadcastRegDomainChanged(country_code);
}
LogSupportedBands(wiphy_index);