Kể từ ngày 27 tháng 3 năm 2025, bạn nên sử dụng android-latest-release thay vì aosp-main để xây dựng và đóng góp cho AOSP. Để biết thêm thông tin, hãy xem phần Thay đổi đối với AOSP.
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Để di chuyển quá trình triển khai VHAL HIDL hiện có sang VHAL AIDL, hãy sử dụng cấu trúc triển khai tham chiếu AIDL để triển khai giao diện IVehicleHardware.
Nếu cách triển khai HIDL hiện tại cũng tuân theo cách triển khai tham chiếu HIDL, thì nhà cung cấp đã triển khai lớp VehicleHal. IVehicleHardware rất giống với VehicleHal.
HIDL VHAL
AIDL VHAL
getAllPropertyConfigs()
Bằng giá với VehicleHal.listProperties()
getValues(callback, requests)
Có thể gọi VehicleHal.get() cho mỗi yêu cầu và có thể gọi lệnh gọi lại.
dump()
Bằng giá với VehicleHal.dump()
checkHealth()
Có thể trả về VehicleHal.get()
registerPropertyChangeCallback()
Tương tự như việc thiết lập VehicleHal.mOnHalEvent
Sự khác biệt về loại trong AIDL
Khi di chuyển từ HIDL VHAL sang AIDL VHAL, hãy cân nhắc những điểm khác biệt sau.
HIDL tạo một tệp tiêu đề (types.h) cho tất cả các loại được tạo từ types.hal. AIDL tạo một tệp tiêu đề cho mỗi loại. Ví dụ: VehiclePropValue.h từ VehiclePropValue.aidl.
Do đó, bạn phải đưa tất cả tệp tiêu đề vào cho các loại bạn cần. Tệp trợ giúp VehicleHalTypes.h trong thư viện VehicleHalUtils chứa hầu hết các loại phổ biến.
Thay vì ...
Mục đích sử dụng
hidl_vec
std::vector
hidl_string
std::string
android::sp
std::shared_ptr
android::wp
std::weak_ptr
Tất cả các loại được xác định trong types.hal đều giống nhau trong AIDL ngoại trừ:
SubscribeFlags bị xoá vì không được sử dụng do onPropertySet bị xoá
UserFlags hiện được xác định trong UserInfo.aidl và phải được xác định dưới dạng cờ thay vì enum. Trường cờ người dùng là một số nguyên có nhiều UserInfo.USER_FLAG_XXX bit-or với nhau.
Đổi tên RawValue trong VehiclePropValue thành RawPropValue
Đổi tên bytes trong RawValue thành byteValues
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-07-27 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-07-27 UTC."],[],[],null,["# HIDL VHAL migration guide\n\nTo migrate an existing **HIDL** VHAL implementation to an **AIDL** VHAL,\nuse the\n[AIDL reference implementation](/docs/automotive/vhal/reference-implementation)\nstructure to implement the `IVehicleHardware` interface.\n\nIf the existing HIDL implementation also follows\n[HIDL reference implementation](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/automotive/vehicle/2.0/default/impl/vhal_v2_0),\nthe vendor has implemented the `VehicleHal` class. `IVehicleHardware` is\nvery similar to `VehicleHal`.\n| **Note:** AIDL uses different types than HIDL. Some types used in the HIDL implementation must be migrated. For detail, see [Type differences in AIDL](#aidl-diffs) below.\n\n| HIDL VHAL | AIDL VHAL |\n|------------------------------------|----------------------------------------------------------------------|\n| `getAllPropertyConfigs()` | Same as `VehicleHal.listProperties()` |\n| `getValues(callback, requests)` | Can call `VehicleHal.get()` for each request and can call callbacks. |\n| `dump()` | Same as `VehicleHal.dump()` |\n| `checkHealth()` | Can return `VehicleHal.get()` |\n| `registerPropertyChangeCallback()` | Similar to setting `VehicleHal.mOnHalEvent` |\n\nType differences in AIDL\n------------------------\n\nWhen migrating from the HIDL VHAL to the AIDL VHAL, consider these differences.\n\n1. HIDL generates one header file (`types.h`) for all types generated from `types.hal`. AIDL generates one header file for each type. For example, `VehiclePropValue.h` from `VehiclePropValue.aidl`.\n\n As a result, you must include all header files for the types you need. A helper file,\n `VehicleHalTypes.h` in the `VehicleHalUtils` library contains most of\n the common types.\n\n| Instead of ... | Use |\n|----------------|-------------------|\n| `hidl_vec` | `std::vector` |\n| `hidl_string` | `std::string` |\n| `android::sp` | `std::shared_ptr` |\n| `android::wp` | `std::weak_ptr` |\n\n2. All types defined in `types.hal` are the same in AIDL **except** for:\n - `SubscribeFlags` is removed as it's not used because `onPropertySet` is removed\n - `UserFlags` is now defined in `UserInfo.aidl` and should be defined as a flag instead of an enum. A user flag field is an integer that has multiple `UserInfo.USER_FLAG_XXX` bit-or together.\n - `RawValue` in `VehiclePropValue` is renamed as `RawPropValue`\n - `bytes` in `RawValue` is renamed as `byteValues`"]]