Merge changes from topic "getminmaxvalue" into main
* changes:
Add VTS test for getMinMaxSupportedValue.
Generate cpp header file for supported enums.
diff --git a/automotive/vehicle/aidl/aidl_test/Android.bp b/automotive/vehicle/aidl/aidl_test/Android.bp
index d3ce307..1419455 100644
--- a/automotive/vehicle/aidl/aidl_test/Android.bp
+++ b/automotive/vehicle/aidl/aidl_test/Android.bp
@@ -44,6 +44,7 @@
srcs: ["VehiclePropertyAnnotationCppTest.cpp"],
header_libs: ["IVehicleGeneratedHeaders-V4"],
static_libs: [
+ "VehicleHalUtils",
"libgtest",
"libgmock",
],
diff --git a/automotive/vehicle/aidl/aidl_test/VehiclePropertyAnnotationCppTest.cpp b/automotive/vehicle/aidl/aidl_test/VehiclePropertyAnnotationCppTest.cpp
index dd82d1b..d982caf 100644
--- a/automotive/vehicle/aidl/aidl_test/VehiclePropertyAnnotationCppTest.cpp
+++ b/automotive/vehicle/aidl/aidl_test/VehiclePropertyAnnotationCppTest.cpp
@@ -17,6 +17,8 @@
#include <AccessForVehicleProperty.h>
#include <AnnotationsForVehicleProperty.h>
#include <ChangeModeForVehicleProperty.h>
+#include <EnumForVehicleProperty.h>
+#include <VehicleHalTypes.h>
#include <aidl/android/hardware/automotive/vehicle/VehicleProperty.h>
#include <gmock/gmock.h>
@@ -73,3 +75,16 @@
<< " must not be empty";
}
}
+
+TEST(VehiclePropertyAnnotationCppTest, testSupportedEnums) {
+ auto supportedEnums =
+ aidl_vehicle::getSupportedEnumValuesForProperty(VehicleProperty::INFO_FUEL_TYPE);
+ // We only listed part of the fuel type values here. This is enough to verify that the
+ // generated code is correct.
+ ASSERT_THAT(supportedEnums,
+ ::testing::IsSupersetOf(
+ {static_cast<int64_t>(aidl_vehicle::FuelType::FUEL_TYPE_UNLEADED),
+ static_cast<int64_t>(aidl_vehicle::FuelType::FUEL_TYPE_LEADED),
+ static_cast<int64_t>(aidl_vehicle::FuelType::FUEL_TYPE_DIESEL_1),
+ static_cast<int64_t>(aidl_vehicle::FuelType::FUEL_TYPE_DIESEL_2)}));
+}
diff --git a/automotive/vehicle/aidl/generated_lib/4/cpp/AccessForVehicleProperty.h b/automotive/vehicle/aidl/generated_lib/4/cpp/AccessForVehicleProperty.h
index eea1c5c..e645b7c 100644
--- a/automotive/vehicle/aidl/generated_lib/4/cpp/AccessForVehicleProperty.h
+++ b/automotive/vehicle/aidl/generated_lib/4/cpp/AccessForVehicleProperty.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2023 The Android Open Source Project
+ * Copyright (C) 2025 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/automotive/vehicle/aidl/generated_lib/4/cpp/AnnotationsForVehicleProperty.h b/automotive/vehicle/aidl/generated_lib/4/cpp/AnnotationsForVehicleProperty.h
index 27301a5..5b6048a 100644
--- a/automotive/vehicle/aidl/generated_lib/4/cpp/AnnotationsForVehicleProperty.h
+++ b/automotive/vehicle/aidl/generated_lib/4/cpp/AnnotationsForVehicleProperty.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2023 The Android Open Source Project
+ * Copyright (C) 2025 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/automotive/vehicle/aidl/generated_lib/4/cpp/ChangeModeForVehicleProperty.h b/automotive/vehicle/aidl/generated_lib/4/cpp/ChangeModeForVehicleProperty.h
index b353ab9..ca07ecf 100644
--- a/automotive/vehicle/aidl/generated_lib/4/cpp/ChangeModeForVehicleProperty.h
+++ b/automotive/vehicle/aidl/generated_lib/4/cpp/ChangeModeForVehicleProperty.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2023 The Android Open Source Project
+ * Copyright (C) 2025 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/automotive/vehicle/aidl/generated_lib/4/cpp/EnumForVehicleProperty.h b/automotive/vehicle/aidl/generated_lib/4/cpp/EnumForVehicleProperty.h
new file mode 100644
index 0000000..5afe069
--- /dev/null
+++ b/automotive/vehicle/aidl/generated_lib/4/cpp/EnumForVehicleProperty.h
@@ -0,0 +1,313 @@
+/*
+ * Copyright (C) 2025 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * DO NOT EDIT MANUALLY!!!
+ *
+ * Generated by tools/generate_annotation_enums.py.
+ */
+
+// clang-format off
+
+#pragma once
+
+#define addSupportedValues(EnumType) \
+{ \
+constexpr auto values = ndk::internal::enum_values<EnumType>; \
+for (size_t i = 0; i < values.size(); i++) { \
+ supportedValues.insert(static_cast<int64_t>(values[i])); \
+} \
+}
+
+#include <VehicleHalTypes.h>
+#include <aidl/android/hardware/automotive/vehicle/VehicleProperty.h>
+
+#include <unordered_set>
+
+namespace aidl::android::hardware::automotive::vehicle {
+std::unordered_set<int64_t> getSupportedEnumValuesForProperty(VehicleProperty propertyId) {
+ std::unordered_set<int64_t> supportedValues;
+ switch (propertyId) {
+ case VehicleProperty::INFO_FUEL_TYPE:
+ addSupportedValues(FuelType)
+ break;
+ case VehicleProperty::INFO_EV_CONNECTOR_TYPE:
+ addSupportedValues(EvConnectorType)
+ break;
+ case VehicleProperty::INFO_FUEL_DOOR_LOCATION:
+ addSupportedValues(PortLocationType)
+ break;
+ case VehicleProperty::INFO_EV_PORT_LOCATION:
+ addSupportedValues(PortLocationType)
+ break;
+ case VehicleProperty::INFO_DRIVER_SEAT:
+ addSupportedValues(VehicleAreaSeat)
+ break;
+ case VehicleProperty::INFO_MULTI_EV_PORT_LOCATIONS:
+ addSupportedValues(PortLocationType)
+ break;
+ case VehicleProperty::INFO_VEHICLE_SIZE_CLASS:
+ addSupportedValues(VehicleSizeClass)
+ break;
+ case VehicleProperty::ENGINE_OIL_LEVEL:
+ addSupportedValues(VehicleOilLevel)
+ break;
+ case VehicleProperty::IMPACT_DETECTED:
+ addSupportedValues(ImpactSensorLocation)
+ break;
+ case VehicleProperty::GEAR_SELECTION:
+ addSupportedValues(VehicleGear)
+ break;
+ case VehicleProperty::CURRENT_GEAR:
+ addSupportedValues(VehicleGear)
+ break;
+ case VehicleProperty::TURN_SIGNAL_STATE:
+ addSupportedValues(VehicleTurnSignal)
+ break;
+ case VehicleProperty::IGNITION_STATE:
+ addSupportedValues(VehicleIgnitionState)
+ break;
+ case VehicleProperty::EV_STOPPING_MODE:
+ addSupportedValues(EvStoppingMode)
+ break;
+ case VehicleProperty::ELECTRONIC_STABILITY_CONTROL_STATE:
+ addSupportedValues(ElectronicStabilityControlState)
+ addSupportedValues(ErrorState)
+ break;
+ case VehicleProperty::TURN_SIGNAL_LIGHT_STATE:
+ addSupportedValues(VehicleTurnSignal)
+ break;
+ case VehicleProperty::TURN_SIGNAL_SWITCH:
+ addSupportedValues(VehicleTurnSignal)
+ break;
+ case VehicleProperty::HVAC_FAN_DIRECTION:
+ addSupportedValues(VehicleHvacFanDirection)
+ break;
+ case VehicleProperty::HVAC_TEMPERATURE_DISPLAY_UNITS:
+ addSupportedValues(VehicleUnit)
+ break;
+ case VehicleProperty::HVAC_FAN_DIRECTION_AVAILABLE:
+ addSupportedValues(VehicleHvacFanDirection)
+ break;
+ case VehicleProperty::DISTANCE_DISPLAY_UNITS:
+ addSupportedValues(VehicleUnit)
+ break;
+ case VehicleProperty::FUEL_VOLUME_DISPLAY_UNITS:
+ addSupportedValues(VehicleUnit)
+ break;
+ case VehicleProperty::TIRE_PRESSURE_DISPLAY_UNITS:
+ addSupportedValues(VehicleUnit)
+ break;
+ case VehicleProperty::EV_BATTERY_DISPLAY_UNITS:
+ addSupportedValues(VehicleUnit)
+ break;
+ case VehicleProperty::VEHICLE_SPEED_DISPLAY_UNITS:
+ addSupportedValues(VehicleUnit)
+ break;
+ case VehicleProperty::HW_ROTARY_INPUT:
+ addSupportedValues(RotaryInputType)
+ break;
+ case VehicleProperty::HW_CUSTOM_INPUT:
+ addSupportedValues(CustomInputType)
+ break;
+ case VehicleProperty::SEAT_FOOTWELL_LIGHTS_STATE:
+ addSupportedValues(VehicleLightState)
+ break;
+ case VehicleProperty::SEAT_FOOTWELL_LIGHTS_SWITCH:
+ addSupportedValues(VehicleLightSwitch)
+ break;
+ case VehicleProperty::SEAT_AIRBAGS_DEPLOYED:
+ addSupportedValues(VehicleAirbagLocation)
+ break;
+ case VehicleProperty::SEAT_OCCUPANCY:
+ addSupportedValues(VehicleSeatOccupancyState)
+ break;
+ case VehicleProperty::WINDSHIELD_WIPERS_STATE:
+ addSupportedValues(WindshieldWipersState)
+ break;
+ case VehicleProperty::WINDSHIELD_WIPERS_SWITCH:
+ addSupportedValues(WindshieldWipersSwitch)
+ break;
+ case VehicleProperty::HEADLIGHTS_STATE:
+ addSupportedValues(VehicleLightState)
+ break;
+ case VehicleProperty::HIGH_BEAM_LIGHTS_STATE:
+ addSupportedValues(VehicleLightState)
+ break;
+ case VehicleProperty::FOG_LIGHTS_STATE:
+ addSupportedValues(VehicleLightState)
+ break;
+ case VehicleProperty::HAZARD_LIGHTS_STATE:
+ addSupportedValues(VehicleLightState)
+ break;
+ case VehicleProperty::HEADLIGHTS_SWITCH:
+ addSupportedValues(VehicleLightSwitch)
+ break;
+ case VehicleProperty::HIGH_BEAM_LIGHTS_SWITCH:
+ addSupportedValues(VehicleLightSwitch)
+ break;
+ case VehicleProperty::FOG_LIGHTS_SWITCH:
+ addSupportedValues(VehicleLightSwitch)
+ break;
+ case VehicleProperty::HAZARD_LIGHTS_SWITCH:
+ addSupportedValues(VehicleLightSwitch)
+ break;
+ case VehicleProperty::CABIN_LIGHTS_STATE:
+ addSupportedValues(VehicleLightState)
+ break;
+ case VehicleProperty::CABIN_LIGHTS_SWITCH:
+ addSupportedValues(VehicleLightSwitch)
+ break;
+ case VehicleProperty::READING_LIGHTS_STATE:
+ addSupportedValues(VehicleLightState)
+ break;
+ case VehicleProperty::READING_LIGHTS_SWITCH:
+ addSupportedValues(VehicleLightSwitch)
+ break;
+ case VehicleProperty::STEERING_WHEEL_LIGHTS_STATE:
+ addSupportedValues(VehicleLightState)
+ break;
+ case VehicleProperty::STEERING_WHEEL_LIGHTS_SWITCH:
+ addSupportedValues(VehicleLightSwitch)
+ break;
+ case VehicleProperty::ELECTRONIC_TOLL_COLLECTION_CARD_TYPE:
+ addSupportedValues(ElectronicTollCollectionCardType)
+ break;
+ case VehicleProperty::ELECTRONIC_TOLL_COLLECTION_CARD_STATUS:
+ addSupportedValues(ElectronicTollCollectionCardStatus)
+ break;
+ case VehicleProperty::FRONT_FOG_LIGHTS_STATE:
+ addSupportedValues(VehicleLightState)
+ break;
+ case VehicleProperty::FRONT_FOG_LIGHTS_SWITCH:
+ addSupportedValues(VehicleLightSwitch)
+ break;
+ case VehicleProperty::REAR_FOG_LIGHTS_STATE:
+ addSupportedValues(VehicleLightState)
+ break;
+ case VehicleProperty::REAR_FOG_LIGHTS_SWITCH:
+ addSupportedValues(VehicleLightSwitch)
+ break;
+ case VehicleProperty::EV_CHARGE_STATE:
+ addSupportedValues(EvChargeState)
+ break;
+ case VehicleProperty::EV_REGENERATIVE_BRAKING_STATE:
+ addSupportedValues(EvRegenerativeBrakingState)
+ break;
+ case VehicleProperty::TRAILER_PRESENT:
+ addSupportedValues(TrailerState)
+ break;
+ case VehicleProperty::GENERAL_SAFETY_REGULATION_COMPLIANCE_REQUIREMENT:
+ addSupportedValues(GsrComplianceRequirementType)
+ break;
+ case VehicleProperty::SHUTDOWN_REQUEST:
+ addSupportedValues(VehicleApPowerStateShutdownParam)
+ break;
+ case VehicleProperty::VEHICLE_DRIVING_AUTOMATION_CURRENT_LEVEL:
+ addSupportedValues(VehicleAutonomousState)
+ break;
+ case VehicleProperty::VEHICLE_DRIVING_AUTOMATION_TARGET_LEVEL:
+ addSupportedValues(VehicleAutonomousState)
+ break;
+ case VehicleProperty::CAMERA_SERVICE_CURRENT_STATE:
+ addSupportedValues(CameraServiceState)
+ break;
+ case VehicleProperty::AUTOMATIC_EMERGENCY_BRAKING_STATE:
+ addSupportedValues(AutomaticEmergencyBrakingState)
+ addSupportedValues(ErrorState)
+ break;
+ case VehicleProperty::FORWARD_COLLISION_WARNING_STATE:
+ addSupportedValues(ForwardCollisionWarningState)
+ addSupportedValues(ErrorState)
+ break;
+ case VehicleProperty::BLIND_SPOT_WARNING_STATE:
+ addSupportedValues(BlindSpotWarningState)
+ addSupportedValues(ErrorState)
+ break;
+ case VehicleProperty::LANE_DEPARTURE_WARNING_STATE:
+ addSupportedValues(LaneDepartureWarningState)
+ addSupportedValues(ErrorState)
+ break;
+ case VehicleProperty::LANE_KEEP_ASSIST_STATE:
+ addSupportedValues(LaneKeepAssistState)
+ addSupportedValues(ErrorState)
+ break;
+ case VehicleProperty::LANE_CENTERING_ASSIST_COMMAND:
+ addSupportedValues(LaneCenteringAssistCommand)
+ break;
+ case VehicleProperty::LANE_CENTERING_ASSIST_STATE:
+ addSupportedValues(LaneCenteringAssistState)
+ addSupportedValues(ErrorState)
+ break;
+ case VehicleProperty::EMERGENCY_LANE_KEEP_ASSIST_STATE:
+ addSupportedValues(EmergencyLaneKeepAssistState)
+ addSupportedValues(ErrorState)
+ break;
+ case VehicleProperty::CRUISE_CONTROL_TYPE:
+ addSupportedValues(CruiseControlType)
+ addSupportedValues(ErrorState)
+ break;
+ case VehicleProperty::CRUISE_CONTROL_STATE:
+ addSupportedValues(CruiseControlState)
+ addSupportedValues(ErrorState)
+ break;
+ case VehicleProperty::CRUISE_CONTROL_COMMAND:
+ addSupportedValues(CruiseControlCommand)
+ break;
+ case VehicleProperty::HANDS_ON_DETECTION_DRIVER_STATE:
+ addSupportedValues(HandsOnDetectionDriverState)
+ addSupportedValues(ErrorState)
+ break;
+ case VehicleProperty::HANDS_ON_DETECTION_WARNING:
+ addSupportedValues(HandsOnDetectionWarning)
+ addSupportedValues(ErrorState)
+ break;
+ case VehicleProperty::DRIVER_DROWSINESS_ATTENTION_STATE:
+ addSupportedValues(DriverDrowsinessAttentionState)
+ addSupportedValues(ErrorState)
+ break;
+ case VehicleProperty::DRIVER_DROWSINESS_ATTENTION_WARNING:
+ addSupportedValues(DriverDrowsinessAttentionWarning)
+ addSupportedValues(ErrorState)
+ break;
+ case VehicleProperty::DRIVER_DISTRACTION_STATE:
+ addSupportedValues(DriverDistractionState)
+ addSupportedValues(ErrorState)
+ break;
+ case VehicleProperty::DRIVER_DISTRACTION_WARNING:
+ addSupportedValues(DriverDistractionWarning)
+ addSupportedValues(ErrorState)
+ break;
+ case VehicleProperty::LOW_SPEED_COLLISION_WARNING_STATE:
+ addSupportedValues(LowSpeedCollisionWarningState)
+ addSupportedValues(ErrorState)
+ break;
+ case VehicleProperty::CROSS_TRAFFIC_MONITORING_WARNING_STATE:
+ addSupportedValues(CrossTrafficMonitoringWarningState)
+ addSupportedValues(ErrorState)
+ break;
+ case VehicleProperty::LOW_SPEED_AUTOMATIC_EMERGENCY_BRAKING_STATE:
+ addSupportedValues(LowSpeedAutomaticEmergencyBrakingState)
+ addSupportedValues(ErrorState)
+ break;
+
+ default:
+ // Do nothing.
+ break;
+ }
+ return supportedValues;
+}
+} // aidl::android::hardware::automotive::vehicle
diff --git a/automotive/vehicle/aidl/generated_lib/4/cpp/VersionForVehicleProperty.h b/automotive/vehicle/aidl/generated_lib/4/cpp/VersionForVehicleProperty.h
index 5f6e047..ff69759 100644
--- a/automotive/vehicle/aidl/generated_lib/4/cpp/VersionForVehicleProperty.h
+++ b/automotive/vehicle/aidl/generated_lib/4/cpp/VersionForVehicleProperty.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2023 The Android Open Source Project
+ * Copyright (C) 2025 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/automotive/vehicle/aidl/generated_lib/4/java/AccessForVehicleProperty.java b/automotive/vehicle/aidl/generated_lib/4/java/AccessForVehicleProperty.java
index 1a68d4d..8f42a83 100644
--- a/automotive/vehicle/aidl/generated_lib/4/java/AccessForVehicleProperty.java
+++ b/automotive/vehicle/aidl/generated_lib/4/java/AccessForVehicleProperty.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2023 The Android Open Source Project
+ * Copyright (C) 2025 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/automotive/vehicle/aidl/generated_lib/4/java/AnnotationsForVehicleProperty.java b/automotive/vehicle/aidl/generated_lib/4/java/AnnotationsForVehicleProperty.java
index 1d79180..07f55b1 100644
--- a/automotive/vehicle/aidl/generated_lib/4/java/AnnotationsForVehicleProperty.java
+++ b/automotive/vehicle/aidl/generated_lib/4/java/AnnotationsForVehicleProperty.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2023 The Android Open Source Project
+ * Copyright (C) 2025 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/automotive/vehicle/aidl/generated_lib/4/java/ChangeModeForVehicleProperty.java b/automotive/vehicle/aidl/generated_lib/4/java/ChangeModeForVehicleProperty.java
index a0dab66..cf44887 100644
--- a/automotive/vehicle/aidl/generated_lib/4/java/ChangeModeForVehicleProperty.java
+++ b/automotive/vehicle/aidl/generated_lib/4/java/ChangeModeForVehicleProperty.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2023 The Android Open Source Project
+ * Copyright (C) 2025 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/automotive/vehicle/aidl/generated_lib/4/java/EnumForVehicleProperty.java b/automotive/vehicle/aidl/generated_lib/4/java/EnumForVehicleProperty.java
index 7ab14ec..fe88da8 100644
--- a/automotive/vehicle/aidl/generated_lib/4/java/EnumForVehicleProperty.java
+++ b/automotive/vehicle/aidl/generated_lib/4/java/EnumForVehicleProperty.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2023 The Android Open Source Project
+ * Copyright (C) 2025 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/automotive/vehicle/aidl/generated_lib/4/java/UnitsForVehicleProperty.java b/automotive/vehicle/aidl/generated_lib/4/java/UnitsForVehicleProperty.java
index b30c8e6..3a35dbb 100644
--- a/automotive/vehicle/aidl/generated_lib/4/java/UnitsForVehicleProperty.java
+++ b/automotive/vehicle/aidl/generated_lib/4/java/UnitsForVehicleProperty.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2023 The Android Open Source Project
+ * Copyright (C) 2025 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/automotive/vehicle/aidl/impl/current/utils/common/include/VehicleHalTypes.h b/automotive/vehicle/aidl/impl/current/utils/common/include/VehicleHalTypes.h
index fcc006b..19d2f71 100644
--- a/automotive/vehicle/aidl/impl/current/utils/common/include/VehicleHalTypes.h
+++ b/automotive/vehicle/aidl/impl/current/utils/common/include/VehicleHalTypes.h
@@ -24,6 +24,7 @@
#include <aidl/android/hardware/automotive/vehicle/CruiseControlCommand.h>
#include <aidl/android/hardware/automotive/vehicle/CruiseControlState.h>
#include <aidl/android/hardware/automotive/vehicle/CruiseControlType.h>
+#include <aidl/android/hardware/automotive/vehicle/CustomInputType.h>
#include <aidl/android/hardware/automotive/vehicle/DiagnosticFloatSensorIndex.h>
#include <aidl/android/hardware/automotive/vehicle/DiagnosticIntegerSensorIndex.h>
#include <aidl/android/hardware/automotive/vehicle/DriverDistractionState.h>
@@ -31,9 +32,13 @@
#include <aidl/android/hardware/automotive/vehicle/DriverDrowsinessAttentionState.h>
#include <aidl/android/hardware/automotive/vehicle/DriverDrowsinessAttentionWarning.h>
#include <aidl/android/hardware/automotive/vehicle/ElectronicStabilityControlState.h>
+#include <aidl/android/hardware/automotive/vehicle/ElectronicTollCollectionCardStatus.h>
+#include <aidl/android/hardware/automotive/vehicle/ElectronicTollCollectionCardType.h>
#include <aidl/android/hardware/automotive/vehicle/EmergencyLaneKeepAssistState.h>
#include <aidl/android/hardware/automotive/vehicle/ErrorState.h>
+#include <aidl/android/hardware/automotive/vehicle/EvChargeState.h>
#include <aidl/android/hardware/automotive/vehicle/EvConnectorType.h>
+#include <aidl/android/hardware/automotive/vehicle/EvRegenerativeBrakingState.h>
#include <aidl/android/hardware/automotive/vehicle/EvStoppingMode.h>
#include <aidl/android/hardware/automotive/vehicle/EvsServiceState.h>
#include <aidl/android/hardware/automotive/vehicle/EvsServiceType.h>
@@ -62,6 +67,7 @@
#include <aidl/android/hardware/automotive/vehicle/Obd2SecondaryAirStatus.h>
#include <aidl/android/hardware/automotive/vehicle/Obd2SparkIgnitionMonitors.h>
#include <aidl/android/hardware/automotive/vehicle/PortLocationType.h>
+#include <aidl/android/hardware/automotive/vehicle/RotaryInputType.h>
#include <aidl/android/hardware/automotive/vehicle/SetValueRequest.h>
#include <aidl/android/hardware/automotive/vehicle/SetValueResult.h>
#include <aidl/android/hardware/automotive/vehicle/SetValueResults.h>
@@ -69,10 +75,12 @@
#include <aidl/android/hardware/automotive/vehicle/SubscribeOptions.h>
#include <aidl/android/hardware/automotive/vehicle/SupportedValuesListResult.h>
#include <aidl/android/hardware/automotive/vehicle/SupportedValuesListResults.h>
+#include <aidl/android/hardware/automotive/vehicle/TrailerState.h>
#include <aidl/android/hardware/automotive/vehicle/VehicleAirbagLocation.h>
#include <aidl/android/hardware/automotive/vehicle/VehicleApPowerBootupReason.h>
#include <aidl/android/hardware/automotive/vehicle/VehicleApPowerStateReport.h>
#include <aidl/android/hardware/automotive/vehicle/VehicleApPowerStateReq.h>
+#include <aidl/android/hardware/automotive/vehicle/VehicleApPowerStateShutdownParam.h>
#include <aidl/android/hardware/automotive/vehicle/VehicleArea.h>
#include <aidl/android/hardware/automotive/vehicle/VehicleAreaDoor.h>
#include <aidl/android/hardware/automotive/vehicle/VehicleAreaMirror.h>
diff --git a/automotive/vehicle/tools/generate_annotation_enums.py b/automotive/vehicle/tools/generate_annotation_enums.py
index 5367f3f..44a810e 100755
--- a/automotive/vehicle/tools/generate_annotation_enums.py
+++ b/automotive/vehicle/tools/generate_annotation_enums.py
@@ -42,6 +42,7 @@
ACCESS_CPP_FILE_PATH = GENERATED_LIB + '/cpp/AccessForVehicleProperty.h'
CHANGE_MODE_JAVA_FILE_PATH = GENERATED_LIB + '/java/ChangeModeForVehicleProperty.java'
ACCESS_JAVA_FILE_PATH = GENERATED_LIB + '/java/AccessForVehicleProperty.java'
+ENUM_CPP_FILE_PATH = GENERATED_LIB + '/cpp/EnumForVehicleProperty.h'
ENUM_JAVA_FILE_PATH = GENERATED_LIB + '/java/EnumForVehicleProperty.java'
UNITS_JAVA_FILE_PATH = GENERATED_LIB + '/java/UnitsForVehicleProperty.java'
VERSION_CPP_FILE_PATH = GENERATED_LIB + '/cpp/VersionForVehicleProperty.h'
@@ -84,7 +85,7 @@
]
LICENSE = """/*
- * Copyright (C) 2023 The Android Open Source Project
+ * Copyright (C) 2025 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -173,6 +174,40 @@
}} // aidl::android::hardware::automotive::vehicle
"""
+ENUM_CPP_FORMATTER = """#pragma once
+
+#define addSupportedValues(EnumType) \\
+{{ \\
+constexpr auto values = ndk::internal::enum_values<EnumType>; \\
+for (size_t i = 0; i < values.size(); i++) {{ \\
+ supportedValues.insert(static_cast<int64_t>(values[i])); \\
+}} \\
+}}
+
+#include <VehicleHalTypes.h>
+#include <aidl/android/hardware/automotive/vehicle/VehicleProperty.h>
+
+#include <unordered_set>
+
+namespace aidl::android::hardware::automotive::vehicle {{
+std::unordered_set<int64_t> getSupportedEnumValuesForProperty(VehicleProperty propertyId) {{
+ std::unordered_set<int64_t> supportedValues;
+ switch (propertyId) {{
+{0}
+ default:
+ // Do nothing.
+ break;
+ }}
+ return supportedValues;
+}}
+}} // aidl::android::hardware::automotive::vehicle
+"""
+
+ENUM_CPP_SWITCH_CASE_FORMATTER = """ case {0}:
+{1}
+ break;
+"""
+
CHANGE_MODE_JAVA_FORMATTER = """package android.hardware.automotive.vehicle;
import java.util.Map;
@@ -403,7 +438,16 @@
elif field == 'enum_types':
if len(config.enum_types) < 1:
continue
- if not cpp:
+ if cpp:
+ switch_case = ''
+ for index, enum_type in enumerate(config.enum_types):
+ if index != 0:
+ switch_case += '\n'
+ switch_case += TAB + TAB + TAB + 'addSupportedValues({0})'.format(enum_type)
+ content += ENUM_CPP_SWITCH_CASE_FORMATTER.format(
+ 'VehicleProperty::' + config.name, switch_case)
+ continue
+ else:
value = "List.of(" + ', '.join([class_name + ".class" for class_name in config.enum_types]) + ")"
elif field == 'unit_type':
if not config.unit_type:
@@ -596,8 +640,10 @@
generated_files.append(access_mode)
enum_types = GeneratedFile('enum_types')
+ enum_types.setCppFilePath(os.path.join(android_top, ENUM_CPP_FILE_PATH))
enum_types.setJavaFilePath(os.path.join(android_top, ENUM_JAVA_FILE_PATH))
enum_types.setJavaFormatter(ENUM_JAVA_FORMATTER)
+ enum_types.setCppFormatter(ENUM_CPP_FORMATTER)
generated_files.append(enum_types)
unit_type = GeneratedFile('unit_type')
diff --git a/automotive/vehicle/vts/src/VtsHalAutomotiveVehicle_TargetTest.cpp b/automotive/vehicle/vts/src/VtsHalAutomotiveVehicle_TargetTest.cpp
index c93de09..d4b0528 100644
--- a/automotive/vehicle/vts/src/VtsHalAutomotiveVehicle_TargetTest.cpp
+++ b/automotive/vehicle/vts/src/VtsHalAutomotiveVehicle_TargetTest.cpp
@@ -19,6 +19,7 @@
#include <AccessForVehicleProperty.h>
#include <AnnotationsForVehicleProperty.h>
#include <ChangeModeForVehicleProperty.h>
+#include <EnumForVehicleProperty.h>
#include <IVhalClient.h>
#include <VehicleHalTypes.h>
#include <VehicleUtils.h>
@@ -49,10 +50,15 @@
using ::aidl::android::hardware::automotive::vehicle::AllowedAccessForVehicleProperty;
using ::aidl::android::hardware::automotive::vehicle::AnnotationsForVehicleProperty;
using ::aidl::android::hardware::automotive::vehicle::ChangeModeForVehicleProperty;
+using ::aidl::android::hardware::automotive::vehicle::getSupportedEnumValuesForProperty;
using ::aidl::android::hardware::automotive::vehicle::HasSupportedValueInfo;
using ::aidl::android::hardware::automotive::vehicle::IVehicle;
+using ::aidl::android::hardware::automotive::vehicle::MinMaxSupportedValueResult;
+using ::aidl::android::hardware::automotive::vehicle::PropIdAreaId;
+using ::aidl::android::hardware::automotive::vehicle::RawPropValues;
using ::aidl::android::hardware::automotive::vehicle::StatusCode;
using ::aidl::android::hardware::automotive::vehicle::SubscribeOptions;
+using ::aidl::android::hardware::automotive::vehicle::SupportedValuesListResult;
using ::aidl::android::hardware::automotive::vehicle::toString;
using ::aidl::android::hardware::automotive::vehicle::VehicleArea;
using ::aidl::android::hardware::automotive::vehicle::VehicleProperty;
@@ -172,6 +178,9 @@
const std::vector<std::unique_ptr<IHalAreaConfig>>& areaConfigs) const;
void verifyProperty(VehicleProperty propId, std::vector<VehiclePropertyAccess> accessModes,
VehiclePropertyChangeMode changeMode);
+ void testGetMinMaxSupportedValueForPropIdAreaId(int32_t propId,
+ const IHalAreaConfig& areaConfig,
+ bool minMaxValueRequired);
static bool isBooleanGlobalProp(int32_t property) {
return (property & toInt(VehiclePropertyType::MASK)) ==
@@ -259,21 +268,21 @@
readWritePresent = true;
break;
default:
- ASSERT_EQ(access, toInt(VehiclePropertyAccess::NONE)) << StringPrintf(
- "Area access can be NONE only if global property access is also NONE");
+ ASSERT_EQ(access, toInt(VehiclePropertyAccess::NONE))
+ << "Area access can be NONE only if global property access is also NONE";
return;
}
}
if (readOnlyPresent) {
- ASSERT_FALSE(writeOnlyPresent) << StringPrintf(
- "Found both READ_ONLY and WRITE_ONLY access modes in area configs, which is not "
- "supported");
+ ASSERT_FALSE(writeOnlyPresent)
+ << "Found both READ_ONLY and WRITE_ONLY access modes in area configs, which is not "
+ "supported";
maximalAreaAccessSubset = toInt(VehiclePropertyAccess::READ);
} else if (writeOnlyPresent) {
- ASSERT_FALSE(readWritePresent) << StringPrintf(
- "Found both WRITE_ONLY and READ_WRITE access modes in area configs, which is not "
- "supported");
+ ASSERT_FALSE(readWritePresent) << "Found both WRITE_ONLY and READ_WRITE access modes in "
+ "area configs, which is not "
+ "supported";
maximalAreaAccessSubset = toInt(VehiclePropertyAccess::WRITE);
} else if (readWritePresent) {
maximalAreaAccessSubset = toInt(VehiclePropertyAccess::READ_WRITE);
@@ -801,7 +810,153 @@
}
}
-void verifyPropertyConfigMinMaxValue(const IHalPropConfig* config, int propertyType) {
+void verifyRawPropValues(const RawPropValues& rawPropValues, int32_t propertyType) {
+ switch (propertyType) {
+ case toInt(VehiclePropertyType::INT32):
+ ASSERT_THAT(rawPropValues.int32Values, ::testing::SizeIs(1))
+ << "int32Values field must contain exactly one element for INT32 type";
+ break;
+ case toInt(VehiclePropertyType::FLOAT):
+ ASSERT_THAT(rawPropValues.floatValues, ::testing::SizeIs(1))
+ << "floatValues field must contain exactly one element for FLOAT type";
+ break;
+ case toInt(VehiclePropertyType::INT64):
+ ASSERT_THAT(rawPropValues.int64Values, ::testing::SizeIs(1))
+ << "int64Values field must contain exactly one element for INT64 type";
+ break;
+ default:
+ // This must not happen since we already checked this condition in
+ // verifyPropertyConfigMinMaxValue
+ FAIL() << "minSupportedValue or maxSupportedValue must only be specified for "
+ "INT32, INT64 or FLOAT type property";
+ break;
+ }
+}
+
+void VtsHalAutomotiveTest::testGetMinMaxSupportedValueForPropIdAreaId(
+ int32_t propId, const IHalAreaConfig& areaConfig, bool minMaxValueRequired) {
+ int areaId = areaConfig.getAreaId();
+ int propertyType = propId & toInt(VehiclePropertyType::MASK);
+ std::optional<HasSupportedValueInfo> maybeHasSupportedValueInfo =
+ areaConfig.getHasSupportedValueInfo();
+ if (!maybeHasSupportedValueInfo.has_value()) {
+ return;
+ }
+ if (!maybeHasSupportedValueInfo->hasMaxSupportedValue &&
+ !maybeHasSupportedValueInfo->hasMaxSupportedValue) {
+ return;
+ }
+ VhalClientResult<std::vector<MinMaxSupportedValueResult>> result =
+ mVhalClient->getMinMaxSupportedValue({PropIdAreaId{
+ .propId = propId,
+ .areaId = areaId,
+ }});
+ ASSERT_RESULT_OK(result)
+ << "getMinMaxSupportedValue must return okay result if hasMaxSupportedValue "
+ << " or hasMaxSupportedValue is true";
+ ASSERT_THAT(*result, ::testing::SizeIs(1))
+ << "getMinMaxSupportedValue result list size must be 1 for 1 request";
+ const MinMaxSupportedValueResult& individualResult = (*result)[0];
+ if (minMaxValueRequired) {
+ ASSERT_EQ(individualResult.status, StatusCode::OK)
+ << "getMinMaxSupportedValue must return okay status if min/max value is required "
+ "for";
+ }
+ if (individualResult.status != StatusCode::OK) {
+ return;
+ }
+ bool hasMinValue = individualResult.minSupportedValue.has_value();
+ bool hasMaxValue = individualResult.maxSupportedValue.has_value();
+ if (maybeHasSupportedValueInfo->hasMinSupportedValue) {
+ ASSERT_TRUE(hasMinValue)
+ << "minSupportedValue field must not be null if hasMinSupportedValue is true";
+ }
+ if (maybeHasSupportedValueInfo->hasMaxSupportedValue) {
+ ASSERT_TRUE(hasMaxValue)
+ << "minSupportedValue field must not be null if hasMinSupportedValue is true";
+ }
+ if (hasMinValue) {
+ ASSERT_NO_FATAL_FAILURE(
+ verifyRawPropValues(*individualResult.minSupportedValue, propertyType))
+ << "MinMaxSupportedValueResult.minSupportedValue is not a valid RawPropValues for "
+ << "the property type, value: " << (individualResult.minSupportedValue)->toString();
+ }
+ if (hasMaxValue) {
+ ASSERT_NO_FATAL_FAILURE(
+ verifyRawPropValues(*individualResult.maxSupportedValue, propertyType))
+ << "MinMaxSupportedValueResult.maxSupportedValue is not a valid RawPropValues for "
+ << "the property type, value: " << (individualResult.maxSupportedValue)->toString();
+ }
+ if (hasMinValue && hasMaxValue) {
+ int32_t minInt32Value;
+ int32_t maxInt32Value;
+ float minFloatValue;
+ float maxFloatValue;
+ int64_t minInt64Value;
+ int64_t maxInt64Value;
+ switch (propertyType) {
+ case toInt(VehiclePropertyType::INT32):
+ minInt32Value = (individualResult.minSupportedValue)->int32Values[0];
+ maxInt32Value = (individualResult.maxSupportedValue)->int32Values[0];
+ ASSERT_LE(minInt32Value, maxInt32Value)
+ << "minSupportedValue must be less or equal to maxSupportedValue";
+ break;
+ case toInt(VehiclePropertyType::FLOAT):
+ minFloatValue = (individualResult.minSupportedValue)->floatValues[0];
+ maxFloatValue = (individualResult.maxSupportedValue)->floatValues[0];
+ ASSERT_LE(minFloatValue, maxFloatValue)
+ << "minSupportedValue must be less or equal to maxSupportedValue";
+ break;
+ case toInt(VehiclePropertyType::INT64):
+ minInt64Value = (individualResult.minSupportedValue)->int64Values[0];
+ maxInt64Value = (individualResult.maxSupportedValue)->int64Values[0];
+ ASSERT_LE(minInt64Value, maxInt64Value)
+ << "minSupportedValue must be less or equal to maxSupportedValue";
+ break;
+ default:
+ // This must not happen since we already checked this condition in
+ // verifyPropertyConfigMinMaxValue
+ FAIL() << "minSupportedValue or maxSupportedValue must only be specified for "
+ "INT32, INT64 or FLOAT type property";
+ break;
+ }
+ }
+}
+
+// Test the getMinMaxSupportedValues API. We use this one test case to cover all properties that
+// may support this API.
+TEST_P(VtsHalAutomotiveVehicleTargetTest, testGetMinMaxSupportedValue) {
+ if (!mVhalClient->isAidlVhal() || mVhalClient->getRemoteInterfaceVersion() < 4) {
+ GTEST_SKIP() << "Skip checking testGetMinMaxSupportedValues the behavior is not supported "
+ "for current VHAL version";
+ }
+
+ auto configsResult = mVhalClient->getAllPropConfigs();
+ ASSERT_TRUE(configsResult.ok())
+ << "Failed to get all property configs, error: " << configsResult.error().message();
+
+ for (const auto& cfgPtr : configsResult.value()) {
+ int32_t propId = cfgPtr->getPropId();
+ bool minMaxValueRequired = false;
+ std::unordered_set<std::string> annotations;
+ auto it = AnnotationsForVehicleProperty.find(static_cast<VehicleProperty>(propId));
+ if (it != AnnotationsForVehicleProperty.end()) {
+ annotations = it->second;
+ }
+ if (annotations.find(ANNOTATION_REQUIRE_MIN_MAX_VALUE) != annotations.end()) {
+ minMaxValueRequired = true;
+ }
+ const std::vector<std::unique_ptr<IHalAreaConfig>>& areaConfigs = cfgPtr->getAreaConfigs();
+ for (const auto& areaCfgPtr : areaConfigs) {
+ EXPECT_NO_FATAL_FAILURE(testGetMinMaxSupportedValueForPropIdAreaId(propId, *areaCfgPtr,
+ minMaxValueRequired))
+ << "test getMinMaxSupportedValue failed for property: "
+ << propIdToString(propId) << ", areaId: " << areaCfgPtr->getAreaId();
+ }
+ }
+}
+
+void verifyPropertyConfigMinMaxValue(const IHalPropConfig* config, int32_t propertyType) {
for (const auto& areaConfig : config->getAreaConfigs()) {
std::optional<HasSupportedValueInfo> maybeHasSupportedValueInfo =
areaConfig->getHasSupportedValueInfo();
@@ -853,6 +1008,17 @@
"maxInt64Value is specified in VehicleAreaConfig";
}
}
+ if (maybeHasSupportedValueInfo.has_value() &&
+ (maybeHasSupportedValueInfo->hasMinSupportedValue ||
+ maybeHasSupportedValueInfo->hasMaxSupportedValue)) {
+ EXPECT_THAT(propertyType, ::testing::AnyOf(toInt(VehiclePropertyType::INT32),
+ toInt(VehiclePropertyType::INT64),
+ toInt(VehiclePropertyType::FLOAT)))
+ << "HasSupportedValueInfo.hasMinSupportedValue and "
+ "HasSupportedValueInfo.hasMaxSupportedValue is only allowed to be set to "
+ "true "
+ "for INT32, INT64 or FLOAT type property";
+ }
}
}
@@ -930,7 +1096,12 @@
"supported enum values is not empty";
}
- // TODO(b/381123190): Verify the supported enum values are within the defined enum type.
+ if (!supportedEnumValues.empty()) {
+ std::unordered_set<int64_t> allowedEnumValues = getSupportedEnumValuesForProperty(
+ static_cast<VehicleProperty>(config->getPropId()));
+ EXPECT_THAT(supportedEnumValues, ::testing::IsSubsetOf(allowedEnumValues))
+ << "Supported enum values must be part of defined enum type";
+ }
}
}