From d5fa689e433e2141ea71305fe1ce522c0fc49350 Mon Sep 17 00:00:00 2001 From: Yu Shan Date: Fri, 20 Oct 2023 17:28:37 -0700 Subject: [PATCH] Add VUR to VHAL interface. Add enableVariableUpdateRate to subscribe options and supportVariableUpdateRate to VehicleAreaConfig. If variable update rate is enabled, VHAL will only send property change events for continuous property if the property's value changes. This is for improving performance and not send duplicate events. Test: m Bug: 306754638 Change-Id: Ic0d1ec2ebbf8ed6c26da3f3b820ac85e9c345b2c --- .../automotive/vehicle/SubscribeOptions.aidl | 1 + .../automotive/vehicle/VehicleAreaConfig.aidl | 1 + .../automotive/vehicle/SubscribeOptions.aidl | 15 +++++++++++ .../automotive/vehicle/VehicleAreaConfig.aidl | 27 +++++++++++++++++++ .../vehicle/VehicleAreaConfig.proto | 1 + 5 files changed, 45 insertions(+) diff --git a/automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/SubscribeOptions.aidl b/automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/SubscribeOptions.aidl index 23fc8a92b4..1b1696b240 100644 --- a/automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/SubscribeOptions.aidl +++ b/automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/SubscribeOptions.aidl @@ -38,4 +38,5 @@ parcelable SubscribeOptions { int[] areaIds; float sampleRate; float resolution = 0.0f; + boolean enableVariableUpdateRate; } diff --git a/automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/VehicleAreaConfig.aidl b/automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/VehicleAreaConfig.aidl index 3322769071..08d4ee46e8 100644 --- a/automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/VehicleAreaConfig.aidl +++ b/automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/VehicleAreaConfig.aidl @@ -43,4 +43,5 @@ parcelable VehicleAreaConfig { float maxFloatValue; @nullable long[] supportedEnumValues; android.hardware.automotive.vehicle.VehiclePropertyAccess access = android.hardware.automotive.vehicle.VehiclePropertyAccess.NONE; + boolean supportVariableUpdateRate; } diff --git a/automotive/vehicle/aidl/android/hardware/automotive/vehicle/SubscribeOptions.aidl b/automotive/vehicle/aidl/android/hardware/automotive/vehicle/SubscribeOptions.aidl index 1f2fb2754e..69f6190363 100644 --- a/automotive/vehicle/aidl/android/hardware/automotive/vehicle/SubscribeOptions.aidl +++ b/automotive/vehicle/aidl/android/hardware/automotive/vehicle/SubscribeOptions.aidl @@ -49,4 +49,19 @@ parcelable SubscribeOptions { * 10, VHAL should return a StatusCode::INVALID_ARG. */ float resolution = 0.0f; + + /** + * Whether to enable variable update rate. + * + * This only applies for continuous property. If variable update rate is + * enabled, for each given areaId, if VHAL supports variable update rate for + * the [propId, areaId], VHAL must ignore duplicate property value events + * and only sends changed value events (a.k.a treat continuous as an + * on-change property). + * + * If VHAL does not support variable update rate for the [propId, areaId], + * indicated by 'supportVariableUpdateRate' in 'VehicleAreaConfig', or if + * this property is not a continuous property, this option must be ignored. + */ + boolean enableVariableUpdateRate; } diff --git a/automotive/vehicle/aidl/android/hardware/automotive/vehicle/VehicleAreaConfig.aidl b/automotive/vehicle/aidl/android/hardware/automotive/vehicle/VehicleAreaConfig.aidl index 9fd9bda3f8..08863b2576 100644 --- a/automotive/vehicle/aidl/android/hardware/automotive/vehicle/VehicleAreaConfig.aidl +++ b/automotive/vehicle/aidl/android/hardware/automotive/vehicle/VehicleAreaConfig.aidl @@ -70,4 +70,31 @@ parcelable VehicleAreaConfig { * well. */ VehiclePropertyAccess access = VehiclePropertyAccess.NONE; + + /** + * Whether variable update rate is supported. + * + * This applies for continuous property only. + * + * It is HIGHLY RECOMMENDED to support variable update rate for all non-heartbeat continuous + * properties for better performance. + * + * If variable update rate is supported and 'enableVariableUpdateRate' is true in subscribe + * options, VHAL must only sends property update event when the property's value changes + * (a.k.a treat continuous as an on-change property). + * + * E.g. if the client is subscribing at 5hz at time 0. If the property's value is 0 initially + * and becomes 1 after 1 second. + + * If variable update rate is not enabled, VHAL clients will receive 5 property change events + * with value 0 and 5 events with value 1 after 2 seconds. + * + * If variable update rate is enabled, VHAL clients will receive 1 property change event + * with value 1 at time 1s. VHAL may/may not send a property event for the initial value (e.g. + * a property change event with value 0 at time 0s). VHAL client must not rely on the first + * property event, and must use getValues to fetch the initial value. In fact, car service is + * using getValues to fetch the initial value, convert it to a property event and deliver to + * car service clients. + */ + boolean supportVariableUpdateRate; } diff --git a/automotive/vehicle/aidl/impl/proto/android/hardware/automotive/vehicle/VehicleAreaConfig.proto b/automotive/vehicle/aidl/impl/proto/android/hardware/automotive/vehicle/VehicleAreaConfig.proto index 04b7dd4d82..8093658477 100644 --- a/automotive/vehicle/aidl/impl/proto/android/hardware/automotive/vehicle/VehicleAreaConfig.proto +++ b/automotive/vehicle/aidl/impl/proto/android/hardware/automotive/vehicle/VehicleAreaConfig.proto @@ -44,4 +44,5 @@ message VehicleAreaConfig { */ repeated int64 supported_enum_values = 8; int32 access = 9; + bool support_variable_update_rate = 10; };