Changements de comportement : toutes les applications

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 introduit des limites de mémoire pour les applications en fonction de la RAM totale de l'appareil afin de créer un environnement plus stable et déterministe pour vos applications et les utilisateurs d'Android. Ces limites se concentrent sur les fuites de mémoire et d'autres anomalies avant qu'elles ne déclenchent une instabilité à l'échelle du système, entraînant des saccades de l'interface utilisateur, une décharge plus rapide de la batterie et l'arrêt des applications. Bien que nous prévoyions un impact minimal sur la grande majorité des sessions d'application, nous vous recommandons de suivre les bonnes pratiques suivantes concernant la mémoire, y compris d'établir une référence pour la mémoire.

Vous pouvez déterminer si votre session d'application a été affectée en appelant getDescription dans ApplicationExitInfo. Si votre application a été affectée, le motif de sortie sera REASON_OTHER et la description contiendra la chaîne "MemoryLimiter:AnonSwap" ainsi que d'autres informations. Vous pouvez également utiliser le profilage basé sur des déclencheurs avec TRIGGER_TYPE_ANOMALY pour obtenir des empreintes de la mémoire collectées lorsque la limite de mémoire est atteinte.

La documentation Gérer la mémoire de votre application fournit des informations pour vous aider à diagnostiquer les problèmes de mémoire de votre application et à optimiser sa consommation de ressources.

Tester le comportement de votre application en fonction des contraintes de mémoire

Vous pouvez utiliser Android Debug Bridge (adb) pour ajuster ou désactiver les limites de mémoire sur n'importe quel appareil qui les impose. La commande shell am fournit trois sous-commandes pour ajuster les limites de mémoire. (Ces commandes n'ont aucun effet sur un appareil qui n'impose pas de limites de mémoire.)

  • am memory-limiter ignore <uid>|none|all
  • am memory-limiter manual <pid> <limit>|max|none
  • am memory-limiter status
ignore

Indique au limiteur de mémoire d'ignorer certains processus ou tous les processus. La transmission d'un UID (ID utilisateur Android) indique au limiteur de mémoire d'ignorer l'application sur tous les processus associés à cet UID. Vous pouvez également transmettre all (ignorer toutes les applications) ou none (n'ignorer aucune application). La transmission de none remplace tous les appels précédents à am memory-limiter ignore.

Si vous demandez au limiteur de mémoire d'ignorer un UID, vous pouvez toujours appliquer une limite de mémoire manuelle à un processus de l'application en appelant am memory-limiter manual.

manual

Indique au système d'imposer une contrainte de mémoire au processus avec l'ID de processus (PID) spécifié. La contrainte de mémoire est spécifiée sous la forme d'un nombre entier de Mo. Par exemple, la transmission de 30 spécifie que le processus est limité à 30 Mo de mémoire. La transmission de max supprime toutes les limites de mémoire de ce processus. La transmission de none supprime toutes les limites manuelles définies sur le processus, ce qui rétablit la limite par défaut du système (le cas échéant).

status

Indique l'état actuel du limiteur de mémoire. L'état inclut les limites de mémoire imposées aux processus visibles et non visibles.

Confidentialité

Android 17 inclut les modifications suivantes pour améliorer la confidentialité des utilisateurs.

Protection par OTP envoyé 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 concernant la sécurité des appareils et des applications.

Plan d'abandon de usesClearTraffic

In a future release, we plan to deprecate the usesCleartextTraffic element. Apps that need to make unencrypted (HTTP) connections should migrate to using a network security configuration file, which lets you specify which domains your app needs to make cleartext connections to.

Be aware that network security configuration files are only supported on API levels 24 and higher. If your app has a minimum API level lower than 24, you should do both of the following:

  • Set the usesCleartextTraffic attribute to true
  • Use a network configuration file

If your app's minimum API level is 24 or higher, you can use a network configuration file and you don't need to set usesCleartextTraffic.

Limiter les autorisations d'URI implicites

Currently, if an app launches an intent with a URI that has the action ACTION_SEND, ACTION_SEND_MULTIPLE, or ACTION_IMAGE_CAPTURE, the system automatically grants the read and write URI permissions to the target app. Starting in Android 18, the system will no longer automatically grant these permissions. For this reason, we recommend that apps explicitly grant the relevant URI permissions instead of relying on the system to grant them.

To detect the usage of these intents in your app, use StrictMode with detectImplicitUriPermissionGrant() to trigger a 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);

Alternatively, you can monitor for logged exceptions containing the message Please set the grant explicitly in the app that appears when system implicitly sets the grant. You can monitor for these logs using the following adb command:

adb logcat | grep "Please set the grant explicitly in the app"

To explicitly grant the necessary permissions, add the FLAG_GRANT_READ_URI_PERMISSION flag to ACTION_SEND and ACTION_SEND_MULTIPLE intents:

Kotlin

intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)

Java

intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

Include both FLAG_GRANT_READ_URI_PERMISSION and FLAG_GRANT_WRITE_URI_PERMISSION flags for 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 du keystore par application

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 new ERROR_TOO_MANY_KEYS value.
  • All other apps: getNumericErrorCode() returns ERROR_INCORRECT_USAGE.

Bloquer le trafic de rebouclage entre les profils

À partir d'Android 17, le trafic de bouclage entre profils n'est plus autorisé par défaut. Le trafic de bouclage au sein du 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.

Restauration de la visibilité de l'IME par défaut après la rotation

À partir d'Android 17, lorsque la configuration de l'appareil change (par exemple, par rotation) et que l'application ne gère pas ce changement, la visibilité précédente de l'IME n'est pas restaurée.

Si votre application subit une modification de configuration qu'elle ne gère pas et qu'elle a besoin que le clavier soit visible après la modification, vous devez le demander explicitement. Vous pouvez effectuer cette requête de l'une des manières suivantes :

  • Définissez l'attribut android:windowSoftInputMode sur stateAlwaysVisible.
  • Demandez le clavier virtuel de manière programmatique dans la méthode onCreate() de votre activité ou ajoutez la méthode onConfigurationChanged().

Action humaine

Android 17 inclut les modifications suivantes qui affectent la façon dont les applications interagissent avec les périphériques d'interface 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

Beginning with Android 17, if an app requests pointer capture using View.requestPointerCapture() and the user uses a touchpad, the system recognizes pointer movement and scrolling gestures from the user's touches and reports them to the app in the same way as pointer and scroll wheel movements from a captured mouse. In most cases, this removes the need for apps that support captured mice to add special handling logic for touchpads. For more details, see the documentation for View.POINTER_CAPTURE_MODE_RELATIVE.

Previously, the system did not attempt to recognize gestures from the touchpad, and instead delivered the raw, absolute finger locations to the app in a similar format to touchscreen touches. If an app still requires this absolute data, it should call the new View.requestPointerCapture(int) method with View.POINTER_CAPTURE_MODE_ABSOLUTE instead.

Multimédia

Android 17 inclut les modifications suivantes concernant le comportement des contenus multimédias.

Renforcement de l'audio en arrière-plan

Beginning with Android 17, the audio framework enforces restrictions on background audio interactions including audio playback, audio focus requests, and volume change APIs to ensure that these changes are started intentionally by the user.

If the app tries to call audio APIs while the app is not in a valid lifecycle, the audio playback and volume change APIs fail silently without throwing an exception or providing a failure message. The audio focus API fails with the result code AUDIOFOCUS_REQUEST_FAILED.

For more information, including mitigation strategies, see Background audio hardening.

Connectivité

Android 17 inclut les modifications suivantes pour améliorer la connectivité des appareils.

Lancement autonome de la réassociation en cas de perte de la liaison 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 enabling the system to re-establish bonds after user consent is granted. This eliminates the need for 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_REQUEST now includes the EXTRA_PAIRING_CONTEXT extra 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_MISSING intent 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