يتضمّن الإصدار 17 من نظام التشغيل Android تغييرات في السلوك قد تؤثّر في تطبيقك.
تنطبق تغييرات السلوك التالية على جميع التطبيقات عند تشغيلها على الإصدار 17 من نظام التشغيل Android،
بغض النظر عن targetSdkVersion. عليك اختبار تطبيقك ثم تعديله حسب الحاجة ليتوافق مع هذه التغييرات، حيثما ينطبق ذلك.
احرص أيضًا على مراجعة قائمة التغييرات في السلوك التي تؤثّر فقط في التطبيقات التي تستهدف الإصدار 17 من نظام التشغيل Android.
الوظيفة الأساسية
يتضمّن نظام التشغيل Android 17 (المستوى 37 لواجهة برمجة التطبيقات) التغييرات التالية التي تعدّل أو توسّع العديد من الإمكانات الأساسية لنظام Android.
الحدود القصوى لذاكرة التطبيقات
Android 17 introduces app memory limits based on the device's total RAM to create a more stable and deterministic environment for your apps and Android users. These limits focus on memory leaks and other outliers before they trigger system-wide instability resulting in UI stuttering, higher battery drain, and apps being killed. While we anticipate minimal impact on the vast majority of app sessions, we recommend the following memory best practices, including establishing a baseline for memory.
You can determine if your app session was impacted by calling
getDescription in ApplicationExitInfo; if your app was
affected, the exit reason will be REASON_OTHER and
the description will contain the string "MemoryLimiter:AnonSwap" along with
other information. You can also use trigger-based profiling with
TRIGGER_TYPE_ANOMALY to get heap dumps that are collected when the
memory limit is hit.
The Manage your app's memory documentation gives information to help you diagnose your app's memory issues and optimize its resource consumption.
Test your app's behavior under the memory constraints
You can use Android Debug Bridge (adb) to adjust or disable the
memory limits on any device that imposes them. The shell command am
provides three subcommands to adjust the memory limits. (These commands have
no effect on a device which does not impose memory limits.)
am memory-limiter ignore <uid>|none|allam memory-limiter manual <pid> <limit>|max|noneam memory-limiter status
ignoreInstructs the memory limiter to ignore some or all processes. Passing a UID (Android User ID) instructs the memory limiter to ignore enforcement on all processes associated with that UID. You can also pass
all(ignore all apps) ornone(do not ignore any apps). Passingnoneoverrides any previous calls toam memory-limiter ignore.If you instruct the memory limiter to ignore a UID, you can still apply a manual memory limit to a process within the app by calling
am memory-limiter manual.manualInstructs the system to impose a memory constraint on the process with the specified PID (Process ID). The memory constraint is specified as an integer number of MB; for example, passing
30specifies that the process is limited to 30 MB of memory. Passingmaxremoves all memory limits on that process. Passingnoneremoves any manual limits set on the process, restoring the system's default limit (if any).statusReports the current status of the memory limiter. The status includes the memory limits imposed on visible and non-visible processes.
الخصوصية
يتضمّن نظام التشغيل Android 17 التغييرات التالية لتحسين خصوصية المستخدم.
الحماية من خلال كلمة المرور الصالحة لمرة واحدة (OTP) عبر الرسائل القصيرة
Beginning with Android 17, Android is expanding its protection for SMS messages containing one-time passwords (OTP).
In previous versions of Android, this protection was primarily focused on the SMS Retriever format. Delivery of messages containing an SMS retriever hash was delayed for most apps for three hours. However, certain apps (like the default SMS handler) were exempt from the delay, and the app that owned the hash was also exempted.
Beginning with Android 17, the protection is also applied to WebOTP format messages. If an app has permission to read SMS messages but is not the intended recipient of a WebOTP message (as determined by domain verification), the message is not accessible to the app until three hours after the message's receipt. This change is intended to improve user security by ensuring that only apps associated with the domain mentioned in the message can programmatically read the verification code.
During this three hour delay, the SMS_RECEIVED_ACTION broadcast is
withheld and SMS provider database queries are filtered. The
SMS message is available to these apps after the delay. This change applies to
all apps, regardless of their target API level.
Certain apps such as the default SMS assistant app, connected device companion apps, etc., are exempted from this delay. All apps that rely on reading SMS messages for OTP extraction should transition to using SMS Retriever or SMS User Consent APIs to ensure continued functionality.
الأمان
يتضمّن نظام التشغيل Android 17 التحسينات التالية على أمان الأجهزة والتطبيقات.
خطة إيقاف usesClearTraffic نهائيًا
في إصدار مستقبلي، نخطّط لإيقاف نهائي للعنصر usesCleartextTraffic.
على التطبيقات التي تحتاج إلى إجراء اتصالات غير مشفّرة (HTTP) الانتقال إلى استخدام ملف إعداد أمان الشبكة، ما يتيح لك تحديد النطاقات التي يحتاج تطبيقك إلى إجراء اتصالات نص عادي بها.
يُرجى العِلم أنّ ملفات إعداد أمان الشبكة لا تتوفّر إلا على مستويات واجهة برمجة التطبيقات 24 والإصدارات الأحدث. إذا كان الحد الأدنى لمستوى واجهة برمجة التطبيقات في تطبيقك أقل من 24، عليك تنفيذ كلا الإجراءَين التاليَين:
- ضبط السمة
usesCleartextTrafficعلىtrue - استخدام ملف إعداد الشبكة
إذا كان الحد الأدنى لمستوى واجهة برمجة التطبيقات في تطبيقك هو 24 أو أعلى، يمكنك استخدام ملف إعداد الشبكة وليس عليك ضبط usesCleartextTraffic.
حظر منح أذونات ضمنية لمعرّف الموارد المنتظم (URI)
في الوقت الحالي، إذا أطلق تطبيق غرضًا باستخدام معرّف موارد منتظم (URI) يتضمّن الإجراء ACTION_SEND أو ACTION_SEND_MULTIPLE أو ACTION_IMAGE_CAPTURE، يمنح النظام تلقائيًا أذونات القراءة والكتابة لمعرّف الموارد المنتظم (URI) إلى التطبيق المستهدف. بدءًا من الإصدار 18 من نظام التشغيل Android، لن يمنح النظام هذه الأذونات تلقائيًا. لهذا السبب، ننصح بأن تمنح التطبيقات بشكل صريح أذونات عناوين URI ذات الصلة بدلاً من الاعتماد على النظام لمنحها.
لرصد استخدام هذه الـ intents في تطبيقك، استخدِم StrictMode مع
detectImplicitUriPermissionGrant() لتشغيل مخالفة:
Kotlin
val policy = StrictMode.VmPolicy.Builder() .detectImplicitUriPermissionGrant() .penaltyLog() .build() StrictMode.setVmPolicy(policy)
Java
StrictMode.VmPolicy policy = new StrictMode.VmPolicy.Builder() .detectImplicitUriPermissionGrant() .penaltyLog() .build(); StrictMode.setVmPolicy(policy);
بدلاً من ذلك، يمكنك مراقبة الاستثناءات المسجّلة التي تتضمّن الرسالة
Please set the grant explicitly in the app التي تظهر عندما يضبط النظام الإذن ضمنيًا. يمكنك مراقبة هذه السجلات باستخدام الأمر adb التالي:
adb logcat | grep "Please set the grant explicitly in the app"
لمنح الأذونات اللازمة بشكل صريح، أضِف العلامة
FLAG_GRANT_READ_URI_PERMISSION إلى الغرضين ACTION_SEND وACTION_SEND_MULTIPLE:
Kotlin
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
Java
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
تضمين كل من علامتَي FLAG_GRANT_READ_URI_PERMISSION وFLAG_GRANT_WRITE_URI_PERMISSION للغرض ACTION_IMAGE_CAPTURE:
Kotlin
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
Java
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
الحدود القصوى لمخزن مفاتيح كل تطبيق
Apps should avoid creating excessive numbers of keys in Android Keystore, because it is a shared resource for all apps on the device. Beginning with Android 17, the system enforces a limit on the number of keys an app can own. The limit is 50,000 keys for non-system apps targeting Android 17 (API level 37) or higher, and 200,000 keys for all other apps. System apps have a limit of 200,000 keys, regardless of which API level they target.
If an app attempts to create keys beyond the limit, the creation fails with a
KeyStoreException. The exception's message string contains information
about the key limit. If the app calls getNumericErrorCode() on the
exception, the return value depends on what API level the app targets:
- Apps targeting Android 17 (API level 37) or higher:
getNumericErrorCode()returns the newERROR_TOO_MANY_KEYSvalue. - All other apps:
getNumericErrorCode()returnsERROR_INCORRECT_USAGE.
حظر الزيارات المكرّرة بين الملفات الشخصية
从 Android 17 开始,默认情况下不再允许跨个人资料环回流量。同一个人资料内的环回流量不受影响。 此项变更适用于在 Android 17 或更高版本上运行的所有应用,无论应用以哪个 API 级别为目标平台。
تجربة المستخدم وواجهة مستخدم النظام
يتضمّن نظام التشغيل Android 17 التغييرات التالية التي تهدف إلى توفير تجربة استخدام أكثر سلاسةً وسهولةً.
استعادة مستوى رؤية محرر أسلوب الإدخال التلقائي بعد التدوير
从 Android 17 开始,当设备的配置发生变化(例如,通过旋转)且应用本身未处理此变化时,系统不会恢复之前的 IME 可见性。
如果应用经历了它无法处理的配置更改,并且应用需要在更改后显示键盘,您必须明确请求此行为。您可以通过以下方式之一提出此要求:
- 将
android:windowSoftInputMode属性设置为stateAlwaysVisible。 - 在 activity 的
onCreate()方法中以编程方式请求显示软键盘,或添加onConfigurationChanged()方法。
المعلومات المقدَّمة
يتضمّن نظام التشغيل Android 17 التغييرات التالية التي تؤثّر في طريقة تفاعل التطبيقات مع أجهزة الإدخال البشرية، مثل لوحات المفاتيح ولوحات اللمس.
تقدّم لوحات اللمس أحداثًا نسبية تلقائيًا أثناء عملية التقاط المؤشر
بدءًا من Android 17، إذا طلب تطبيق التقاط المؤشر باستخدام
View.requestPointerCapture() واستخدم المستخدم لوحة لمس، سيتعرّف النظام على
حركة المؤشر وإيماءات التمرير التي يجريها المستخدم
ويُبلغ التطبيق بها بالطريقة نفسها التي يتم بها الإبلاغ عن حركات المؤشر وعجلة التمرير
من خلال فأرة تم التقاطها. في معظم الحالات، يؤدي ذلك إلى إزالة الحاجة إلى أن تضيف التطبيقات التي تتوافق مع المؤشرات التي تم التقاطها منطق معالجة خاصًا بلوحات اللمس. لمزيد من التفاصيل، يُرجى الاطّلاع على مستندات View.POINTER_CAPTURE_MODE_RELATIVE.
في السابق، لم يكن النظام يحاول التعرّف على الإيماءات من لوحة اللمس، بل كان يرسل إلى التطبيق المواقع الجغرافية المطلقة للأصابع بتنسيق مشابه للمس الشاشة. إذا كان أحد التطبيقات لا يزال يتطلّب هذه البيانات المطلقة، عليه استدعاء طريقة View.requestPointerCapture(int) الجديدة مع View.POINTER_CAPTURE_MODE_ABSOLUTE بدلاً من ذلك.
الوسائط
يتضمّن نظام التشغيل Android 17 التغييرات التالية على سلوك الوسائط.
تعزيز أمان الصوت في الخلفية
اعتبارًا من Android 17، يفرض إطار عمل الصوت قيودًا على التفاعلات الصوتية في الخلفية، بما في ذلك تشغيل الصوت وطلبات أولوية الصوت وواجهات برمجة التطبيقات لتغيير مستوى الصوت، وذلك لضمان أن يبدأ المستخدم هذه التغييرات عن قصد.
إذا حاول التطبيق استدعاء واجهات برمجة التطبيقات الصوتية أثناء عدم توفّره في مراحل نشاط صالحة، ستتعذّر واجهات برمجة التطبيقات لتشغيل الصوت وتغيير مستوى الصوت بدون إظهار استثناء أو تقديم رسالة خطأ. تفشل واجهة برمجة التطبيقات لأولوية الصوت مع رمز النتيجة AUDIOFOCUS_REQUEST_FAILED.
لمزيد من المعلومات، بما في ذلك استراتيجيات التخفيف، يُرجى الاطّلاع على مقالة تعزيز أمان الصوت في الخلفية.
إمكانية الاتصال
يتضمّن نظام التشغيل Android 17 التغييرات التالية لتحسين إمكانية ربط الأجهزة.
إعادة الإقران التلقائي عند فقدان ربط البلوتوث
يقدّم نظام التشغيل Android 17 ميزة إعادة الإقران الذاتي، وهي تحسين على مستوى النظام مصمَّم لحل مشكلة فقدان ربط البلوتوث تلقائيًا.
في السابق، إذا تم فقدان عملية الربط، كان على المستخدمين الانتقال يدويًا إلى "الإعدادات" لإلغاء الربط ثم إعادة ربط الجهاز الطرفي. تستند هذه الميزة إلى تحسين الأمان في Android 16 من خلال السماح للنظام بإعادة إنشاء عمليات الربط في الخلفية بدون أن يضطر المستخدمون إلى الانتقال يدويًا إلى "الإعدادات" لإلغاء ربط الأجهزة الطرفية وإعادة ربطها.
على الرغم من أنّ معظم التطبيقات لن تتطلّب تغييرات في الرموز البرمجية، على المطوّرين الانتباه إلى التغييرات التالية في سلوك حزمة Bluetooth:
- سياق الاقتران الجديد: يتضمّن
ACTION_PAIRING_REQUESTالآن الإضافةEXTRA_PAIRING_CONTEXTالتي تتيح للتطبيقات التمييز بين طلب اقتران عادي ومحاولة إعادة الاقتران التي يبدأها النظام المستقل. - تحديثات المفاتيح الشرطية: لن يتم استبدال مفاتيح الأمان الحالية إلا إذا تم إعادة الربط بنجاح وكان الاتصال الجديد يستوفي مستوى الأمان المطلوب أو يتجاوزه.
- تعديل توقيت الغرض: لن يتم بث الغرض
ACTION_KEY_MISSINGإلا إذا تعذّرت محاولة إعادة الاقتران التلقائي. يؤدي ذلك إلى تقليل معالجة الأخطاء غير الضرورية في التطبيق إذا استعاد النظام عملية الربط بنجاح في الخلفية. - إشعار المستخدم: يدير النظام عملية إعادة الاقتران من خلال إشعارات واجهة المستخدم الجديدة ومربّعات الحوار. سيُطلب من المستخدمين تأكيد محاولة إعادة الربط للتأكّد من أنّهم على علم بعملية إعادة الاتصال.
على الشركات المصنّعة للأجهزة الطرفية ومطوّري التطبيقات المصاحبة التأكّد من أنّ الأجهزة والمعدّات والتطبيقات تتعامل بسلاسة مع عمليات انتقال الربط. لاختبار هذا السلوك، يمكنك محاكاة فقدان الربط عن بُعد باستخدام إحدى الطريقتَين التاليتَين:
- إزالة معلومات الربط يدويًا من الجهاز الطرفي
- إلغاء إقران الجهاز يدويًا من خلال: الإعدادات > الأجهزة المتصلة