自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
全屏 intent 限制
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
为了防范垃圾广告和凭据钓鱼式攻击,从 Android 14 开始,只能向提供通话和闹钟功能的应用授予用于发送全屏通知的默认 USE_FULL_SCREEN_INTENT
权限。
对于安装在 Android 14 中的所有应用,USE_FULL_SCREEN_INTENT
权限默认处于启用状态。安装后,Google Play 商店会撤消不具备通话或闹钟功能的应用的全屏 intent (FSI) 权限。
对于在搭载 Android 13 或更低版本的手机上安装的应用,USE_FULL_SCREEN_INTENT
权限默认保持启用状态。
用户权限
在 Android 14 中,应用可以使用 NotificationManager#canUseFullScreenIntent()
检查自己能否发送全屏通知。为了获得发送全屏通知的用户权限,应用需要使用 ACTION_MANAGE_APP_USE_FULL_SCREEN_INTENT
启动管理全屏 intent 设置,如图 1 所示:
图 1. 使应用能够发送全屏 intent 的界面。
管理全屏 intent 设置位于特殊应用访问权限下的设置菜单中。借助此界面,用户可以根据需要撤消此权限。
OEM 要求
在 Android 14 中,应用的 FSI 权限默认处于启用状态。原始设备制造商 (OEM) 必须指定哪些应用有资格获得 FSI 权限。OEM 必须确保第三方应用商店使用 PackageInstaller.SessionParams
(特别是结合 PERMISSION_STATE_DEFAULT
、PERMISSION_STATE_DENIED
和 PERMISSION_STATE_GRANTED
参数)为其应用设置 FSI 权限的初始授权状态。
验证
您可以使用 NotificationFullScreenIntentVerifierActivity.java
中的 CTS 验证程序测试和 NotificationManagerTest.java
中的 CTS 测试来验证 FSI 限制。
手动测试
如需手动测试应用的 FSI 限制,请按以下步骤操作:
- 在应用的
AndroidManifest.xml
文件中声明 USE_FULL_SCREEN_INTENT
。
- 使用
ACTION_MANAGE_APP_USE_FULL_SCREEN_INTENT
管理用于开启或关闭 FSI 的设置。
- 在测试手机上,手动切换用户对于全屏通知的权限,如图 1 所示。
- 发送 FSI 通知。
- 针对以下 FSI 权限和显示模式组合,验证全屏通知的外观:
FSI 权限
|
已解锁屏幕
|
已锁定屏幕
|
屏幕外
|
屏幕常亮 (AOD)
|
由用户授予
|
带药丸按钮的常驻浮动通知 (HUN)
|
启动 FSI
|
启动 FSI
|
启动 FSI
|
被用户拒绝
|
带药丸按钮 HUN 显示 60 秒
|
带药丸按钮的 HUN 会在列表中优先显示 60 秒
|
AOD 处于开启状态,显示 60 秒带药丸按钮的 HUN
|
带药丸按钮 HUN 显示 60 秒
|
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-26。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-03-26。"],[],[],null,["# Full-screen intent limits\n\nTo prevent ad spam and credential phishing, starting with Android 14,\nthe default [`USE_FULL_SCREEN_INTENT`](https://developer.android.com/reference/android/Manifest.permission#USE_FULL_SCREEN_INTENT)\npermission to send full-screen notifications can be granted only to apps that\nprovide calling and alarm functionalities.\n\nFor all apps being installed on Android 14, the\n[`USE_FULL_SCREEN_INTENT`](https://developer.android.com/reference/android/Manifest.permission#USE_FULL_SCREEN_INTENT)\npermission is enabled by default. Upon installation, the Google Play Store\nrevokes the full-screen intent (FSI) permission for apps that do not have\ncalling or alarm functionalities.\n\nFor apps installed on phones running versions\nAndroid 13 or lower, the\n[`USE_FULL_SCREEN_INTENT`](https://developer.android.com/reference/android/Manifest.permission#USE_FULL_SCREEN_INTENT)\npermission remains enabled by default.\n\nUser permission\n---------------\n\nWith Android 14, apps can use [`NotificationManager#canUseFullScreenIntent()`](https://developer.android.com/reference/android/app/NotificationManager#canUseFullScreenIntent())\nto check if they can send full-screen notifications. To get user permission to\nsend full-screen notifications, apps use [`ACTION_MANAGE_APP_USE_FULL_SCREEN_INTENT`](https://developer.android.com/reference/android/provider/Settings#ACTION_MANAGE_APP_USE_FULL_SCREEN_INTENT)\nto launch the **Manage full screen intents** setting as shown in Figure 1:\n\n**Figure 1.** UI for enabling apps to send full-screen intents.\n\nThe **Manage full screen intents** setting is in the **Settings** menu under\n**Special App Access**. With this UI, users can revoke this permission if needed.\n\nOEM requirements\n----------------\n\nIn Android 14, FSI permissions for apps are enabled by\ndefault. OEMs must specify which apps qualify for FSI permissions. OEMs must\nensure that third-party app stores set the initial grant states of FSI\npermissions for their apps using\n[`PackageInstaller.SessionParams`](https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams),\nspecifically with the [`PERMISSION_STATE_DEFAULT`](https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#PERMISSION_STATE_DEFAULT), [`PERMISSION_STATE_DENIED`](https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#PERMISSION_STATE_DENIED), and [`PERMISSION_STATE_GRANTED`](https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#PERMISSION_STATE_GRANTED)\nparameters.\n\nValidation\n----------\n\nUse the CTS Verifier test in [`NotificationFullScreenIntentVerifierActivity.java`](https://android.googlesource.com/platform/cts/+/refs/heads/android16-release/apps/CtsVerifier/src/com/android/cts/verifier/notifications/NotificationFullScreenIntentVerifierActivity.java),\nand the CTS test in [`NotificationManagerTest.java`](https://cs.android.com/android/platform/superproject/+/android-latest-release:cts/tests/app/src/android/app/cts/NotificationManagerTest.java;drc=ed156b1d4a7d91675dba1adb9191a92cf439dab0;l=148)\nto validate the FSI limits.\n\n### Manual tests\n\nFollow these steps to manually test FSI limits on your app:\n\n1. Declare [`USE_FULL_SCREEN_INTENT`](https://developer.android.com/reference/android/Manifest.permission#USE_FULL_SCREEN_INTENT) in your app's `AndroidManifest.xml` file.\n2. Use [`ACTION_MANAGE_APP_USE_FULL_SCREEN_INTENT`](https://developer.android.com/reference/android/provider/Settings#ACTION_MANAGE_APP_USE_FULL_SCREEN_INTENT) to manage settings to turn FSI on or off.\n3. On your test phone, manually toggle the user permission for full-screen notifications as shown in Figure 1.\n4. Send an FSI notification.\n5. Validate the appearance of the full-screen notification for the following combinations of FSI permission and display modes:\n\n|--------------------|----------------------------------------------------------|----------------------------------------------------------|---------------------------------------------------|-------------------------------|\n| **FSI permission** | **Unlocked screen** | **Locked screen** | **Off screen** | **Always-on display (AOD)** |\n| Granted by user | Persistent heads-up notification (HUN) with pill buttons | Launch FSI | Launch FSI | Launch FSI |\n| Denied by user | HUN with pill buttons for 60s | HUN with pill buttons shows up first in the list for 60s | AOD turns on, shows HUN with pill buttons for 60s | HUN with pill buttons for 60s |"]]