Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e6dc7d24 authored by Yu Shan's avatar Yu Shan Committed by Android (Google) Code Review
Browse files

Merge "Populate both VehiclePropConfig and VehicleAreaConfig.access" into main

parents 1654e826 127dc87b
Loading
Loading
Loading
Loading
+12 −8
Original line number Diff line number Diff line
@@ -53,21 +53,25 @@ parcelable VehicleAreaConfig {
    /**
     * Defines if the area ID for this property is READ, WRITE or READ_WRITE. This only applies if
     * the property is defined in the framework as a READ_WRITE property. Access (if set) should be
     * equal to, or a superset of, the VehiclePropConfig.access of the property.
     * equal to, or a superset of, the VehiclePropConfig.access of the property. If access is not
     * set for this VehicleAreaConfig (i.e. access == VehiclePropertyAccess.NONE), then it will
     * automatically be assumed that the areaId access is the same as the VehiclePropConfig.access
     * of the property.
     *
     * For example, if a property is defined as READ_WRITE, but the OEM wants to specify certain
     * area Ids as READ-only, the corresponding areaIds should have an access set to READ, while the
     * others must be set to READ_WRITE. We do not support setting specific area Ids to WRITE-only
     * when the property is READ-WRITE.
     *
     * Exclusively one of VehiclePropConfig and the VehicleAreaConfigs should be specified for a
     * single property. If VehiclePropConfig.access is populated, none of the
     * VehicleAreaConfig.access values should be populated. If VehicleAreaConfig.access values are
     * populated, VehiclePropConfig.access must not be populated.
     * VehiclePropConfig.access should be equal the maximal subset of the accesses set in
     * VehiclePropConfig.areaConfigs, excluding those with access == VehiclePropertyAccess.NONE. For
     * example, if a VehiclePropConfig has some area configs with an access of
     * VehiclePropertyAccess.READ and others with an access of VehiclePropertyAccess.READ_WRITE, the
     * VehiclePropConfig object's access should be VehiclePropertyAccess.READ.
     *
     * VehicleAreaConfigs should not be partially populated with access. If the OEM wants to specify
     * access for one area Id, all other configs should be populated with their access levels as
     * well.
     * In the scenario where the OEM actually wants to set VehicleAreaConfig.access =
     * VehiclePropertyAccess.NONE, the maximal subset rule should apply with this area config
     * included, making the VehiclePropConfig.access = VehiclePropertyAccess.NONE.
     */
    VehiclePropertyAccess access = VehiclePropertyAccess.NONE;

+14 −3
Original line number Diff line number Diff line
@@ -29,9 +29,20 @@ parcelable VehiclePropConfig {
    /**
     * Defines if the property is read or write or both.
     *
     * If populating VehicleAreaConfig.access fields for this property, this field should not be
     * populated. If the OEM decides to populate this field, none of the VehicleAreaConfig.access
     * fields should be populated.
     * If any VehicleAreaConfig.access is not set (i.e. VehicleAreaConfig.access ==
     * VehiclePropertyAccess.NONE) for this property, it will automatically be assumed that the
     * areaId access is the same as the VehiclePropConfig.access.
     *
     * VehiclePropConfig.access should be equal the maximal subset of the accesses set in its
     * areaConfigs, excluding those with access == VehiclePropertyAccess.NONE. For example, if a
     * VehiclePropConfig has some area configs with an access of VehiclePropertyAccess.READ and
     * others with an access of VehiclePropertyAccess.READ_WRITE, the VehiclePropConfig object's
     * access should be VehiclePropertyAccess.READ.
     *
     * In the scenario where the OEM actually wants to set VehicleAreaConfig.access =
     * VehiclePropertyAccess.NONE for a particular area config, the maximal subset rule should apply
     * with this area config included, making the VehiclePropConfig.access =
     * VehiclePropertyAccess.NONE.
     */
    VehiclePropertyAccess access = VehiclePropertyAccess.NONE;

+2 −4
Original line number Diff line number Diff line
@@ -142,10 +142,8 @@ class JsonConfigParser {
                         std::vector<std::string>* errors);

    // Prase a JSON field as an array of area configs.
    void parseAreas(
            const Json::Value& parentJsonNode, const std::string& fieldName,
            ConfigDeclaration* outPtr, std::vector<std::string>* errors,
            aidl::android::hardware::automotive::vehicle::VehiclePropertyAccess defaultAccess);
    void parseAreas(const Json::Value& parentJsonNode, const std::string& fieldName,
                    ConfigDeclaration* outPtr, std::vector<std::string>* errors);
};

}  // namespace jsonconfigloader_impl
+7 −8
Original line number Diff line number Diff line
@@ -541,8 +541,7 @@ bool JsonConfigParser::parsePropValues(const Json::Value& parentJsonNode,
}

void JsonConfigParser::parseAreas(const Json::Value& parentJsonNode, const std::string& fieldName,
                                  ConfigDeclaration* config, std::vector<std::string>* errors,
                                  VehiclePropertyAccess defaultAccess) {
                                  ConfigDeclaration* config, std::vector<std::string>* errors) {
    if (!parentJsonNode.isObject()) {
        errors->push_back("Node: " + parentJsonNode.toStyledString() + " is not an object");
        return;
@@ -566,8 +565,8 @@ void JsonConfigParser::parseAreas(const Json::Value& parentJsonNode, const std::
        }
        VehicleAreaConfig areaConfig = {};
        areaConfig.areaId = areaId;
        parseAccessChangeMode(jsonAreaConfig, "access", propStr, &defaultAccess, &areaConfig.access,
                              errors);
        parseAccessChangeMode(jsonAreaConfig, "access", propStr, &(config->config.access),
                              &areaConfig.access, errors);
        tryParseJsonValueToVariable(jsonAreaConfig, "minInt32Value", /*optional=*/true,
                                    &areaConfig.minInt32Value, errors);
        tryParseJsonValueToVariable(jsonAreaConfig, "maxInt32Value", /*optional=*/true,
@@ -625,8 +624,8 @@ std::optional<ConfigDeclaration> JsonConfigParser::parseEachProperty(
    if (itChangeMode != ChangeModeForVehicleProperty.end()) {
        defaultChangeMode = &itChangeMode->second;
    }
    VehiclePropertyAccess access = VehiclePropertyAccess::NONE;
    parseAccessChangeMode(propJsonValue, "access", propStr, defaultAccessMode, &access, errors);
    parseAccessChangeMode(propJsonValue, "access", propStr, defaultAccessMode,
                          &configDecl.config.access, errors);

    parseAccessChangeMode(propJsonValue, "changeMode", propStr, defaultChangeMode,
                          &configDecl.config.changeMode, errors);
@@ -645,14 +644,14 @@ std::optional<ConfigDeclaration> JsonConfigParser::parseEachProperty(
    tryParseJsonValueToVariable(propJsonValue, "maxSampleRate", /*optional=*/true,
                                &configDecl.config.maxSampleRate, errors);

    parseAreas(propJsonValue, "areas", &configDecl, errors, access);
    parseAreas(propJsonValue, "areas", &configDecl, errors);

    // If there is no area config, by default we allow variable update rate, so we have to add
    // a global area config.
    if (configDecl.config.areaConfigs.size() == 0) {
        VehicleAreaConfig areaConfig = {
                .areaId = 0,
                .access = access,
                .access = configDecl.config.access,
                .supportVariableUpdateRate = true,
        };
        configDecl.config.areaConfigs.push_back(std::move(areaConfig));
+11 −11
Original line number Diff line number Diff line
@@ -286,7 +286,7 @@ TEST_F(JsonConfigLoaderUnitTest, testCheckDefaultAccessChangeMode) {
    ASSERT_EQ(configs.size(), 1u);

    const VehiclePropConfig& propConfig = configs.begin()->second.config;
    ASSERT_EQ(propConfig.access, VehiclePropertyAccess::NONE);
    ASSERT_EQ(propConfig.access, VehiclePropertyAccess::READ);
    ASSERT_EQ(propConfig.areaConfigs[0].access, VehiclePropertyAccess::READ);
    ASSERT_EQ(propConfig.changeMode, VehiclePropertyChangeMode::STATIC);
}
@@ -308,7 +308,7 @@ TEST_F(JsonConfigLoaderUnitTest, testAccessOverride) {
    ASSERT_EQ(configs.size(), 1u);

    const VehiclePropConfig& propConfig = configs.begin()->second.config;
    ASSERT_EQ(propConfig.access, VehiclePropertyAccess::NONE);
    ASSERT_EQ(propConfig.access, VehiclePropertyAccess::WRITE);
    ASSERT_EQ(propConfig.areaConfigs[0].access, VehiclePropertyAccess::WRITE);
    ASSERT_EQ(propConfig.changeMode, VehiclePropertyChangeMode::STATIC);
}
@@ -330,7 +330,7 @@ TEST_F(JsonConfigLoaderUnitTest, testChangeModeOverride) {
    ASSERT_EQ(configs.size(), 1u);

    const VehiclePropConfig& propConfig = configs.begin()->second.config;
    ASSERT_EQ(propConfig.access, VehiclePropertyAccess::NONE);
    ASSERT_EQ(propConfig.access, VehiclePropertyAccess::READ);
    ASSERT_EQ(propConfig.areaConfigs[0].access, VehiclePropertyAccess::READ);
    ASSERT_EQ(propConfig.changeMode, VehiclePropertyChangeMode::ON_CHANGE);
}
@@ -353,7 +353,7 @@ TEST_F(JsonConfigLoaderUnitTest, testCustomProp) {
    ASSERT_EQ(configs.size(), 1u);

    const VehiclePropConfig& propConfig = configs.begin()->second.config;
    ASSERT_EQ(propConfig.access, VehiclePropertyAccess::NONE);
    ASSERT_EQ(propConfig.access, VehiclePropertyAccess::WRITE);
    ASSERT_EQ(propConfig.areaConfigs[0].access, VehiclePropertyAccess::WRITE);
    ASSERT_EQ(propConfig.changeMode, VehiclePropertyChangeMode::ON_CHANGE);
}
@@ -554,7 +554,7 @@ TEST_F(JsonConfigLoaderUnitTest, testAreas_Simple) {
    ASSERT_EQ(configs.size(), 1u);

    const VehiclePropConfig& config = configs.begin()->second.config;
    ASSERT_EQ(config.access, VehiclePropertyAccess::NONE);
    ASSERT_EQ(config.access, VehiclePropertyAccess::READ);
    ASSERT_EQ(config.areaConfigs.size(), 1u);
    const VehicleAreaConfig& areaConfig = config.areaConfigs[0];
    ASSERT_EQ(areaConfig.minInt32Value, 1);
@@ -641,7 +641,7 @@ TEST_F(JsonConfigLoaderUnitTest, testAreas_HandlesNoSupportedEnumValuesDeclared)
    ASSERT_EQ(configs.size(), 1u);

    const VehiclePropConfig& config = configs.begin()->second.config;
    ASSERT_EQ(config.access, VehiclePropertyAccess::NONE);
    ASSERT_EQ(config.access, VehiclePropertyAccess::READ);
    ASSERT_EQ(config.areaConfigs.size(), 1u);

    const VehicleAreaConfig& areaConfig = config.areaConfigs[0];
@@ -670,7 +670,7 @@ TEST_F(JsonConfigLoaderUnitTest, testAreas_HandlesSupportedEnumValues) {
    ASSERT_EQ(configs.size(), 1u);

    const VehiclePropConfig& config = configs.begin()->second.config;
    ASSERT_EQ(config.access, VehiclePropertyAccess::NONE);
    ASSERT_EQ(config.access, VehiclePropertyAccess::READ);
    ASSERT_EQ(config.areaConfigs.size(), 1u);

    const VehicleAreaConfig& areaConfig = config.areaConfigs[0];
@@ -702,7 +702,7 @@ TEST_F(JsonConfigLoaderUnitTest, testAreas_HandlesEmptySupportedEnumValues) {
    ASSERT_EQ(configs.size(), 1u);

    const VehiclePropConfig& config = configs.begin()->second.config;
    ASSERT_EQ(config.access, VehiclePropertyAccess::NONE);
    ASSERT_EQ(config.access, VehiclePropertyAccess::READ);
    ASSERT_EQ(config.areaConfigs.size(), 1u);

    const VehicleAreaConfig& areaConfig = config.areaConfigs[0];
@@ -731,7 +731,7 @@ TEST_F(JsonConfigLoaderUnitTest, testAccess_areaOverrideGlobalDefault) {
    ASSERT_EQ(configs.size(), 1u);

    const VehiclePropConfig& config = configs.begin()->second.config;
    ASSERT_EQ(config.access, VehiclePropertyAccess::NONE);
    ASSERT_EQ(config.access, VehiclePropertyAccess::READ_WRITE);
    ASSERT_EQ(config.areaConfigs.size(), 1u);

    const VehicleAreaConfig& areaConfig = config.areaConfigs[0];
@@ -759,7 +759,7 @@ TEST_F(JsonConfigLoaderUnitTest, testAccess_globalOverrideDefault) {
    ASSERT_EQ(configs.size(), 1u);

    const VehiclePropConfig& config = configs.begin()->second.config;
    ASSERT_EQ(config.access, VehiclePropertyAccess::NONE);
    ASSERT_EQ(config.access, VehiclePropertyAccess::READ);
    ASSERT_EQ(config.areaConfigs.size(), 1u);

    const VehicleAreaConfig& areaConfig = config.areaConfigs[0];
@@ -791,7 +791,7 @@ TEST_F(JsonConfigLoaderUnitTest, testAccess_areaOverrideGlobal) {
    ASSERT_EQ(configs.size(), 1u);

    const VehiclePropConfig& config = configs.begin()->second.config;
    ASSERT_EQ(config.access, VehiclePropertyAccess::NONE);
    ASSERT_EQ(config.access, VehiclePropertyAccess::READ);
    ASSERT_EQ(config.areaConfigs.size(), 2u);

    const VehicleAreaConfig& areaConfig1 = config.areaConfigs[0];
Loading