Add additional dirty checks in updateWakefulnessLocked
updateWakefulnessLocked is responsible for updating the wakefulness
state, ie. going to sleep if sleep conditions are met.
By changing the sleep timeout settings to a value that is lower than the
time since last user activity, you can get into a state where the device
does not go to sleep even though the sleep timeout is expired.
updateWakefulnessLocked should check all dirty flags that could trigger
a change in wakefulness.
This CL adds checks for two dirty flags:
- DIRTY_SETTINGS: As described above, changing the sleep timeout could
lead to a situation in which the sleep timeout is already expired and
the device should go to sleep
- DIRTY_SCREEN_BRIGHTNESS_BOOST: Inattentive sleep is disabled during
screen brightness boosts. As soon as the brightness boost ends, the
device should go to sleep if the timeout is expired.
Bug: 149008991
Test: 1. adb shell settings put secure sleep_timeout 900000
2. adb shell input keyevent HOME
3. sleep 15
4. adb shell settings put secure sleep_timeout 10000
Observe: Device goes to sleep
Test: 1. adb shell settings put secure attentive_timeout -1
2. adb shell input keyevent HOME
3. sleep 40
4. adb shell settings put secure attentive_timeout 32000
Observe: Device goes to sleep
Change-Id: I86be64f18f5c4d9dba43376fa608223b8c5ae6b2
This commit is contained in:
@@ -2385,7 +2385,8 @@ public final class PowerManagerService extends SystemService
|
||||
boolean changed = false;
|
||||
if ((dirty & (DIRTY_WAKE_LOCKS | DIRTY_USER_ACTIVITY | DIRTY_BOOT_COMPLETED
|
||||
| DIRTY_WAKEFULNESS | DIRTY_STAY_ON | DIRTY_PROXIMITY_POSITIVE
|
||||
| DIRTY_DOCK_STATE | DIRTY_ATTENTIVE)) != 0) {
|
||||
| DIRTY_DOCK_STATE | DIRTY_ATTENTIVE | DIRTY_SETTINGS
|
||||
| DIRTY_SCREEN_BRIGHTNESS_BOOST)) != 0) {
|
||||
if (mWakefulness == WAKEFULNESS_AWAKE && isItBedTimeYetLocked()) {
|
||||
if (DEBUG_SPEW) {
|
||||
Slog.d(TAG, "updateWakefulnessLocked: Bed time...");
|
||||
|
||||
Reference in New Issue
Block a user