0

How to create custom vehicle properties in android Automotive VHAL?

How can I generate PropertyID and how to access it from CarPropertyManager?

I found below reference but I am not clear on this:

https://source.android.com/devices/automotive/properties#prop_custom][1]

Jaimin Modi
  • 1,530
  • 4
  • 20
  • 72
  • URL correction: https://source.android.com/devices/automotive/vhal/properties#handling-custom-properties – Jitendra Jan 27 '22 at 11:49

2 Answers2

0

Check this https://android.googlesource.com/platform/hardware/interfaces/+/refs/tags/android-9.0.0_r51/automotive/vehicle/2.0/types.hal

with note

  Vendors are allowed to extend this enum with their own properties 
  In this case they must use VehiclePropertyGroup:VENDOR flag when property is
  declared.

You have to expand enum VehicleProperty and then make it available via CarPropertyManager and can get value via CarPropertyValue

Xuân Tâm
  • 156
  • 8
0

Customize vehicle property with the following attributes:

    EXAMPLE_PROPERTY = (
    0xXXXX
    | VehiclePropertyGroup:VENDOR
    | VehiclePropertyType:STRING
    | VehicleArea:GLOBAL),

The custom properties can be accessed through the CarPropertyManager. We jsut have one permission defined for all the vendor properties: Car.PERMISSION_VENDOR_EXTENDSION (Android 10)

Check this https://source.android.com/devices/automotive/vhal/properties#handling-custom-properties

On Android 11, vehicle hal support customize vendor permissions feature through SUPPORT_CUSTOMIZE_VENDOR_PERMISSION

    /**
 * Support customize permissions for vendor properties
 *
 * Implement this property if vehicle hal support customize vendor permissions feature.
 * VehiclePropConfig.configArray is used to indicate vendor properties and permissions
 * which selected for this vendor property. The permission must be one of enum in
 * VehicleVendorPermission.
 * The configArray is set as follows:
 *      configArray[n] = propId : property ID for the vendor property
 *      configArray[n+1] = one of enums in VehicleVendorPermission. It indicates the permission
 *      for reading value of the property.
 *      configArray[n+2] = one of enums in VehicleVendorPermission. It indicates the permission
 *      for writing value of the property.
 *
 * For example:
 * configArray = {
 *      vendor_prop_1, PERMISSION_VENDOR_SEAT_READ, PERMISSION_VENDOR_SEAT_WRITE,
 *      vendor_prop_2, PERMISSION_VENDOR_INFO, PERMISSION_NOT_ACCESSIBLE,
 * }
 * If vendor properties are not in this array, they will have the default vendor permission.
 * If vendor chose PERMISSION_NOT_ACCESSIBLE, android will not have access to the property. In
 * the example, Android can not write value for vendor_prop_2.
 *
 * @change_mode VehiclePropertyChangeMode:STATIC
 * @access VehiclePropertyAccess:READ
 */
SUPPORT_CUSTOMIZE_VENDOR_PERMISSION = (
    0x0F05
    | VehiclePropertyGroup:SYSTEM
    | VehiclePropertyType:BOOLEAN
    | VehicleArea:GLOBAL),
Ninh Ngo
  • 1
  • 1