Vehicle Properties

The Vehicle Hardware Abstraction Layer (VHAL) interface defines the properties OEMs can implement and contains property metadata (for example, whether the property is an int and which change modes are allowed). The VHAL interface is based on accessing (read, write, subscribe) a property, which is an abstraction for a specific function.

HAL interfaces

The VHAL uses the following interfaces:

  • getAllPropConfigs() generates (vec<VehiclePropConfig>propConfigs)
    List the configuration of all properties supported by the VHAL. CarService uses supported properties only.
  • getPropConfigs(vec<int32_t> props) generates (StatusCode status,vec<VehiclePropConfig> propConfigs);
    Return the configuration of selected properties.
  • set(VehiclePropValue propValue) generates (StatusCodestatus);
    Write a value to property. Result of write is defined per property.
  • subscribe(IVehicleCallback callback, vec<SubscribeOptions> options) generates (StatusCode status);
    Start monitoring a property value change. For zoned property, unsubscribe(IVehicleCallback callback, int32_t propId) generates (StatusCode status);

The VHAL uses the following callback interfaces:

  • oneway onPropertyEvent(vec<VehiclePropValue>propValues);
    Notifies vehicle property's value change. Should be done only for subscribed properties.
  • oneway onPropertySetError(StatusCode errorCode,int32_t propId,int32_tareaId);
    Return global VHAL level error or error per property. Global error causes the HAL to restart, which can lead to restarting other components (including applications).

Vehicle properties

Properties can be read-only, write-only (used to pass information to VHAL level), or read and write (support of most properties is optional). Each property is uniquely identified by an int32 key and has a predefined type (value_type):

  • FLOAT[]
  • INT32
  • INT32[]
  • INT64
  • INT64[]

A zoned property may have more than one value, based on the number of zones supported by the property.

Area types

The VHAL defines multiple area types:

Area Type Description
GLOBAL This property is a singleton and does not have multiple areas.
WINDOW Area based on windows, uses VehicleAreaWindow enum.
MIRROR Area based on mirrors, uses VehicleAreaMirror enum.
SEAT Area based on seats, uses VehicleAreaSeat enum.
DOOR Area based on doors, uses VehicleAreaDoor enum.
WHEEL Area based on wheels, uses VehicleAreaWheel enum.

Each zoned property must use a pre-defined area type. Each area type has a set of bit flags defined in an enum for the area type. For example, the SEAT area defines VehicleAreaSeat enums:

  • ROW_1_LEFT = 0x0001
  • ROW_1_CENTER = 0x0002
  • ROW_1_RIGHT = 0x0004
  • ROW_2_LEFT = 0x0010
  • ROW_2_CENTER = 0x0020
  • ROW_2_RIGHT = 0x0040
  • ROW_3_LEFT = 0x0100
  • ...

Area IDs

Zoned properties are addressed through Area IDs. Each zoned property may support one or more Area IDs. An Area ID is composed of one or more flags from its respective enum. For example, a property using VehicleAreaSeat might use the following Area IDs:

Item Description
ROW_1_LEFT | ROW_1_RIGHT The Area ID applies to both front seats.
ROW_2_LEFT Applies only to the rear left seat.
ROW_2_RIGHT Applies only to the rear right seat.

Property status

Every property value comes with a VehiclePropertyStatus value. This indicates the current status for the property:

Item Description
AVAILABLE Property is available and the value is valid.
UNAVAILABLE Property value is currently unavailable. Used for transiently disabled features for a supported property.
ERROR Something is wrong with this property.

Configuring a property

Use VehiclePropConfig to provide configuration information for each property. Information includes:

Variable Description
access r, w, rw
changeMode Represents how a property is monitored, on change versus continuous.
areaConfigs areaId, min, and max values.
configArray Additional configuration parameters.
configString Additional information passed as a string.
minSampleRate maxSampleRate
prop Property ID, int

Handling zone properties

A zoned property is equivalent to a collection of multiple properties where each sub-property can be accessed with the specified Area ID value.

  • get call for zoned property always includes the Area ID in the request. Therefore, only the current value for the requested Area ID is returned. If the property is a global, then Area ID is 0.
  • set call for zoned property always includes the Area ID in the request. Therefore, only the requested Area ID is changed.
  • subscribe call generates events for all Area IDs for the property.

Get calls

During initialization, the value for the property may not be available yet as the matching vehicle network message has not yet been received. In such cases, the get call should return -EAGAIN. Some properties (such as HVAC) have separate on/off power property. Calling get for such a property (when powered off) should return a UNAVAILABLE status rather than returning an error. For example, get HVAC Temperature

VHAL get HVAC example

Figure 1. Get HVAC temperature (CS = CarService, VHAL = Vehicle HAL)

Set calls

In a typical operation, a set call leads to making a change request across the vehicle network. A set call is ideally an asynchronous operation that returns as soon as possible, but it can also be synchronous. Some set calls may require initial data to be ready but during initialization, such data may not be available yet. In such cases, the set call should return StatusCode#TRY_AGAIN. Some properties with separate power on and off should return StatusCode#NOT_AVAILABLE or StatusCode#NOT_AVAILABLE_DISABLED when the property is powered off and set cannot be done. Until set is made effective, get does not necessarily return the same value as what is set. For example, set HVAC Temperature.

VHAL set HVAC example

Figure 2. Set HVAC temperature (CS = CarService, VHAL = Vehicle HAL)

Handling custom properties

To support partner-specific needs, the VHAL allows custom properties that are restricted to system apps. Use the following guidelines when working with custom properties:

  • Property ID should be generated using the following fields:
    • VehiclePropertyGroup:VENDOR
      The VENDOR group is used only for custom properties.
    • VehicleArea
      Select an appropriate Area Type.
    • VehiclePropertyType
      Select the proper data type. BYTES type allows the passing of raw data which is sufficient in most cases. Sending big data frequently through custom properties can slow down entire vehicle network access — be careful when adding a big payload.
    • Property ID
      Choose a four nibble ID for the custom property.
  • To prevent ecosystem fragmentation, custom properties must not be used to replicate vehicle properties that already exist in the (VehiclePropertyIds SDK).
  • Fill in VehiclePropConfig.configString with a short description of the custom property. This allows sanity check tools to flag the accidental replication of existing vehicle properties. For example, "hazard light state."
  • Access through CarPropertyManager (for Java components) or through the Vehicle Network Service API (for native). Do not modify other car APIs as doing so can lead to future compatibility issues.
  • After implementing vendor properties, selectonly the permissions list in the VehicleVendorPermission enum for vendor properties. Mapping vendor permissions to system properties will break the CTS and VTS.

Handling HVAC properties

You can use the VHAL to control HVAC by setting HVAC-related properties. Most HVAC properties are zoned properties, although several are non-zoned (global) properties. Sample defined properties include:

Property Purpose
VEHICLE_PROPERTY_HVAC_RECIRC_ON Control recirculation per zone.

To see a complete list of HVAC properties, search for VEHICLE_PROPERTY_HVAC_* in types.hal. When the HVAC property uses VehicleAreaSeat, additional rules for mapping a zoned HVAC property to Area IDs apply. Each available seat in the car must be part of an Area ID in the Area ID array.

Example One. A car has two front seats (ROW_1_LEFT, ROW_1_RIGHT) and three back seats (ROW_2_LEFT, ROW_2_CENTER, ROW_2_RIGHT). The car has two temperature control units: the driver side and passenger side.

  • A valid mapping set of Area IDs for HVAC_TEMPERATURE SET is:
    • ROW_1_LEFT | ROW_2_LEFT
  • An alternative mapping for the same hardware configuration is:

Example Two. A car has three seat rows with two seats in the front row (ROW_1_LEFT, ROW_1_RIGHT), three seats in the second (ROW_2_LEFT, ROW_2_CENTER, ROW_2_RIGHT), and three in the third rows (ROW_3_LEFT, ROW_3_CENTER, ROW_3_RIGHT). The car has three temperature control units: driver side, passenger side, and rear. A reasonable way to map HVAC_TEMPERATURE_SET to Area IDs is as a three element array:

  • ROW_1_LEFT

Handling sensor properties

VHAL sensor properties represent real sensor data or policy information such as driving status. Some sensor information (such as driving status and day/night mode) is accessible by any app without restriction as the data is mandatory to build a safe vehicle application. Other sensor information (such as vehicle speed) is more sensitive and requires specific permissions that users can manage.

See the supported sensor properties (in types.hal).

Vehicle Map Service

The Vehicle Map Service (VMS) provides a mechanism to exchange map data between clients through a pub/sub interface to support common vehicle features, such as Advanced Driver Assistance Systems (ADAS). Clients can include vehicle systems interfacing through the VMS property in the VHAL or privileged Android applications. Data shared on VMS are intended to be limited to map data for use by vehicle systems and supporting apps.

VMS is intended for use only in Android Automotive implementations; AOSP does not contain default clients that publish or subscribe to VMS. For the VMS property in the VHAL, the message types and data structures are described in VHAL 2.0 in the VmsMessageType enum, which lists the types of supported VMS messages. This enum is used as the first integer in the vehicle property integers array and determines how the rest of the message is decoded.