Modifiche al comportamento: tutte le app

La piattaforma Android 15 include modifiche al comportamento che potrebbero influire sulla tua app. Le seguenti modifiche al comportamento si applicano a tutte le app quando vengono eseguite su Android 15, indipendentemente da targetSdkVersion. Devi testare la tua app e poi modificarla in base alle necessità per supportarli correttamente, ove applicabile.

Assicurati di esaminare anche l'elenco delle modifiche al comportamento che interessano solo le app che hanno come target Android 15.

Funzionalità di base

Android 15 modifica o espande varie funzionalità di base del sistema Android.

Modifiche allo stato di interruzione del pacchetto

软件包 FLAG_STOPPED 状态(用户可以通过在 AOSP build 中长按应用图标并选择“强制停止”来启用此状态)的用途一直是让应用保持在此状态,直到用户通过直接启动应用或间接与应用互动(通过 Sharesheet 或 widget、将应用选择为动态壁纸等)来明确将应用从此状态移除。在 Android 15 中,我们更新了系统行为,使其与此预期行为保持一致。应用应仅通过直接或间接的用户操作从停止状态移除。

为了支持预期行为,除了现有限制之外,当应用在搭载 Android 15 的设备上进入停止状态时,系统还会取消所有待处理 intent。当用户的操作将应用从停止状态移除时,系统会将 ACTION_BOOT_COMPLETED 广播传送到应用,以便应用有机会重新注册所有待处理 intent。

您可以调用新的 ApplicationStartInfo.wasForceStopped() 方法来确认应用是否已进入停止状态。

Supporto delle dimensioni delle pagine di 16 kB

Storicamente, Android ha supportato solo dimensioni delle pagine di memoria di 4 KB, il che ha ottimizzato le prestazioni della memoria di sistema per la quantità media di memoria totale che i dispositivi Android hanno in genere avuto. A partire da Android 15, AOSP supporta i dispositivi configurati per utilizzare una dimensione pagina di 16 KB (dispositivi da 16 KB). Se la tua app utilizza librerie NDK, direttamente o indirettamente tramite un SDK, dovrai ricompilare l'app per farla funzionare su questi dispositivi da 16 KB.

Man mano che i produttori di dispositivi continuano a creare dispositivi con quantità maggiori di memoria fisica (RAM), molti di questi dispositivi adotteranno dimensioni delle pagine di 16 KB (e alla fine maggiori) per ottimizzare le prestazioni del dispositivo. L'aggiunta del supporto per i dispositivi con dimensioni di pagina di 16 kB consente alla tua app di essere eseguita su questi dispositivi e di sfruttare i miglioramenti delle prestazioni associati. Senza ricompilazione, le app non funzioneranno sui dispositivi da 16 KB nelle versioni future di Android.

Per aiutarti ad aggiungere il supporto per la tua app, abbiamo fornito indicazioni su come verificare se la tua app è interessata, su come ricompilare l'app (se applicabile) e su come testarla in un ambiente da 16 kB utilizzando emulatori (incluse le immagini di sistema Android 15 per Android Emulator).

Benefits and performance gains

配置为使用 16 KB 页面大小的设备平均会使用略多一些的内存,但系统和应用的性能也会得到各种提升:

  • 缩短了系统内存压力时的应用启动时间:平均降低了 3.16%;对于我们测试的某些应用而言,改进幅度更大(最高可达 30%)
  • 应用启动期间的功耗降低:平均降低了 4.56%
  • 相机启动更快:热启动速度平均提高了 4.48%,冷启动速度平均提高了 6.60%
  • 缩短了系统启动时间:平均缩短了 8%(约 950 毫秒)

这些改进基于我们的初始测试,实际设备上的结果可能会有所不同。随着测试的继续进行,我们将进一步分析应用的潜在收益。

Check if your app is impacted

Se la tua app utilizza codice nativo, devi ricompilarla con il supporto per i dispositivi da 16 kB. Se non sai con certezza se la tua app utilizza codice nativo, puoi utilizzare APK Analyzer per identificare se è presente codice nativo e poi controllare l'allineamento dei segmenti ELF per le librerie condivise che trovi. Android Studio offre anche funzionalità che ti aiutano a rilevare automaticamente i problemi di allineamento.

Se la tua app utilizza solo codice scritto nel linguaggio di programmazione Java o in Kotlin, incluse tutte le librerie o gli SDK, allora la tua app supporta già dispositivi da 16 KB. Tuttavia, ti consigliamo di testare l'app in un ambiente da 16 KB per verificare che non si verifichino regressioni impreviste nel comportamento dell'app.

Modifiche necessarie per alcune app per supportare lo spazio privato

私密空间是 Android 15 中推出的一项新功能,可让用户在设备上创建一个单独的空间,在额外的身份验证层保护下,防止敏感应用遭到窥探。由于私密空间中的应用具有受限的公开范围,因此某些类型的应用需要执行额外的步骤,才能查看和与用户私密空间中的应用互动。

所有应用

由于私密空间中的应用会保存在单独的用户资料中(类似于工作资料),因此应用不应假定其任何未位于主资料中的已安装副本都位于工作资料中。如果您的应用包含与工作资料应用相关的逻辑,并且做出了上述假设,则需要调整此逻辑。

医疗应用

当用户锁定私密空间时,私密空间中的所有应用都会停止运行,并且这些应用无法执行前台或后台活动,包括显示通知。此行为可能会严重影响安装在私密空间中的医疗应用的使用和功能。

私密空间设置体验会向用户发出警告,告知私密空间不适合需要执行关键前台或后台活动的应用,例如显示医疗应用发送的通知。不过,应用无法确定自己是否在私密空间中使用,因此无法在这种情况下向用户显示警告。

因此,如果您开发的是医疗应用,请检查此功能可能会对您的应用产生哪些影响,并采取适当的措施(例如告知用户不要在私密空间中安装您的应用),以免中断关键的应用功能。

启动器应用

如果您开发的是启动器应用,则必须执行以下操作,才能看到私密空间中的应用:

  1. 您的应用必须被指定为设备的默认启动器应用,即具有 ROLE_HOME 角色。
  2. 您的应用必须在应用的清单文件中声明 ACCESS_HIDDEN_PROFILES 普通权限。

声明 ACCESS_HIDDEN_PROFILES 权限的启动器应用必须处理以下私密空间用例:

  1. 您的应用必须为安装在私密空间中的应用提供单独的启动器容器。使用 getLauncherUserInfo() 方法确定要处理的用户个人资料类型。
  2. 用户必须能够隐藏和显示私密空间容器。
  3. 用户必须能够锁定和解锁私密空间容器。使用 requestQuietModeEnabled() 方法锁定(通过传递 true)或解锁(通过传递 false)私密空间。
  4. 在锁定状态下,私密空间容器中的任何应用都应不可见,也无法通过搜索等机制被发现。您的应用应为 ACTION_PROFILE_AVAILABLEACTION_PROFILE_UNAVAILABLE 广播注册接收器,并在私密空间容器的锁定或解锁状态发生变化时更新应用中的界面。这两种状态的广播都包含 EXTRA_USER,您的应用可以使用该常量来引用不公开个人资料的用户。

    您还可以使用 isQuietModeEnabled() 方法检查私密空间个人资料是否已锁定。

应用商店应用

私密空间包含一个“安装应用”按钮,用于启动隐式 intent 以将应用安装到用户的私密空间。为了让应用能够接收此隐式 intent,请在应用的清单文件中声明一个 <intent-filter>,并将 <category> 设为 CATEGORY_APP_MARKET

Carattere emoji basato su PNG rimosso

The legacy, PNG-based emoji font file (NotoColorEmojiLegacy.ttf) has been removed, leaving just the vector-based file. Beginning with Android 13 (API level 33), the emoji font file used by the system emoji renderer changed from a PNG-based file to a vector based file. The system retained the legacy font file in Android 13 and 14 for compatibility reasons, so that apps with their own font renderers could continue to use the legacy font file until they were able to upgrade.

To check if your app is affected, search your app's code for references to the NotoColorEmojiLegacy.ttf file.

You can choose to adapt your app in a number of ways:

  • Use platform APIs for text rendering. You can render text to a bitmap-backed Canvas and use that to get a raw image if necessary.
  • Add COLRv1 font support to your app. The FreeType open source library supports COLRv1 in version 2.13.0 and higher.
  • As a last resort, you can bundle the legacy emoji font file (NotoColorEmoji.ttf) into your APK, although in that case your app will be missing the latest emoji updates. For more information, see the Noto Emoji GitHub project page.

Aumento della versione minima dell'SDK target da 23 a 24

Android 15 基于 在 Android 14 中进行的更改,并扩展了 安全性。在 Android 15 中, 无法安装低于 24 的 targetSdkVersion。 要求应用符合现代 API 级别有助于确保更好的安全性和 保护隐私。

恶意软件通常会以较低的 API 级别为目标平台,以绕过安全和隐私 更高的 Android 版本中引入的保护机制。例如,有些恶意软件应用使用 targetSdkVersion 22,以避免受到 Android 6.0 Marshmallow(API 级别 23)在 2015 年引入的运行时权限模型的约束。这项 Android 15 变更使恶意软件更难以规避安全和隐私权方面的改进限制。尝试安装以较低 API 级别为目标平台的应用将导致安装失败,并且 Logcat 中会显示如下所示的消息:

INSTALL_FAILED_DEPRECATED_SDK_VERSION: App package must target at least SDK version 24, but found 7

在升级到 Android 15 的设备上,targetSdkVersion 级别较低的任何应用 安装在 Google Play 上

如果您需要测试以旧版 API 级别为目标平台的应用,请使用以下 ADB 命令:

adb install --bypass-low-target-sdk-block FILENAME.apk

Sicurezza e privacy

Android 15 introduces robust measures to combat one-time passcode (OTP) fraud and to protect the user's sensitive content, focusing on hardening the Notification Listener Service and screenshare protections. Key enhancements include redacting OTPs from notifications accessible to untrusted apps, hiding notifications during screenshare, and securing app activities when OTPs are posted. These changes aim to keep the user's sensitive content safe from unauthorized actors.

Developers need to be aware of the following to ensure their apps are compatible with the changes in Android 15:

OTP Redaction

Android will stop untrusted apps that implement a NotificationListenerService from reading unredacted content from notifications where an OTP has been detected. Trusted apps such as companion device manager associations are exempt from these restrictions.

Screenshare Protection

  • Notification content is hidden during screen sharing sessions to preserve the user's privacy. If the app implements setPublicVersion(), Android shows the public version of the notification which serves as a replacement notification in insecure contexts. Otherwise, the notification content is redacted without any further context.
  • Sensitive content like password input is hidden from remote viewers to prevent revealing the user's sensitive information.
  • Activities from apps that post notifications during screenshare where an OTP has been detected will be hidden. App content is hidden from the remote viewer when launched.
  • Beyond Android's automatic identification of sensitive fields, developers can manually mark parts of their app as sensitive using setContentSensitivity, which is hidden from remote viewers during screenshare.
  • Developers can choose to toggle the Disable screen share protections option under Developer Options to be exempted from the screenshare protections for demo or testing purposes. The default system screen recorder is exempted from these changes, since the recordings remain on-device.

Fotocamera e contenuti multimediali

Android 15 apporta le seguenti modifiche al comportamento della fotocamera e dei contenuti multimediali per tutte le app.

La riproduzione audio diretta e l'offload invalidano le tracce audio dirette o offload aperte in precedenza quando vengono raggiunti i limiti delle risorse

Before Android 15, if an app requested direct or offload audio playback while another app was playing audio and the resource limits were reached, the app would fail to open a new AudioTrack.

Beginning with Android 15, when an app requests direct or offload playback and the resource limits are reached, the system invalidates any currently open AudioTrack objects which prevent fulfilling the new track request.

(Direct and offload audio tracks are typically opened for playback of compressed audio formats. Common use-cases for playing direct audio include streaming encoded audio over HDMI to a TV. Offload tracks are typically used to play compressed audio on a mobile device with hardware DSP acceleration.)

Esperienza utente e UI di sistema

Android 15 include alcune modifiche volte a creare un'esperienza utente più coerente e intuitiva.

Animazioni predittive per Indietro attivate per le app che hanno eseguito l'opt-in

Beginning in Android 15, the developer option for predictive back animations has been removed. System animations such as back-to-home, cross-task, and cross-activity now appear for apps that have opted in to the predictive back gesture either entirely or at an activity level. If your app is affected, take the following actions:

  • Ensure that your app has been properly migrated to use the predictive back gesture.
  • Ensure that your fragment transitions work with predictive back navigation.
  • Migrate away from animation and framework transitions and use animator and androidx transitions instead.
  • Migrate away from back stacks that FragmentManager doesn't know about. Use back stacks managed by FragmentManager or by the Navigation component instead.

Widget disattivati quando l'utente arresta forzatamente un'app

如果用户在搭载 Android 15 的设备上强制停止应用,系统会暂时停用该应用的所有微件。这些 widget 会灰显,用户无法与其互动。这是因为,从 Android 15 开始,当系统强制停止应用时,会取消应用的所有待处理 intent。

系统会在用户下次启动应用时重新启用这些微件。

如需了解详情,请参阅对软件包停止状态的更改

Il chip della barra di stato della proiezione dei contenuti multimediali avvisa gli utenti della condivisione dello schermo, della trasmissione e della registrazione

Gli exploit di proiezione dello schermo espongono i dati utente privati, come le informazioni finanziarie, perché gli utenti non si rendono conto che lo schermo del loro dispositivo viene condiviso.

Per le app in esecuzione su dispositivi con Android 15 QPR1 o versioni successive, un chip della barra di stato grande e in evidenza avvisa gli utenti di eventuali proiezioni dello schermo in corso. Gli utenti possono toccare il chip per impedire la condivisione, la trasmissione o la registrazione della schermata. Inoltre, la proiezione dello schermo si interrompe automaticamente quando lo schermo del dispositivo è bloccato.

Chip barra delle app per condivisione schermo, trasmissione e registrazione.

检查您的应用是否受到影响

默认情况下,您的应用会包含状态栏条状标签,并会在锁定屏幕激活时自动暂停屏幕投影。

如需详细了解如何针对这些用例测试应用,请参阅状态栏条状标签和自动停止

Limitazioni di accesso alla rete in background

In Android 15, le app che avviano una richiesta di rete al di fuori di un ciclo di vita del processo valido ricevono un'eccezione. In genere, un UnknownHostException o un altro IOException correlato alla presa. Le richieste di rete che si verificano al di fuori di un ciclo di vita valido sono solitamente dovute al fatto che le app continuano inconsapevolmente una richiesta di rete anche dopo che l'app non è più attiva.

Per ridurre al minimo questa eccezione, assicurati che le richieste di rete siano sensibili al ciclo di vita e annullate al termine di un ciclo di vita del processo valido utilizzando componenti sensibili al ciclo di vita. Se è importante che la richiesta di rete venga eseguita anche quando l'utente abbandona l'applicazione, valuta la possibilità di pianificarla utilizzando WorkManager o di continuare un'attività visibile all'utente utilizzando il servizio in primo piano.

Ritiri

Con ogni release, API Android specifiche potrebbero diventare obsolete o dover essere refattorizzate per offrire una migliore esperienza per gli sviluppatori o supportare nuove funzionalità della piattaforma. In questi casi, ritiriamo ufficialmente le API obsolete e indirizziamo gli sviluppatori a API alternative da utilizzare.

Il ritiro significa che abbiamo interrotto il supporto ufficiale per le API, ma queste continueranno a rimanere disponibili per gli sviluppatori. Per scoprire di più sui ritiri importanti in questa release di Android, consulta la pagina dei ritiri.