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
1 file changed