2025 年 3 月 27 日より、AOSP のビルドとコントリビューションには aosp-main
ではなく android-latest-release
を使用することをおすすめします。詳細については、AOSP の変更をご覧ください。
Android カメラサービスを使用する
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Android カメラサービスは、車載デバイスのほかスマートフォンやタブレット、テレビなどのフォーム ファクタでも使用するカメラスタックで構成されています。カメラの全体的なアーキテクチャについては、カメラをご覧ください。このページでは、車載デバイスに特化したトピックと、Android Camera API の活用方法を取り上げています。
Android カメラサービスを有効にする
車載プラットフォームで Android カメラサービスを有効にするには、製品の makefile で ENABLE_CAMERA_SERVICE
を true
に指定する必要があります。
車載専用カメラの特性
車載デバイスに関して言うと、カメラ HAL は、車載フォーム ファクタに固有の 2 つの特性を備えている必要があります。
特定の位置情報やレンズの向きに合わせてカメラが正確に調整されていない場合(android.automotive.location
または android.automotive.lens.facing
特性に *_OTHER
が示されます)、あるいは複数のカメラで同じ位置情報と方向を共有している場合、カメラ 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 に表示されません。ただし、次のフラグを TRUE
に設定することにより、OEM はこの動作をオーバーライドできます。これにより 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 をネイティブ アプリに割り当てる方法については、任意アクセス制御(DAS)をご覧ください。カメラに早期アクセスできるのは、車体の外部に配置されたシステムカメラに限定されています。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-03-26 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-03-26 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."]]