קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
ב-Android 11, מצב שינה לא ממוקד הוא תכונת חיסכון בחשמל שמאפשרת להגדיר זמן קצוב לתפוגה של חוסר פעילות של המשתמש, שאחריו המסך נכבה, גם אם חלונות עם FLAG_KEEP_SCREEN_ON גלויים או אם חסימות מצב שינה ברמה FULL_WAKE_LOCK, SCREEN_BRIGHT_WAKE_LOCK או SCREEN_DIM_WAKE_LOCK מוחזקות.
התכונה הזו לא משפיעה על Wakelocks ברמה PARTIAL_WAKE_LOCK.
קצת לפני שפג התוקף של הזמן הקצוב, יכולה להופיע הודעה שמזהירה את המשתמש שהמכשיר ייכנס למצב שינה אם הוא לא יבצע פעולה כלשהי במכשיר.
בהקשר הזה, 'פעילות משתמש' מתייחסת לכל דבר שמפעיל קריאה ל-PowerManager#userActivity (ללא הדגל USER_ACTIVITY_FLAG_NO_CHANGE_LIGHTS), כולל, בין היתר:
אינטראקציה עם מסך המגע
לחיצה על לחצן פיזי
אירועי קלט מאביזר חיצוני (לדוגמה, מקלדת מחוברת, שלט רחוק ב-Bluetooth, שלט רחוק ב-IR)
אינטראקציה קולית
קבלת הודעות מסוימות של HDMI CEC, כמו One Touch Play
התחלת סשן העברה חדש
התאמה אישית
אם התכונה מופעלת, תוצג במכשיר אזהרה במסך אחרי פרק זמן מסוים של חוסר פעילות של המשתמש. אם לא תתבצע פעולה, המסך יכבה. אפשר להתאים אישית את התכונה באמצעות אפשרויות ההגדרה האלה.
הגדרת הזמן הקצוב לתפוגה
כדי להגדיר את הזמן הקצוב לתפוגה, מעדכנים את הרכיב הבא ב-frameworks/base/core/res/res/values/config.xml:
config_attentiveTimeout
המדיניות מציינת את פרק הזמן (באלפיות שנייה) שמוגדרת לו ברירת המחדל של חוסר פעילות מצד המשתמש, שאחריו המסך נכבה (גם אם יש נעילות מסך).
מוגדר בזמן ה-build.
אם הערך הוא בין 0 ל-config_minimumScreenOffTimeout, זמן הקצאת הזמן מוגדר ל-config_minimumScreenOffTimeout כדי למנוע מהמסך של המכשיר לכבות זמן קצר אחרי ההתעוררות.
ברירת המחדל: -1, שמשביתה את התכונה הזו.
שינוי ברירת המחדל של זמן הקצאת הזמן
כדי לשנות את הגדרת ברירת המחדל של הזמן הקצוב לתפוגה, מעדכנים את האלמנט הבא.
Settings.Secure.ATTENTIVE_TIMEOUT
אם הפרמטר מוגדר, הוא מבטל את ברירת המחדל של הזמן הקצוב לתפוגה של מצב שינה לא ממוקד שמוגדרת על ידי config_attentiveTimeout.
אפשר להגדיר אותו בזמן הריצה.
הגדרת משך הזמן עד להצגת האזהרה
כדי להגדיר את משך הזמן, מעדכנים את הרכיב הבא בקובץ frameworks/base/core/res/res/values/config.xml:
config_attentiveWarningDuration
משך הזמן שבו תוצג למשתמש הודעת אזהרה לפני שהמסך יכבה אחרי תקופה ארוכה של חוסר פעילות.
הערך צריך להיות נמוך בהרבה מזמן הקצאת הזמן לישון ללא תשומת לב, אחרת תיפתח תיבת הדו-שיח עם האזהרה כל הזמן ולא תהיה אפשרות לסגור אותה.
ברירת המחדל: 30000 (30 שניות).
הצגת העדפות הזמן הקצוב לתפוגה ב-TvSettings
כדי להציג את העדפות הזמן הקצוב לתפוגה, מעדכנים את הרכיב הבא ב-packages/apps/TvSettings/Settings/res/values/config.xml:
config_show_standby_timeout
האם להציג פריט העדפה שמאפשר לכבות את המסך במהלך הפעלת מדיה.
ברירת המחדל: false.
מקורות מידע לגבי ממשק המשתמש של האזהרה
הפריסה של תיבת הדו-שיח עם האזהרה מוגדרת בקובץ 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
אפשר לשנות את ההגדרות והמשאבים בזמן ה-build באמצעות שכבות-על של משאבים.
הטמעה
כדי להפעיל את התכונה, מבצעים את הפעולות הבאות.
משנים את ברירת המחדל 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 מכיל את הטמעת ממשק המשתמש של האזהרה שמוגדרת כברירת מחדל.
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
מתחילים להפעיל סרטון (כדי לקבל את הנעילה של המסך).
מוודאים שתיבת הדו-שיח עם האזהרה על שינה מופיעה אחרי כמה שניות.
מוודאים שהמסך נכבה לאחר שתוקף הזמן הקצוב לכיבוי פג.
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. Java ו-OpenJDK הם סימנים מסחריים או סימנים מסחריים רשומים של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-27 (שעון UTC).
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 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."]]