To migrate an existing HIDL VHAL implementation to an AIDL VHAL,
use the
AIDL reference implementation
structure to implement the IVehicleHardware interface.
If the existing HIDL implementation also follows
HIDL reference implementation,
the vendor has implemented the VehicleHal class. IVehicleHardware is
very similar to VehicleHal.
| HIDL VHAL | AIDL VHAL |
|---|---|
getAllPropertyConfigs() |
Same as VehicleHal.listProperties() |
getValues(callback, requests) |
Can call VehicleHal.get() for each request and can call callbacks.
|
dump() |
Same as VehicleHal.dump() |
checkHealth() |
Can return VehicleHal.get() |
registerPropertyChangeCallback() |
Similar to setting VehicleHal.mOnHalEvent |
Type differences in AIDL
When migrating from the HIDL VHAL to the AIDL VHAL, consider these differences.
- HIDL generates one header file (
types.h) for all types generated fromtypes.hal. AIDL generates one header file for each type. For example,VehiclePropValue.hfromVehiclePropValue.aidl.As a result, you must include all header files for the types you need. A helper file,
VehicleHalTypes.hin theVehicleHalUtilslibrary contains most of the common types. - All types defined in
types.halare the same in AIDL except for:SubscribeFlagsis removed as it's not used becauseonPropertySetis removedUserFlagsis now defined inUserInfo.aidland should be defined as a flag instead of an enum. A user flag field is an integer that has multipleUserInfo.USER_FLAG_XXXbit-or together.RawValueinVehiclePropValueis renamed asRawPropValuebytesinRawValueis renamed asbyteValues
| Instead of ... | Use |
|---|---|
hidl_vec |
std::vector |
hidl_string |
std::string |
android::sp |
std::shared_ptr |
android::wp |
std::weak_ptr |