Loading automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/VehicleAreaConfig.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -41,4 +41,5 @@ parcelable VehicleAreaConfig { long maxInt64Value; float minFloatValue; float maxFloatValue; @nullable long[] supportedEnumValues; } automotive/vehicle/aidl/android/hardware/automotive/vehicle/VehicleAreaConfig.aidl +7 −0 Original line number Diff line number Diff line Loading @@ -40,4 +40,11 @@ parcelable VehicleAreaConfig { float minFloatValue; float maxFloatValue; /** * If the property has a @data_enum, then it is possible to specify a supported subset of the * @data_enum. If the property has a @data_enum and supportedEnumValues is null, then it is * assumed all @data_enum values are supported unless specified through another mechanism. */ @nullable long[] supportedEnumValues; } automotive/vehicle/aidl/impl/default_config/JsonConfigLoader/src/JsonConfigLoader.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -105,6 +105,7 @@ const std::unordered_map<std::string, int> CONSTANTS_BY_NAME = { FAN_DIRECTION_FLOOR | FAN_DIRECTION_DEFROST | FAN_DIRECTION_FACE}, {"FUEL_DOOR_REAR_LEFT", FUEL_DOOR_REAR_LEFT}, {"LIGHT_STATE_ON", LIGHT_STATE_ON}, {"LIGHT_STATE_OFF", LIGHT_STATE_OFF}, {"LIGHT_SWITCH_OFF", LIGHT_SWITCH_OFF}, {"LIGHT_SWITCH_AUTO", LIGHT_SWITCH_AUTO}, {"MIRROR_DRIVER_LEFT_RIGHT", Loading Loading @@ -460,6 +461,13 @@ void JsonConfigParser::parseAreas(const Json::Value& parentJsonNode, const std:: &areaConfig.minFloatValue, errors); tryParseJsonValueToVariable(jsonAreaConfig, "maxFloatValue", /*optional=*/true, &areaConfig.maxFloatValue, errors); std::vector<int64_t> supportedEnumValues; tryParseJsonArrayToVariable(jsonAreaConfig, "supportedEnumValues", /*optional=*/true, &supportedEnumValues, errors); if (!supportedEnumValues.empty()) { areaConfig.supportedEnumValues = std::move(supportedEnumValues); } config->config.areaConfigs.push_back(std::move(areaConfig)); RawPropValues areaValue = {}; Loading automotive/vehicle/aidl/impl/default_config/JsonConfigLoader/test/JsonConfigLoaderUnitTest.cpp +83 −0 Original line number Diff line number Diff line Loading @@ -616,6 +616,89 @@ TEST_F(JsonConfigLoaderUnitTest, testAreas_FailInvalidTypeForOneAreaValue) { << "Wrong type for DefaultValue for one area must cause error"; } TEST_F(JsonConfigLoaderUnitTest, testAreas_HandlesNoSupportedEnumValuesDeclared) { std::istringstream iss(R"( { "properties": [{ "property": "VehicleProperty::CABIN_LIGHTS_STATE", "areas": [{ "areaId": 0, }] }] } )"); auto result = mLoader.loadPropConfig(iss); ASSERT_TRUE(result.ok()); auto configs = result.value(); ASSERT_EQ(configs.size(), 1u); const VehiclePropConfig& config = configs.begin()->second.config; ASSERT_EQ(config.areaConfigs.size(), 1u); const VehicleAreaConfig& areaConfig = config.areaConfigs[0]; ASSERT_EQ(areaConfig.areaId, 0); ASSERT_FALSE(areaConfig.supportedEnumValues); } TEST_F(JsonConfigLoaderUnitTest, testAreas_HandlesSupportedEnumValues) { std::istringstream iss(R"( { "properties": [{ "property": "VehicleProperty::CABIN_LIGHTS_STATE", "areas": [{ "areaId": 0, "supportedEnumValues": ["Constants::LIGHT_STATE_ON", "Constants::LIGHT_STATE_OFF"] }] }] } )"); auto result = mLoader.loadPropConfig(iss); ASSERT_TRUE(result.ok()); auto configs = result.value(); ASSERT_EQ(configs.size(), 1u); const VehiclePropConfig& config = configs.begin()->second.config; ASSERT_EQ(config.areaConfigs.size(), 1u); const VehicleAreaConfig& areaConfig = config.areaConfigs[0]; ASSERT_EQ(areaConfig.areaId, 0); ASSERT_TRUE(areaConfig.supportedEnumValues); ASSERT_EQ(areaConfig.supportedEnumValues.value().size(), 2u); ASSERT_EQ(areaConfig.supportedEnumValues.value(), std::vector<int64_t>({LIGHT_STATE_ON, LIGHT_STATE_OFF})); } TEST_F(JsonConfigLoaderUnitTest, testAreas_HandlesEmptySupportedEnumValues) { std::istringstream iss(R"( { "properties": [{ "property": "VehicleProperty::CABIN_LIGHTS_STATE", "areas": [{ "areaId": 0, "supportedEnumValues": [] }] }] } )"); auto result = mLoader.loadPropConfig(iss); ASSERT_TRUE(result.ok()); auto configs = result.value(); ASSERT_EQ(configs.size(), 1u); const VehiclePropConfig& config = configs.begin()->second.config; ASSERT_EQ(config.areaConfigs.size(), 1u); const VehicleAreaConfig& areaConfig = config.areaConfigs[0]; ASSERT_EQ(areaConfig.areaId, 0); ASSERT_FALSE(areaConfig.supportedEnumValues); } } // namespace vehicle } // namespace automotive } // namespace hardware Loading automotive/vehicle/aidl/impl/utils/common/include/PropertyUtils.h +1 −0 Original line number Diff line number Diff line Loading @@ -96,6 +96,7 @@ constexpr int FUEL_DOOR_REAR_LEFT = toInt(propertyutils_impl::PortLocationType:: constexpr int CHARGE_PORT_FRONT_LEFT = toInt(propertyutils_impl::PortLocationType::FRONT_LEFT); constexpr int CHARGE_PORT_REAR_LEFT = toInt(propertyutils_impl::PortLocationType::REAR_LEFT); constexpr int LIGHT_STATE_ON = toInt(propertyutils_impl::VehicleLightState::ON); constexpr int LIGHT_STATE_OFF = toInt(propertyutils_impl::VehicleLightState::OFF); constexpr int LIGHT_SWITCH_OFF = toInt(propertyutils_impl::VehicleLightSwitch::OFF); constexpr int LIGHT_SWITCH_AUTO = toInt(propertyutils_impl::VehicleLightSwitch::AUTOMATIC); constexpr int WHEEL_FRONT_LEFT = toInt(propertyutils_impl::VehicleAreaWheel::LEFT_FRONT); Loading Loading
automotive/vehicle/aidl/aidl_api/android.hardware.automotive.vehicle/current/android/hardware/automotive/vehicle/VehicleAreaConfig.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -41,4 +41,5 @@ parcelable VehicleAreaConfig { long maxInt64Value; float minFloatValue; float maxFloatValue; @nullable long[] supportedEnumValues; }
automotive/vehicle/aidl/android/hardware/automotive/vehicle/VehicleAreaConfig.aidl +7 −0 Original line number Diff line number Diff line Loading @@ -40,4 +40,11 @@ parcelable VehicleAreaConfig { float minFloatValue; float maxFloatValue; /** * If the property has a @data_enum, then it is possible to specify a supported subset of the * @data_enum. If the property has a @data_enum and supportedEnumValues is null, then it is * assumed all @data_enum values are supported unless specified through another mechanism. */ @nullable long[] supportedEnumValues; }
automotive/vehicle/aidl/impl/default_config/JsonConfigLoader/src/JsonConfigLoader.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -105,6 +105,7 @@ const std::unordered_map<std::string, int> CONSTANTS_BY_NAME = { FAN_DIRECTION_FLOOR | FAN_DIRECTION_DEFROST | FAN_DIRECTION_FACE}, {"FUEL_DOOR_REAR_LEFT", FUEL_DOOR_REAR_LEFT}, {"LIGHT_STATE_ON", LIGHT_STATE_ON}, {"LIGHT_STATE_OFF", LIGHT_STATE_OFF}, {"LIGHT_SWITCH_OFF", LIGHT_SWITCH_OFF}, {"LIGHT_SWITCH_AUTO", LIGHT_SWITCH_AUTO}, {"MIRROR_DRIVER_LEFT_RIGHT", Loading Loading @@ -460,6 +461,13 @@ void JsonConfigParser::parseAreas(const Json::Value& parentJsonNode, const std:: &areaConfig.minFloatValue, errors); tryParseJsonValueToVariable(jsonAreaConfig, "maxFloatValue", /*optional=*/true, &areaConfig.maxFloatValue, errors); std::vector<int64_t> supportedEnumValues; tryParseJsonArrayToVariable(jsonAreaConfig, "supportedEnumValues", /*optional=*/true, &supportedEnumValues, errors); if (!supportedEnumValues.empty()) { areaConfig.supportedEnumValues = std::move(supportedEnumValues); } config->config.areaConfigs.push_back(std::move(areaConfig)); RawPropValues areaValue = {}; Loading
automotive/vehicle/aidl/impl/default_config/JsonConfigLoader/test/JsonConfigLoaderUnitTest.cpp +83 −0 Original line number Diff line number Diff line Loading @@ -616,6 +616,89 @@ TEST_F(JsonConfigLoaderUnitTest, testAreas_FailInvalidTypeForOneAreaValue) { << "Wrong type for DefaultValue for one area must cause error"; } TEST_F(JsonConfigLoaderUnitTest, testAreas_HandlesNoSupportedEnumValuesDeclared) { std::istringstream iss(R"( { "properties": [{ "property": "VehicleProperty::CABIN_LIGHTS_STATE", "areas": [{ "areaId": 0, }] }] } )"); auto result = mLoader.loadPropConfig(iss); ASSERT_TRUE(result.ok()); auto configs = result.value(); ASSERT_EQ(configs.size(), 1u); const VehiclePropConfig& config = configs.begin()->second.config; ASSERT_EQ(config.areaConfigs.size(), 1u); const VehicleAreaConfig& areaConfig = config.areaConfigs[0]; ASSERT_EQ(areaConfig.areaId, 0); ASSERT_FALSE(areaConfig.supportedEnumValues); } TEST_F(JsonConfigLoaderUnitTest, testAreas_HandlesSupportedEnumValues) { std::istringstream iss(R"( { "properties": [{ "property": "VehicleProperty::CABIN_LIGHTS_STATE", "areas": [{ "areaId": 0, "supportedEnumValues": ["Constants::LIGHT_STATE_ON", "Constants::LIGHT_STATE_OFF"] }] }] } )"); auto result = mLoader.loadPropConfig(iss); ASSERT_TRUE(result.ok()); auto configs = result.value(); ASSERT_EQ(configs.size(), 1u); const VehiclePropConfig& config = configs.begin()->second.config; ASSERT_EQ(config.areaConfigs.size(), 1u); const VehicleAreaConfig& areaConfig = config.areaConfigs[0]; ASSERT_EQ(areaConfig.areaId, 0); ASSERT_TRUE(areaConfig.supportedEnumValues); ASSERT_EQ(areaConfig.supportedEnumValues.value().size(), 2u); ASSERT_EQ(areaConfig.supportedEnumValues.value(), std::vector<int64_t>({LIGHT_STATE_ON, LIGHT_STATE_OFF})); } TEST_F(JsonConfigLoaderUnitTest, testAreas_HandlesEmptySupportedEnumValues) { std::istringstream iss(R"( { "properties": [{ "property": "VehicleProperty::CABIN_LIGHTS_STATE", "areas": [{ "areaId": 0, "supportedEnumValues": [] }] }] } )"); auto result = mLoader.loadPropConfig(iss); ASSERT_TRUE(result.ok()); auto configs = result.value(); ASSERT_EQ(configs.size(), 1u); const VehiclePropConfig& config = configs.begin()->second.config; ASSERT_EQ(config.areaConfigs.size(), 1u); const VehicleAreaConfig& areaConfig = config.areaConfigs[0]; ASSERT_EQ(areaConfig.areaId, 0); ASSERT_FALSE(areaConfig.supportedEnumValues); } } // namespace vehicle } // namespace automotive } // namespace hardware Loading
automotive/vehicle/aidl/impl/utils/common/include/PropertyUtils.h +1 −0 Original line number Diff line number Diff line Loading @@ -96,6 +96,7 @@ constexpr int FUEL_DOOR_REAR_LEFT = toInt(propertyutils_impl::PortLocationType:: constexpr int CHARGE_PORT_FRONT_LEFT = toInt(propertyutils_impl::PortLocationType::FRONT_LEFT); constexpr int CHARGE_PORT_REAR_LEFT = toInt(propertyutils_impl::PortLocationType::REAR_LEFT); constexpr int LIGHT_STATE_ON = toInt(propertyutils_impl::VehicleLightState::ON); constexpr int LIGHT_STATE_OFF = toInt(propertyutils_impl::VehicleLightState::OFF); constexpr int LIGHT_SWITCH_OFF = toInt(propertyutils_impl::VehicleLightSwitch::OFF); constexpr int LIGHT_SWITCH_AUTO = toInt(propertyutils_impl::VehicleLightSwitch::AUTOMATIC); constexpr int WHEEL_FRONT_LEFT = toInt(propertyutils_impl::VehicleAreaWheel::LEFT_FRONT); Loading