Skip to content

Commit 6edb6db

Browse files
author
Craig Mautner
committed
Ignore invalid combination of PowerManager flags.
ACQUIRE_CAUSES_WAKEUP is supposed to be ignored if combined with PARTIAL_WAKE_LOCK. Instead it was being carried out for any values of the WakeLock level. This change reverts behavior to closely match previous releases of the framework by only honoring ACQUIRE_CAUSES_WAKEUP for screen wake lock levels. The only difference being that in previous releases ACQUIRE_ could have been combined with PROXIMITY_SCREEN_OFF_WAKE_LOCK (it never was) and now such a combination will ignore the ACQUIRE_ flag. Bug 7532258 fixed. Change-Id: I46e848d8fd1b57e54c63141bf3d4f353986b5bdf
1 parent 7b0c877 commit 6edb6db

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

core/java/android/os/PowerManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ public final class PowerManager {
182182
* </p><p>
183183
* Since not all devices have proximity sensors, use {@link #isWakeLockLevelSupported}
184184
* to determine whether this wake lock level is supported.
185+
* </p><p>
186+
* Cannot be used with {@link #ACQUIRE_CAUSES_WAKEUP}.
185187
* </p>
186188
*
187189
* {@hide}

services/java/com/android/server/power/PowerManagerService.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,8 +618,19 @@ private void acquireWakeLockInternal(IBinder lock, int flags, String tag, WorkSo
618618
}
619619
}
620620

621+
private static boolean isScreenLock(final WakeLock wakeLock) {
622+
switch (wakeLock.mFlags & PowerManager.WAKE_LOCK_LEVEL_MASK) {
623+
case PowerManager.FULL_WAKE_LOCK:
624+
case PowerManager.SCREEN_BRIGHT_WAKE_LOCK:
625+
case PowerManager.SCREEN_DIM_WAKE_LOCK:
626+
return true;
627+
}
628+
return false;
629+
}
630+
621631
private void applyWakeLockFlagsOnAcquireLocked(WakeLock wakeLock) {
622-
if ((wakeLock.mFlags & PowerManager.ACQUIRE_CAUSES_WAKEUP) != 0) {
632+
if ((wakeLock.mFlags & PowerManager.ACQUIRE_CAUSES_WAKEUP) != 0 &&
633+
isScreenLock(wakeLock)) {
623634
wakeUpNoUpdateLocked(SystemClock.uptimeMillis());
624635
}
625636
}

0 commit comments

Comments
 (0)