Loading automotive/vehicle/aidl/impl/current/default_config/JsonConfigLoader/src/JsonConfigLoader.cpp +17 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ using ::aidl::android::hardware::automotive::vehicle::FuelType; using ::aidl::android::hardware::automotive::vehicle::GsrComplianceRequirementType; using ::aidl::android::hardware::automotive::vehicle::HandsOnDetectionDriverState; using ::aidl::android::hardware::automotive::vehicle::HandsOnDetectionWarning; using ::aidl::android::hardware::automotive::vehicle::HasSupportedValueInfo; using ::aidl::android::hardware::automotive::vehicle::ImpactSensorLocation; using ::aidl::android::hardware::automotive::vehicle::LaneCenteringAssistCommand; using ::aidl::android::hardware::automotive::vehicle::LaneCenteringAssistState; Loading Loading @@ -600,6 +601,22 @@ void JsonConfigParser::parseAreas(const Json::Value& parentJsonNode, const std:: if (!supportedEnumValues.empty()) { areaConfig.supportedEnumValues = std::move(supportedEnumValues); } if (jsonAreaConfig.isMember("hasSupportedValueInfo")) { HasSupportedValueInfo hasSupportedValueInfo = HasSupportedValueInfo{}; const Json::Value& jsonHasSupportedValueInfo = jsonAreaConfig["hasSupportedValueInfo"]; tryParseJsonValueToVariable(jsonHasSupportedValueInfo, "hasMinSupportedValue", /*optional=*/true, &hasSupportedValueInfo.hasMinSupportedValue, errors); tryParseJsonValueToVariable(jsonHasSupportedValueInfo, "hasMaxSupportedValue", /*optional=*/true, &hasSupportedValueInfo.hasMaxSupportedValue, errors); tryParseJsonValueToVariable(jsonHasSupportedValueInfo, "hasSupportedValuesList", /*optional=*/true, &hasSupportedValueInfo.hasSupportedValuesList, errors); areaConfig.hasSupportedValueInfo = std::move(hasSupportedValueInfo); } config->config.areaConfigs.push_back(std::move(areaConfig)); RawPropValues areaValue = {}; Loading automotive/vehicle/aidl/impl/current/default_config/JsonConfigLoader/test/JsonConfigLoaderUnitTest.cpp +103 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ namespace hardware { namespace automotive { namespace vehicle { using ::aidl::android::hardware::automotive::vehicle::HasSupportedValueInfo; using ::aidl::android::hardware::automotive::vehicle::RawPropValues; using ::aidl::android::hardware::automotive::vehicle::VehicleAreaConfig; using ::aidl::android::hardware::automotive::vehicle::VehiclePropConfig; Loading Loading @@ -803,6 +804,108 @@ TEST_F(JsonConfigLoaderUnitTest, testAccess_areaOverrideGlobal) { ASSERT_EQ(areaConfig2.areaId, 1); } TEST_F(JsonConfigLoaderUnitTest, testHasSupportedValueInfo_allTrue) { std::istringstream iss(R"( { "properties": [{ "property": "VehicleProperty::CABIN_LIGHTS_SWITCH", "areas": [{ "access": "VehiclePropertyAccess::WRITE", "areaId": 0, "hasSupportedValueInfo": { "hasMinSupportedValue": true, "hasMaxSupportedValue": true, "hasSupportedValuesList": true } }], "access": "VehiclePropertyAccess::READ", }] } )"); 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.access, VehiclePropertyAccess::READ); ASSERT_EQ(config.areaConfigs.size(), 1u); const VehicleAreaConfig& areaConfig = config.areaConfigs[0]; ASSERT_EQ(areaConfig.hasSupportedValueInfo, HasSupportedValueInfo({ .hasMinSupportedValue = true, .hasMaxSupportedValue = true, .hasSupportedValuesList = true, })); } TEST_F(JsonConfigLoaderUnitTest, testHasSupportedValueInfo_allFalse) { std::istringstream iss(R"( { "properties": [{ "property": "VehicleProperty::CABIN_LIGHTS_SWITCH", "areas": [{ "access": "VehiclePropertyAccess::WRITE", "areaId": 0, "hasSupportedValueInfo": { "hasMinSupportedValue": false, "hasMaxSupportedValue": false, "hasSupportedValuesList": false } }], "access": "VehiclePropertyAccess::READ", }] } )"); 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.access, VehiclePropertyAccess::READ); ASSERT_EQ(config.areaConfigs.size(), 1u); const VehicleAreaConfig& areaConfig = config.areaConfigs[0]; ASSERT_EQ(areaConfig.hasSupportedValueInfo, HasSupportedValueInfo({ .hasMinSupportedValue = false, .hasMaxSupportedValue = false, .hasSupportedValuesList = false, })); } TEST_F(JsonConfigLoaderUnitTest, testHasSupportedValueInfo_unspecified) { std::istringstream iss(R"( { "properties": [{ "property": "VehicleProperty::CABIN_LIGHTS_SWITCH", "areas": [{ "access": "VehiclePropertyAccess::WRITE", "areaId": 0 }], "access": "VehiclePropertyAccess::READ", }] } )"); 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.access, VehiclePropertyAccess::READ); ASSERT_EQ(config.areaConfigs.size(), 1u); const VehicleAreaConfig& areaConfig = config.areaConfigs[0]; ASSERT_EQ(areaConfig.hasSupportedValueInfo, std::nullopt); } } // namespace vehicle } // namespace automotive } // namespace hardware Loading automotive/vehicle/aidl/impl/current/default_config/config/TestProperties.json +6 −3 Original line number Diff line number Diff line Loading @@ -99,12 +99,15 @@ { "defaultValue": { "int32Values": [ 1 2 ] }, "areaId": "VehicleAreaWindow::FRONT_WINDSHIELD", "minInt32Value": -100, "maxInt32Value": 100 "hasSupportedValueInfo": { "hasMinSupportedValue": true, "hasMaxSupportedValue": true, "hasSupportedValuesList": true } }, { "defaultValue": { Loading automotive/vehicle/aidl/impl/current/fake_impl/hardware/include/FakeVehicleHardware.h +6 −0 Original line number Diff line number Diff line Loading @@ -108,6 +108,12 @@ class FakeVehicleHardware : public IVehicleHardware { aidl::android::hardware::automotive::vehicle::StatusCode unsubscribe(int32_t propId, int32_t areaId) override; std::vector<aidlvhal::MinMaxSupportedValueResult> getMinMaxSupportedValues( const std::vector<PropIdAreaId>& propIdAreaIds) override; std::vector<aidlvhal::SupportedValuesListResult> getSupportedValuesLists( const std::vector<PropIdAreaId>& propIdAreaIds) override; protected: // mValuePool is also used in mServerSidePropStore. const std::shared_ptr<VehiclePropValuePool> mValuePool; Loading automotive/vehicle/aidl/impl/current/fake_impl/hardware/src/FakeVehicleHardware.cpp +58 −0 Original line number Diff line number Diff line Loading @@ -62,11 +62,13 @@ using ::aidl::android::hardware::automotive::vehicle::DriverDrowsinessAttentionW using ::aidl::android::hardware::automotive::vehicle::ErrorState; using ::aidl::android::hardware::automotive::vehicle::GetValueRequest; using ::aidl::android::hardware::automotive::vehicle::GetValueResult; using ::aidl::android::hardware::automotive::vehicle::MinMaxSupportedValueResult; using ::aidl::android::hardware::automotive::vehicle::RawPropValues; using ::aidl::android::hardware::automotive::vehicle::SetValueRequest; using ::aidl::android::hardware::automotive::vehicle::SetValueResult; 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::VehicleApPowerStateReport; using ::aidl::android::hardware::automotive::vehicle::VehicleApPowerStateReq; Loading Loading @@ -2299,6 +2301,62 @@ StatusCode FakeVehicleHardware::subscribe(SubscribeOptions options) { return StatusCode::OK; } std::vector<MinMaxSupportedValueResult> FakeVehicleHardware::getMinMaxSupportedValues( const std::vector<PropIdAreaId>& propIdAreaIds) { std::vector<MinMaxSupportedValueResult> 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)) { results.push_back(MinMaxSupportedValueResult{ .status = StatusCode::INVALID_ARG, }); continue; } results.push_back(MinMaxSupportedValueResult{ .status = StatusCode::OK, .minSupportedValue = RawPropValues{ .int32Values = {0}, }, .maxSupportedValue = RawPropValues{ .int32Values = {10}, }, }); } return results; } std::vector<SupportedValuesListResult> FakeVehicleHardware::getSupportedValuesLists( const std::vector<PropIdAreaId>& propIdAreaIds) { 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)) { results.push_back(SupportedValuesListResult{ .status = StatusCode::INVALID_ARG, }); continue; } results.push_back(SupportedValuesListResult{ .status = StatusCode::OK, .supportedValuesList = std::vector<std::optional<RawPropValues>>({ RawPropValues{.int32Values = {0}}, RawPropValues{.int32Values = {2}}, RawPropValues{.int32Values = {4}}, RawPropValues{.int32Values = {6}}, RawPropValues{.int32Values = {8}}, RawPropValues{.int32Values = {10}}, }), }); } return results; } bool FakeVehicleHardware::isVariableUpdateRateSupported(const VehiclePropConfig& vehiclePropConfig, int32_t areaId) { for (size_t i = 0; i < vehiclePropConfig.areaConfigs.size(); i++) { Loading Loading
automotive/vehicle/aidl/impl/current/default_config/JsonConfigLoader/src/JsonConfigLoader.cpp +17 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ using ::aidl::android::hardware::automotive::vehicle::FuelType; using ::aidl::android::hardware::automotive::vehicle::GsrComplianceRequirementType; using ::aidl::android::hardware::automotive::vehicle::HandsOnDetectionDriverState; using ::aidl::android::hardware::automotive::vehicle::HandsOnDetectionWarning; using ::aidl::android::hardware::automotive::vehicle::HasSupportedValueInfo; using ::aidl::android::hardware::automotive::vehicle::ImpactSensorLocation; using ::aidl::android::hardware::automotive::vehicle::LaneCenteringAssistCommand; using ::aidl::android::hardware::automotive::vehicle::LaneCenteringAssistState; Loading Loading @@ -600,6 +601,22 @@ void JsonConfigParser::parseAreas(const Json::Value& parentJsonNode, const std:: if (!supportedEnumValues.empty()) { areaConfig.supportedEnumValues = std::move(supportedEnumValues); } if (jsonAreaConfig.isMember("hasSupportedValueInfo")) { HasSupportedValueInfo hasSupportedValueInfo = HasSupportedValueInfo{}; const Json::Value& jsonHasSupportedValueInfo = jsonAreaConfig["hasSupportedValueInfo"]; tryParseJsonValueToVariable(jsonHasSupportedValueInfo, "hasMinSupportedValue", /*optional=*/true, &hasSupportedValueInfo.hasMinSupportedValue, errors); tryParseJsonValueToVariable(jsonHasSupportedValueInfo, "hasMaxSupportedValue", /*optional=*/true, &hasSupportedValueInfo.hasMaxSupportedValue, errors); tryParseJsonValueToVariable(jsonHasSupportedValueInfo, "hasSupportedValuesList", /*optional=*/true, &hasSupportedValueInfo.hasSupportedValuesList, errors); areaConfig.hasSupportedValueInfo = std::move(hasSupportedValueInfo); } config->config.areaConfigs.push_back(std::move(areaConfig)); RawPropValues areaValue = {}; Loading
automotive/vehicle/aidl/impl/current/default_config/JsonConfigLoader/test/JsonConfigLoaderUnitTest.cpp +103 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ namespace hardware { namespace automotive { namespace vehicle { using ::aidl::android::hardware::automotive::vehicle::HasSupportedValueInfo; using ::aidl::android::hardware::automotive::vehicle::RawPropValues; using ::aidl::android::hardware::automotive::vehicle::VehicleAreaConfig; using ::aidl::android::hardware::automotive::vehicle::VehiclePropConfig; Loading Loading @@ -803,6 +804,108 @@ TEST_F(JsonConfigLoaderUnitTest, testAccess_areaOverrideGlobal) { ASSERT_EQ(areaConfig2.areaId, 1); } TEST_F(JsonConfigLoaderUnitTest, testHasSupportedValueInfo_allTrue) { std::istringstream iss(R"( { "properties": [{ "property": "VehicleProperty::CABIN_LIGHTS_SWITCH", "areas": [{ "access": "VehiclePropertyAccess::WRITE", "areaId": 0, "hasSupportedValueInfo": { "hasMinSupportedValue": true, "hasMaxSupportedValue": true, "hasSupportedValuesList": true } }], "access": "VehiclePropertyAccess::READ", }] } )"); 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.access, VehiclePropertyAccess::READ); ASSERT_EQ(config.areaConfigs.size(), 1u); const VehicleAreaConfig& areaConfig = config.areaConfigs[0]; ASSERT_EQ(areaConfig.hasSupportedValueInfo, HasSupportedValueInfo({ .hasMinSupportedValue = true, .hasMaxSupportedValue = true, .hasSupportedValuesList = true, })); } TEST_F(JsonConfigLoaderUnitTest, testHasSupportedValueInfo_allFalse) { std::istringstream iss(R"( { "properties": [{ "property": "VehicleProperty::CABIN_LIGHTS_SWITCH", "areas": [{ "access": "VehiclePropertyAccess::WRITE", "areaId": 0, "hasSupportedValueInfo": { "hasMinSupportedValue": false, "hasMaxSupportedValue": false, "hasSupportedValuesList": false } }], "access": "VehiclePropertyAccess::READ", }] } )"); 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.access, VehiclePropertyAccess::READ); ASSERT_EQ(config.areaConfigs.size(), 1u); const VehicleAreaConfig& areaConfig = config.areaConfigs[0]; ASSERT_EQ(areaConfig.hasSupportedValueInfo, HasSupportedValueInfo({ .hasMinSupportedValue = false, .hasMaxSupportedValue = false, .hasSupportedValuesList = false, })); } TEST_F(JsonConfigLoaderUnitTest, testHasSupportedValueInfo_unspecified) { std::istringstream iss(R"( { "properties": [{ "property": "VehicleProperty::CABIN_LIGHTS_SWITCH", "areas": [{ "access": "VehiclePropertyAccess::WRITE", "areaId": 0 }], "access": "VehiclePropertyAccess::READ", }] } )"); 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.access, VehiclePropertyAccess::READ); ASSERT_EQ(config.areaConfigs.size(), 1u); const VehicleAreaConfig& areaConfig = config.areaConfigs[0]; ASSERT_EQ(areaConfig.hasSupportedValueInfo, std::nullopt); } } // namespace vehicle } // namespace automotive } // namespace hardware Loading
automotive/vehicle/aidl/impl/current/default_config/config/TestProperties.json +6 −3 Original line number Diff line number Diff line Loading @@ -99,12 +99,15 @@ { "defaultValue": { "int32Values": [ 1 2 ] }, "areaId": "VehicleAreaWindow::FRONT_WINDSHIELD", "minInt32Value": -100, "maxInt32Value": 100 "hasSupportedValueInfo": { "hasMinSupportedValue": true, "hasMaxSupportedValue": true, "hasSupportedValuesList": true } }, { "defaultValue": { Loading
automotive/vehicle/aidl/impl/current/fake_impl/hardware/include/FakeVehicleHardware.h +6 −0 Original line number Diff line number Diff line Loading @@ -108,6 +108,12 @@ class FakeVehicleHardware : public IVehicleHardware { aidl::android::hardware::automotive::vehicle::StatusCode unsubscribe(int32_t propId, int32_t areaId) override; std::vector<aidlvhal::MinMaxSupportedValueResult> getMinMaxSupportedValues( const std::vector<PropIdAreaId>& propIdAreaIds) override; std::vector<aidlvhal::SupportedValuesListResult> getSupportedValuesLists( const std::vector<PropIdAreaId>& propIdAreaIds) override; protected: // mValuePool is also used in mServerSidePropStore. const std::shared_ptr<VehiclePropValuePool> mValuePool; Loading
automotive/vehicle/aidl/impl/current/fake_impl/hardware/src/FakeVehicleHardware.cpp +58 −0 Original line number Diff line number Diff line Loading @@ -62,11 +62,13 @@ using ::aidl::android::hardware::automotive::vehicle::DriverDrowsinessAttentionW using ::aidl::android::hardware::automotive::vehicle::ErrorState; using ::aidl::android::hardware::automotive::vehicle::GetValueRequest; using ::aidl::android::hardware::automotive::vehicle::GetValueResult; using ::aidl::android::hardware::automotive::vehicle::MinMaxSupportedValueResult; using ::aidl::android::hardware::automotive::vehicle::RawPropValues; using ::aidl::android::hardware::automotive::vehicle::SetValueRequest; using ::aidl::android::hardware::automotive::vehicle::SetValueResult; 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::VehicleApPowerStateReport; using ::aidl::android::hardware::automotive::vehicle::VehicleApPowerStateReq; Loading Loading @@ -2299,6 +2301,62 @@ StatusCode FakeVehicleHardware::subscribe(SubscribeOptions options) { return StatusCode::OK; } std::vector<MinMaxSupportedValueResult> FakeVehicleHardware::getMinMaxSupportedValues( const std::vector<PropIdAreaId>& propIdAreaIds) { std::vector<MinMaxSupportedValueResult> 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)) { results.push_back(MinMaxSupportedValueResult{ .status = StatusCode::INVALID_ARG, }); continue; } results.push_back(MinMaxSupportedValueResult{ .status = StatusCode::OK, .minSupportedValue = RawPropValues{ .int32Values = {0}, }, .maxSupportedValue = RawPropValues{ .int32Values = {10}, }, }); } return results; } std::vector<SupportedValuesListResult> FakeVehicleHardware::getSupportedValuesLists( const std::vector<PropIdAreaId>& propIdAreaIds) { 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)) { results.push_back(SupportedValuesListResult{ .status = StatusCode::INVALID_ARG, }); continue; } results.push_back(SupportedValuesListResult{ .status = StatusCode::OK, .supportedValuesList = std::vector<std::optional<RawPropValues>>({ RawPropValues{.int32Values = {0}}, RawPropValues{.int32Values = {2}}, RawPropValues{.int32Values = {4}}, RawPropValues{.int32Values = {6}}, RawPropValues{.int32Values = {8}}, RawPropValues{.int32Values = {10}}, }), }); } return results; } bool FakeVehicleHardware::isVariableUpdateRateSupported(const VehiclePropConfig& vehiclePropConfig, int32_t areaId) { for (size_t i = 0; i < vehiclePropConfig.areaConfigs.size(); i++) { Loading