Skip to content

Commit 84f85dc

Browse files
Jeff BrownAndroid (Google) Code Review
authored andcommitted
Merge "Fix keyguard wake-up issue."
2 parents 827c182 + ff1baef commit 84f85dc

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

core/java/android/os/PowerManager.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -542,14 +542,18 @@ public void acquire(long timeout) {
542542

543543
private void acquireLocked() {
544544
if (!mRefCounted || mCount++ == 0) {
545+
// Do this even if the wake lock is already thought to be held (mHeld == true)
546+
// because non-reference counted wake locks are not always properly released.
547+
// For example, the keyguard's wake lock might be forcibly released by the
548+
// power manager without the keyguard knowing. A subsequent call to acquire
549+
// should immediately acquire the wake lock once again despite never having
550+
// been explicitly released by the keyguard.
545551
mHandler.removeCallbacks(mReleaser);
546-
if (!mHeld) {
547-
try {
548-
mService.acquireWakeLock(mFlags, mToken, mTag, mWorkSource);
549-
} catch (RemoteException e) {
550-
}
551-
mHeld = true;
552+
try {
553+
mService.acquireWakeLock(mFlags, mToken, mTag, mWorkSource);
554+
} catch (RemoteException e) {
552555
}
556+
mHeld = true;
553557
}
554558
}
555559

0 commit comments

Comments
 (0)