wifi: Fixes in WifiLegacyHal am: 11f930321b am: d2d3498a4d

am: 6cc0c1def5

Change-Id: I78c13686807c4e72cf976f7f45b796a421e55435
This commit is contained in:
Roshan Pius 2016-12-14 01:38:17 +00:00 committed by android-build-merger
commit 8e8f7b2308
4 changed files with 24 additions and 14 deletions

View file

@ -165,7 +165,6 @@ std::pair<WifiStatus, sp<IWifiChip>> Wifi::getChipInternal(ChipId chip_id) {
}
WifiStatus Wifi::initializeLegacyHal() {
LOG(INFO) << "Initializing legacy HAL";
legacy_hal::wifi_error legacy_status = legacy_hal_->initialize();
if (legacy_status != legacy_hal::WIFI_SUCCESS) {
LOG(ERROR) << "Failed to initialize legacy HAL: "
@ -176,7 +175,6 @@ WifiStatus Wifi::initializeLegacyHal() {
}
WifiStatus Wifi::stopLegacyHalAndDeinitializeModeController() {
LOG(INFO) << "Stopping legacy HAL";
run_state_ = RunState::STOPPING;
const auto on_complete_callback_ = [&]() {
if (chip_.get()) {

View file

@ -249,9 +249,11 @@ void onNanEventTransmitFollowUp(NanTransmitFollowupInd* event) {
WifiLegacyHal::WifiLegacyHal()
: global_handle_(nullptr),
wlan_interface_handle_(nullptr),
awaiting_event_loop_termination_(false) {}
awaiting_event_loop_termination_(false),
is_started_(false) {}
wifi_error WifiLegacyHal::initialize() {
LOG(DEBUG) << "Initialize legacy HAL";
// 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_);
@ -266,29 +268,39 @@ 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 (is_started_) {
LOG(DEBUG) << "Legacy HAL already started";
return WIFI_SUCCESS;
}
LOG(DEBUG) << "Starting legacy HAL";
if (!iface_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_) {
LOG(ERROR) << "Failed to retrieve global handle";
return status;
}
event_loop_thread_ = std::thread(&WifiLegacyHal::runEventLoop, this);
std::thread(&WifiLegacyHal::runEventLoop, this).detach();
status = retrieveWlanInterfaceHandle();
if (status != WIFI_SUCCESS || !wlan_interface_handle_) {
LOG(ERROR) << "Failed to retrieve wlan interface handle";
return status;
}
LOG(VERBOSE) << "Legacy HAL start complete";
LOG(DEBUG) << "Legacy HAL start complete";
is_started_ = true;
return WIFI_SUCCESS;
}
wifi_error WifiLegacyHal::stop(
const std::function<void()>& on_stop_complete_user_callback) {
LOG(INFO) << "Stopping legacy HAL";
if (!is_started_) {
LOG(DEBUG) << "Legacy HAL already stopped";
on_stop_complete_user_callback();
return WIFI_SUCCESS;
}
LOG(DEBUG) << "Stopping legacy HAL";
on_stop_complete_internal_callback = [&](wifi_handle handle) {
CHECK_EQ(global_handle_, handle) << "Handle mismatch";
// Invalidate all the internal pointers now that the HAL is
@ -299,7 +311,8 @@ wifi_error WifiLegacyHal::stop(
};
awaiting_event_loop_termination_ = true;
global_func_table_.wifi_cleanup(global_handle_, onStopComplete);
LOG(VERBOSE) << "Legacy HAL stop initiated";
LOG(DEBUG) << "Legacy HAL stop complete";
is_started_ = false;
return WIFI_SUCCESS;
}
@ -1030,12 +1043,12 @@ wifi_error WifiLegacyHal::retrieveWlanInterfaceHandle() {
}
void WifiLegacyHal::runEventLoop() {
LOG(VERBOSE) << "Starting legacy HAL event loop";
LOG(DEBUG) << "Starting legacy HAL event loop";
global_func_table_.wifi_event_loop(global_handle_);
if (!awaiting_event_loop_termination_) {
LOG(FATAL) << "Legacy HAL event loop terminated, but HAL was not stopping";
}
LOG(VERBOSE) << "Legacy HAL event loop terminated";
LOG(DEBUG) << "Legacy HAL event loop terminated";
awaiting_event_loop_termination_ = false;
}

View file

@ -250,8 +250,6 @@ class WifiLegacyHal {
getGscanCachedResults();
void invalidate();
// Event loop thread used by legacy HAL.
std::thread event_loop_thread_;
// Global function table of legacy HAL.
wifi_hal_fn global_func_table_;
// Opaque handle to be used for all global operations.
@ -260,6 +258,8 @@ 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_;
// Flag to indicate if the legacy HAL has been started.
bool is_started_;
wifi_system::InterfaceTool iface_tool_;
};

View file

@ -64,8 +64,7 @@ bool WifiModeController::changeFirmwareMode(IfaceType type) {
LOG(ERROR) << "Failed to load WiFi driver";
return false;
}
if (!driver_tool_->IsFirmwareModeChangeNeeded(
convertIfaceTypeToFirmwareMode(type))) {
if (!driver_tool_->ChangeFirmwareMode(convertIfaceTypeToFirmwareMode(type))) {
LOG(ERROR) << "Failed to change firmware mode";
return false;
}