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

Commit c6a797c4 authored by Sharvil Nanavati's avatar Sharvil Nanavati Committed by Android Git Automerger
Browse files

am dc10b18f: Fix bug b/16119342 by synchronizing the access of mWakeLock in release().

* commit 'dc10b18f':
  Fix bug b/16119342 by synchronizing the access of mWakeLock in release().
parents 75ac958d dc10b18f
Loading
Loading
Loading
Loading
+19 −12
Original line number Diff line number Diff line
@@ -415,10 +415,14 @@ public class AdapterService extends Service {
            mPendingAlarm = null;
        }

        // This wake lock release may also be called concurrently by
        // {@link #releaseWakeLock(String lockName)}, so a synchronization is needed here.
        synchronized (this) {
            if (mWakeLock != null) {
                mWakeLock.release();
                mWakeLock = null;
            }
        }

        if (mAdapterStateMachine != null) {
            mAdapterStateMachine.doQuit();
@@ -1590,9 +1594,11 @@ public class AdapterService extends Service {
    }

    // This function is called from JNI. It allows native code to release a wake lock acquired
    // by |acquireWakeLock|. If the wake lock is not held, this function returns failure. See
    // the comment for |acquireWakeLock| for an explanation of the interface.
    // by |acquireWakeLock|. If the wake lock is not held, this function returns failure.
    // Note that the release() call is also invoked by {@link #cleanup()} so a synchronization is
    // needed here. See the comment for |acquireWakeLock| for an explanation of the interface.
    private boolean releaseWakeLock(String lockName) {
        synchronized (this) {
            if (mWakeLock == null) {
                errorLog("Repeated wake lock release; aborting release: " + lockName);
                return false;
@@ -1601,6 +1607,7 @@ public class AdapterService extends Service {
            mWakeLock.release();
            mWakeLock = null;
            mWakeLockName = null;
        }
        return true;
    }