HIDL VHAL migration guide

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.

  1. 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.

    As a result, you must include all header files for the types you need. A helper file, VehicleHalTypes.h in the VehicleHalUtils library contains most of the common types.

  2. Instead of ... Use
    hidl_vec std::vector
    hidl_string std::string
    android::sp std::shared_ptr
    android::wp std::weak_ptr
  3. All types defined in types.hal are the same in AIDL except for:
    • SubscribeFlags is removed as it's not used because onPropertySet is removed
    • 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.
    • RawValue in VehiclePropValue is renamed as RawPropValue
    • bytes in RawValue is renamed as byteValues