diff options
Diffstat (limited to 'wifi/1.5/default/wifi_iface_util.cpp')
-rw-r--r-- | wifi/1.5/default/wifi_iface_util.cpp | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/wifi/1.5/default/wifi_iface_util.cpp b/wifi/1.5/default/wifi_iface_util.cpp index 2a0aef8906..d1434e3a41 100644 --- a/wifi/1.5/default/wifi_iface_util.cpp +++ b/wifi/1.5/default/wifi_iface_util.cpp @@ -41,8 +41,10 @@ namespace implementation { namespace iface_util { WifiIfaceUtil::WifiIfaceUtil( - const std::weak_ptr<wifi_system::InterfaceTool> iface_tool) + const std::weak_ptr<wifi_system::InterfaceTool> iface_tool, + const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal) : iface_tool_(iface_tool), + legacy_hal_(legacy_hal), random_mac_address_(nullptr), event_handlers_map_() {} @@ -59,14 +61,20 @@ bool WifiIfaceUtil::setMacAddress(const std::string& iface_name, return false; } #endif - if (!iface_tool_.lock()->SetMacAddress(iface_name.c_str(), mac)) { - LOG(ERROR) << "SetMacAddress failed."; - return false; - } + bool success = iface_tool_.lock()->SetMacAddress(iface_name.c_str(), mac); #ifndef WIFI_AVOID_IFACE_RESET_MAC_CHANGE if (!iface_tool_.lock()->SetUpState(iface_name.c_str(), true)) { - LOG(ERROR) << "SetUpState(true) failed."; - return false; + LOG(ERROR) << "SetUpState(true) failed. Wait for driver ready."; + // Wait for driver ready and try to set iface UP again + if (legacy_hal_.lock()->waitForDriverReady() != + legacy_hal::WIFI_SUCCESS) { + LOG(ERROR) << "SetUpState(true) wait for driver ready failed."; + return false; + } + if (!iface_tool_.lock()->SetUpState(iface_name.c_str(), true)) { + LOG(ERROR) << "SetUpState(true) failed after retry."; + return false; + } } #endif IfaceEventHandlers event_handlers = {}; @@ -77,8 +85,12 @@ bool WifiIfaceUtil::setMacAddress(const std::string& iface_name, if (event_handlers.on_state_toggle_off_on != nullptr) { event_handlers.on_state_toggle_off_on(iface_name); } - LOG(DEBUG) << "Successfully SetMacAddress."; - return true; + if (!success) { + LOG(ERROR) << "SetMacAddress failed."; + } else { + LOG(DEBUG) << "SetMacAddress succeeded."; + } + return success; } std::array<uint8_t, 6> WifiIfaceUtil::getOrCreateRandomMacAddress() { |