(wifi) Removes unique_ptr<thread> and detaches

Bug: 77731993
Test: Build and boot oc
Change-Id: Ib1b1a6b68477c983fad38b116260c94d7a5b5621
diff --git a/common/commands/wifi_relay/wifi_relay.cpp b/common/commands/wifi_relay/wifi_relay.cpp
index 1af95d9..5db8a10 100644
--- a/common/commands/wifi_relay/wifi_relay.cpp
+++ b/common/commands/wifi_relay/wifi_relay.cpp
@@ -278,37 +278,36 @@
       exit(1);
   }
 
-  std::unique_ptr<std::thread> nlThread(
-          new std::thread([&client, &nlRoute]() {
-              for (;;) {
-                  fd_set rs;
-                  FD_ZERO(&rs);
+  std::thread([&client, &nlRoute] {
+    for (;;) {
+      fd_set rs;
+      FD_ZERO(&rs);
 
-                  int fdGeneric = nl_socket_get_fd(client.Sock());
-                  int fdRoute = nl_socket_get_fd(nlRoute.Sock());
+      int fdGeneric = nl_socket_get_fd(client.Sock());
+      int fdRoute = nl_socket_get_fd(nlRoute.Sock());
 
-                  FD_SET(fdGeneric, &rs);
-                  FD_SET(fdRoute, &rs);
+      FD_SET(fdGeneric, &rs);
+      FD_SET(fdRoute, &rs);
 
-                  int maxFd = std::max(fdGeneric, fdRoute);
+      int maxFd = std::max(fdGeneric, fdRoute);
 
-                  int res = select(maxFd + 1, &rs, nullptr, nullptr, nullptr);
+      int res = select(maxFd + 1, &rs, nullptr, nullptr, nullptr);
 
-                  if (res == 0) {
-                      continue;
-                  } else if (res < 0) {
-                      continue;
-                  }
+      if (res == 0) {
+        continue;
+      } else if (res < 0) {
+        continue;
+      }
 
-                  if (FD_ISSET(fdGeneric, &rs)) {
-                      nl_recvmsgs_default(client.Sock());
-                  }
+      if (FD_ISSET(fdGeneric, &rs)) {
+        nl_recvmsgs_default(client.Sock());
+      }
 
-                  if (FD_ISSET(fdRoute, &rs)) {
-                      nl_recvmsgs_default(nlRoute.Sock());
-                  }
-              }
-          }));
+      if (FD_ISSET(fdRoute, &rs)) {
+        nl_recvmsgs_default(nlRoute.Sock());
+      }
+    }
+  }).detach();
 
   const std::string phyName = FLAGS_iface_name + "_phy";
   if (createRadio(&client, relay.mac80211Family(), phyName.c_str()) < 0) {
diff --git a/common/libs/wifi/netlink.cc b/common/libs/wifi/netlink.cc
index 143a585..61c848b 100644
--- a/common/libs/wifi/netlink.cc
+++ b/common/libs/wifi/netlink.cc
@@ -45,7 +45,7 @@
   }
 
   // Start the thread processing asynchronous netlink responses.
-  netlink_thread_.reset(new std::thread([this]() { HandleNetlinkMessages(); }));
+  std::thread([this] { HandleNetlinkMessages(); }).detach();
 
   // Query relevant netlink families:
   // MAC80211 family allows us to create virtual radios and corresponding
diff --git a/common/libs/wifi/netlink.h b/common/libs/wifi/netlink.h
index e380731..2eb374f 100644
--- a/common/libs/wifi/netlink.h
+++ b/common/libs/wifi/netlink.h
@@ -62,8 +62,6 @@
 #endif
   int nl80211_family_ = 0;
 
-  std::unique_ptr<std::thread> netlink_thread_;
-
   Netlink(const Netlink&) = delete;
   Netlink& operator=(const Netlink&) = delete;
 };
diff --git a/common/libs/wifi/packet_switch.cc b/common/libs/wifi/packet_switch.cc
index b913a69..523611e 100644
--- a/common/libs/wifi/packet_switch.cc
+++ b/common/libs/wifi/packet_switch.cc
@@ -51,7 +51,7 @@
   nl_->WRCL().SetDefaultHandler(
       [this](nl_msg* m) { ProcessPacket(m, false); });
 
-  shm_xchg_.reset(new std::thread([this] {
+  shm_xchg_ = std::thread([this] {
       size_t maxlen = getpagesize();
       std::unique_ptr<uint8_t[]> msg(new uint8_t[maxlen]);
       auto hdr = reinterpret_cast<nlmsghdr*>(msg.get());
@@ -68,7 +68,7 @@
         nlm.reset(nlmsg_convert(hdr));
         ProcessPacket(nlm.get(), true);
       }
-    }));
+    });
 }
 
 void PacketSwitch::Stop() {
@@ -77,8 +77,7 @@
   started_ = false;
   nl_->WRCL().SetDefaultHandler(std::function<void(nl_msg*)>());
 
-  shm_xchg_->join();
-  shm_xchg_.reset();
+  shm_xchg_.join();
 }
 
 void PacketSwitch::ProcessPacket(nl_msg* m, bool is_incoming) {
diff --git a/common/libs/wifi/packet_switch.h b/common/libs/wifi/packet_switch.h
index 257ccd2..4edf720 100644
--- a/common/libs/wifi/packet_switch.h
+++ b/common/libs/wifi/packet_switch.h
@@ -44,7 +44,7 @@
   // whether to carry on working, or terminate.
   bool started_ = false;
 
-  std::unique_ptr<std::thread> shm_xchg_;
+  std::thread shm_xchg_;
   std::unique_ptr<vsoc::RegionWorker> worker_;
   vsoc::wifi::WifiExchangeView* shm_wifi_;
 
diff --git a/common/libs/wifi_relay/mac80211_hwsim.cpp b/common/libs/wifi_relay/mac80211_hwsim.cpp
index c08fcc9..4601c78 100644
--- a/common/libs/wifi_relay/mac80211_hwsim.cpp
+++ b/common/libs/wifi_relay/mac80211_hwsim.cpp
@@ -40,7 +40,7 @@
       mWifiExchange(wifiExchange) {
     mWifiWorker = mWifiExchange->StartWorker();
 
-    mThread.reset(new std::thread([this]{
+    mThread = std::thread([this]{
         std::unique_ptr<uint8_t[]> buf(
             new uint8_t[Mac80211HwSim::kMessageSizeMax]);
 
@@ -63,15 +63,14 @@
 
             hdr = nlmsg_next(hdr, &len);
           }
-        }}));
+    }});
 }
 
 Mac80211HwSim::Remote::~Remote() {
     mDone = true;
     mWifiExchange->InterruptSelf();
 
-    mThread->join();
-    mThread.reset();
+    mThread.join();
 }
 
 intptr_t Mac80211HwSim::Remote::send(const void *data, size_t size) {
diff --git a/common/libs/wifi_relay/mac80211_hwsim.h b/common/libs/wifi_relay/mac80211_hwsim.h
index 43f94fe..28eea6f 100644
--- a/common/libs/wifi_relay/mac80211_hwsim.h
+++ b/common/libs/wifi_relay/mac80211_hwsim.h
@@ -73,7 +73,7 @@
         std::unique_ptr<vsoc::RegionWorker> mWifiWorker;
 
         volatile bool mDone = false;
-        std::unique_ptr<std::thread> mThread;
+        std::thread mThread;
     };
 
     int mInitCheck = -ENODEV;