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

Commit 96587ffd authored by Jie Cheng's avatar Jie Cheng Committed by Linux Build Service Account
Browse files

Sensors: Fix the mLock dead lock when enable sensor fail

SensorSeverce::enable will get the mLock, if enable the sensor
fail it will call the cleanupWithDisable and get the mLock too.
This will be a dead lock and crash the Android framewor. The
mLock should be used by the disable function but not used in
the cleanupWithDisable function.

Change-Id: I789fe7bf0ef944ae8852016bea92e8a373f469cd
parent 6524af3c
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -552,7 +552,7 @@ status_t SensorService::disable(const sp<SensorEventConnection>& connection,
{
    if (mInitCheck != NO_ERROR)
        return mInitCheck;

    Mutex::Autolock _l(mLock);
    status_t err = cleanupWithoutDisable(connection, handle);
    if (err == NO_ERROR) {
        SensorInterface* sensor = mSensorMap.valueFor(handle);
@@ -563,7 +563,6 @@ status_t SensorService::disable(const sp<SensorEventConnection>& connection,

status_t SensorService::cleanupWithoutDisable(const sp<SensorEventConnection>& connection,
        int handle) {
    Mutex::Autolock _l(mLock);
    SensorRecord* rec = mActiveSensors.valueFor(handle);
    if (rec) {
        // see if this connection becomes inactive