Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d3849e10 authored by Brian Stack's avatar Brian Stack
Browse files

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
parent 54a73b63
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -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;