C

Qt IF Android Vehicle Properties

The Qt IF Android Vehicle Properties libraries are part of the Qt Android Automotive Vehicle Module. These autogenerated libraries are based on the similar Qt IF Vehicle Functions.

The interface to access vehicle properties is defined by a QFace configuration file which covers the Android Automotive Vehicle Properties. This interface description is used to generate various front ends and back ends which can be used to access vehicle data or do simulation for development purposes. This solution is based on templates coming from the Qt Interface Framework Generator and our own Qt IF Generator Extensions also implemented in the Qt Android Automotive Vehicle Module.

How it Works

One of the generated back ends, the Qt for Android Automotive JNI back end facilitates direct access to Android Automotive vehicle properties. A C++ front end is generated to get access to multiple back ends accessing vehicle data. A Qt Quick plugin is also generated to enable the same access by using the QML language.

The set of available vehicle properties, which are grouped into feature components, is defined by the QFace configuration file together with a YAML annotations file (YAML Annotations). These two files reflect the Android vehicle properties defined in AOSP sources (VHAL v2.0) and defines the property ID mappings as well as zoning configuration. That is why modification of this interface needs to be reflected in the mentioned files, followed by rebuilding these libraries from source code.

Module Structure

Vehicle Properties consists of the following components:

  • The Vehicle Properties front end: a library that encapsulates the features defined by the interface configuration in QFace format.
  • The Vehicle Properties QML plugin: responsible for interfacing between the Qt Quick application and the Qt IF Vehicle Properties front end.
  • The Vehicle Properties JNI back end: a specialized implementation that interacts with the back end service (the one that directly accesses the Android car API).

Vehicle properties are grouped into the following components:

Component nameProperty nameVehicle Property Id // QIfHvac
QIfHvacpowerOnHVAC_POWER_ON
acOnHVAC_AC_ON
maxAcOnHVAC_MAX_AC_ON
dualOnHVAC_DUAL_ON
autoOnHVAC_AUTO_ON
temperatureCurrentHVAC_TEMPERATURE_CURRENT
temperatureSetHVAC_TEMPERATURE_SET
fanDirectionHVAC_FAN_DIRECTION
actualFanSpeedHVAC_ACTUAL_FAN_SPEED_RPM
fanSpeedHVAC_FAN_SPEED
defrosterHVAC_DEFROSTER
recircOnHVAC_RECIRC_ON
autoRecircOnHVAC_AUTO_RECIRC_ON
seatVentilationHVAC_SEAT_VENTILATION
maxDefrostOnHVAC_MAX_DEFROST_ON
seatTemperatureHVAC_SEAT_TEMPERATURE
sideMirrorHeatHVAC_SIDE_MIRROR_HEAT
steeringWheelHeatHVAC_STEERING_WHEEL_HEAT
temperatureDisplayUnitsHVAC_TEMPERATURE_DISPLAY_UNITS // QIfWindowControl
QIfWindowControlwindowPosWINDOW_POS
windowMoveWINDOW_MOVE
windowLockWINDOW_LOCK // QIfCarInfo
QIfCarInfoinfoModelYearINFO_MODEL_YEAR
infoFuelCapacityINFO_FUEL_CAPACITY
infoEvBatteryCapacityINFO_EV_BATTERY_CAPACITY
infoFuelDoorLocationINFO_FUEL_DOOR_LOCATION
infoEvPortLocationINFO_EV_PORT_LOCATION
infoDriverSeatINFO_DRIVER_SEAT // QIfMirrorControl
QIfMirrorControlmirrorZPosMIRROR_Z_POS
mirrorZMoveMIRROR_Z_MOVE
mirrorYPosMIRROR_Y_POS
mirrorYMoveMIRROR_Y_MOVE
mirrorLockMIRROR_LOCK
mirrorFoldMIRROR_FOLD // QIfSeatControl
QIfSeatControlseatMemorySelectSEAT_MEMORY_SELECT
seatMemorySetSEAT_MEMORY_SET
seatBeltBuckledSEAT_BELT_BUCKLED
seatBeltHeightPosSEAT_BELT_HEIGHT_POS
seatBeltHeightMoveSEAT_BELT_HEIGHT_MOVE
seatForeAftPosSEAT_FORE_AFT_POS
seatForeAftMoveSEAT_FORE_AFT_MOVE
seatBackrestAngle1PosSEAT_BACKREST_ANGLE_1_POS
seatBackrestAngle1MoveSEAT_BACKREST_ANGLE_1_MOVE
seatBackrestAngle2PosSEAT_BACKREST_ANGLE_2_POS
seatBackrestAngle2MoveSEAT_BACKREST_ANGLE_2_MOVE
seatHeightPosSEAT_HEIGHT_POS
seatHeightMoveSEAT_HEIGHT_MOVE
seatDepthPosSEAT_DEPTH_POS
seatDepthMoveSEAT_DEPTH_MOVE
seatTiltPosSEAT_TILT_POS
seatTiltMoveSEAT_TILT_MOVE
seatLumbarForeAftPosSEAT_LUMBAR_FORE_AFT_POS
seatLumbarForeAftMoveSEAT_LUMBAR_FORE_AFT_MOVE
seatLumbarSideSupportPosSEAT_LUMBAR_SIDE_SUPPORT_POS
seatLumbarSideSupportMoveSEAT_LUMBAR_SIDE_SUPPORT_MOVE
seatHeadrestHeightPosSEAT_HEADREST_HEIGHT_POS
seatHeadrestHeightMoveSEAT_HEADREST_HEIGHT_MOVE
seatHeadrestAnglePosSEAT_HEADREST_ANGLE_POS
seatHeadrestAngleMoveSEAT_HEADREST_ANGLE_MOVE
seatHeadrestForeAftPosSEAT_HEADREST_FORE_AFT_POS
seatHeadrestForeAftMoveSEAT_HEADREST_FORE_AFT_MOVE
seatOccupancySEAT_OCCUPANCY // QIfTireControl
QIfTireControltirePressureTIRE_PRESSURE
tirePressureDisplayUnitsTIRE_PRESSURE_DISPLAY_UNITS // QIfLightsControl
QIfLightsControlheadlightsStateHEADLIGHTS_STATE
highbeamLightsStateHIGH_BEAM_LIGHTS_STATE
fogLightsStateFOG_LIGHTS_STATE
hazardLightsStateHAZARD_LIGHTS_STATE
headlightsSwitchHEADLIGHTS_SWITCH
highbeamLightsSwitchHIGH_BEAM_LIGHTS_SWITCH
fogLightsSwitchFOG_LIGHTS_SWITCH
hazardLightsSwitchHAZARD_LIGHTS_SWITCH
cabinLightsStateCABIN_LIGHTS_STATE
cabinLightsSwitchCABIN_LIGHTS_SWITCH
readingLightsStateREADING_LIGHTS_STATE
readingLightsSwitchREADING_LIGHTS_SWITCH
nightModeNIGHT_MODE // QIfFuelControl
QIfFuelControlfuelLevelFUEL_LEVEL
fuelDoorOpenFUEL_DOOR_OPEN
fuelLevelLowFUEL_LEVEL_LOW
fuelVolumeDisplayUnitsFUEL_VOLUME_DISPLAY_UNITS
fuelConsumptionUnitsDistanceOverVolumeFUEL_CONSUMPTION_UNITS_DISTANCE_OVER_VOLUME
rangeRemainingRANGE_REMAINING
evBatteryLevelEV_BATTERY_LEVEL
evChargePortOpenEV_CHARGE_PORT_OPEN
evChargePortConnectedEV_CHARGE_PORT_CONNECTED
evBatteryInstantaneousChargeRateEV_BATTERY_INSTANTANEOUS_CHARGE_RATE
evBatteryDisplayUnitsEV_BATTERY_DISPLAY_UNITS // QIfDoorControl
QIfDoorControldoorPosDOOR_POS
doorMoveDOOR_MOVE
doorLockDOOR_LOCK // QIfDriveInfo
QIfDriveInfoperfOdometerPERF_ODOMETER
perfVehicleSpeedPERF_VEHICLE_SPEED
perfVehicleSpeedDisplayPERF_VEHICLE_SPEED_DISPLAY
perfSteeringAnglePERF_STEERING_ANGLE
gearSelectionGEAR_SELECTION
currentGearCURRENT_GEAR
parkingBrakeAutoApplyPARKING_BRAKE_AUTO_APPLY
parkingBrakeOnPARKING_BRAKE_ON
turnSignalStateTURN_SIGNAL_STATE
ignitionStateIGNITION_STATE
absActiveABS_ACTIVE
tractionControlActiveTRACTION_CONTROL_ACTIVE
distanceDisplayUnitsDISTANCE_DISPLAY_UNITS
vehicleSpeedDisplayUnitsVEHICLE_SPEED_DISPLAY_UNITS
envOutsideTemperatureENV_OUTSIDE_TEMPERATURE // QIfEngineInfo
QIfEngineInfoengineCoolantTempENGINE_COOLANT_TEMP
engineOilLevelENGINE_OIL_LEVEL
engineOilTempENGINE_OIL_TEMP
engineRpmENGINE_RPM // QIfHWControl
QIfHWControlapPowerBootupReasonAP_POWER_BOOTUP_REASON
displayBrightnessDISPLAY_BRIGHTNESS

How to use it

The frontend library can be used by directly interacting with C++ code, or by using the QML plugin. To use the plugin at the C++ code level, follow the steps described in Qt IF Vehicle Functions Module. (Note that C++ code is generated under the default Qt namespace as in Qt In Namespace.) The use of the QML plugin is demonstrated by the Vehicle Properties Browser example. Integrate this library with your project by following these steps:

  1. If using qmake, add the dependencies of the Qt IF Android Vehicle Properties front end to your qmake project file (*.pro):
    QT += ifandroidvehicleproperties interfaceframework

    If using CMake:

    find_package(Qt6 COMPONENTS InterfaceFramework)
    find_package(Qt6 COMPONENTS IfAndroidVehicleProperties)
    
    target_link_libraries(my_target PUBLIC
        Qt::InterfaceFramework
        Qt::IfAndroidVehicleProperties
    )
  2. Add the paths to additional dependency libraries of the android runtime environment. For qmake use the following code:
    ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android

    For CMake use the following code:

    set_property(TARGET my_target PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
                 ${CMAKE_CURRENT_SOURCE_DIR}/android)

    Note: In order to set target property on Android use MANUAL_FINALIZATION as described in CMake manual finalization.

  3. In the AndroidManifest.xml file add the proper permissions for accessing the VHAL properties (e.g. for HVAC it would be CONTROL_CAR_CLIMATE)
    <uses-permission android:name="android.car.permission.CONTROL_CAR_CLIMATE"/>
  4. In the QML file add the import statement of this plugin
    import QtIf.Android.VehicleProperties
  5. Define an instance of the desired component in QML (e.g. HVAC)
    HVAC { id: climateControl }
  6. The interaction with vehicle properties is as for any other typical Qt property
    onClicked: {
        climateControl.setHvacAcOn(!climateControl.hvacAcOn)
    }
    text: climateControl.hvacAcOn ? "AC ON" : "AC OFF"
  7. If the vehicle has an interface with zones, then the interaction with the properties needs to point to a certain zone (see Zoned HVAC Control).

Known issues and limitations

  1. Currently to deploy an application using this module, additional actions are needed to meet the dependencies:
    1. Enable AndroidX in gradle.properties file by adding android.useAndroidX=true
    2. Add android.car.jar package to the APK

    For more information, see Deploying an Application on Android.

  2. The Android build needs to be aligned with the vehicle interface definition used by this module, and a proper android.car.jar package needs to be delivered together with the APK as shown in the Vehicle Properties Browser example.
  3. The current version of this library uses the JNI back end for accessing the Android Car Service. To use the Qt Remote Objects back end, the library requires adjustments to the source code.
  4. Property fuelDoorOpen is read-only on Android 10, but it can be written from Android 11 onward.
  5. Static vehicle properties do not react on change in emulator. Static properties are supposed to be set once, during the production, by the manufacturer of the car, so Android Automotive does not broadcast it's changes. Those properties are:
    1. QIfCarInfo.infoModelYear (INFO_MODEL_YEAR)
    2. QIfCarInfo.infoFuelCapacity (INFO_FUEL_CAPACITY)
    3. QIfCarInfo.infoEvBatteryCapacity (INFO_EV_BATTERY_CAPACITY)
    4. QIfCarInfo.infoFuelDoorLocation (INFO_FUEL_DOOR_LOCATION)
    5. QIfCarInfo.infoEvPortLocation (INFO_EV_PORT_LOCATION)
    6. QIfCarInfo.infoDriverSeat (INFO_DRIVER_SEAT)

    Full list of Android Automotive static properties can be found here on AOSP: Vehicle Properties source code.

See also Qt for Android and Qt Interface Framework.

Available under certain Qt licenses.
Find out more.