Como nas versões anteriores, o Android 16 inclui mudanças de comportamento que podem afetar seu app. As mudanças de comportamento abaixo se aplicam exclusivamente a apps destinados ao Android 16 ou versões mais recentes. Caso seu app seja direcionado ao Android 16 ou a versões mais recentes, faça modificações para oferecer suporte a esses comportamentos, quando aplicável.
Consulte também a lista de mudanças de comportamento que afetam todos os apps
executados no Android 16, independente da targetSdkVersion do app.
Experiência do usuário e interface do sistema
O Android 16 (nível 36 da API) inclui as seguintes mudanças que visam criar uma experiência do usuário mais consistente e intuitiva.
Fim da opção de recusar a exibição de ponta a ponta
O Android 15 impôs a exibição de ponta a ponta para apps destinados ao Android 15 (nível 35 da API), mas o app pode desativar essa opção definindo
R.attr#windowOptOutEdgeToEdgeEnforcement como true. Para apps destinados ao Android 16 (nível 36 da API), R.attr#windowOptOutEdgeToEdgeEnforcement foi descontinuado e desativado, e o app não pode desativar a exibição de ponta a ponta.
- Se o app for destinado ao Android 16 (nível da API 36) e estiver em execução em um dispositivo Android 15,
R.attr#windowOptOutEdgeToEdgeEnforcementvai continuar funcionando. - Se o app for destinado ao Android 16 (nível da API 36) e estiver em execução em um dispositivo Android 16,
R.attr#windowOptOutEdgeToEdgeEnforcementserá desativado.
Para testes no Android 16, verifique se o app oferece suporte à exibição de ponta a ponta e remova qualquer uso de R.attr#windowOptOutEdgeToEdgeEnforcement para que o app também ofereça suporte à exibição de ponta a ponta em um dispositivo Android 15. Para oferecer suporte à exibição de ponta a ponta,
consulte as orientações do Compose e das visualizações.
Migração ou opção de recusar necessária para o botão Voltar preditivo
For apps targeting Android 16 (API level 36) or higher and running on an
Android 16 or higher device, the predictive back system animations
(back-to-home, cross-task, and cross-activity) are enabled by default.
Additionally, onBackPressed is not called and
KeyEvent.KEYCODE_BACK is not dispatched anymore.
If your app intercepts the back event and you haven't migrated to predictive
back yet, update your app to use supported back navigation APIs, or
temporarily opt out by setting the
android:enableOnBackInvokedCallback attribute to false in the
<application> or <activity> tag of your app's AndroidManifest.xml file.
APIs de fontes elegantes descontinuadas e desativadas
Apps targeting Android 15 (API level 35) have the
elegantTextHeight
TextView attribute set to true by
default, replacing the compact font with one that is much more readable. You
could override this by setting the elegantTextHeight attribute to false.
Android 16 deprecates the
elegantTextHeight attribute,
and the attribute will be ignored once your app targets Android 16. The "UI
fonts" controlled by these APIs are being discontinued, so you should adapt any
layouts to ensure consistent and future proof text rendering in Arabic, Lao,
Myanmar, Tamil, Gujarati, Kannada, Malayalam, Odia, Telugu or Thai.
elegantTextHeight behavior for apps targeting Android
14 (API level 34) and lower, or for apps targeting Android 15 (API level 35)
that overrode the default by setting the elegantTextHeight
attribute to false.
elegantTextHeight behavior for apps targeting Android
16 (API level 36), or for apps targeting Android 15 (API level 35) that didn't
override the default by setting the elegantTextHeight attribute
to false.Funcionalidade principal
O Android 16 (nível 36 da API) inclui as seguintes mudanças que modificam ou expandem vários recursos principais do sistema Android.
Otimização do agendamento de trabalho de taxa fixa
在以 Android 16 为目标平台之前,如果 scheduleAtFixedRate 因不在有效的进程生命周期内而错过了任务执行,则当应用返回到有效的生命周期时,所有错过的执行会立即执行。
以 Android 16 为目标平台时,当应用返回到有效的生命周期时,系统会立即执行最多 1 次未执行的 scheduleAtFixedRate 执行。此行为变更预计会提升应用性能。在您的应用中测试此行为,检查您的应用是否受到影响。您还可以使用应用兼容性框架并启用 STPE_SKIP_MULTIPLE_MISSED_PERIODIC_TASKS 兼容性标志进行测试。
Formatos de dispositivos
O Android 16 (nível 36 da API) inclui as seguintes mudanças para apps quando exibidos em dispositivos de tela grande.
Layouts adaptáveis
现在,Android 应用可在各种设备(例如手机、平板电脑、可折叠设备、桌面设备、汽车和电视)上运行,并且在大屏设备上支持多种窗口模式(例如分屏和桌面窗口化模式),因此开发者应构建能够适应任何屏幕和窗口尺寸的 Android 应用,无论设备屏幕方向如何。在当今多设备的世界中,限制屏幕方向和尺寸可调整性等范式过于严格。
忽略屏幕方向、尺寸可调整性和宽高比限制
对于以 Android 16(API 级别 36)为目标平台的应用,在最小宽度 >= 600dp 的显示屏上,屏幕方向、尺寸调整能力和宽高比限制不再适用。应用会填满整个显示窗口,无论宽高比或用户偏好的屏幕方向如何,都不会使用竖屏黑边模式。
此变更引入了新的标准平台行为。Android 正在向一种模型转变,在该模型中,应用需要适应各种屏幕方向、显示大小和宽高比。固定屏幕方向或有限的尺寸调整等限制会阻碍应用的适应性。使应用具有自适应性,以提供尽可能最佳的用户体验。
您还可以使用应用兼容性框架并启用 UNIVERSAL_RESIZABLE_BY_DEFAULT 兼容性标志来测试此行为。
常见的重大更改
忽略屏幕方向、可调整大小性和宽高比限制可能会影响应用在某些设备上的界面,尤其是那些专为锁定为纵向的小布局设计的元素:例如,布局拉伸、动画和组件超出屏幕等问题。任何关于宽高比或屏幕方向的假设都可能导致应用出现视觉问题。详细了解如何避免这些问题并改进应用的自适应行为。
允许设备旋转会导致更多 activity 重新创建,如果未正确保留用户状态,可能会导致用户状态丢失。如需了解如何正确保存界面状态,请参阅保存界面状态。
实现细节
在全屏模式和多窗口模式下,以下清单属性和运行时 API 会被大屏设备忽略:
screenOrientationresizableActivityminAspectRatiomaxAspectRatiosetRequestedOrientation()getRequestedOrientation()
系统会忽略 screenOrientation、setRequestedOrientation() 和 getRequestedOrientation() 的以下值:
portraitreversePortraitsensorPortraituserPortraitlandscapereverseLandscapesensorLandscapeuserLandscape
对于显示屏可调整大小性,android:resizeableActivity="false"、android:minAspectRatio 和 android:maxAspectRatio 没有影响。
对于以 Android 16(API 级别 36)为目标平台的应用,默认情况下,大屏设备会忽略应用的屏幕方向、尺寸调整和宽高比限制。尚未完全准备就绪的每个应用都可以通过选择停用来暂时替换此行为,这会导致应用恢复到之前放置在兼容模式下的行为。
例外情况
在以下情况下,Android 16 的屏幕方向、尺寸调整能力和宽高比限制不适用:
- 游戏(基于
android:appCategory标志) - 用户在设备的宽高比设置中明确选择启用应用的默认行为
- 小于
sw600dp的屏幕
暂时选择不接收
如需选择停用特定 activity,请声明 PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY 清单属性:
<activity ...>
<property android:name="android.window.PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY" android:value="true" />
...
</activity>
如果应用的很多部分尚未准备好支持 Android 16,您可以在应用级别应用相同的属性,从而完全选择不启用该功能:
<application ...>
<property android:name="android.window.PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY" android:value="true" />
</application>
Saúde e fitness
O Android 16 (nível 36 da API) inclui as seguintes mudanças relacionadas a dados de saúde e fitness.
Permissões de saúde e fitness
Para apps direcionados ao Android 16 (nível 36 da API) ou mais recentes, as permissões
BODY_SENSORS são mais granulares
em android.permissions.health, um modelo adotado também pelo Conexão Saúde. No Android 16, qualquer API que antes exigia BODY_SENSORS
ou BODY_SENSORS_BACKGROUND agora precisa da permissão
android.permissions.health correspondente. Isso afeta os seguintes tipos de dados, APIs e tipos de serviços em primeiro plano:
HEART_RATE_BPMdos Recursos de Saúde no Wear OSSensor.TYPE_HEART_RATEdo Android Sensor ManagerheartRateAccuracyeheartRateBpmdeProtoLayoutno Wear OSFOREGROUND_SERVICE_TYPE_HEALTH, em que a permissãoandroid.permission.healthé necessária em vez deBODY_SENSORS
Se o app usa essas APIs, ele precisa solicitar as permissões granulares respectivas:
- Para monitoramento da frequência cardíaca, SpO2 ou temperatura da pele durante o uso:
solicite a permissão granular em
android.permissions.health, comoREAD_HEART_RATEem vez deBODY_SENSORS. - Para acesso ao sensor em segundo plano: solicite
READ_HEALTH_DATA_IN_BACKGROUNDem vez deBODY_SENSORS_BACKGROUND.
Essas permissões são as mesmas que protegem o acesso à leitura de dados da Conexão Saúde, o repositório de dados do Android para informações de saúde, condicionamento físico e bem-estar.
Apps para dispositivos móveis
Os apps para dispositivos móveis que migram para usar a READ_HEART_RATE e outras permissões granulares
também precisam declarar uma atividade para mostrar
a Política de Privacidade do app. Esse é o mesmo requisito da Conexão Saúde.
Conectividade
O Android 16 (nível 36 da API) inclui as seguintes mudanças na pilha do Bluetooth para melhorar a conectividade com dispositivos periféricos.
Novas intents para processar a perda de vinculação e mudanças de criptografia
As part of the Improved bond loss handling, Android 16 also introduces 2 new intents to provide apps with greater awareness of bond loss and encryption changes.
Apps targeting Android 16 can now:
- Receive an
ACTION_KEY_MISSINGintent when remote bond loss is detected, allowing them to provide more informative user feedback and take appropriate actions. - Receive an
ACTION_ENCRYPTION_CHANGEintent whenever encryption status of the link changes. This includes encryption status change, encryption algorithm change, and encryption key size change. Apps must consider the bond restored if the link is successfully encrypted upon receivingACTION_ENCRYPTION_CHANGEintent later.
Adapting to varying OEM implementations
While Android 16 introduces these new intents, their implementation and broadcasting can vary across different device manufacturers (OEMs). To ensure your app provides a consistent and reliable experience across all devices, developers should design their bond loss handling to gracefully adapt to these potential variations.
We recommend the following app behaviors:
If the
ACTION_KEY_MISSINGintent is broadcast:The ACL (Asynchronous Connection-Less) link will be disconnected by the system, but the bond information for the device will be retained (as described here).
Your app should use this intent as the primary signal for bond loss detection and guiding the user to confirm the remote device is in range before initiating device forgetting or re-pairing.
If a device disconnects after
ACTION_KEY_MISSINGis received, your app should be cautious about reconnecting, as the device may no longer be bonded with the system.If the
ACTION_KEY_MISSINGintent is NOT broadcast:The ACL link will remain connected, and the bond information for the device will be removed by the system, same to behavior in Android 15.
In this scenario, your app should continue its existing bond loss handling mechanisms as in previous Android releases, to detect and manage bond loss events.
Nova maneira de remover a vinculação do Bluetooth
All apps targeting Android 16 are now able to unpair bluetooth devices using a
public API in CompanionDeviceManager. If a companion device is
being managed as a CDM association, then the app can trigger
bluetooth bond removal by using the new removeBond(int) API
on the associated device. The app can monitor the bond state changes by
listening to the bluetooth device broadcast event
ACTION_BOND_STATE_CHANGED.
Segurança
O Android 16 (nível 36 da API) inclui as seguintes mudanças de segurança.
Bloqueio da versão do MediaStore
For apps targeting Android 16 or higher, MediaStore#getVersion() will now
be unique to each app. This eliminates identifying properties from the version
string to prevent abuse and usage for fingerprinting techniques. Apps shouldn't
make any assumptions around the format of this version. Apps should already
handle version changes when using this API and in most cases shouldn't need to
change their current behavior, unless the developer has attempted to infer
additional information that is beyond the intended scope of this API.
Intents mais seguras
The Safer Intents feature is a multi-phase security initiative designed to improve the security of Android's intent resolution mechanism. The goal is to protect apps from malicious actions by adding checks during intent processing and filtering intents that don't meet specific criteria.
In Android 15 the feature focused on the sending app. Now with Android 16, control shifts to the receiving app, allowing developers to opt-in to strict intent resolution using their app manifest.
Two key changes are being implemented:
Explicit Intents Must Match the Target Component's Intent Filter: If an intent explicitly targets a component, it should match that component's intent filter.
Intents Without an Action Cannot Match any Intent Filter: Intents that don't have an action specified shouldn't be resolved to any intent filter.
These changes only apply when multiple apps are involved and don't affect intent handling within a single app.
Impact
The opt-in nature means that developers must explicitly enable it in their app manifest for it to take effect. As a result, the feature's impact will be limited to apps whose developers:
- Are aware of the Safer Intents feature and its benefits.
- Actively choose to incorporate stricter intent handling practices into their apps.
This opt-in approach minimizes the risk of breaking existing apps that may rely on the current less-secure intent resolution behavior.
While the initial impact in Android 16 may be limited, the Safer Intents initiative has a roadmap for broader impact in future Android releases. The plan is to eventually make strict intent resolution the default behavior.
The Safer Intents feature has the potential to significantly enhance the security of the Android ecosystem by making it more difficult for malicious apps to exploit vulnerabilities in the intent resolution mechanism.
However, the transition to opt-out and mandatory enforcement must be carefully managed to address potential compatibility issues with existing apps.
Implementation
Developers need to explicitly enable stricter intent matching using the
intentMatchingFlags attribute in their app manifest.
Here is an example where the feature is opt-in for the entire app,
but disabled/opt-out on a receiver:
<application android:intentMatchingFlags="enforceIntentFilter">
<receiver android:name=".MyBroadcastReceiver" android:exported="true" android:intentMatchingFlags="none">
<intent-filter>
<action android:name="com.example.MY_CUSTOM_ACTION" />
</intent-filter>
<intent-filter>
<action android:name="com.example.MY_ANOTHER_CUSTOM_ACTION" />
</intent-filter>
</receiver>
</application>
More on the supported flags:
| Flag Name | Description |
|---|---|
| enforceIntentFilter | Enforces stricter matching for incoming intents |
| none | Disables all special matching rules for incoming intents. When specifying multiple flags, conflicting values are resolved by giving precedence to the "none" flag |
| allowNullAction | Relaxes the matching rules to allow intents without an action to match. This flag to be used in conjunction with "enforceIntentFilter" to achieve a specific behavior |
Testing and Debugging
When the enforcement is active, apps should function correctly if the intent
caller has properly populated the intent.
However, blocked intents will trigger warning log messages like
"Intent does not match component's intent filter:" and "Access blocked:"
with the tag "PackageManager."
This indicates a potential issue that could impact the app and requires
attention.
Logcat filter:
tag=:PackageManager & (message:"Intent does not match component's intent filter:" | message: "Access blocked:")
Filtragem de chamadas de sistema da GPU
为了加固 Mali GPU Surface,我们已在生产版本中屏蔽了已废弃或仅用于 GPU 开发的 Mali GPU IOCTL。 此外,用于 GPU 性能剖析的 IOCTL 已限制为 shell 进程或可调试的应用。如需详细了解平台级政策,请参阅 SAC 更新。
此项变更适用于使用 Mali GPU 的 Pixel 设备(Pixel 6-9)。Arm
已在其 r54p2 release 版本的
Documentation/ioctl-categories.rst 中提供了 IOCTL 的官方分类。此列表将在未来的驱动程序版本中继续维护。
此项变更不会影响受支持的图形 API(包括 Vulkan 和 OpenGL),预计也不会影响开发者或现有应用。 Streamline Performance Analyzer 和 Android GPU 检查器等 GPU 性能剖析工具不会受到影响。
测试
如果您看到类似以下内容的 SELinux 拒绝,则您的应用很可能受到了此项变更的影响:
06-30 10:47:18.617 20360 20360 W roidJUnitRunner: type=1400 audit(0.0:85): avc: denied { ioctl }
for path="/dev/mali0" dev="tmpfs" ino=1188 ioctlcmd=0x8023
scontext=u:r:untrusted_app_25:s0:c512,c768 tcontext=u:object_r:gpu_device:s0 tclass=chr_file
permissive=0 app=com.google.android.selinux.pts
如果您的应用需要使用被屏蔽的 IOCTL,请提交 bug 并将其分配给 android-partner-security@google.com。
常见问题解答
此项政策变更是否适用于所有 OEM? 此项变更将采用选择启用模式,但任何想要使用此加固方法的原始设备制造商(OEM)都可以使用。如需了解如何实现此项变更,请参阅实现文档。
是否必须在 OEM 代码库中进行更改才能实现此项变更,还是默认随新的 AOSP 版本提供? 平台级变更将默认随新的 AOSP 版本提供。供应商可以选择在其代码库中启用此项变更,以便应用此项变更。
SoC 是否负责让 IOCTL 列表保持最新状态?例如,如果我的设备使用 ARM Mali GPU,我是否需要就任何变更与 ARM 联系? 各个 SoC 必须在驱动程序发布后根据设备更新其 IOCTL 列表。 例如,ARM 会在驱动程序更新后更新其发布的 IOCTL 列表。 不过,OEM 应确保将更新纳入其 SEPolicy,并根据需要将任何选定的自定义 IOCTL 添加到列表中。
此项变更是否会自动应用于所有在售 Pixel 设备,还是需要用户执行操作来切换某些内容以应用此项变更? 此项变更适用于所有使用 Mali GPU 的在售 Pixel 设备(Pixel 6-9)。无需用户执行任何操作即可应用此项变更。
使用此政策是否会影响内核驱动程序的性能? 我们已使用 GFXBench 在 Mali GPU 上对此政策进行了测试,未观察到 GPU 性能发生任何可衡量的变化。
IOCTL 列表是否需要与当前的用户空间和内核驱动程序版本保持一致?是,允许的 IOCTL 列表必须与用户空间和内核驱动程序支持的 IOCTL 同步。如果用户空间或内核驱动程序中的 IOCTL 发生更新,则必须更新 SEPolicy IOCTL 列表以进行匹配。
ARM 已将 IOCTL 分类为“受限”/“检测”,但我们希望在生产用例中使用其中的一些 IOCTL,并/或拒绝其他 IOCTL。 各个 OEM/SoC 负责根据其用户空间 Mali 库的配置,决定如何对其使用的 IOCTL 进行分类。 ARM 的列表可用于帮助决定这些内容,但每个 OEM/SoC 的用例可能有所不同。
Privacidade
O Android 16 (nível 36 da API) inclui as seguintes mudanças de privacidade.
Permissão de rede local
Qualquer app com a permissão INTERNET pode acessar dispositivos na LAN.
Isso facilita a conexão de apps a dispositivos locais, mas também tem implicações de privacidade, como a formação de uma impressão digital do usuário e a atuação como um proxy de localização.
O projeto de proteções de rede local visa proteger a privacidade do usuário, restringindo o acesso à rede local por trás de uma nova permissão de execução.
Plano de lançamento
Essa mudança será implementada entre duas versões, 25Q2 e 26Q2 , respectivamente. É fundamental que os desenvolvedores sigam estas orientações para a 25Q2 e compartilhem feedback, porque essas proteções serão aplicadas em uma versão mais recente do Android. Além disso, eles precisarão atualizar os cenários que dependem do acesso implícito à rede local usando as orientações a seguir e se preparar para a rejeição e revogação da nova permissão pelo usuário.
Impacto
Na fase atual, a LNP é um recurso opcional, o que significa que apenas os apps que ativarem essa opção serão afetados. O objetivo da fase de ativação é que os desenvolvedores de apps entendam quais partes do app dependem do acesso implícito à rede local para que possam se preparar para proteger a permissão na próxima versão.
Os apps serão afetados se acessarem a rede local do usuário usando:
- Uso direto ou de biblioteca de soquetes brutos em endereços de rede local (por exemplo, protocolo de descoberta de serviço mDNS ou SSDP)
- Uso de classes de nível de framework que acessam a rede local (por exemplo, NsdManager)
O tráfego para e de um endereço de rede local exige permissão de acesso à rede local. A tabela a seguir lista alguns casos comuns:
| Operação de rede de baixo nível do app | Permissão de rede local necessária |
|---|---|
| Fazer uma conexão TCP de saída | sim |
| Aceitar conexões TCP recebidas | sim |
| Enviar uma transmissão UDP unicast, multicast, broadcast | sim |
| Receber uma transmissão UDP unicast, multicast, broadcast | sim |
Essas restrições são implementadas profundamente na pilha de rede e, portanto, se aplicam a todas as APIs de rede. Isso inclui soquetes criados em código nativo ou gerenciado, bibliotecas de rede como Cronet e OkHttp e todas as APIs implementadas sobre elas. A tentativa de resolver serviços na rede local (ou seja, aqueles com um sufixo .local) exigirá permissão de rede local.
Exceções às regras acima:
- Se o servidor DNS de um dispositivo estiver em uma rede local, o tráfego de ou para ele (na porta 53) não exigirá permissão de acesso à rede local.
- Os aplicativos que usam o Output Switcher como seletor no app não vão precisar de permissões de rede local (mais orientações serão fornecidas no quarto trimestre de 2025).
Orientação para desenvolvedores (ativação)
Para ativar as restrições de rede local, faça o seguinte:
- Atualize o dispositivo para uma versão com o Android 25Q2 Beta 3 ou mais recente.
- Instale o app a ser testado.
Ative a flag Appcompat no adb:
adb shell am compat enable RESTRICT_LOCAL_NETWORK <package_name>Reinicialize o dispositivo
Agora, o acesso do app à rede local está restrito, e qualquer tentativa de acesso à rede local vai gerar erros de soquete. Se você estiver usando APIs que realizam operações de rede local fora do processo do app (por exemplo, NsdManager), elas não serão afetadas durante a fase de ativação.
Para restaurar o acesso, conceda ao app a permissão NEARBY_WIFI_DEVICES.
- Verifique se o app declara a permissão
NEARBY_WIFI_DEVICESno manifesto. - Acesse Configurações > Apps > [Nome do aplicativo] > Permissões > Dispositivos por perto > Permitir.
Agora, o acesso do app à rede local será restaurado, e todos os cenários vão funcionar como antes da ativação do app.
Quando a aplicação da proteção de rede local começar, o tráfego de rede do app será afetado da seguinte maneira.
| Permissão | Solicitação de LAN de saída | Solicitação de saída/entrada da Internet | Solicitação de LAN de entrada |
|---|---|---|---|
| Concedido | funciona | funciona | funciona |
| Não concedido | Falhas | funciona | Falhas |
Use o comando a seguir para desativar a flag de compatibilidade do app
adb shell am compat disable RESTRICT_LOCAL_NETWORK <package_name>
Erros
Os erros decorrentes dessas restrições serão retornados ao soquete de chamada sempre que ele invocar o envio ou uma variante de envio para um endereço de rede local.
Exemplo de erros:
sendto failed: EPERM (Operation not permitted)
sendto failed: ECONNABORTED (Operation not permitted)
Definição de rede local
Uma rede local neste projeto se refere a uma rede IP que utiliza uma interface de rede com capacidade de transmissão, como Wi-Fi ou Ethernet, mas exclui conexões de rede celular (WWAN) ou VPN.
As seguintes são consideradas redes locais:
IPv4 :
- 169.254.0.0/16 // Link local
- 100.64.0.0/10 // CGNAT
- 10.0.0.0/8 // RFC1918
- 172.16.0.0/12 // RFC1918
- 192.168.0.0/16 // RFC1918
IPv6 :
- Link-local
- Rotas conectadas diretamente
- Redes stub como Thread
- Várias sub-redes (TBD)
Além disso, os endereços multicast (224.0.0.0/4, ff00::/8) e o endereço de transmissão IPv4 (255.255.255.255) são classificados como endereços de rede local.
Fotos pertencentes ao app
When prompted for photo and video permissions by an app targeting SDK 36 or higher on devices running Android 16 or higher, users who choose to limit access to selected media will see any photos owned by the app pre-selected in the photo picker. Users can deselect any of these pre-selected items, which will revoke the app's access to those photos and videos.