La plate-forme Android 17 apporte des modifications de comportement susceptibles d'affecter votre application.
Les modifications de comportement suivantes s'appliquent à toutes les applications lorsqu'elles s'exécutent sur Android 17,
peu importe la targetSdkVersion. Vous devez tester votre application, puis la modifier si nécessaire afin de prendre en charge ces modifications, le cas échéant.
Veillez également à consulter la liste des modifications de comportement qui n'affectent que les applications ciblant Android 17.
Fonctionnalité de base
Android 17 (niveau d'API 37) inclut les modifications suivantes qui modifient ou étendent diverses fonctionnalités de base du système Android.
Limites de mémoire des applications
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. In Android 17, limits are set conservatively to establish system baselines, targeting extreme 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.
Confidentialité
Android 17 inclut les modifications suivantes pour améliorer la confidentialité des utilisateurs.
Protection des codes secrets à usage unique par SMS
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.
Sécurité
Android 17 inclut les améliorations suivantes pour la sécurité des appareils et des applications.
Plan d'abandon de usesClearTraffic
Dans une prochaine version, nous prévoyons d'abandonner l'élément usesCleartextTraffic.
Les applications qui doivent établir des connexions non chiffrées (HTTP) doivent migrer vers l'utilisation d'un fichier de configuration de la sécurité réseau, qui vous permet de spécifier les domaines auxquels votre application doit établir des connexions en texte clair.
Notez que les fichiers de configuration de la sécurité réseau ne sont compatibles qu'avec le niveau d'API 24 et les niveaux supérieurs. Si le niveau d'API minimal de votre application est inférieur à 24, vous devez effectuer les deux actions suivantes :
- Définissez l'attribut
usesCleartextTrafficsurtrue. - Utiliser un fichier de configuration réseau
Si le niveau d'API minimal de votre application est de 24 ou plus, vous pouvez utiliser un fichier de configuration réseau et vous n'avez pas besoin de définir usesCleartextTraffic.
Restreindre les autorisations d'URI implicites
Actuellement, si une application lance un intent avec un URI qui comporte l'action
ACTION_SEND, ACTION_SEND_MULTIPLE ou
ACTION_IMAGE_CAPTURE, le système accorde automatiquement les autorisations de lecture et
d'écriture de l'URI à l'application cible. À partir d'Android 18, le système n'accordera
plus automatiquement ces autorisations. C'est pourquoi nous vous recommandons d'accorder explicitement les autorisations d'URI pertinentes au lieu de laisser le système le faire.
Pour détecter l'utilisation de ces intents dans votre application, utilisez StrictMode avec
detectImplicitUriPermissionGrant() pour déclencher une violation :
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);
Vous pouvez également surveiller les exceptions enregistrées contenant le message Please set the grant explicitly in the app qui s'affiche lorsque le système définit implicitement l'autorisation. Vous pouvez surveiller ces journaux à l'aide de la commande adb suivante :
adb logcat | grep "Please set the grant explicitly in the app"
Pour accorder explicitement les autorisations nécessaires, ajoutez l'
FLAG_GRANT_READ_URI_PERMISSION aux intents ACTION_SEND et
ACTION_SEND_MULTIPLE :
Kotlin
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
Java
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
Incluez les options FLAG_GRANT_READ_URI_PERMISSION et
FLAG_GRANT_WRITE_URI_PERMISSION pour les
ACTION_IMAGE_CAPTURE intents :
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);
Limites de keystore par application
应用应避免在 Android 密钥库中创建过多的密钥,因为它是设备上所有应用的共享资源。从 Android 17 开始,系统会强制限制应用可拥有的密钥数量。对于以 Android 17(API 级别 37)或更高版本为目标平台的非系统应用,密钥数量上限为 50,000 个;对于所有其他应用,密钥数量上限为 200,000 个。无论系统应用以哪个 API 级别为目标,其密钥数量上限均为 20 万。
如果应用尝试创建超出限制的密钥,则创建会失败并显示 KeyStoreException。异常的消息字符串包含有关密钥限制的信息。如果应用针对异常调用 getNumericErrorCode(),则返回值取决于应用的目标 API 级别:
- 如果应用以 Android 17(API 级别 37)或更高版本为目标平台,
getNumericErrorCode()会返回新的ERROR_TOO_MANY_KEYS值。 - 所有其他应用:
getNumericErrorCode()返回ERROR_INCORRECT_USAGE。
Bloquer le trafic de bouclage entre profils
À partir d'Android 17, le trafic de bouclage entre profils n'est plus autorisé par défaut. Le trafic de bouclage au sein d'un même profil n'est pas affecté. Cette modification s'applique à toutes les applications exécutées sur Android 17 ou version ultérieure, quel que soit le niveau d'API ciblé par l'application.
Expérience utilisateur et UI du système
Android 17 inclut les modifications suivantes qui visent à créer une expérience utilisateur plus cohérente et intuitive.
Restaurer la visibilité de l'IME par défaut après une rotation
从 Android 17 开始,当设备的配置发生变化(例如,通过旋转)且应用本身未处理此变化时,系统不会恢复之前的 IME 可见性。
如果应用经历了它无法处理的配置更改,并且应用需要在更改后显示键盘,您必须明确请求此行为。您可以通过以下方式之一提出此要求:
- 将
android:windowSoftInputMode属性设置为stateAlwaysVisible。 - 在 activity 的
onCreate()方法中以编程方式请求显示软键盘,或添加onConfigurationChanged()方法。
Action humaine
Android 17 inclut les modifications suivantes qui affectent la façon dont les applications interagissent avec les appareils d'entrée humaine tels que les claviers et les pavés tactiles.
Les pavés tactiles fournissent des événements relatifs par défaut lors de la capture du pointeur
从 Android 17 开始,如果应用使用 View.requestPointerCapture() 请求捕获指针,并且用户使用触控板,系统会识别用户触摸操作产生的指针移动和滚动手势,并以与捕获的鼠标产生的指针和滚轮移动相同的方式将这些信息报告给应用。在大多数情况下,这使得支持捕获鼠标的应用无需为触控板添加特殊的处理逻辑。如需了解详情,请参阅 View.POINTER_CAPTURE_MODE_RELATIVE 的文档。
之前,系统不会尝试识别触控板的手势,而是以类似于触摸屏触摸的格式将原始的绝对手指位置传递给应用。如果应用仍需要此绝对数据,则应改为使用 View.POINTER_CAPTURE_MODE_ABSOLUTE 调用新的 View.requestPointerCapture(int) 方法。
Contenus multimédias
Android 17 inclut les modifications suivantes concernant le comportement des contenus multimédias.
Renforcement de l'audio en arrière-plan
À partir d'Android 17, le framework audio applique des restrictions sur les interactions audio en arrière-plan, y compris la lecture audio, les requêtes de priorité audio et les API de modification du volume, afin de s'assurer que ces modifications sont lancées intentionnellement par l'utilisateur.
Si l'application tente d'appeler des API audio alors qu'elle ne se trouve pas dans un cycle de vie valide, les API de lecture audio et de modification du volume échouent silencieusement, sans générer d'exception ni fournir de message d'échec. L'API de focus audio échoue avec le code de résultat AUDIOFOCUS_REQUEST_FAILED.
Pour en savoir plus, y compris sur les stratégies d'atténuation, consultez Renforcement de la sécurité de l'audio en arrière-plan.
Connectivité
Android 17 inclut les modifications suivantes pour améliorer la connectivité des appareils.
Réassociation autonome en cas de perte de l'association Bluetooth
Android 17 introduces autonomous re-pairing, a system-level enhancement designed to automatically resolve Bluetooth bond loss.
Previously, if a bond was lost, users had to manually navigate to Settings to unpair and then re-pair the peripheral. This feature builds upon the security improvement of Android 16 by allowing the system to re-establish bonds in the background without requiring users to manually navigate to Settings to unpair and re-pair peripherals.
While most apps will not require code changes, developers should be aware of the following behavior changes in Bluetooth stack:
- New pairing context: The
ACTION_PAIRING_REQUESTnow includes theEXTRA_PAIRING_CONTEXTextra which allows apps to distinguish between a standard pairing request and an autonomous system-initiated re-pairing attempt. - Conditional key updates: Existing security keys will only be replaced if the re-pairing is successful and new connection meets or exceeds the security level of the previous bond.
- Modified intent timing: The
ACTION_KEY_MISSINGintent is now broadcast only if the autonomous re-pairing attempt fails. This reduces unnecessary error handling in the app if the system successfully recovers the bond in the background. - User notification: The system manages re-pairing via new UI notifications and dialogs. Users will be prompted to confirm the re-pairing attempt to ensure they are aware of the reconnection.
Peripheral device manufacturers and companion app developers should verify that hardware and app gracefully handle bond transitions. To test this behavior, simulate a remote bond loss using either of the following methods:
- Manually remove the bond information from the peripheral device
- Manually unpair the device in: Settings > Connected devices