diff options
author | Brian Stack <bstack@google.com> | 2019-01-07 12:57:12 -0800 |
---|---|---|
committer | Brian Stack <bstack@google.com> | 2019-01-09 17:08:34 +0000 |
commit | d3849e10295d848cf3e040a446bcb6f139cfad30 (patch) | |
tree | 34eecc1d22b45fc3b56de3ab9c5e0865a3d959e5 /sensors | |
parent | 54a73b633ebf8a4febb00d34d55acf29270dca68 (diff) | |
download | android_hardware_interfaces-d3849e10295d848cf3e040a446bcb6f139cfad30.tar.gz android_hardware_interfaces-d3849e10295d848cf3e040a446bcb6f139cfad30.tar.bz2 android_hardware_interfaces-d3849e10295d848cf3e040a446bcb6f139cfad30.zip |
Stop Wake Lock thread if it is running
If the Wake Lock thread is running, stop it whenever initialize() is
called in order to prevent an invalid Wake Lock Queue from being read.
Also disable all sensors whenever initialize() is called to ensure
that stale sensor registrations are properly cleaned up.
Bug: 122468928
Test: Sensors HAL 2.0 tests run without crashing
Change-Id: I5fb55628545adbb481da6fcda157c78cff834134
Diffstat (limited to 'sensors')
-rw-r--r-- | sensors/2.0/default/Sensors.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/sensors/2.0/default/Sensors.cpp b/sensors/2.0/default/Sensors.cpp index efc8b053b..855e66ff1 100644 --- a/sensors/2.0/default/Sensors.cpp +++ b/sensors/2.0/default/Sensors.cpp @@ -86,6 +86,17 @@ Return<Result> Sensors::initialize( 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; |