اعتبارًا من 27 آذار (مارس) 2025، ننصحك باستخدام android-latest-release
بدلاً من aosp-main
لإنشاء AOSP والمساهمة فيه. لمزيد من المعلومات، يُرجى الاطّلاع على التغييرات في AOSP.
أداة تجميد التطبيقات المخزَّنة مؤقتًا
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
يتوافق نظام التشغيل Android 11 QPR3 أو الإصدارات الأحدث مع أداة "تجميد" التطبيقات المخزّنة مؤقتًا. تعمل هذه الميزة على إيقاف تنفيذ العمليات المخزَّنة مؤقتًا وتقليل استخدام موارد
التطبيقات التي تُظهر سلوكًا غير مرغوب فيه والتي قد تحاول العمل أثناء الاحتفاظ بها في ذاكرة التخزين المؤقت. يُجمِّد الإطار التطبيقات المخزّنة مؤقتًا عن طريق نقل عملياتها إلى مجموعة cgroup مجمّدة، ويؤدي ذلك إلى تقليل استهلاك وحدة المعالجة المركزية (CPU) النشطة وغير النشطة في حال توفّر تطبيقات نشطة مخزّنة مؤقتًا.
يمكن تفعيل أداة تجميد التطبيقات باستخدام علامة إعدادات النظام أو خيار المطوِّر.
استخدام أداة تجميد التطبيقات
يستفيد برنامج تجميد التطبيقات المخزّنة مؤقتًا من أداة تجميد cgroup v2 للنواة. يمكن للأجهزة التي يتم شحنها
مزوّدة بنظام تشغيل متوافق تفعيل هذه الميزة (اختياريًا). لإجراء ذلك، فعِّل خيار المطوّر "تعليق تنفيذ التطبيقات المخزّنة مؤقتًا في ذاكرة التخزين" أو اضبط علامة إعدادات الجهاز activity_manager_native_boot use_freezer
على true
. مثلاً:
adb shell device_config put activity_manager_native_boot use_freezer true && adb reboot
يتم إيقاف وضع "التجميد" عند ضبط العلامة use_freezer
على "خطأ" أو عند إيقاف خيار
المطوّر. يمكنك تفعيل هذا الإعداد أو إيقافه من خلال تغيير أحد إعدادات الجهاز في إصدار أو تحديث للبرامج.
لا يعرِض "مجمِّد التطبيقات" واجهات برمجة التطبيقات الرسمية (ولا يتضمّن مرجعًا
لتطبيق العميل)، ولكنه يستخدم واجهات برمجة تطبيقات النظام المخفية setProcessFrozen
وenableFreezer
. لمعرفة تفاصيل عن واجهات برمجة التطبيقات هذه، يُرجى الرجوع إلى ActivityManager's
Process.java
وActivityManagerService API. يمكن للمطوّرين أيضًا الرجوع إلى
رمز العميل في ActivityManager
للاطّلاع على التجارب.
التعامل مع الميزات المخصّصة
لا يُتوقّع عادةً أن تُجري العمليات أيّ عمل عند تخزينها مؤقتًا، ولكن قد تتضمّن بعض التطبيقات
ميزات مخصّصة تتطلّب عمليات يُتوقّع أن يتم تشغيلها أثناء
التخزين المؤقت. عند تفعيل أداة تجميد التطبيقات على جهاز يعمل بتطبيق مماثل، يتم تجميد
العمليات المخزّنة مؤقتًا وقد يؤدي ذلك إلى إيقاف الميزات المخصّصة.
كحل بديل، إذا كان التطبيق يتضمّن عملية تحتاج إلى تنفيذ أنشطة أثناء ملفها الشخصي في ذاكرة التخزين المؤقت، يمكنك تغيير حالة العملية إلى "غير محفوظة في ذاكرة التخزين المؤقت" (مثل Bound ForeGround
Service (BFGS) أو المقدّمة) قبل أن تحتاج العملية إلى تنفيذ أي عمل للسماح
للتطبيق بالبقاء نشطًا.
اختبار أداة تجميد التطبيقات
للتأكّد من أنّ أداة تجميد التطبيقات تعمل على النحو المطلوب، يمكنك استخدام المراجع التالية:
ابحث عن قائمة بالعمليات المتوقفة باستخدام الأمر adb shell dumpsys activity
وgrep للبحث عن Apps frozen:
.
تحقّق من توفّر ملف /sys/fs/cgroup/uid_0/cgroup.freeze
.
يمكنك عرض logcat الذي يعرض الإدخالات المجمّدة وغير المجمّدة في كل مرة تتم فيها نقل عملية
إلى أو من "المجمّر". مثلاً:
adb logcat | grep -i "\(freezing\|froze\)"
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ 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,["# Cached apps freezer\n\nAndroid 11 QPR3 or higher supports the cached apps\nfreezer. This feature stops execution for cached processes and reduces resource\nusage by misbehaving apps that might attempt to operate while cached. The\nframework freezes cached apps by migrating their processes into a frozen cgroup;\nthis reduces active and idle CPU consumption in presence of active cached apps.\nThe app freezer can be enabled using a system configuration flag or a developer\noption.\n\nImplement the apps freezer\n--------------------------\n\nThe cached apps freezer leverages the kernel cgroup v2 freezer. Devices shipping\nwith a compatible kernel can (optionally) enable it. To do so, enable the\ndeveloper option \"Suspend execution for cached apps\" or set the device config\nflag `activity_manager_native_boot use_freezer` to `true`. For example: \n\n adb shell device_config put activity_manager_native_boot use_freezer true && adb reboot\n\nThe freezer is disabled when the flag `use_freezer` is set to false or the\ndeveloper option is disabled. You can toggle this setting by changing a device\nconfiguration in a software release or update.\n\nThe apps freezer doesn't expose official APIs (and doesn't have a reference\nimplementation client), but does use the hidden system APIs `setProcessFrozen`\nand `enableFreezer`. For details on these APIs, refer to ActivityManager's\n`Process.java` and the ActivityManagerService API. Developers can also refer to\nthe client code in `ActivityManager` for experiments.\n\nHandle custom features\n----------------------\n\nTypically, processes aren't expected to do any work when cached, but some apps\nmight have custom features supported by processes that are expected to run while\ncached. When the apps freezer is enabled on a device running such an app, the\ncached processes are frozen and might prevent custom features from working.\n\nAs a workaround, if an app has a process that needs to perform activities while\ncached, change the process status to non-cached (such as Bound ForeGround\nService (BFGS) or foreground) before the process needs to do any work to allow\nthe app to remain active.\n\nTest the apps freezer\n---------------------\n\nTo verify the app freezer is working as intended, use the following resources:\n\n- Check for a list of frozen processes using the `adb shell dumpsys activity`\n command and grep for `Apps frozen:`.\n\n- Check for the presence of the `/sys/fs/cgroup/uid_0/cgroup.freeze` file.\n\n- View logcat, which shows frozen and unfrozen entries each time a process\n migrates in or out of the freezer. For example:\n\n adb logcat | grep -i \"\\(freezing\\|froze\\)\""]]