Allow setting supported values for reference VHAL.
Debug command in reference VHAL now allows setting supported values
for all properties that specify hasSupportedValuesList to true.
We also introduce a new field "supportedValues" in the fake VHAL
JSON config to allow specifying the initial supported values. If
this field is not specified, we will fallback to use
supportedEnumValues field.
This CL add supportedValues field to HVAC_TEMP_SET and
EV_CHARGE_PERCENT_LIMIT to demonstrate how it may be used.
Flag: EXEMPT VHAL
Test: atest FakeVehicleHardwareTest
Bug: 394692817
Change-Id: I5f602d596360732e2142d691dcce907d6786d7bf
diff --git a/automotive/vehicle/aidl/impl/current/default_config/JsonConfigLoader/include/ConfigDeclaration.h b/automotive/vehicle/aidl/impl/current/default_config/JsonConfigLoader/include/ConfigDeclaration.h
index 40ac129..c4b794a 100644
--- a/automotive/vehicle/aidl/impl/current/default_config/JsonConfigLoader/include/ConfigDeclaration.h
+++ b/automotive/vehicle/aidl/impl/current/default_config/JsonConfigLoader/include/ConfigDeclaration.h
@@ -39,6 +39,9 @@
std::unordered_map<int32_t, aidl::android::hardware::automotive::vehicle::RawPropValues>
initialAreaValues;
+ // The optional supported values for each areaId.
+ std::unordered_map<int32_t, std::vector<float>> supportedValuesForAreaId;
+
inline bool operator==(const ConfigDeclaration& other) const {
return (config == other.config && initialValue == other.initialValue &&
initialAreaValues == other.initialAreaValues);
diff --git a/automotive/vehicle/aidl/impl/current/default_config/JsonConfigLoader/src/JsonConfigLoader.cpp b/automotive/vehicle/aidl/impl/current/default_config/JsonConfigLoader/src/JsonConfigLoader.cpp
index 5b945b2..f2fc0a5 100644
--- a/automotive/vehicle/aidl/impl/current/default_config/JsonConfigLoader/src/JsonConfigLoader.cpp
+++ b/automotive/vehicle/aidl/impl/current/default_config/JsonConfigLoader/src/JsonConfigLoader.cpp
@@ -602,6 +602,13 @@
areaConfig.supportedEnumValues = std::move(supportedEnumValues);
}
+ std::vector<float> supportedValues;
+ tryParseJsonArrayToVariable(jsonAreaConfig, "supportedValues", /*optional=*/true,
+ &supportedValues, errors);
+ if (!supportedValues.empty()) {
+ config->supportedValuesForAreaId[areaId] = std::move(supportedValues);
+ }
+
if (jsonAreaConfig.isMember("hasSupportedValueInfo")) {
HasSupportedValueInfo hasSupportedValueInfo = HasSupportedValueInfo{};
const Json::Value& jsonHasSupportedValueInfo = jsonAreaConfig["hasSupportedValueInfo"];
diff --git a/automotive/vehicle/aidl/impl/current/default_config/config/DefaultProperties.json b/automotive/vehicle/aidl/impl/current/default_config/config/DefaultProperties.json
index 2915cc1..d32b335 100644
--- a/automotive/vehicle/aidl/impl/current/default_config/config/DefaultProperties.json
+++ b/automotive/vehicle/aidl/impl/current/default_config/config/DefaultProperties.json
@@ -1600,21 +1600,30 @@
"supportedEnumValues": [
"Constants::LIGHT_STATE_OFF",
"Constants::LIGHT_STATE_ON"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
},
{
"areaId": "Constants::SEAT_1_RIGHT",
"supportedEnumValues": [
"Constants::LIGHT_STATE_OFF",
"Constants::LIGHT_STATE_ON"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
},
{
"areaId": "Constants::SEAT_2_LEFT_2_RIGHT_2_CENTER",
"supportedEnumValues": [
"Constants::LIGHT_STATE_OFF",
"Constants::LIGHT_STATE_ON"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
}
]
},
@@ -1632,7 +1641,10 @@
"Constants::LIGHT_SWITCH_OFF",
"Constants::LIGHT_SWITCH_ON",
"Constants::LIGHT_SWITCH_AUTO"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
},
{
"areaId": "Constants::SEAT_1_RIGHT",
@@ -1640,7 +1652,10 @@
"Constants::LIGHT_SWITCH_OFF",
"Constants::LIGHT_SWITCH_ON",
"Constants::LIGHT_SWITCH_AUTO"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
},
{
"areaId": "Constants::SEAT_2_LEFT_2_RIGHT_2_CENTER",
@@ -1648,7 +1663,10 @@
"Constants::LIGHT_SWITCH_OFF",
"Constants::LIGHT_SWITCH_ON",
"Constants::LIGHT_SWITCH_AUTO"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
}
]
},
@@ -1948,7 +1966,10 @@
"VehicleAirbagLocation::LEFT_SIDE",
"VehicleAirbagLocation::RIGHT_SIDE",
"VehicleAirbagLocation::CURTAIN"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
},
{
"areaId": "Constants::SEAT_1_RIGHT",
@@ -1958,21 +1979,30 @@
"VehicleAirbagLocation::LEFT_SIDE",
"VehicleAirbagLocation::RIGHT_SIDE",
"VehicleAirbagLocation::CURTAIN"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
},
{
"areaId": "Constants::SEAT_2_LEFT",
"supportedEnumValues": [
"VehicleAirbagLocation::FRONT",
"VehicleAirbagLocation::CURTAIN"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
},
{
"areaId": "Constants::SEAT_2_RIGHT",
"supportedEnumValues": [
"VehicleAirbagLocation::FRONT",
"VehicleAirbagLocation::CURTAIN"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
}
]
},
@@ -2186,6 +2216,21 @@
60,
80,
100
+ ],
+ "areas": [
+ {
+ "areaId": 0,
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ },
+ "supportedValues": [
+ 20,
+ 40,
+ 60,
+ 80,
+ 100
+ ]
+ }
]
},
{
@@ -2557,7 +2602,10 @@
"Constants::EV_STOPPING_MODE_CREEP",
"Constants::EV_STOPPING_MODE_ROLL",
"Constants::EV_STOPPING_MODE_HOLD"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
}
]
},
@@ -3253,8 +3301,42 @@
"maxFloatValue": 32.5,
"hasSupportedValueInfo": {
"hasMinSupportedValue": true,
- "hasMaxSupportedValue": true
- }
+ "hasMaxSupportedValue": true,
+ "hasSupportedValuesList": true
+ },
+ "supportedValues": [
+ 17.5,
+ 18,
+ 18.5,
+ 19,
+ 19.5,
+ 20,
+ 20.5,
+ 21,
+ 21.5,
+ 22,
+ 22.5,
+ 23,
+ 23.5,
+ 24,
+ 24.5,
+ 25,
+ 25.5,
+ 26,
+ 26.5,
+ 27,
+ 27.5,
+ 28,
+ 28.5,
+ 29,
+ 29.5,
+ 30,
+ 30.5,
+ 31,
+ 31.5,
+ 32,
+ 32.5
+ ]
},
{
"areaId": "Constants::SEAT_1_RIGHT",
@@ -3262,8 +3344,42 @@
"maxFloatValue": 32.5,
"hasSupportedValueInfo": {
"hasMinSupportedValue": true,
- "hasMaxSupportedValue": true
- }
+ "hasMaxSupportedValue": true,
+ "hasSupportedValuesList": true
+ },
+ "supportedValues": [
+ 17.5,
+ 18,
+ 18.5,
+ 19,
+ 19.5,
+ 20,
+ 20.5,
+ 21,
+ 21.5,
+ 22,
+ 22.5,
+ 23,
+ 23.5,
+ 24,
+ 24.5,
+ 25,
+ 25.5,
+ 26,
+ 26.5,
+ 27,
+ 27.5,
+ 28,
+ 28.5,
+ 29,
+ 29.5,
+ 30,
+ 30.5,
+ 31,
+ 31.5,
+ 32,
+ 32.5
+ ]
},
{
"areaId": "Constants::SEAT_2_LEFT",
@@ -3271,8 +3387,42 @@
"maxFloatValue": 32.5,
"hasSupportedValueInfo": {
"hasMinSupportedValue": true,
- "hasMaxSupportedValue": true
- }
+ "hasMaxSupportedValue": true,
+ "hasSupportedValuesList": true
+ },
+ "supportedValues": [
+ 17.5,
+ 18,
+ 18.5,
+ 19,
+ 19.5,
+ 20,
+ 20.5,
+ 21,
+ 21.5,
+ 22,
+ 22.5,
+ 23,
+ 23.5,
+ 24,
+ 24.5,
+ 25,
+ 25.5,
+ 26,
+ 26.5,
+ 27,
+ 27.5,
+ 28,
+ 28.5,
+ 29,
+ 29.5,
+ 30,
+ 30.5,
+ 31,
+ 31.5,
+ 32,
+ 32.5
+ ]
},
{
"areaId": "Constants::SEAT_2_RIGHT",
@@ -3280,8 +3430,42 @@
"maxFloatValue": 32.5,
"hasSupportedValueInfo": {
"hasMinSupportedValue": true,
- "hasMaxSupportedValue": true
- }
+ "hasMaxSupportedValue": true,
+ "hasSupportedValuesList": true
+ },
+ "supportedValues": [
+ 17.5,
+ 18,
+ 18.5,
+ 19,
+ 19.5,
+ 20,
+ 20.5,
+ 21,
+ 21.5,
+ 22,
+ 22.5,
+ 23,
+ 23.5,
+ 24,
+ 24.5,
+ 25,
+ 25.5,
+ 26,
+ 26.5,
+ 27,
+ 27.5,
+ 28,
+ 28.5,
+ 29,
+ 29.5,
+ 30,
+ 30.5,
+ 31,
+ 31.5,
+ 32,
+ 32.5
+ ]
},
{
"areaId": "Constants::SEAT_2_CENTER",
@@ -3289,8 +3473,42 @@
"maxFloatValue": 32.5,
"hasSupportedValueInfo": {
"hasMinSupportedValue": true,
- "hasMaxSupportedValue": true
- }
+ "hasMaxSupportedValue": true,
+ "hasSupportedValuesList": true
+ },
+ "supportedValues": [
+ 17.5,
+ 18,
+ 18.5,
+ 19,
+ 19.5,
+ 20,
+ 20.5,
+ 21,
+ 21.5,
+ 22,
+ 22.5,
+ 23,
+ 23.5,
+ 24,
+ 24.5,
+ 25,
+ 25.5,
+ 26,
+ 26.5,
+ 27,
+ 27.5,
+ 28,
+ 28.5,
+ 29,
+ 29.5,
+ 30,
+ 30.5,
+ 31,
+ 31.5,
+ 32,
+ 32.5
+ ]
}
],
"comment":
@@ -3450,7 +3668,10 @@
"ImpactSensorLocation::REAR_LEFT_DOOR_SIDE",
"ImpactSensorLocation::REAR_RIGHT_DOOR_SIDE",
"ImpactSensorLocation::REAR"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
}
]
},
@@ -3971,14 +4192,20 @@
"WindshieldWipersState::OFF",
"WindshieldWipersState::ON",
"WindshieldWipersState::SERVICE"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
},
{
"areaId": "VehicleAreaWindow::REAR_WINDSHIELD",
"supportedEnumValues": [
"WindshieldWipersState::OFF",
"WindshieldWipersState::ON"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
}
]
},
@@ -4007,7 +4234,10 @@
"WindshieldWipersSwitch::CONTINUOUS_LEVEL_5",
"WindshieldWipersSwitch::AUTO",
"WindshieldWipersSwitch::SERVICE"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
},
{
"areaId": "VehicleAreaWindow::REAR_WINDSHIELD",
@@ -4019,7 +4249,10 @@
"WindshieldWipersSwitch::CONTINUOUS_LEVEL_2",
"WindshieldWipersSwitch::AUTO",
"WindshieldWipersSwitch::SERVICE"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
}
]
},
@@ -4363,7 +4596,10 @@
"supportedEnumValues": [
"Constants::LIGHT_STATE_OFF",
"Constants::LIGHT_STATE_ON"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
}
]
},
@@ -4454,7 +4690,10 @@
"Constants::LIGHT_SWITCH_OFF",
"Constants::LIGHT_SWITCH_ON",
"Constants::LIGHT_SWITCH_AUTO"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
}
]
},
@@ -5356,7 +5595,10 @@
"EmergencyLaneKeepAssistState::ACTIVATED_STEER_LEFT",
"EmergencyLaneKeepAssistState::ACTIVATED_STEER_RIGHT",
"EmergencyLaneKeepAssistState::USER_OVERRIDE"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
}
]
},
@@ -5386,7 +5628,10 @@
"CruiseControlType::STANDARD",
"CruiseControlType::ADAPTIVE",
"CruiseControlType::PREDICTIVE"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
}
]
},
@@ -5410,7 +5655,10 @@
"CruiseControlState::USER_OVERRIDE",
"CruiseControlState::SUSPENDED",
"CruiseControlState::FORCED_DEACTIVATION_WARNING"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
}
]
},
@@ -5426,7 +5674,10 @@
"CruiseControlCommand::DECREASE_TARGET_SPEED",
"CruiseControlCommand::INCREASE_TARGET_TIME_GAP",
"CruiseControlCommand::DECREASE_TARGET_TIME_GAP"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
}
]
},
@@ -5508,7 +5759,10 @@
"ErrorState::NOT_AVAILABLE_DISABLED",
"HandsOnDetectionDriverState::HANDS_ON",
"HandsOnDetectionDriverState::HANDS_OFF"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
}
]
},
@@ -5526,7 +5780,10 @@
"ErrorState::NOT_AVAILABLE_DISABLED",
"HandsOnDetectionWarning::NO_WARNING",
"HandsOnDetectionWarning::WARNING"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
}
]
},
@@ -5559,7 +5816,10 @@
"DriverDrowsinessAttentionState::KSS_RATING_7_SLEEPY_NO_EFFORT",
"DriverDrowsinessAttentionState::KSS_RATING_8_SLEEPY_SOME_EFFORT",
"DriverDrowsinessAttentionState::KSS_RATING_9_VERY_SLEEPY"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
}
]
},
@@ -5585,7 +5845,10 @@
"ErrorState::NOT_AVAILABLE_DISABLED",
"DriverDrowsinessAttentionWarning::NO_WARNING",
"DriverDrowsinessAttentionWarning::WARNING"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
}
]
},
@@ -5611,7 +5874,10 @@
"ErrorState::NOT_AVAILABLE_DISABLED",
"DriverDistractionState::NOT_DISTRACTED",
"DriverDistractionState::DISTRACTED"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
}
]
},
@@ -5637,7 +5903,10 @@
"ErrorState::NOT_AVAILABLE_DISABLED",
"DriverDistractionWarning::NO_WARNING",
"DriverDistractionWarning::WARNING"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
}
]
},
@@ -5813,7 +6082,10 @@
"AutomaticEmergencyBrakingState::ENABLED",
"AutomaticEmergencyBrakingState::ACTIVATED",
"AutomaticEmergencyBrakingState::USER_OVERRIDE"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
}
]
},
@@ -5843,7 +6115,10 @@
"ErrorState::NOT_AVAILABLE_DISABLED",
"ForwardCollisionWarningState::NO_WARNING",
"ForwardCollisionWarningState::WARNING"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
}
]
},
@@ -5873,7 +6148,10 @@
"ErrorState::NOT_AVAILABLE_DISABLED",
"BlindSpotWarningState::NO_WARNING",
"BlindSpotWarningState::WARNING"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
},
{
"areaId": "VehicleAreaMirror::DRIVER_RIGHT",
@@ -5885,7 +6163,10 @@
"ErrorState::NOT_AVAILABLE_DISABLED",
"BlindSpotWarningState::NO_WARNING",
"BlindSpotWarningState::WARNING"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
}
]
},
@@ -5915,7 +6196,10 @@
"LaneDepartureWarningState::NO_WARNING",
"LaneDepartureWarningState::WARNING_LEFT",
"LaneDepartureWarningState::WARNING_RIGHT"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
}
]
},
@@ -5946,7 +6230,10 @@
"LaneKeepAssistState::ACTIVATED_STEER_LEFT",
"LaneKeepAssistState::ACTIVATED_STEER_RIGHT",
"LaneKeepAssistState::USER_OVERRIDE"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
}
]
},
@@ -5981,7 +6268,10 @@
"LaneCenteringAssistState::ACTIVATED",
"LaneCenteringAssistState::USER_OVERRIDE",
"LaneCenteringAssistState::FORCED_DEACTIVATION_WARNING"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
}
]
},
@@ -6010,7 +6300,10 @@
"ErrorState::NOT_AVAILABLE_DISABLED",
"LowSpeedCollisionWarningState::NO_WARNING",
"LowSpeedCollisionWarningState::WARNING"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
}
]
},
@@ -6039,7 +6332,10 @@
"ErrorState::NOT_AVAILABLE_DISABLED",
"ElectronicStabilityControlState::ENABLED",
"ElectronicStabilityControlState::ACTIVATED"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
}
]
},
@@ -6073,7 +6369,10 @@
"CrossTrafficMonitoringWarningState::WARNING_REAR_LEFT",
"CrossTrafficMonitoringWarningState::WARNING_REAR_RIGHT",
"CrossTrafficMonitoringWarningState::WARNING_REAR_BOTH"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
}
]
},
@@ -6103,7 +6402,10 @@
"LowSpeedAutomaticEmergencyBrakingState::ENABLED",
"LowSpeedAutomaticEmergencyBrakingState::ACTIVATED",
"LowSpeedAutomaticEmergencyBrakingState::USER_OVERRIDE"
- ]
+ ],
+ "hasSupportedValueInfo": {
+ "hasSupportedValuesList": true
+ }
}
]
},
diff --git a/automotive/vehicle/aidl/impl/current/default_config/config/TestProperties.json b/automotive/vehicle/aidl/impl/current/default_config/config/TestProperties.json
index 5779050..bca6e94 100644
--- a/automotive/vehicle/aidl/impl/current/default_config/config/TestProperties.json
+++ b/automotive/vehicle/aidl/impl/current/default_config/config/TestProperties.json
@@ -117,7 +117,12 @@
"hasMinSupportedValue": true,
"hasMaxSupportedValue": true,
"hasSupportedValuesList": true
- }
+ },
+ "supportedValues": [
+ 1,
+ 2,
+ 3
+ ]
},
{
"defaultValue": {
diff --git a/automotive/vehicle/aidl/impl/current/fake_impl/hardware/include/FakeVehicleHardware.h b/automotive/vehicle/aidl/impl/current/fake_impl/hardware/include/FakeVehicleHardware.h
index b9d315a..d51e430 100644
--- a/automotive/vehicle/aidl/impl/current/fake_impl/hardware/include/FakeVehicleHardware.h
+++ b/automotive/vehicle/aidl/impl/current/fake_impl/hardware/include/FakeVehicleHardware.h
@@ -170,6 +170,13 @@
std::shared_ptr<RecurrentTimer::Callback> recurrentAction;
};
+ struct DumpOptionPropIdAreaIdInfo {
+ int32_t propId;
+ int32_t areaId;
+ std::string propIdStr;
+ std::string areaIdStr;
+ };
+
const std::unique_ptr<obd2frame::FakeObd2Frame> mFakeObd2Frame;
const std::unique_ptr<FakeUserHal> mFakeUserHal;
// RecurrentTimer is thread-safe.
@@ -189,9 +196,6 @@
std::unordered_map<PropIdAreaId, VehiclePropValuePool::RecyclableType, PropIdAreaIdHash>
mSavedProps GUARDED_BY(mLock);
std::unordered_set<PropIdAreaId, PropIdAreaIdHash> mSubOnChangePropIdAreaIds GUARDED_BY(mLock);
- int32_t mMinSupportedValueForTestIntProp GUARDED_BY(mLock) = 0;
- int32_t mMaxSupportedValueForTestIntProp GUARDED_BY(mLock) = 10;
- std::vector<int32_t> mSupportedValuesListForTestIntProp GUARDED_BY(mLock) = {0, 2, 4, 6, 8, 10};
std::unordered_map<PropIdAreaId, aidl::android::hardware::automotive::vehicle::RawPropValues,
PropIdAreaIdHash>
@@ -199,6 +203,10 @@
std::unordered_map<PropIdAreaId, aidl::android::hardware::automotive::vehicle::RawPropValues,
PropIdAreaIdHash>
mMaxSupportedValueByPropIdAreaId GUARDED_BY(mLock);
+ std::unordered_map<PropIdAreaId,
+ std::vector<aidl::android::hardware::automotive::vehicle::RawPropValues>,
+ PropIdAreaIdHash>
+ mSupportedValuesByPropIdAreaId GUARDED_BY(mLock);
// PendingRequestHandler is thread-safe.
mutable PendingRequestHandler<GetValuesCallback,
@@ -327,9 +335,6 @@
float sampleRateHz) REQUIRES(mLock);
void unregisterRefreshLocked(PropIdAreaId propIdAreaId) REQUIRES(mLock);
void refreshTimestampForInterval(int64_t intervalInNanos) EXCLUDES(mLock);
- void triggerSupportedValueChange(
- const aidl::android::hardware::automotive::vehicle::VehiclePropConfig& config)
- EXCLUDES(mLock);
void triggerSupportedValueChange(int32_t propId, int32_t areaId) EXCLUDES(mLock);
template <class T>
void setMinSupportedValueLocked(int32_t propId, int32_t areaId, T minValue) REQUIRES(mLock);
@@ -339,6 +344,8 @@
android::base::Result<void> parseAndSetMinMaxValue(int32_t propId, int32_t areaId,
const std::vector<std::string>& options,
size_t index) EXCLUDES(mLock);
+ android::base::Result<DumpOptionPropIdAreaIdInfo> parseDumpOptionPropIdAreaId(
+ const std::vector<std::string>& options, size_t& index);
static aidl::android::hardware::automotive::vehicle::VehiclePropValue createHwInputKeyProp(
aidl::android::hardware::automotive::vehicle::VehicleHwKeyInputAction action,
@@ -372,8 +379,13 @@
static android::base::Result<int32_t> parseAreaId(const std::vector<std::string>& options,
size_t index, int32_t propId);
template <class T>
- static android::base::Result<std::vector<T>> parseValues(
- const std::vector<std::string>& options, size_t index);
+ static android::base::Result<std::vector<T>> parseOptionValues(
+ const std::vector<std::string>& options, size_t index, size_t count);
+
+ template <class T>
+ static android::base::Result<
+ std::vector<aidl::android::hardware::automotive::vehicle::RawPropValues>>
+ parseOptionsToSupportedValuesList(const std::vector<std::string>& options, size_t index);
};
} // namespace fake
diff --git a/automotive/vehicle/aidl/impl/current/fake_impl/hardware/src/FakeVehicleHardware.cpp b/automotive/vehicle/aidl/impl/current/fake_impl/hardware/src/FakeVehicleHardware.cpp
index c174e92..4eb84dd 100644
--- a/automotive/vehicle/aidl/impl/current/fake_impl/hardware/src/FakeVehicleHardware.cpp
+++ b/automotive/vehicle/aidl/impl/current/fake_impl/hardware/src/FakeVehicleHardware.cpp
@@ -297,6 +297,24 @@
return ss.str();
}
+template <class T>
+RawPropValues createRawPropValues(T value);
+
+template <>
+RawPropValues createRawPropValues(int32_t value) {
+ return RawPropValues{.int32Values = {value}};
+}
+
+template <>
+RawPropValues createRawPropValues(int64_t value) {
+ return RawPropValues{.int64Values = {value}};
+}
+
+template <>
+RawPropValues createRawPropValues(float value) {
+ return RawPropValues{.floatValues = {value}};
+}
+
} // namespace
void FakeVehicleHardware::storePropInitialValue(const ConfigDeclaration& config) {
@@ -398,46 +416,16 @@
return configsByPropId;
}
-template <>
-void FakeVehicleHardware::setMinSupportedValueLocked(int32_t propId, int32_t areaId,
- int32_t minValue) {
+template <class T>
+void FakeVehicleHardware::setMinSupportedValueLocked(int32_t propId, int32_t areaId, T minValue) {
mMinSupportedValueByPropIdAreaId[PropIdAreaId{.propId = propId, .areaId = areaId}] =
- RawPropValues{.int32Values = {minValue}};
+ createRawPropValues<T>(minValue);
}
-template <>
-void FakeVehicleHardware::setMaxSupportedValueLocked(int32_t propId, int32_t areaId,
- int32_t maxValue) {
+template <class T>
+void FakeVehicleHardware::setMaxSupportedValueLocked(int32_t propId, int32_t areaId, T maxValue) {
mMaxSupportedValueByPropIdAreaId[PropIdAreaId{.propId = propId, .areaId = areaId}] =
- RawPropValues{.int32Values = {maxValue}};
-}
-
-template <>
-void FakeVehicleHardware::setMinSupportedValueLocked(int32_t propId, int32_t areaId,
- int64_t minValue) {
- mMinSupportedValueByPropIdAreaId[PropIdAreaId{.propId = propId, .areaId = areaId}] =
- RawPropValues{.int64Values = {minValue}};
-}
-
-template <>
-void FakeVehicleHardware::setMaxSupportedValueLocked(int32_t propId, int32_t areaId,
- int64_t maxValue) {
- mMaxSupportedValueByPropIdAreaId[PropIdAreaId{.propId = propId, .areaId = areaId}] =
- RawPropValues{.int64Values = {maxValue}};
-}
-
-template <>
-void FakeVehicleHardware::setMinSupportedValueLocked(int32_t propId, int32_t areaId,
- float minValue) {
- mMinSupportedValueByPropIdAreaId[PropIdAreaId{.propId = propId, .areaId = areaId}] =
- RawPropValues{.floatValues = {minValue}};
-}
-
-template <>
-void FakeVehicleHardware::setMaxSupportedValueLocked(int32_t propId, int32_t areaId,
- float maxValue) {
- mMaxSupportedValueByPropIdAreaId[PropIdAreaId{.propId = propId, .areaId = areaId}] =
- RawPropValues{.floatValues = {maxValue}};
+ createRawPropValues<T>(maxValue);
}
void FakeVehicleHardware::init(int32_t s2rS2dConfig) {
@@ -470,12 +458,7 @@
if (!areaConfig.hasSupportedValueInfo.has_value()) {
continue;
}
- if (!areaConfig.hasSupportedValueInfo->hasMinSupportedValue &&
- !areaConfig.hasSupportedValueInfo->hasMaxSupportedValue) {
- continue;
- }
if (areaConfig.hasSupportedValueInfo->hasMinSupportedValue) {
- RawPropValues rawPropValues = {};
switch (propertyType) {
case toInt(VehiclePropertyType::INT32):
setMinSupportedValueLocked(cfg.prop, areaConfig.areaId,
@@ -497,7 +480,6 @@
}
}
if (areaConfig.hasSupportedValueInfo->hasMaxSupportedValue) {
- RawPropValues rawPropValues = {};
switch (propertyType) {
case toInt(VehiclePropertyType::INT32):
setMaxSupportedValueLocked(cfg.prop, areaConfig.areaId,
@@ -513,11 +495,71 @@
break;
default:
ALOGE("hasMaxSupportedValue must only be true for INT32, INT64 or "
- "FLOAT "
- "type property");
+ "FLOAT type property");
continue;
}
}
+ if (areaConfig.hasSupportedValueInfo->hasSupportedValuesList) {
+ std::vector<RawPropValues> supportedValuesList;
+ // We first check "supportedValues" field to populate supported values list.
+ const auto& supportedValuesForAreaId =
+ configDeclaration.supportedValuesForAreaId;
+ const auto it = supportedValuesForAreaId.find(areaConfig.areaId);
+ if (it != supportedValuesForAreaId.end()) {
+ for (float supportedValueFloat : it->second) {
+ switch (propertyType) {
+ case toInt(VehiclePropertyType::INT32):
+ supportedValuesList.push_back(createRawPropValues(
+ static_cast<int32_t>(supportedValueFloat)));
+ break;
+ case toInt(VehiclePropertyType::INT64):
+ supportedValuesList.push_back(createRawPropValues(
+ static_cast<int64_t>(supportedValueFloat)));
+ break;
+ case toInt(VehiclePropertyType::FLOAT):
+ supportedValuesList.push_back(
+ createRawPropValues(supportedValueFloat));
+ break;
+ default:
+ ALOGE("supportedValues field is only supported for INT32, "
+ "INT64 or FLOAT type "
+ "property");
+ }
+ }
+ } else {
+ // If "supportedValues" is not specified, try to use "supportedEnumValues".
+ switch (propertyType) {
+ case toInt(VehiclePropertyType::INT32):
+ if (areaConfig.supportedEnumValues.has_value()) {
+ for (int64_t supportedEnumValue :
+ *areaConfig.supportedEnumValues) {
+ int32_t supportedValue =
+ static_cast<int32_t>(supportedEnumValue);
+ supportedValuesList.push_back(
+ createRawPropValues(supportedValue));
+ }
+ }
+ break;
+ case toInt(VehiclePropertyType::INT64):
+ if (areaConfig.supportedEnumValues.has_value()) {
+ for (int64_t supportedEnumValue :
+ *areaConfig.supportedEnumValues) {
+ supportedValuesList.push_back(
+ createRawPropValues(supportedEnumValue));
+ }
+ }
+ break;
+ default:
+ // Do nothing
+ break;
+ }
+ }
+ if (!supportedValuesList.empty()) {
+ mSupportedValuesByPropIdAreaId[PropIdAreaId{.propId = cfg.prop,
+ .areaId = areaConfig.areaId}] =
+ std::move(supportedValuesList);
+ }
+ }
}
}
}
@@ -1901,44 +1943,131 @@
return result;
}
-std::string FakeVehicleHardware::dumpSetMinMaxValue(const std::vector<std::string>& options) {
- // Requires at least --set-minmaxvalue <PropId> <MinValue> <MaxValue>
- if (auto result = checkArgumentsSize(options, /*minSize=*/4); !result.ok()) {
- return StringPrintf("Not enough arguments\n");
- }
- size_t index = 1;
+Result<FakeVehicleHardware::DumpOptionPropIdAreaIdInfo>
+FakeVehicleHardware::parseDumpOptionPropIdAreaId(const std::vector<std::string>& options,
+ size_t& index) {
const std::string& propIdStr = options[index];
auto maybePropId = parsePropId(options, index);
index++;
if (!maybePropId.ok()) {
- return StringPrintf("Failed to set min/max supported value: propId not valid: %s\n",
- propIdStr.c_str());
+ return Error() << "propId not valid: " << propIdStr;
}
int32_t propId = maybePropId.value();
auto configResult = mServerSidePropStore->getPropConfig(propId);
if (!configResult.ok()) {
- return "Failed to set min/max supported value: property not supported\n";
+ return Error() << "property not supported";
}
std::string areaIdStr = "0";
int32_t areaId = 0;
if (EqualsIgnoreCase(options[index], "-a")) {
index++;
if (index >= options.size()) {
- return StringPrintf("Not enough arguments\n");
+ return Error() << "Not enough arguments";
}
areaIdStr = options[index];
auto maybeAreaId = parseAreaId(options, index, propId);
if (!maybeAreaId.ok()) {
- return StringPrintf("Failed to set min/max supported value: areaId not valid: %s\n",
- areaIdStr.c_str());
+ return Error() << "areaId not valid: " << areaIdStr;
}
areaId = maybeAreaId.value();
index++;
}
+ return DumpOptionPropIdAreaIdInfo{
+ .propId = propId, .areaId = areaId, .propIdStr = propIdStr, .areaIdStr = areaIdStr};
+}
- if (index + 1 >= options.size()) {
- return StringPrintf("Not enough arguments\n");
+template <class T>
+Result<void> FakeVehicleHardware::parseAndSetMinMaxValue(int32_t propId, int32_t areaId,
+ const std::vector<std::string>& options,
+ size_t index) {
+ auto valuesResult = parseOptionValues<T>(options, index, /*count= */ 2);
+ if (!valuesResult.ok()) {
+ return Error() << "Failed to set min/max supported value: "
+ << valuesResult.error().message();
}
+ T minValue = (*valuesResult)[0];
+ T maxValue = (*valuesResult)[1];
+ if (minValue > maxValue) {
+ return Error() << "Failed to set min/max supported value: MinValue: " << minValue
+ << " must not > MaxValue: " << maxValue;
+ }
+ {
+ std::scoped_lock<std::mutex> lockGuard(mLock);
+ setMinSupportedValueLocked(propId, areaId, minValue);
+ setMaxSupportedValueLocked(propId, areaId, maxValue);
+ }
+ return {};
+}
+
+template <class T>
+Result<std::vector<T>> FakeVehicleHardware::parseOptionValues(
+ const std::vector<std::string>& options, size_t index, size_t count) {
+ if (index + count > options.size()) {
+ return Error() << "Not enough arguments";
+ }
+ std::vector<T> values;
+ for (size_t i = index; i < index + count; i++) {
+ auto result = safelyParseInt<T>(i, options[i]);
+ if (!result.ok()) {
+ return Error() << StringPrintf("Value: \"%s\" is not a valid int: %s",
+ options[i].c_str(), getErrorMsg(result).c_str());
+ }
+ values.push_back(result.value());
+ }
+ return values;
+}
+
+// This is a special version of parseOptionValues for float type.
+template <>
+Result<std::vector<float>> FakeVehicleHardware::parseOptionValues(
+ const std::vector<std::string>& options, size_t index, size_t count) {
+ if (index + count > options.size()) {
+ return Error() << "Not enough arguments";
+ }
+ std::vector<float> values;
+ for (size_t i = index; i < index + count; i++) {
+ auto result = safelyParseFloat(i, options[i]);
+ if (!result.ok()) {
+ return Error() << StringPrintf("Value: \"%s\" is not a valid float: %s",
+ options[i].c_str(), getErrorMsg(result).c_str());
+ }
+ values.push_back(result.value());
+ }
+ return values;
+}
+
+template <class T>
+Result<std::vector<RawPropValues>> FakeVehicleHardware::parseOptionsToSupportedValuesList(
+ const std::vector<std::string>& options, size_t index) {
+ std::vector<RawPropValues> supportedValuesList;
+ auto valuesResult = parseOptionValues<T>(options, index, options.size() - index);
+ if (!valuesResult.ok()) {
+ return Error() << valuesResult.error().message();
+ }
+ std::vector<T> values = *valuesResult;
+ if (values.size() == 0) {
+ return Error() << "Not enough arguments";
+ }
+ for (T value : *valuesResult) {
+ supportedValuesList.push_back(createRawPropValues(value));
+ }
+ return supportedValuesList;
+}
+
+std::string FakeVehicleHardware::dumpSetMinMaxValue(const std::vector<std::string>& options) {
+ // Requires at least --set-minmaxvalue <PropId> <MinValue> <MaxValue>
+ if (auto result = checkArgumentsSize(options, /*minSize=*/4); !result.ok()) {
+ return "Failed to set min/max supported value: Not enough arguments\n";
+ }
+ size_t index = 1;
+ Result<DumpOptionPropIdAreaIdInfo> maybeInfo = parseDumpOptionPropIdAreaId(options, index);
+ if (!maybeInfo.ok()) {
+ return StringPrintf("Failed to set min/max supported value: %s\n",
+ maybeInfo.error().message().c_str());
+ }
+ int32_t propId = maybeInfo->propId;
+ int32_t areaId = maybeInfo->areaId;
+
Result<void> parseAndSetValueResult = {};
switch (propId & toInt(VehiclePropertyType::MASK)) {
case toInt(VehiclePropertyType::INT32):
@@ -1962,90 +2091,52 @@
}
triggerSupportedValueChange(propId, areaId);
- return StringPrintf("Min/Max supported value for propId: %s, areaId: %s set", propIdStr.c_str(),
- areaIdStr.c_str());
-}
-
-template <class T>
-Result<void> FakeVehicleHardware::parseAndSetMinMaxValue(int32_t propId, int32_t areaId,
- const std::vector<std::string>& options,
- size_t index) {
- auto valuesResult = parseValues<T>(options, index);
- if (!valuesResult.ok()) {
- return Error() << "Failed to set min/max supported value: "
- << valuesResult.error().message();
- }
- T minValue = (*valuesResult)[0];
- T maxValue = (*valuesResult)[1];
- if (minValue > maxValue) {
- return Error() << "Failed to set min/max supported value: MinValue: " << minValue
- << " must not > MaxValue: " << maxValue;
- }
- {
- std::scoped_lock<std::mutex> lockGuard(mLock);
- setMinSupportedValueLocked(propId, areaId, minValue);
- setMaxSupportedValueLocked(propId, areaId, maxValue);
- }
- return {};
-}
-
-template <class T>
-Result<std::vector<T>> FakeVehicleHardware::parseValues(const std::vector<std::string>& options,
- size_t index) {
- std::vector<T> values;
- for (size_t i = index; i < index + 2; i++) {
- auto result = safelyParseInt<T>(i, options[i]);
- if (!result.ok()) {
- return Error() << StringPrintf("Value: \"%s\" is not a valid int: %s",
- options[i].c_str(), getErrorMsg(result).c_str());
- }
- values.push_back(result.value());
- }
- return values;
-}
-
-// This is a special version of parseValues for float type.
-template <>
-Result<std::vector<float>> FakeVehicleHardware::parseValues(const std::vector<std::string>& options,
- size_t index) {
- std::vector<float> values;
- for (size_t i = index; i < index + 2; i++) {
- auto result = safelyParseFloat(i, options[i]);
- if (!result.ok()) {
- return Error() << StringPrintf("Value: \"%s\" is not a valid float: %s",
- options[i].c_str(), getErrorMsg(result).c_str());
- }
- values.push_back(result.value());
- }
- return values;
+ return StringPrintf("Min/Max supported value for propId: %s, areaId: %s set",
+ maybeInfo->propIdStr.c_str(), maybeInfo->propIdStr.c_str());
}
std::string FakeVehicleHardware::dumpSetSupportedValues(const std::vector<std::string>& options) {
- if (auto result = checkArgumentsSize(options, /*minSize=*/2); !result.ok()) {
- return getErrorMsg(result);
- }
- int testPropId = toInt(TestVendorProperty::VENDOR_EXTENSION_INT_PROPERTY);
- auto configResult = mServerSidePropStore->getPropConfig(testPropId);
- if (!configResult.ok()) {
- return "Failed to set min/max supported value: VENDOR_EXTENSION_INT_PROPERTY not supported";
- }
- std::vector<int32_t> values;
- for (size_t i = 1; i < options.size(); i++) {
- auto int32Result = safelyParseInt<int32_t>(i, options[i]);
- if (!int32Result.ok()) {
- return StringPrintf(
- "Failed to set supported values: Value: \"%s\" is not a valid int: %s\n",
- options[i].c_str(), getErrorMsg(int32Result).c_str());
- }
- values.push_back(int32Result.value());
+ // We at least requires set-supportedvalues <PROP> <SUPPORTED_VALUE>
+ if (auto result = checkArgumentsSize(options, /*minSize=*/3); !result.ok()) {
+ return "Failed to set supported values list: Not enough arguments\n";
}
- {
- std::scoped_lock<std::mutex> lockGuard(mLock);
- mSupportedValuesListForTestIntProp = values;
+ size_t index = 1;
+ Result<DumpOptionPropIdAreaIdInfo> maybeInfo = parseDumpOptionPropIdAreaId(options, index);
+ if (!maybeInfo.ok()) {
+ return StringPrintf("Failed to set supported values list: %s\n",
+ maybeInfo.error().message().c_str());
}
- triggerSupportedValueChange(configResult.value());
- return "Supported values list for VENDOR_EXTENSION_INT_PROPERTY set";
+ int32_t propId = maybeInfo->propId;
+ int32_t areaId = maybeInfo->areaId;
+ Result<std::vector<RawPropValues>> maybeSupportedValues;
+ switch (propId & toInt(VehiclePropertyType::MASK)) {
+ case toInt(VehiclePropertyType::INT32):
+ maybeSupportedValues = parseOptionsToSupportedValuesList<int32_t>(options, index);
+ break;
+ case toInt(VehiclePropertyType::INT64):
+ maybeSupportedValues = parseOptionsToSupportedValuesList<int64_t>(options, index);
+ break;
+ case toInt(VehiclePropertyType::FLOAT):
+ maybeSupportedValues = parseOptionsToSupportedValuesList<float>(options, index);
+ break;
+ default:
+ return StringPrintf(
+ "Failed to set supported values list: only int32/int64/float type"
+ " property is supported\n");
+ }
+ if (!maybeSupportedValues.ok()) {
+ return StringPrintf("Failed to set supported values list: %s\n",
+ maybeSupportedValues.error().message().c_str());
+ }
+ {
+ std::lock_guard<std::mutex> lock(mLock);
+ mSupportedValuesByPropIdAreaId[PropIdAreaId{.propId = propId, .areaId = areaId}] =
+ *maybeSupportedValues;
+ }
+ triggerSupportedValueChange(maybeInfo->propId, maybeInfo->areaId);
+ return StringPrintf("Supported values list for propId: %s, areaId: %s set",
+ maybeInfo->propIdStr.c_str(), maybeInfo->propIdStr.c_str());
}
void FakeVehicleHardware::triggerSupportedValueChange(int32_t propId, int32_t areaId) {
@@ -2060,56 +2151,44 @@
}});
}
-// Triggers supported value change for all areaIds that specify hasSupportedValueInfo.
-void FakeVehicleHardware::triggerSupportedValueChange(const VehiclePropConfig& config) {
- if (mOnSupportedValueChangeCallback == nullptr) {
- ALOGE("onSupportedValueChangeCallback is not registered, ignore event");
- return;
- }
-
- std::vector<PropIdAreaId> propIdAreaIds;
- for (const VehicleAreaConfig& areaConfig : config.areaConfigs) {
- if (areaConfig.hasSupportedValueInfo != std::nullopt) {
- propIdAreaIds.push_back({
- .propId = config.prop,
- .areaId = areaConfig.areaId,
- });
- }
- }
- (*mOnSupportedValueChangeCallback)(std::move(propIdAreaIds));
-}
-
std::string FakeVehicleHardware::dumpHelp() {
- return "Usage: \n\n"
- "[no args]: dumps (id and value) all supported properties \n"
- "--help: shows this help\n"
- "--list: lists the property IDs and their supported area IDs for all supported "
- "properties\n"
- "--get <PROP_ID_1> [PROP_ID_2] [PROP_ID_N]: dumps the value of specific properties. \n"
- "--getWithArg <PROP_ID> [ValueArguments]: gets the value for a specific property. "
- "The value arguments constructs a VehiclePropValue used in the getValue request. \n"
- "--set <PROP_ID> [ValueArguments]: sets the value of property PROP_ID, the value "
- "arguments constructs a VehiclePropValue used in the setValue request. \n"
- "--set-minmaxvalue <PROP_ID> [-a AREA_ID] <MIN_VALUE> <MAX_VALUE>: sets the min max "
- "supported value e.g. --set-minmaxvalue HVAC_TEMPERATURE_SET -a ROW_1_LEFT -5.1 5.1\n"
- "--set-supportedvalues <VALUE_1(int)> [VALUE_2(int) ...]: sets the supported values list"
- "for VENDOR_EXTENSION_INT_PROPERTY\n"
- "--save-prop <PROP_ID> [-a AREA_ID]: saves the current value for PROP_ID, integration "
- "tests that modify prop value must call this before test and restore-prop after test. \n"
- "--restore-prop <PROP_ID> [-a AREA_ID]: restores a previously saved property value. \n"
- "--inject-event <PROP_ID> [ValueArguments]: inject a property update event from car\n\n"
- "ValueArguments are in the format of [-a OPTIONAL_AREA_ID] "
- "[-i INT_VALUE_1 [INT_VALUE_2 ...]] "
- "[-i64 INT64_VALUE_1 [INT64_VALUE_2 ...]] "
- "[-f FLOAT_VALUE_1 [FLOAT_VALUE_2 ...]] "
- "[-s STR_VALUE] "
- "[-b BYTES_VALUE].\n"
- "For example: to set property ID 0x1234, areaId 0x1 to int32 values: [1, 2, 3], "
- "use \"--set 0x1234 -a 0x1 -i 1 2 3\"\n"
- "Note that the string, bytes and area value can be set just once, while the other can"
- " have multiple values (so they're used in the respective array), "
- "BYTES_VALUE is in the form of 0xXXXX, e.g. 0xdeadbeef.\n" +
- genFakeDataHelp() + "Fake user HAL usage: \n" + mFakeUserHal->showDumpHelp();
+ return R"(Usage:
+[no args]: dumps (id and value) all supported properties
+
+--help: shows this help
+
+--list: lists the property IDs and their supported area IDs for all supported properties
+
+--get <PROP_ID_1> [PROP_ID_2] [PROP_ID_N]: dumps the value of specific properties.
+
+--getWithArg <PROP_ID> [ValueArguments]: gets the value for a specific property.
+The value arguments constructs a VehiclePropValue used in the getValue request.
+
+--set <PROP_ID> [ValueArguments]: sets the value of property PROP_ID
+The value arguments constructs a VehiclePropValue used in the setValue request.
+
+--set-minmaxvalue <PROP_ID> [-a AREA_ID] <MIN_VALUE> <MAX_VALUE>: sets the min max supported value
+e.g. --set-minmaxvalue HVAC_TEMPERATURE_SET -a ROW_1_LEFT 17 32
+
+--set-supportedvalues <PROP_ID> [-a AREA_ID] <VALUE_1> [VALUE_2 ...]: sets the supported values list
+e.g. --set-supportedvalues HVAC_TEMPERATURE_SET -a ROW_1_LEFT 17 17.5 18 18.5
+
+--save-prop <PROP_ID> [-a AREA_ID]: saves the current value for PROP_ID, integration tests that
+modify prop value must call this before test and restore-prop after test.
+
+--restore-prop <PROP_ID> [-a AREA_ID]: restores a previously saved property value.
+
+--inject-event <PROP_ID> [ValueArguments]: inject a property update event from car
+ValueArguments are in the format of
+[-a OPTIONAL_AREA_ID] [-i INT_VALUE_1 [INT_VALUE_2 ...]] [-i64 INT64_VALUE_1 [INT64_VALUE_2 ...]]
+[-f FLOAT_VALUE_1 [FLOAT_VALUE_2 ...]] [-s STR_VALUE] [-b BYTES_VALUE].
+For example: to set property ID 0x1234, areaId 0x1 to int32 values: [1, 2, 3]
+use "--set 0x1234 -a 0x1 -i 1 2 3"
+Note that the string, bytes and area value can be set just once, while the other can have multiple
+values (so they're used in the respective array), BYTES_VALUE is in the form of 0xXXXX,
+e.g. 0xdeadbeef.
+)" + genFakeDataHelp() +
+ "Fake user HAL usage: \n" + mFakeUserHal->showDumpHelp();
}
std::string FakeVehicleHardware::dumpAllProperties() {
@@ -2629,19 +2708,17 @@
const std::vector<PropIdAreaId>& propIdAreaIds) {
std::scoped_lock<std::mutex> lockGuard(mLock);
std::vector<SupportedValuesListResult> results;
- // We only support VENDOR_EXTENSION_INT_PROPERTY
for (const auto& propIdAreaId : propIdAreaIds) {
- int propId = propIdAreaId.propId;
- int areaId = propIdAreaId.areaId;
- if (propId != toInt(TestVendorProperty::VENDOR_EXTENSION_INT_PROPERTY)) {
+ const auto it = mSupportedValuesByPropIdAreaId.find(propIdAreaId);
+ if (it == mSupportedValuesByPropIdAreaId.end()) {
results.push_back(SupportedValuesListResult{
.status = StatusCode::INVALID_ARG,
});
continue;
}
std::vector<std::optional<RawPropValues>> supportedValuesList;
- for (int32_t value : mSupportedValuesListForTestIntProp) {
- supportedValuesList.push_back(RawPropValues{.int32Values = {value}});
+ for (const RawPropValues& supportedValue : it->second) {
+ supportedValuesList.push_back(supportedValue);
}
results.push_back(SupportedValuesListResult{
.status = StatusCode::OK,
diff --git a/automotive/vehicle/aidl/impl/current/fake_impl/hardware/test/FakeVehicleHardwareTest.cpp b/automotive/vehicle/aidl/impl/current/fake_impl/hardware/test/FakeVehicleHardwareTest.cpp
index 617d2d2..8262098 100644
--- a/automotive/vehicle/aidl/impl/current/fake_impl/hardware/test/FakeVehicleHardwareTest.cpp
+++ b/automotive/vehicle/aidl/impl/current/fake_impl/hardware/test/FakeVehicleHardwareTest.cpp
@@ -80,6 +80,7 @@
using ::aidl::android::hardware::automotive::vehicle::VehicleApPowerStateShutdownParam;
using ::aidl::android::hardware::automotive::vehicle::VehicleAreaMirror;
using ::aidl::android::hardware::automotive::vehicle::VehicleAreaSeat;
+using ::aidl::android::hardware::automotive::vehicle::VehicleAreaWindow;
using ::aidl::android::hardware::automotive::vehicle::VehicleHwKeyInputAction;
using ::aidl::android::hardware::automotive::vehicle::VehiclePropConfig;
using ::aidl::android::hardware::automotive::vehicle::VehicleProperty;
@@ -2591,7 +2592,7 @@
DumpResult result = getHardware()->dump(options);
ASSERT_FALSE(result.callerShouldDumpState);
ASSERT_NE(result.buffer, "");
- ASSERT_THAT(result.buffer, ContainsRegex("Usage: "));
+ ASSERT_THAT(result.buffer, ContainsRegex("Usage:"));
}
TEST_F(FakeVehicleHardwareTest, testDumpListProperties) {
@@ -2892,8 +2893,9 @@
ASSERT_THAT(result.buffer, ContainsRegex("Failed"));
}
-TEST_F(FakeVehicleHardwareTest, testDumpSetSupportedValues) {
- std::vector<std::string> options = {"--set-supportedvalues", "1", "2", "3"};
+TEST_F(FakeVehicleHardwareTest, testDumpSetSupportedValues_Int) {
+ std::vector<std::string> options = {
+ "--set-supportedvalues", "EV_STOPPING_MODE", "-a", "0", "1", "2", "3"};
std::vector<PropIdAreaId> changedPropIdAreaIds;
getHardware()->registerSupportedValueChangeCallback(
@@ -2907,11 +2909,13 @@
ASSERT_THAT(result.buffer, ContainsRegex("Supported values list .* set"));
ASSERT_EQ(changedPropIdAreaIds.size(), 1u);
+ EXPECT_EQ(changedPropIdAreaIds[0], (PropIdAreaId{
+ .propId = toInt(VehicleProperty::EV_STOPPING_MODE),
+ .areaId = 0,
+ }));
- auto results = getHardware()->getSupportedValuesLists({PropIdAreaId{
- .propId = toInt(TestVendorProperty::VENDOR_EXTENSION_INT_PROPERTY), .areaId = 0}});
+ auto results = getHardware()->getSupportedValuesLists({changedPropIdAreaIds[0]});
- ASSERT_EQ(results.size(), 1u);
EXPECT_EQ(results[0].status, StatusCode::OK);
EXPECT_NE(results[0].supportedValuesList, std::nullopt);
EXPECT_EQ(results[0].supportedValuesList.value(), std::vector<std::optional<RawPropValues>>({
@@ -2921,13 +2925,108 @@
}));
}
+TEST_F(FakeVehicleHardwareTest, testDumpSetSupportedValues_forGlobalPropertySkipArea) {
+ std::vector<std::string> options = {"--set-supportedvalues", "EV_STOPPING_MODE", "1", "2", "3"};
+ std::vector<PropIdAreaId> changedPropIdAreaIds;
+
+ getHardware()->registerSupportedValueChangeCallback(
+ std::make_unique<IVehicleHardware::SupportedValueChangeCallback>(
+ [&changedPropIdAreaIds](std::vector<PropIdAreaId> propIdAreaIds) {
+ changedPropIdAreaIds = propIdAreaIds;
+ }));
+
+ DumpResult result = getHardware()->dump(options);
+ ASSERT_FALSE(result.callerShouldDumpState);
+ ASSERT_THAT(result.buffer, ContainsRegex("Supported values list .* set"));
+
+ ASSERT_EQ(changedPropIdAreaIds.size(), 1u);
+ EXPECT_EQ(changedPropIdAreaIds[0], (PropIdAreaId{
+ .propId = toInt(VehicleProperty::EV_STOPPING_MODE),
+ .areaId = 0,
+ }));
+
+ auto results = getHardware()->getSupportedValuesLists({changedPropIdAreaIds[0]});
+
+ EXPECT_EQ(results[0].status, StatusCode::OK);
+ EXPECT_NE(results[0].supportedValuesList, std::nullopt);
+ EXPECT_EQ(results[0].supportedValuesList.value(), std::vector<std::optional<RawPropValues>>({
+ RawPropValues{.int32Values = {1}},
+ RawPropValues{.int32Values = {2}},
+ RawPropValues{.int32Values = {3}},
+ }));
+}
+
+TEST_F(FakeVehicleHardwareTest, testDumpSetSupportedValues_Float) {
+ std::vector<std::string> options = {"--set-supportedvalues",
+ "HVAC_TEMPERATURE_SET",
+ "-a",
+ "ROW_1_LEFT",
+ "1.1",
+ "2.2",
+ "3.3"};
+ std::vector<PropIdAreaId> changedPropIdAreaIds;
+
+ getHardware()->registerSupportedValueChangeCallback(
+ std::make_unique<IVehicleHardware::SupportedValueChangeCallback>(
+ [&changedPropIdAreaIds](std::vector<PropIdAreaId> propIdAreaIds) {
+ changedPropIdAreaIds = propIdAreaIds;
+ }));
+
+ DumpResult result = getHardware()->dump(options);
+ ASSERT_FALSE(result.callerShouldDumpState);
+ ASSERT_THAT(result.buffer, ContainsRegex("Supported values list .* set"));
+
+ ASSERT_EQ(changedPropIdAreaIds.size(), 1u);
+ EXPECT_EQ(changedPropIdAreaIds[0],
+ (PropIdAreaId{
+ .propId = toInt(VehicleProperty::HVAC_TEMPERATURE_SET),
+ .areaId = toInt(VehicleAreaSeat::ROW_1_LEFT),
+ }));
+
+ auto results = getHardware()->getSupportedValuesLists({changedPropIdAreaIds[0]});
+
+ EXPECT_EQ(results[0].status, StatusCode::OK);
+ EXPECT_NE(results[0].supportedValuesList, std::nullopt);
+ EXPECT_EQ(results[0].supportedValuesList.value(), std::vector<std::optional<RawPropValues>>({
+ RawPropValues{.floatValues = {1.1}},
+ RawPropValues{.floatValues = {2.2}},
+ RawPropValues{.floatValues = {3.3}},
+ }));
+}
+
TEST_F(FakeVehicleHardwareTest, testDumpSetSupportedValues_invalidInt) {
- std::vector<std::string> options = {"--set-supportedvalues", "1", "2", "ab", "3"};
+ std::vector<std::string> options = {
+ "--set-supportedvalues", "EV_STOPPING_MODE", "1", "2", "ab", "3"};
DumpResult result = getHardware()->dump(options);
ASSERT_THAT(result.buffer, ContainsRegex("Failed"));
}
+TEST_F(FakeVehicleHardwareTest, testDumpSetSupportedValues_notEnoughArguments) {
+ std::vector<std::string> options = {"--set-supportedvalues", "EV_STOPPING_MODE"};
+
+ DumpResult result = getHardware()->dump(options);
+ ASSERT_THAT(result.buffer, ContainsRegex("Failed"));
+ ASSERT_THAT(result.buffer, ContainsRegex("Not enough arguments"));
+}
+
+TEST_F(FakeVehicleHardwareTest, testDumpSetSupportedValues_withAreaId_notEnoughArguments) {
+ std::vector<std::string> options = {"--set-supportedvalues", "EV_STOPPING_MODE", "-a", "0"};
+
+ DumpResult result = getHardware()->dump(options);
+ ASSERT_THAT(result.buffer, ContainsRegex("Failed"));
+ ASSERT_THAT(result.buffer, ContainsRegex("Not enough arguments"));
+}
+
+TEST_F(FakeVehicleHardwareTest, testDumpSetSupportedValues_invalidAreaId) {
+ std::vector<std::string> options = {"--set-supportedvalues", "EV_STOPPING_MODE", "-a", "blah",
+ "1"};
+
+ DumpResult result = getHardware()->dump(options);
+ ASSERT_THAT(result.buffer, ContainsRegex("Failed"));
+ ASSERT_THAT(result.buffer, ContainsRegex("areaId not valid"));
+}
+
struct SetPropTestCase {
std::string test_name;
std::vector<std::string> options;
@@ -4073,25 +4172,32 @@
TEST_F(FakeVehicleHardwareTest, testGetSupportedValuesLists) {
auto results = getHardware()->getSupportedValuesLists({
PropIdAreaId{.propId = toInt(TestVendorProperty::VENDOR_EXTENSION_INT_PROPERTY),
- .areaId = 0},
- PropIdAreaId{.propId = toInt(VehicleProperty::HVAC_TEMPERATURE_SET), .areaId = 0},
+ .areaId = toInt(VehicleAreaWindow::FRONT_WINDSHIELD)},
+ // This property does not specify supported values list.
+ PropIdAreaId{.propId = toInt(VehicleProperty::INFO_EV_BATTERY_CAPACITY), .areaId = 0},
});
ASSERT_EQ(results.size(), 2u);
EXPECT_EQ(results[0].status, StatusCode::OK);
EXPECT_NE(results[0].supportedValuesList, std::nullopt);
EXPECT_NE((results[0].supportedValuesList)->size(), 0u);
- EXPECT_EQ(results[0].supportedValuesList.value(), std::vector<std::optional<RawPropValues>>({
- RawPropValues{.int32Values = {0}},
- RawPropValues{.int32Values = {2}},
- RawPropValues{.int32Values = {4}},
- RawPropValues{.int32Values = {6}},
- RawPropValues{.int32Values = {8}},
- RawPropValues{.int32Values = {10}},
- }));
+ EXPECT_EQ(results[0].supportedValuesList.value(),
+ std::vector<std::optional<RawPropValues>>({RawPropValues{.int32Values = {1}},
+ RawPropValues{.int32Values = {2}},
+ RawPropValues{.int32Values = {3}}}));
EXPECT_EQ(results[1].status, StatusCode::INVALID_ARG);
}
+TEST_F(FakeVehicleHardwareTest, testGetSupportedValuesLists_populateFromSupportedEnumValues) {
+ auto results = getHardware()->getSupportedValuesLists({PropIdAreaId{
+ .propId = toInt(VehicleProperty::FORWARD_COLLISION_WARNING_STATE), .areaId = 0}});
+
+ ASSERT_EQ(results.size(), 1u);
+ EXPECT_EQ(results[0].status, StatusCode::OK);
+ ASSERT_NE(results[0].supportedValuesList, std::nullopt);
+ ASSERT_THAT(results[0].supportedValuesList.value(), ::testing::Not(::testing::IsEmpty()));
+}
+
} // namespace fake
} // namespace vehicle
} // namespace automotive