自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
系統攝影機
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
在搭載 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 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-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"]],["上次更新時間:2025-07-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."]]