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

Commit e94f8eb8 authored by Andre Eisenbach's avatar Andre Eisenbach
Browse files

Make sure wakelock is held before releaseing it

Bug: 27748109
Change-Id: I38c8ec640f5def7c53348d2dd96a0a2492ff00cc
parent 07b96772
Loading
Loading
Loading
Loading
+12 −9
Original line number Diff line number Diff line
@@ -659,6 +659,7 @@ public class AdapterService extends Service {
        // {@link #releaseWakeLock(String lockName)}, so a synchronization is needed here.
        synchronized (this) {
            if (mWakeLock != null) {
                if (mWakeLock.isHeld())
                    mWakeLock.release();
                mWakeLock = null;
            }
@@ -2194,6 +2195,7 @@ public class AdapterService extends Service {
    // extended to allow acquiring an arbitrary number of wake locks. The current interface
    // takes |lockName| as a parameter in anticipation of that implementation.
    private boolean acquireWakeLock(String lockName) {
        synchronized (this) {
            if (mWakeLock == null) {
                mWakeLockName = lockName;
                mWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, lockName);
@@ -2201,7 +2203,7 @@ public class AdapterService extends Service {

            if (!mWakeLock.isHeld())
                mWakeLock.acquire();

        }
        return true;
    }

@@ -2216,6 +2218,7 @@ public class AdapterService extends Service {
                return false;
            }

            if (mWakeLock.isHeld())
                mWakeLock.release();
        }
        return true;