From 3ba02e052bb0ca49b3aa4c37469faf3aaa89bf94 Mon Sep 17 00:00:00 2001 From: Les Lee Date: Wed, 7 Sep 2022 13:44:06 +0800 Subject: [PATCH] wifi: Two AP instances use the same interface name When device supports two AP interfaces (i.e. {AP, 2}. not a bridged case), the AP interface name might be observed from the getPredefinedApIfaceNames. Check if the interface name is used or not when creating a new interface. Bug: 244387442 Test: Manual test by commands adb shell cmd wifi start-softap tetheredAp open -b 2 adb shell cmd wifi start-lohs lohs open -b 5 Change-Id: I59b3796895ee09452a9650c4dc138ad9e143282e --- wifi/1.6/default/wifi_chip.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/wifi/1.6/default/wifi_chip.cpp b/wifi/1.6/default/wifi_chip.cpp index c7c00b17fd..920beb8778 100644 --- a/wifi/1.6/default/wifi_chip.cpp +++ b/wifi/1.6/default/wifi_chip.cpp @@ -1926,9 +1926,10 @@ uint32_t WifiChip::startIdxOfApIface() { // concurrent STA and not dual AP, else start with idx 0. std::string WifiChip::allocateApIfaceName() { // Check if we have a dedicated iface for AP. - std::vector ifnames = getPredefinedApIfaceNames(false); - if (!ifnames.empty()) { - return ifnames[0]; + std::vector ifnames = getPredefinedApIfaceNames(true); + for (auto const& ifname : ifnames) { + if (findUsingName(ap_ifaces_, ifname)) continue; + return ifname; } return allocateApOrStaIfaceName(IfaceType::AP, startIdxOfApIface()); }