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

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

Merge changes from topic "vhal_json_config"

* changes:
  Add area config parsing.
  Add recently added properties and fix change mode.
  Add constant value parsers.
  Create JsonConfigLoader.
parents a5a64105 9b64b82f
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -6,6 +6,15 @@
    {
    {
      "name": "VehicleHalDefaultConfigTest"
      "name": "VehicleHalDefaultConfigTest"
    },
    },
    {
      "name": "VehicleHalDefaultConfigTestEnableTestProperties"
    },
    {
      "name": "JsonConfigLoaderUnitTest"
    },
    {
      "name": "JsonConfigLoaderUnitTestEnableTestProperties"
    },
    {
    {
      "name": "VehicleHalVehicleUtilsTest"
      "name": "VehicleHalVehicleUtilsTest"
    },
    },
+1 −1
Original line number Original line Diff line number Diff line
@@ -542,7 +542,7 @@ enum VehicleProperty {
     */
     */
    TRACTION_CONTROL_ACTIVE = 0x040B + 0x10000000 + 0x01000000
    TRACTION_CONTROL_ACTIVE = 0x040B + 0x10000000 + 0x01000000
            + 0x00200000, // VehiclePropertyGroup:SYSTEM,VehicleArea:GLOBAL,VehiclePropertyType:BOOLEAN
            + 0x00200000, // VehiclePropertyGroup:SYSTEM,VehicleArea:GLOBAL,VehiclePropertyType:BOOLEAN
    /*
    /**
     * HVAC Properties
     * HVAC Properties
     *
     *
     * Additional rules for mapping a zoned HVAC property (except
     * Additional rules for mapping a zoned HVAC property (except
+8 −2
Original line number Original line Diff line number Diff line
@@ -25,7 +25,13 @@ cc_library_headers {
    export_include_dirs: ["include"],
    export_include_dirs: ["include"],
    defaults: ["VehicleHalDefaults"],
    defaults: ["VehicleHalDefaults"],
    static_libs: ["VehicleHalUtils"],
    static_libs: ["VehicleHalUtils"],
    header_libs: ["VehicleHalTestUtilHeaders"],
    header_libs: [
        "VehicleHalJsonConfigLoaderHeaders",
        "VehicleHalTestUtilHeaders",
    ],
    export_static_lib_headers: ["VehicleHalUtils"],
    export_static_lib_headers: ["VehicleHalUtils"],
    export_header_lib_headers: ["VehicleHalTestUtilHeaders"],
    export_header_lib_headers: [
        "VehicleHalTestUtilHeaders",
        "VehicleHalJsonConfigLoaderHeaders",
    ],
}
}
+62 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2022 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.
 */

package {
    default_applicable_licenses: ["Android-Apache-2.0"],
}

cc_library {
    name: "VehicleHalJsonConfigLoader",
    vendor: true,
    srcs: ["src/*.cpp"],
    local_include_dirs: ["include"],
    export_include_dirs: ["include"],
    defaults: ["VehicleHalDefaults"],
    static_libs: ["VehicleHalUtils"],
    header_libs: [
        "IVehicleGeneratedHeaders",
    ],
    shared_libs: ["libjsoncpp"],
}

cc_library {
    name: "VehicleHalJsonConfigLoaderEnableTestProperties",
    vendor: true,
    srcs: ["src/*.cpp"],
    local_include_dirs: ["include"],
    export_include_dirs: ["include"],
    defaults: ["VehicleHalDefaults"],
    static_libs: ["VehicleHalUtils"],
    header_libs: [
        "VehicleHalTestUtilHeaders",
        "IVehicleGeneratedHeaders",
    ],
    cflags: ["-DENABLE_VEHICLE_HAL_TEST_PROPERTIES"],
    shared_libs: ["libjsoncpp"],
}

cc_library_headers {
    name: "VehicleHalJsonConfigLoaderHeaders",
    vendor: true,
    local_include_dirs: ["include"],
    export_include_dirs: ["include"],
    defaults: ["VehicleHalDefaults"],
    static_libs: ["VehicleHalUtils"],
    header_libs: [
        "IVehicleGeneratedHeaders",
    ],
    shared_libs: ["libjsoncpp"],
}
+61 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2022 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.
 */

#ifndef android_hardware_automotive_vehicle_aidl_impl_default_config_JsonConfigLoader_include_ConfigDeclaration_H_
#define android_hardware_automotive_vehicle_aidl_impl_default_config_JsonConfigLoader_include_ConfigDeclaration_H_

#include <VehicleHalTypes.h>

#include <unordered_map>

namespace android {
namespace hardware {
namespace automotive {
namespace vehicle {

// ConfigDeclaration represents one property config, its optional initial value and its optional
// area configs and initial values for each area.
struct ConfigDeclaration {
    aidl::android::hardware::automotive::vehicle::VehiclePropConfig config;

    // This value will be used as an initial value for the property. If this field is specified for
    // property that supports multiple areas then it will be used for all areas unless particular
    // area is overridden in initialAreaValue field.
    aidl::android::hardware::automotive::vehicle::RawPropValues initialValue;
    // Use initialAreaValues if it is necessary to specify different values per each area.
    std::unordered_map<int32_t, aidl::android::hardware::automotive::vehicle::RawPropValues>
            initialAreaValues;

    inline bool operator==(const ConfigDeclaration& other) const {
        return (config == other.config && initialValue == other.initialValue &&
                initialAreaValues == other.initialAreaValues);
    }

    friend std::ostream& operator<<(std::ostream& os, const ConfigDeclaration& c) {
        return os << "Config Declaration for property: "
                  << aidl::android::hardware::automotive::vehicle::toString(
                             static_cast<
                                     aidl::android::hardware::automotive::vehicle::VehicleProperty>(
                                     c.config.prop));
    }
};

}  // namespace vehicle
}  // namespace automotive
}  // namespace hardware
}  // namespace android

#endif  // android_hardware_automotive_vehicle_aidl_impl_default_config_JsonConfigLoader_include_ConfigDeclaration_H_
Loading