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

Commit b2b9b2db authored by Eric Laurent's avatar Eric Laurent Committed by Android Git Automerger
Browse files

am 1ae4b6ce: am fe6db33a: am 4ef1dc2d: Merge "Only increase the counter when we do take a wakelock"

* commit '1ae4b6ce':
  Only increase the counter when we do take a wakelock
parents 8e26486d 1ae4b6ce
Loading
Loading
Loading
Loading
+7 −5
Original line number Original line Diff line number Diff line
@@ -318,7 +318,7 @@ sp<TimedEventQueue::Event> TimedEventQueue::removeEventFromQueue_l(


void TimedEventQueue::acquireWakeLock_l()
void TimedEventQueue::acquireWakeLock_l()
{
{
    if (mWakeLockCount++ == 0) {
    if (mWakeLockCount == 0) {
        CHECK(mWakeLockToken == 0);
        CHECK(mWakeLockToken == 0);
        if (mPowerManager == 0) {
        if (mPowerManager == 0) {
            // use checkService() to avoid blocking if power service is not up yet
            // use checkService() to avoid blocking if power service is not up yet
@@ -341,21 +341,23 @@ void TimedEventQueue::acquireWakeLock_l()
            IPCThreadState::self()->restoreCallingIdentity(token);
            IPCThreadState::self()->restoreCallingIdentity(token);
            if (status == NO_ERROR) {
            if (status == NO_ERROR) {
                mWakeLockToken = binder;
                mWakeLockToken = binder;
                mWakeLockCount++;
            }
            }
        }
        }
    } else {
        mWakeLockCount++;
    }
    }
}
}


void TimedEventQueue::releaseWakeLock_l(bool force)
void TimedEventQueue::releaseWakeLock_l(bool force)
{
{
    if (force) {
    if (mWakeLockCount == 0) {
    if (mWakeLockCount == 0) {
        return;
        return;
    }
    }
    if (force) {
        // Force wakelock release below by setting reference count to 1.
        // Force wakelock release below by setting reference count to 1.
        mWakeLockCount = 1;
        mWakeLockCount = 1;
    }
    }
    CHECK(mWakeLockCount != 0);
    if (--mWakeLockCount == 0) {
    if (--mWakeLockCount == 0) {
        CHECK(mWakeLockToken != 0);
        CHECK(mWakeLockToken != 0);
        if (mPowerManager != 0) {
        if (mPowerManager != 0) {