Switch away from std::async for proximity-active callback.

By default, std::async() returns a future with the expectation that the
caller monitors it. By ignoring the future we forced the future's
destructor to run which waits on the thread by default (causing a
deadlock). Since we don't really want to monitor the future for our
purposes here anyway, we're switching to a detached thread with
this change.

Test: Verify that when sensor is enabled, there is an additional
      refresh rate vote for the rate specified in config file.
Bug: 175793106
Change-Id: Icfc2fc7e8dc84c614a9a19d7f23c9ce6d55cc6f0
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp
index a1c800e..2281721 100644
--- a/services/sensorservice/SensorService.cpp
+++ b/services/sensorservice/SensorService.cpp
@@ -1626,19 +1626,17 @@
 }
 
 void SensorService::notifyProximityStateLocked(
-        const std::vector<sp<ProximityActiveListener>>& listnrs) {
-    std::async(
-        std::launch::async,
-        [](uint64_t mySeq, bool isActive, std::vector<sp<ProximityActiveListener>> listeners) {
-            while (completedCallbackSeq.load() != mySeq - 1)
-                std::this_thread::sleep_for(1ms);
-            for (auto& listener : listeners)
-                listener->onProximityActive(isActive);
-            completedCallbackSeq++;
-        },
-        ++curProxCallbackSeq, mProximityActiveCount > 0,
-        listnrs /* (this is meant to be a copy) */
-    );
+        const std::vector<sp<ProximityActiveListener>>& listeners) {
+    const bool isActive = mProximityActiveCount > 0;
+    const uint64_t mySeq = ++curProxCallbackSeq;
+    std::thread t([isActive, mySeq, listenersCopy = listeners]() {
+        while (completedCallbackSeq.load() != mySeq - 1)
+            std::this_thread::sleep_for(1ms);
+        for (auto& listener : listenersCopy)
+            listener->onProximityActive(isActive);
+        completedCallbackSeq++;
+    });
+    t.detach();
 }
 
 status_t SensorService::addProximityActiveListener(const sp<ProximityActiveListener>& callback) {