自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
系统相机
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
在搭载 Android 11 或更高版本的设备上,Android 框架支持系统相机,这些相机设备仅对具有 android.permission.SYSTEM_CAMERA
权限和常规相机权限的进程可见。Android 11 中引入了 android.permission.SYSTEM_CAMERA
权限,其保护级别为 system|signature
。这意味着,只有安装在系统分区上且具有与系统相同的证书或使用该证书进行签名的应用才能获得此权限。第三方公开应用无法访问系统相机。
如果设备制造商希望实现需要访问相机的功能,但这些功能仅限于特权应用或系统应用,系统相机会很有用。
由于获得 android.permission.SYSTEM_CAMERA
权限的系统应用还必须具有 android.permission.CAMERA
权限,因此用户可以选择撤消常规的 CAMERA
权限,以防止此类应用访问设备上的相机。
实现
如需将特定相机设备作为系统相机,相机 HAL 必须在其功能列表中声明 ANDROID_REQUEST_AVAILABLE_CAPABILITIES_SYSTEM_CAMERA
。
如需创建有权访问系统相机的应用,必须在特定于设备的 privapp-permissions.xml
文件中将相应应用列入许可名单,该文件用于指定必须向哪些应用授予 android.permission.SYSTEM_CAMERA
权限。
验证
如需验证公开应用是否无法发现设备上的任何系统相机,请运行 android.permission.cts.Camera2PermissionTest.testSystemCameraDiscovery
CTS 测试。
所有相机 CTS 测试均针对系统的相机设备运行。
本页面上的内容和代码示例受内容许可部分所述许可的限制。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,["# System cameras\n\nOn devices running Android 11 or higher, the Android\nframework supports system\ncameras, which are camera devices that are visible only to processes with the\n`android.permission.SYSTEM_CAMERA` permission and regular camera permissions.\nThe `android.permission.SYSTEM_CAMERA` permission, introduced in\nAndroid 11, has\na protection level of `system|signature`. This means that only apps installed on\nthe system partition with or signed with the same certificate as the system can\nbe granted this permission. Third-party public apps can't access system cameras.\n\nSystem cameras are useful for device manufacturers that want to implement\nfeatures that require access to a camera but are also restricted to privileged\nor system apps.\n\nBecause systems apps that are granted the\n`android.permission.SYSTEM_CAMERA` permission must also have the\n[`android.permission.CAMERA`](https://developer.android.com/reference/android/Manifest.permission#CAMERA)\npermission, users can choose to revoke normal `CAMERA` permissions to prevent\nsuch an app from accessing the cameras on the device.\n\nImplementation\n--------------\n\nTo make a particular camera device a system camera, the camera HAL must\nadvertise\n[`ANDROID_REQUEST_AVAILABLE_CAPABILITIES_SYSTEM_CAMERA`](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/camera/metadata/3.5/types.hal#120)\nin its capabilities list.\n\nTo create an app that has access to a system camera, the app must be allowlisted\nin the device-specific `privapp-permissions.xml` file, which specifies the apps\nthat the\n[`android.permission.SYSTEM_CAMERA`](https://android.googlesource.com/platform/frameworks/base/+/refs/heads/android16-release/core/res/AndroidManifest.xml#1312)\npermission must be granted to.\n\nValidation\n----------\n\nTo verify that no system cameras on the device can be discovered by a public\napp, run the\n`android.permission.cts.Camera2PermissionTest.testSystemCameraDiscovery` CTS\ntest.\n\nAll\n[camera CTS tests](/docs/compatibility/cts/camera-hal#cts_tests)\nrun on system camera devices."]]