From 6e3806fc3417b29c1e33d908d150dcd737c5944e Mon Sep 17 00:00:00 2001 From: Beverly Date: Fri, 15 Jan 2021 12:17:02 -0500 Subject: [PATCH] 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 (cherry picked from commit 386c3fcc8f6678d330f72e900c40f890db9b76f4) --- .../src/com/android/systemui/util/wakelock/WakeLock.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/util/wakelock/WakeLock.java b/packages/SystemUI/src/com/android/systemui/util/wakelock/WakeLock.java index 08cd6e383897a..8d77c4a194a95 100644 --- a/packages/SystemUI/src/com/android/systemui/util/wakelock/WakeLock.java +++ b/packages/SystemUI/src/com/android/systemui/util/wakelock/WakeLock.java @@ -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 {