From 03d642f6d94af339a3bb317c960f43b048101413 Mon Sep 17 00:00:00 2001 From: Les Lee Date: Mon, 21 Jun 2021 21:25:20 +0800 Subject: [PATCH] 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 --- wifi/1.5/default/wifi_chip.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/wifi/1.5/default/wifi_chip.cpp b/wifi/1.5/default/wifi_chip.cpp index 961f9da4c2..6fa9601672 100644 --- a/wifi/1.5/default/wifi_chip.cpp +++ b/wifi/1.5/default/wifi_chip.cpp @@ -1059,7 +1059,8 @@ WifiStatus WifiChip::removeIfaceInstanceFromBridgedApIfaceInternal( // 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 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 @@ WifiStatus WifiChip::removeIfaceInstanceFromBridgedApIfaceInternal( << " " << 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); }