wifi: Update active iface when bridged AP instance down
The active interface need to be updated when any of interface changecd.
Also fix the local cache bridged_ap_instances value incorrect
when erasing.
Bug: 191625124
Test: Manual check property "wifi.active.interface" after wlan2 down
Test: Manual test with command "halutil -sar enable 0" after wlan2 down
Change-Id: I40150c231313505ca355228e711c2448088f41ad
diff --git a/wifi/1.5/default/wifi_chip.cpp b/wifi/1.5/default/wifi_chip.cpp
index 961f9da..6fa9601 100644
--- a/wifi/1.5/default/wifi_chip.cpp
+++ b/wifi/1.5/default/wifi_chip.cpp
@@ -1059,7 +1059,8 @@
// Requires to remove one of the instance in bridge mode
for (auto const& it : br_ifaces_ap_instances_) {
if (it.first == ifname) {
- for (auto const& iface : it.second) {
+ std::vector<std::string> ap_instances = it.second;
+ for (auto const& iface : ap_instances) {
if (iface == ifInstanceName) {
if (!iface_util_->removeIfaceFromBridge(it.first, iface)) {
LOG(ERROR)
@@ -1075,13 +1076,20 @@
<< " " << legacyErrorToString(legacy_status);
return createWifiStatusFromLegacyError(legacy_status);
}
+ ap_instances.erase(
+ std::remove(ap_instances.begin(), ap_instances.end(),
+ ifInstanceName),
+ ap_instances.end());
+ br_ifaces_ap_instances_[ifname] = ap_instances;
+ break;
}
}
break;
}
}
- br_ifaces_ap_instances_.erase(ifInstanceName);
iface->removeInstance(ifInstanceName);
+ setActiveWlanIfaceNameProperty(getFirstActiveWlanIfaceName());
+
return createWifiStatus(WifiStatusCode::SUCCESS);
}