OSDN Git Service

wifi(implementation): Clear the chip immediately on IWifi.stop()
authorRoshan Pius <rpius@google.com>
Tue, 7 Mar 2017 20:45:56 +0000 (12:45 -0800)
committerRoshan Pius <rpius@google.com>
Tue, 7 Mar 2017 23:24:16 +0000 (23:24 +0000)
Currently, we wait for the legacy HAL callback to complete to clear and
invalidate the chip objects and it's derivatives. This may cause us to
access the wifi legacy HAL in a indeterminate state (as it's processing stop)
on subsequent HIDL calls.
So, clear up the chip object and derivatives immediately after we
process the stop to prevent any subsequent calls from sneaking in.

Also,
Added a couple of logs when wifi HAL is started/stopped to help debug
such issues later.

Bug: 36026601
Test: Turn on/off wifi and switch to softap mode multiple times.
Change-Id: Id5c2c9a90a335b2de4ae331ac8610b1a4e7875da

wifi/1.0/default/wifi.cpp

index 3d482b4..b48844e 100644 (file)
@@ -115,6 +115,7 @@ WifiStatus Wifi::startInternal() {
       }
     }
   }
+  LOG(INFO) << "Wifi HAL started";
   return wifi_status;
 }
 
@@ -139,6 +140,13 @@ WifiStatus Wifi::stopInternal() {
       }
     }
   }
+  // Clear the chip object and its child objects since the HAL is now
+  // stopped.
+  if (chip_.get()) {
+    chip_->invalidate();
+    chip_.clear();
+  }
+  LOG(INFO) << "Wifi HAL stopped";
   return wifi_status;
 }
 
@@ -172,13 +180,7 @@ WifiStatus Wifi::initializeLegacyHal() {
 
 WifiStatus Wifi::stopLegacyHalAndDeinitializeModeController() {
   run_state_ = RunState::STOPPING;
-  const auto on_complete_callback_ = [&]() {
-    if (chip_.get()) {
-      chip_->invalidate();
-    }
-    chip_.clear();
-    run_state_ = RunState::STOPPED;
-  };
+  const auto on_complete_callback_ = [&]() { run_state_ = RunState::STOPPED; };
   legacy_hal::wifi_error legacy_status =
       legacy_hal_->stop(on_complete_callback_);
   if (legacy_status != legacy_hal::WIFI_SUCCESS) {