自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
受限的屏幕读取
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
在 Android 9 及更低版本中,会向具有签名权限或特许权限的应用授予屏幕缓冲区捕获权限(READ_FRAME_BUFFER
、CAPTURE_VIDEO_OUTPUT
和 CAPTURE_SECURE_VIDEO_OUTPUT
)。这支持进行无缝的屏幕缓冲区捕获 activity,例如截取屏幕截图或录制设备的屏幕内容。
从 Android 10 开始,为防止应用以静默方式访问设备的屏幕内容,不再向特权应用授予视频捕获权限。未经用户同意的访问会受到限制,并仅向具有签名权限的应用授予。运行依赖此静默捕获功能的特权应用的设备制造商会受到这项要求的影响。
从 Android 10 开始,如果您没有列出的屏幕缓冲区捕获签名权限,则应用在未经用户同意的情况下无法捕获屏幕缓冲区。要确保您拥有所需权限,请在清单文件中搜索之前列出的签名权限。将所有受影响的特权应用(可以通过搜索找到)迁移到 MediaProjectionManager 类,通过该类,任何第三方应用都可以在没有权限但征得用户同意的情况下捕获屏幕缓冲区。应用启动此流程时,它会显示一个对话框,提示用户允许屏幕捕获。在 Android 10 中,此对话框包含以下新功能:
- 提供更明显的与投射图标的关联。
- 提供有关数据(可以访问)敏感度的更多信息。
- 防止用户在将来启动时隐藏该对话框:该对话框每次都会显示。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[[["易于理解","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-07-27。"],[],[],null,["# Restricted screen reading\n\nIn Android 9 and lower, the screen buffer\ncapture permissions (`READ_FRAME_BUFFER`,\n`CAPTURE_VIDEO_OUTPUT`, and\n`CAPTURE_SECURE_VIDEO_OUTPUT`) were granted to apps that\nhad *either* signature or privileged permissions. This\nenabled seamless screen-buffer capturing activities, such as\ntaking screenshots, or recording a device's screen contents.\n\nStarting in Android 10, to prevent\nsilent access to a device's screen contents, video capture\npermissions aren't granted to privileged apps. Access\nwithout user consent is [restricted](https://developer.android.com/about/versions/11/privacy/permissions),\nand granted only to apps that have signature\npermissions. Device manufacturers that run privileged apps relying\non this silent capture functionality are affected by this\nrequirement.\n\nAs of Android 10 if you\ndon't have the listed screen-buffer capture signature permissions, your\napp can't capture screen buffers without user consent. To\nensure you have the permissions you need, search your manifest file\nfor the previously listed signature permissions. Migrate all affected privileged\napps (as found in your search) to the [MediaProjectionManager](https://developer.android.com/reference/android/media/projection/MediaProjectionManager)\nclass, which allows any third party app\nto capture screen buffers without permissions, but with user\nconsent. This flow displays a dialog that prompts the user to\nallow screen capturing when an app initiates it. In Android 10,\nnew features of the dialog include the following:\n\n- Provides more visible associations with the **Cast** icon.\n- Provides more information about the sensitivity of the data that can be accessed.\n- Prevents users from hiding the dialog on future initiations: the dialog shows every time."]]