VHAL supports Java and native clients. Car Service is the only
Java client for VHAL. For typically car apps, use the Car APIs (for example,
CarPropertyManager
)
to access VHAL properties instead of directly communicating with
the VHAL. In fact, the SELinux blocks this. For details, see the Car API documentation at
Package Index.
For native clients, starting with Android 13, use
libvhalclient
instead of directly
connecting with VHAL. This is a client library that exposes one common interface,
IVhalClient.h
for AIDL and HIDL VHAL implementations. The following example shows
how to create a VHAL native client and use it to get a Vehicle Identification Number (VIN) number:
using ::aidl::android::hardware::automotive::vehicle::VehicleProperty; using ::android::frameworks::automotive::vhal::IVhalClient; using ::android::hardware::automotive::vehicle::toInt; auto vhalClient = IVhalClient::tryCreate(); if (vhalClient == nullptr) { // handle error. } auto result = vhalClient->getValueSync( *vhalClient->createHalPropValue(toInt(VehicleProperty::INFO_VIN))); // Use result