Wifi: Handle subsystem restart notification
This commit adds the logic to handle a notification of a wifi subsystem
restart to trigger the callback to the framework for self recovery.
Bug: 159367026
Test: force a firmware restart and make sure Wifi is recovered.
Change-Id: If6b5863d1d7473917088ec5be1910fa0db5dd6ae
diff --git a/wifi/1.4/default/wifi.cpp b/wifi/1.4/default/wifi.cpp
index 9c6b0f0..cfebfe0 100644
--- a/wifi/1.4/default/wifi.cpp
+++ b/wifi/1.4/default/wifi.cpp
@@ -107,9 +107,23 @@
}
WifiStatus wifi_status = initializeModeControllerAndLegacyHal();
if (wifi_status.code == WifiStatusCode::SUCCESS) {
+ // Register the callback for subsystem restart
+ const auto& on_subsystem_restart_callback =
+ [this](const std::string& error) {
+ WifiStatus wifi_status =
+ createWifiStatus(WifiStatusCode::ERROR_UNKNOWN, error);
+ for (const auto& callback : event_cb_handler_.getCallbacks()) {
+ if (!callback->onFailure(wifi_status).isOk()) {
+ LOG(ERROR) << "Failed to invoke onFailure callback";
+ }
+ }
+ };
+
// Create the chip instance once the HAL is started.
- chip_ = new WifiChip(kChipId, legacy_hal_, mode_controller_,
- iface_util_, feature_flags_);
+ // Need to consider the case of multiple chips TODO(156998862)
+ chip_ =
+ new WifiChip(kChipId, legacy_hal_, mode_controller_, iface_util_,
+ feature_flags_, on_subsystem_restart_callback);
run_state_ = RunState::STARTED;
for (const auto& callback : event_cb_handler_.getCallbacks()) {
if (!callback->onStart().isOk()) {