Add setting to go to sleep after long user inactivity

The European Commision prescribes an auto-standby feature for TV panels:
After some hours of inactivity, the device has to go from on-mode to
standby-mode or off-mode, or another condition not exceeding the
applicable requirements for standby-mode or for off-mode.

After a long time of no user activity the device should go to sleep,
even if wakelocks are held (eg. during video playback).

Test: 1. Set attentive timeout low, to 35s:
         `adb shell settings put secure attentive_timeout 35000`
      2. Play a YouTube video
      3. Observe warning dialog appearing after 5s
      4. Verify: Clicking a remote button or changing the setting higher hides
         the warning. Remote button press is consumed.
      5. Verify: After 35s of not pressing a button the device goes to sleep
      6. Verify: If "Stay awake" developer option is enabled, then
         warning is not displayed and device does not go to sleep after 35s
      7. Verify: No warning or sleep if setting is set to -1
Test: `atest frameworks/base/services/tests/servicestests/src/com/android/server/power/PowerManagerServiceTest.java`
Bug: 137633812
Change-Id: I551b6cffc336437fb1c5a00b4102f68ae0e003e9
This commit is contained in:
Robert Horvath
2019-07-10 10:46:38 +02:00
parent 94eebca44e
commit 5560f38654
23 changed files with 887 additions and 74 deletions

View File

@@ -2501,4 +2501,11 @@
<!-- Notification content text when switching to a default launcher that supports gesture navigation [CHAR LIMIT=NONE] -->
<string name="notification_content_gesture_nav_available">Go to Settings to update system navigation</string>
<!-- Title of the overlay warning the user to interact with the device or it will go to sleep. [CHAR LIMIT=25] -->
<string name="inattentive_sleep_warning_title">Standby</string>
<!-- Message of the overlay warning the user to interact with the device or it will go to sleep. [CHAR LIMIT=NONE] -->
<string name="inattentive_sleep_warning_message" product="tv">The Android TV device will soon turn off; press a button to keep it on.</string>
<!-- Message of the overlay warning the user to interact with the device or it will go to sleep. [CHAR LIMIT=NONE] -->
<string name="inattentive_sleep_warning_message" product="default">The device will soon turn off; press to keep it on.</string>
</resources>