이 컨텍스트에서 사용자 활동은 USER_ACTIVITY_FLAG_NO_CHANGE_LIGHTS 플래그를 포함하지 않고 PowerManager#userActivity 호출을 트리거하는 모든 것을 의미합니다 (다음을 포함하되 이에 국한되지 않음).
터치스크린과 상호작용
물리적 버튼 누르기
외부 액세서리의 입력 이벤트 (예: 연결된 키보드, 블루투스 리모컨, IR 원격)
음성 상호작용
원터치 플레이와 같은 특정 HDMI CEC 메시지 수신
새 전송 세션 시작
맞춤설정
기능이 사용 설정되면 지정된 사용자 비활성 시간 후 기기 화면에 경고가 표시됩니다. 아무 조치도 취하지 않으면 화면이 꺼집니다. 이러한 구성 옵션을 사용하여 기능을 맞춤설정할 수 있습니다.
제한 시간 구성
제한 시간을 구성하려면 frameworks/base/core/res/res/values/config.xml에서 다음 요소를 업데이트합니다.
config_attentiveTimeout
기본 사용자 비활성 시간(밀리초)을 지정합니다. 지정된 시간이 지나면 화면이 꺼지며 이는 화면 wake lock이 설정된 경우에도 마찬가지입니다.
빌드 시간에 설정합니다.
값이 0~config_minimumScreenOffTimeout이면 제한 시간이 config_minimumScreenOffTimeout으로 설정되어 절전 모드가 해제된 직후 기기의 화면이 꺼지지 않도록 합니다.
기본값은 -1이며, 이 기능을 사용 중지합니다.
기본 제한 시간 재정의
기본 제한 시간 설정을 재정의하려면 다음 요소를 업데이트하세요.
Settings.Secure.ATTENTIVE_TIMEOUT
이 매개변수를 설정하면 config_attentiveTimeout으로 설정된 기본 대기 시간 제한 시간을 재정의합니다.
런타임 시 설정할 수 있습니다.
경고 전 지속 시간 구성
지속 시간을 구성하려면 frameworks/base/core/res/res/values/config.xml에서 다음 요소를 업데이트합니다.
config_attentiveWarningDuration
오랜 시간 사용자의 활동이 없을 때 화면이 꺼지기 전에 사용자에게 얼마나 오랫동안 경고 메시지를 표시할지를 나타냅니다.
이 값은 자동 절전 모드의 설정된 제한 시간보다 훨씬 짧아야 합니다. 그러지 않으면 경고 대화상자가 계속 표시되고 이를 닫을 수 없습니다.
기본: 30000 (30s).
TV 설정 제한 시간 설정 표시
제한 시간 환경설정을 표시하려면 packages/apps/TvSettings/Settings/res/values/config.xml에서 다음 요소를 업데이트합니다.
config_show_standby_timeout
미디어 재생 중에 화면을 끄도록 허용하는 환경설정 항목을 표시할지 여부입니다.
기본값은 false입니다.
경고 UI를 위한 리소스
경고 대화상자의 레이아웃은 frameworks/base/packages/SystemUI/res/layout/inattentive_sleep_warning.xml에 정의되어 있습니다.
대화상자의 다음 문자열은 frameworks/base/packages/SystemUI/res/values/strings.xml와 frameworks/base/packages/SystemUI/res-product/values/strings.xml에서 정의됩니다.
inattentive_sleep_warning_title
inattentive_sleep_warning_message
빌드 시간 구성과 리소스는 리소스 오버레이에 의해 변경될 수 있습니다.
구현
다음을 사용하여 기능을 사용 설정합니다.
기본 config_attentiveTimeout을 재정의합니다.
AOSP TvSettings를 사용하는 경우:
config_show_standby_timeout를 재정의하여 설정에서 이 기능을 사용 중지합니다.
Settings.Secure.ATTENTIVE_TIMEOUT를 설정하는 자체 설정을 구현합니다.
유효성 검사
이 기능의 CTS 테스트는 cts/hostsidetests/os/src/android/os/cts/InattentiveSleepTests.java에 있습니다.
예시 및 소스
frameworks/base/packages/SystemUI/src/com/android/systemui/power/InattentiveSleepWarningView.java에는 기본 경고 UI 구현이 포함되어 있습니다.
packages/apps/TvSettings는 설정에서 기능을 노출하는 방법의 예시를 제공합니다.
직접 테스트 사례 예시
기기의 상태 HAL(하드웨어 추상화 계층)이 기기에 배터리가 있다고(battery_present가 true임) 보고하는 경우 stay_on_while_plugged_in 개발자 설정이 꺼져 있어야 합니다. 그러지 않으면 이 기능으로 화면이 꺼지지 않을 수 있습니다. adb shell settings put global stay_on_while_plugged_in 0
자동 절전 모드의 제한 시간을 경고 대화상자의 지속 시간보다 몇 초 더 길게 설정합니다. adb shell settings put secure attentive_timeout 32000
동영상 재생을 다시 시작하여 화면 wake lock을 확보합니다.
절전 모드 경고 대화상자가 몇 초 후에 표시되는지 확인합니다.
설정된 제한 시간이 지나면 화면이 꺼지는지 확인합니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-07-27(UTC)
[null,null,["최종 업데이트: 2025-07-27(UTC)"],[],[],null,["# TV standby\n\nIn Android 11, inattentive sleep is a power-saving feature\nthat allows a user inactivity timeout to be set after which the screen turns off, even\nif windows with [FLAG_KEEP_SCREEN_ON](https://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_KEEP_SCREEN_ON)\nare visible or wakelocks of level\n[FULL_WAKE_LOCK](https://developer.android.com/reference/android/os/PowerManager#FULL_WAKE_LOCK),\n[SCREEN_BRIGHT_WAKE_LOCK](https://developer.android.com/reference/android/os/PowerManager#SCREEN_BRIGHT_WAKE_LOCK) or\n[SCREEN_DIM_WAKE_LOCK](https://developer.android.com/reference/android/os/PowerManager#SCREEN_DIM_WAKE_LOCK)\nare held.\nWakelocks with level [PARTIAL_WAKE_LOCK](https://developer.android.com/reference/android/os/PowerManager#PARTIAL_WAKE_LOCK) aren't affected by this feature.\nShortly before the timeout expires, a message can be shown that warns\nthe user that the device will go to sleep if they don't interact with the device.\n\nIn this context, user activity refers to anything that triggers a call to\n`PowerManager#userActivity` (without the `USER_ACTIVITY_FLAG_NO_CHANGE_LIGHTS`\nflag), including but not limited to:\n\n- Interacting with the touchscreen\n- Pressing a physical button\n- Input events from an external accessory (for example, connected keyboard, bluetooth remote, IR remote)\n- Voice interaction\n- Receiving certain HDMI CEC messages, such as One Touch Play\n- Starting a new cast session\n\nCustomization\n-------------\n\nIf the feature is enabled, the device shows an onscreen warning after a specified time of\nuser inactivity. If no action is taken, the screen turns off. You can customize the feature\nusing these configuration options.\n| **Caution:** If a similar power-saving feature is already implemented, enabling this feature might lead to unintended consequences, such as duplicate warning UI.\n\n### Configure the timeout\n\nTo configure the timeout, update the following element in\n`frameworks/base/core/res/res/values/config.xml`:\n\n- `config_attentiveTimeout`\n - Specifies the default time in milliseconds of user inactivity after which the screen turns off (even if screen wakelocks are in place).\n - Set at build time.\n - If the value is between `0` and `config_minimumScreenOffTimeout`, the timeout is set to `config_minimumScreenOffTimeout` to prevent the device from turning off its screen shortly after waking up.\n - Default: `-1`, which disables this feature.\n\n### Override the default timeout\n\nTo override the default timeout setting, update the following element.\n\n- `Settings.Secure.ATTENTIVE_TIMEOUT`\n - If set, overrides the default inattentive sleep timeout set by `config_attentiveTimeout`.\n - Can be set at runtime.\n\n### Configure the duration before warning appears\n\nTo configure the duration, update the following element in\n`frameworks/base/core/res/res/values/config.xml`:\n\n- `config_attentiveWarningDuration`\n - How long to show a warning message to the user before the screen turns off after prolonged user inactivity.\n - The value should be well below the set inattentive sleep timeout, otherwise the warning dialog shows constantly and can't be dismissed.\n - Default: `30000` (30s).\n\n### Show the timeout preferences in TvSettings\n\nTo show the timeout preferences, update the following element in\n`packages/apps/TvSettings/Settings/res/values/config.xml`:\n\n- `config_show_standby_timeout`\n - Whether to show a preference item for allowing turning the screen off during media playback.\n - Default: `false`.\n\n### Resources for the warning UI\n\n- The layout of the warning dialog is defined in `frameworks/base/packages/SystemUI/res/layout/inattentive_sleep_warning.xml`.\n- The following strings for the dialog are defined in `frameworks/base/packages/SystemUI/res/values/strings.xml` and `frameworks/base/packages/SystemUI/res-product/values/strings.xml`.\n - `inattentive_sleep_warning_title`\n - `inattentive_sleep_warning_message`\n\nThe build time configurations and resources can be changed by resource overlays.\n\nImplementation\n--------------\n\nEnable the feature using the following.\n\n1. Override the default `config_attentiveTimeout`.\n2. If using the AOSP `TvSettings`:\n - Disable the feature in settings by overriding `config_show_standby_timeout`.\n - Implement your own settings that set `Settings.Secure.ATTENTIVE_TIMEOUT`.\n\nValidation\n----------\n\nThe CTS tests for the feature are at\n`cts/hostsidetests/os/src/android/os/cts/InattentiveSleepTests.java`.\n\nExamples and source\n-------------------\n\n- `frameworks/base/packages/SystemUI/src/com/android/systemui/power/InattentiveSleepWarningView.java` contains the default warning UI implementation.\n- `packages/apps/TvSettings` provides an example of how to expose the feature in settings.\n\nManual test case example\n------------------------\n\n1. Make sure the `stay_on_while_plugged_in`\n developer setting is off if the device's health HAL reports that the device has a\n battery (`battery_present` is `true`) as this might prevent the\n feature from turning off the screen. \n\n `adb shell settings put global stay_on_while_plugged_in 0`\n\n2. Set an inattentive sleep timeout to be a few seconds more than the warning dialog duration. \n `adb shell settings put secure attentive_timeout 32000`\n3. Start playing back a video (to acquire a screen wakelock).\n4. Verify that the sleep warning dialog appears after a few seconds.\n5. Verify that the screen turns off after the set timeout expires."]]