Merge "Stop Wake Lock thread if it is running"
diff --git a/sensors/2.0/default/Sensors.cpp b/sensors/2.0/default/Sensors.cpp
index 99c80df..15fe86f 100644
--- a/sensors/2.0/default/Sensors.cpp
+++ b/sensors/2.0/default/Sensors.cpp
@@ -87,6 +87,17 @@
const sp<ISensorsCallback>& sensorsCallback) {
Result result = Result::OK;
+ // Ensure that all sensors are disabled
+ for (auto sensor : mSensors) {
+ sensor.second->activate(false /* enable */);
+ }
+
+ // Stop the Wake Lock thread if it is currently running
+ if (mReadWakeLockQueueRun.load()) {
+ mReadWakeLockQueueRun = false;
+ mWakeLockThread.join();
+ }
+
// Save a reference to the callback
mCallback = sensorsCallback;