wifi(implementation): Copy the user complete callback by value

The callback object may go out of scope by the time it's invoked. So,
make a copy of it. We're doing the same for the other user callbacks
received in this class.

Bug: 34930275
Test: Compiles
Change-Id: I275bba11ae8735a21514d871e8aa473f92f0fd7d
diff --git a/wifi/1.0/default/service.cpp b/wifi/1.0/default/service.cpp
index 96d5c6f..059304e 100644
--- a/wifi/1.0/default/service.cpp
+++ b/wifi/1.0/default/service.cpp
@@ -27,7 +27,7 @@
 int main(int /*argc*/, char** argv) {
   android::base::InitLogging(argv,
                              android::base::LogdLogger(android::base::SYSTEM));
-  LOG(INFO) << "wifi_hal_legacy is starting up...";
+  LOG(INFO) << "Wifi Hal is starting up...";
 
   configureRpcThreadpool(1, true /* callerWillJoin */);
 
@@ -39,6 +39,6 @@
 
   joinRpcThreadpool();
 
-  LOG(INFO) << "wifi_hal_legacy is terminating...";
+  LOG(INFO) << "Wifi Hal is terminating...";
   return 0;
 }
diff --git a/wifi/1.0/default/wifi_legacy_hal.cpp b/wifi/1.0/default/wifi_legacy_hal.cpp
index 40f55a3..cd89acc 100644
--- a/wifi/1.0/default/wifi_legacy_hal.cpp
+++ b/wifi/1.0/default/wifi_legacy_hal.cpp
@@ -350,7 +350,8 @@
     return WIFI_SUCCESS;
   }
   LOG(DEBUG) << "Stopping legacy HAL";
-  on_stop_complete_internal_callback = [&](wifi_handle handle) {
+  on_stop_complete_internal_callback = [on_stop_complete_user_callback,
+                                        this](wifi_handle handle) {
     CHECK_EQ(global_handle_, handle) << "Handle mismatch";
     // Invalidate all the internal pointers now that the HAL is
     // stopped.
diff --git a/wifi/1.0/default/wifi_legacy_hal.h b/wifi/1.0/default/wifi_legacy_hal.h
index dce4ed4..e65b79b 100644
--- a/wifi/1.0/default/wifi_legacy_hal.h
+++ b/wifi/1.0/default/wifi_legacy_hal.h
@@ -124,6 +124,9 @@
 /**
  * Class that encapsulates all legacy HAL interactions.
  * This class manages the lifetime of the event loop thread used by legacy HAL.
+ *
+ * Note: aThere will only be a single instance of this class created in the Wifi
+ * object and will be valid for the lifetime of the process.
  */
 class WifiLegacyHal {
  public: