ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
ใช้บริการกล้อง Android
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
บริการกล้อง Android ประกอบด้วยสแต็กกล้องที่ใช้ในอุปกรณ์ยานยนต์ รวมถึงอุปกรณ์รูปแบบอื่นๆ เช่น โทรศัพท์มือถือ แท็บเล็ต และทีวี หากต้องการดูสถาปัตยกรรมโดยรวมของกล้อง โปรดดูหัวข้อกล้อง หน้านี้จะเน้นหัวข้อเฉพาะสำหรับอุปกรณ์ยานยนต์และการทำงานร่วมกับ Android Camera API
เปิดใช้บริการกล้อง Android
หากต้องการเปิดใช้บริการกล้อง Android ในแพลตฟอร์มยานยนต์ ไฟล์ make ของผลิตภัณฑ์ต้องระบุ ENABLE_CAMERA_SERVICE
เป็น true
ลักษณะเฉพาะของกล้องสำหรับยานยนต์
ในบริบทของอุปกรณ์ยานยนต์ HAL ของกล้องต้องมีลักษณะเฉพาะ 2 อย่างสำหรับรูปแบบของยานยนต์โดยเฉพาะ ดังนี้
ในกรณีที่กล้องไม่ได้จัดวางให้สอดคล้องกับตำแหน่งหรือการวางแนวเลนส์ที่เฉพาะเจาะจงอย่างแม่นยำ (ระบุด้วยที่มี *_OTHER
ในลักษณะของ android.automotive.location
หรือ android.automotive.lens.facing
) หรือเมื่อกล้องหลายตัวใช้ตำแหน่งและทิศทางเดียวกัน HAL ของกล้องควรระบุลักษณะเพิ่มเติมเพื่อให้แอประบุตำแหน่งของกล้องได้อย่างแม่นยำ คุณลักษณะเหล่านี้ได้แก่
ให้สิทธิ์เข้าถึงแก่ผู้ใช้ระบบแบบไม่มีส่วนหัว
แอปของระบบและแอปของบุคคลที่หนึ่ง (1P) บางแอปเข้าถึงกล้องในฐานะผู้ใช้ระบบแบบไม่มีส่วนหัว หรือที่เรียกว่าผู้ใช้ 0 ได้ ฟีเจอร์นี้ช่วยให้มั่นใจได้ว่าแอปที่สำคัญต่อความปลอดภัย เช่น กล้องมองหลัง จะสตรีมกล้องต่อไปได้โดยไม่หยุดชะงัก ไม่ว่าผู้ใช้จะสลับไปมาระหว่างแอปต่างๆ ในเบื้องหน้าก็ตาม เฉพาะแอปที่ลงนามในแพลตฟอร์มและมีสิทธิ์ใหม่เท่านั้นandroid.permission.CAMERA_HEADLESS_SYSTEM_USER
จึงจะเข้าถึงกล้องในฐานะผู้ใช้ 0 ได้
สําหรับแอปที่เข้าถึงกล้องในฐานะผู้ใช้ 0 จะต้องใช้ข้อมูลจากกล้องในอุปกรณ์เท่านั้น และจะต้องไม่ส่งออกนอกอุปกรณ์ รวมถึงข้อมูลใดๆ ที่มาจากข้อมูลกล้อง แอปเหล่านี้กำหนดให้ต้องได้รับสิทธิ์ android.permission.CAMERA
ล่วงหน้า และต้องปฏิบัติตามนโยบายสิทธิ์ก่อนให้สิทธิ์ที่ระบุไว้ในข้อกำหนดของ GAS Design for Driving
กำหนดค่ารายการที่อนุญาตด้านความเป็นส่วนตัวของกล้อง
ตอนนี้ผู้ผลิตอุปกรณ์ดั้งเดิม (OEM) สามารถกำหนดค่าแอปกล้องที่เฉพาะเจาะจงให้รวมอยู่ในรายการที่อนุญาตซึ่งให้สิทธิ์เข้าถึงกล้องได้ ไม่ว่าสถานะปุ่มสลับความเป็นส่วนตัวของกล้องจะเป็นอย่างไร ฟีเจอร์นี้ช่วยให้ผู้ใช้ปิดใช้การเข้าถึงกล้องสำหรับแอปบันเทิง เช่น โซเชียลมีเดียและวิดีโอคอนเฟอเรนซ์ ได้ พร้อมกับอนุญาตให้เข้าถึงกล้องสำหรับแอปบางแอปในรายการที่อนุญาต
เฉพาะแอประบบและแอปที่มีสิทธิ์ซึ่งได้รับสิทธิ์ android.permission.CAMERA_PRIVACY_ALLOWLIST
เท่านั้นที่ใช้ฟีเจอร์นี้ได้
พาร์ทเนอร์ Google Automotive Services (GAS) ต้องส่งแอปในรายการที่อนุญาตเพื่อรับการตรวจสอบและปฏิบัติตามนโยบายรายการที่อนุญาตด้านความเป็นส่วนตัว ดูข้อมูลเพิ่มเติมได้ที่Android สำหรับรถยนต์
เพิ่มแอปไปยังรายการที่อนุญาต
ในไดเรกทอรี etc/sysconfig
ให้ทำดังนี้
เพิ่มชื่อแพ็กเกจของแอปในไฟล์ XML การกำหนดค่าระบบ โดยทำดังนี้
<!-- In an xml file under etc/sysconfig —>
<!--
Allowlisted packages for the camera privacy toggle. Users will not be able to turn the privacy on for these packages as OEM requires camera access for these packages to preserve user safety.
-->
<config>
<camera-privacy-allowlisted-app package="package_name" />
</config>
เพิ่ม URL ของการเปิดเผยนโยบายความเป็นส่วนตัวของแอปลงใน AndroidManifest.xml
ชื่อของ meta-data
ควรเป็น privacy_policy
<meta-data android:name="privacy_policy" android:value= privacy policy URL/>
โดยค่าเริ่มต้น ปุ่มเปิด/ปิดความเป็นส่วนตัวของกล้องสำหรับแอปในรายการที่อนุญาตหรือแอปที่ต้องใช้งานจะซ่อนอยู่ใน UI การตั้งค่าความเป็นส่วนตัว อย่างไรก็ตาม OEM สามารถลบล้างลักษณะการทำงานนี้ได้ด้วยการตั้งค่า Flag ต่อไปนี้เป็น TRUE
ซึ่งจะช่วยให้ OEM ปรับแต่งระดับการมองเห็นของปุ่มสลับความเป็นส่วนตัวของกล้องสำหรับแอปที่จำเป็นตามค่ากำหนดได้
<!-- Whether to show the toggle to turn on the camera privacy for required apps -->
<bool name="config_show_camera_required_apps_toggle">false</bool>
รับสิทธิ์ทดลองใช้กล้องก่อนเปิดตัว
แอปที่เน้นความปลอดภัยและคำนึงถึงเวลาบางแอปจะเข้าถึงกล้องได้ก่อนที่กระบวนการบูตของ Android จะเสร็จสมบูรณ์ อย่างไรก็ตาม สิทธิ์เข้าถึงนี้จะมอบให้แก่ไคลเอ็นต์ที่มีสิทธิ์เท่านั้นที่มี UID AID_AUTOMOTIVE_EVS
ดูข้อมูลเพิ่มเติมเกี่ยวกับการกำหนด UID ที่เฉพาะเจาะจงให้กับแอปเนทีฟได้ที่การควบคุมการเข้าถึงแบบมีการพิจารณา (DAC)
การทดลองใช้กล้องก่อนเปิดตัวนี้จำกัดไว้สำหรับกล้องของระบบที่ติดตั้งไว้ที่ภายนอกตัวถังรถ
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-06-12 UTC
[[["เข้าใจง่าย","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-06-12 UTC"],[],[],null,["# Use the Android Camera Service\n\nThe Android Camera Service comprises the camera stack used in automotive\ndevices, as well as in other form factors such as mobile phones, tablets,\nand TVs. To view the overall camera architecture, see\n[Camera](/docs/core/camera). This page focuses on topics specific to automotive\ndevices, and working with the [Android Camera API](https://developer.android.com/reference/android/hardware/camera2/package-summary).\n\nEnable Android Camera Service\n-----------------------------\n\nTo enable the Android Camera Service on the automotive platform, the product's\nmakefile must specify `ENABLE_CAMERA_SERVICE` as `true`.\n\nAutomotive-specific camera characteristics\n------------------------------------------\n\nIn the context of automotive devices, the camera HAL must include two\ndistinctive characteristics specific to the automotive form factor:\n\n| Name | Description |\n|-------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------|\n| [android.automotive.location](https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics#AUTOMOTIVE_LOCATION) | Specifies the positioning of cameras in relation to the vehicle's body frame. |\n| [android.automotive.lens.facing](https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics#AUTOMOTIVE_LENS_FACING) | Indicates which direction a camera lens is facing relative to the vehicle body frame and passenger seats. |\n\nIn situations when cameras don't precisely align with specific location or lens\norientation (indicated by the presence of `*_OTHER` in the\n[`android.automotive.location`](https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics#AUTOMOTIVE_LOCATION) or [`android.automotive.lens.facing`](https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics#AUTOMOTIVE_LENS_FACING)\ncharacteristics), or when multiple cameras share the same location and\ndirection, the camera HAL should provide additional characteristics to enable\napps to accurately determine the camera's location. These characteristics\ninclude:\n\n- [`android.lens.poseReference`](https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics#LENS_POSE_REFERENCE)\n- [`android.lens.poseRotation`](https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics#LENS_POSE_ROTATION)\n- [`android.lens.poseTranslation`](https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics#LENS_POSE_TRANSLATION)\n\nGrant access to the Headless System User\n----------------------------------------\n\nCertain system and first-party (1P) apps can access the camera as the Headless\nSystem User, also known as User 0. This feature ensures that safety-critical\napps, such as the rear-view camera, can continue camera streaming without\ninterruption, regardless of foreground user switching. Only apps that are\nplatform-signed and hold the new permission\n`android.permission.CAMERA_HEADLESS_SYSTEM_USER` can access the camera as\nUser 0.\n\nFor apps accessing cameras as User 0, the camera data MUST be consumed locally\nand MUST not be transmitted off the device, including any data derived from the\ncamera data. These apps require that the `android.permission.CAMERA` permission\nbe pre-granted and must adhere to the pre-grant permission policy outlined in\n[Design for Driving](https://developers.google.com/cars) for GAS requirements.\n\nConfigure a camera privacy allowlist\n------------------------------------\n\nOriginal equipment manufacturers (OEMs) can now configure specific camera apps\nto be included on an allowlist that grants camera access regardless of the\ncamera privacy toggle's status. This feature enables users to disable camera\naccess for entertainment apps, such as social media and video conferencing,\nwhile simultaneously permitting camera access for certain allowlisted apps.\n\nOnly system and privileged apps granted the\n`android.permission.CAMERA_PRIVACY_ALLOWLIST` permission can use this feature.\nGoogle Automotive Services (GAS) partners must submit their allowlisted apps\nfor review and comply with the privacy allowlist policy. To learn more, see\n[Android for Cars](https://developers.google.com/cars).\n\n### Add an app to the allowlist\n\nIn the `etc/sysconfig` directory:\n\n1. Add the app's package name in a system configuration XML file:\n\n \u003c!-- In an xml file under etc/sysconfig ---\u003e\n\n \u003c!--\n Allowlisted packages for the camera privacy toggle. Users will not be able to turn the privacy on for these packages as OEM requires camera access for these packages to preserve user safety.\n --\u003e\n\n \u003cconfig\u003e\n \u003ccamera-privacy-allowlisted-app package=\"package_name\" /\u003e\n \u003c/config\u003e\n\n2. Add the app's URL of privacy policy disclosure to `AndroidManifest.xml`.\n The name of the `meta-data` should be `privacy_policy`.\n\n \u003cmeta-data android:name=\"privacy_policy\" android:value= privacy policy URL/\u003e\n\nBy default, the camera privacy toggle for allowlisted apps or required apps is\nhidden in the **Privacy Settings** UI. However, OEMs can override this behavior\nby setting the following flag to `TRUE`. This allows OEMs to customize the\nvisibility of the camera privacy toggle for the required apps based on their\npreferences. \n\n \u003c!-- Whether to show the toggle to turn on the camera privacy for required apps --\u003e\n\n \u003cbool name=\"config_show_camera_required_apps_toggle\"\u003efalse\u003c/bool\u003e\n\nGet early camera access\n-----------------------\n\nSpecific time-sensitive and safety-oriented apps can access the camera before\nthe Android boot process is finished. However, this access is exclusively\ngranted to privileged clients with the `UID AID_AUTOMOTIVE_EVS`. To learn more\nabout assigning a specific UID to a native app,\nsee [Discretionary access control (DAC)](/docs/core/permissions/filesystem).\nThis early access to the camera is limited to system cameras positioned on the\nexterior of the vehicle's body."]]