C

Qt IF Android Vehicle Properties Module

The Qt IF Android vehicle properties module is a submodule of Qt for Android Automotive. This submodule is an extension of the similar Qt IF Vehicle Functions Module.

It provides a C++ and QML wrapper for Android Automotive Vehicle Properties as a Qt IF plugin. The solution is based on templates used by the Qt Interface Framework Generator for code generation. The interface is defined by a QFace configuration file which covers the Android Automotive Vehicle Properties.

How it Works

The module encapsulates the Qt for Android Automotive JNI back end (Qt IF Android Extensions). This module facilitates access to Android vehicle properties. It provides a dedicated Qt Quick plugin to enable access 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 YAML annotations file (YAML Annotations). These two files reflect the Android vehicle properties defined in AOSP sources (VHAL v2.0) and defines the property IDs mappings as well as zoning configuration. That is why modification of this interface needs to be reflected in the mentioned files and followed by rebuilding this module from source code.

Module Structure

The module consists of following components:

  • The QML plugin: responsible for interfacing between the Qt Quick application and the Qt IF Vehicle Properties module.
  • The Vehicle Properties Module: a Qt plugin that encapsulates the features defined by the interface configuration (QFace format). It also contains the JNI back end interface. This is 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 module 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. The use of the QML plugin is presented in source code of the Qt for Android Automotive vehicle properties example. Integrate this module by following these steps:

  1. If using qmake, add the dependencies of the Qt IF Android Vehicle Properties module 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 libs for 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 APPEND 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 1.0
  5. Define an instance of the desired component (e.g. HVAC)
    HVAC { id: climateControl }
  6. The interaction with the vehicle properties is like any 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 like in the Qt for Android Automotive Vehicle Properties example.
  3. The current version of this module uses the JNI back end for accessing the Android Car Service. To use the Qt Remote Objects back end, the module would need 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.