From 908a69a53a90945c351a3d97da4cb1b9c0d7c8c3 Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Mon, 3 Oct 2016 13:33:23 -0700 Subject: [PATCH] wifi: Use hal_tool & if_tool Changes in the CL: 1. Currently |WifiNative.cpp|, uses |hal_tool| to initialize the function table and |if_tool| to set the interface up when |startHAL| method is invoked. Use the same sequence in the HIDL'ized HAL. 2. Remove the assertion if the function table initialization fails. This will result in a failure indication on starting the HAL now. Bug: 31352200 Test: mmma -j32 hardware/interfaces/wifi/1.0/default Change-Id: I268845ed62158b6a2ff36659f0bb15c4100a7222 --- wifi/1.0/default/Android.mk | 6 ++++-- wifi/1.0/default/wifi_legacy_hal.cpp | 20 ++++++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/wifi/1.0/default/Android.mk b/wifi/1.0/default/Android.mk index 14923f5925..07865a5df7 100644 --- a/wifi/1.0/default/Android.mk +++ b/wifi/1.0/default/Android.mk @@ -30,7 +30,8 @@ LOCAL_SHARED_LIBRARIES := \ libhwbinder \ liblog \ libnl \ - libutils + libutils \ + libwifi-system LOCAL_WHOLE_STATIC_LIBRARIES := $(LIB_WIFI_HAL) include $(BUILD_SHARED_LIBRARY) @@ -49,7 +50,8 @@ LOCAL_SHARED_LIBRARIES := \ libhwbinder \ liblog \ libnl \ - libutils + libutils \ + libwifi-system LOCAL_WHOLE_STATIC_LIBRARIES := $(LIB_WIFI_HAL) LOCAL_INIT_RC := android.hardware.wifi@1.0-service.rc include $(BUILD_EXECUTABLE) diff --git a/wifi/1.0/default/wifi_legacy_hal.cpp b/wifi/1.0/default/wifi_legacy_hal.cpp index a9ad0d172e..e755feace2 100644 --- a/wifi/1.0/default/wifi_legacy_hal.cpp +++ b/wifi/1.0/default/wifi_legacy_hal.cpp @@ -21,6 +21,8 @@ #include #include +#include +#include namespace { std::string getWlanInterfaceName() { @@ -50,16 +52,24 @@ namespace implementation { WifiLegacyHal::WifiLegacyHal() : global_handle_(nullptr), wlan_interface_handle_(nullptr), - awaiting_event_loop_termination_(false) { - CHECK_EQ(init_wifi_vendor_hal_func_table(&global_func_table_), WIFI_SUCCESS) - << "Failed to initialize legacy hal function table"; -} + awaiting_event_loop_termination_(false) {} wifi_error WifiLegacyHal::start() { // Ensure that we're starting in a good state. CHECK(!global_handle_ && !wlan_interface_handle_ && !awaiting_event_loop_termination_); + android::wifi_system::HalTool hal_tool; + android::wifi_system::InterfaceTool if_tool; + if (!hal_tool.InitFunctionTable(&global_func_table_)) { + LOG(ERROR) << "Failed to initialize legacy hal function table"; + return WIFI_ERROR_UNKNOWN; + } + if (!if_tool.SetWifiUpState(true)) { + LOG(ERROR) << "Failed to set WiFi interface up"; + return WIFI_ERROR_UNKNOWN; + } + LOG(INFO) << "Starting legacy HAL"; wifi_error status = global_func_table_.wifi_initialize(&global_handle_); if (status != WIFI_SUCCESS || !global_handle_) { @@ -130,6 +140,8 @@ void WifiLegacyHal::runEventLoop() { } LOG(VERBOSE) << "Legacy HAL event loop terminated"; awaiting_event_loop_termination_ = false; + android::wifi_system::InterfaceTool if_tool; + if_tool.SetWifiUpState(false); } } // namespace implementation