تغييرات السلوك: جميع التطبيقات

يتضمّن نظام التشغيل Android 16 تغييرات في السلوك قد تؤثر في تطبيقك. تنطبق تغييرات السلوك التالية على جميع التطبيقات عند تشغيلها على Android 16، بغض النظر عن targetSdkVersion. يجب اختبار تطبيقك ثم تعديله حسب الحاجة لتتوافق مع هذه التغييرات، حيثما ينطبق ذلك.

احرص أيضًا على مراجعة قائمة التغييرات في السلوك التي تؤثر فقط في التطبيقات التي تستهدف الإصدار 16 من Android.

الوظيفة الأساسية

يتضمّن الإصدار Android 16 (المستوى 36 من واجهة برمجة التطبيقات) التغييرات التالية التي تعدّل أو توسّع الإمكانات الأساسية المختلفة لنظام Android.

تحسينات الحصة في JobScheduler

Starting in Android 16, we're adjusting regular and expedited job execution runtime quota based on the following factors:

  • Which app standby bucket the application is in: in Android 16, active standby buckets will start being enforced by a generous runtime quota.
  • If the job starts execution while the app is in a top state: in Android 16, Jobs started while the app is visible to the user and continues after the app becomes invisible, will adhere to the job runtime quota.
  • If the job is executing while running a Foreground Service: in Android 16, jobs that are executing while concurrently with a foreground service will adhere to the job runtime quota. If you're leveraging jobs for user initiated data transfer, consider using user initiated data transfer jobs instead.

This change impacts tasks scheduled using WorkManager, JobScheduler, and DownloadManager. To debug why a job was stopped, we recommend logging why your job was stopped by calling WorkInfo.getStopReason() (for JobScheduler jobs, call JobParameters.getStopReason()).

For more information on battery-optimal best practices, refer to guidance on optimize battery use for task scheduling APIs.

We also recommend leveraging the new JobScheduler#getPendingJobReasonsHistory API introduced in Android 16 to understand why a job has not executed.

Testing

To test your app's behavior, you can enable override of certain job quota optimizations as long as the app is running on an Android 16 device.

To disable enforcement of "top state will adhere to job runtime quota", run the following adb command:

adb shell am compat enable OVERRIDE_QUOTA_ENFORCEMENT_TO_TOP_STARTED_JOBS APP_PACKAGE_NAME

To disable enforcement of "jobs that are executing while concurrently with a foreground service will adhere to the job runtime quota", run the following adb command:

adb shell am compat enable OVERRIDE_QUOTA_ENFORCEMENT_TO_FGS_JOBS APP_PACKAGE_NAME

To test certain app standby bucket behavior, you can set the app standby bucket of your app using the following adb command:

adb shell am set-standby-bucket APP_PACKAGE_NAME active|working_set|frequent|rare|restricted

To understand the app standby bucket your app is in, you can get the app standby bucket of your app using the following adb command:

adb shell am get-standby-bucket APP_PACKAGE_NAME

سبب إيقاف المهام الفارغة المهجورة

تحدث المهمة المهجورة عندما يتم جمع المهملات من عنصر JobParameters المرتبط بالمهمة ، ولكن لم يتم استدعاء JobService#jobFinished(JobParameters, boolean) للإشارة إلى اكتمال المهمة. يشير ذلك إلى أنّه قد يكون المهام قيد التشغيل ويتم إعادة جدولتها بدون علم التطبيق.

لا تحافظ التطبيقات التي تعتمد على JobScheduler على إشارة قوية إلى ملف برمجي JobParameters، وسيتم الآن منح مهلة سبب إيقاف المهمة الجديد STOP_REASON_TIMEOUT_ABANDONED بدلاً من STOP_REASON_TIMEOUT.

إذا تكرّر سبب الإيقاف الجديد، سيتّخذ النظام خطوات لتخفيف المشكلة من خلال تقليل تكرار المهام.

على التطبيقات استخدام سبب الإيقاف الجديد لرصد المهام المتوقفة عن العمل والحدّ منها.

إذا كنت تستخدم WorkManager أو AsyncTask أو DownloadManager، لن تتأثر بهذه التغييرات، لأنّ واجهات برمجة التطبيقات هذه تدير دورة حياة المهام نيابةً عن تطبيقك.

إيقاف الإصدار القديم من JobInfo#setImportantWhileForeground نهائيًا

تشير طريقة JobInfo.Builder#setImportantWhileForeground(boolean) إلى أهمية إحدى المهام عندما يكون تطبيق تحديد الموعد في المقدّمة أو عندما يتم إعفاؤه مؤقتًا من القيود المفروضة على التطبيقات التي تعمل في الخلفية.

تم إيقاف هذه الطريقة نهائيًا منذ الإصدار 12 من Android (المستوى 31 لواجهة برمجة التطبيقات). اعتبارًا من الإصدار Android 16، لم تعُد هذه الطريقة تعمل بفعالية، وسيتم تجاهل استدعاء هذه الطريقة.

تنطبق إزالة هذه الوظيفة أيضًا على JobInfo#isImportantWhileForeground(). بدءًا من الإصدار Android 16، إذا تم استدعاء الطريقة، ستُرجع الطريقة false.

لم يعُد نطاق أولوية البث المجدوَل عالميًا.

Android apps are allowed to define priorities on broadcast receivers to control the order in which the receivers receive and process the broadcast. For manifest-declared receivers, apps can use the android:priority attribute to define the priority and for context-registered receivers, apps can use the IntentFilter#setPriority() API to define the priority. When a broadcast is sent, the system delivers it to receivers in order of their priority, from highest to lowest.

In Android 16, broadcast delivery order using the android:priority attribute or IntentFilter#setPriority() across different processes will not be guaranteed. Broadcast priorities will only be respected within the same application process rather than across all processes.

Also, broadcast priorities will be automatically confined to the range (SYSTEM_LOW_PRIORITY + 1, SYSTEM_HIGH_PRIORITY - 1). Only system components will be allowed to set SYSTEM_LOW_PRIORITY, SYSTEM_HIGH_PRIORITY as broadcast priority.

Your app might be impacted if it does either of the following:

  1. Your application has declared multiple processes with the same broadcast intent, and has expectations around receiving those intents in a certain order based on the priority.
  2. Your application process interacts with other processes and has expectations around receiving a broadcast intent in a certain order.

If the processes need to coordinate with each other, they should communicate using other coordination channels.

التغييرات الداخلية في ART

Android 16 includes the latest updates to the Android Runtime (ART) that improve the Android Runtime's (ART's) performance and provide support for additional Java features. Through Google Play System updates, these improvements are also available to over a billion devices running Android 12 (API level 31) and higher.

As these changes are released, libraries and app code that rely on internal structures of ART might not work correctly on devices running Android 16, along with earlier Android versions that update the ART module through Google Play system updates.

Relying on internal structures (such as non-SDK interfaces) can always lead to compatibility problems, but it's particularly important to avoid relying on code (or libraries containing code) that leverages internal ART structures, since ART changes aren't tied to the platform version the device is running on and they go out to over a billion devices through Google Play system updates.

All developers should check whether their app is impacted by testing their apps thoroughly on Android 16. In addition, check the known issues to see if your app depends on any libraries that we've identified that rely on internal ART structures. If you do have app code or library dependencies that are affected, seek public API alternatives whenever possible and request public APIs for new use cases by creating a feature request in our issue tracker.

وضع التوافق مع حجم الصفحة البالغ 16 كيلوبايت

Android 15 introduced support for 16 KB memory pages to optimize performance of the platform. Android 16 adds a compatibility mode, allowing some apps built for 4 KB memory pages to run on a device configured for 16 KB memory pages.

When your app is running on a device with Android 16 or higher, if Android detects that your app has 4 KB aligned memory pages, it automatically uses compatibility mode and display a notification dialog to the user. Setting the android:pageSizeCompat property in the AndroidManifest.xml to enable the backwards compatibility mode will prevent the display of the dialog when your app launches. To use the android:pageSizeCompat property, compile your app using the Android 16 SDK.

For best performance, reliability, and stability, your app should still be 16 KB aligned. Check out our recent blog post on updating your apps to support 16 KB memory pages for more details.

The compatibility mode dialog that displays when the system detects that a 4 KB-aligned app could run more optimally if 16 KB aligned.

تجربة المستخدم وواجهة المستخدم للنظام

يتضمّن الإصدار Android 16 (المستوى 36 من واجهة برمجة التطبيقات) التغييرات التالية التي تهدف إلى توفير تجربة استخدام أكثر اتساقًا وسهولة.

إيقاف نهائي لإعلانات تسهيل الاستخدام المزعجة

يوقف نظام التشغيل Android 16 نهائيًا إعلانات تسهيل الاستخدام التي تتميز باستخدام announceForAccessibility أو إرسال TYPE_ANNOUNCEMENT أحداث تسهيل الاستخدام. ويمكن أن تؤدي هذه العناصر إلى اختلاف تجربتَي المستخدمين في TalkBack وقارئ شاشة Android، وتعمل العناصر البديلة بشكل أفضل على تلبية مجموعة أوسع من احتياجات المستخدمين في مجموعة متنوعة من التكنولوجيات المساعِدة في Android.

أمثلة على الحلول البديلة:

تتضمّن المستندات المرجعية لواجهة برمجة التطبيقات announceForAccessibility المتوقّفة نهائيًا مزيدًا من التفاصيل حول البدائل المقترَحة.

إتاحة وضع "التنقّل باستخدام ثلاثة أزرار"

Android 16 brings predictive back support to the 3-button navigation for apps that have properly migrated to predictive back. Long-pressing the back button initiates a predictive back animation, giving you a preview of where the back swipe takes you.

This behavior applies across all areas of the system that support predictive back animations, including the system animations (back-to-home, cross-task, and cross-activity).

The predictive back animations in 3-button navigation mode.

أشكال الأجهزة

يتضمّن الإصدار Android 16 (المستوى 36 من واجهة برمجة التطبيقات) التغييرات التالية على التطبيقات عند عرضها على الشاشات من قِبل مالكي الأجهزة الافتراضية.

عمليات إلغاء مالك الجهاز الافتراضي

مالك الجهاز الافتراضي هو تطبيق موثوق به أو مميّز ينشئ ويدير جهازًا افتراضيًا. يشغِّل مالكو الأجهزة الافتراضية التطبيقات على جهاز افتراضي ثم يُعرِضون التطبيقات على شاشة جهاز بعيد، مثل كمبيوتر شخصي أو جهاز واقع افتراضي أو نظام معلومات ترفيهية في السيارة. يكون مالك الجهاز الافتراضي على جهاز محلي، مثل هاتف جوّال.

ينشئ مالك الجهاز الافتراضي على الهاتف جهازًا افتراضيًا يعرض التطبيق على الشاشة البعيدة.

عمليات إلغاء الإعدادات لكل تطبيق

على الأجهزة التي تعمل بإصدار Android 16 (المستوى 36 لواجهة برمجة التطبيقات)، يمكن لمالكي الأجهزة الافتراضية تجاوز إعدادات التطبيقات على أجهزة افتراضية محدّدة يديرها أصحاب الأجهزة الافتراضية. على سبيل المثال، لتحسين تنسيق التطبيق، يمكن لمالك الجهاز الافتراضي تجاهل القيود المفروضة على الاتجاه ونسبة العرض إلى الارتفاع وإمكانية تغيير الحجم عند بث التطبيقات على شاشة خارجية.

التغييرات الشائعة التي قد تؤدي إلى حدوث أعطال

قد يؤثر سلوك Android 16 في واجهة مستخدم تطبيقك على شاشات كبيرة، مثل شاشات السيارات أو أجهزة Chromebook، خاصةً التنسيقات التي تم تصميمها للشاشات الصغيرة في الوضع العمودي. للتعرّف على كيفية جعل تطبيقك متوافقًا مع جميع أشكال الأجهزة، اطّلِع على لمحة عن التنسيقات المتوافقة.

المراجع

بث التطبيقات المصاحبة

الأمان

يتضمّن الإصدار 16 من Android (المستوى 36 لواجهة برمجة التطبيقات) تغييرات تعزّز أمان النظام بهدف المساعدة في حماية التطبيقات والمستخدمين من التطبيقات الضارّة.

أمان محسّن ضد هجمات إعادة التوجيه المستندة إلى الأهداف

يقدّم نظام التشغيل Android 16 أمانًا تلقائيًا ضد هجمات إعادة التوجيه العامةIntent، مع الحد الأدنى من التوافق والتغييرات المطلوبة للمطوّرين.

نحن بصدد تقديم حلول تحصين الأمان بشكل تلقائي لمنع Intent استغلال عمليات إعادة التوجيه. في معظم الحالات، لن تواجه التطبيقات التي تستخدم النوايا عادةً أي مشاكل في التوافق. لقد جمعنا المقاييس طوال عملية تطوير التطبيقات بهدف رصد التطبيقات التي قد تواجه مشاكل.

تحدث إعادة توجيه Intent في Android عندما يتمكّن المهاجم من التحكّم جزئيًا أو كليًا في محتوى Intent المستخدَم لإطلاق مكوّن جديد في سياق تطبيق معرّض للاختراق، بينما يطلق التطبيق المستهدف Intent من المستوى الفرعي غير الموثوق فيه في حقل التطبيقات الإضافية ("Intent من المستوى الأعلى"). يمكن أن يؤدي ذلك إلى قيام تطبيق المهاجم بتشغيل مكوّنات خاصة في سياق التطبيق المستهدف، أو بدء إجراءات مميّزة، أو الحصول على إذن الوصول إلى عناوين URI للوصول إلى البيانات الحسّاسة، مما قد يؤدي بدوره إلى سرقة البيانات وتنفيذ رموز برمجية عشوائية.

إيقاف معالجة إعادة التوجيه المستندة إلى النية

يقدّم نظام التشغيل Android 16 واجهة برمجة تطبيقات جديدة تتيح للتطبيقات إيقاف ميزات أمان الإطلاق. قد يكون ذلك ضروريًا في حالات معيّنة يتداخل فيها سلوك أمان الإعدادات التلقائية مع حالات الاستخدام المشروعة للتطبيق.

بالنسبة إلى التطبيقات التي يتم تجميعها باستخدام حزمة تطوير البرامج (SDK) لنظام التشغيل Android 16 (المستوى 36 لواجهة برمجة التطبيقات) أو إصدار أحدث

يمكنك استخدام الطريقة removeLaunchSecurityProtection() مباشرةً في عنصر Intent.

val i = intent
val iSublevel: Intent? = i.getParcelableExtra("sub_intent")
iSublevel?.removeLaunchSecurityProtection() // Opt out from hardening
iSublevel?.let { startActivity(it) }
بالنسبة إلى التطبيقات التي يتم تجميعها لنظام التشغيل Android 15 (المستوى 35 لواجهة برمجة التطبيقات) أو الإصدارات الأقدم

على الرغم من أنّه لا يُنصح بذلك، يمكنك استخدام ميزة "العرض" للوصول إلى الطريقة removeLaunchSecurityProtection().

val i = intent
val iSublevel: Intent? = i.getParcelableExtra("sub_intent", Intent::class.java)
try {
    val removeLaunchSecurityProtection = Intent::class.java.getDeclaredMethod("removeLaunchSecurityProtection")
    removeLaunchSecurityProtection.invoke(iSublevel)
} catch (e: Exception) {
    // Handle the exception, e.g., log it
} // Opt-out from the security hardening using reflection
iSublevel?.let { startActivity(it) }

إمكانية الاتصال

يتضمّن الإصدار 16 من Android (المستوى 36 من واجهة برمجة التطبيقات) التغييرات التالية في حِزمة البلوتوث لتحسين إمكانية الاتصال بالأجهزة الطرفية.

معالجة محسّنة لخسارة الضمان

بدءًا من Android 16، تم تعديل حِزمة البلوتوث لتحسين الأمان وتجربة المستخدم عند رصد فقدان الربط عن بُعد. في السابق، كان النظام يزيل الربط تلقائيًا ويُطلق عملية إقران جديدة، ما قد يؤدي إلى إعادة إقران غير مقصودة. لقد لاحظنا في العديد من الحالات أنّ التطبيقات لا تهتم بحدث فقدان الارتباط بطريقة متّسقة.

لتوحيد التجربة، حسّن نظام التشغيل Android 16 معالجة فقدان الربط في النظام. إذا تعذّر مصادقة جهاز بلوتوث سبق ربطه عند إعادة الربط، سيقطع النظام الرابط ويحتفظ بمعلومات الربط المحلية ويعرض مربّع حوار للنظام يُعلم المستخدمين بفقدان الربط ويوجّههم إلى إعادة الإقران.