From 3ee519be3a3da1d9b341cbeeb400ceeaeb309aae Mon Sep 17 00:00:00 2001 From: Ahmed ElArabawy Date: Mon, 20 Apr 2020 16:28:49 +0800 Subject: [PATCH] Wifi: Optionally avoid interface down/up when doing setMacAddress Some vendors implementation will reset wifi chip when doing interface down. Accordingly, We need to avoid the interface down/up when doing setMacAddress to avoid loss of sync between framework and firmware. This commit uses a BOARD_WIFI_AVOID_IFACE_RESET_MAC_CHANGE macro to check if it is needed to avoid interface down/up at setMacAddress. Bug: 153771961 Test: VTS Test Test: atest VtsHalWifiV1_2TargetTest Change-Id: I971764f1c272ebfd245959974fa0d1b10ba7c39b --- wifi/1.4/default/Android.mk | 3 +++ wifi/1.4/default/wifi_iface_util.cpp | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/wifi/1.4/default/Android.mk b/wifi/1.4/default/Android.mk index 8573e8e1f5..6be7dad59e 100644 --- a/wifi/1.4/default/Android.mk +++ b/wifi/1.4/default/Android.mk @@ -36,6 +36,9 @@ endif ifdef WIFI_HIDL_FEATURE_DISABLE_AP_MAC_RANDOMIZATION LOCAL_CPPFLAGS += -DWIFI_HIDL_FEATURE_DISABLE_AP_MAC_RANDOMIZATION endif +ifdef WIFI_AVOID_IFACE_RESET_MAC_CHANGE +LOCAL_CPPFLAGS += -DWIFI_AVOID_IFACE_RESET_MAC_CHANGE +endif # Allow implicit fallthroughs in wifi_legacy_hal.cpp until they are fixed. LOCAL_CFLAGS += -Wno-error=implicit-fallthrough LOCAL_SRC_FILES := \ diff --git a/wifi/1.4/default/wifi_iface_util.cpp b/wifi/1.4/default/wifi_iface_util.cpp index 036c97bcba..13ba0225d1 100644 --- a/wifi/1.4/default/wifi_iface_util.cpp +++ b/wifi/1.4/default/wifi_iface_util.cpp @@ -52,18 +52,22 @@ std::array WifiIfaceUtil::getFactoryMacAddress( bool WifiIfaceUtil::setMacAddress(const std::string& iface_name, const std::array& mac) { +#ifndef WIFI_AVOID_IFACE_RESET_MAC_CHANGE if (!iface_tool_.lock()->SetUpState(iface_name.c_str(), false)) { LOG(ERROR) << "SetUpState(false) failed."; return false; } +#endif if (!iface_tool_.lock()->SetMacAddress(iface_name.c_str(), mac)) { LOG(ERROR) << "SetMacAddress failed."; return false; } +#ifndef WIFI_AVOID_IFACE_RESET_MAC_CHANGE if (!iface_tool_.lock()->SetUpState(iface_name.c_str(), true)) { LOG(ERROR) << "SetUpState(true) failed."; return false; } +#endif IfaceEventHandlers event_handlers = {}; const auto it = event_handlers_map_.find(iface_name); if (it != event_handlers_map_.end()) {