diff options
author | Roshan Pius <rpius@google.com> | 2016-11-18 14:07:54 -0800 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2016-12-07 15:38:24 -0800 |
commit | 97334114c61fdd0c12a7bfdeaa8ac36aa2c2368c (patch) | |
tree | c5faf3b66fa16cdcf0911e7d3caf2c1be0d4d29c /wifi | |
parent | a26a6e08075fe9a035df14cedaf2e864aba2317b (diff) | |
download | platform_hardware_interfaces-97334114c61fdd0c12a7bfdeaa8ac36aa2c2368c.tar.gz platform_hardware_interfaces-97334114c61fdd0c12a7bfdeaa8ac36aa2c2368c.tar.bz2 platform_hardware_interfaces-97334114c61fdd0c12a7bfdeaa8ac36aa2c2368c.zip |
wifi: Split out initialize and start in WifiLegacyHal
We need to separate these because we need to invoke start() after every
firmware mode change (chip reconfigure).
While there,
1. Make InterfaceTool a member of the class.
2. Make the stop() symmetric with start(). i.e interface is set
down on stop immediately instead of waiting for the thread to stop.
Bug: 31997422
Test: Compiles
Change-Id: I202afcc70571188dc076a841249761bc97fcf817
Diffstat (limited to 'wifi')
-rw-r--r-- | wifi/1.0/default/wifi_legacy_hal.cpp | 27 | ||||
-rw-r--r-- | wifi/1.0/default/wifi_legacy_hal.h | 7 |
2 files changed, 20 insertions, 14 deletions
diff --git a/wifi/1.0/default/wifi_legacy_hal.cpp b/wifi/1.0/default/wifi_legacy_hal.cpp index 560a273568..de1eb396c0 100644 --- a/wifi/1.0/default/wifi_legacy_hal.cpp +++ b/wifi/1.0/default/wifi_legacy_hal.cpp @@ -18,10 +18,11 @@ #include <android-base/logging.h> #include <cutils/properties.h> -#include <wifi_system/interface_tool.h> #include "wifi_legacy_hal.h" +using android::wifi_system::InterfaceTool; + namespace android { namespace hardware { namespace wifi { @@ -241,12 +242,7 @@ WifiLegacyHal::WifiLegacyHal() wlan_interface_handle_(nullptr), 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::InterfaceTool if_tool; +wifi_error WifiLegacyHal::initialize() { // TODO: Add back the HAL Tool if we need to. All we need from the HAL tool // for now is this function call which we can directly call. wifi_error status = init_wifi_vendor_hal_func_table(&global_func_table_); @@ -254,13 +250,19 @@ wifi_error WifiLegacyHal::start() { LOG(ERROR) << "Failed to initialize legacy hal function table"; return WIFI_ERROR_UNKNOWN; } - if (!if_tool.SetWifiUpState(true)) { + return WIFI_SUCCESS; +} + +wifi_error WifiLegacyHal::start() { + // Ensure that we're starting in a good state. + CHECK(global_func_table_.wifi_initialize && !global_handle_ && + !wlan_interface_handle_ && !awaiting_event_loop_termination_); + if (!iface_tool_.SetWifiUpState(true)) { LOG(ERROR) << "Failed to set WiFi interface up"; return WIFI_ERROR_UNKNOWN; } - LOG(INFO) << "Starting legacy HAL"; - status = global_func_table_.wifi_initialize(&global_handle_); + wifi_error status = global_func_table_.wifi_initialize(&global_handle_); if (status != WIFI_SUCCESS || !global_handle_) { LOG(ERROR) << "Failed to retrieve global handle"; return status; @@ -280,10 +282,11 @@ wifi_error WifiLegacyHal::stop( LOG(INFO) << "Stopping legacy HAL"; on_stop_complete_internal_callback = [&](wifi_handle handle) { CHECK_EQ(global_handle_, handle) << "Handle mismatch"; - on_stop_complete_user_callback(); // Invalidate all the internal pointers now that the HAL is // stopped. invalidate(); + iface_tool_.SetWifiUpState(false); + on_stop_complete_user_callback(); }; awaiting_event_loop_termination_ = true; global_func_table_.wifi_cleanup(global_handle_, onStopComplete); @@ -974,8 +977,6 @@ 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); } std::pair<wifi_error, std::vector<wifi_cached_scan_results>> diff --git a/wifi/1.0/default/wifi_legacy_hal.h b/wifi/1.0/default/wifi_legacy_hal.h index 62b773eb15..b569dbdb01 100644 --- a/wifi/1.0/default/wifi_legacy_hal.h +++ b/wifi/1.0/default/wifi_legacy_hal.h @@ -21,6 +21,8 @@ #include <thread> #include <vector> +#include <wifi_system/interface_tool.h> + namespace android { namespace hardware { namespace wifi { @@ -125,7 +127,9 @@ class WifiLegacyHal { std::string getP2pIfaceName(); std::string getStaIfaceName(); - // Initialize the legacy HAL and start the event looper thread. + // Initialize the legacy HAL function table. + wifi_error initialize(); + // Start the legacy HAL and the event looper thread. wifi_error start(); // Deinitialize the legacy HAL and stop the event looper thread. wifi_error stop(const std::function<void()>& on_complete_callback); @@ -245,6 +249,7 @@ class WifiLegacyHal { wifi_interface_handle wlan_interface_handle_; // Flag to indicate if we have initiated the cleanup of legacy HAL. bool awaiting_event_loop_termination_; + wifi_system::InterfaceTool iface_tool_; }; } // namespace legacy_hal |