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.h
fromVehiclePropValue.aidl
.As a result, you must include all header files for the types you need. A helper file,
VehicleHalTypes.h
in theVehicleHalUtils
library contains most of the common types. - All types defined in
types.hal
are the same in AIDL except for:SubscribeFlags
is removed as it's not used becauseonPropertySet
is removedUserFlags
is now defined inUserInfo.aidl
and should be defined as a flag instead of an enum. A user flag field is an integer that has multipleUserInfo.USER_FLAG_XXX
bit-or together.RawValue
inVehiclePropValue
is renamed asRawPropValue
bytes
inRawValue
is renamed asbyteValues
Instead of ... | Use |
---|---|
hidl_vec |
std::vector |
hidl_string |
std::string |
android::sp |
std::shared_ptr |
android::wp |
std::weak_ptr |