참조 구현은 2계층 아키텍처에 기반합니다. 상위 계층 DefaultVehicleHal에서는 VHAL AIDL 인터페이스를 구현하고 모든 하드웨어 기기에 일반적인 VHAL 로직을 제공합니다. 하위 계층 FakeVehicleHardware에서는 IVehicleHardware 인터페이스를 구현합니다. 이 클래스는 실제 하드웨어 또는 차량 버스와 상호작용하는 VHAL 로직을 시뮬레이션하며 기기별로 다릅니다. 원하는 경우 공급업체는 이 동일한 아키텍처를 조정하고 동일한 DefaultVehicleHal 클래스를 재사용하고(메서드를 덮어쓰도록 확장) 자체 IVehicleHardware 구현을 제공할 수 있습니다.
권한을 확인합니다. checkReadPermission 및 checkWritePermission 함수를 참고하세요.
주기적으로 IVehicleHardware.checkHealth를 호출하고 하트비트 신호를 전송합니다(checkHealth 함수 참고).
IVehicleHardware는 VHAL의 하드웨어별 구현을 나타내는 데 사용되는 일반 인터페이스입니다. IVehicleHardware의 참조 구현은 인메모리 맵을 사용하여 속성 값을 저장하고 실제 차량 버스와 통신하지 않는 FakeVehicleHardware입니다. 에뮬레이터에서 실행되기 위한 것이며 하드웨어 관련 종속 항목이 없습니다. 공급업체 구현에서는 이를 그대로 사용하면 안 되며 차량 버스 관련 로직을 추가해야 합니다.
Android 14에서 FakeVehicleHardware는 초기화 중 런타임에 JSON 스타일 구성 파일이 포함된 기기의 /vendor/etc/automotive/vhalconfig/ 폴더에서 지원되는 속성 구성을 읽습니다. 구성 파일 형식 및 구성 파일 콘텐츠는 참조 VHAL 리드미 파일을 확인하세요.
FakeVehicleHardware는 테스트를 위한 구성 파일 재정의도 지원합니다. 시스템 속성 persist.vendor.vhal_init_value_override가 설정된 경우 기기의 /vendor/etc/automotive/vhaloverride/ 폴더에 있는 구성 파일을 사용하여 기존 구성을 재정의합니다. 공급업체 구현에서는 VHAL 지원 속성 구성이 하드 코딩되지 않고 시작 시간에 동적으로 결정될 수 있도록 유사한 접근 방식을 사용할 수 있습니다.
차량 속성 구성은 기기가 시작되고 나면 정적이어야 합니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2024-05-07(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"]],["최종 업데이트: 2024-05-07(UTC)"],[],[],null,["# Reference implementation\n\nWe provide a\n[reference implementation](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/automotive/vehicle/aidl/impl/current)\nfor the AIDL VHAL. The main service thread is implemented\nat\n[`VehicleService.cpp`](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/automotive/vehicle/aidl/impl/current/vhal/src/VehicleService.cpp).\nThe VHAL interface implementation is located at\n[`DefaultVehicleHal.cpp`](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/automotive/vehicle/aidl/impl/current/vhal/src/DefaultVehicleHal.cpp).\n\n\nThe reference implementation is based on a two-layer architecture. On the upper layer,\n`DefaultVehicleHal`, implements VHAL AIDL interface and provides VHAL logic\ngeneric to all hardware devices. On the lower layer, `FakeVehicleHardware`,\nimplements the `IVehicleHardware` interface. This class simulates the VHAL logic\nof interacting with actual hardware or vehicle bus and is device-specific. Optionally, vendors\ncan adapt this same architecture, reuse the same `DefaultVehicleHal` class (extending\nit to overwrite a method), and provide their own `IVehicleHardware` implementation.\n**Figure 1.** VHAL reference implementation\n\n[`DefaultVehicleHal`](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/automotive/vehicle/aidl/impl/current/vhal/src/DefaultVehicleHal.cpp)\ncontains the following logic, which is considered to be generic and can apply to any VHAL\nimplementation.\n\n- Implements the `IVehicle` interface.\n- Performs basic input checks, including a check for duplicate IDs.\n- Allocates client objects (for example, `GetValuesClient`) for each operation for each binder client, and adds each to a global pool.\n- Manages async callbacks logic, such as adding a pending request to a pending request pool. Resolves pending requests when we receive the results or returns error when one of the pending requests times out.\n- Serializes and deserializes `LargeParcelable` (see `ParcelableUtils.h`).\n- Manages subscription (see `SubscriptionManager.h`).\n- Checks permissions. (See the `checkReadPermission` and `checkWritePermission` functions).\n- Periodically calls `IVehicleHardware.checkHealth` and sends heartbeat signals (see the `checkHealth` function).\n\n[`IVehicleHardware`](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/automotive/vehicle/aidl/impl/current/hardware/include/IVehicleHardware.h)\nis a generic interface used to represent a VHAL's hardware-specific\nimplementation. The reference implementation for `IVehicleHardware` is\n[`FakeVehicleHardware`](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/automotive/vehicle/aidl/impl/current/fake_impl/hardware/src/FakeVehicleHardware.cpp),\nwhich uses an in-memory map to store property value and does\nnot communicate with an actual vehicle bus. It's intended to run on an emulator and have no\nhardware-specific dependencies. Vendor implementations must not use it as-is and must add\nvehicle bus-specific logic.\n\nStarting in Android 14, `FakeVehicleHardware` reads the supported property config at run-time\nduring initialization from the device's `/vendor/etc/automotive/vhalconfig/` folder,\nwhich contains a JSON-style config file. See the\n[reference VHAL README file](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/automotive/vehicle/aidl/impl/current/default_config/config/README.md)\nfor config file format and config file content.\n\n`FakeVehicleHardware` also supports config file override for testing. If the\nsystem property `persist.vendor.vhal_init_value_override` is set (this property must be\nset at build time or very early during boot before VHAL initialization), it uses the config\nfile from the `/vendor/etc/automotive/vhaloverride/` folder on the device to override\nthe existing configuration. A vendor implementation can use a similar approach so that the VHAL-\nsupported property configuration is not hard-coded and can be dynamically decided at start time.\nThe list of vehicle property configs must be static after VHAL is initialized.\n\nStarting in Android 16, [`GRPCVehicleHardware`](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/automotive/vehicle/aidl/impl/current/grpc/GRPCVehicleHardware.cpp)\nprovides another reference `IVehicleHardware` implementation. This implementation\nassumes there is a separate server running on a remote machine or VM which contains the property\nhandling logic. The VHAL running on AAOS devices acts as a proxy that forwards requests to\nthe remote server. See [grpc](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/automotive/vehicle/aidl/impl/current/README.md#grpc)\nfor more details."]]