اعتبارًا من 27 آذار (مارس) 2025، ننصحك باستخدام android-latest-release بدلاً من aosp-main لإنشاء AOSP والمساهمة فيه. لمزيد من المعلومات، يُرجى الاطّلاع على التغييرات في AOSP.
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
في Android 11، يُعدّ وضع "الاستراحة بدون انتباه" ميزة لتوفير الطاقة
تسمح بضبط مهلة عدم نشاط المستخدم ليتم بعدها إطفاء الشاشة، حتى
إذا كانت النوافذ التي تتضمّن FLAG_KEEP_SCREEN_ON
مرئية أو تم الاحتفاظ بقفل تنشيط الشاشة من المستوى
FULL_WAKE_LOCK أو
SCREEN_BRIGHT_WAKE_LOCK أو
SCREEN_DIM_WAKE_LOCK.
لا تتأثر عمليات قفل التنشيط ذات المستوى PARTIAL_WAKE_LOCK بهذه الميزة.
قبل انتهاء مهلة الانتظار بفترة قصيرة، يمكن عرض رسالة تحذر
المستخدم من أنّ الجهاز سينتقل إلى وضع السكون إذا لم يتفاعل معه.
في هذا السياق، يشير نشاط المستخدم إلى أي إجراء يؤدي إلى طلب PowerManager#userActivity (بدون العلامة USER_ACTIVITY_FLAG_NO_CHANGE_LIGHTS
)، بما في ذلك على سبيل المثال لا الحصر:
التفاعل مع الشاشة التي تعمل باللمس
الضغط على زرّ
إدخال أحداث من ملحق خارجي (مثل لوحة مفاتيح متصلة أو جهاز تحكّم عن بُعد مزوّد بالبلوتوث أو
جهاز تحكّم عن بُعد مزوّد بتقنية الأشعة تحت الحمراء)
التفاعل الصوتي
تلقّي رسائل معيّنة من HDMI CEC، مثل One Touch Play
بدء جلسة بث جديدة
التخصيص
في حال تفعيل الميزة، يعرض الجهاز تحذيرًا على الشاشة بعد مرور مدة زمنية محددة من عدم تحرك المستخدم. في حال عدم اتّخاذ أي إجراء، يتم إيقاف الشاشة. ويمكنك تخصيص الميزة
باستخدام خيارات الضبط هذه.
ضبط المهلة
لضبط مهلة الانتظار، عدِّل العنصر التالي في
frameworks/base/core/res/res/values/config.xml:
config_attentiveTimeout
تحدِّد هذه السمة الوقت التلقائي بالملي ثانية الذي لا يُدخل المستخدم خلاله أي بيانات ويتم بعدها إطفاء الشاشة
(حتى إذا كانت أدوات قفل تنشيط الشاشة مثبَّتة).
يتم ضبطها في وقت التصميم.
إذا كانت القيمة تتراوح بين 0 وconfig_minimumScreenOffTimeout،
يتم ضبط مهلة الانتظار على config_minimumScreenOffTimeout لمنع الجهاز من
إطفاء شاشته بعد وقت قصير من تنشيطها.
القيمة التلقائية: -1، ما يؤدي إلى إيقاف هذه الميزة
في حال ضبطها، تلغي المهلة التلقائية للنوم في حال عدم الانتباه التي تم ضبطها باستخدام
config_attentiveTimeout.
يمكن ضبطه أثناء التشغيل.
ضبط المدة قبل ظهور التحذير
لضبط المدة، عدِّل العنصر التالي في
frameworks/base/core/res/res/values/config.xml:
config_attentiveWarningDuration
المدة التي يتم خلالها عرض رسالة تحذيرية للمستخدم قبل أن يتم إطفاء الشاشة بعد
فترة طويلة من عدم نشاط المستخدم
يجب أن تكون القيمة أقل بكثير من مهلة السكون في حال عدم الانتباه المحدَّدة، وإلا سيظهر مربع diálogo التحذير باستمرار ولا يمكن إغلاقه.
القيمة التلقائية: 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
يمكن تغيير الإعدادات والموارد في وقت التصميم من خلال تراكب الموارد.
التنفيذ
فعِّل الميزة باتّباع الخطوات التالية:
يمكنك إلغاء القيمة التلقائية 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 تقدّم مثالاً على كيفية عرض الميزة في
الإعدادات.
مثال على حالة اختبار يدوية
تأكَّد من أنّ stay_on_while_plugged_in
إعداد المطوّر غير مفعَّل إذا أبلغ HAL عن حالة الجهاز بأنّه يحتوي على
بطارية (battery_present هو true)، لأنّ ذلك قد يمنع
الميزة من إطفاء الشاشة. 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 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],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."]]