Don't release WakeLock w/o active client

Once we see the WakeLock isn't held, we should return before attempting
to release a non-existent WakeLock.

Bug: 168002974
Test: manual
Change-Id: I0172c637d7f6f22888c126da42d4fd1fe45fe0db
This commit is contained in:
Beverly
2021-01-15 12:17:02 -05:00
parent 4ed0306754
commit 386c3fcc8f

View File

@@ -33,7 +33,7 @@ public interface WakeLock {
static final String REASON_WRAP = "wrap";
/**
* Default wake-lock timeout, to avoid battery regressions.
* Default wake-lock timeout in milliseconds, to avoid battery regressions.
*/
long DEFAULT_MAX_TIMEOUT = 20000;
@@ -104,6 +104,7 @@ public interface WakeLock {
if (count == null) {
Log.wtf(TAG, "Releasing WakeLock with invalid reason: " + why,
new Throwable());
return;
} else if (count == 1) {
mActiveClients.remove(why);
} else {