Come le release precedenti, Android 16 include modifiche al comportamento che potrebbero influire sulla tua app. Le seguenti modifiche al comportamento si applicano esclusivamente alle app che hanno come target Android 16 o versioni successive. Se la tua app ha come target Android 16 o versioni successive, devi modificarla per supportare questi comportamenti, ove applicabile.
Assicurati di esaminare anche l'elenco delle modifiche al comportamento che interessano tutte le app
in esecuzione su Android 16, indipendentemente dal targetSdkVersion della tua app.
Esperienza utente e UI di sistema
Android 16 (livello API 36) include le seguenti modifiche volte a creare un'esperienza utente più coerente e intuitiva.
Ritiro del consenso alla visualizzazione edge-to-edge
Android 15 强制执行全屏显示,但您的应用可以通过将 R.attr#windowOptOutEdgeToEdgeEnforcement 设置为 true 来选择停用此功能。对于以 Android 16(API 级别 36)为目标平台的应用,R.attr#windowOptOutEdgeToEdgeEnforcement 已被废弃并停用,并且您的应用无法选择不采用从边缘到边缘的布局。
- 如果您的应用以 Android 16(API 级别 36)为目标平台,并且在 Android 15 设备上运行,则
R.attr#windowOptOutEdgeToEdgeEnforcement会继续正常运行。 - 如果您的应用以 Android 16(API 级别 36)为目标平台,并且在 Android 16 设备上运行,则
R.attr#windowOptOutEdgeToEdgeEnforcement会被停用。
如需在 Android 16 中进行测试,请确保您的应用支持无边框设计,并移除所有 R.attr#windowOptOutEdgeToEdgeEnforcement 用法,以便您的应用在 Android 15 设备上也能支持无边框设计。如需支持从边缘到边缘的显示,请参阅 Compose 和 Views 指南。
Migrazione o disattivazione richieste per la funzionalità Indietro predittivo
对于以 Android 16(API 级别 36)或更高版本为目标平台且在搭载 Android 16 或更高版本的设备上运行的应用,预测性返回系统动画(返回主屏幕、跨任务和跨 activity)默认处于启用状态。此外,系统不再调用 onBackPressed,也不再调度 KeyEvent.KEYCODE_BACK。
如果您的应用会拦截返回事件,但您尚未迁移到预测性返回,请更新应用以使用受支持的返回导航 API,或者通过在应用的 AndroidManifest.xml 文件的 <application> 或 <activity> 标记中将 android:enableOnBackInvokedCallback 属性设置为 false 来暂时选择停用。
API per i caratteri eleganti ritirate e disabilitate
Le app che hanno come target Android 15 (livello API 35) hanno l'attributo
elegantTextHeight
TextView impostato su true per
impostazione predefinita, sostituendo il carattere compatto con uno molto più leggibile. Puoi
ignorare questa impostazione impostando l'attributo elegantTextHeight su false.
Android 16 ritira l'attributo
elegantTextHeight
e l'attributo verrà ignorato una volta che la tua app avrà come target Android 16. I "caratteri
dell'interfaccia utente" controllati da queste API verranno ritirati, pertanto devi adattare tutti
i layout per garantire il rendering del testo coerente e a prova di futuro in arabo, laotiano,
birmano, tamil, gujarati, kannada, malayalam, odia, telugu o tailandese.
elegantTextHeight per le app che hanno come target Android
14 (livello API 34) e versioni precedenti o per le app che hanno come target Android 15 (livello API 35)
che hanno sostituito il valore predefinito impostando l'attributo elegantTextHeight su false.
elegantTextHeight per le app che hanno come target Android
16 (livello API 36) o per le app che hanno come target Android 15 (livello API 35) che non
hanno eseguito l'override del valore predefinito impostando l'attributo elegantTextHeight
su false.Funzionalità di base
Android 16 (livello API 36) include le seguenti modifiche che modificano o espandono varie funzionalità di base del sistema Android.
Ottimizzazione della pianificazione del lavoro a tariffa fissa
在以 Android 16 为目标平台之前,如果 scheduleAtFixedRate 因不在有效的进程生命周期内而错过了任务执行,则当应用返回到有效的生命周期时,所有错过的执行会立即执行。
以 Android 16 为目标平台时,当应用返回到有效的生命周期时,系统会立即执行最多 1 次未执行的 scheduleAtFixedRate 执行。此行为变更预计会提升应用性能。在您的应用中测试此行为,检查您的应用是否受到影响。您还可以使用应用兼容性框架并启用 STPE_SKIP_MULTIPLE_MISSED_PERIODIC_TASKS 兼容性标志进行测试。
Fattori di forma dei dispositivi
Android 16 (livello API 36) include le seguenti modifiche per le app quando vengono visualizzate su dispositivi con schermi di grandi dimensioni.
Layout adattivi
现在,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>
Salute e fitness
Android 16 (livello API 36) include le seguenti modifiche relative ai dati di salute e fitness.
Autorizzazioni per salute e fitness
对于以 Android 16(API 级别 36)或更高版本为目标平台的应用,BODY_SENSORS 权限使用 android.permissions.health 下更精细的权限,健康数据共享也使用这些权限。自 Android 16 起,凡是以前需要具有 BODY_SENSORS 或 BODY_SENSORS_BACKGROUND 权限的 API,现在都需要获取相应的 android.permissions.health 权限。这会影响以下数据类型、API 和前台服务类型:
- 从 Wear OS 上的健康服务中获取
HEART_RATE_BPM - 来自 Android Sensor Manager 的
Sensor.TYPE_HEART_RATE - 在 Wear OS 上,
ProtoLayout中的heartRateAccuracy和heartRateBpm FOREGROUND_SERVICE_TYPE_HEALTH,其中需要使用相应的android.permission.health权限来代替BODY_SENSORS
如果您的应用使用这些 API,则应请求相应的精细权限:
- 对于使用期间的心率、血氧饱和度或体表温度监测:请求
android.permissions.health下的精细权限,例如READ_HEART_RATE,而不是BODY_SENSORS。 - 对于后台传感器访问权限:请求
READ_HEALTH_DATA_IN_BACKGROUND而不是BODY_SENSORS_BACKGROUND。
这些权限与用于保护对 Health Connect(Android 健康、健身和身心状态数据存储区)中读取数据的访问权限相同。
移动应用
迁移到使用 READ_HEART_RATE 和其他精细权限的移动应用还必须声明 activity 以显示应用的隐私权政策。此要求与健康数据共享的要求相同。
Connettività
Android 16 (livello API 36) include le seguenti modifiche nello stack Bluetooth per migliorare la connettività con i dispositivi periferici.
Nuovi intent per gestire la perdita dell'accoppiamento e le modifiche alla crittografia
作为改进了对键值对丢失的处理的一部分,Android 16 还引入了 2 个新 intent,以便应用更好地了解键值对丢失和加密更改。
以 Android 16 为目标平台的应用现在可以:
- 在检测到远程键盘连接丢失时接收
ACTION_KEY_MISSINGintent,以便提供更具信息量的用户反馈并采取适当的措施。 - 每当链接的加密状态发生变化时,都会收到
ACTION_ENCRYPTION_CHANGEintent。这包括加密状态更改、加密算法更改和加密密钥大小更改。如果应用在稍后收到ACTION_ENCRYPTION_CHANGEintent 时成功加密了链接,则必须将该绑定视为已恢复。
适应不同的 OEM 实现
虽然 Android 16 引入了这些新 intent,但其实现和广播可能会因不同的设备制造商 (OEM) 而异。为了确保您的应用在所有设备上都能提供一致且可靠的体验,开发者应设计其绑定丢失处理机制,以妥善适应这些潜在的变化。
我们建议您采用以下应用行为:
如果广播
ACTION_KEY_MISSINGintent:系统会断开 ACL(异步无连接)链接,但会保留设备的配对信息(如此处所述)。
您的应用应将此 intent 用作检测配对丢失的主要信号,并在发起设备忘记或重新配对之前引导用户确认远程设备是否在范围内。
如果设备在收到
ACTION_KEY_MISSING后断开连接,您的应用应谨慎重新连接,因为设备可能已不再与系统绑定。如果未广播
ACTION_KEY_MISSINGintent:ACL 链接将保持连接状态,系统会移除设备的配对信息,与 Android 15 中的行为相同。
在这种情况下,您的应用应继续使用与之前的 Android 版本相同的现有配对丢失处理机制,以检测和管理配对丢失事件。
Nuovo modo per rimuovere l'associazione Bluetooth
现在,以 Android 16 为目标平台的所有应用都可以使用 CompanionDeviceManager 中的公共 API 解除蓝牙设备配对。如果配套设备作为 CDM 关联进行管理,则应用可以在关联的设备上使用新的 removeBond(int) API 触发蓝牙配对的移除。该应用可以通过监听蓝牙设备广播事件 ACTION_BOND_STATE_CHANGED 来监控配对状态变化。
Sicurezza
Android 16 (livello API 36) include le seguenti modifiche alla sicurezza.
Blocco della versione di MediaStore
对于以 Android 16 或更高版本为目标平台的应用,MediaStore#getVersion() 现在将是每个应用的唯一标识。这会从版本字符串中移除标识属性,以防止滥用和用于指纹识别技术。应用不应对此版本的格式做出任何假设。在使用此 API 时,应用应已处理版本变更,并且在大多数情况下无需更改其当前行为,除非开发者尝试推断超出此 API 预期范围的其他信息。
Intent più sicuri
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, shifts control 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:")
Filtro delle chiamate di sistema della GPU
To harden the Mali GPU surface, Mali GPU IOCTLs that have been deprecated or are intended solely for GPU development have been blocked in production builds. Additionally, IOCTLs used for GPU profiling have been restricted to the shell process or debuggable applications. Refer to the SAC update for more details on the platform-level policy.
This change takes place on Pixel devices using the Mali GPU (Pixel 6-9). Arm
has provided official categorization of their IOCTLs in
Documentation/ioctl-categories.rst of their r54p2 release. This
list will continue to be maintained in future driver releases.
This change does not impact supported graphics APIs (including Vulkan and OpenGL), and is not expected to impact developers or existing applications. GPU profiling tools such as the Streamline Performance Analyzer and the Android GPU Inspector won't be affected.
Testing
If you see a SELinux denial similar to the following, it is likely your application has been impacted by this change:
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
If your application needs to use blocked IOCTLs, please file a bug and assign it to android-partner-security@google.com.
FAQ
Does this policy change apply to all OEMs? This change will be opt-in, but available to any OEMs who would like to use this hardening method. Instructions for implementing the change can be found in the implementation documentation.
Is it mandatory to make changes in the OEM codebase to implement this, or does it come with a new AOSP release by default? The platform-level change will come with a new AOSP release by default. Vendors may opt-in to this change in their codebase if they would like to apply it.
Are SoCs responsible for keeping the IOCTL list up to date? For example, if my device uses an ARM Mali GPU, would I need to reach out to ARM for any of the changes? Individual SoCs must update their IOCTL lists per device upon driver release. For example, ARM will update their published IOCTL list upon driver updates. However, OEMs should make sure that they incorporate the updates in their SEPolicy, and add any selected custom IOCTLs to the lists as needed.
Does this change apply to all Pixel in-market devices automatically, or is a user action required to toggle something to apply this change? This change applies to all Pixel in-market devices using the Mali GPU (Pixel 6-9). No user action is required to apply this change.
Will use of this policy impact the performance of the kernel driver? This policy was tested on the Mali GPU using GFXBench, and no measurable change to GPU performance was observed.
Is it necessary for the IOCTL list to align with the current userspace and kernel driver versions? Yes, the list of allowed IOCTLs must be synchronized with the IOCTLs supported by both the userspace and kernel drivers. If the IOCTLs in the user space or kernel driver are updated, the SEPolicy IOCTL list must be updated to match.
ARM has categorized IOCTLs as 'restricted' / 'instrumentation', but we want to use some of them in production use-cases, and/or deny others. Individual OEMs/SoCs are responsible for deciding on how to categorize the IOCTLs they use, based on the configuration of their userspace Mali libraries. ARM's list can be used to help decide on these, but each OEM/SoC's use-case may be different.
Privacy
Android 16 (livello API 36) include le seguenti modifiche alla privacy.
Autorizzazione di accesso alla rete locale
具有 INTERNET 权限的任何应用都可以访问局域网上的设备。
这使得应用可以轻松连接到本地设备,但也存在隐私影响,例如形成用户指纹,以及成为位置信息的代理。
本地网络保护项目旨在通过在新的运行时权限后限制对本地网络的访问,来保护用户的隐私。
发布计划
这项变更将在 25Q2 和 26Q2 这两个版本之间部署。 开发者必须遵循 25Q2 的相关指南并分享反馈,因为这些保护措施将在后续 Android 版本中强制执行。此外,他们还需要按照以下指南更新依赖于隐式本地网络访问权限的场景,并为用户拒绝和撤消新权限做好准备。
影响
在当前阶段,LNP 是一项选择启用功能,这意味着只有选择启用的应用会受到影响。选择启用阶段的目标是让应用开发者了解应用的哪些部分依赖于隐式本地网络访问权限,以便他们为下一个版本做好权限保护准备。
如果应用使用以下方式访问用户的本地网络,则会受到影响:
- 在本地网络地址(例如 mDNS 或 SSDP 服务发现协议)上直接或通过库使用原始套接字
- 使用可访问本地网络的框架级类(例如 NsdManager)
向本地网络地址发送流量和从本地网络地址接收流量需要本地网络访问权限。下表列出了一些常见情况:
| 应用低级层网络操作 | 需要本地网络权限 |
|---|---|
| 建立出站 TCP 连接 | 是 |
| 接受传入的 TCP 连接 | 是 |
| 发送 UDP 单播、多播、广播 | 是 |
| 接收传入的 UDP 单播、多播、广播 | 是 |
这些限制是在网络堆栈深处实现的,因此适用于所有网络 API。这包括在原生代码或受管理代码中创建的套接字、Cronet 和 OkHttp 等网络库,以及基于这些库实现的任何 API。尝试解析本地网络上的服务(即带有 .local 后缀的服务)将需要本地网络权限。
上述规则的例外情况:
- 如果设备的 DNS 服务器位于本地网络上,则进出该服务器(位于端口 53)的流量不需要本地网络访问权限。
- 如果应用使用输出切换器作为其应用内选择器,则无需本地网络权限(更多指南将在 2025 年第 4 季度发布)。
开发者指南(选择启用)
如需选择启用本地网络限制,请执行以下操作:
- 将设备刷写到 25Q2 Beta 3 或更高版本的 build。
- 安装要测试的应用。
在 adb 中切换 Appcompat 标志:
adb shell am compat enable RESTRICT_LOCAL_NETWORK <package_name>重启设备
现在,您的应用对本地网络的访问受到限制,任何访问本地网络的尝试都会导致套接字错误。如果您使用的 API 在应用进程之外执行本地网络操作(例如:NsdManager),在选择启用阶段,这些 API 不会受到影响。
如需恢复访问权限,您必须向应用授予 NEARBY_WIFI_DEVICES 权限。
- 确保应用在其清单中声明了
NEARBY_WIFI_DEVICES权限。 - 依次前往设置 > 应用 > [应用名称] > 权限 > 附近的设备 > 允许。
现在,应用对本地网络的访问权限应该已恢复,并且所有场景都应像选择启用应用之前一样正常运行。
本地网络保护功能开始强制执行后,应用的网络流量将受到以下影响。
| 权限 | 出站 LAN 请求 | 出站/入站互联网请求 | 入站 LAN 请求 |
|---|---|---|---|
| 已授予 | Works | Works | Works |
| 未授予 | 最差排行榜 | Works | 最差排行榜 |
使用以下命令切换关闭应用兼容性标志
adb shell am compat disable RESTRICT_LOCAL_NETWORK <package_name>
错误
每当调用套接字调用 send 或 send 变体向本地网络地址发送数据时,系统都会向该套接字返回因这些限制而产生的错误。
错误示例:
sendto failed: EPERM (Operation not permitted)
sendto failed: ECONNABORTED (Operation not permitted)
本地网络定义
此项目中的本地网络是指使用支持广播的网络接口(例如 Wi-Fi 或以太网)的 IP 网络,但不包括移动网络 (WWAN) 或 VPN 连接。
以下网络被视为本地网络:
IPv4:
- 169.254.0.0/16 // 链路本地
- 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:
- 链路本地
- 直接连接的路线
- Thread 等桩网络
- 多个子网(待定)
此外,多播地址 (224.0.0.0/4、ff00::/8) 和 IPv4 广播地址 (255.255.255.255) 都归类为本地网络地址。
Foto di proprietà dell'app
当面向 SDK 36 或更高版本的应用在搭载 Android 16 或更高版本的设备上提示用户授予照片和视频权限时,如果用户选择限制对所选媒体的访问权限,则会在照片选择器中看到该应用拥有的所有照片。用户可以取消选择任何这些预选项,这会撤消该应用对这些照片和视频的访问权限。