اعتبارًا من 27 آذار (مارس) 2025، ننصحك باستخدام android-latest-release
بدلاً من aosp-main
لإنشاء AOSP والمساهمة فيه. لمزيد من المعلومات، يُرجى الاطّلاع على التغييرات في AOSP.
نبذة عن المهام
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
لقطات مهام هي بنية أساسية تم تقديمها في Android 8.0 وتجمع بين
لقطات الشاشة للصور المصغّرة للتطبيقات المستخدَمة مؤخرًا بالإضافة إلى مساحات العرض المحفوظة
من "مدير النوافذ". تمثّل الصور المصغّرة "العناصر الأخيرة" الحالة الأخيرة للمهمة في
عرض "العناصر الأخيرة".
عندما ينتقل نشاط إلى حالة الإيقاف، لا يُزيل "مدير النوافذ" سطح النشاط ما دام هذا النشاط في أعلى المهام. إذا كان
يجب عرض هذا النشاط مرة أخرى، تمكّن "مدير النوافذ" من بدء التأثير المتحرك
بدون انتظار انتهاء النشاط من رسم إطاره الأول، لأنّه
تمكّن من استخدام "السطح المحفوظ" هذا.
هندسة معمارية
تم دمج مفهومَي "الصور المصغّرة للمحتوى المستخدَم مؤخرًا" و"مساحات العرض المحفوظة" في ميزة "
لقطات المهام". عندما تنتقل مهمة إلى الخلفية، يضع "مدير النوافذ" لقطة شاشة
لهذه المهمة في GraphicBuffer. طالما أنّ تطبيق النشاط الأهم في المهمة يظل في الذاكرة، سيتم الاحتفاظ بـ GraphicBuffer في
الذاكرة. الآن، عند عرض النشاط نفسه في المقدّمة مرة أخرى، سينشئ Window
Manager نافذة بدء (TaskSnapshotSurface)، ويُرفِق
GraphicBuffer بدون نسخ أي ذاكرة إلى قائمة انتظار المخزن المؤقت للنافذة
الافتتاحية. بعد أن يرسم النشاط إطاره الأول، ستتم إزالة نافذة بدء "لقطة المهام"
بسلاسة مثل شاشات البداية العادية.
يتم أيضًا إرسال GraphicBuffer نفسه عبر Binder إلى SystemUI لاستخدامه في رسم
حالة معاينة إحدى المهام في عرض "التطبيقات المستخدَمة مؤخرًا". بما أنّ هذا العنصر هو مجرد مرجع
للذاكرة المؤقتة، فإنّ إرساله عبر الرابط يستهلك القليل من الموارد. عندما يصل
GraphicBuffer إلى SystemUI، يتم تحويله إلى ملف Bitmap للأجهزة ثم تتم
رسومه على الشاشة بدون تحميل أي ذاكرة إلى ذاكرة الرسومات.
المزايا
هناك ثلاث مزايا رئيسية لهذه البنية الجديدة:
- إذا تم استخدام لقطة المهام كنافذة بداية، يظهر انتقال سلس
بين اللقطة والمحتوى الفعلي.
- عند رسم لقطة المهام في SystemUI، يمكن إجراء ذلك بدون أي
نسخ. في السابق، كان يجب نسخ الصورة النقطية إلى Ashmem، ثم إلى ذاكرة الرسومات. وبما أنّ هذه الطريقة تخزِّن اللقطة مباشرةً في ذاكرة الرسومات، ليس هناك حاجة إلى
النسخ.
- تتطابق الحالة التي تظهر لك في "التطبيقات المستخدَمة مؤخرًا" دائمًا مع الحالة التي ستظهر لك أولاً عند
إعادة فتح التطبيق. ويؤدي الاحتفاظ بمساحة التخزين المؤقت نفسها هنا إلى توفير الكثير من الذاكرة.
لهذا السبب، يمكن الآن لميزة "الصور الأخيرة" عرض هذه الصور بدقة كاملة.
في السابق، كان يتم تقليل العينة بنسبة% 64 لتوفير مساحة في الذاكرة.
التنفيذ
تتوفّر هذه الميزة بالكامل في نظام Android الأساسي. ولا يلزم دمجها، ولا يمكن تخصيصها. ومع ذلك، يمكن لصنّاع الأجهزة
إيقاف ميزة "لقطات المهام" بالكامل.
لإيقاف هذه الميزة، عدِّل هذه الدالة:
frameworks/base/services/core/java/com/android/server/wm/TaskSnapshotController.java#215
يُرجى العلم أنّه في حال إيقاف الميزة، لن تعرض بطاقة "المحتوى الأخير" أي Thumbnails على الإطلاق.
لقطات عالية الدقة ومنخفضة الدقة
يتم تسجيل لقطات المهام على القرص بمقياسَين. عند استعادة لقطة ملف مهمة
من القرص، تتم قراءة اللقطات المنخفضة الدقة أولاً، ثم يتم استبدالها
بالمقابلة العالية الدقة. ويؤدي هذا التحسين إلى تقليل أوقات تحميل الصور.
بخلاف ذلك، قد يكون هناك تأخير طفيف عند قراءة ملف اللقطة من
القرص، وسيظهر للمستخدم بطاقة مهمة فارغة إلى أن تصبح الصورة متاحة.
يمكنك ضبط المقاييس في ملف إعدادات تراكب الجهاز
overlay/frameworks/base/core/res/res/values/config.xml
من خلال ضبط
config_highResTaskSnapshotScale
و
config_lowResTaskSnapshotScale
. يتم ضبط هاتين القيمتَين تلقائيًا على 1.0
و0.5 على التوالي. أوقِف لقطات الشاشة ذات الدقة المنخفضة من خلال ضبط قيمة
config_lowResTaskSnapshotScale
على 0.0.
الأمثلة والمصدر
يمكنك العثور على بقية رمز هذه الميزة ضمن ملفات TaskSnapshot* في:
frameworks/base/+/android16-release/services/core/java/com/android/server/wm/
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ 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,["# Task snapshots\n\n*Task Snapshots* is infrastructure introduced in Android 8.0 that combines\nscreenshots for *Recents Thumbnails* as well as *Saved Surfaces*\nfrom Window Manager. Recents Thumbnails represent the last state of a task in\nthe Recents view.\n\n\nWhen an activity went into a stopped state, Window Manager didn't destroy the\nsurfaces of the activity as long as that activity was on the top of the task. If\nthis activity had to be shown again, Window Manager was able to start the\nanimation without waiting for the activity to finish drawing its first frame, as\nit was able to use this Saved Surface.\n\nArchitecture\n------------\n\n\nThe two concepts of Recents Thumbnails and Saved Surfaces are unified with Task\nSnapshots. When a task goes into background, Window Manager places a screenshot\nof this task into a GraphicBuffer. As long as the app of the top\nactivity of the task stays in memory, this GraphicBuffer will be retained in\nmemory. Now, when the same activity is brought to the front again, Window\nManager will create a starting window (TaskSnapshotSurface), and attach the\nGraphicBuffer without copying any memory to the buffer queue of the starting\nwindow. As soon as the activity has drawn its first frame, the Task Snapshot\nstarting window will fade out smoothly like regular splash screens.\n\n\nThe same GraphicBuffer is also sent over Binder to SystemUI to be used to draw\nthe preview state of a task in the Recents view. Since this is just a reference\nto a buffer, sending it over binder expends few resources. When the\nGraphicBuffer arrives at SystemUI, it is wrapped into a hardware Bitmap and then\ndrawn onto the screen without any memory uploading to the graphics memory.\n\nBenefits\n--------\n\n\nThere are three main benefits to this new architecture:\n\n- If the task snapshot is used as a starting window, there is a nice crossfade between the snapshot and the real content.\n- When the task snapshot is drawn in SystemUI, it can be done so without any copying. Previously the bitmap had to be copied into Ashmem, then into graphics memory. Since this method stores the snapshot directly in graphics memory, no copying is needed.\n- The state you see in Recents always matches the state you'll first see when reopening the app. Having the same buffer here also saves a lot of memory. That's why Recents is now able to show these images at full resolution. Previously, it was down sampled by 64% to save memory.\n\nImplementation\n--------------\n\n\nThis feature exists entirely in the Android platform. No integration is\nrequired, and customization isn't supported. However, device manufacturers can\ndisable the Task Snapshots feature entirely.\n\n\nTo disable this feature, modify this function: \n\n```text\nframeworks/base/services/core/java/com/android/server/wm/TaskSnapshotController.java#215\n```\n\n\nNote that if the feature is disabled, the Recents view will not show any\nthumbnails whatsoever.\n\nHigh-res and low-res snapshots\n------------------------------\n\nTask snapshots are written to the disk at two scales. When restoring a task snapshot from the disk, low-res snapshots are read first, and then replaced by their high-res counterpart. This optimization improves image load times. Otherwise, there could be a slight delay when reading the snapshot file from the disk, and the user would see a blank task card until the image was available. You can configure the scales in the device overlay config file `overlay/frameworks/base/core/res/res/values/config.xml` by setting `config_highResTaskSnapshotScale` and `config_lowResTaskSnapshotScale`. By default, these are set to 1.0 and 0.5 respectively. Disable low-res snapshots by setting `config_lowResTaskSnapshotScale` to 0.0.\n\nExamples and source\n-------------------\n\n\nFind the rest of the code for this feature within the TaskSnapshot\\* files in: \n\n```text\nframeworks/base/+/android16-release/services/core/java/com/android/server/wm/\n```"]]