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 name | Property name | Vehicle Property Id // QIfHvac |
---|---|---|
QIfHvac | powerOn | HVAC_POWER_ON |
acOn | HVAC_AC_ON | |
maxAcOn | HVAC_MAX_AC_ON | |
dualOn | HVAC_DUAL_ON | |
autoOn | HVAC_AUTO_ON | |
temperatureCurrent | HVAC_TEMPERATURE_CURRENT | |
temperatureSet | HVAC_TEMPERATURE_SET | |
fanDirection | HVAC_FAN_DIRECTION | |
actualFanSpeed | HVAC_ACTUAL_FAN_SPEED_RPM | |
fanSpeed | HVAC_FAN_SPEED | |
defroster | HVAC_DEFROSTER | |
recircOn | HVAC_RECIRC_ON | |
autoRecircOn | HVAC_AUTO_RECIRC_ON | |
seatVentilation | HVAC_SEAT_VENTILATION | |
maxDefrostOn | HVAC_MAX_DEFROST_ON | |
seatTemperature | HVAC_SEAT_TEMPERATURE | |
sideMirrorHeat | HVAC_SIDE_MIRROR_HEAT | |
steeringWheelHeat | HVAC_STEERING_WHEEL_HEAT | |
temperatureDisplayUnits | HVAC_TEMPERATURE_DISPLAY_UNITS // QIfWindowControl | |
QIfWindowControl | windowPos | WINDOW_POS |
windowMove | WINDOW_MOVE | |
windowLock | WINDOW_LOCK // QIfCarInfo | |
QIfCarInfo | infoModelYear | INFO_MODEL_YEAR |
infoFuelCapacity | INFO_FUEL_CAPACITY | |
infoEvBatteryCapacity | INFO_EV_BATTERY_CAPACITY | |
infoFuelDoorLocation | INFO_FUEL_DOOR_LOCATION | |
infoEvPortLocation | INFO_EV_PORT_LOCATION | |
infoDriverSeat | INFO_DRIVER_SEAT // QIfMirrorControl | |
QIfMirrorControl | mirrorZPos | MIRROR_Z_POS |
mirrorZMove | MIRROR_Z_MOVE | |
mirrorYPos | MIRROR_Y_POS | |
mirrorYMove | MIRROR_Y_MOVE | |
mirrorLock | MIRROR_LOCK | |
mirrorFold | MIRROR_FOLD // QIfSeatControl | |
QIfSeatControl | seatMemorySelect | SEAT_MEMORY_SELECT |
seatMemorySet | SEAT_MEMORY_SET | |
seatBeltBuckled | SEAT_BELT_BUCKLED | |
seatBeltHeightPos | SEAT_BELT_HEIGHT_POS | |
seatBeltHeightMove | SEAT_BELT_HEIGHT_MOVE | |
seatForeAftPos | SEAT_FORE_AFT_POS | |
seatForeAftMove | SEAT_FORE_AFT_MOVE | |
seatBackrestAngle1Pos | SEAT_BACKREST_ANGLE_1_POS | |
seatBackrestAngle1Move | SEAT_BACKREST_ANGLE_1_MOVE | |
seatBackrestAngle2Pos | SEAT_BACKREST_ANGLE_2_POS | |
seatBackrestAngle2Move | SEAT_BACKREST_ANGLE_2_MOVE | |
seatHeightPos | SEAT_HEIGHT_POS | |
seatHeightMove | SEAT_HEIGHT_MOVE | |
seatDepthPos | SEAT_DEPTH_POS | |
seatDepthMove | SEAT_DEPTH_MOVE | |
seatTiltPos | SEAT_TILT_POS | |
seatTiltMove | SEAT_TILT_MOVE | |
seatLumbarForeAftPos | SEAT_LUMBAR_FORE_AFT_POS | |
seatLumbarForeAftMove | SEAT_LUMBAR_FORE_AFT_MOVE | |
seatLumbarSideSupportPos | SEAT_LUMBAR_SIDE_SUPPORT_POS | |
seatLumbarSideSupportMove | SEAT_LUMBAR_SIDE_SUPPORT_MOVE | |
seatHeadrestHeightPos | SEAT_HEADREST_HEIGHT_POS | |
seatHeadrestHeightMove | SEAT_HEADREST_HEIGHT_MOVE | |
seatHeadrestAnglePos | SEAT_HEADREST_ANGLE_POS | |
seatHeadrestAngleMove | SEAT_HEADREST_ANGLE_MOVE | |
seatHeadrestForeAftPos | SEAT_HEADREST_FORE_AFT_POS | |
seatHeadrestForeAftMove | SEAT_HEADREST_FORE_AFT_MOVE | |
seatOccupancy | SEAT_OCCUPANCY // QIfTireControl | |
QIfTireControl | tirePressure | TIRE_PRESSURE |
tirePressureDisplayUnits | TIRE_PRESSURE_DISPLAY_UNITS // QIfLightsControl | |
QIfLightsControl | headlightsState | HEADLIGHTS_STATE |
highbeamLightsState | HIGH_BEAM_LIGHTS_STATE | |
fogLightsState | FOG_LIGHTS_STATE | |
hazardLightsState | HAZARD_LIGHTS_STATE | |
headlightsSwitch | HEADLIGHTS_SWITCH | |
highbeamLightsSwitch | HIGH_BEAM_LIGHTS_SWITCH | |
fogLightsSwitch | FOG_LIGHTS_SWITCH | |
hazardLightsSwitch | HAZARD_LIGHTS_SWITCH | |
cabinLightsState | CABIN_LIGHTS_STATE | |
cabinLightsSwitch | CABIN_LIGHTS_SWITCH | |
readingLightsState | READING_LIGHTS_STATE | |
readingLightsSwitch | READING_LIGHTS_SWITCH | |
nightMode | NIGHT_MODE // QIfFuelControl | |
QIfFuelControl | fuelLevel | FUEL_LEVEL |
fuelDoorOpen | FUEL_DOOR_OPEN | |
fuelLevelLow | FUEL_LEVEL_LOW | |
fuelVolumeDisplayUnits | FUEL_VOLUME_DISPLAY_UNITS | |
fuelConsumptionUnitsDistanceOverVolume | FUEL_CONSUMPTION_UNITS_DISTANCE_OVER_VOLUME | |
rangeRemaining | RANGE_REMAINING | |
evBatteryLevel | EV_BATTERY_LEVEL | |
evChargePortOpen | EV_CHARGE_PORT_OPEN | |
evChargePortConnected | EV_CHARGE_PORT_CONNECTED | |
evBatteryInstantaneousChargeRate | EV_BATTERY_INSTANTANEOUS_CHARGE_RATE | |
evBatteryDisplayUnits | EV_BATTERY_DISPLAY_UNITS // QIfDoorControl | |
QIfDoorControl | doorPos | DOOR_POS |
doorMove | DOOR_MOVE | |
doorLock | DOOR_LOCK // QIfDriveInfo | |
QIfDriveInfo | perfOdometer | PERF_ODOMETER |
perfVehicleSpeed | PERF_VEHICLE_SPEED | |
perfVehicleSpeedDisplay | PERF_VEHICLE_SPEED_DISPLAY | |
perfSteeringAngle | PERF_STEERING_ANGLE | |
gearSelection | GEAR_SELECTION | |
currentGear | CURRENT_GEAR | |
parkingBrakeAutoApply | PARKING_BRAKE_AUTO_APPLY | |
parkingBrakeOn | PARKING_BRAKE_ON | |
turnSignalState | TURN_SIGNAL_STATE | |
ignitionState | IGNITION_STATE | |
absActive | ABS_ACTIVE | |
tractionControlActive | TRACTION_CONTROL_ACTIVE | |
distanceDisplayUnits | DISTANCE_DISPLAY_UNITS | |
vehicleSpeedDisplayUnits | VEHICLE_SPEED_DISPLAY_UNITS | |
envOutsideTemperature | ENV_OUTSIDE_TEMPERATURE // QIfEngineInfo | |
QIfEngineInfo | engineCoolantTemp | ENGINE_COOLANT_TEMP |
engineOilLevel | ENGINE_OIL_LEVEL | |
engineOilTemp | ENGINE_OIL_TEMP | |
engineRpm | ENGINE_RPM // QIfHWControl | |
QIfHWControl | apPowerBootupReason | AP_POWER_BOOTUP_REASON |
displayBrightness | DISPLAY_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:
- Add the dependencies of the Qt IF Android Vehicle Properties front end to your
CMakelists.txt
file.find_package(Qt6 COMPONENTS InterfaceFramework) find_package(Qt6 COMPONENTS IfAndroidVehicleProperties) target_link_libraries(my_target PUBLIC Qt::InterfaceFramework Qt::IfAndroidVehicleProperties )
- Add the paths to additional dependency libraries of the android runtime environment.
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. - 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"/>
- In the QML file add the import statement of this plugin
import QtIf.Android.VehicleProperties
- Define an instance of the desired component in QML (e.g. HVAC)
HVAC { id: climateControl }
- 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"
- 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).
Examples Related to this library
Known issues and limitations
- Currently to deploy an application using this module, additional actions are needed to meet the dependencies:
- Enable AndroidX in gradle.properties file by adding android.useAndroidX=true
- Add android.car.jar package to the APK
For more information, see Deploying an Application on Android.
- 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. - 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.
- Property
fuelDoorOpen
is read-only on Android 10, but it can be written from Android 11 onward. - 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:
- QIfCarInfo.infoModelYear (INFO_MODEL_YEAR)
- QIfCarInfo.infoFuelCapacity (INFO_FUEL_CAPACITY)
- QIfCarInfo.infoEvBatteryCapacity (INFO_EV_BATTERY_CAPACITY)
- QIfCarInfo.infoFuelDoorLocation (INFO_FUEL_DOOR_LOCATION)
- QIfCarInfo.infoEvPortLocation (INFO_EV_PORT_LOCATION)
- 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.