summaryrefslogtreecommitdiff
path: root/src/components/policy
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/policy')
-rw-r--r--src/components/policy/policy_external/CMakeLists.txt66
-rw-r--r--src/components/policy/policy_external/doc/doxygen/components/SmartObjects/Smart Objects Validation/Schema Structure.txt26
-rw-r--r--src/components/policy/policy_external/include/policy/cache_manager.h44
-rw-r--r--src/components/policy/policy_external/include/policy/cache_manager_interface.h12
-rw-r--r--src/components/policy/policy_external/include/policy/policy_helper.h9
-rw-r--r--src/components/policy/policy_external/include/policy/policy_manager_impl.h13
-rw-r--r--src/components/policy/policy_external/include/policy/policy_table/enums.h582
-rw-r--r--src/components/policy/policy_external/include/policy/policy_table/policy_enum_schema_factory.h62
-rw-r--r--src/components/policy/policy_external/include/policy/policy_table/types.h114
-rw-r--r--src/components/policy/policy_external/include/policy/policy_types.h2
-rw-r--r--src/components/policy/policy_external/include/policy/pt_representation.h5
-rw-r--r--src/components/policy/policy_external/include/policy/sql_pt_queries.h15
-rw-r--r--src/components/policy/policy_external/include/policy/sql_pt_representation.h34
-rw-r--r--src/components/policy/policy_external/src/cache_manager.cc109
-rw-r--r--src/components/policy/policy_external/src/policy_helper.cc157
-rw-r--r--src/components/policy/policy_external/src/policy_manager_impl.cc85
-rw-r--r--src/components/policy/policy_external/src/policy_table/enums.cc1439
-rw-r--r--src/components/policy/policy_external/src/policy_table/types.cc498
-rw-r--r--src/components/policy/policy_external/src/policy_table/validation.cc51
-rw-r--r--src/components/policy/policy_external/src/sql_pt_queries.cc131
-rw-r--r--src/components/policy/policy_external/src/sql_pt_representation.cc460
-rw-r--r--src/components/policy/policy_external/test/include/policy/mock_pt_representation.h1
-rw-r--r--src/components/policy/policy_external/test/include/policy/policy_manager_impl_test_base.h2
-rw-r--r--src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc24
-rw-r--r--src/components/policy/policy_external/test/policy_manager_impl_test.cc9
-rw-r--r--src/components/policy/policy_external/test/policy_manager_impl_test_base.cc4
-rw-r--r--src/components/policy/policy_external/test/sql_pt_ext_representation_test.cc18
-rw-r--r--src/components/policy/policy_external/test/sql_pt_representation_test.cc123
-rw-r--r--src/components/policy/policy_regular/CMakeLists.txt71
-rw-r--r--src/components/policy/policy_regular/include/policy/cache_manager.h38
-rw-r--r--src/components/policy/policy_regular/include/policy/cache_manager_interface.h12
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_helper.h2
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_manager_impl.h12
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_table/enums.h574
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_table/policy_enum_schema_factory.h60
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_table/types.h114
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_types.h2
-rw-r--r--src/components/policy/policy_regular/include/policy/pt_representation.h5
-rw-r--r--src/components/policy/policy_regular/include/policy/sql_pt_queries.h13
-rw-r--r--src/components/policy/policy_regular/include/policy/sql_pt_representation.h33
-rw-r--r--src/components/policy/policy_regular/src/cache_manager.cc112
-rw-r--r--src/components/policy/policy_regular/src/policy_helper.cc161
-rw-r--r--src/components/policy/policy_regular/src/policy_manager_impl.cc74
-rw-r--r--src/components/policy/policy_regular/src/policy_table/enums.cc1518
-rw-r--r--src/components/policy/policy_regular/src/policy_table/types.cc496
-rw-r--r--src/components/policy/policy_regular/src/policy_table/validation.cc49
-rw-r--r--src/components/policy/policy_regular/src/sql_pt_queries.cc135
-rw-r--r--src/components/policy/policy_regular/src/sql_pt_representation.cc469
-rw-r--r--src/components/policy/policy_regular/test/include/policy/mock_pt_representation.h1
-rw-r--r--src/components/policy/policy_regular/test/policy_manager_impl_test.cc387
-rw-r--r--src/components/policy/policy_regular/test/sql_pt_representation_test.cc158
-rw-r--r--src/components/policy/policy_regular/test/vehicle_data_item_type_test.cc250
52 files changed, 4378 insertions, 4463 deletions
diff --git a/src/components/policy/policy_external/CMakeLists.txt b/src/components/policy/policy_external/CMakeLists.txt
index 80c3cb60e6..361c48a598 100644
--- a/src/components/policy/policy_external/CMakeLists.txt
+++ b/src/components/policy/policy_external/CMakeLists.txt
@@ -28,6 +28,8 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
+include(${CMAKE_SOURCE_DIR}/tools/cmake/helpers/generators.cmake)
+
# --- Policy
set(install_destination bin)
set(copy_destination ${CMAKE_BINARY_DIR}/src/appMain)
@@ -36,13 +38,16 @@ set(library_name ${CMAKE_SHARED_LIBRARY_PREFIX}Policy${CMAKE_SHARED_LIBRARY_SUFF
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
include_directories (
- include
- ${COMPONENTS_DIR}/rpc_base/include
+ ${POLICY_PATH}/include/
+ ${COMPONENTS_DIR}/
${COMPONENTS_DIR}/utils/include/
${COMPONENTS_DIR}/config_profile/include
+ ${COMPONENTS_DIR}/smart_objects/include/
+ ${COMPONENTS_DIR}/rpc_base/include
+ ${CMAKE_BINARY_DIR}/src/components/
${POLICY_GLOBAL_INCLUDE_PATH}/
- ${LOG4CXX_INCLUDE_DIRECTORY}
${BOOST_INCLUDE_DIR}
+ ${LOG4CXX_INCLUDE_DIRECTORY}
${JSONCPP_INCLUDE_DIRECTORY}
)
@@ -59,12 +64,54 @@ set(SOURCES
${COMPONENTS_DIR}/rpc_base/src/rpc_base/rpc_base.cc
)
+set(GENERATED_MOBILE_POLICY_TYPES_CPP
+ "${CMAKE_CURRENT_BINARY_DIR}/generated_MOBILE_API_policy_types.cc"
+ "${CMAKE_CURRENT_BINARY_DIR}/generated_MOBILE_API_enum_schema_factory.cc")
+
+set(GENERATED_MOBILE_POLICY_TYPES_HPP
+ "${CMAKE_CURRENT_BINARY_DIR}/generated_MOBILE_API_policy_types.h")
+
+set(GENERATED_MOBILE_POLICY_TYPES
+ ${GENERATED_MOBILE_POLICY_TYPES_HPP}
+ ${GENERATED_MOBILE_POLICY_TYPES_CPP})
+
+generate_policy_types("${GENERATED_MOBILE_POLICY_TYPES}"
+ "${COMPONENTS_DIR}/interfaces/MOBILE_API.xml"
+ "rpc::policy_table_interface_base"
+ "mobile-policy-types")
+
+set(GENERATED_HMI_POLICY_TYPES_CPP
+ "${CMAKE_CURRENT_BINARY_DIR}/generated_HMI_API_policy_types.cc")
+
+set(GENERATED_HMI_POLICY_TYPES_HPP
+ "${CMAKE_CURRENT_BINARY_DIR}/generated_HMI_API_policy_types.h")
+
+set(GENERATED_HMI_POLICY_TYPES
+ ${GENERATED_HMI_POLICY_TYPES_HPP}
+ ${GENERATED_HMI_POLICY_TYPES_CPP})
+
+
+generate_policy_types("${GENERATED_HMI_POLICY_TYPES}"
+ "${COMPONENTS_DIR}/interfaces/HMI_API.xml"
+ "rpc::policy_table_interface_base"
+ "hmi-policy-types")
+
+if (REMOTE_CONTROL)
+ list(APPEND SOURCES ${POLICY_PATH}/src/access_remote_impl.cc)
+endif()
+
list(APPEND SOURCES
${POLICY_PATH}/src/sql_pt_ext_queries.cc
${POLICY_PATH}/src/sql_pt_ext_representation.cc
)
-set(LIBRARIES ConfigProfile policy_struct dbms jsoncpp Utils)
+set(LIBRARIES
+ ConfigProfile
+ policy_struct
+ dbms jsoncpp
+ Utils
+)
+
if (CMAKE_SYSTEM_NAME STREQUAL "QNX")
# --- QDB Wrapper
include_directories (${COMPONENTS_DIR}/utils/include/utils)
@@ -103,13 +150,22 @@ install(TARGETS Policy
set(struct_target policy_struct)
set(TABLE_STRUCT_SOURCES
+ ${GENERATED_MOBILE_POLICY_TYPES_CPP}
+ ${GENERATED_HMI_POLICY_TYPES_CPP}
${POLICY_PATH}/src/policy_table/enums.cc
${POLICY_PATH}/src/policy_table/types.cc
${POLICY_PATH}/src/policy_table/validation.cc
)
add_library(${struct_target} ${TABLE_STRUCT_SOURCES})
-target_link_libraries(${struct_target} Utils)
+target_link_libraries(${struct_target}
+MOBILE_API
+HMI_API
+Utils
+SmartObjects
+formatters
+jsoncpp
+)
# --- Usage statistics
set(USAGE_STATISTICS_SOURCES
diff --git a/src/components/policy/policy_external/doc/doxygen/components/SmartObjects/Smart Objects Validation/Schema Structure.txt b/src/components/policy/policy_external/doc/doxygen/components/SmartObjects/Smart Objects Validation/Schema Structure.txt
index a031e9fd86..d4be0ce490 100644
--- a/src/components/policy/policy_external/doc/doxygen/components/SmartObjects/Smart Objects Validation/Schema Structure.txt
+++ b/src/components/policy/policy_external/doc/doxygen/components/SmartObjects/Smart Objects Validation/Schema Structure.txt
@@ -19,7 +19,7 @@ ns_smart_device_link::ns_smart_objects::CArraySchemaItem provides validation for
ns_smart_device_link::ns_smart_objects::CObjectSchemaItem used in case when Schema Item includes another Schema Item. Actually this is only way to create tree node of new Schema. All other Schema Items will be used only to become leafs of validation tree.
After creation of all required Schema Items (which is actually bind in the tree) it is possible to create Schema.
-Schema can be initialized not only by raw root Schema Item, but also by special abstraction called Member (defined by ns_smart_device_link::ns_smart_objects::CObjectSchemaItem::SMember class). So every root item (ns_smart_device_link::ns_smart_objects::CObjectSchemaItem) firstly should be wrapped as Member. This wrapping process also allows to set "is mandatory" status for every Member.
+Schema can be initialized not only by raw root Schema Item, but also by special abstraction called Member (defined by ns_smart_device_link::ns_smart_objects::SMember class). So every root item (ns_smart_device_link::ns_smart_objects::CObjectSchemaItem) firstly should be wrapped as Member. This wrapping process also allows to set "is mandatory" status for every Member.
and pass root Schema Item as initial parameter to the new Schema.
@@ -69,29 +69,29 @@ TSharedPtr<ISchemaItem> resultCode_SchemaItem = TEnumSchemaItem<Result::eType>::
// Provides additional human readable info regarding the result.
TSharedPtr<ISchemaItem> info_SchemaItem = CStringSchemaItem::create(TSchemaItemParameter<size_t>(1000), TSchemaItemParameter<std::string>());
-schemaMembersMap["success"] = CObjectSchemaItem::SMember(success_SchemaItem, true);
+schemaMembersMap["success"] = SMember(success_SchemaItem, true);
-schemaMembersMap["resultCode"] = CObjectSchemaItem::SMember(resultCode_SchemaItem, true);
+schemaMembersMap["resultCode"] = SMember(resultCode_SchemaItem, true);
-schemaMembersMap["info"] = CObjectSchemaItem::SMember(info_SchemaItem, false);
+schemaMembersMap["info"] = SMember(info_SchemaItem, false);
-std::map<std::string, CObjectSchemaItem::SMember> paramsMembersMap;
+std::map<std::string, SMember> paramsMembersMap;
-paramsMembersMap[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = CObjectSchemaItem::SMember(TEnumSchemaItem<FunctionID::eType>::create(FunctionIDItems), true);
+paramsMembersMap[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = SMember(TEnumSchemaItem<FunctionID::eType>::create(FunctionIDItems), true);
-paramsMembersMap[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(TEnumSchemaItem<messageType::eType>::create(MessageTypeItems), true);
+paramsMembersMap[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = SMember(TEnumSchemaItem<messageType::eType>::create(MessageTypeItems), true);
-paramsMembersMap[ns_smart_device_link::ns_json_handler::strings::S_CORRELATION_ID] = CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+paramsMembersMap[ns_smart_device_link::ns_json_handler::strings::S_CORRELATION_ID] = SMember(TNumberSchemaItem<int>::create(), true);
-paramsMembersMap[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(1, 2), true);
+paramsMembersMap[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = SMember(TNumberSchemaItem<int>::create(1, 2), true);
-paramsMembersMap[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+paramsMembersMap[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = SMember(TNumberSchemaItem<int>::create(), true);
-std::map<std::string, CObjectSchemaItem::SMember> rootMembersMap;
+std::map<std::string, SMember> rootMembersMap;
-rootMembersMap[ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS] = CObjectSchemaItem::SMember(CObjectSchemaItem::create(schemaMembersMap), true);
+rootMembersMap[ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS] = SMember(CObjectSchemaItem::create(schemaMembersMap), true);
-rootMembersMap[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = CObjectSchemaItem::SMember(CObjectSchemaItem::create(paramsMembersMap), true);
+rootMembersMap[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = SMember(CObjectSchemaItem::create(paramsMembersMap), true);
CSmartSchema(CObjectSchemaItem::create(rootMembersMap));
diff --git a/src/components/policy/policy_external/include/policy/cache_manager.h b/src/components/policy/policy_external/include/policy/cache_manager.h
index 05d423da83..acc7a7da51 100644
--- a/src/components/policy/policy_external/include/policy/cache_manager.h
+++ b/src/components/policy/policy_external/include/policy/cache_manager.h
@@ -154,17 +154,25 @@ class CacheManager : public CacheManagerInterface {
*/
virtual bool SecondsBetweenRetries(std::vector<int>& seconds);
- /**
- * @brief Gets information about vehicle
- */
- virtual const VehicleInfo GetVehicleInfo() const;
-
const boost::optional<bool> LockScreenDismissalEnabledState() const OVERRIDE;
const boost::optional<std::string> LockScreenDismissalWarningMessage(
const std::string& language) const OVERRIDE;
/**
+ * @brief Gets vehicle data items
+ * @return Structure with vehicle data items
+ */
+ virtual const std::vector<policy_table::VehicleDataItem> GetVehicleDataItems()
+ const OVERRIDE;
+
+ /**
+ * @brief Gets copy of current policy table data
+ * @return policy_table as json object
+ */
+ virtual Json::Value GetPolicyTableData() const OVERRIDE;
+
+ /**
* @brief Get a list of enabled cloud applications
* @param enabled_apps List filled with the policy app id of each enabled
* cloud application
@@ -859,6 +867,14 @@ class CacheManager : public CacheManagerInterface {
void OnDeviceSwitching(const std::string& device_id_from,
const std::string& device_id_to) OVERRIDE;
+ /**
+ * @brief Method for separate standard vehicle data items from custom
+ * @param full vehicle data items during PTU
+ * @return array with only custom vehicle items
+ */
+ static policy_table::VehicleDataItems CollectCustomVDItems(
+ const policy_table::VehicleDataItems& vd_items);
+
private:
std::string currentDateTime();
struct AppHMITypeToString {
@@ -1043,6 +1059,24 @@ class CacheManager : public CacheManagerInterface {
void MergeCFM(const policy_table::PolicyTable& new_pt,
policy_table::PolicyTable& pt);
+ /**
+ * @brief MergeVD allows to merge VehicleDataItems section by
+ *definite rules.
+ *
+ * The rules are:
+ * 1. If vehicle_data_items key is not presented in the updated PolicyTable,
+ * update for VehicleDataItems should be ignored.
+ * 2. If vehicle_data_items presented in updated PolicyTable, the
+ * VehicleDataItems in the database (LocalPT) should be overwritten with
+ * updated data.
+ *
+ * @param new_pt the policy table loaded from updated preload JSON file.
+ *
+ * @param pt the exists database
+ */
+ void MergeVD(const policy_table::PolicyTable& new_pt,
+ policy_table::PolicyTable& pt);
+
void InitBackupThread();
/**
diff --git a/src/components/policy/policy_external/include/policy/cache_manager_interface.h b/src/components/policy/policy_external/include/policy/cache_manager_interface.h
index 4eb1f2167d..ff09ed608d 100644
--- a/src/components/policy/policy_external/include/policy/cache_manager_interface.h
+++ b/src/components/policy/policy_external/include/policy/cache_manager_interface.h
@@ -162,9 +162,17 @@ class CacheManagerInterface {
virtual bool SecondsBetweenRetries(std::vector<int>& seconds) = 0;
/**
- * @brief Get information about vehicle
+ * @brief Gets copy of current policy table data
+ * @return policy_table as json object
*/
- virtual const VehicleInfo GetVehicleInfo() const = 0;
+ virtual Json::Value GetPolicyTableData() const = 0;
+
+ /**
+ * @brief Gets vehicle data items
+ * @return Structure with vehicle data items
+ */
+ virtual const std::vector<policy_table::VehicleDataItem> GetVehicleDataItems()
+ const = 0;
/**
* @brief Get a list of enabled cloud applications
diff --git a/src/components/policy/policy_external/include/policy/policy_helper.h b/src/components/policy/policy_external/include/policy/policy_helper.h
index 0918f9e1c3..2054485ef5 100644
--- a/src/components/policy/policy_external/include/policy/policy_helper.h
+++ b/src/components/policy/policy_external/include/policy/policy_helper.h
@@ -129,6 +129,15 @@ struct CheckAppPolicy {
bool HasNewGroups(const AppPoliciesValueType& app_policy,
policy_table::Strings* new_groups = NULL) const;
/**
+ * @brief Checks whether updated application policy contains group content
+ * update in compare to current one
+ * @param app_policy Reference to updated application policy
+ * @param updated_groups List of updated groups if any
+ * @return True if updated groups found, otherwise - false
+ */
+ bool HasUpdatedGroups(const policy::AppPoliciesValueType& app_policy,
+ policy_table::Strings* updated_groups = NULL) const;
+ /**
* @brief Checks whether updated policy has groups which require user consent
* @param app_policy Reference to updated application policy
* @return True if has groups requiring user consents, otherwise - false
diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h
index 1524e949ef..497394886f 100644
--- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h
+++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h
@@ -639,10 +639,17 @@ class PolicyManagerImpl : public PolicyManager {
const std::string& policy_app_id) const OVERRIDE;
/**
- * @brief Get information about vehicle
- * @return vehicle information
+ * @brief Gets copy of current policy table data
+ * @return policy_table as json object
*/
- const VehicleInfo GetVehicleInfo() const OVERRIDE;
+ Json::Value GetPolicyTableData() const OVERRIDE;
+
+ /**
+ * @brief Gets vehicle data items
+ * @return Structure with vehicle data items
+ */
+ const std::vector<policy_table::VehicleDataItem> GetVehicleDataItems()
+ const OVERRIDE;
/**
* @brief Get a list of enabled cloud applications
diff --git a/src/components/policy/policy_external/include/policy/policy_table/enums.h b/src/components/policy/policy_external/include/policy/policy_table/enums.h
index d3aee9dcf8..a74eb1f886 100644
--- a/src/components/policy/policy_external/include/policy/policy_table/enums.h
+++ b/src/components/policy/policy_external/include/policy/policy_table/enums.h
@@ -35,133 +35,12 @@
#include <string>
+#include "generated_HMI_API_policy_types.h"
+#include "generated_MOBILE_API_policy_types.h"
+
namespace rpc {
namespace policy_table_interface_base {
-enum Priority {
- P_EMERGENCY,
- P_NAVIGATION,
- P_VOICECOM,
- P_COMMUNICATION,
- P_NORMAL,
- P_PROJECTION,
- P_NONE,
-};
-
-bool IsValidEnum(Priority val);
-const char* EnumToJsonString(Priority val);
-bool EnumFromJsonString(const std::string& literal, Priority* result);
-
-enum HmiLevel {
- HL_BACKGROUND,
- HL_FULL,
- HL_LIMITED,
- HL_NONE,
-};
-bool IsValidEnum(HmiLevel val);
-const char* EnumToJsonString(HmiLevel val);
-bool EnumFromJsonString(const std::string& literal, HmiLevel* result);
-
-enum Parameter {
- P_GPS,
- P_SPEED,
- P_ENGINETORQUE,
- P_EXTERNALTEMPERATURE,
- P_TURNSIGNAL,
- P_FUELLEVEL,
- P_FUELLEVEL_STATE,
- P_HEADLAMPSTATUS,
- P_INSTANTFUELCONSUMPTION,
- P_FUELRANGE,
- P_ODOMETER,
- P_TIREPRESSURE,
- P_WIPERSTATUS,
- P_VIN,
- P_ACCPEDALPOSITION,
- P_BELTSTATUS,
- P_ELECTRONICPARKBRAKESTATUS,
- P_DRIVERBRAKING,
- P_PRNDL,
- P_RPM,
- P_STEERINGWHEELANGLE,
- P_ENGINEOILLIFE,
- P_MYKEY,
- P_AIRBAGSTATUS,
- P_BODYINFORMATION,
- P_CLUSTERMODESTATUS,
- P_DEVICESTATUS,
- P_EMERGENCYEVENT,
- P_ECALLINFO,
- P_ABS_STATE,
- P_FUEL_RANGE,
- P_TIRE_PRESSURE_VALUE,
- P_TPMS,
- P_CLOUD_APP_VEHICLE_ID,
- P_LONGTITUDE_DEGREES,
- P_LATITUDE_DEGREES,
- P_LOCATION_NAME,
- P_LOCATION_DESCRIPTION,
- P_ADDRESS_LINES,
- P_PHONE_NUMBER,
- P_LOCATION_IMAGE,
- P_DELIVERY_MODE,
- P_TIMESTAMP,
- P_ADDRESS,
- P_EMPTY // Added to allow empty parameters handling
-};
-
-bool IsValidEnum(Parameter val);
-const char* EnumToJsonString(Parameter val);
-bool EnumFromJsonString(const std::string& literal, Parameter* result);
-
-enum AppHMIType {
- AHT_DEFAULT,
- AHT_COMMUNICATION,
- AHT_MEDIA,
- AHT_MESSAGING,
- AHT_NAVIGATION,
- AHT_INFORMATION,
- AHT_SOCIAL,
- AHT_BACKGROUND_PROCESS,
- AHT_TESTING,
- AHT_SYSTEM,
- AHT_PROJECTION,
- AHT_REMOTE_CONTROL,
-};
-bool IsValidEnum(AppHMIType val);
-const char* EnumToJsonString(AppHMIType val);
-bool EnumFromJsonString(const std::string& literal, AppHMIType* result);
-
-enum RequestType {
- RT_HTTP,
- RT_FILE_RESUME,
- RT_AUTH_REQUEST,
- RT_AUTH_CHALLENGE,
- RT_AUTH_ACK,
- RT_PROPRIETARY,
- RT_QUERY_APPS,
- RT_LAUNCH_APP,
- RT_LOCK_SCREEN_ICON_URL,
- RT_TRAFFIC_MESSAGE_CHANNEL,
- RT_DRIVER_PROFILE,
- RT_VOICE_SEARCH,
- RT_NAVIGATION,
- RT_PHONE,
- RT_CLIMATE,
- RT_SETTINGS,
- RT_VEHICLE_DIAGNOSTICS,
- RT_EMERGENCY,
- RT_MEDIA,
- RT_FOTA,
- RT_OEM_SPECIFIC,
- RT_ICON_URL,
- RT_EMPTY // Added to allow empty Request Types handling
-};
-
-bool IsValidEnum(RequestType val);
-const char* EnumToJsonString(RequestType val);
-bool EnumFromJsonString(const std::string& literal, RequestType* result);
-
enum Input {
I_GUI,
I_VUI,
@@ -170,461 +49,6 @@ bool IsValidEnum(Input val);
const char* EnumToJsonString(Input val);
bool EnumFromJsonString(const std::string& literal, Input* result);
-enum ModuleType {
- MT_CLIMATE,
- MT_RADIO,
- MT_SEAT,
- MT_AUDIO,
- MT_LIGHT,
- MT_HMI_SETTINGS,
- MT_EMPTY
-};
-bool IsValidEnum(ModuleType val);
-const char* EnumToJsonString(ModuleType val);
-bool EnumFromJsonString(const std::string& literal, ModuleType* result);
-
-enum HybridAppPreference { HAP_MOBILE, HAP_CLOUD, HAP_BOTH };
-bool IsValidEnum(HybridAppPreference val);
-const char* EnumToJsonString(HybridAppPreference val);
-bool EnumFromJsonString(const std::string& literal,
- HybridAppPreference* result);
-
-/**
- * @brief Enumeration FunctionID.
- *
- * Enumeration linking function names with function IDs in AppLink protocol.
- * Assumes enumeration starts at value 0.
- */
-enum FunctionID {
- /**
- * @brief RESERVED.
- */
- RESERVED = 0,
-
- /**
- * @brief RegisterAppInterfaceID.
- */
- RegisterAppInterfaceID = 1,
-
- /**
- * @brief UnregisterAppInterfaceID.
- */
- UnregisterAppInterfaceID = 2,
-
- /**
- * @brief SetGlobalPropertiesID.
- */
- SetGlobalPropertiesID = 3,
-
- /**
- * @brief ResetGlobalPropertiesID.
- */
- ResetGlobalPropertiesID = 4,
-
- /**
- * @brief AddCommandID.
- */
- AddCommandID = 5,
-
- /**
- * @brief DeleteCommandID.
- */
- DeleteCommandID = 6,
-
- /**
- * @brief AddSubMenuID.
- */
- AddSubMenuID = 7,
-
- /**
- * @brief DeleteSubMenuID.
- */
- DeleteSubMenuID = 8,
-
- /**
- * @brief CreateInteractionChoiceSetID.
- */
- CreateInteractionChoiceSetID = 9,
-
- /**
- * @brief PerformInteractionID.
- */
- PerformInteractionID = 10,
-
- /**
- * @brief DeleteInteractionChoiceSetID.
- */
- DeleteInteractionChoiceSetID = 11,
-
- /**
- * @brief AlertID.
- */
- AlertID = 12,
-
- /**
- * @brief ShowID.
- */
- ShowID = 13,
-
- /**
- * @brief SpeakID.
- */
- SpeakID = 14,
-
- /**
- * @brief SetMediaClockTimerID.
- */
- SetMediaClockTimerID = 15,
-
- /**
- * @brief PerformAudioPassThruID.
- */
- PerformAudioPassThruID = 16,
-
- /**
- * @brief EndAudioPassThruID.
- */
- EndAudioPassThruID = 17,
-
- /**
- * @brief SubscribeButtonID.
- */
- SubscribeButtonID = 18,
-
- /**
- * @brief UnsubscribeButtonID.
- */
- UnsubscribeButtonID = 19,
-
- /**
- * @brief SubscribeVehicleDataID.
- */
- SubscribeVehicleDataID = 20,
-
- /**
- * @brief UnsubscribeVehicleDataID.
- */
- UnsubscribeVehicleDataID = 21,
-
- /**
- * @brief GetVehicleDataID.
- */
- GetVehicleDataID = 22,
-
- /**
- * @brief ReadDIDID.
- */
- ReadDIDID = 23,
-
- /**
- * @brief GetDTCsID.
- */
- GetDTCsID = 24,
-
- /**
- * @brief ScrollableMessageID.
- */
- ScrollableMessageID = 25,
-
- /**
- * @brief SliderID.
- */
- SliderID = 26,
-
- /**
- * @brief ShowConstantTBTID.
- */
- ShowConstantTBTID = 27,
-
- /**
- * @brief AlertManeuverID.
- */
- AlertManeuverID = 28,
-
- /**
- * @brief UpdateTurnListID.
- */
- UpdateTurnListID = 29,
-
- /**
- * @brief ChangeRegistrationID.
- */
- ChangeRegistrationID = 30,
-
- /**
- * @brief GenericResponseID.
- */
- GenericResponseID = 31,
-
- /**
- * @brief PutFileID.
- */
- PutFileID = 32,
-
- /**
- * @brief DeleteFileID.
- */
- DeleteFileID = 33,
-
- /**
- * @brief ListFilesID.
- */
- ListFilesID = 34,
-
- /**
- * @brief SetAppIconID.
- */
- SetAppIconID = 35,
-
- /**
- * @brief SetDisplayLayoutID.
- */
- SetDisplayLayoutID = 36,
-
- /**
- * @brief DiagnosticMessageID.
- */
- DiagnosticMessageID = 37,
-
- /**
- * @brief SystemRequestID.
- */
- SystemRequestID = 38,
-
- /**
- * @brief SendLocationID.
- */
- SendLocationID = 39,
-
- /**
- * @brief DialNumberID.
- */
- DialNumberID = 40,
-
- /**
- * @brief ButtonPressID.
- */
- ButtonPressID = 41,
-
- /**
- * @brief GetInteriorVehicleDataID.
- */
- GetInteriorVehicleDataID = 43,
-
- /**
- * @brief SetInteriorVehicleDataID.
- */
- SetInteriorVehicleDataID = 44,
-
- /**
- * @brief GetWayPointsID.
- */
- GetWayPointsID = 45,
-
- /**
- * @brief SubscribeWayPointsID.
- */
- SubscribeWayPointsID = 46,
-
- /**
- * @brief UnsubscribeWayPointsID.
- */
- UnsubscribeWayPointsID = 47,
-
- /**
- * @brief GetSystemCapabilityID.
- */
- GetSystemCapabilityID = 48,
-
- /**
- * @brief SendHapticDataID.
- */
- SendHapticDataID = 49,
-
- /**
- * @brief SetCloudAppPropertiesID.
- */
- SetCloudAppPropertiesID = 50,
-
- /**
- * @brief GetCloudAppPropertiesID.
- */
- GetCloudAppPropertiesID = 51,
-
- /**
- * @brief PublishAppServiceID.
- */
- PublishAppServiceID = 52,
-
- /**
- * @brief GetAppServiceDataID.
- */
- GetAppServiceDataID = 53,
-
- /**
- * @brief GetFileID
- */
- GetFileID = 54,
-
- /**
- * @brief PerformAppServiceInteractionID.
- */
- PerformAppServiceInteractionID = 55,
-
- /**
- * @brief UnpublishAppServiceID.
- */
- UnpublishAppServiceID = 56,
-
- /**
- * @brief CancelInteractionID.
- */
- CancelInteractionID = 57,
-
- /**
- * @brief CloseApplicationID.
- */
- CloseApplicationID = 58,
-
- /**
- * @brief ShowAppMenuID.
- */
- ShowAppMenuID = 59,
-
- /**
- * @brief CreateWindowID.
- */
- CreateWindowID = 60,
-
- /**
- * @brief DeleteWindowID.
- */
- DeleteWindowID = 61,
-
- /**
- * @brief OnHMIStatusID.
- */
- OnHMIStatusID = 32768,
-
- /**
- * @brief OnAppInterfaceUnregisteredID.
- */
- OnAppInterfaceUnregisteredID = 32769,
-
- /**
- * @brief OnButtonEventID.
- */
- OnButtonEventID = 32770,
-
- /**
- * @brief OnButtonPressID.
- */
- OnButtonPressID = 32771,
-
- /**
- * @brief OnVehicleDataID.
- */
- OnVehicleDataID = 32772,
-
- /**
- * @brief OnCommandID.
- */
- OnCommandID = 32773,
-
- /**
- * @brief OnTBTClientStateID.
- */
- OnTBTClientStateID = 32774,
-
- /**
- * @brief OnDriverDistractionID.
- */
- OnDriverDistractionID = 32775,
-
- /**
- * @brief OnPermissionsChangeID.
- */
- OnPermissionsChangeID = 32776,
-
- /**
- * @brief OnAudioPassThruID.
- */
- OnAudioPassThruID = 32777,
-
- /**
- * @brief OnLanguageChangeID.
- */
- OnLanguageChangeID = 32778,
-
- /**
- * @brief OnKeyboardInputID.
- */
- OnKeyboardInputID = 32779,
-
- /**
- * @brief OnTouchEventID.
- */
- OnTouchEventID = 32780,
-
- /**
- * @brief OnSystemRequestID.
- */
- OnSystemRequestID = 32781,
-
- /**
- * @brief OnHashChangeID.
- */
- OnHashChangeID = 32782,
-
- /**
- * @brief OnInteriorVehicleDataID.
- */
- OnInteriorVehicleDataID = 32783,
-
- /**
- * @brief OnWayPointChangeID.
- */
- OnWayPointChangeID = 32784,
-
- /**
- * @brief OnRCStatusID.
- */
- OnRCStatusID = 32785,
-
- /**
- * @brief OnAppServiceDataID.
- */
- OnAppServiceDataID = 32786,
-
- /**
- * @brief OnSystemCapabilityUpdatedID
- */
- OnSystemCapabilityUpdatedID = 32787,
-
- /**
- * @brief EncodedSyncPDataID.
- */
- EncodedSyncPDataID = 65536,
-
- /**
- * @brief SyncPDataID.
- */
- SyncPDataID = 65537,
-
- /**
- * @brief OnEncodedSyncPDataID.
- */
- OnEncodedSyncPDataID = 98304,
-
- /**
- * @brief OnSyncPDataID.
- */
- OnSyncPDataID = 98305
-};
-bool IsValidEnum(FunctionID val);
-const char* EnumToJsonString(FunctionID val);
-bool EnumFromJsonString(const std::string& literal, FunctionID* result);
-
extern const std::string kDefaultApp;
extern const std::string kPreDataConsentApp;
extern const std::string kDeviceApp;
diff --git a/src/components/policy/policy_external/include/policy/policy_table/policy_enum_schema_factory.h b/src/components/policy/policy_external/include/policy/policy_table/policy_enum_schema_factory.h
new file mode 100644
index 0000000000..4871179342
--- /dev/null
+++ b/src/components/policy/policy_external/include/policy/policy_table/policy_enum_schema_factory.h
@@ -0,0 +1,62 @@
+/**
+ * Copyright (c) 2017, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_POLICY_TABLE_POLICY_ENUM_SCHEMA_FACTORY_H
+#define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_POLICY_TABLE_POLICY_ENUM_SCHEMA_FACTORY_H
+
+#include <memory>
+#include <string>
+
+#include "smart_objects/smart_schema.h"
+
+namespace rpc {
+namespace policy_table_interface_base {
+
+class EnumSchemaItemFactory {
+ public:
+ /**
+ * @brief Get enum schema from enum name
+ * Implementation of this function should be generated from MOBILE_API.xml
+ * @param enum_name enum name to get schema factory for
+ * @return shared pointer to schema factory or empty shared pointer if
+ * enum_name is wrong
+ */
+ static std::shared_ptr<ns_smart_device_link::ns_smart_objects::ISchemaItem>
+ Get(const std::string& enum_name);
+
+ static bool IsRPCSpecVehicleDataType(const std::string& vd_name);
+};
+
+} // namespace policy_table_interface_base
+} // namespace rpc
+
+#endif // SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_POLICY_TABLE_POLICY_ENUM_SCHEMA_FACTORY_H
diff --git a/src/components/policy/policy_external/include/policy/policy_table/types.h b/src/components/policy/policy_external/include/policy/policy_table/types.h
index 7f59c17384..11c76bdd68 100644
--- a/src/components/policy/policy_external/include/policy/policy_table/types.h
+++ b/src/components/policy/policy_external/include/policy/policy_table/types.h
@@ -37,7 +37,9 @@
#include "utils/macro.h"
#include "policy/policy_table/enums.h"
+#include "policy/policy_table/policy_enum_schema_factory.h"
#include "rpc_base/rpc_message.h"
+#include "utils/helpers.h"
namespace Json {
class Value;
@@ -48,6 +50,7 @@ struct AppLevel;
struct ApplicationParams;
struct ConsentRecords;
struct DeviceParams;
+struct EndpointProperty;
struct MessageLanguages;
struct MessageString;
struct RpcParameters;
@@ -69,16 +72,18 @@ typedef Array<Enum<AppHMIType>, 0, 255> AppHMITypes;
typedef Array<Enum<HmiLevel>, 0, 4> HmiLevels;
-typedef Array<Enum<Parameter>, 0, 100> Parameters;
+typedef Array<String<0, 255>, 0, 100> Parameters;
typedef Map<RpcParameters, 0, UINT_MAX> Rpc;
-typedef Array<String<10, 255>, 1, 3> URL;
+typedef Array<String<10, INT_MAX>, 1, 3> URL;
typedef Map<URL, 1, 255> URLList;
typedef Map<URLList, 1, 255> ServiceEndpoints;
+typedef Map<EndpointProperty, 0, 255> ServiceEndpointProperties;
+
typedef uint8_t NumberOfNotificationsType;
typedef Map<Integer<NumberOfNotificationsType, 0, 255>, 0, 7>
NumberOfNotificationsPerMinute;
@@ -349,6 +354,24 @@ struct Rpcs : CompositeType {
bool Validate() const;
};
+struct EndpointProperty : CompositeType {
+ public:
+ Optional<String<0, 100> > version;
+
+ EndpointProperty();
+ ~EndpointProperty();
+ explicit EndpointProperty(const Json::Value* value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport* report__) const;
+ void SetPolicyTableType(PolicyTableType pt_type) OVERRIDE;
+
+ private:
+ bool Validate() const;
+};
+
struct ModuleConfig : CompositeType {
public:
Integer<uint8_t, 0, 255> exchange_after_x_ignition_cycles;
@@ -357,6 +380,7 @@ struct ModuleConfig : CompositeType {
Integer<uint16_t, 0, 65535> timeout_after_x_seconds;
SecondsBetweenRetries seconds_between_retries;
ServiceEndpoints endpoints;
+ Optional<ServiceEndpointProperties> endpoint_properties;
NumberOfNotificationsPerMinute notifications_per_minute_by_priority;
Optional<String<0, 100> > vehicle_make;
Optional<String<0, 100> > vehicle_model;
@@ -367,6 +391,8 @@ struct ModuleConfig : CompositeType {
Optional<Boolean> full_app_id_supported;
Optional<Boolean> lock_screen_dismissal_enabled;
+ static const std::string kDefaultOemMappingServiceName;
+
public:
ModuleConfig();
ModuleConfig(uint8_t exchange_after_x_ignition_cycles,
@@ -375,6 +401,7 @@ struct ModuleConfig : CompositeType {
uint16_t timeout_after_x_seconds,
const SecondsBetweenRetries& seconds_between_retries,
const ServiceEndpoints& endpoints,
+ const ServiceEndpointProperties& endpoint_properties,
const NumberOfNotificationsPerMinute&
notifications_per_minute_by_priority);
~ModuleConfig();
@@ -601,6 +628,88 @@ struct DeviceParams : CompositeType {
bool Validate() const;
};
+struct VehicleDataItem : CompositeType {
+ public:
+ static const std::vector<std::string> kPODTypes;
+
+ static const std::string kInteger;
+ static const std::string kStruct;
+ static const std::string kString;
+ static const std::string kFloat;
+ static const std::string kDouble;
+ static const std::string kBoolean;
+ static const std::string kName;
+ static const std::string kParams;
+
+ String<1, 255> name;
+ String<0, 255> type;
+ String<1, 255> key;
+ Boolean mandatory;
+ Optional<Array<VehicleDataItem, 0, 255> > params;
+
+ Optional<Boolean> array;
+ Optional<String<0, 255> > since;
+ Optional<String<0, 255> > until;
+ Optional<Boolean> removed;
+ Optional<Boolean> deprecated;
+ Optional<Float<-INT32_MAX, INT32_MAX> > minvalue;
+ Optional<Float<-INT32_MAX, INT32_MAX> > maxvalue;
+ Optional<Integer<uint32_t, 0, UINT32_MAX> > minsize;
+ Optional<Integer<uint32_t, 0, UINT32_MAX> > maxsize;
+ Optional<Integer<uint32_t, 0, UINT32_MAX> > minlength;
+ Optional<Integer<uint32_t, 0, UINT_MAX> > maxlength;
+
+ VehicleDataItem();
+ VehicleDataItem(const VehicleDataItem& policy_table);
+ explicit VehicleDataItem(const Json::Value* value__);
+
+ bool operator==(const VehicleDataItem& vd);
+
+ ~VehicleDataItem();
+
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_not_empty() const;
+ void ReportErrors(rpc::ValidationReport* report__) const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+
+ /**
+ * @brief Validates type of vehicle data item according to
+ * POD types and generated from API enums.
+ * @return true if type is valid.
+ */
+ bool ValidateTypes() const;
+ bool IsPrimitiveType() const;
+ bool ValidateNaming(std::string str) const;
+
+ private:
+ bool Validate() const;
+};
+
+typedef Array<VehicleDataItem, 0, 255> VehicleDataItems;
+
+struct VehicleData : CompositeType {
+ public:
+ Optional<String<0, 100> > schema_version;
+ Optional<VehicleDataItems> schema_items;
+
+ VehicleData();
+ VehicleData(const VehicleData& vehicle_data);
+ VehicleData(const Json::Value* value__);
+ ~VehicleData();
+
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport* report__) const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+
+ private:
+ bool Validate() const;
+};
+
struct PolicyTable : CompositeType {
public:
ApplicationPoliciesSection app_policies_section;
@@ -610,6 +719,7 @@ struct PolicyTable : CompositeType {
Optional<ModuleMeta> module_meta;
Optional<UsageAndErrorCounts> usage_and_error_counts;
Optional<DeviceData> device_data;
+ Optional<VehicleData> vehicle_data;
public:
PolicyTable();
diff --git a/src/components/policy/policy_external/include/policy/policy_types.h b/src/components/policy/policy_external/include/policy/policy_types.h
index fe63ae3479..ee2d806ba5 100644
--- a/src/components/policy/policy_external/include/policy/policy_types.h
+++ b/src/components/policy/policy_external/include/policy/policy_types.h
@@ -511,7 +511,7 @@ enum PermissionsCheckResult {
RESULT_NICKNAME_MISMATCH,
RESULT_PERMISSIONS_REVOKED,
RESULT_CONSENT_NEEDED,
- RESULT_CONSENT_NOT_REQIURED,
+ RESULT_CONSENT_NOT_REQUIRED,
RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED,
RESULT_REQUEST_TYPE_CHANGED,
RESULT_REQUEST_SUBTYPE_CHANGED,
diff --git a/src/components/policy/policy_external/include/policy/pt_representation.h b/src/components/policy/policy_external/include/policy/pt_representation.h
index 6eaa718cf0..d233bbf268 100644
--- a/src/components/policy/policy_external/include/policy/pt_representation.h
+++ b/src/components/policy/policy_external/include/policy/pt_representation.h
@@ -134,11 +134,6 @@ class PTRepresentation {
virtual bool SecondsBetweenRetries(std::vector<int>* seconds) = 0;
/**
- * @brief Get information about vehicle
- */
- virtual const VehicleInfo GetVehicleInfo() const = 0;
-
- /**
* @brief Allows to update 'vin' field in module_meta table.
*
* @param new 'vin' value.
diff --git a/src/components/policy/policy_external/include/policy/sql_pt_queries.h b/src/components/policy/policy_external/include/policy/sql_pt_queries.h
index 5382ff2d6b..c613cec0d6 100644
--- a/src/components/policy/policy_external/include/policy/sql_pt_queries.h
+++ b/src/components/policy/policy_external/include/policy/sql_pt_queries.h
@@ -142,6 +142,21 @@ extern const std::string kDeleteModuleTypes;
extern const std::string kDeleteAllDevices;
extern const std::string kSelectDBVersion;
extern const std::string kUpdateDBVersion;
+extern const std::string kSelectVehicleDataItem;
+extern const std::string kInsertVehicleDataItem;
+extern const std::string kDeleteVehicleDataItems;
+extern const std::string kInsertVehicleDataItemParams;
+extern const std::string kSelectVehicleDataItemParams;
+extern const std::string kDeleteVehicleDataItemParams;
+extern const std::string kSelectVehicleDataItemWithVersion;
+extern const std::string kSelectPrimitiveVehicleDataItems;
+extern const std::string kSelectCompositeVehicleDataItemsKey;
+extern const std::string kSelectOEMMappingVersion;
+extern const std::string kSelectVehicleDataSchemaVersion;
+extern const std::string kInsertVehicleDataSchemaVersion;
+extern const std::string kSelectEndpointProperties;
+extern const std::string kInsertEndpointVersion;
+
} // namespace sql_pt
} // namespace policy
diff --git a/src/components/policy/policy_external/include/policy/sql_pt_representation.h b/src/components/policy/policy_external/include/policy/sql_pt_representation.h
index 826c9b3b6e..5d2d63a8bd 100644
--- a/src/components/policy/policy_external/include/policy/sql_pt_representation.h
+++ b/src/components/policy/policy_external/include/policy/sql_pt_representation.h
@@ -44,6 +44,7 @@ namespace policy_table = rpc::policy_table_interface_base;
namespace utils {
namespace dbms {
class SQLDatabase;
+class SQLQuery;
} // namespace dbms
} // namespace utils
@@ -70,8 +71,6 @@ class SQLPTRepresentation : public virtual PTRepresentation {
virtual int TimeoutResponse();
virtual bool SecondsBetweenRetries(std::vector<int>* seconds);
virtual bool RefreshDB();
- virtual const VehicleInfo GetVehicleInfo() const;
-
virtual std::vector<UserFriendlyMessage> GetUserFriendlyMsg(
const std::vector<std::string>& msg_codes, const std::string& language);
@@ -124,6 +123,9 @@ class SQLPTRepresentation : public virtual PTRepresentation {
policy_table::ConsumerFriendlyMessages* messages) const;
virtual bool GatherApplicationPoliciesSection(
policy_table::ApplicationPoliciesSection* policies) const;
+ virtual bool GatherVehicleDataItems(
+ policy_table::VehicleDataItems* vehicle_data_items) const;
+ virtual bool GatherVehicleData(policy_table::VehicleData* vehicle_data) const;
bool GatherAppGroup(const std::string& app_id,
policy_table::Strings* app_groups) const;
@@ -159,6 +161,9 @@ class SQLPTRepresentation : public virtual PTRepresentation {
virtual bool SaveSpecificAppPolicy(
const policy_table::ApplicationPolicies::value_type& app);
virtual bool SaveDevicePolicy(const policy_table::DevicePolicy& device);
+ virtual bool SaveVehicleDataItems(
+ const policy_table::VehicleDataItems& vehicle_data_items);
+ virtual bool SaveVehicleData(const policy_table::VehicleData& vehicle_data);
virtual bool SaveMessageString(const std::string& type,
const std::string& lang,
@@ -203,6 +208,26 @@ class SQLPTRepresentation : public virtual PTRepresentation {
virtual bool IsDBVersionActual() const OVERRIDE;
virtual bool UpdateDBVersion() const OVERRIDE;
+ policy_table::VehicleDataItems GetVehicleDataItem(
+ const std::string& name, const std::string& key) const;
+ bool InsertVehicleDataItem(
+ const policy_table::VehicleDataItem& vehicle_data_item);
+ bool VehicleDataItemExists(
+ const policy_table::VehicleDataItem& vehicle_data_item) const;
+
+ /**
+ * @brief Retrieves vehicle data items of type Struct (which contains params)
+ * from the database including these parameters.
+ * @return Array of parameterized VehicleDataItems (including params)
+ */
+ policy_table::VehicleDataItems SelectCompositeVehicleDataItems() const;
+
+ /**
+ * @brief Retrieves vehicle data items of non Struct type from the database.
+ * @return Array of primitive VehicleDataItems
+ */
+ policy_table::VehicleDataItems SelectPrimitiveVehicleDataItems() const;
+
private:
utils::dbms::SQLDatabase* db_;
@@ -220,12 +245,17 @@ class SQLPTRepresentation : public virtual PTRepresentation {
const int32_t GetDBVersion() const;
bool SaveRpcs(int64_t group_id, const policy_table::Rpc& rpcs);
bool SaveServiceEndpoints(const policy_table::ServiceEndpoints& endpoints);
+ bool SaveServiceEndpointProperties(
+ const policy_table::ServiceEndpointProperties& endpoint_properties);
bool SaveSecondsBetweenRetries(
const policy_table::SecondsBetweenRetries& seconds);
bool SaveNumberOfNotificationsPerMinute(
const policy_table::NumberOfNotificationsPerMinute& notifications);
bool SaveMessageType(const std::string& type);
bool SaveLanguage(const std::string& code);
+ policy_table::VehicleDataItem PopulateVDIFromQuery(
+ const utils::dbms::SQLQuery& query) const;
+ bool DeleteVehicleDataItems() const;
bool is_in_memory;
bool SaveExternalConsentEntities(
diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc
index 965b91c9f4..3e1538ab04 100644
--- a/src/components/policy/policy_external/src/cache_manager.cc
+++ b/src/components/policy/policy_external/src/cache_manager.cc
@@ -33,6 +33,7 @@
#include "policy/cache_manager.h"
#include <algorithm>
+#include <boost/algorithm/string.hpp>
#include <cmath>
#include <ctime>
#include <functional>
@@ -752,6 +753,26 @@ bool CacheManager::ApplyUpdate(const policy_table::Table& update_pt) {
pt_->policy_table.consumer_friendly_messages.assign_if_valid(
update_pt.policy_table.consumer_friendly_messages);
+ pt_->policy_table.module_config.endpoint_properties =
+ update_pt.policy_table.module_config.endpoint_properties;
+
+ // Apply update for vehicle data
+ if (update_pt.policy_table.vehicle_data.is_initialized()) {
+ if (!update_pt.policy_table.vehicle_data->schema_items.is_initialized() ||
+ update_pt.policy_table.vehicle_data->schema_items->empty()) {
+ pt_->policy_table.vehicle_data->schema_items =
+ rpc::Optional<policy_table::VehicleDataItems>();
+ } else {
+ policy_table::VehicleDataItems custom_items = CollectCustomVDItems(
+ *update_pt.policy_table.vehicle_data->schema_items);
+
+ pt_->policy_table.vehicle_data->schema_version =
+ update_pt.policy_table.vehicle_data->schema_version;
+ pt_->policy_table.vehicle_data->schema_items =
+ rpc::Optional<policy_table::VehicleDataItems>(custom_items);
+ }
+ }
+
ResetCalculatedPermissions();
Backup();
@@ -762,6 +783,21 @@ bool CacheManager::ApplyUpdate(const policy_table::Table& update_pt) {
return true;
}
+policy_table::VehicleDataItems CacheManager::CollectCustomVDItems(
+ const policy_table::VehicleDataItems& vd_items) {
+ policy_table::VehicleDataItems result_items;
+ for (auto& item : vd_items) {
+ const std::string i_name = "VEHICLEDATA_" + std::string(item.name);
+ const std::string vd_name = boost::to_upper_copy<std::string>(i_name);
+ const bool is_standard =
+ policy_table::EnumSchemaItemFactory::IsRPCSpecVehicleDataType(vd_name);
+ if (!is_standard) {
+ result_items.push_back(item);
+ }
+ }
+ return result_items;
+}
+
void CacheManager::GetHMIAppTypeAfterUpdate(
std::map<std::string, StringArray>& app_hmi_types) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -1231,14 +1267,8 @@ void CacheManager::CheckPermissions(const PTString& app_id,
if (rpc_param.hmi_levels.end() != hmi_iter) {
result.hmi_level_permitted = PermitResult::kRpcAllowed;
- policy_table::Parameters::const_iterator params_iter =
- rpc_param.parameters->begin();
- policy_table::Parameters::const_iterator params_iter_end =
- rpc_param.parameters->end();
-
- for (; params_iter != params_iter_end; ++params_iter) {
- result.list_of_allowed_params.insert(
- policy_table::EnumToJsonString(*params_iter));
+ for (const auto& param : *rpc_param.parameters) {
+ result.list_of_allowed_params.insert(std::string(param));
}
}
}
@@ -1387,20 +1417,21 @@ bool CacheManager::SecondsBetweenRetries(std::vector<int>& seconds) {
return true;
}
-const policy::VehicleInfo CacheManager::GetVehicleInfo() const {
- CACHE_MANAGER_CHECK(VehicleInfo());
+const std::vector<policy_table::VehicleDataItem>
+CacheManager::GetVehicleDataItems() const {
+ CACHE_MANAGER_CHECK(std::vector<policy_table::VehicleDataItem>());
sync_primitives::AutoLock auto_lock(cache_lock_);
- policy_table::ModuleConfig& module_config = pt_->policy_table.module_config;
- VehicleInfo vehicle_info;
- vehicle_info.vehicle_make = *module_config.vehicle_make;
- vehicle_info.vehicle_model = *module_config.vehicle_model;
- vehicle_info.vehicle_year = *module_config.vehicle_year;
- LOG4CXX_DEBUG(
- logger_,
- "Vehicle info (make, model, year):" << vehicle_info.vehicle_make << ","
- << vehicle_info.vehicle_model << ","
- << vehicle_info.vehicle_year);
- return vehicle_info;
+
+ if (pt_->policy_table.vehicle_data.is_initialized() &&
+ pt_->policy_table.vehicle_data->schema_items.is_initialized()) {
+ return *(pt_->policy_table.vehicle_data->schema_items);
+ }
+
+ return std::vector<policy_table::VehicleDataItem>();
+}
+
+Json::Value CacheManager::GetPolicyTableData() const {
+ return pt_->policy_table.ToJsonValue();
}
void CacheManager::GetEnabledCloudApps(
@@ -1669,11 +1700,19 @@ std::vector<UserFriendlyMessage> CacheManager::GetUserFriendlyMsg(
void CacheManager::GetUpdateUrls(const uint32_t service_type,
EndpointUrls& out_end_points) {
- std::stringstream service_type_stream;
- service_type_stream << (service_type <= 9 ? "0x0" : "0x") << service_type;
-
- const std::string service_type_str = service_type_stream.str();
- GetUpdateUrls(service_type_str, out_end_points);
+ auto find_hexademical =
+ [service_type](policy_table::ServiceEndpoints::value_type end_point) {
+ uint32_t decimal;
+ std::istringstream(end_point.first) >> std::hex >> decimal;
+ return end_point.first.compare(0, 2, "0x") == 0 &&
+ decimal == service_type;
+ };
+ auto& end_points = pt_->policy_table.module_config.endpoints;
+ const auto end_point =
+ std::find_if(end_points.begin(), end_points.end(), find_hexademical);
+ if (end_point != end_points.end()) {
+ GetUpdateUrls(end_point->first, out_end_points);
+ }
}
void CacheManager::GetUpdateUrls(const std::string& service_type,
@@ -2014,6 +2053,14 @@ std::shared_ptr<policy_table::Table> CacheManager::GenerateSnapshot() {
sync_primitives::AutoLock auto_lock(cache_lock_);
snapshot_->policy_table = pt_->policy_table;
+ if (pt_->policy_table.vehicle_data.is_initialized()) {
+ snapshot_->policy_table.vehicle_data =
+ rpc::Optional<policy_table::VehicleData>();
+ snapshot_->policy_table.vehicle_data->mark_initialized();
+ snapshot_->policy_table.vehicle_data->schema_version =
+ pt_->policy_table.vehicle_data->schema_version;
+ }
+
snapshot_->SetPolicyTableType(policy_table::PT_SNAPSHOT);
CheckSnapshotInitialization();
@@ -2531,6 +2578,8 @@ bool CacheManager::Init(const std::string& file_name,
} else {
rpc::ValidationReport report("policy_table");
snapshot->ReportErrors(&report);
+ LOG4CXX_DEBUG(logger_,
+ "Validation report: " << rpc::PrettyFormat(report));
ex_backup_->RemoveDB();
}
} break;
@@ -2595,7 +2644,6 @@ bool CacheManager::LoadFromFile(const std::string& file_name,
LOG4CXX_FATAL(logger_, "Failed to read policy table source file.");
return false;
}
-
Json::Value value;
Json::Reader reader(Json::Features::strictMode());
std::string json(json_string.begin(), json_string.end());
@@ -2934,6 +2982,7 @@ bool CacheManager::MergePreloadPT(const std::string& file_name) {
MergeFG(new_table, current);
MergeAP(new_table, current);
MergeCFM(new_table, current);
+ MergeVD(new_table, current);
Backup();
}
return true;
@@ -3001,6 +3050,12 @@ void CacheManager::MergeCFM(const policy_table::PolicyTable& new_pt,
}
}
+void CacheManager::MergeVD(const policy_table::PolicyTable& new_pt,
+ policy_table::PolicyTable& pt) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ pt.vehicle_data.assign_if_valid(new_pt.vehicle_data);
+}
+
void CacheManager::InitBackupThread() {
LOG4CXX_AUTO_TRACE(logger_);
backuper_ = new BackgroundBackuper(this);
diff --git a/src/components/policy/policy_external/src/policy_helper.cc b/src/components/policy/policy_external/src/policy_helper.cc
index bb0a36df68..99e4450065 100644
--- a/src/components/policy/policy_external/src/policy_helper.cc
+++ b/src/components/policy/policy_external/src/policy_helper.cc
@@ -46,7 +46,8 @@ namespace {
CREATE_LOGGERPTR_GLOBAL(logger_, "Policy")
-bool Compare(const StringsValueType& first, const StringsValueType& second) {
+bool CompareStrings(const StringsValueType& first,
+ const StringsValueType& second) {
const std::string& first_str = first;
const std::string& second_str = second;
return (strcasecmp(first_str.c_str(), second_str.c_str()) < 0);
@@ -137,10 +138,10 @@ bool policy::CheckAppPolicy::HasRevokedGroups(
snapshot_->policy_table.app_policies_section.apps.find(app_policy.first);
policy_table::Strings groups_new = app_policy.second.groups;
- std::sort(groups_new.begin(), groups_new.end(), Compare);
+ std::sort(groups_new.begin(), groups_new.end(), CompareStrings);
policy_table::Strings groups_curr = (*it).second.groups;
- std::sort(groups_curr.begin(), groups_curr.end(), Compare);
+ std::sort(groups_curr.begin(), groups_curr.end(), CompareStrings);
StringsConstItr it_groups_new = groups_new.begin();
StringsConstItr it_groups_new_end = groups_new.end();
@@ -154,7 +155,7 @@ bool policy::CheckAppPolicy::HasRevokedGroups(
it_groups_new,
it_groups_new_end,
std::back_inserter(revoked_group_list),
- Compare);
+ CompareStrings);
// Remove groups which are not required user consent
policy_table::Strings::iterator it_revoked = revoked_group_list.begin();
@@ -174,6 +175,76 @@ bool policy::CheckAppPolicy::HasRevokedGroups(
return !revoked_group_list.empty();
}
+bool policy::CheckAppPolicy::HasUpdatedGroups(
+ const policy::AppPoliciesValueType& app_policy,
+ policy_table::Strings* updated_groups) const {
+ AppPoliciesConstItr it =
+ snapshot_->policy_table.app_policies_section.apps.find(app_policy.first);
+
+ policy_table::Strings groups_new = app_policy.second.groups;
+ std::sort(groups_new.begin(), groups_new.end(), CompareStrings);
+
+ policy_table::Strings groups_curr = (*it).second.groups;
+ std::sort(groups_curr.begin(), groups_curr.end(), CompareStrings);
+
+ policy_table::Strings intersection_list;
+ std::set_intersection(groups_new.begin(),
+ groups_new.end(),
+ groups_curr.begin(),
+ groups_curr.end(),
+ std::back_inserter(intersection_list));
+
+ auto IsGroupContentUpdated =
+ [this](const StringsValueType& groupName) -> bool {
+ const auto& func_group_from_update =
+ update_->policy_table.functional_groupings.find(groupName);
+ const auto& func_group_from_snapshot =
+ snapshot_->policy_table.functional_groupings.find(groupName);
+
+ const auto& update_fg_rpcs = func_group_from_update->second.rpcs;
+ const auto& snapshot_fg_rpcs = func_group_from_snapshot->second.rpcs;
+
+ if (update_fg_rpcs.is_null() || snapshot_fg_rpcs.is_null()) {
+ return !(update_fg_rpcs.is_null() && snapshot_fg_rpcs.is_null());
+ }
+
+ if (update_fg_rpcs.size() != snapshot_fg_rpcs.size()) {
+ return true;
+ }
+
+ for (const auto& rpc : update_fg_rpcs) {
+ const auto& old_rpc = snapshot_fg_rpcs.find(rpc.first);
+ if (snapshot_fg_rpcs.end() == old_rpc) {
+ return true;
+ }
+
+ const bool hmi_levels_same =
+ old_rpc->second.hmi_levels == rpc.second.hmi_levels;
+ const bool parameters_same =
+ *(old_rpc->second.parameters) == *(rpc.second.parameters);
+
+ if (!hmi_levels_same || !parameters_same) {
+ return true;
+ }
+ }
+
+ return false;
+ };
+
+ policy_table::Strings updated_group_list;
+ for (const auto& item : intersection_list) {
+ if (IsGroupContentUpdated(item)) {
+ updated_group_list.push_back(item);
+ }
+ }
+
+ if (updated_groups) {
+ *updated_groups = updated_group_list;
+ }
+
+ return !updated_group_list.empty();
+}
+
bool policy::CheckAppPolicy::HasNewGroups(
const policy::AppPoliciesValueType& app_policy,
policy_table::Strings* new_groups) const {
@@ -181,10 +252,10 @@ bool policy::CheckAppPolicy::HasNewGroups(
snapshot_->policy_table.app_policies_section.apps.find(app_policy.first);
policy_table::Strings groups_new = app_policy.second.groups;
- std::sort(groups_new.begin(), groups_new.end(), Compare);
+ std::sort(groups_new.begin(), groups_new.end(), CompareStrings);
policy_table::Strings groups_curr = (*it).second.groups;
- std::sort(groups_curr.begin(), groups_curr.end(), Compare);
+ std::sort(groups_curr.begin(), groups_curr.end(), CompareStrings);
StringsConstItr it_groups_new = groups_new.begin();
StringsConstItr it_groups_new_end = groups_new.end();
@@ -192,13 +263,55 @@ bool policy::CheckAppPolicy::HasNewGroups(
StringsConstItr it_groups_curr = groups_curr.begin();
StringsConstItr it_groups_curr_end = groups_curr.end();
+ auto CompareGroupContent =
+ [this](const StringsValueType& update_group_name,
+ const StringsValueType& snapshot_group_name) -> bool {
+ if (CompareStrings(update_group_name, snapshot_group_name)) {
+ return true;
+ }
+
+ const auto& func_group_from_update =
+ update_->policy_table.functional_groupings.find(update_group_name);
+ const auto& func_group_from_snapshot =
+ snapshot_->policy_table.functional_groupings.find(snapshot_group_name);
+
+ const auto& update_fg_rpcs = func_group_from_update->second.rpcs;
+ const auto& snapshot_fg_rpcs = func_group_from_snapshot->second.rpcs;
+
+ if (update_fg_rpcs.is_null() || snapshot_fg_rpcs.is_null()) {
+ return !(update_fg_rpcs.is_null() && snapshot_fg_rpcs.is_null());
+ }
+
+ if (update_fg_rpcs.size() != snapshot_fg_rpcs.size()) {
+ return true;
+ }
+
+ for (const auto& rpc : update_fg_rpcs) {
+ const auto& old_rpc = snapshot_fg_rpcs.find(rpc.first);
+ if (snapshot_fg_rpcs.end() == old_rpc) {
+ return true;
+ }
+
+ const bool hmi_levels_same =
+ old_rpc->second.hmi_levels == rpc.second.hmi_levels;
+ const bool parameters_same =
+ *(old_rpc->second.parameters) == *(rpc.second.parameters);
+
+ if (!hmi_levels_same || !parameters_same) {
+ return true;
+ }
+ }
+
+ return false;
+ };
+
policy_table::Strings new_group_list;
std::set_difference(it_groups_new,
it_groups_new_end,
it_groups_curr,
it_groups_curr_end,
std::back_inserter(new_group_list),
- Compare);
+ CompareGroupContent);
if (new_groups) {
*new_groups = new_group_list;
@@ -210,14 +323,23 @@ bool policy::CheckAppPolicy::HasNewGroups(
bool policy::CheckAppPolicy::HasConsentNeededGroups(
const policy::AppPoliciesValueType& app_policy) const {
policy_table::Strings new_groups;
- if (!HasNewGroups(app_policy, &new_groups)) {
+ policy_table::Strings updated_groups;
+ if (!HasNewGroups(app_policy, &new_groups) &&
+ !HasUpdatedGroups(app_policy, &updated_groups)) {
return false;
}
- StringsConstItr it_new = new_groups.begin();
- StringsConstItr it_new_end = new_groups.end();
- for (; it_new != it_new_end; ++it_new) {
- if (IsConsentRequired(app_policy.first, *it_new)) {
+ policy_table::Strings groups_to_check_consent;
+ std::set_union(new_groups.begin(),
+ new_groups.end(),
+ updated_groups.begin(),
+ updated_groups.end(),
+ std::back_inserter(groups_to_check_consent));
+
+ StringsConstItr it = groups_to_check_consent.begin();
+ StringsConstItr it_end = groups_to_check_consent.end();
+ for (; it != it_end; ++it) {
+ if (IsConsentRequired(app_policy.first, *it)) {
return true;
}
}
@@ -454,14 +576,16 @@ PermissionsCheckResult CheckAppPolicy::CheckPermissionsChanges(
const bool encryption_required_flag_changed =
IsEncryptionRequiredFlagChanged(app_policy);
+ bool has_updated_groups = HasUpdatedGroups(app_policy);
+
if (has_revoked_groups && has_consent_needed_groups) {
return RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED;
} else if (has_revoked_groups) {
return RESULT_PERMISSIONS_REVOKED;
} else if (has_consent_needed_groups) {
return RESULT_CONSENT_NEEDED;
- } else if (has_new_groups) {
- return RESULT_CONSENT_NOT_REQIURED;
+ } else if (has_new_groups || has_updated_groups) {
+ return RESULT_CONSENT_NOT_REQUIRED;
} else if (encryption_required_flag_changed) {
return RESULT_ENCRYPTION_REQUIRED_FLAG_CHANGED;
}
@@ -654,7 +778,7 @@ void FillActionsForAppPolicies::operator()(
case RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED:
actions_[app_id].is_consent_needed = true;
break;
- case RESULT_CONSENT_NOT_REQIURED:
+ case RESULT_CONSENT_NOT_REQUIRED:
case RESULT_PERMISSIONS_REVOKED:
case RESULT_REQUEST_TYPE_CHANGED:
case RESULT_REQUEST_SUBTYPE_CHANGED:
@@ -762,8 +886,7 @@ void FillNotificationData::UpdateParameters(
}
for (; it_parameters != it_parameters_end; ++it_parameters) {
- out_parameter[current_key_].insert(
- policy_table::EnumToJsonString(*it_parameters));
+ out_parameter[current_key_].insert(*it_parameters);
}
// We should reset ALL DISALLOWED flags if at least one parameter is allowed
diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc
index 0629fea022..92be87a9fc 100644
--- a/src/components/policy/policy_external/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_external/src/policy_manager_impl.cc
@@ -302,7 +302,9 @@ void FilterInvalidFunctions(policy_table::Rpc& rpcs) {
* schema
* @param rpc_parameters parameters to filter
*/
-void FilterInvalidRPCParameters(policy_table::RpcParameters& rpc_parameters) {
+void FilterInvalidRPCParameters(
+ policy_table::RpcParameters& rpc_parameters,
+ const std::vector<policy_table::VehicleDataItem>& vehicle_data_items) {
policy_table::HmiLevels valid_hmi_levels;
for (const auto& hmi_level : rpc_parameters.hmi_levels) {
if (hmi_level.is_valid()) {
@@ -311,10 +313,31 @@ void FilterInvalidRPCParameters(policy_table::RpcParameters& rpc_parameters) {
}
rpc_parameters.hmi_levels.swap(valid_hmi_levels);
+ auto ParamExists =
+ [&vehicle_data_items](const rpc::String<0, 255>& param_name) {
+ policy_table::Parameter parameter_enum;
+ if (policy_table::EnumFromJsonString(param_name, &parameter_enum)) {
+ return true;
+ }
+
+ // In case when this collection is empty that means collection is not
+ // initialized
+ if (vehicle_data_items.empty()) {
+ return false;
+ }
+
+ for (const auto& vdi : vehicle_data_items) {
+ if (param_name == vdi.name) {
+ return true;
+ }
+ }
+ return false;
+ };
+
policy_table::Parameters valid_params;
const policy_table::Parameters& params = *(rpc_parameters.parameters);
for (const auto& param : params) {
- if (param.is_valid()) {
+ if (param.is_valid() && ParamExists(param)) {
valid_params.push_back(param);
}
}
@@ -404,7 +427,9 @@ void FilterInvalidApplicationParameters(
* @brief FilterPolicyTable filter values that not present in schema
* @param pt policy table to filter
*/
-void FilterPolicyTable(policy_table::PolicyTable& pt) {
+void FilterPolicyTable(
+ policy_table::PolicyTable& pt,
+ const std::vector<policy_table::VehicleDataItem>& current_vd_items) {
policy_table::ModuleConfig& module_config = pt.module_config;
if (module_config.is_initialized() &&
module_config.notifications_per_minute_by_priority.is_initialized()) {
@@ -423,8 +448,18 @@ void FilterPolicyTable(policy_table::PolicyTable& pt) {
policy_table::Rpc& rpcs = group.second.rpcs;
FilterInvalidFunctions(rpcs);
+ policy_table::VehicleDataItems vehicle_data_items;
+
+ if (!pt.vehicle_data->struct_empty()) {
+ vehicle_data_items =
+ pt.vehicle_data.is_initialized() &&
+ pt.vehicle_data->schema_items.is_initialized()
+ ? *pt.vehicle_data->schema_items
+ : current_vd_items;
+ }
+
for (auto& func : rpcs) {
- FilterInvalidRPCParameters(func.second);
+ FilterInvalidRPCParameters(func.second, vehicle_data_items);
}
}
}
@@ -445,7 +480,9 @@ bool PolicyManagerImpl::LoadPT(const std::string& file,
}
file_system::DeleteFile(file);
- FilterPolicyTable(pt_update->policy_table);
+ auto current_vd_items = GetVehicleDataItems();
+
+ FilterPolicyTable(pt_update->policy_table, current_vd_items);
if (!IsPTValid(pt_update, policy_table::PT_UPDATE)) {
wrong_ptu_update_received_ = true;
update_status_manager_.OnWrongUpdateReceived();
@@ -469,13 +506,9 @@ bool PolicyManagerImpl::LoadPT(const std::string& file,
return false;
}
- // Checking of difference between PTU and current policy state
- // Must to be done before PTU applying since it is possible, that functional
- // groups, which had been present before are absent in PTU and will be
- // removed after update. So in case of revoked groups system has to know
- // names and ids of revoked groups before they will be removed.
- CheckAppPolicyResults results =
- CheckPermissionsChanges(pt_update, policy_table_snapshot);
+ // Replace predefined policies with its actual setting, e.g. "123":"default"
+ // to actual values of default section
+ UnwrapAppPolicies(pt_update->policy_table.app_policies_section.apps);
// Replace current data with updated
if (!cache_->ApplyUpdate(*pt_update)) {
@@ -486,6 +519,14 @@ bool PolicyManagerImpl::LoadPT(const std::string& file,
return false;
}
+ // Checking of difference between PTU and current policy state
+ // Must to be done before PTU applying since it is possible, that functional
+ // groups, which had been present before are absent in PTU and will be
+ // removed after update. So in case of revoked groups system has to know
+ // names and ids of revoked groups before they will be removed.
+ CheckAppPolicyResults results =
+ CheckPermissionsChanges(pt_update, policy_table_snapshot);
+
ExternalConsentStatus status = cache_->GetExternalConsentStatus();
GroupsByExternalConsentStatus groups_by_status =
cache_->GetGroupsWithSameEntities(status);
@@ -533,10 +574,6 @@ CheckAppPolicyResults PolicyManagerImpl::CheckPermissionsChanges(
const std::shared_ptr<policy_table::Table> snapshot) {
LOG4CXX_AUTO_TRACE(logger_);
- // Replace predefined policies with its actual setting, e.g. "123":"default"
- // to actual values of default section
- UnwrapAppPolicies(pt_update->policy_table.app_policies_section.apps);
-
CheckAppPolicyResults out_results;
std::for_each(pt_update->policy_table.app_policies_section.apps.begin(),
pt_update->policy_table.app_policies_section.apps.end(),
@@ -753,8 +790,13 @@ const std::vector<std::string> PolicyManagerImpl::GetAppRequestSubTypes(
return request_subtypes;
}
-const VehicleInfo PolicyManagerImpl::GetVehicleInfo() const {
- return cache_->GetVehicleInfo();
+const std::vector<policy_table::VehicleDataItem>
+PolicyManagerImpl::GetVehicleDataItems() const {
+ return cache_->GetVehicleDataItems();
+}
+
+Json::Value PolicyManagerImpl::GetPolicyTableData() const {
+ return cache_->GetPolicyTableData();
}
void PolicyManagerImpl::GetEnabledCloudApps(
@@ -986,7 +1028,12 @@ void PolicyManagerImpl::CheckPermissions(const PTString& device_id,
result.hmi_level_permitted = kRpcUserDisallowed;
} else if (!result.IsAnyAllowed(rpc_params)) {
LOG4CXX_DEBUG(logger_, "There are no parameters allowed.");
- result.hmi_level_permitted = kRpcDisallowed;
+
+ if (!result.list_of_undefined_params.empty()) {
+ result.hmi_level_permitted = kRpcAllowed;
+ } else {
+ result.hmi_level_permitted = kRpcDisallowed;
+ }
}
}
diff --git a/src/components/policy/policy_external/src/policy_table/enums.cc b/src/components/policy/policy_external/src/policy_table/enums.cc
index c7dfe98271..8f5d58aad2 100644
--- a/src/components/policy/policy_external/src/policy_table/enums.cc
+++ b/src/components/policy/policy_external/src/policy_table/enums.cc
@@ -3,555 +3,6 @@
namespace rpc {
namespace policy_table_interface_base {
-bool IsValidEnum(Priority val) {
- switch (val) {
- case P_EMERGENCY:
- return true;
- case P_NAVIGATION:
- return true;
- case P_VOICECOM:
- return true;
- case P_COMMUNICATION:
- return true;
- case P_NORMAL:
- return true;
- case P_PROJECTION:
- return true;
- case P_NONE:
- return true;
- default:
- return false;
- }
-}
-const char* EnumToJsonString(Priority val) {
- switch (val) {
- case P_EMERGENCY:
- return "EMERGENCY";
- case P_NAVIGATION:
- return "NAVIGATION";
- case P_VOICECOM:
- return "VOICECOM";
- case P_COMMUNICATION:
- return "COMMUNICATION";
- case P_NORMAL:
- return "NORMAL";
- case P_PROJECTION:
- return "PROJECTION";
- case P_NONE:
- return "NONE";
- default:
- return "";
- }
-}
-bool EnumFromJsonString(const std::string& literal, Priority* result) {
- if ("EMERGENCY" == literal) {
- *result = P_EMERGENCY;
- return true;
- } else if ("NAVIGATION" == literal) {
- *result = P_NAVIGATION;
- return true;
- } else if ("VOICECOM" == literal) {
- *result = P_VOICECOM;
- return true;
- } else if ("COMMUNICATION" == literal) {
- *result = P_COMMUNICATION;
- return true;
- } else if ("NORMAL" == literal) {
- *result = P_NORMAL;
- return true;
- } else if ("PROJECTION" == literal) {
- *result = P_PROJECTION;
- return true;
- } else if ("NONE" == literal) {
- *result = P_NONE;
- return true;
- } else {
- return false;
- }
-}
-
-bool IsValidEnum(HmiLevel val) {
- switch (val) {
- case HL_BACKGROUND:
- return true;
- case HL_FULL:
- return true;
- case HL_LIMITED:
- return true;
- case HL_NONE:
- return true;
- default:
- return false;
- }
-}
-const char* EnumToJsonString(HmiLevel val) {
- switch (val) {
- case HL_BACKGROUND:
- return "BACKGROUND";
- case HL_FULL:
- return "FULL";
- case HL_LIMITED:
- return "LIMITED";
- case HL_NONE:
- return "NONE";
- default:
- return "";
- }
-}
-bool EnumFromJsonString(const std::string& literal, HmiLevel* result) {
- if ("BACKGROUND" == literal) {
- *result = HL_BACKGROUND;
- return true;
- } else if ("FULL" == literal) {
- *result = HL_FULL;
- return true;
- } else if ("LIMITED" == literal) {
- *result = HL_LIMITED;
- return true;
- } else if ("NONE" == literal) {
- *result = HL_NONE;
- return true;
- } else {
- return false;
- }
-}
-
-bool IsValidEnum(Parameter val) {
- switch (val) {
- case P_GPS:
- return true;
- case P_SPEED:
- return true;
- case P_ENGINETORQUE:
- return true;
- case P_EXTERNALTEMPERATURE:
- return true;
- case P_TURNSIGNAL:
- return true;
- case P_FUELLEVEL:
- return true;
- case P_FUELLEVEL_STATE:
- return true;
- case P_HEADLAMPSTATUS:
- return true;
- case P_INSTANTFUELCONSUMPTION:
- return true;
- case P_FUELRANGE:
- return true;
- case P_CLOUD_APP_VEHICLE_ID:
- return true;
- case P_ODOMETER:
- return true;
- case P_TIREPRESSURE:
- return true;
- case P_WIPERSTATUS:
- return true;
- case P_VIN:
- return true;
- case P_ACCPEDALPOSITION:
- return true;
- case P_BELTSTATUS:
- return true;
- case P_ELECTRONICPARKBRAKESTATUS:
- return true;
- case P_DRIVERBRAKING:
- return true;
- case P_PRNDL:
- return true;
- case P_RPM:
- return true;
- case P_STEERINGWHEELANGLE:
- return true;
- case P_ENGINEOILLIFE:
- return true;
- case P_MYKEY:
- return true;
- case P_AIRBAGSTATUS:
- return true;
- case P_BODYINFORMATION:
- return true;
- case P_CLUSTERMODESTATUS:
- return true;
- case P_DEVICESTATUS:
- return true;
- case P_EMERGENCYEVENT:
- return true;
- case P_ECALLINFO:
- return true;
- case P_ABS_STATE:
- return true;
- case P_FUEL_RANGE:
- return true;
- case P_TIRE_PRESSURE_VALUE:
- return true;
- case P_TPMS:
- return true;
- case P_LONGTITUDE_DEGREES:
- return true;
- case P_LATITUDE_DEGREES:
- return true;
- case P_LOCATION_NAME:
- return true;
- case P_LOCATION_DESCRIPTION:
- return true;
- case P_ADDRESS_LINES:
- return true;
- case P_PHONE_NUMBER:
- return true;
- case P_LOCATION_IMAGE:
- return true;
- case P_DELIVERY_MODE:
- return true;
- case P_TIMESTAMP:
- return true;
- case P_ADDRESS:
- return true;
- case P_EMPTY:
- return true;
- default:
- return false;
- }
-}
-
-const char* EnumToJsonString(Parameter val) {
- switch (val) {
- case P_GPS:
- return "gps";
- case P_SPEED:
- return "speed";
- case P_ENGINETORQUE:
- return "engineTorque";
- case P_EXTERNALTEMPERATURE:
- return "externalTemperature";
- case P_TURNSIGNAL:
- return "turnSignal";
- case P_FUELLEVEL:
- return "fuelLevel";
- case P_FUELLEVEL_STATE:
- return "fuelLevel_State";
- case P_HEADLAMPSTATUS:
- return "headLampStatus";
- case P_INSTANTFUELCONSUMPTION:
- return "instantFuelConsumption";
- case P_FUELRANGE:
- return "fuelRange";
- case P_CLOUD_APP_VEHICLE_ID:
- return "cloudAppVehicleID";
- case P_ODOMETER:
- return "odometer";
- case P_TIREPRESSURE:
- return "tirePressure";
- case P_WIPERSTATUS:
- return "wiperStatus";
- case P_VIN:
- return "vin";
- case P_ACCPEDALPOSITION:
- return "accPedalPosition";
- case P_BELTSTATUS:
- return "beltStatus";
- case P_ELECTRONICPARKBRAKESTATUS:
- return "electronicParkBrakeStatus";
- case P_DRIVERBRAKING:
- return "driverBraking";
- case P_PRNDL:
- return "prndl";
- case P_RPM:
- return "rpm";
- case P_STEERINGWHEELANGLE:
- return "steeringWheelAngle";
- case P_ENGINEOILLIFE:
- return "engineOilLife";
- case P_MYKEY:
- return "myKey";
- case P_AIRBAGSTATUS:
- return "airbagStatus";
- case P_BODYINFORMATION:
- return "bodyInformation";
- case P_CLUSTERMODESTATUS:
- return "clusterModeStatus";
- case P_DEVICESTATUS:
- return "deviceStatus";
- case P_EMERGENCYEVENT:
- return "emergencyEvent";
- case P_ECALLINFO:
- return "eCallInfo";
- case P_ABS_STATE:
- return "abs_State";
- case P_FUEL_RANGE:
- return "fuelRange";
- case P_TIRE_PRESSURE_VALUE:
- return "tirePressureValue";
- case P_TPMS:
- return "tpms";
- case P_LONGTITUDE_DEGREES:
- return "longitudeDegrees";
- case P_LATITUDE_DEGREES:
- return "latitudeDegrees";
- case P_LOCATION_NAME:
- return "locationName";
- case P_LOCATION_DESCRIPTION:
- return "locationDescription";
- case P_ADDRESS_LINES:
- return "addressLines";
- case P_PHONE_NUMBER:
- return "phoneNumber";
- case P_LOCATION_IMAGE:
- return "locationImage";
- case P_DELIVERY_MODE:
- return "deliveryMode";
- case P_TIMESTAMP:
- return "timeStamp";
- case P_ADDRESS:
- return "address";
- case P_EMPTY:
- return "EMPTY";
- default:
- return "";
- }
-}
-
-bool EnumFromJsonString(const std::string& literal, Parameter* result) {
- if ("gps" == literal) {
- *result = P_GPS;
- return true;
- } else if ("speed" == literal) {
- *result = P_SPEED;
- return true;
- } else if ("engineTorque" == literal) {
- *result = P_ENGINETORQUE;
- return true;
- } else if ("externalTemperature" == literal) {
- *result = P_EXTERNALTEMPERATURE;
- return true;
- } else if ("turnSignal" == literal) {
- *result = P_TURNSIGNAL;
- return true;
- } else if ("fuelLevel" == literal) {
- *result = P_FUELLEVEL;
- return true;
- } else if ("fuelLevel_State" == literal) {
- *result = P_FUELLEVEL_STATE;
- return true;
- } else if ("headLampStatus" == literal) {
- *result = P_HEADLAMPSTATUS;
- return true;
- } else if ("instantFuelConsumption" == literal) {
- *result = P_INSTANTFUELCONSUMPTION;
- return true;
- } else if ("fuelRange" == literal) {
- *result = P_FUELRANGE;
- return true;
- } else if ("cloudAppVehicleID" == literal) {
- *result = P_CLOUD_APP_VEHICLE_ID;
- return true;
- } else if ("odometer" == literal) {
- *result = P_ODOMETER;
- return true;
- } else if ("tirePressure" == literal) {
- *result = P_TIREPRESSURE;
- return true;
- } else if ("wiperStatus" == literal) {
- *result = P_WIPERSTATUS;
- return true;
- } else if ("vin" == literal) {
- *result = P_VIN;
- return true;
- } else if ("accPedalPosition" == literal) {
- *result = P_ACCPEDALPOSITION;
- return true;
- } else if ("beltStatus" == literal) {
- *result = P_BELTSTATUS;
- return true;
- } else if ("electronicParkBrakeStatus" == literal) {
- *result = P_ELECTRONICPARKBRAKESTATUS;
- return true;
- } else if ("driverBraking" == literal) {
- *result = P_DRIVERBRAKING;
- return true;
- } else if ("prndl" == literal) {
- *result = P_PRNDL;
- return true;
- } else if ("rpm" == literal) {
- *result = P_RPM;
- return true;
- } else if ("steeringWheelAngle" == literal) {
- *result = P_STEERINGWHEELANGLE;
- return true;
- } else if ("engineOilLife" == literal) {
- *result = P_ENGINEOILLIFE;
- return true;
- } else if ("myKey" == literal) {
- *result = P_MYKEY;
- return true;
- } else if ("airbagStatus" == literal) {
- *result = P_AIRBAGSTATUS;
- return true;
- } else if ("bodyInformation" == literal) {
- *result = P_BODYINFORMATION;
- return true;
- } else if ("clusterModeStatus" == literal) {
- *result = P_CLUSTERMODESTATUS;
- return true;
- } else if ("deviceStatus" == literal) {
- *result = P_DEVICESTATUS;
- return true;
- } else if ("emergencyEvent" == literal) {
- *result = P_EMERGENCYEVENT;
- return true;
- } else if ("eCallInfo" == literal) {
- *result = P_ECALLINFO;
- return true;
- } else if ("abs_State" == literal) {
- *result = P_ABS_STATE;
- return true;
- } else if ("fuelRange" == literal) {
- *result = P_FUEL_RANGE;
- return true;
- } else if ("tirePressureValue" == literal) {
- *result = P_TIRE_PRESSURE_VALUE;
- return true;
- } else if ("tpms" == literal) {
- *result = P_TPMS;
- return true;
- } else if ("longitudeDegrees" == literal) {
- *result = P_LONGTITUDE_DEGREES;
- return true;
- } else if ("latitudeDegrees" == literal) {
- *result = P_LATITUDE_DEGREES;
- return true;
- } else if ("locationName" == literal) {
- *result = P_LOCATION_NAME;
- return true;
- } else if ("locationDescription" == literal) {
- *result = P_LOCATION_DESCRIPTION;
- return true;
- } else if ("addressLines" == literal) {
- *result = P_ADDRESS_LINES;
- return true;
- } else if ("phoneNumber" == literal) {
- *result = P_PHONE_NUMBER;
- return true;
- } else if ("locationImage" == literal) {
- *result = P_LOCATION_IMAGE;
- return true;
- } else if ("deliveryMode" == literal) {
- *result = P_DELIVERY_MODE;
- return true;
- } else if ("timeStamp" == literal) {
- *result = P_TIMESTAMP;
- return true;
- } else if ("address" == literal) {
- *result = P_ADDRESS;
- return true;
- } else if ("EMPTY" == literal) {
- *result = P_EMPTY;
- return true;
- } else {
- return false;
- }
-}
-
-bool IsValidEnum(AppHMIType val) {
- switch (val) {
- case AHT_DEFAULT:
- return true;
- case AHT_COMMUNICATION:
- return true;
- case AHT_MEDIA:
- return true;
- case AHT_MESSAGING:
- return true;
- case AHT_NAVIGATION:
- return true;
- case AHT_INFORMATION:
- return true;
- case AHT_SOCIAL:
- return true;
- case AHT_BACKGROUND_PROCESS:
- return true;
- case AHT_TESTING:
- return true;
- case AHT_SYSTEM:
- return true;
- case AHT_PROJECTION:
- return true;
- case AHT_REMOTE_CONTROL:
- return true;
- default:
- return false;
- }
-}
-const char* EnumToJsonString(AppHMIType val) {
- switch (val) {
- case AHT_DEFAULT:
- return "DEFAULT";
- case AHT_COMMUNICATION:
- return "COMMUNICATION";
- case AHT_MEDIA:
- return "MEDIA";
- case AHT_MESSAGING:
- return "MESSAGING";
- case AHT_NAVIGATION:
- return "NAVIGATION";
- case AHT_INFORMATION:
- return "INFORMATION";
- case AHT_SOCIAL:
- return "SOCIAL";
- case AHT_BACKGROUND_PROCESS:
- return "BACKGROUND_PROCESS";
- case AHT_TESTING:
- return "TESTING";
- case AHT_SYSTEM:
- return "SYSTEM";
- case AHT_PROJECTION:
- return "PROJECTION";
- case AHT_REMOTE_CONTROL:
- return "REMOTE_CONTROL";
- default:
- return "";
- }
-}
-bool EnumFromJsonString(const std::string& literal, AppHMIType* result) {
- if ("DEFAULT" == literal) {
- *result = AHT_DEFAULT;
- return true;
- } else if ("COMMUNICATION" == literal) {
- *result = AHT_COMMUNICATION;
- return true;
- } else if ("MEDIA" == literal) {
- *result = AHT_MEDIA;
- return true;
- } else if ("MESSAGING" == literal) {
- *result = AHT_MESSAGING;
- return true;
- } else if ("NAVIGATION" == literal) {
- *result = AHT_NAVIGATION;
- return true;
- } else if ("INFORMATION" == literal) {
- *result = AHT_INFORMATION;
- return true;
- } else if ("SOCIAL" == literal) {
- *result = AHT_SOCIAL;
- return true;
- } else if ("BACKGROUND_PROCESS" == literal) {
- *result = AHT_BACKGROUND_PROCESS;
- return true;
- } else if ("TESTING" == literal) {
- *result = AHT_TESTING;
- return true;
- } else if ("SYSTEM" == literal) {
- *result = AHT_SYSTEM;
- return true;
- } else if ("PROJECTION" == literal) {
- *result = AHT_PROJECTION;
- return true;
- } else if ("REMOTE_CONTROL" == literal) {
- *result = AHT_REMOTE_CONTROL;
- return true;
- } else {
- return false;
- }
-}
bool IsValidEnum(Input val) {
switch (val) {
@@ -563,6 +14,7 @@ bool IsValidEnum(Input val) {
return false;
}
}
+
const char* EnumToJsonString(Input val) {
switch (val) {
case I_GUI:
@@ -585,895 +37,6 @@ bool EnumFromJsonString(const std::string& literal, Input* result) {
}
}
-bool IsValidEnum(RequestType val) {
- switch (val) {
- case RT_HTTP:
- return true;
- case RT_FILE_RESUME:
- return true;
- case RT_AUTH_REQUEST:
- return true;
- case RT_AUTH_CHALLENGE:
- return true;
- case RT_AUTH_ACK:
- return true;
- case RT_PROPRIETARY:
- return true;
- case RT_QUERY_APPS:
- return true;
- case RT_LAUNCH_APP:
- return true;
- case RT_LOCK_SCREEN_ICON_URL:
- return true;
- case RT_TRAFFIC_MESSAGE_CHANNEL:
- return true;
- case RT_DRIVER_PROFILE:
- return true;
- case RT_VOICE_SEARCH:
- return true;
- case RT_NAVIGATION:
- return true;
- case RT_PHONE:
- return true;
- case RT_CLIMATE:
- return true;
- case RT_SETTINGS:
- return true;
- case RT_VEHICLE_DIAGNOSTICS:
- return true;
- case RT_EMERGENCY:
- return true;
- case RT_MEDIA:
- return true;
- case RT_FOTA:
- return true;
- case RT_OEM_SPECIFIC:
- return true;
- case RT_ICON_URL:
- return true;
- case RT_EMPTY:
- return true;
- default:
- return false;
- }
-}
-
-const char* EnumToJsonString(RequestType val) {
- switch (val) {
- case RT_HTTP:
- return "HTTP";
- case RT_FILE_RESUME:
- return "FILE_RESUME";
- case RT_AUTH_REQUEST:
- return "AUTH_REQUEST";
- case RT_AUTH_CHALLENGE:
- return "AUTH_CHALLENGE";
- case RT_AUTH_ACK:
- return "AUTH_ACK";
- case RT_PROPRIETARY:
- return "PROPRIETARY";
- case RT_QUERY_APPS:
- return "QUERY_APPS";
- case RT_LAUNCH_APP:
- return "LAUNCH_APP";
- case RT_LOCK_SCREEN_ICON_URL:
- return "LOCK_SCREEN_ICON_URL";
- case RT_TRAFFIC_MESSAGE_CHANNEL:
- return "TRAFFIC_MESSAGE_CHANNEL";
- case RT_DRIVER_PROFILE:
- return "DRIVER_PROFILE";
- case RT_VOICE_SEARCH:
- return "VOICE_SEARCH";
- case RT_NAVIGATION:
- return "NAVIGATION";
- case RT_PHONE:
- return "PHONE";
- case RT_CLIMATE:
- return "CLIMATE";
- case RT_SETTINGS:
- return "SETTINGS";
- case RT_VEHICLE_DIAGNOSTICS:
- return "VEHICLE_DIAGNOSTICS";
- case RT_EMERGENCY:
- return "EMERGENCY";
- case RT_MEDIA:
- return "MEDIA";
- case RT_FOTA:
- return "FOTA";
- case RT_OEM_SPECIFIC:
- return "OEM_SPECIFIC";
- case RT_ICON_URL:
- return "ICON_URL";
- case RT_EMPTY:
- return "EMPTY";
- default:
- return "";
- }
-}
-
-bool EnumFromJsonString(const std::string& literal, RequestType* result) {
- if ("HTTP" == literal) {
- *result = RT_HTTP;
- return true;
- }
- if ("FILE_RESUME" == literal) {
- *result = RT_FILE_RESUME;
- return true;
- }
- if ("AUTH_REQUEST" == literal) {
- *result = RT_AUTH_REQUEST;
- return true;
- }
- if ("AUTH_CHALLENGE" == literal) {
- *result = RT_AUTH_CHALLENGE;
- return true;
- }
- if ("AUTH_ACK" == literal) {
- *result = RT_AUTH_ACK;
- return true;
- }
- if ("PROPRIETARY" == literal) {
- *result = RT_PROPRIETARY;
- return true;
- }
- if ("QUERY_APPS" == literal) {
- *result = RT_QUERY_APPS;
- return true;
- }
- if ("LAUNCH_APP" == literal) {
- *result = RT_LAUNCH_APP;
- return true;
- }
- if ("LOCK_SCREEN_ICON_URL" == literal) {
- *result = RT_LOCK_SCREEN_ICON_URL;
- return true;
- }
- if ("TRAFFIC_MESSAGE_CHANNEL" == literal) {
- *result = RT_TRAFFIC_MESSAGE_CHANNEL;
- return true;
- }
- if ("DRIVER_PROFILE" == literal) {
- *result = RT_DRIVER_PROFILE;
- return true;
- }
- if ("VOICE_SEARCH" == literal) {
- *result = RT_VOICE_SEARCH;
- return true;
- }
- if ("NAVIGATION" == literal) {
- *result = RT_NAVIGATION;
- return true;
- }
- if ("PHONE" == literal) {
- *result = RT_PHONE;
- return true;
- }
- if ("CLIMATE" == literal) {
- *result = RT_CLIMATE;
- return true;
- }
- if ("SETTINGS" == literal) {
- *result = RT_SETTINGS;
- return true;
- }
- if ("VEHICLE_DIAGNOSTICS" == literal) {
- *result = RT_VEHICLE_DIAGNOSTICS;
- return true;
- }
- if ("EMERGENCY" == literal) {
- *result = RT_EMERGENCY;
- return true;
- }
- if ("MEDIA" == literal) {
- *result = RT_MEDIA;
- return true;
- }
- if ("FOTA" == literal) {
- *result = RT_FOTA;
- return true;
- }
- if ("OEM_SPECIFIC" == literal) {
- *result = RT_OEM_SPECIFIC;
- return true;
- }
- if ("ICON_URL" == literal) {
- *result = RT_ICON_URL;
- return true;
- }
- if ("EMPTY" == literal) {
- *result = RT_EMPTY;
- return true;
- } else {
- return false;
- }
-}
-
-bool IsValidEnum(ModuleType val) {
- switch (val) {
- case MT_CLIMATE:
- return true;
- case MT_RADIO:
- return true;
- case MT_AUDIO:
- return true;
- case MT_LIGHT:
- return true;
- case MT_HMI_SETTINGS:
- return true;
- case MT_SEAT:
- return true;
- case MT_EMPTY:
- return true;
- default:
- return false;
- }
-}
-const char* EnumToJsonString(ModuleType val) {
- switch (val) {
- case MT_CLIMATE:
- return "CLIMATE";
- case MT_RADIO:
- return "RADIO";
- case MT_AUDIO:
- return "AUDIO";
- case MT_LIGHT:
- return "LIGHT";
- case MT_HMI_SETTINGS:
- return "HMI_SETTINGS";
- case MT_SEAT:
- return "SEAT";
- case MT_EMPTY:
- return "EMPTY";
- default:
- return "";
- }
-}
-
-bool EnumFromJsonString(const std::string& literal, ModuleType* result) {
- if ("CLIMATE" == literal) {
- *result = MT_CLIMATE;
- return true;
- } else if ("RADIO" == literal) {
- *result = MT_RADIO;
- return true;
- } else if ("SEAT" == literal) {
- *result = MT_SEAT;
- return true;
- } else if ("AUDIO" == literal) {
- *result = MT_AUDIO;
- return true;
- } else if ("LIGHT" == literal) {
- *result = MT_LIGHT;
- return true;
- } else if ("HMI_SETTINGS" == literal) {
- *result = MT_HMI_SETTINGS;
- return true;
- } else if ("EMPTY" == literal) {
- *result = MT_EMPTY;
- return true;
- } else {
- return false;
- }
-}
-
-bool IsValidEnum(HybridAppPreference val) {
- return strlen(EnumToJsonString(val)) > 0;
-}
-
-const char* EnumToJsonString(HybridAppPreference val) {
- switch (val) {
- case HAP_MOBILE:
- return "MOBILE";
- case HAP_CLOUD:
- return "CLOUD";
- case HAP_BOTH:
- return "BOTH";
- default:
- return "";
- }
-}
-
-bool EnumFromJsonString(const std::string& literal,
- HybridAppPreference* result) {
- if ("MOBILE" == literal) {
- *result = HAP_MOBILE;
- return true;
- } else if ("CLOUD" == literal) {
- *result = HAP_CLOUD;
- return true;
- } else if ("BOTH" == literal) {
- *result = HAP_BOTH;
- return true;
- }
- return false;
-}
-
-const char* EnumToJsonString(FunctionID val) {
- switch (val) {
- case RegisterAppInterfaceID:
- return "RegisterAppInterface";
- case UnregisterAppInterfaceID:
- return "UnregisterAppInterface";
- case SetGlobalPropertiesID:
- return "SetGlobalProperties";
- case ResetGlobalPropertiesID:
- return "ResetGlobalProperties";
- case AddCommandID:
- return "AddCommand";
- case DeleteCommandID:
- return "DeleteCommand";
- case AddSubMenuID:
- return "AddSubMenu";
- case DeleteSubMenuID:
- return "DeleteSubMenu";
- case CreateInteractionChoiceSetID:
- return "CreateInteractionChoiceSet";
- case PerformInteractionID:
- return "PerformInteraction";
- case DeleteInteractionChoiceSetID:
- return "DeleteInteractionChoiceSet";
- case AlertID:
- return "Alert";
- case ShowID:
- return "Show";
- case SpeakID:
- return "Speak";
- case SetMediaClockTimerID:
- return "SetMediaClockTimer";
- case PerformAudioPassThruID:
- return "PerformAudioPassThru";
- case EndAudioPassThruID:
- return "EndAudioPassThru";
- case SubscribeButtonID:
- return "SubscribeButton";
- case UnsubscribeButtonID:
- return "UnsubscribeButton";
- case SubscribeVehicleDataID:
- return "SubscribeVehicleData";
- case UnsubscribeVehicleDataID:
- return "UnsubscribeVehicleData";
- case GetVehicleDataID:
- return "GetVehicleData";
- case ReadDIDID:
- return "ReadDID";
- case GetDTCsID:
- return "GetDTCs";
- case ScrollableMessageID:
- return "ScrollableMessage";
- case SliderID:
- return "Slider";
- case ShowConstantTBTID:
- return "ShowConstantTBT";
- case AlertManeuverID:
- return "AlertManeuver";
- case UpdateTurnListID:
- return "UpdateTurnList";
- case ChangeRegistrationID:
- return "ChangeRegistration";
- case GenericResponseID:
- return "GenericResponse";
- case PutFileID:
- return "PutFile";
- case DeleteFileID:
- return "DeleteFile";
- case ListFilesID:
- return "ListFiles";
- case SetAppIconID:
- return "SetAppIcon";
- case SetDisplayLayoutID:
- return "SetDisplayLayout";
- case DiagnosticMessageID:
- return "DiagnosticMessage";
- case SystemRequestID:
- return "SystemRequest";
- case SendLocationID:
- return "SendLocation";
- case DialNumberID:
- return "DialNumber";
- case ButtonPressID:
- return "ButtonPress";
- case GetInteriorVehicleDataID:
- return "GetInteriorVehicleData";
- case SetInteriorVehicleDataID:
- return "SetInteriorVehicleData";
- case GetWayPointsID:
- return "GetWayPoints";
- case SubscribeWayPointsID:
- return "SubscribeWayPoints";
- case UnsubscribeWayPointsID:
- return "UnsubscribeWayPoints";
- case GetSystemCapabilityID:
- return "GetSystemCapability";
- case SendHapticDataID:
- return "SendHapticData";
- case SetCloudAppPropertiesID:
- return "SetCloudAppProperties";
- case GetCloudAppPropertiesID:
- return "GetCloudAppProperties";
- case PublishAppServiceID:
- return "PublishAppService";
- case GetFileID:
- return "GetFile";
- case GetAppServiceDataID:
- return "GetAppServiceData";
- case PerformAppServiceInteractionID:
- return "PerformAppServiceInteraction";
- case OnHMIStatusID:
- return "OnHMIStatus";
- case OnAppInterfaceUnregisteredID:
- return "OnAppInterfaceUnregistered";
- case OnButtonEventID:
- return "OnButtonEvent";
- case OnButtonPressID:
- return "OnButtonPress";
- case OnVehicleDataID:
- return "OnVehicleData";
- case OnCommandID:
- return "OnCommand";
- case OnTBTClientStateID:
- return "OnTBTClientState";
- case OnDriverDistractionID:
- return "OnDriverDistraction";
- case OnPermissionsChangeID:
- return "OnPermissionsChange";
- case OnAudioPassThruID:
- return "OnAudioPassThru";
- case OnLanguageChangeID:
- return "OnLanguageChange";
- case OnKeyboardInputID:
- return "OnKeyboardInput";
- case OnTouchEventID:
- return "OnTouchEvent";
- case OnSystemRequestID:
- return "OnSystemRequest";
- case OnHashChangeID:
- return "OnHashChange";
- case OnInteriorVehicleDataID:
- return "OnInteriorVehicleData";
- case OnWayPointChangeID:
- return "OnWayPointChange";
- case OnRCStatusID:
- return "OnRCStatus";
- case OnAppServiceDataID:
- return "OnAppServiceData";
- case EncodedSyncPDataID:
- return "EncodedSyncPData";
- case SyncPDataID:
- return "SyncPData";
- case OnEncodedSyncPDataID:
- return "OnEncodedSyncPData";
- case OnSyncPDataID:
- return "OnSyncPData";
- case OnSystemCapabilityUpdatedID:
- return "OnSystemCapabilityUpdated";
- default:
- return "";
- }
-};
-
-bool EnumFromJsonString(const std::string& literal, FunctionID* result) {
- if ("RegisterAppInterface" == literal) {
- *result = RegisterAppInterfaceID;
- return true;
- }
-
- if ("UnregisterAppInterface" == literal) {
- *result = UnregisterAppInterfaceID;
- return true;
- }
-
- if ("SetGlobalProperties" == literal) {
- *result = SetGlobalPropertiesID;
- return true;
- }
-
- if ("ResetGlobalProperties" == literal) {
- *result = ResetGlobalPropertiesID;
- return true;
- }
-
- if ("AddCommand" == literal) {
- *result = AddCommandID;
- return true;
- }
-
- if ("DeleteCommand" == literal) {
- *result = DeleteCommandID;
- return true;
- }
-
- if ("AddSubMenu" == literal) {
- *result = AddSubMenuID;
- return true;
- }
-
- if ("DeleteSubMenu" == literal) {
- *result = DeleteSubMenuID;
- return true;
- }
-
- if ("CreateInteractionChoiceSet" == literal) {
- *result = CreateInteractionChoiceSetID;
- return true;
- }
-
- if ("PerformInteraction" == literal) {
- *result = PerformInteractionID;
- return true;
- }
-
- if ("DeleteInteractionChoiceSet" == literal) {
- *result = DeleteInteractionChoiceSetID;
- return true;
- }
-
- if ("Alert" == literal) {
- *result = AlertID;
- return true;
- }
-
- if ("Show" == literal) {
- *result = ShowID;
- return true;
- }
-
- if ("Speak" == literal) {
- *result = SpeakID;
- return true;
- }
-
- if ("SetMediaClockTimer" == literal) {
- *result = SetMediaClockTimerID;
- return true;
- }
-
- if ("PerformAudioPassThru" == literal) {
- *result = PerformAudioPassThruID;
- return true;
- }
-
- if ("EndAudioPassThru" == literal) {
- *result = EndAudioPassThruID;
- return true;
- }
-
- if ("SubscribeButton" == literal) {
- *result = SubscribeButtonID;
- return true;
- }
-
- if ("UnsubscribeButton" == literal) {
- *result = UnsubscribeButtonID;
- return true;
- }
-
- if ("SubscribeVehicleData" == literal) {
- *result = SubscribeVehicleDataID;
- return true;
- }
-
- if ("UnsubscribeVehicleData" == literal) {
- *result = UnsubscribeVehicleDataID;
- return true;
- }
-
- if ("GetVehicleData" == literal) {
- *result = GetVehicleDataID;
- return true;
- }
-
- if ("ReadDID" == literal) {
- *result = ReadDIDID;
- return true;
- }
-
- if ("GetDTCs" == literal) {
- *result = GetDTCsID;
- return true;
- }
-
- if ("ScrollableMessage" == literal) {
- *result = ScrollableMessageID;
- return true;
- }
-
- if ("Slider" == literal) {
- *result = SliderID;
- return true;
- }
-
- if ("ShowConstantTBT" == literal) {
- *result = ShowConstantTBTID;
- return true;
- }
-
- if ("AlertManeuver" == literal) {
- *result = AlertManeuverID;
- return true;
- }
-
- if ("UpdateTurnList" == literal) {
- *result = UpdateTurnListID;
- return true;
- }
-
- if ("ChangeRegistration" == literal) {
- *result = ChangeRegistrationID;
- return true;
- }
-
- if ("GenericResponse" == literal) {
- *result = GenericResponseID;
- return true;
- }
-
- if ("PutFile" == literal) {
- *result = PutFileID;
- return true;
- }
-
- if ("DeleteFile" == literal) {
- *result = DeleteFileID;
- return true;
- }
-
- if ("ListFiles" == literal) {
- *result = ListFilesID;
- return true;
- }
-
- if ("SetAppIcon" == literal) {
- *result = SetAppIconID;
- return true;
- }
-
- if ("SetDisplayLayout" == literal) {
- *result = SetDisplayLayoutID;
- return true;
- }
-
- if ("DiagnosticMessage" == literal) {
- *result = DiagnosticMessageID;
- return true;
- }
-
- if ("SystemRequest" == literal) {
- *result = SystemRequestID;
- return true;
- }
-
- if ("SendLocation" == literal) {
- *result = SendLocationID;
- return true;
- }
-
- if ("DialNumber" == literal) {
- *result = DialNumberID;
- return true;
- }
-
- if ("ButtonPress" == literal) {
- *result = ButtonPressID;
- return true;
- }
-
- if ("GetInteriorVehicleData" == literal) {
- *result = GetInteriorVehicleDataID;
- return true;
- }
-
- if ("SetInteriorVehicleData" == literal) {
- *result = SetInteriorVehicleDataID;
- return true;
- }
-
- if ("GetWayPoints" == literal) {
- *result = GetWayPointsID;
- return true;
- }
-
- if ("SubscribeWayPoints" == literal) {
- *result = SubscribeWayPointsID;
- return true;
- }
-
- if ("UnsubscribeWayPoints" == literal) {
- *result = UnsubscribeWayPointsID;
- return true;
- }
-
- if ("GetSystemCapability" == literal) {
- *result = GetSystemCapabilityID;
- return true;
- }
-
- if ("SendHapticData" == literal) {
- *result = SendHapticDataID;
- return true;
- }
-
- if ("SetCloudAppProperties" == literal) {
- *result = SetCloudAppPropertiesID;
- return true;
- }
-
- if ("GetCloudAppProperties" == literal) {
- *result = GetCloudAppPropertiesID;
- return true;
- }
-
- if ("PublishAppService" == literal) {
- *result = PublishAppServiceID;
- return true;
- }
-
- if ("GetFile" == literal) {
- *result = GetFileID;
- return true;
- }
-
- if ("GetAppServiceData" == literal) {
- *result = GetAppServiceDataID;
- return true;
- }
-
- if ("PerformAppServiceInteraction" == literal) {
- *result = PerformAppServiceInteractionID;
- return true;
- }
-
- if ("UnpublishAppService" == literal) {
- *result = UnpublishAppServiceID;
- return true;
- }
-
- if ("CancelInteraction" == literal) {
- *result = CancelInteractionID;
- return true;
- }
-
- if ("CreateWindow" == literal) {
- *result = CreateWindowID;
- return true;
- }
-
- if ("DeleteWindow" == literal) {
- *result = DeleteWindowID;
- return true;
- }
-
- if ("CloseApplication" == literal) {
- *result = CloseApplicationID;
- return true;
- }
-
- if ("ShowAppMenu" == literal) {
- *result = ShowAppMenuID;
- return true;
- }
-
- if ("OnHMIStatus" == literal) {
- *result = OnHMIStatusID;
- return true;
- }
-
- if ("OnAppInterfaceUnregistered" == literal) {
- *result = OnAppInterfaceUnregisteredID;
- return true;
- }
-
- if ("OnButtonEvent" == literal) {
- *result = OnButtonEventID;
- return true;
- }
-
- if ("OnButtonPress" == literal) {
- *result = OnButtonPressID;
- return true;
- }
-
- if ("OnVehicleData" == literal) {
- *result = OnVehicleDataID;
- return true;
- }
-
- if ("OnCommand" == literal) {
- *result = OnCommandID;
- return true;
- }
-
- if ("OnTBTClientState" == literal) {
- *result = OnTBTClientStateID;
- return true;
- }
-
- if ("OnDriverDistraction" == literal) {
- *result = OnDriverDistractionID;
- return true;
- }
-
- if ("OnPermissionsChange" == literal) {
- *result = OnPermissionsChangeID;
- return true;
- }
-
- if ("OnAudioPassThru" == literal) {
- *result = OnAudioPassThruID;
- return true;
- }
-
- if ("OnLanguageChange" == literal) {
- *result = OnLanguageChangeID;
- return true;
- }
-
- if ("OnKeyboardInput" == literal) {
- *result = OnKeyboardInputID;
- return true;
- }
-
- if ("OnTouchEvent" == literal) {
- *result = OnTouchEventID;
- return true;
- }
-
- if ("OnSystemRequest" == literal) {
- *result = OnSystemRequestID;
- return true;
- }
-
- if ("OnHashChange" == literal) {
- *result = OnHashChangeID;
- return true;
- }
-
- if ("OnInteriorVehicleData" == literal) {
- *result = OnInteriorVehicleDataID;
- return true;
- }
-
- if ("OnWayPointChange" == literal) {
- *result = OnWayPointChangeID;
- return true;
- }
-
- if ("OnRCStatus" == literal) {
- *result = OnRCStatusID;
- return true;
- }
-
- if ("OnAppServiceData" == literal) {
- *result = OnAppServiceDataID;
- return true;
- }
-
- if ("OnSystemCapabilityUpdated" == literal) {
- *result = OnSystemCapabilityUpdatedID;
- return true;
- }
-
- if ("EncodedSyncPData" == literal) {
- *result = EncodedSyncPDataID;
- return true;
- }
-
- if ("SyncPData" == literal) {
- *result = SyncPDataID;
- return true;
- }
-
- if ("OnEncodedSyncPData" == literal) {
- *result = OnEncodedSyncPDataID;
- return true;
- }
-
- if ("OnSyncPData" == literal) {
- *result = OnSyncPDataID;
- return true;
- }
- return false;
-};
-
const std::string kDefaultApp = "default";
const std::string kPreDataConsentApp = "pre_DataConsent";
const std::string kDeviceApp = "device";
diff --git a/src/components/policy/policy_external/src/policy_table/types.cc b/src/components/policy/policy_external/src/policy_table/types.cc
index cfe5ceed30..73b2002056 100644
--- a/src/components/policy/policy_external/src/policy_table/types.cc
+++ b/src/components/policy/policy_external/src/policy_table/types.cc
@@ -768,9 +768,60 @@ void Rpcs::SetPolicyTableType(PolicyTableType pt_type) {
disallowed_by_external_consent_entities_on.SetPolicyTableType(pt_type);
}
+// EndpointProperties methods
+EndpointProperty::EndpointProperty() : CompositeType(kUninitialized) {}
+
+EndpointProperty::~EndpointProperty() {}
+
+EndpointProperty::EndpointProperty(const Json::Value* value__)
+ : CompositeType(InitHelper(value__, &Json::Value::isObject))
+ , version(impl::ValueMember(value__, "version")) {}
+
+Json::Value EndpointProperty::ToJsonValue() const {
+ Json::Value result__(Json::objectValue);
+ impl::WriteJsonField("version", version, &result__);
+ return result__;
+}
+
+bool EndpointProperty::is_valid() const {
+ if (!version.is_valid()) {
+ return false;
+ }
+ return Validate();
+}
+
+bool EndpointProperty::is_initialized() const {
+ return (initialization_state__ != kUninitialized) || (!struct_empty());
+}
+
+bool EndpointProperty::struct_empty() const {
+ if (version.is_initialized()) {
+ return false;
+ }
+
+ return true;
+}
+
+void EndpointProperty::ReportErrors(rpc::ValidationReport* report__) const {
+ if (struct_empty()) {
+ rpc::CompositeType::ReportErrors(report__);
+ }
+ if (!version.is_valid()) {
+ version.ReportErrors(&report__->ReportSubobject("version"));
+ }
+}
+
+void EndpointProperty::SetPolicyTableType(PolicyTableType pt_type) {
+ CompositeType::SetPolicyTableType(pt_type);
+ version.SetPolicyTableType(pt_type);
+}
+
// ModuleConfig methods
ModuleConfig::ModuleConfig() : CompositeType(kUninitialized) {}
+const std::string ModuleConfig::kDefaultOemMappingServiceName =
+ "custom_vehicle_data_mapping_url";
+
ModuleConfig::ModuleConfig(
uint8_t exchange_after_x_ignition_cycles,
int64_t exchange_after_x_kilometers,
@@ -778,6 +829,7 @@ ModuleConfig::ModuleConfig(
uint16_t timeout_after_x_seconds,
const SecondsBetweenRetries& seconds_between_retries,
const ServiceEndpoints& endpoints,
+ const ServiceEndpointProperties& endpoint_properties,
const NumberOfNotificationsPerMinute& notifications_per_minute_by_priority)
: CompositeType(kUninitialized)
, exchange_after_x_ignition_cycles(exchange_after_x_ignition_cycles)
@@ -786,6 +838,7 @@ ModuleConfig::ModuleConfig(
, timeout_after_x_seconds(timeout_after_x_seconds)
, seconds_between_retries(seconds_between_retries)
, endpoints(endpoints)
+ , endpoint_properties(endpoint_properties)
, notifications_per_minute_by_priority(
notifications_per_minute_by_priority) {}
@@ -803,6 +856,7 @@ ModuleConfig::ModuleConfig(const Json::Value* value__)
, seconds_between_retries(
impl::ValueMember(value__, "seconds_between_retries"))
, endpoints(impl::ValueMember(value__, "endpoints"))
+ , endpoint_properties(impl::ValueMember(value__, "endpoint_properties"))
, notifications_per_minute_by_priority(
impl::ValueMember(value__, "notifications_per_minute_by_priority"))
, vehicle_make(impl::ValueMember(value__, "vehicle_make"))
@@ -823,6 +877,7 @@ void ModuleConfig::SafeCopyFrom(const ModuleConfig& from) {
timeout_after_x_seconds = from.timeout_after_x_seconds;
seconds_between_retries = from.seconds_between_retries;
endpoints = from.endpoints;
+ endpoint_properties = from.endpoint_properties;
notifications_per_minute_by_priority =
from.notifications_per_minute_by_priority;
lock_screen_dismissal_enabled = from.lock_screen_dismissal_enabled;
@@ -851,6 +906,7 @@ Json::Value ModuleConfig::ToJsonValue() const {
impl::WriteJsonField(
"seconds_between_retries", seconds_between_retries, &result__);
impl::WriteJsonField("endpoints", endpoints, &result__);
+ impl::WriteJsonField("endpoint_properties", endpoint_properties, &result__);
impl::WriteJsonField("notifications_per_minute_by_priority",
notifications_per_minute_by_priority,
&result__);
@@ -893,6 +949,9 @@ bool ModuleConfig::is_valid() const {
if (!endpoints.is_valid()) {
return false;
}
+ if (!endpoint_properties.is_valid()) {
+ return false;
+ }
if (!notifications_per_minute_by_priority.is_valid()) {
return false;
}
@@ -953,6 +1012,10 @@ bool ModuleConfig::struct_empty() const {
return false;
}
+ if (endpoint_properties.is_initialized()) {
+ return false;
+ }
+
if (notifications_per_minute_by_priority.is_initialized()) {
return false;
}
@@ -1009,6 +1072,10 @@ void ModuleConfig::ReportErrors(rpc::ValidationReport* report__) const {
if (!endpoints.is_valid()) {
endpoints.ReportErrors(&report__->ReportSubobject("endpoints"));
}
+ if (!endpoint_properties.is_valid()) {
+ endpoint_properties.ReportErrors(
+ &report__->ReportSubobject("endpoint_properties"));
+ }
if (!notifications_per_minute_by_priority.is_valid()) {
notifications_per_minute_by_priority.ReportErrors(
&report__->ReportSubobject("notifications_per_minute_by_priority"));
@@ -1074,6 +1141,7 @@ void ModuleConfig::SetPolicyTableType(PolicyTableType pt_type) {
timeout_after_x_seconds.SetPolicyTableType(pt_type);
seconds_between_retries.SetPolicyTableType(pt_type);
endpoints.SetPolicyTableType(pt_type);
+ endpoint_properties.SetPolicyTableType(pt_type);
notifications_per_minute_by_priority.SetPolicyTableType(pt_type);
lock_screen_dismissal_enabled.SetPolicyTableType(pt_type);
vehicle_make.SetPolicyTableType(pt_type);
@@ -2115,6 +2183,421 @@ void DeviceParams::SetPolicyTableType(PolicyTableType pt_type) {
connection_type.SetPolicyTableType(pt_type);
}
+// VehicleDataItem methods
+VehicleDataItem::VehicleDataItem() : CompositeType(kUninitialized) {}
+
+VehicleDataItem::VehicleDataItem(const VehicleDataItem& vehicle_data)
+ : CompositeType(vehicle_data.initialization_state__)
+ , name(vehicle_data.name)
+ , type(vehicle_data.type)
+ , key(vehicle_data.key)
+ , mandatory(vehicle_data.mandatory)
+ , params(vehicle_data.params)
+ , array(vehicle_data.array)
+ , since(vehicle_data.since)
+ , until(vehicle_data.until)
+ , removed(vehicle_data.removed)
+ , deprecated(vehicle_data.deprecated)
+ , minvalue(vehicle_data.minvalue)
+ , maxvalue(vehicle_data.maxvalue)
+ , minsize(vehicle_data.minsize)
+ , maxsize(vehicle_data.maxsize)
+ , minlength(vehicle_data.minlength)
+ , maxlength(vehicle_data.maxlength) {}
+
+VehicleDataItem::VehicleDataItem(const Json::Value* value__)
+ : CompositeType(InitHelper(value__, &Json::Value::isObject))
+ , name(impl::ValueMember(value__, "name"))
+ , type(impl::ValueMember(value__, "type"))
+ , key(impl::ValueMember(value__, "key"))
+ , mandatory(impl::ValueMember(value__, "mandatory"))
+ , params(impl::ValueMember(value__, "params"))
+ , array(impl::ValueMember(value__, "array"))
+ , since(impl::ValueMember(value__, "since"))
+ , until(impl::ValueMember(value__, "until"))
+ , removed(impl::ValueMember(value__, "removed"))
+ , deprecated(impl::ValueMember(value__, "deprecated"))
+ , minvalue(impl::ValueMember(value__, "minvalue"))
+ , maxvalue(impl::ValueMember(value__, "maxvalue"))
+ , minsize(impl::ValueMember(value__, "minsize"))
+ , maxsize(impl::ValueMember(value__, "maxsize"))
+ , minlength(impl::ValueMember(value__, "minlength"))
+ , maxlength(impl::ValueMember(value__, "maxlength")) {}
+
+VehicleDataItem::~VehicleDataItem() {}
+
+const std::string VehicleDataItem::kInteger = "Integer";
+const std::string VehicleDataItem::kStruct = "Struct";
+const std::string VehicleDataItem::kString = "String";
+const std::string VehicleDataItem::kFloat = "Float";
+const std::string VehicleDataItem::kDouble = "Double";
+const std::string VehicleDataItem::kBoolean = "Boolean";
+
+const std::vector<std::string> VehicleDataItem::kPODTypes = {
+ kInteger, kFloat, kDouble, kString, kBoolean};
+
+Json::Value VehicleDataItem::ToJsonValue() const {
+ Json::Value ret(Json::objectValue);
+ impl::WriteJsonField("name", name, &ret);
+ impl::WriteJsonField("type", type, &ret);
+ impl::WriteJsonField("key", key, &ret);
+ impl::WriteJsonField("array", array, &ret);
+ impl::WriteJsonField("mandatory", mandatory, &ret);
+ impl::WriteJsonField("params", params, &ret);
+ impl::WriteJsonField("since", since, &ret);
+ impl::WriteJsonField("until", until, &ret);
+ impl::WriteJsonField("removed", removed, &ret);
+ impl::WriteJsonField("deprecated", deprecated, &ret);
+ impl::WriteJsonField("minvalue", minvalue, &ret);
+ impl::WriteJsonField("maxvalue", maxvalue, &ret);
+ impl::WriteJsonField("minsize", minsize, &ret);
+ impl::WriteJsonField("maxsize", maxsize, &ret);
+ impl::WriteJsonField("minlength", minlength, &ret);
+ impl::WriteJsonField("maxlength", maxlength, &ret);
+ return ret;
+}
+
+bool VehicleDataItem::operator==(const VehicleDataItem& vd) {
+ return (name == vd.name && type == vd.type && key == vd.key &&
+ mandatory == vd.mandatory && params == vd.params &&
+ array == vd.array && since == vd.since && until == vd.until &&
+ removed == vd.removed && deprecated == vd.deprecated &&
+ minvalue == vd.minvalue && maxvalue == vd.maxvalue &&
+ minsize == vd.minsize && maxsize == vd.maxsize &&
+ minlength == vd.minlength && maxlength == vd.maxlength);
+}
+
+bool VehicleDataItem::is_valid() const {
+ if (!name.is_valid()) {
+ return false;
+ }
+ if (!type.is_valid()) {
+ return false;
+ }
+ if (!key.is_valid()) {
+ return false;
+ }
+ if (!array.is_valid()) {
+ return false;
+ }
+ if (!mandatory.is_valid()) {
+ return false;
+ }
+ if (!params.is_valid()) {
+ return false;
+ }
+ if (!since.is_valid()) {
+ return false;
+ }
+ if (!until.is_valid()) {
+ return false;
+ }
+ if (!removed.is_valid()) {
+ return false;
+ }
+ if (!deprecated.is_valid()) {
+ return false;
+ }
+ if (!minvalue.is_valid()) {
+ return false;
+ }
+ if (!maxvalue.is_valid()) {
+ return false;
+ }
+ if (!minsize.is_valid()) {
+ return false;
+ }
+ if (!maxsize.is_valid()) {
+ return false;
+ }
+ if (!minlength.is_valid()) {
+ return false;
+ }
+ if (!maxlength.is_valid()) {
+ return false;
+ }
+ return Validate();
+}
+
+bool VehicleDataItem::is_initialized() const {
+ return (initialization_state__ != kUninitialized) || (struct_not_empty());
+}
+
+bool VehicleDataItem::struct_not_empty() const {
+ if (!name.is_initialized()) {
+ return false;
+ }
+ if (!type.is_initialized()) {
+ return false;
+ }
+ if (!key.is_initialized()) {
+ return false;
+ }
+ if (!array.is_initialized()) {
+ return false;
+ }
+ if (!mandatory.is_initialized()) {
+ return false;
+ }
+ if (!params.is_initialized()) {
+ return false;
+ }
+ if (!since.is_initialized()) {
+ return false;
+ }
+ if (!until.is_initialized()) {
+ return false;
+ }
+ if (!removed.is_initialized()) {
+ return false;
+ }
+ if (!deprecated.is_initialized()) {
+ return false;
+ }
+ if (!minvalue.is_initialized()) {
+ return false;
+ }
+ if (!maxvalue.is_initialized()) {
+ return false;
+ }
+ if (!minsize.is_initialized()) {
+ return false;
+ }
+ if (!maxsize.is_initialized()) {
+ return false;
+ }
+ if (!minlength.is_initialized()) {
+ return false;
+ }
+ if (!maxlength.is_initialized()) {
+ return false;
+ }
+ return true;
+}
+
+void VehicleDataItem::ReportErrors(rpc::ValidationReport* report__) const {
+ if (!struct_not_empty()) {
+ rpc::CompositeType::ReportErrors(report__);
+ }
+ if (!name.is_valid()) {
+ name.ReportErrors(&report__->ReportSubobject("name"));
+ }
+
+ if (!ValidateNaming(std::string(name))) {
+ report__->set_validation_info(
+ "Invalid name values [" + std::string(name) +
+ "]. It should not contain spaces or invalid chars.");
+ }
+ if (!type.is_valid()) {
+ type.ReportErrors(&report__->ReportSubobject("type"));
+ }
+ if (type.is_initialized() && !ValidateTypes()) {
+ report__->set_validation_info("Unknown type [" + std::string(name) +
+ "]: '" + std::string(type) + "'.");
+ }
+ if (!key.is_valid()) {
+ key.ReportErrors(&report__->ReportSubobject("key"));
+ }
+ if (!ValidateNaming(std::string(key))) {
+ report__->set_validation_info(
+ "Invalid key values [" + std::string(key) +
+ "]. It should not contain spaces or invalid chars.");
+ }
+ if (!array.is_valid()) {
+ array.ReportErrors(&report__->ReportSubobject("array"));
+ }
+ if (!mandatory.is_valid()) {
+ mandatory.ReportErrors(&report__->ReportSubobject("mandatory"));
+ }
+ if (!params.is_valid()) {
+ params.ReportErrors(&report__->ReportSubobject("params"));
+ }
+ if (!since.is_valid()) {
+ since.ReportErrors(&report__->ReportSubobject("since"));
+ }
+ if (!until.is_valid()) {
+ until.ReportErrors(&report__->ReportSubobject("until"));
+ }
+ if (!removed.is_valid()) {
+ removed.ReportErrors(&report__->ReportSubobject("removed"));
+ }
+ if (!deprecated.is_valid()) {
+ deprecated.ReportErrors(&report__->ReportSubobject("deprecated"));
+ }
+ if (!minvalue.is_valid()) {
+ minvalue.ReportErrors(&report__->ReportSubobject("minvalue"));
+ }
+ if (!maxvalue.is_valid()) {
+ maxvalue.ReportErrors(&report__->ReportSubobject("maxvalue"));
+ }
+ if (!minsize.is_valid()) {
+ minsize.ReportErrors(&report__->ReportSubobject("minsize"));
+ }
+ if (!maxsize.is_valid()) {
+ maxsize.ReportErrors(&report__->ReportSubobject("maxsize"));
+ }
+ if (!minlength.is_valid()) {
+ minlength.ReportErrors(&report__->ReportSubobject("minlength"));
+ }
+ if (!maxlength.is_valid()) {
+ maxlength.ReportErrors(&report__->ReportSubobject("maxlength"));
+ }
+}
+
+void VehicleDataItem::SetPolicyTableType(PolicyTableType pt_type) {
+ CompositeType::SetPolicyTableType(pt_type);
+ name.SetPolicyTableType(pt_type);
+ type.SetPolicyTableType(pt_type);
+ key.SetPolicyTableType(pt_type);
+ array.SetPolicyTableType(pt_type);
+ mandatory.SetPolicyTableType(pt_type);
+ params.SetPolicyTableType(pt_type);
+ since.SetPolicyTableType(pt_type);
+ until.SetPolicyTableType(pt_type);
+ removed.SetPolicyTableType(pt_type);
+ deprecated.SetPolicyTableType(pt_type);
+ minvalue.SetPolicyTableType(pt_type);
+ maxvalue.SetPolicyTableType(pt_type);
+ minsize.SetPolicyTableType(pt_type);
+ maxsize.SetPolicyTableType(pt_type);
+ minlength.SetPolicyTableType(pt_type);
+ maxlength.SetPolicyTableType(pt_type);
+}
+
+bool VehicleDataItem::ValidateNaming(std::string str) const {
+ auto contains_spec_chars = [](std::string str) {
+ const auto invalid_chars = "!@#$%^&*";
+ return str.npos != str.find_first_of(invalid_chars);
+ };
+
+ auto contains_spaces = [](std::string str) {
+ const auto found_space =
+ std::find_if(str.begin(), str.end(), [](unsigned char ch) {
+ return std::isspace(ch);
+ });
+
+ return found_space != str.end();
+ };
+
+ auto empty_string = [](std::string str) {
+ str.erase(std::remove_if(str.begin(),
+ str.end(),
+ [](unsigned char ch) { return std::isspace(ch); }),
+ str.end());
+ return str.length() < 1;
+ };
+
+ return !empty_string(str) && !contains_spaces(str) &&
+ !contains_spec_chars(str);
+}
+
+bool VehicleDataItem::ValidateTypes() const {
+ if (IsPrimitiveType() || NULL != EnumSchemaItemFactory::Get(type)) {
+ // params should be empty for POD types
+ // and for enum values, generated from API
+ return (!(params.is_initialized()) || params->empty());
+ }
+
+ if (VehicleDataItem::kStruct == std::string(type)) {
+ return params.is_initialized() && !(params->empty()) && params.is_valid();
+ }
+ return false;
+}
+
+bool VehicleDataItem::IsPrimitiveType() const {
+ return helpers::in_range(kPODTypes, std::string(type));
+}
+
+// VehicleData methods
+VehicleData::VehicleData() : CompositeType(kUninitialized) {}
+
+VehicleData::VehicleData(const VehicleData& vehicle_data)
+ : CompositeType(vehicle_data.initialization_state__)
+ , schema_version(vehicle_data.schema_version)
+ , schema_items(vehicle_data.schema_items) {}
+
+VehicleData::VehicleData(const Json::Value* value__)
+ : CompositeType(InitHelper(value__, &Json::Value::isObject))
+ , schema_version(impl::ValueMember(value__, "schema_version"))
+ , schema_items(impl::ValueMember(value__, "schema_items")) {}
+
+VehicleData::~VehicleData() {}
+
+bool VehicleData::is_valid() const {
+ if (!schema_version.is_valid()) {
+ return false;
+ }
+ if (!schema_items.is_valid()) {
+ return false;
+ }
+ return Validate();
+}
+
+bool VehicleData::is_initialized() const {
+ return (initialization_state__ != kUninitialized) || (!struct_empty());
+}
+
+bool VehicleData::struct_empty() const {
+ if (schema_version.is_initialized()) {
+ return false;
+ }
+ if (schema_items.is_initialized()) {
+ return false;
+ }
+ return true;
+}
+
+Json::Value VehicleData::ToJsonValue() const {
+ Json::Value ret(Json::objectValue);
+ impl::WriteJsonField("schema_version", schema_version, &ret);
+ impl::WriteJsonField("schema_items", schema_items, &ret);
+ return ret;
+}
+
+void VehicleData::ReportErrors(rpc::ValidationReport* report__) const {
+ if (struct_empty()) {
+ rpc::CompositeType::ReportErrors(report__);
+ }
+ const auto pt_type = GetPolicyTableType();
+ const auto pt_type_str = PolicyTableTypeToString(pt_type);
+ std::string validation_info = "";
+
+ if (PT_SNAPSHOT == pt_type) {
+ if (schema_items.is_initialized()) {
+ validation_info +=
+ "; schema_items " + omitted_validation_info + pt_type_str;
+ }
+ if (!schema_version.is_initialized()) {
+ validation_info +=
+ "; schema_version " + required_validation_info + pt_type_str;
+ }
+ report__->set_validation_info(validation_info);
+ }
+ if (PT_UPDATE == pt_type || PT_PRELOADED == pt_type) {
+ if ((schema_version.is_initialized() && !schema_items.is_initialized()) ||
+ (!schema_version.is_initialized() && schema_items.is_initialized())) {
+ validation_info +=
+ "; if schema_version exist, schema_items should "
+ "also exist in " +
+ pt_type_str;
+ }
+ report__->set_validation_info(validation_info);
+ }
+
+ if (!schema_version.is_valid()) {
+ schema_version.ReportErrors(&report__->ReportSubobject("schema_version"));
+ }
+ if (!schema_items.is_valid()) {
+ schema_items.ReportErrors(&report__->ReportSubobject("schema_items"));
+ }
+}
+
+void VehicleData::SetPolicyTableType(PolicyTableType pt_type) {
+ CompositeType::SetPolicyTableType(pt_type);
+ schema_version.SetPolicyTableType(pt_type);
+ schema_items.SetPolicyTableType(pt_type);
+}
+
// PolicyTable methods
PolicyTable::PolicyTable() : CompositeType(kUninitialized) {}
@@ -2141,7 +2624,8 @@ PolicyTable::PolicyTable(const Json::Value* value__)
, module_meta(impl::ValueMember(value__, "module_meta"))
, usage_and_error_counts(
impl::ValueMember(value__, "usage_and_error_counts"))
- , device_data(impl::ValueMember(value__, "device_data")) {}
+ , device_data(impl::ValueMember(value__, "device_data"))
+ , vehicle_data(impl::ValueMember(value__, "vehicle_data")) {}
Json::Value PolicyTable::ToJsonValue() const {
Json::Value result__(Json::objectValue);
@@ -2154,6 +2638,7 @@ Json::Value PolicyTable::ToJsonValue() const {
impl::WriteJsonField(
"usage_and_error_counts", usage_and_error_counts, &result__);
impl::WriteJsonField("device_data", device_data, &result__);
+ impl::WriteJsonField("vehicle_data", vehicle_data, &result__);
return result__;
}
@@ -2179,6 +2664,9 @@ bool PolicyTable::is_valid() const {
if (!device_data.is_valid()) {
return false;
}
+ if (!vehicle_data.is_valid()) {
+ return false;
+ }
return Validate();
}
@@ -2211,6 +2699,10 @@ bool PolicyTable::struct_empty() const {
if (device_data.is_initialized()) {
return false;
}
+
+ if (vehicle_data.is_initialized()) {
+ return false;
+ }
return true;
}
@@ -2253,6 +2745,9 @@ void PolicyTable::ReportErrors(rpc::ValidationReport* report__) const {
if (!device_data.is_valid()) {
device_data.ReportErrors(&report__->ReportSubobject("device_data"));
}
+ if (!vehicle_data.is_valid()) {
+ vehicle_data.ReportErrors(&report__->ReportSubobject("vehicle_data"));
+ }
}
void PolicyTable::SetPolicyTableType(PolicyTableType pt_type) {
@@ -2264,6 +2759,7 @@ void PolicyTable::SetPolicyTableType(PolicyTableType pt_type) {
module_meta.SetPolicyTableType(pt_type);
usage_and_error_counts.SetPolicyTableType(pt_type);
device_data.SetPolicyTableType(pt_type);
+ vehicle_data.SetPolicyTableType(pt_type);
}
// Table methods
diff --git a/src/components/policy/policy_external/src/policy_table/validation.cc b/src/components/policy/policy_external/src/policy_table/validation.cc
index f9c3f82793..12a79748d7 100644
--- a/src/components/policy/policy_external/src/policy_table/validation.cc
+++ b/src/components/policy/policy_external/src/policy_table/validation.cc
@@ -221,6 +221,15 @@ bool RpcParameters::Validate() const {
bool Rpcs::Validate() const {
return true;
}
+
+bool EndpointProperty::Validate() const {
+ if (!version.is_valid()) {
+ return false;
+ }
+
+ return true;
+}
+
bool ModuleConfig::Validate() const {
switch (GetPolicyTableType()) {
case PT_PRELOADED: {
@@ -258,6 +267,14 @@ bool ModuleConfig::Validate() const {
}
}
+ if (endpoint_properties.is_initialized()) {
+ const auto& endpoint_property =
+ endpoint_properties->find(kDefaultOemMappingServiceName);
+ if (endpoint_properties->end() != endpoint_property) {
+ return (*endpoint_property).second.version.is_initialized();
+ }
+ }
+
return true;
}
@@ -304,6 +321,40 @@ bool ConsentRecords::Validate() const {
bool DeviceParams::Validate() const {
return true;
}
+
+bool VehicleDataItem::Validate() const {
+ if (!ValidateNaming(std::string(name))) {
+ return false;
+ };
+
+ if (!ValidateNaming(std::string(key))) {
+ return false;
+ };
+
+ if (!ValidateTypes()) {
+ LOG4CXX_ERROR(
+ logger_,
+ "Unknown type: " << std::string(type) << " of " << std::string(key));
+ return false;
+ }
+ return true;
+}
+
+bool VehicleData::Validate() const {
+ const PolicyTableType policy_table_type = GetPolicyTableType();
+ bool result = true;
+ if (PT_SNAPSHOT == policy_table_type) {
+ result =
+ (!schema_items.is_initialized()) && schema_version.is_initialized();
+ }
+ if (PT_UPDATE == policy_table_type || PT_PRELOADED == policy_table_type) {
+ result =
+ (schema_version.is_initialized() && schema_items.is_initialized()) ||
+ (!schema_version.is_initialized() && !schema_items.is_initialized());
+ }
+ return result;
+}
+
bool PolicyTable::Validate() const {
PolicyTableType policy_table_type = GetPolicyTableType();
diff --git a/src/components/policy/policy_external/src/sql_pt_queries.cc b/src/components/policy/policy_external/src/sql_pt_queries.cc
index 5e89d0b372..e5fde1abf9 100644
--- a/src/components/policy/policy_external/src/sql_pt_queries.cc
+++ b/src/components/policy/policy_external/src/sql_pt_queries.cc
@@ -386,6 +386,11 @@ const std::string kCreateSchema =
"); "
"CREATE INDEX IF NOT EXISTS `endpoint.fk_endpoint_application1_idx` "
" ON `endpoint`(`application_id` COLLATE NOCASE); "
+ /*endpoint properties*/
+ "CREATE TABLE IF NOT EXISTS `endpoint_properties`( "
+ " `service` VARCHAR(100) NOT NULL, "
+ " `version` VARCHAR(100) NOT NULL "
+ ");"
"CREATE TABLE IF NOT EXISTS `message`( "
" `id` INTEGER PRIMARY KEY NOT NULL, "
" `tts` TEXT, "
@@ -449,6 +454,40 @@ const std::string kCreateSchema =
" `entity_id` INTEGER NOT NULL, "
" `on_off` TEXT NOT NULL "
" ); "
+ /*vehicle data*/
+ "CREATE TABLE IF NOT EXISTS `vehicle_data`( "
+ " `schema_version` VARCHAR(100) NOT NULL "
+ ");"
+ /* vehicle data item definition*/
+ "CREATE TABLE IF NOT EXISTS `vehicle_data_item_definition`( "
+ " `name` VARCHAR(255) NOT NULL, "
+ " `type` VARCHAR(255) NOT NULL, "
+ " `key` VARCHAR(255) NOT NULL, "
+ " `mandatory` BOOL NOT NULL, "
+ " `array` BOOL, "
+ " `since` VARCHAR(45), "
+ " `until` VARCHAR(45), "
+ " `removed` BOOL, "
+ " `deprecated` BOOL, "
+ " `minvalue` INTEGER, "
+ " `maxvalue` INTEGER, "
+ " `minsize` INTEGER, "
+ " `maxsize` INTEGER, "
+ " `minlength` INTEGER, "
+ " `maxlength` INTEGER "
+ "); "
+ "CREATE TABLE IF NOT EXISTS `vehicle_data_item_parameters`( "
+ " `parent_name` VARCHAR(255) NOT NULL, "
+ " `parent_key` VARCHAR(255) NOT NULL, "
+ " `param_name` VARCHAR(255) NOT NULL, "
+ " `param_key` VARCHAR(255) NOT NULL, "
+ " CONSTRAINT `fk_vdi_id` "
+ " FOREIGN KEY(`parent_name`, `parent_key`) "
+ " REFERENCES `vehicle_data_item_definition`(`name`, `key`), "
+ " CONSTRAINT `fk_vdi_param_id` "
+ " FOREIGN KEY(`param_name`, `param_key`) "
+ " REFERENCES `vehicle_data_item_definition`(`name`, `key`) "
+ "); "
"COMMIT;";
const std::string kInsertInitData =
@@ -464,6 +503,8 @@ const std::string kInsertInitData =
" `exchange_after_x_ignition_cycles`, `exchange_after_x_kilometers`, "
" `exchange_after_x_days`, `timeout_after_x_seconds`)"
" VALUES(1, 0, 0, 0, 0, 0); "
+ "INSERT OR IGNORE INTO `vehicle_data` ("
+ " `schema_version`) VALUES('0'); "
"INSERT OR IGNORE INTO `priority`(`value`) VALUES ('EMERGENCY'); "
"INSERT OR IGNORE INTO `priority`(`value`) VALUES ('NAVIGATION'); "
"INSERT OR IGNORE INTO `priority`(`value`) VALUES ('VOICECOMMUNICATION'); "
@@ -528,6 +569,7 @@ const std::string kDropSchema =
"DROP TABLE IF EXISTS `message`; "
"DROP INDEX IF EXISTS `endpoint.fk_endpoint_application1_idx`; "
"DROP TABLE IF EXISTS `endpoint`; "
+ "DROP TABLE IF EXISTS `endpoint_properties`; "
"DROP INDEX IF EXISTS `consent_group.fk_consent_group_device1_idx`; "
"DROP INDEX IF EXISTS "
"`consent_group.fk_consent_group_functional_group1_idx`; "
@@ -593,6 +635,9 @@ const std::string kDropSchema =
"DROP TABLE IF EXISTS `device`; "
"DROP TABLE IF EXISTS `_internal_data`; "
"DROP TABLE IF EXISTS `_internal_external_consent_status`; "
+ "DROP TABLE IF EXISTS `vehicle_data`; "
+ "DROP TABLE IF EXISTS `vehicle_data_item_definition`; "
+ "DROP TABLE IF EXISTS `vehicle_data_item_parameters`; "
"COMMIT; "
"VACUUM;";
@@ -601,6 +646,7 @@ const std::string kDeleteData =
"DELETE FROM `message`; "
"DELETE FROM `module_type`; "
"DELETE FROM `endpoint`; "
+ "DELETE FROM `endpoint_properties`; "
"DELETE FROM `consent_group`; "
"DELETE FROM `external_consent_status_group`; "
"DELETE FROM `external_consent_entities`; "
@@ -627,6 +673,9 @@ const std::string kDeleteData =
"DELETE FROM `usage_and_error_count`; "
"DELETE FROM `device`; "
"DELETE FROM `request_type`; "
+ "DELETE FROM `vehicle_data`; "
+ "DELETE FROM `vehicle_data_item_definition`; "
+ "DELETE FROM `vehicle_data_item_parameters`; "
"COMMIT; "
"VACUUM;";
@@ -634,6 +683,82 @@ const std::string kCheckDBIntegrity = "PRAGMA integrity_check";
const std::string kCheckPgNumber = "PRAGMA page_count";
+const std::string kSelectEndpointProperties =
+ "SELECT `service`, `version` FROM `endpoint_properties`";
+
+const std::string kSelectVehicleDataSchemaVersion =
+ "SELECT `schema_version` FROM `vehicle_data` ";
+
+const std::string kSelectVehicleDataItem =
+ "SELECT * FROM `vehicle_data_item_definition` "
+ "WHERE `key` = ? AND `name` = ?";
+
+const std::string kSelectVehicleDataItemWithVersion =
+ "SELECT * FROM `vehicle_data_item_definition` "
+ "WHERE `name` IS ? AND `key` IS ? AND `since` IS ? AND `until` IS ?";
+
+const std::string kSelectVehicleDataItemParams =
+ "SELECT * FROM `vehicle_data_item_parameters` "
+ "WHERE `parent_name` = ? AND `parent_key` = ?";
+
+const std::string kSelectCompositeVehicleDataItemsKey =
+ "SELECT DISTINCT `parent_name`, `parent_key` FROM "
+ "`vehicle_data_item_parameters` "
+ "LEFT JOIN "
+ "(SELECT DISTINCT `param_name`, `param_key` FROM "
+ "`vehicle_data_item_parameters`) `vdi_params` ON "
+ "`vehicle_data_item_parameters`.`parent_name` = `vdi_params`.`param_name` "
+ "AND "
+ "`vehicle_data_item_parameters`.`parent_key` = `vdi_params`.`param_key` "
+ "WHERE `vdi_params`.`param_key` IS NULL";
+
+const std::string kSelectPrimitiveVehicleDataItems =
+ "SELECT * FROM `vehicle_data_item_definition` "
+ "LEFT JOIN ( "
+ "SELECT `parent_name`, `parent_key` FROM `vehicle_data_item_parameters` "
+ "UNION "
+ "SELECT `param_name`, `param_key` FROM `vehicle_data_item_parameters`) "
+ "`vdi_params` ON "
+ "`vehicle_data_item_definition`.`name` = `vdi_params`.`parent_name` "
+ "AND "
+ "`vehicle_data_item_definition`.`key` = `vdi_params`.`parent_key` "
+ "WHERE `vdi_params`.`parent_key` IS NULL";
+
+const std::string kInsertVehicleDataSchemaVersion =
+ "UPDATE `vehicle_data` SET `schema_version` = ?";
+
+const std::string kInsertEndpointVersion =
+ "INSERT OR REPLACE INTO `endpoint_properties`(`service`, "
+ "`version`) "
+ "VALUES(?, ?)";
+
+const std::string kInsertVehicleDataItem =
+ "INSERT INTO `vehicle_data_item_definition` ("
+ " `name`, "
+ " `type`, "
+ " `key`, "
+ " `mandatory`, "
+ " `array`, "
+ " `since`, "
+ " `until`, "
+ " `removed`, "
+ " `deprecated`, "
+ " `minvalue`, "
+ " `maxvalue`, "
+ " `minsize`, "
+ " `maxsize`, "
+ " `minlength`, "
+ " `maxlength`) "
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ";
+
+const std::string kInsertVehicleDataItemParams =
+ "INSERT INTO `vehicle_data_item_parameters` ("
+ " `parent_name`, "
+ " `parent_key`, "
+ " `param_name`, "
+ " `param_key`) "
+ "VALUES (?, ?, ?, ?) ";
+
const std::string kSelectRpc =
"SELECT DISTINCT `rpc`.`parameter` FROM `rpc` "
" JOIN `app_group` AS `g` ON (`g`.`functional_group_id` = "
@@ -924,6 +1049,12 @@ const std::string kDeleteAppServiceNames = "DELETE FROM `app_service_names`";
const std::string kDeleteAppServiceHandledRpcs =
"DELETE FROM `app_service_handled_rpcs`";
+const std::string kDeleteVehicleDataItems =
+ "DELETE FROM `vehicle_data_item_definition`";
+
+const std::string kDeleteVehicleDataItemParams =
+ "DELETE FROM `vehicle_data_item_parameters`";
+
const std::string kSelectApplicationRevoked =
"SELECT `is_revoked` FROM `application` WHERE `id` = ?";
diff --git a/src/components/policy/policy_external/src/sql_pt_representation.cc b/src/components/policy/policy_external/src/sql_pt_representation.cc
index f2a2d34145..7874abc4ee 100644
--- a/src/components/policy/policy_external/src/sql_pt_representation.cc
+++ b/src/components/policy/policy_external/src/sql_pt_representation.cc
@@ -451,16 +451,6 @@ bool SQLPTRepresentation::Close() {
return db_->LastError().number() == utils::dbms::OK;
}
-const VehicleInfo SQLPTRepresentation::GetVehicleInfo() const {
- policy_table::ModuleConfig module_config;
- GatherModuleConfig(&module_config);
- VehicleInfo vehicle_info;
- vehicle_info.vehicle_make = *module_config.vehicle_make;
- vehicle_info.vehicle_model = *module_config.vehicle_model;
- vehicle_info.vehicle_year = *module_config.vehicle_year;
- return vehicle_info;
-}
-
bool SQLPTRepresentation::Drop() {
utils::dbms::SQLQuery query(db());
if (!query.Exec(sql_pt::kDropSchema)) {
@@ -525,6 +515,11 @@ std::shared_ptr<policy_table::Table> SQLPTRepresentation::GenerateSnapshot()
GatherConsumerFriendlyMessages(
&*table->policy_table.consumer_friendly_messages);
GatherApplicationPoliciesSection(&table->policy_table.app_policies_section);
+ GatherVehicleData(&*table->policy_table.vehicle_data);
+ if (!table->policy_table.vehicle_data.is_initialized()) {
+ rpc::Optional<rpc::String<0, 100> > null_version;
+ table->policy_table.vehicle_data->schema_version = null_version;
+ }
return table;
}
@@ -569,6 +564,18 @@ void SQLPTRepresentation::GatherModuleConfig(
}
}
+ utils::dbms::SQLQuery endpoint_properties(db());
+ if (!endpoint_properties.Prepare(sql_pt::kSelectEndpointProperties)) {
+ LOG4CXX_ERROR(logger_, "Incorrect statement for Endpoint properties");
+ } else {
+ while (endpoint_properties.Next()) {
+ const std::string& service = endpoint_properties.GetString(0);
+ const std::string& version = endpoint_properties.GetString(1);
+ auto& ep_properties = (*config->endpoint_properties);
+ *ep_properties[service].version = version;
+ }
+ }
+
utils::dbms::SQLQuery notifications(db());
if (!notifications.Prepare(sql_pt::kSelectNotificationsPerMin)) {
LOG4CXX_WARN(logger_, "Incorrect select statement for notifications");
@@ -664,16 +671,15 @@ bool SQLPTRepresentation::GatherFunctionalGroupings(
}
}
if (!rpcs.IsNull(2)) {
- policy_table::Parameter param;
- if (policy_table::EnumFromJsonString(rpcs.GetString(2), &param)) {
- // EMPTY is a special mark to specify that 'parameters' section is
- // present, but has no parameters. It is not valid parameter value.
- if (policy_table::P_EMPTY == param) {
- (*rpcs_tbl.rpcs[rpcs.GetString(0)].parameters).mark_initialized();
- continue;
- }
- InsertUnique(param, &(*rpcs_tbl.rpcs[rpcs.GetString(0)].parameters));
+ std::string param = rpcs.GetString(2);
+ // EMPTY is a special mark to specify that 'parameters' section is
+ // present, but has no parameters. It is not valid parameter value.
+ if (policy_table::EnumToJsonString(policy_table::P_EMPTY) == param) {
+ (*rpcs_tbl.rpcs[rpcs.GetString(0)].parameters).mark_initialized();
+ continue;
}
+ InsertUnique(rpcs.GetString(2),
+ &(*rpcs_tbl.rpcs[rpcs.GetString(0)].parameters));
}
}
@@ -832,6 +838,43 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection(
return true;
}
+bool SQLPTRepresentation::GatherVehicleData(
+ policy_table::VehicleData* vehicle_data) const {
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kSelectVehicleDataSchemaVersion) ||
+ !query.Next()) {
+ LOG4CXX_ERROR(logger_,
+ "Incorrect statement for vehicle data schema version");
+ return false;
+ }
+ *vehicle_data->schema_version = query.GetString(0);
+
+ vehicle_data->mark_initialized();
+ return GatherVehicleDataItems(&*vehicle_data->schema_items);
+}
+
+bool SQLPTRepresentation::GatherVehicleDataItems(
+ policy_table::VehicleDataItems* vehicle_data_items) const {
+ auto parameterized_vdi = SelectCompositeVehicleDataItems();
+ if (!parameterized_vdi.is_initialized()) {
+ return false;
+ }
+
+ auto non_parameterized_vdi = SelectPrimitiveVehicleDataItems();
+ if (!non_parameterized_vdi.is_initialized()) {
+ return false;
+ }
+
+ vehicle_data_items->insert(vehicle_data_items->end(),
+ parameterized_vdi.begin(),
+ parameterized_vdi.end());
+ vehicle_data_items->insert(vehicle_data_items->end(),
+ non_parameterized_vdi.begin(),
+ non_parameterized_vdi.end());
+
+ return true;
+}
+
bool SQLPTRepresentation::Save(const policy_table::Table& table) {
LOG4CXX_AUTO_TRACE(logger_);
db_->BeginTransaction();
@@ -866,6 +909,10 @@ bool SQLPTRepresentation::Save(const policy_table::Table& table) {
db_->RollbackTransaction();
return false;
}
+ if (!SaveVehicleData(*table.policy_table.vehicle_data)) {
+ db_->RollbackTransaction();
+ return false;
+ }
db_->CommitTransaction();
return true;
}
@@ -966,8 +1013,7 @@ bool SQLPTRepresentation::SaveRpcs(int64_t group_id,
query_parameter.Bind(0, it->first);
query_parameter.Bind(
1, std::string(policy_table::EnumToJsonString(*hmi_it)));
- query_parameter.Bind(
- 2, std::string(policy_table::EnumToJsonString(*ps_it)));
+ query_parameter.Bind(2, std::string(*ps_it));
query_parameter.Bind(3, group_id);
if (!query_parameter.Exec() || !query_parameter.Reset()) {
LOG4CXX_WARN(logger_, "Incorrect insert into rpc with parameter");
@@ -1185,6 +1231,44 @@ bool policy::SQLPTRepresentation::SaveDevicePolicy(
return true;
}
+bool SQLPTRepresentation::SaveVehicleDataItems(
+ const policy_table::VehicleDataItems& vehicle_data_items) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ DeleteVehicleDataItems();
+ for (const auto& item : vehicle_data_items) {
+ if (!InsertVehicleDataItem(item)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+bool SQLPTRepresentation::SaveVehicleData(
+ const policy_table::VehicleData& vehicle_data) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (vehicle_data.is_initialized() &&
+ vehicle_data.schema_version.is_initialized()) {
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kInsertVehicleDataSchemaVersion)) {
+ LOG4CXX_WARN(logger_,
+ "Incorrect insert of schema_version to vehicle_data.");
+ return false;
+ }
+ query.Bind(0, *vehicle_data.schema_version);
+ if (!query.Exec() || !query.Reset()) {
+ LOG4CXX_WARN(logger_, "Failed to insert schema_version to vehicle_data.");
+ return false;
+ }
+ }
+
+ auto vehicle_data_items = vehicle_data.is_initialized() &&
+ vehicle_data.schema_items.is_initialized()
+ ? *(vehicle_data.schema_items)
+ : policy_table::VehicleDataItems();
+
+ return SaveVehicleDataItems(vehicle_data_items);
+}
+
bool SQLPTRepresentation::SaveAppGroup(
const std::string& app_id, const policy_table::Strings& app_groups) {
utils::dbms::SQLQuery query(db());
@@ -1308,7 +1392,9 @@ bool SQLPTRepresentation::SaveRequestSubType(
} else if (request_subtypes.is_initialized()) {
LOG4CXX_WARN(logger_, "Request subtypes empty.");
query.Bind(0, app_id);
- query.Bind(1, std::string("EMPTY"));
+ query.Bind(1,
+ std::string(policy_table::EnumToJsonString(
+ policy_table::RequestType::RT_EMPTY)));
if (!query.Exec() || !query.Reset()) {
LOG4CXX_WARN(logger_, "Incorrect insert into request subtypes.");
return false;
@@ -1451,6 +1537,10 @@ bool SQLPTRepresentation::SaveModuleConfig(
return false;
}
+ if (!SaveServiceEndpointProperties(*config.endpoint_properties)) {
+ return false;
+ }
+
return true;
}
@@ -1489,6 +1579,31 @@ bool SQLPTRepresentation::SaveServiceEndpoints(
return true;
}
+bool SQLPTRepresentation::SaveServiceEndpointProperties(
+ const policy_table::ServiceEndpointProperties& endpoint_properties) {
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kInsertEndpointVersion)) {
+ LOG4CXX_WARN(
+ logger_,
+ "Incorrect insert of endpoint property to endpoint_properties.");
+ return false;
+ }
+
+ for (auto& endpoint_property : endpoint_properties) {
+ query.Bind(0, endpoint_property.first);
+ query.Bind(1, endpoint_property.second.version);
+
+ if (!query.Exec() || !query.Reset()) {
+ LOG4CXX_WARN(
+ logger_,
+ "Failed to insert endpoint property into endpoint_properties.");
+ return false;
+ }
+ }
+
+ return true;
+}
+
bool SQLPTRepresentation::SaveConsumerFriendlyMessages(
const policy_table::ConsumerFriendlyMessages& messages) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -1575,6 +1690,120 @@ bool SQLPTRepresentation::SaveLanguage(const std::string& code) {
return true;
}
+policy_table::VehicleDataItem SQLPTRepresentation::PopulateVDIFromQuery(
+ const utils::dbms::SQLQuery& query) const {
+ policy_table::VehicleDataItem result;
+
+ result.name = query.GetString(0);
+ result.type = query.GetString(1);
+ result.key = query.GetString(2);
+ result.mandatory = query.GetBoolean(3);
+
+ if (!query.IsNull(4)) {
+ *result.array = query.GetBoolean(4);
+ }
+ if (!query.IsNull(5)) {
+ *result.since = query.GetString(5);
+ }
+ if (!query.IsNull(6)) {
+ *result.until = query.GetString(6);
+ }
+ if (!query.IsNull(7)) {
+ *result.removed = query.GetBoolean(7);
+ }
+ if (!query.IsNull(8)) {
+ *result.deprecated = query.GetBoolean(8);
+ }
+ if (!query.IsNull(9)) {
+ *result.minvalue = query.GetInteger(9);
+ }
+ if (!query.IsNull(10)) {
+ *result.maxvalue = query.GetInteger(10);
+ }
+ if (!query.IsNull(11)) {
+ *result.minsize = query.GetUInteger(11);
+ }
+ if (!query.IsNull(12)) {
+ *result.maxsize = query.GetUInteger(12);
+ }
+ if (!query.IsNull(13)) {
+ *result.minlength = query.GetUInteger(13);
+ }
+ if (!query.IsNull(14)) {
+ *result.maxlength = query.GetUInteger(14);
+ }
+ result.params->mark_initialized();
+
+ result.mark_initialized();
+ return result;
+}
+
+policy_table::VehicleDataItems
+SQLPTRepresentation::SelectCompositeVehicleDataItems() const {
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kSelectCompositeVehicleDataItemsKey)) {
+ LOG4CXX_ERROR(logger_,
+ "Incorrect statement for parameterized vehicle data items");
+ return policy_table::VehicleDataItems();
+ }
+
+ policy_table::VehicleDataItems result;
+ result.mark_initialized();
+
+ while (query.Next()) {
+ const auto vdi = GetVehicleDataItem(query.GetString(0), query.GetString(1));
+ if (!vdi.is_initialized()) {
+ return policy_table::VehicleDataItems();
+ }
+ for (const auto& item : vdi) {
+ result.push_back(item);
+ }
+ }
+
+ return result;
+}
+
+policy_table::VehicleDataItems
+SQLPTRepresentation::SelectPrimitiveVehicleDataItems() const {
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kSelectPrimitiveVehicleDataItems)) {
+ LOG4CXX_ERROR(
+ logger_,
+ "Incorrect statement for non parameterized vehicle data items");
+ return policy_table::VehicleDataItems();
+ }
+
+ auto result = policy_table::VehicleDataItems();
+ result.mark_initialized();
+
+ while (query.Next()) {
+ const auto vdi = PopulateVDIFromQuery(query);
+ if (!vdi.is_initialized()) {
+ return policy_table::VehicleDataItems();
+ }
+ result.push_back(vdi);
+ }
+ return result;
+}
+
+bool SQLPTRepresentation::DeleteVehicleDataItems() const {
+ utils::dbms::SQLQuery query(db());
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ if (!query.Exec(sql_pt::kDeleteVehicleDataItems)) {
+ LOG4CXX_ERROR(logger_,
+ "Failed clearing database: " << query.LastError().text());
+ return false;
+ }
+
+ if (!query.Exec(sql_pt::kDeleteVehicleDataItemParams)) {
+ LOG4CXX_ERROR(logger_,
+ "Failed clearing database: " << query.LastError().text());
+ return false;
+ }
+ return true;
+}
+
bool SQLPTRepresentation::SaveMessageString(
const std::string& type,
const std::string& lang,
@@ -1817,7 +2046,8 @@ bool SQLPTRepresentation::GatherRequestSubType(
query.Bind(0, app_id);
while (query.Next()) {
const std::string request_subtype = query.GetString(0);
- if ("EMPTY" == request_subtype) {
+ if (policy_table::EnumToJsonString(policy_table::RequestType::RT_EMPTY) ==
+ request_subtype) {
request_subtypes->mark_initialized();
continue;
}
@@ -2306,6 +2536,190 @@ bool SQLPTRepresentation::UpdateDBVersion() const {
return true;
}
+policy_table::VehicleDataItems SQLPTRepresentation::GetVehicleDataItem(
+ const std::string& name, const std::string& key) const {
+ policy_table::VehicleDataItems result;
+ utils::dbms::SQLQuery query(db());
+
+ if (!query.Prepare(sql_pt::kSelectVehicleDataItem)) {
+ LOG4CXX_ERROR(logger_,
+ "Incorrent select statement of vehicle data item. "
+ << query.LastError().text());
+ return result;
+ }
+
+ query.Bind(0, key);
+ query.Bind(1, name);
+
+ while (query.Next()) {
+ auto vdi = PopulateVDIFromQuery(query);
+ if (!vdi.is_initialized()) {
+ return policy_table::VehicleDataItems();
+ }
+
+ utils::dbms::SQLQuery param_query(db());
+ if (policy_table::VehicleDataItem::kStruct ==
+ static_cast<std::string>(vdi.type)) {
+ if (!param_query.Prepare(sql_pt::kSelectVehicleDataItemParams)) {
+ LOG4CXX_ERROR(logger_,
+ "Incorrent select statement of vehicle data item. "
+ << param_query.LastError().text());
+ return policy_table::VehicleDataItems();
+ }
+
+ param_query.Bind(0, name);
+ param_query.Bind(1, key);
+
+ while (param_query.Next()) {
+ const auto param_with_diff_versions = GetVehicleDataItem(
+ param_query.GetString(2), param_query.GetString(3));
+ if (!param_with_diff_versions.is_initialized()) {
+ return policy_table::VehicleDataItems();
+ }
+ for (const auto& param : param_with_diff_versions) {
+ vdi.params->push_back(param);
+ }
+ }
+ }
+ result.push_back(vdi);
+ }
+ if (!result.empty()) {
+ result.mark_initialized();
+ }
+
+ return result;
+}
+
+bool SQLPTRepresentation::InsertVehicleDataItem(
+ const policy_table::VehicleDataItem& vehicle_data_item) {
+ utils::dbms::SQLQuery query(db());
+
+ if (!vehicle_data_item.is_initialized() || !vehicle_data_item.is_valid()) {
+ LOG4CXX_ERROR(logger_, "Vehicle data item is not initialized.");
+ return false;
+ }
+
+ if (VehicleDataItemExists(vehicle_data_item)) {
+ LOG4CXX_INFO(logger_,
+ static_cast<std::string>(vehicle_data_item.key)
+ << " is already stored.");
+ return true;
+ }
+
+ if (!query.Prepare(sql_pt::kInsertVehicleDataItem)) {
+ LOG4CXX_ERROR(logger_,
+ "Incorrent select statement of vehicle data item. "
+ << query.LastError().text());
+ return false;
+ }
+
+ query.Bind(0, vehicle_data_item.name);
+ query.Bind(1, vehicle_data_item.type);
+ query.Bind(2, vehicle_data_item.key);
+ query.Bind(3, vehicle_data_item.mandatory);
+ vehicle_data_item.array.is_initialized()
+ ? query.Bind(4, *vehicle_data_item.array)
+ : query.Bind(4);
+ vehicle_data_item.since.is_initialized()
+ ? query.Bind(5, *vehicle_data_item.since)
+ : query.Bind(5);
+ vehicle_data_item.until.is_initialized()
+ ? query.Bind(6, *vehicle_data_item.until)
+ : query.Bind(6);
+ vehicle_data_item.removed.is_initialized()
+ ? query.Bind(7, *vehicle_data_item.removed)
+ : query.Bind(7);
+ vehicle_data_item.deprecated.is_initialized()
+ ? query.Bind(8, *vehicle_data_item.deprecated)
+ : query.Bind(8);
+ vehicle_data_item.minvalue.is_initialized()
+ ? query.Bind(9, *vehicle_data_item.minvalue)
+ : query.Bind(9);
+ vehicle_data_item.maxvalue.is_initialized()
+ ? query.Bind(10, *vehicle_data_item.maxvalue)
+ : query.Bind(10);
+ vehicle_data_item.minsize.is_initialized()
+ ? query.Bind(11, static_cast<int64_t>(*vehicle_data_item.minsize))
+ : query.Bind(11);
+ vehicle_data_item.maxsize.is_initialized()
+ ? query.Bind(12, static_cast<int64_t>(*vehicle_data_item.maxsize))
+ : query.Bind(12);
+ vehicle_data_item.minlength.is_initialized()
+ ? query.Bind(13, static_cast<int64_t>(*vehicle_data_item.minlength))
+ : query.Bind(13);
+ vehicle_data_item.maxlength.is_initialized()
+ ? query.Bind(14, static_cast<int64_t>(*vehicle_data_item.maxlength))
+ : query.Bind(14);
+
+ if (!query.Exec() || !query.Reset()) {
+ LOG4CXX_ERROR(logger_,
+ "Failed to insert vehicle data item: "
+ << static_cast<std::string>(vehicle_data_item.key)
+ << ". Error: " << query.LastError().text());
+ return false;
+ }
+
+ if (vehicle_data_item.params->is_initialized()) {
+ for (const auto& param : *(vehicle_data_item.params)) {
+ if (!InsertVehicleDataItem(param)) {
+ return false;
+ }
+
+ if (!query.Prepare(sql_pt::kInsertVehicleDataItemParams)) {
+ LOG4CXX_ERROR(logger_,
+ "Incorrent select statement of vehicle data item. "
+ << query.LastError().text());
+ return false;
+ }
+
+ query.Bind(0, vehicle_data_item.name);
+ query.Bind(1, vehicle_data_item.key);
+ query.Bind(2, param.name);
+ query.Bind(3, param.key);
+
+ if (!query.Exec() || !query.Reset()) {
+ LOG4CXX_ERROR(
+ logger_,
+ "Failed to insert to vehicle data item relations helper table: "
+ << static_cast<std::string>(param.key)
+ << ". Error: " << query.LastError().text());
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+bool SQLPTRepresentation::VehicleDataItemExists(
+ const policy_table::VehicleDataItem& vehicle_data_item) const {
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kSelectVehicleDataItemWithVersion)) {
+ LOG4CXX_ERROR(logger_,
+ "Incorrent select statement for vehicle data item. "
+ << query.LastError().text());
+ return false;
+ }
+
+ query.Bind(0, vehicle_data_item.name);
+ query.Bind(1, vehicle_data_item.key);
+ vehicle_data_item.since.is_initialized()
+ ? query.Bind(2, std::string(*vehicle_data_item.since))
+ : query.Bind(2);
+ vehicle_data_item.until.is_initialized()
+ ? query.Bind(3, std::string(*vehicle_data_item.until))
+ : query.Bind(3);
+
+ if (!query.Exec()) {
+ LOG4CXX_ERROR(logger_,
+ "Failed to retrieve vehicle data item: "
+ << std::string(vehicle_data_item.key)
+ << ". Error: " << query.LastError().text());
+ return false;
+ }
+ return !query.IsNull(0);
+}
+
const int32_t SQLPTRepresentation::GetDBVersion() const {
return utils::Djb2HashFromString(sql_pt::kCreateSchema);
}
diff --git a/src/components/policy/policy_external/test/include/policy/mock_pt_representation.h b/src/components/policy/policy_external/test/include/policy/mock_pt_representation.h
index 33d4c46e64..0b3fe7aef7 100644
--- a/src/components/policy/policy_external/test/include/policy/mock_pt_representation.h
+++ b/src/components/policy/policy_external/test/include/policy/mock_pt_representation.h
@@ -66,7 +66,6 @@ class MockPTRepresentation : virtual public ::policy::PTRepresentation {
MOCK_METHOD1(SecondsBetweenRetries, bool(std::vector<int>* seconds));
MOCK_METHOD2(GetPriority,
bool(const std::string& app_id, std::string* priority));
- MOCK_CONST_METHOD0(GetVehicleInfo, const ::policy::VehicleInfo());
MOCK_METHOD1(SetVINValue, bool(const std::string& value));
MOCK_METHOD2(GetUserFriendlyMsg,
std::vector< ::policy::UserFriendlyMessage>(
diff --git a/src/components/policy/policy_external/test/include/policy/policy_manager_impl_test_base.h b/src/components/policy/policy_external/test/include/policy/policy_manager_impl_test_base.h
index 2ab6caf15d..816b99cc2f 100644
--- a/src/components/policy/policy_external/test/include/policy/policy_manager_impl_test_base.h
+++ b/src/components/policy/policy_external/test/include/policy/policy_manager_impl_test_base.h
@@ -113,7 +113,7 @@ class PolicyManagerImplTest : public ::testing::Test {
const std::string unpaired_device_id_;
PolicyManagerImpl* policy_manager_;
- MockCacheManagerInterface* cache_manager_;
+ NiceMock<MockCacheManagerInterface>* cache_manager_;
MockUpdateStatusManager update_manager_;
NiceMock<MockPolicyListener> listener_;
NiceMock<MockPTURetryHandler> ptu_retry_handler_;
diff --git a/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc
index bb8c6fc12a..49390b3aa1 100644
--- a/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc
+++ b/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc
@@ -972,14 +972,18 @@ TEST_F(PolicyManagerImplTest, LoadPT_SetInvalidUpdatePT_PTIsNotLoaded) {
std::string json = table.toStyledString();
::policy::BinaryMessage msg(json.begin(), json.end());
+ auto pt = std::make_shared<policy_table::Table>();
+ *pt = update;
+
// Assert
- EXPECT_CALL(*cache_manager_, GenerateSnapshot()).Times(0);
EXPECT_CALL(*cache_manager_, ApplyUpdate(_)).Times(0);
EXPECT_CALL(listener_, GetAppName(_)).Times(0);
EXPECT_CALL(listener_, OnUpdateStatusChanged(_)).Times(1);
EXPECT_CALL(*cache_manager_, SaveUpdateRequired(false)).Times(0);
EXPECT_CALL(*cache_manager_, TimeoutResponse()).Times(0);
EXPECT_CALL(*cache_manager_, SecondsBetweenRetries(_)).Times(0);
+ EXPECT_CALL(*cache_manager_, GetVehicleDataItems())
+ .WillOnce(Return(std::vector<policy_table::VehicleDataItem>()));
EXPECT_FALSE(policy_manager_->LoadPT(kFilePtUpdateJson, msg));
EXPECT_CALL(*cache_manager_, IsPTPreloaded());
EXPECT_FALSE(policy_manager_->GetCache()->IsPTPreloaded());
@@ -1169,24 +1173,6 @@ TEST_F(PolicyManagerImplTest2,
EXPECT_TRUE(policy_manager_->CanAppKeepContext(app_id_2_));
}
-TEST_F(PolicyManagerImplTest2,
- GetVehicleInfo_SetVehicleInfo_ExpectReceivedInfoCorrect) {
- // Arrange
- CreateLocalPT(preloaded_pt_filename_);
- GetPTU(kValidSdlPtUpdateJson);
- std::shared_ptr<policy_table::Table> pt =
- (policy_manager_->GetCache())->GetPT();
- policy_table::ModuleConfig& module_config = pt->policy_table.module_config;
- ::policy::VehicleInfo vehicle_info = policy_manager_->GetVehicleInfo();
-
- EXPECT_EQ(static_cast<std::string>(*module_config.vehicle_make),
- vehicle_info.vehicle_make);
- EXPECT_EQ(static_cast<std::string>(*module_config.vehicle_model),
- vehicle_info.vehicle_model);
- EXPECT_EQ(static_cast<std::string>(*module_config.vehicle_year),
- vehicle_info.vehicle_year);
-}
-
TEST_F(
PolicyManagerImplTest2,
GetPermissionsForApp_SetUserConsentForApp_ExpectReceivedPermissionsCorrect) {
diff --git a/src/components/policy/policy_external/test/policy_manager_impl_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_test.cc
index 1a7500c954..ef5e3e98bc 100644
--- a/src/components/policy/policy_external/test/policy_manager_impl_test.cc
+++ b/src/components/policy/policy_external/test/policy_manager_impl_test.cc
@@ -125,16 +125,19 @@ TEST_F(PolicyManagerImplTest, LoadPT_SetPT_PTIsLoaded) {
std::shared_ptr<policy_table::Table> snapshot =
std::make_shared<policy_table::Table>(update.policy_table);
+ ON_CALL(*cache_manager_, GenerateSnapshot()).WillByDefault(Return(snapshot));
+
// Assert
- EXPECT_CALL(*cache_manager_, GenerateSnapshot()).WillOnce(Return(snapshot));
EXPECT_CALL(*cache_manager_, ApplyUpdate(_)).WillOnce(Return(true));
- EXPECT_CALL(listener_, GetAppName("1234"))
- .WillOnce(Return(custom_str::CustomString("")));
+ EXPECT_CALL(listener_, GetDevicesIds("1234"))
+ .WillRepeatedly(Return(transport_manager::DeviceList()));
EXPECT_CALL(listener_, OnUpdateStatusChanged(_));
EXPECT_CALL(*cache_manager_, SaveUpdateRequired(false));
EXPECT_CALL(*cache_manager_, TimeoutResponse());
EXPECT_CALL(*cache_manager_, SecondsBetweenRetries(_));
+ EXPECT_CALL(*cache_manager_, GetVehicleDataItems())
+ .WillOnce(Return(std::vector<policy_table::VehicleDataItem>()));
EXPECT_TRUE(policy_manager_->LoadPT(kFilePtUpdateJson, msg));
EXPECT_CALL(*cache_manager_, IsPTPreloaded());
EXPECT_FALSE(policy_manager_->GetCache()->IsPTPreloaded());
diff --git a/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc b/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc
index be7f25dabb..81e5c77ff0 100644
--- a/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc
+++ b/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc
@@ -207,7 +207,7 @@ PolicyManagerImplTest::PolicyManagerImplTest()
void PolicyManagerImplTest::SetUp() {
policy_manager_ = new PolicyManagerImpl();
- cache_manager_ = new MockCacheManagerInterface();
+ cache_manager_ = new NiceMock<MockCacheManagerInterface>();
policy_manager_->set_cache_manager(cache_manager_);
policy_manager_->set_listener(&listener_);
@@ -264,7 +264,7 @@ void PolicyManagerImplTest2::SetUp() {
ON_CALL(policy_settings_, app_storage_folder())
.WillByDefault(ReturnRef(app_storage_folder_));
policy_manager_->set_listener(&listener_);
- const char* levels[] = {"BACKGROUND", "FULL", "LIMITED", "NONE"};
+ const char* levels[] = {"FULL", "LIMITED", "BACKGROUND", "NONE"};
hmi_level_.assign(levels, levels + sizeof(levels) / sizeof(levels[0]));
srand(time(NULL));
index_ = rand() % 3;
diff --git a/src/components/policy/policy_external/test/sql_pt_ext_representation_test.cc b/src/components/policy/policy_external/test/sql_pt_ext_representation_test.cc
index a9c7667ba6..7d40210ba4 100644
--- a/src/components/policy/policy_external/test/sql_pt_ext_representation_test.cc
+++ b/src/components/policy/policy_external/test/sql_pt_ext_representation_test.cc
@@ -1541,8 +1541,8 @@ TEST_F(SQLPTExtRepresentationTest, SaveFunctionalGroupings_ExpectedSaved) {
const HmiLevel test_level_1 = HL_FULL;
const HmiLevel test_level_2 = HL_LIMITED;
- const policy_table::Parameter test_parameter_1 = P_GPS;
- const policy_table::Parameter test_parameter_2 = P_SPEED;
+ const std::string test_parameter_1 = "P_GPS";
+ const std::string test_parameter_2 = "P_SPEED";
Rpcs rpcs;
@@ -1578,7 +1578,7 @@ TEST_F(SQLPTExtRepresentationTest, SaveFunctionalGroupings_ExpectedSaved) {
*another_rpcs.user_consent_prompt = another_user_consent_prompt;
const HmiLevel test_level_3 = HL_BACKGROUND;
- const policy_table::Parameter test_parameter_3 = P_BELTSTATUS;
+ const std::string test_parameter_3 = "P_BELTSTATUS";
RpcParameters another_parameters;
another_parameters.hmi_levels.push_back(test_level_3);
@@ -1615,10 +1615,10 @@ TEST_F(SQLPTExtRepresentationTest, SaveFunctionalGroupings_ExpectedSaved) {
EXPECT_TRUE(
(IsKeyExist<HmiLevels>(loaded_parameters.hmi_levels, test_level_2)));
- EXPECT_TRUE((
- IsKeyExist<Parameters>(*loaded_parameters.parameters, test_parameter_1)));
- EXPECT_TRUE((
- IsKeyExist<Parameters>(*loaded_parameters.parameters, test_parameter_2)));
+ EXPECT_TRUE((IsKeyExist<Parameters, std::string>(
+ *loaded_parameters.parameters, test_parameter_1)));
+ EXPECT_TRUE((IsKeyExist<Parameters, std::string>(
+ *loaded_parameters.parameters, test_parameter_2)));
Rpcs another_loaded_rpcs = GetKeyData<FunctionalGroupings, Rpcs>(
loaded_groupings, another_group_name);
@@ -1637,8 +1637,8 @@ TEST_F(SQLPTExtRepresentationTest, SaveFunctionalGroupings_ExpectedSaved) {
EXPECT_TRUE((IsKeyExist<HmiLevels>(another_loaded_parameters.hmi_levels,
test_level_3)));
- EXPECT_TRUE((IsKeyExist<Parameters>(*another_loaded_parameters.parameters,
- test_parameter_3)));
+ EXPECT_TRUE((IsKeyExist<Parameters, std::string>(
+ *another_loaded_parameters.parameters, test_parameter_3)));
}
TEST_F(SQLPTExtRepresentationTest, JsonContentsExternalConsent_ExpectParsed) {
diff --git a/src/components/policy/policy_external/test/sql_pt_representation_test.cc b/src/components/policy/policy_external/test/sql_pt_representation_test.cc
index 9e6e18b77d..67702ab4d2 100644
--- a/src/components/policy/policy_external/test/sql_pt_representation_test.cc
+++ b/src/components/policy/policy_external/test/sql_pt_representation_test.cc
@@ -176,7 +176,7 @@ class SQLPTRepresentationTest : public SQLPTRepresentation,
policy_table::Strings& temp_groups = apps_iter->second.groups;
StringsCompare(groups, temp_groups);
EXPECT_EQ(0u, (*(apps_iter->second.nicknames)).size());
- EXPECT_EQ(prio, apps_iter->second.priority);
+ EXPECT_EQ(prio, (apps_iter->second).priority);
EXPECT_EQ(0u, (*(apps_iter->second.AppHMIType)).size());
EXPECT_EQ(memory_kb, (*(apps_iter->second.memory_kb)));
EXPECT_EQ(heart_beat_timeout_ms,
@@ -376,6 +376,99 @@ class SQLPTRepresentationTest2 : public ::testing::Test {
const uint16_t kAttemptsToOpenPolicyDB = 2u;
};
+TEST_F(SQLPTRepresentationTest, VehicleDataItem_Store_Item) {
+ policy_table::VehicleDataItem rpm;
+ rpm.mark_initialized();
+ rpm.name = "rpm";
+ rpm.type = "Integer";
+ rpm.key = "OEM_REF_RPM";
+ rpm.mandatory = false;
+ *rpm.array = false;
+ rpm.params->mark_initialized();
+ ASSERT_FALSE(reps->VehicleDataItemExists(rpm));
+ ASSERT_TRUE(reps->InsertVehicleDataItem(rpm));
+ ASSERT_TRUE(reps->VehicleDataItemExists(rpm));
+
+ auto rpm_retrieved = reps->GetVehicleDataItem(rpm.name, rpm.key);
+
+ std::cout << rpm.ToJsonValue().toStyledString() << std::endl;
+ std::cout << rpm_retrieved.ToJsonValue().toStyledString() << std::endl;
+
+ ASSERT_EQ(rpm.ToJsonValue(), rpm_retrieved.begin()->ToJsonValue());
+}
+
+TEST_F(SQLPTRepresentationTest, VehicleDataItem_Store_Complete_Item) {
+ policy_table::VehicleDataItem message;
+ message.name = "messsageName";
+ message.type = "String";
+ message.key = "OEM_REF_MSG";
+ message.mandatory = false;
+ *message.array = false;
+ *message.since = "1.0";
+ *message.until = "5.0";
+ *message.removed = false;
+ *message.deprecated = false;
+ *message.minvalue = 0;
+ *message.maxvalue = 255;
+ *message.minsize = 0;
+ *message.maxsize = 255;
+ *message.minlength = 0;
+ *message.maxlength = 255;
+ message.params->mark_initialized();
+ ASSERT_TRUE(reps->InsertVehicleDataItem(message));
+
+ auto message_retrieved = reps->GetVehicleDataItem(message.name, message.key);
+ ASSERT_EQ(message.ToJsonValue(), message_retrieved.begin()->ToJsonValue());
+}
+
+TEST_F(SQLPTRepresentationTest, VehicleDataItem_Store_Struct) {
+ policy_table::VehicleDataItem alss;
+ alss.mark_initialized();
+ alss.name = "ambientLightSensorStatus";
+ alss.type = "AmbientLightStatus";
+ alss.key = "OEM_REF_AMB_LIGHT";
+ alss.mandatory = false;
+ alss.params->mark_initialized();
+ policy_table::VehicleDataItem lss;
+ lss.mark_initialized();
+ lss.name = "LightSensorStatus";
+ lss.type = "Struct";
+ lss.key = "OEM_REF_SEN_LIGHT";
+ lss.mandatory = false;
+ lss.params->mark_initialized();
+ (*lss.params).push_back(alss);
+
+ policy_table::VehicleDataItem hbo;
+ hbo.mark_initialized();
+ hbo.name = "highBeamsOn";
+ hbo.type = "Boolean";
+ hbo.key = "OEM_REF_HIGH_BEAM";
+ hbo.mandatory = true;
+ hbo.params->mark_initialized();
+ policy_table::VehicleDataItem lbo;
+ lbo.mark_initialized();
+ lbo.name = "lowBeamsOn";
+ lbo.type = "Boolean";
+ lbo.key = "OEM_REF_LOW_BEAM";
+ lbo.mandatory = false;
+ lbo.params->mark_initialized();
+ policy_table::VehicleDataItem hls;
+ hls.mark_initialized();
+ hls.name = "headLampStatus";
+ hls.type = "Struct";
+ hls.key = "OEM_REF_HLSTATUS";
+ hls.mandatory = false;
+ hls.params->mark_initialized();
+ (*hls.params).push_back(lss);
+ (*hls.params).push_back(lbo);
+ (*hls.params).push_back(hbo);
+ ASSERT_TRUE(reps->InsertVehicleDataItem(alss));
+ ASSERT_TRUE(reps->InsertVehicleDataItem(hls));
+
+ auto hls_retrieved = reps->GetVehicleDataItem(hls.name, hls.key);
+ ASSERT_EQ(hls.ToJsonValue(), hls_retrieved.begin()->ToJsonValue());
+}
+
TEST_F(SQLPTRepresentationTest2,
CheckActualAttemptsToOpenDB_ExpectCorrectNumber) {
EXPECT_EQ(::policy::FAIL, reps->Init(&policy_settings_));
@@ -406,8 +499,8 @@ TEST_F(SQLPTRepresentationTest,
query.Prepare(query_select);
query.Next();
- // 37 - is current total tables number created by schema
- const int policy_tables_number = 37;
+ // 41 - is current total tables number created by schema
+ const int policy_tables_number = 41;
ASSERT_EQ(policy_tables_number, query.GetInteger(0));
const std::string query_select_count_of_iap_buffer_full =
@@ -965,25 +1058,6 @@ TEST_F(
ASSERT_EQ(0, query.GetInteger(0));
}
-TEST_F(
- SQLPTRepresentationTest,
- GetVehicleInfo_ManuallySetVehcleInfoThenCallGetVehicleInfo_ExpectValuesReceived) {
- // Check
- const std::string query_insert_module_config =
- "UPDATE `module_config` SET `preloaded_pt` = 1, "
- " `exchange_after_x_ignition_cycles` = 50,"
- " `exchange_after_x_kilometers` = 2000, `exchange_after_x_days` = 30,"
- " `timeout_after_x_seconds` = 5, `vehicle_make` = 'FORD', "
- " `vehicle_model` = 'MUSTANG', `vehicle_year` = '2003', "
- "`preloaded_date` = '25.04.2015'";
- ASSERT_TRUE(query_wrapper_->Exec(query_insert_module_config));
- VehicleInfo info = reps->GetVehicleInfo();
-
- ASSERT_EQ("FORD", info.vehicle_make);
- ASSERT_EQ("MUSTANG", info.vehicle_model);
- ASSERT_EQ("2003", info.vehicle_year);
-}
-
TEST_F(SQLPTRepresentationTest,
GetUserFriendlyMsg_SetMsg_ExpectReceivedMsgSetInParams) {
// Arrange
@@ -1695,9 +1769,8 @@ TEST_F(SQLPTRepresentationTest,
const ::policy_table::Parameters& parameters = *(rpc_iter->second.parameters);
EXPECT_EQ(1u, parameters.size());
- EXPECT_TRUE(parameters.end() != std::find(parameters.begin(),
- parameters.end(),
- policy_table::Parameter::P_SPEED));
+ EXPECT_TRUE(parameters.end() !=
+ std::find(parameters.begin(), parameters.end(), "P_SPEED"));
// Check Application Policies Section
GatherApplicationPoliciesSection(&policies);
const uint32_t apps_size = 3u;
diff --git a/src/components/policy/policy_regular/CMakeLists.txt b/src/components/policy/policy_regular/CMakeLists.txt
index f7f34564b6..e14057ec89 100644
--- a/src/components/policy/policy_regular/CMakeLists.txt
+++ b/src/components/policy/policy_regular/CMakeLists.txt
@@ -30,27 +30,81 @@
include(${CMAKE_SOURCE_DIR}/tools/cmake/helpers/platform.cmake)
include(${CMAKE_SOURCE_DIR}/tools/cmake/helpers/sources.cmake)
+include(${CMAKE_SOURCE_DIR}/tools/cmake/helpers/generators.cmake)
include_directories (
- ${POLICY_PATH}/include
- ${POLICY_GLOBAL_INCLUDE_PATH}/
- ${COMPONENTS_DIR}/rpc_base/include
- ${JSONCPP_INCLUDE_DIRECTORY}
+ ${POLICY_PATH}/include/
+ ${COMPONENTS_DIR}/
${COMPONENTS_DIR}/utils/include/
${COMPONENTS_DIR}/config_profile/include
${COMPONENTS_DIR}/connection_handler/include/
${COMPONENTS_DIR}/protocol_handler/include/
- ${LOG4CXX_INCLUDE_DIRECTORY}
- ${BOOST_INCLUDE_DIR}
+ ${COMPONENTS_DIR}/config_profile/include/
+ ${COMPONENTS_DIR}/smart_objects/include/
+ ${COMPONENTS_DIR}/rpc_base/include/
+ ${CMAKE_BINARY_DIR}/src/components/
+ ${POLICY_GLOBAL_INCLUDE_PATH}/
+ ${BOOST_INCLUDE_DIR}/
+ ${JSONCPP_INCLUDE_DIRECTORY}/
+ ${LOG4CXX_INCLUDE_DIRECTORY}/
)
+set(GENERATED_MOBILE_POLICY_TYPES_CPP
+ "${CMAKE_CURRENT_BINARY_DIR}/generated_MOBILE_API_policy_types.cc"
+ "${CMAKE_CURRENT_BINARY_DIR}/generated_MOBILE_API_enum_schema_factory.cc")
+
+set(GENERATED_MOBILE_POLICY_TYPES_HPP
+ "${CMAKE_CURRENT_BINARY_DIR}/generated_MOBILE_API_policy_types.h")
+
+set(GENERATED_MOBILE_POLICY_TYPES
+ ${GENERATED_MOBILE_POLICY_TYPES_HPP}
+ ${GENERATED_MOBILE_POLICY_TYPES_CPP})
+
+generate_policy_types("${GENERATED_MOBILE_POLICY_TYPES}"
+ "${COMPONENTS_DIR}/interfaces/MOBILE_API.xml"
+ "rpc::policy_table_interface_base"
+ "mobile-policy-types")
+
+
+set(GENERATED_HMI_POLICY_TYPES_CPP
+ "${CMAKE_CURRENT_BINARY_DIR}/generated_HMI_API_policy_types.cc")
+
+set(GENERATED_HMI_POLICY_TYPES_HPP
+ "${CMAKE_CURRENT_BINARY_DIR}/generated_HMI_API_policy_types.h")
+
+set(GENERATED_HMI_POLICY_TYPES
+ ${GENERATED_HMI_POLICY_TYPES_HPP}
+ ${GENERATED_HMI_POLICY_TYPES_CPP})
+
+
+generate_policy_types("${GENERATED_HMI_POLICY_TYPES}"
+ "${COMPONENTS_DIR}/interfaces/HMI_API.xml"
+ "rpc::policy_table_interface_base"
+ "hmi-policy-types")
+
set(POLICY_TABLE_PATHS
${CMAKE_CURRENT_SOURCE_DIR}/include/policy/policy_table
${CMAKE_CURRENT_SOURCE_DIR}/src/policy_table
+ ${CMAKE_CURRENT_BINARY_DIR}/
)
-collect_sources(POLICY_TABLE_SOURCES "${POLICY_TABLE_PATHS}")
+
+set(POLICY_TABLE_SOURCES
+ ${GENERATED_MOBILE_POLICY_TYPES_CPP}
+ ${GENERATED_HMI_POLICY_TYPES_CPP}
+ ${POLICY_PATH}/src/policy_table/enums.cc
+ ${POLICY_PATH}/src/policy_table/types.cc
+ ${POLICY_PATH}/src/policy_table/validation.cc
+)
+
add_library(policy_struct ${POLICY_TABLE_SOURCES})
-target_link_libraries(policy_struct Utils)
+target_link_libraries(policy_struct
+ MOBILE_API
+ HMI_API
+ Utils
+ SmartObjects
+ formatters
+ jsoncpp
+)
set(USAGE_STATISTICS_PATHS
${CMAKE_CURRENT_SOURCE_DIR}/include/policy/usage_statistics
@@ -76,7 +130,6 @@ set(LIBRARIES
ConfigProfile
policy_struct
dbms
- jsoncpp
Utils
)
diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h
index 1773347af7..9b0413d7ce 100644
--- a/src/components/policy/policy_regular/include/policy/cache_manager.h
+++ b/src/components/policy/policy_regular/include/policy/cache_manager.h
@@ -142,9 +142,17 @@ class CacheManager : public CacheManagerInterface {
virtual bool SecondsBetweenRetries(std::vector<int>& seconds);
/**
- * @brief Get information about vehicle
+ * @brief Gets copy of current policy table data
+ * @return policy_table as json object
*/
- virtual const VehicleInfo GetVehicleInfo() const;
+ virtual Json::Value GetPolicyTableData() const OVERRIDE;
+
+ /**
+ * @brief Gets vehicle data items
+ * @return Structure with vehicle data items
+ */
+ virtual const std::vector<policy_table::VehicleDataItem> GetVehicleDataItems()
+ const;
const boost::optional<bool> LockScreenDismissalEnabledState() const OVERRIDE;
@@ -841,6 +849,24 @@ class CacheManager : public CacheManagerInterface {
void MergeCFM(const policy_table::PolicyTable& new_pt,
policy_table::PolicyTable& pt);
+ /**
+ * @brief MergeVD allows to merge VehicleDataItems section by
+ *definite rules.
+ *
+ * The rules are:
+ * 1. If vehicle_data_items key is not presented in the updated PolicyTable,
+ * update for VehicleDataItems should be ignored.
+ * 2. If vehicle_data_items presented in updated PolicyTable, the
+ * VehicleDataItems in the database (LocalPT) should be overwritten with
+ * updated data.
+ *
+ * @param new_pt the policy table loaded from updated preload JSON file.
+ *
+ * @param pt the exists database
+ */
+ void MergeVD(const policy_table::PolicyTable& new_pt,
+ policy_table::PolicyTable& pt);
+
const PolicySettings& get_settings() const;
std::shared_ptr<policy_table::Table> pt() const {
@@ -866,6 +892,14 @@ class CacheManager : public CacheManagerInterface {
const std::string& application_name,
policy_table::ApplicationParams& application_policies) const OVERRIDE;
+ /**
+ * @brief Method for separate RPCSpec vehicle data items from custom
+ * @param full vehicle data items during PTU
+ * @return array with only custom vehicle items
+ */
+ static policy_table::VehicleDataItems CollectCustomVDItems(
+ const policy_table::VehicleDataItems& vd_items);
+
private:
std::string currentDateTime();
struct AppHMITypeToString {
diff --git a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h
index 374db728c7..bd03896bfb 100644
--- a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h
+++ b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h
@@ -149,9 +149,17 @@ class CacheManagerInterface {
virtual bool SecondsBetweenRetries(std::vector<int>& seconds) = 0;
/**
- * @brief Get information about vehicle
+ * @brief Gets copy of current policy table data
+ * @return policy_table as json object
*/
- virtual const VehicleInfo GetVehicleInfo() const = 0;
+ virtual Json::Value GetPolicyTableData() const = 0;
+
+ /**
+ * @brief Gets vehicle data items
+ * @return Structure with vehicle data items
+ */
+ virtual const std::vector<policy_table::VehicleDataItem> GetVehicleDataItems()
+ const = 0;
/**
* @brief Get a list of enabled cloud applications
diff --git a/src/components/policy/policy_regular/include/policy/policy_helper.h b/src/components/policy/policy_regular/include/policy/policy_helper.h
index adedd8786f..628a8c49d1 100644
--- a/src/components/policy/policy_regular/include/policy/policy_helper.h
+++ b/src/components/policy/policy_regular/include/policy/policy_helper.h
@@ -96,6 +96,8 @@ struct CheckAppPolicy {
policy_table::Strings* revoked_groups = NULL) const;
bool HasNewGroups(const AppPoliciesValueType& app_policy,
policy_table::Strings* new_groups = NULL) const;
+ bool HasUpdatedGroups(const policy::AppPoliciesValueType& app_policy,
+ policy_table::Strings* updated_groups = NULL) const;
bool HasConsentNeededGroups(const AppPoliciesValueType& app_policy) const;
std::vector<FunctionalGroupPermission> GetRevokedGroups(
const AppPoliciesValueType& app_policy) const;
diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h
index 92ef67176a..c6066a9ae9 100644
--- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h
+++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h
@@ -643,12 +643,18 @@ class PolicyManagerImpl : public PolicyManager {
const std::string& policy_app_id) const OVERRIDE;
/**
- * @brief Get information about vehicle
- * @return vehicle information
+ * @brief Gets vehicle data items
+ * @return Structure with vehicle data items
*/
- const VehicleInfo GetVehicleInfo() const OVERRIDE;
+ const std::vector<policy_table::VehicleDataItem> GetVehicleDataItems()
+ const OVERRIDE;
/**
+ * @brief Gets copy of current policy table data
+ * @return policy_table as json object
+ */
+ Json::Value GetPolicyTableData() const OVERRIDE;
+ /**
* @brief Get a list of enabled cloud applications
* @param enabled_apps List filled with the policy app id of each enabled
* cloud application
diff --git a/src/components/policy/policy_regular/include/policy/policy_table/enums.h b/src/components/policy/policy_regular/include/policy/policy_table/enums.h
index 899e40993e..05b39a0082 100644
--- a/src/components/policy/policy_regular/include/policy/policy_table/enums.h
+++ b/src/components/policy/policy_regular/include/policy/policy_table/enums.h
@@ -34,582 +34,12 @@
#define SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_POLICY_TABLE_ENUMS_H_
#include <string>
+#include "generated_HMI_API_policy_types.h"
+#include "generated_MOBILE_API_policy_types.h"
namespace rpc {
namespace policy_table_interface_base {
-enum Priority {
- P_EMERGENCY,
- P_NAVIGATION,
- P_VOICECOM,
- P_COMMUNICATION,
- P_NORMAL,
- P_PROJECTION,
- P_NONE,
-};
-
-bool IsValidEnum(Priority val);
-const char* EnumToJsonString(Priority val);
-bool EnumFromJsonString(const std::string& literal, Priority* result);
-
-enum HmiLevel {
- HL_BACKGROUND,
- HL_FULL,
- HL_LIMITED,
- HL_NONE,
-};
-bool IsValidEnum(HmiLevel val);
-const char* EnumToJsonString(HmiLevel val);
-bool EnumFromJsonString(const std::string& literal, HmiLevel* result);
-
-enum Parameter {
- P_GPS,
- P_SPEED,
- P_ENGINETORQUE,
- P_EXTERNALTEMPERATURE,
- P_TURNSIGNAL,
- P_FUELLEVEL,
- P_FUELLEVEL_STATE,
- P_HEADLAMPSTATUS,
- P_INSTANTFUELCONSUMPTION,
- P_FUELRANGE,
- P_ODOMETER,
- P_TIREPRESSURE,
- P_WIPERSTATUS,
- P_VIN,
- P_ACCPEDALPOSITION,
- P_BELTSTATUS,
- P_ELECTRONICPARKBRAKESTATUS,
- P_DRIVERBRAKING,
- P_PRNDL,
- P_RPM,
- P_STEERINGWHEELANGLE,
- P_ENGINEOILLIFE,
- P_MYKEY,
- P_CLOUD_APP_VEHICLE_ID,
- P_AIRBAGSTATUS,
- P_BODYINFORMATION,
- P_CLUSTERMODESTATUS,
- P_DEVICESTATUS,
- P_EMERGENCYEVENT,
- P_ECALLINFO,
- P_EMPTY // Added to allow empty parameters handling
-};
-
-bool IsValidEnum(Parameter val);
-const char* EnumToJsonString(Parameter val);
-bool EnumFromJsonString(const std::string& literal, Parameter* result);
-
-enum AppHMIType {
- AHT_DEFAULT,
- AHT_COMMUNICATION,
- AHT_MEDIA,
- AHT_MESSAGING,
- AHT_NAVIGATION,
- AHT_INFORMATION,
- AHT_SOCIAL,
- AHT_BACKGROUND_PROCESS,
- AHT_TESTING,
- AHT_SYSTEM,
- AHT_PROJECTION,
- AHT_REMOTE_CONTROL
-};
-bool IsValidEnum(AppHMIType val);
-const char* EnumToJsonString(AppHMIType val);
-bool EnumFromJsonString(const std::string& literal, AppHMIType* result);
-
-enum RequestType {
- RT_HTTP,
- RT_FILE_RESUME,
- RT_AUTH_REQUEST,
- RT_AUTH_CHALLENGE,
- RT_AUTH_ACK,
- RT_PROPRIETARY,
- RT_QUERY_APPS,
- RT_LAUNCH_APP,
- RT_LOCK_SCREEN_ICON_URL,
- RT_TRAFFIC_MESSAGE_CHANNEL,
- RT_DRIVER_PROFILE,
- RT_VOICE_SEARCH,
- RT_NAVIGATION,
- RT_PHONE,
- RT_CLIMATE,
- RT_SETTINGS,
- RT_VEHICLE_DIAGNOSTICS,
- RT_EMERGENCY,
- RT_MEDIA,
- RT_FOTA,
- RT_OEM_SPECIFIC,
- RT_EMPTY // Added to allow empty Request Types handling
-};
-
-bool IsValidEnum(RequestType val);
-const char* EnumToJsonString(RequestType val);
-bool EnumFromJsonString(const std::string& literal, RequestType* result);
-
-enum Input {
- I_GUI,
- I_VUI,
-};
-bool IsValidEnum(Input val);
-const char* EnumToJsonString(Input val);
-bool EnumFromJsonString(const std::string& literal, Input* result);
-
-enum ModuleType {
- MT_CLIMATE,
- MT_RADIO,
- MT_SEAT,
- MT_AUDIO,
- MT_LIGHT,
- MT_HMI_SETTINGS,
- MT_EMPTY
-};
-bool IsValidEnum(ModuleType val);
-const char* EnumToJsonString(ModuleType val);
-bool EnumFromJsonString(const std::string& literal, ModuleType* result);
-
-enum HybridAppPreference { HAP_MOBILE, HAP_CLOUD, HAP_BOTH };
-bool IsValidEnum(HybridAppPreference val);
-const char* EnumToJsonString(HybridAppPreference val);
-bool EnumFromJsonString(const std::string& literal,
- HybridAppPreference* result);
-
-/**
- * @brief Enumeration FunctionID.
- *
- * Enumeration linking function names with function IDs in AppLink protocol.
- * Assumes enumeration starts at value 0.
- */
-enum FunctionID {
- /**
- * @brief RESERVED.
- */
- RESERVED = 0,
-
- /**
- * @brief RegisterAppInterfaceID.
- */
- RegisterAppInterfaceID = 1,
-
- /**
- * @brief UnregisterAppInterfaceID.
- */
- UnregisterAppInterfaceID = 2,
-
- /**
- * @brief SetGlobalPropertiesID.
- */
- SetGlobalPropertiesID = 3,
-
- /**
- * @brief ResetGlobalPropertiesID.
- */
- ResetGlobalPropertiesID = 4,
-
- /**
- * @brief AddCommandID.
- */
- AddCommandID = 5,
-
- /**
- * @brief DeleteCommandID.
- */
- DeleteCommandID = 6,
-
- /**
- * @brief AddSubMenuID.
- */
- AddSubMenuID = 7,
-
- /**
- * @brief DeleteSubMenuID.
- */
- DeleteSubMenuID = 8,
-
- /**
- * @brief CreateInteractionChoiceSetID.
- */
- CreateInteractionChoiceSetID = 9,
-
- /**
- * @brief PerformInteractionID.
- */
- PerformInteractionID = 10,
-
- /**
- * @brief DeleteInteractionChoiceSetID.
- */
- DeleteInteractionChoiceSetID = 11,
-
- /**
- * @brief AlertID.
- */
- AlertID = 12,
-
- /**
- * @brief ShowID.
- */
- ShowID = 13,
-
- /**
- * @brief SpeakID.
- */
- SpeakID = 14,
-
- /**
- * @brief SetMediaClockTimerID.
- */
- SetMediaClockTimerID = 15,
-
- /**
- * @brief PerformAudioPassThruID.
- */
- PerformAudioPassThruID = 16,
-
- /**
- * @brief EndAudioPassThruID.
- */
- EndAudioPassThruID = 17,
-
- /**
- * @brief SubscribeButtonID.
- */
- SubscribeButtonID = 18,
-
- /**
- * @brief UnsubscribeButtonID.
- */
- UnsubscribeButtonID = 19,
-
- /**
- * @brief SubscribeVehicleDataID.
- */
- SubscribeVehicleDataID = 20,
-
- /**
- * @brief UnsubscribeVehicleDataID.
- */
- UnsubscribeVehicleDataID = 21,
-
- /**
- * @brief GetVehicleDataID.
- */
- GetVehicleDataID = 22,
-
- /**
- * @brief ReadDIDID.
- */
- ReadDIDID = 23,
-
- /**
- * @brief GetDTCsID.
- */
- GetDTCsID = 24,
-
- /**
- * @brief ScrollableMessageID.
- */
- ScrollableMessageID = 25,
-
- /**
- * @brief SliderID.
- */
- SliderID = 26,
-
- /**
- * @brief ShowConstantTBTID.
- */
- ShowConstantTBTID = 27,
-
- /**
- * @brief AlertManeuverID.
- */
- AlertManeuverID = 28,
-
- /**
- * @brief UpdateTurnListID.
- */
- UpdateTurnListID = 29,
-
- /**
- * @brief ChangeRegistrationID.
- */
- ChangeRegistrationID = 30,
-
- /**
- * @brief GenericResponseID.
- */
- GenericResponseID = 31,
-
- /**
- * @brief PutFileID.
- */
- PutFileID = 32,
-
- /**
- * @brief DeleteFileID.
- */
- DeleteFileID = 33,
-
- /**
- * @brief ListFilesID.
- */
- ListFilesID = 34,
-
- /**
- * @brief SetAppIconID.
- */
- SetAppIconID = 35,
-
- /**
- * @brief SetDisplayLayoutID.
- */
- SetDisplayLayoutID = 36,
-
- /**
- * @brief DiagnosticMessageID.
- */
- DiagnosticMessageID = 37,
-
- /**
- * @brief SystemRequestID.
- */
- SystemRequestID = 38,
-
- /**
- * @brief SendLocationID.
- */
- SendLocationID = 39,
-
- /**
- * @brief DialNumberID.
- */
- DialNumberID = 40,
-
- /**
- * @brief ButtonPressID.
- */
- ButtonPressID = 41,
-
- /**
- * @brief GetInteriorVehicleDataID.
- */
- GetInteriorVehicleDataID = 43,
-
- /**
- * @brief SetInteriorVehicleDataID.
- */
- SetInteriorVehicleDataID = 44,
-
- /**
- * @brief GetWayPointsID.
- */
- GetWayPointsID = 45,
-
- /**
- * @brief SubscribeWayPointsID.
- */
- SubscribeWayPointsID = 46,
-
- /**
- * @brief UnsubscribeWayPointsID.
- */
- UnsubscribeWayPointsID = 47,
-
- /**
- * @brief GetSystemCapabilityID.
- */
- GetSystemCapabilityID = 48,
-
- /**
- * @brief SendHapticDataID.
- */
- SendHapticDataID = 49,
-
- /**
- * @brief SetCloudAppPropertiesID.
- */
- SetCloudAppPropertiesID = 50,
-
- /**
- * @brief GetCloudAppPropertiesID.
- */
- GetCloudAppPropertiesID = 51,
-
- /**
- * @brief PublishAppServiceID.
- */
- PublishAppServiceID = 52,
-
- /**
- * @brief GetAppServiceDataID.
- */
- GetAppServiceDataID = 53,
-
- /**
- * @brief GetFileID
- */
- GetFileID = 54,
-
- /**
- * @brief PerformAppServiceInteractionID.
- */
- PerformAppServiceInteractionID = 55,
-
- /**
- * @brief UnpublishAppServiceID.
- */
- UnpublishAppServiceID = 56,
-
- /**
- * @brief CancelInteractionID.
- */
- CancelInteractionID = 57,
-
- /**
- * @brief CloseApplicationID.
- */
- CloseApplicationID = 58,
-
- /**
- * @brief ShowAppMenuID.
- */
- ShowAppMenuID = 59,
-
- /**
- * @brief CreateWindowID.
- */
- CreateWindowID = 60,
-
- /**
- * @brief DeleteWindowID.
- */
- DeleteWindowID = 61,
-
- /**
- * @brief OnHMIStatusID.
- */
- OnHMIStatusID = 32768,
-
- /**
- * @brief OnAppInterfaceUnregisteredID.
- */
- OnAppInterfaceUnregisteredID = 32769,
-
- /**
- * @brief OnButtonEventID.
- */
- OnButtonEventID = 32770,
-
- /**
- * @brief OnButtonPressID.
- */
- OnButtonPressID = 32771,
-
- /**
- * @brief OnVehicleDataID.
- */
- OnVehicleDataID = 32772,
-
- /**
- * @brief OnCommandID.
- */
- OnCommandID = 32773,
-
- /**
- * @brief OnTBTClientStateID.
- */
- OnTBTClientStateID = 32774,
-
- /**
- * @brief OnDriverDistractionID.
- */
- OnDriverDistractionID = 32775,
-
- /**
- * @brief OnPermissionsChangeID.
- */
- OnPermissionsChangeID = 32776,
-
- /**
- * @brief OnAudioPassThruID.
- */
- OnAudioPassThruID = 32777,
-
- /**
- * @brief OnLanguageChangeID.
- */
- OnLanguageChangeID = 32778,
-
- /**
- * @brief OnKeyboardInputID.
- */
- OnKeyboardInputID = 32779,
-
- /**
- * @brief OnTouchEventID.
- */
- OnTouchEventID = 32780,
-
- /**
- * @brief OnSystemRequestID.
- */
- OnSystemRequestID = 32781,
-
- /**
- * @brief OnHashChangeID.
- */
- OnHashChangeID = 32782,
-
- /**
- * @brief OnInteriorVehicleDataID.
- */
- OnInteriorVehicleDataID = 32783,
-
- /**
- * @brief OnWayPointChangeID.
- */
- OnWayPointChangeID = 32784,
-
- /**
- * @brief OnRCStatusID.
- */
- OnRCStatusID = 32785,
-
- /**
- * @brief OnAppServiceDataID.
- */
- OnAppServiceDataID = 32786,
-
- /**
- * @brief OnSystemCapabilityUpdatedID
- */
- OnSystemCapabilityUpdatedID = 32787,
-
- /**
- * @brief EncodedSyncPDataID.
- */
- EncodedSyncPDataID = 65536,
-
- /**
- * @brief SyncPDataID.
- */
- SyncPDataID = 65537,
-
- /**
- * @brief OnEncodedSyncPDataID.
- */
- OnEncodedSyncPDataID = 98304,
-
- /**
- * @brief OnSyncPDataID.
- */
- OnSyncPDataID = 98305
-};
-bool IsValidEnum(FunctionID val);
-const char* EnumToJsonString(FunctionID val);
-bool EnumFromJsonString(const std::string& literal, FunctionID* result);
-
extern const std::string kDefaultApp;
extern const std::string kPreDataConsentApp;
extern const std::string kDeviceApp;
diff --git a/src/components/policy/policy_regular/include/policy/policy_table/policy_enum_schema_factory.h b/src/components/policy/policy_regular/include/policy/policy_table/policy_enum_schema_factory.h
new file mode 100644
index 0000000000..2053923cfe
--- /dev/null
+++ b/src/components/policy/policy_regular/include/policy/policy_table/policy_enum_schema_factory.h
@@ -0,0 +1,60 @@
+/**
+ * Copyright (c) 2017, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_POLICY_TABLE_POLICY_ENUM_SCHEMA_FACTORY_H
+#define SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_POLICY_TABLE_POLICY_ENUM_SCHEMA_FACTORY_H
+#include <memory>
+#include <string>
+
+#include "smart_objects/smart_schema.h"
+
+namespace rpc {
+namespace policy_table_interface_base {
+
+class EnumSchemaItemFactory {
+ public:
+ /**
+ * @brief Get enum schema from enum name
+ * Implementation of this function should be generated from MOBILE_API.xml
+ * @param enum_name enum name to get schema factory for
+ * @return shared pointer to schema factory or empty shared pointer if
+ * enum_name is wrong
+ */
+ static std::shared_ptr<ns_smart_device_link::ns_smart_objects::ISchemaItem>
+ Get(const std::string& enum_name);
+
+ static bool IsRPCSpecVehicleDataType(const std::string& vd_name);
+};
+
+} // namespace policy_table_interface_base
+} // namespace rpc
+#endif // SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_POLICY_TABLE_POLICY_ENUM_SCHEMA_FACTORY_H
diff --git a/src/components/policy/policy_regular/include/policy/policy_table/types.h b/src/components/policy/policy_regular/include/policy/policy_table/types.h
index cb7b689317..2ffbf2e7ec 100644
--- a/src/components/policy/policy_regular/include/policy/policy_table/types.h
+++ b/src/components/policy/policy_regular/include/policy/policy_table/types.h
@@ -36,7 +36,9 @@
#include <climits>
#include "policy/policy_table/enums.h"
+#include "policy/policy_table/policy_enum_schema_factory.h"
#include "rpc_base/rpc_message.h"
+#include "utils/helpers.h"
namespace Json {
class Value;
@@ -46,6 +48,7 @@ namespace policy_table_interface_base {
struct AppLevel;
struct ApplicationParams;
struct DeviceParams;
+struct EndpointProperty;
struct MessageLanguages;
struct MessageString;
struct RpcParameters;
@@ -67,16 +70,18 @@ typedef Array<Enum<AppHMIType>, 0, 255> AppHMITypes;
typedef Array<Enum<HmiLevel>, 0, 4> HmiLevels;
-typedef Array<Enum<Parameter>, 0, 255> Parameters;
+typedef Array<String<0, 255>, 0, 255> Parameters;
typedef Map<RpcParameters, 0, UINT_MAX> Rpc;
-typedef Array<String<10, 255>, 1, 3> URL;
+typedef Array<String<10, INT_MAX>, 1, 3> URL;
typedef Map<URL, 1, 255> URLList;
typedef Map<URLList, 1, 255> ServiceEndpoints;
+typedef Map<EndpointProperty, 0, 255> ServiceEndpointProperties;
+
typedef uint8_t NumberOfNotificationsType;
typedef Map<Integer<NumberOfNotificationsType, 0, 255>, 0, 7>
NumberOfNotificationsPerMinute;
@@ -287,6 +292,24 @@ struct Rpcs : CompositeType {
bool Validate() const;
};
+struct EndpointProperty : CompositeType {
+ public:
+ Optional<String<0, 100> > version;
+
+ EndpointProperty();
+ ~EndpointProperty();
+ explicit EndpointProperty(const Json::Value* value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport* report__) const;
+ void SetPolicyTableType(PolicyTableType pt_type) OVERRIDE;
+
+ private:
+ bool Validate() const;
+};
+
struct ModuleConfig : CompositeType {
public:
Optional<Map<String<0, 100>, 0, 255> > device_certificates;
@@ -298,6 +321,7 @@ struct ModuleConfig : CompositeType {
Integer<uint16_t, 0, 65535> timeout_after_x_seconds;
SecondsBetweenRetries seconds_between_retries;
ServiceEndpoints endpoints;
+ Optional<ServiceEndpointProperties> endpoint_properties;
NumberOfNotificationsPerMinute notifications_per_minute_by_priority;
Optional<String<1, 100> > vehicle_make;
Optional<String<1, 100> > vehicle_model;
@@ -306,6 +330,8 @@ struct ModuleConfig : CompositeType {
Optional<String<0, 65535> > certificate;
Optional<Boolean> lock_screen_dismissal_enabled;
+ static const std::string kDefaultOemMappingServiceName;
+
public:
ModuleConfig();
ModuleConfig(uint8_t exchange_after_x_ignition_cycles,
@@ -314,6 +340,7 @@ struct ModuleConfig : CompositeType {
uint16_t timeout_after_x_seconds,
const SecondsBetweenRetries& seconds_between_retries,
const ServiceEndpoints& endpoints,
+ const ServiceEndpointProperties& endpoint_properties,
const NumberOfNotificationsPerMinute&
notifications_per_minute_by_priority);
~ModuleConfig();
@@ -497,6 +524,88 @@ struct DeviceParams : CompositeType {
bool Validate() const;
};
+struct VehicleDataItem : CompositeType {
+ public:
+ static const std::vector<std::string> kPODTypes;
+
+ static const std::string kInteger;
+ static const std::string kStruct;
+ static const std::string kString;
+ static const std::string kFloat;
+ static const std::string kDouble;
+ static const std::string kBoolean;
+ static const std::string kName;
+ static const std::string kParams;
+
+ String<1, 255> name;
+ String<0, 255> type;
+ String<1, 255> key;
+ Boolean mandatory;
+ Optional<Array<VehicleDataItem, 0, 255> > params;
+
+ Optional<Boolean> array;
+ Optional<String<0, 255> > since;
+ Optional<String<0, 255> > until;
+ Optional<Boolean> removed;
+ Optional<Boolean> deprecated;
+ Optional<Float<-INT32_MAX, INT32_MAX> > minvalue;
+ Optional<Float<-INT32_MAX, INT32_MAX> > maxvalue;
+ Optional<Integer<uint32_t, 0, UINT32_MAX> > minsize;
+ Optional<Integer<uint32_t, 0, UINT32_MAX> > maxsize;
+ Optional<Integer<uint32_t, 0, UINT32_MAX> > minlength;
+ Optional<Integer<uint32_t, 0, UINT32_MAX> > maxlength;
+
+ VehicleDataItem();
+ VehicleDataItem(const VehicleDataItem& policy_table);
+ explicit VehicleDataItem(const Json::Value* value__);
+
+ bool operator==(const VehicleDataItem& vd);
+
+ ~VehicleDataItem();
+
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_not_empty() const;
+ void ReportErrors(rpc::ValidationReport* report__) const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+
+ /**
+ * @brief Validates type of vehicle data item according to
+ * POD types and generated from API enums.
+ * @return true if type is valid.
+ */
+ bool ValidateTypes() const;
+ bool IsPrimitiveType() const;
+ bool ValidateNaming(std::string str) const;
+
+ private:
+ bool Validate() const;
+};
+
+typedef Array<VehicleDataItem, 0, 255> VehicleDataItems;
+
+struct VehicleData : CompositeType {
+ public:
+ Optional<String<0, 100> > schema_version;
+ Optional<VehicleDataItems> schema_items;
+
+ VehicleData();
+ VehicleData(const VehicleData& vehicle_data);
+ VehicleData(const Json::Value* value__);
+ ~VehicleData();
+
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport* report__) const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+
+ private:
+ bool Validate() const;
+};
+
struct PolicyTable : CompositeType {
public:
ApplicationPoliciesSection app_policies_section;
@@ -506,6 +615,7 @@ struct PolicyTable : CompositeType {
Optional<ModuleMeta> module_meta;
Optional<UsageAndErrorCounts> usage_and_error_counts;
Optional<DeviceData> device_data;
+ Optional<VehicleData> vehicle_data;
public:
PolicyTable();
diff --git a/src/components/policy/policy_regular/include/policy/policy_types.h b/src/components/policy/policy_regular/include/policy/policy_types.h
index 08ff9b4285..9fddb9761b 100644
--- a/src/components/policy/policy_regular/include/policy/policy_types.h
+++ b/src/components/policy/policy_regular/include/policy/policy_types.h
@@ -503,7 +503,7 @@ enum PermissionsCheckResult {
RESULT_NICKNAME_MISMATCH,
RESULT_PERMISSIONS_REVOKED,
RESULT_CONSENT_NEEDED,
- RESULT_CONSENT_NOT_REQIURED,
+ RESULT_CONSENT_NOT_REQUIRED,
RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED,
RESULT_REQUEST_TYPE_CHANGED,
RESULT_REQUEST_SUBTYPE_CHANGED,
diff --git a/src/components/policy/policy_regular/include/policy/pt_representation.h b/src/components/policy/policy_regular/include/policy/pt_representation.h
index 0534b27093..1adf24ed19 100644
--- a/src/components/policy/policy_regular/include/policy/pt_representation.h
+++ b/src/components/policy/policy_regular/include/policy/pt_representation.h
@@ -123,11 +123,6 @@ class PTRepresentation {
virtual bool SecondsBetweenRetries(std::vector<int>* seconds) = 0;
/**
- * @brief Get information about vehicle
- */
- virtual const VehicleInfo GetVehicleInfo() const = 0;
-
- /**
* @brief Allows to update 'vin' field in module_meta table.
*
* @param new 'vin' value.
diff --git a/src/components/policy/policy_regular/include/policy/sql_pt_queries.h b/src/components/policy/policy_regular/include/policy/sql_pt_queries.h
index bada9a003a..66637b7812 100644
--- a/src/components/policy/policy_regular/include/policy/sql_pt_queries.h
+++ b/src/components/policy/policy_regular/include/policy/sql_pt_queries.h
@@ -143,6 +143,19 @@ extern const std::string kSelectDBVersion;
extern const std::string kUpdateDBVersion;
extern const std::string kSaveModuleMeta;
extern const std::string kSelectModuleMeta;
+extern const std::string kInsertVehicleDataItem;
+extern const std::string kSelectVehicleDataItem;
+extern const std::string kDeleteVehicleDataItems;
+extern const std::string kInsertVehicleDataItemParams;
+extern const std::string kSelectVehicleDataItemParams;
+extern const std::string kDeleteVehicleDataItemParams;
+extern const std::string kSelectVehicleDataItemWithVersion;
+extern const std::string kSelectPrimitiveVehicleDataItems;
+extern const std::string kSelectCompositeVehicleDataItemsKey;
+extern const std::string kSelectVehicleDataSchemaVersion;
+extern const std::string kInsertVehicleDataSchemaVersion;
+extern const std::string kSelectEndpointProperties;
+extern const std::string kInsertEndpointVersion;
} // namespace sql_pt
} // namespace policy
diff --git a/src/components/policy/policy_regular/include/policy/sql_pt_representation.h b/src/components/policy/policy_regular/include/policy/sql_pt_representation.h
index e95620fbc2..216598850e 100644
--- a/src/components/policy/policy_regular/include/policy/sql_pt_representation.h
+++ b/src/components/policy/policy_regular/include/policy/sql_pt_representation.h
@@ -44,6 +44,7 @@ namespace policy_table = rpc::policy_table_interface_base;
namespace utils {
namespace dbms {
class SQLDatabase;
+class SQLQuery;
} // namespace dbms
} // namespace utils
@@ -69,7 +70,6 @@ class SQLPTRepresentation : public virtual PTRepresentation {
virtual int TimeoutResponse();
virtual bool SecondsBetweenRetries(std::vector<int>* seconds);
virtual bool RefreshDB();
- virtual const VehicleInfo GetVehicleInfo() const;
virtual std::vector<UserFriendlyMessage> GetUserFriendlyMsg(
const std::vector<std::string>& msg_codes, const std::string& language);
@@ -123,6 +123,9 @@ class SQLPTRepresentation : public virtual PTRepresentation {
policy_table::ConsumerFriendlyMessages* messages) const;
virtual bool GatherApplicationPoliciesSection(
policy_table::ApplicationPoliciesSection* policies) const;
+ virtual bool GatherVehicleDataItems(
+ policy_table::VehicleDataItems* vehicle_data_items) const;
+ virtual bool GatherVehicleData(policy_table::VehicleData* vehicle_data) const;
bool GatherAppGroup(const std::string& app_id,
policy_table::Strings* app_groups) const;
@@ -159,6 +162,9 @@ class SQLPTRepresentation : public virtual PTRepresentation {
virtual bool SaveSpecificAppPolicy(
const policy_table::ApplicationPolicies::value_type& app);
virtual bool SaveDevicePolicy(const policy_table::DevicePolicy& device);
+ virtual bool SaveVehicleDataItems(
+ const policy_table::VehicleDataItems& vehicle_data_items);
+ virtual bool SaveVehicleData(const policy_table::VehicleData& vehicle_data);
virtual bool SaveMessageString(const std::string& type,
const std::string& lang,
@@ -202,6 +208,26 @@ class SQLPTRepresentation : public virtual PTRepresentation {
virtual bool IsDBVersionActual() const OVERRIDE;
virtual bool UpdateDBVersion() const OVERRIDE;
+ policy_table::VehicleDataItems GetVehicleDataItem(
+ const std::string& name, const std::string& key) const;
+ bool InsertVehicleDataItem(
+ const policy_table::VehicleDataItem& vehicle_data_item);
+ bool VehicleDataItemExists(
+ const policy_table::VehicleDataItem& vehicle_data_item) const;
+
+ /**
+ * @brief Retrieves vehicle data items of type Struct (which contains
+ * params) from the database including these parameters.
+ * @return Array of composite VehicleDataItems
+ */
+ policy_table::VehicleDataItems SelectCompositeVehicleDataItems() const;
+
+ /**
+ * @brief Retrieves vehicle data items of non Struct type from the database.
+ * @return Array of primitive VehicleDataItems
+ */
+ policy_table::VehicleDataItems SelectPrimitiveVehicleDataItems() const;
+
private:
static const std::string kDatabaseName;
utils::dbms::SQLDatabase* db_;
@@ -217,12 +243,17 @@ class SQLPTRepresentation : public virtual PTRepresentation {
const int32_t GetDBVersion() const;
bool SaveRpcs(int64_t group_id, const policy_table::Rpc& rpcs);
bool SaveServiceEndpoints(const policy_table::ServiceEndpoints& endpoints);
+ bool SaveServiceEndpointProperties(
+ const policy_table::ServiceEndpointProperties& endpoint_properties);
bool SaveSecondsBetweenRetries(
const policy_table::SecondsBetweenRetries& seconds);
bool SaveNumberOfNotificationsPerMinute(
const policy_table::NumberOfNotificationsPerMinute& notifications);
bool SaveMessageType(const std::string& type);
bool SaveLanguage(const std::string& code);
+ policy_table::VehicleDataItem PopulateVDIFromQuery(
+ const utils::dbms::SQLQuery& query) const;
+ bool DeleteVehicleDataItems() const;
bool is_in_memory;
};
diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc
index b13770282f..166a79b89d 100644
--- a/src/components/policy/policy_regular/src/cache_manager.cc
+++ b/src/components/policy/policy_regular/src/cache_manager.cc
@@ -33,14 +33,17 @@
#include "policy/cache_manager.h"
#include <algorithm>
+#include <boost/algorithm/string.hpp>
#include <cmath>
#include <ctime>
#include <functional>
#include <sstream>
+#include "interfaces/MOBILE_API.h"
#include "json/features.h"
#include "json/reader.h"
#include "json/writer.h"
+#include "smart_objects/enum_schema_item.h"
#include "utils/date_time.h"
#include "utils/file_system.h"
#include "utils/gen_hash.h"
@@ -296,11 +299,49 @@ bool CacheManager::ApplyUpdate(const policy_table::Table& update_pt) {
pt_->policy_table.consumer_friendly_messages.assign_if_valid(
update_pt.policy_table.consumer_friendly_messages);
+ pt_->policy_table.module_config.endpoint_properties =
+ update_pt.policy_table.module_config.endpoint_properties;
+
+ // Apply update for vehicle data
+ if (update_pt.policy_table.vehicle_data.is_initialized()) {
+ if (!update_pt.policy_table.vehicle_data->schema_items.is_initialized() ||
+ update_pt.policy_table.vehicle_data->schema_items->empty()) {
+ pt_->policy_table.vehicle_data->schema_items =
+ rpc::Optional<policy_table::VehicleDataItems>();
+ } else {
+ policy_table::VehicleDataItems custom_items = CollectCustomVDItems(
+ *update_pt.policy_table.vehicle_data->schema_items);
+
+ pt_->policy_table.vehicle_data->schema_version =
+ update_pt.policy_table.vehicle_data->schema_version;
+ pt_->policy_table.vehicle_data->schema_items =
+ rpc::Optional<policy_table::VehicleDataItems>(custom_items);
+ }
+ if (update_pt.policy_table.vehicle_data->schema_version.is_initialized() &&
+ update_pt.policy_table.vehicle_data->schema_items.is_initialized()) {
+ }
+ }
+
ResetCalculatedPermissions();
Backup();
return true;
}
+policy_table::VehicleDataItems CacheManager::CollectCustomVDItems(
+ const policy_table::VehicleDataItems& vd_items) {
+ policy_table::VehicleDataItems result_items;
+ for (auto& item : vd_items) {
+ const std::string i_name = "VEHICLEDATA_" + std::string(item.name);
+ const std::string vd_name = boost::to_upper_copy<std::string>(i_name);
+ const bool is_rpc_spec =
+ policy_table::EnumSchemaItemFactory::IsRPCSpecVehicleDataType(vd_name);
+ if (!is_rpc_spec) {
+ result_items.push_back(item);
+ }
+ }
+ return result_items;
+}
+
void CacheManager::GetHMIAppTypeAfterUpdate(
std::map<std::string, StringArray>& app_hmi_types) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -526,14 +567,8 @@ void CacheManager::CheckPermissions(const policy_table::Strings& groups,
if (rpc_param.hmi_levels.end() != hmi_iter) {
result.hmi_level_permitted = PermitResult::kRpcAllowed;
- policy_table::Parameters::const_iterator params_iter =
- rpc_param.parameters->begin();
- policy_table::Parameters::const_iterator params_iter_end =
- rpc_param.parameters->end();
-
- for (; params_iter != params_iter_end; ++params_iter) {
- result.list_of_allowed_params.insert(
- policy_table::EnumToJsonString(*params_iter));
+ for (const auto& param : *rpc_param.parameters) {
+ result.list_of_allowed_params.insert(std::string(param));
}
}
}
@@ -680,20 +715,20 @@ bool CacheManager::SecondsBetweenRetries(std::vector<int>& seconds) {
return true;
}
-const policy::VehicleInfo CacheManager::GetVehicleInfo() const {
- CACHE_MANAGER_CHECK(VehicleInfo());
+const std::vector<policy_table::VehicleDataItem>
+CacheManager::GetVehicleDataItems() const {
+ CACHE_MANAGER_CHECK(std::vector<policy_table::VehicleDataItem>());
sync_primitives::AutoLock auto_lock(cache_lock_);
- policy_table::ModuleConfig& module_config = pt_->policy_table.module_config;
- VehicleInfo vehicle_info;
- vehicle_info.vehicle_make = *module_config.vehicle_make;
- vehicle_info.vehicle_model = *module_config.vehicle_model;
- vehicle_info.vehicle_year = *module_config.vehicle_year;
- LOG4CXX_DEBUG(
- logger_,
- "Vehicle info (make, model, year):" << vehicle_info.vehicle_make << ","
- << vehicle_info.vehicle_model << ","
- << vehicle_info.vehicle_year);
- return vehicle_info;
+ if (pt_->policy_table.vehicle_data.is_initialized() &&
+ pt_->policy_table.vehicle_data->schema_items.is_initialized()) {
+ return *(pt_->policy_table.vehicle_data->schema_items);
+ }
+
+ return std::vector<policy_table::VehicleDataItem>();
+}
+
+Json::Value CacheManager::GetPolicyTableData() const {
+ return pt_->policy_table.ToJsonValue();
}
void CacheManager::GetEnabledCloudApps(
@@ -969,11 +1004,19 @@ std::vector<UserFriendlyMessage> CacheManager::GetUserFriendlyMsg(
void CacheManager::GetUpdateUrls(const uint32_t service_type,
EndpointUrls& out_end_points) {
- std::stringstream service_type_stream;
- service_type_stream << (service_type <= 9 ? "0x0" : "0x") << service_type;
-
- const std::string service_type_str = service_type_stream.str();
- GetUpdateUrls(service_type_str, out_end_points);
+ auto find_hexademical =
+ [service_type](policy_table::ServiceEndpoints::value_type end_point) {
+ uint32_t decimal;
+ std::istringstream(end_point.first) >> std::hex >> decimal;
+ return end_point.first.compare(0, 2, "0x") == 0 &&
+ decimal == service_type;
+ };
+ auto& end_points = pt_->policy_table.module_config.endpoints;
+ const auto end_point =
+ std::find_if(end_points.begin(), end_points.end(), find_hexademical);
+ if (end_point != end_points.end()) {
+ GetUpdateUrls(end_point->first, out_end_points);
+ }
}
void CacheManager::GetUpdateUrls(const std::string& service_type,
@@ -1301,6 +1344,14 @@ std::shared_ptr<policy_table::Table> CacheManager::GenerateSnapshot() {
pt_->policy_table.usage_and_error_counts;
snapshot_->policy_table.device_data = pt_->policy_table.device_data;
+ if (pt_->policy_table.vehicle_data.is_initialized()) {
+ snapshot_->policy_table.vehicle_data =
+ rpc::Optional<policy_table::VehicleData>();
+ snapshot_->policy_table.vehicle_data->mark_initialized();
+ snapshot_->policy_table.vehicle_data->schema_version =
+ pt_->policy_table.vehicle_data->schema_version;
+ }
+
// Set policy table type to Snapshot
snapshot_->SetPolicyTableType(
rpc::policy_table_interface_base::PolicyTableType::PT_SNAPSHOT);
@@ -1684,6 +1735,8 @@ bool CacheManager::Init(const std::string& file_name,
if (!result) {
rpc::ValidationReport report("policy_table");
snapshot->ReportErrors(&report);
+ LOG4CXX_DEBUG(logger_,
+ "Validation report: " << rpc::PrettyFormat(report));
return result;
}
@@ -1934,6 +1987,7 @@ bool CacheManager::MergePreloadPT(const std::string& file_name) {
MergeFG(new_table, current);
MergeAP(new_table, current);
MergeCFM(new_table, current);
+ MergeVD(new_table, current);
Backup();
}
return true;
@@ -2001,6 +2055,12 @@ void CacheManager::MergeCFM(const policy_table::PolicyTable& new_pt,
}
}
+void CacheManager::MergeVD(const policy_table::PolicyTable& new_pt,
+ policy_table::PolicyTable& pt) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ pt.vehicle_data.assign_if_valid(new_pt.vehicle_data);
+}
+
const PolicySettings& CacheManager::get_settings() const {
DCHECK(settings_);
diff --git a/src/components/policy/policy_regular/src/policy_helper.cc b/src/components/policy/policy_regular/src/policy_helper.cc
index 7ebb66bf2b..7338e98cff 100644
--- a/src/components/policy/policy_regular/src/policy_helper.cc
+++ b/src/components/policy/policy_regular/src/policy_helper.cc
@@ -46,7 +46,8 @@ namespace {
CREATE_LOGGERPTR_GLOBAL(logger_, "Policy")
-bool Compare(const StringsValueType& first, const StringsValueType& second) {
+bool CompareStrings(const StringsValueType& first,
+ const StringsValueType& second) {
const std::string& first_str = first;
const std::string& second_str = second;
return (strcasecmp(first_str.c_str(), second_str.c_str()) < 0);
@@ -136,10 +137,10 @@ bool policy::CheckAppPolicy::HasRevokedGroups(
snapshot_->policy_table.app_policies_section.apps.find(app_policy.first);
policy_table::Strings groups_new = app_policy.second.groups;
- std::sort(groups_new.begin(), groups_new.end(), Compare);
+ std::sort(groups_new.begin(), groups_new.end(), CompareStrings);
policy_table::Strings groups_curr = (*it).second.groups;
- std::sort(groups_curr.begin(), groups_curr.end(), Compare);
+ std::sort(groups_curr.begin(), groups_curr.end(), CompareStrings);
StringsConstItr it_groups_new = groups_new.begin();
StringsConstItr it_groups_new_end = groups_new.end();
@@ -153,18 +154,7 @@ bool policy::CheckAppPolicy::HasRevokedGroups(
it_groups_new,
it_groups_new_end,
std::back_inserter(revoked_group_list),
- Compare);
-
- // Remove groups which are not required user consent
- policy_table::Strings::iterator it_revoked = revoked_group_list.begin();
- for (; revoked_group_list.end() != it_revoked;) {
- if (!IsConsentRequired(app_policy.first, std::string(*it_revoked))) {
- revoked_group_list.erase(it_revoked);
- it_revoked = revoked_group_list.begin();
- } else {
- ++it_revoked;
- }
- }
+ CompareStrings);
if (revoked_groups) {
*revoked_groups = revoked_group_list;
@@ -173,6 +163,76 @@ bool policy::CheckAppPolicy::HasRevokedGroups(
return !revoked_group_list.empty();
}
+bool policy::CheckAppPolicy::HasUpdatedGroups(
+ const policy::AppPoliciesValueType& app_policy,
+ policy_table::Strings* updated_groups) const {
+ AppPoliciesConstItr it =
+ snapshot_->policy_table.app_policies_section.apps.find(app_policy.first);
+
+ policy_table::Strings groups_new = app_policy.second.groups;
+ std::sort(groups_new.begin(), groups_new.end(), CompareStrings);
+
+ policy_table::Strings groups_curr = (*it).second.groups;
+ std::sort(groups_curr.begin(), groups_curr.end(), CompareStrings);
+
+ policy_table::Strings intersection_list;
+ std::set_intersection(groups_new.begin(),
+ groups_new.end(),
+ groups_curr.begin(),
+ groups_curr.end(),
+ std::back_inserter(intersection_list));
+
+ auto IsGroupContentUpdated =
+ [this](const StringsValueType& groupName) -> bool {
+ const auto& func_group_from_update =
+ update_->policy_table.functional_groupings.find(groupName);
+ const auto& func_group_from_snapshot =
+ snapshot_->policy_table.functional_groupings.find(groupName);
+
+ const auto& update_fg_rpcs = func_group_from_update->second.rpcs;
+ const auto& snapshot_fg_rpcs = func_group_from_snapshot->second.rpcs;
+
+ if (update_fg_rpcs.is_null() || snapshot_fg_rpcs.is_null()) {
+ return !(update_fg_rpcs.is_null() && snapshot_fg_rpcs.is_null());
+ }
+
+ if (update_fg_rpcs.size() != snapshot_fg_rpcs.size()) {
+ return true;
+ }
+
+ for (const auto& rpc : update_fg_rpcs) {
+ const auto& old_rpc = snapshot_fg_rpcs.find(rpc.first);
+ if (snapshot_fg_rpcs.end() == old_rpc) {
+ return true;
+ }
+
+ const bool hmi_levels_same =
+ old_rpc->second.hmi_levels == rpc.second.hmi_levels;
+ const bool parameters_same =
+ *(old_rpc->second.parameters) == *(rpc.second.parameters);
+
+ if (!hmi_levels_same || !parameters_same) {
+ return true;
+ }
+ }
+
+ return false;
+ };
+
+ policy_table::Strings updated_group_list;
+ for (const auto& item : intersection_list) {
+ if (IsGroupContentUpdated(item)) {
+ updated_group_list.push_back(item);
+ }
+ }
+
+ if (updated_groups) {
+ *updated_groups = updated_group_list;
+ }
+
+ return !updated_group_list.empty();
+}
+
bool policy::CheckAppPolicy::HasNewGroups(
const policy::AppPoliciesValueType& app_policy,
policy_table::Strings* new_groups) const {
@@ -180,10 +240,10 @@ bool policy::CheckAppPolicy::HasNewGroups(
snapshot_->policy_table.app_policies_section.apps.find(app_policy.first);
policy_table::Strings groups_new = app_policy.second.groups;
- std::sort(groups_new.begin(), groups_new.end(), Compare);
+ std::sort(groups_new.begin(), groups_new.end(), CompareStrings);
policy_table::Strings groups_curr = (*it).second.groups;
- std::sort(groups_curr.begin(), groups_curr.end(), Compare);
+ std::sort(groups_curr.begin(), groups_curr.end(), CompareStrings);
StringsConstItr it_groups_new = groups_new.begin();
StringsConstItr it_groups_new_end = groups_new.end();
@@ -197,7 +257,7 @@ bool policy::CheckAppPolicy::HasNewGroups(
it_groups_curr,
it_groups_curr_end,
std::back_inserter(new_group_list),
- Compare);
+ CompareStrings);
if (new_groups) {
*new_groups = new_group_list;
@@ -209,14 +269,23 @@ bool policy::CheckAppPolicy::HasNewGroups(
bool policy::CheckAppPolicy::HasConsentNeededGroups(
const policy::AppPoliciesValueType& app_policy) const {
policy_table::Strings new_groups;
- if (!HasNewGroups(app_policy, &new_groups)) {
+ policy_table::Strings updated_groups;
+ if (!HasNewGroups(app_policy, &new_groups) &&
+ !HasUpdatedGroups(app_policy, &updated_groups)) {
return false;
}
- StringsConstItr it_new = new_groups.begin();
- StringsConstItr it_new_end = new_groups.end();
- for (; it_new != it_new_end; ++it_new) {
- if (IsConsentRequired(app_policy.first, *it_new)) {
+ policy_table::Strings groups_to_check_consent;
+ std::set_union(new_groups.begin(),
+ new_groups.end(),
+ updated_groups.begin(),
+ updated_groups.end(),
+ std::back_inserter(groups_to_check_consent));
+
+ StringsConstItr it = groups_to_check_consent.begin();
+ StringsConstItr it_end = groups_to_check_consent.end();
+ for (; it != it_end; ++it) {
+ if (IsConsentRequired(app_policy.first, *it)) {
return true;
}
}
@@ -391,32 +460,32 @@ bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) {
"Permissions for application:" << app_id << " have been changed.");
if (IsPredefinedApp(app_policy)) {
- LOG4CXX_DEBUG(logger_, "app id: " << app_id << " is predefined app");
- for (const policy_table::ApplicationPolicies::value_type& app :
- snapshot_->policy_table.app_policies_section.apps) {
- if (app_policy.first == app.second.get_string()) {
- if (RESULT_CONSENT_NOT_REQIURED != result) {
- SetPendingPermissions(app, result);
- AddResult(app_id, RESULT_CONSENT_NEEDED);
- }
- LOG4CXX_DEBUG(logger_, "Sending permissions for app: " << app_id);
- }
+ const auto& snapshot_app_policy_begin =
+ snapshot_->policy_table.app_policies_section.apps.begin();
+ const auto& snapshot_app_policy_end =
+ snapshot_->policy_table.app_policies_section.apps.end();
+
+ auto find_app = [&app_id](AppPoliciesValueType app) {
+ return app_id == app.second.get_string();
+ };
+
+ const auto& app = std::find_if(
+ snapshot_app_policy_begin, snapshot_app_policy_end, find_app);
+
+ if ((snapshot_app_policy_end != app) &&
+ (RESULT_CONSENT_NOT_REQUIRED != result)) {
+ SetPendingPermissions(*app, result);
+ AddResult(app_id, RESULT_CONSENT_NEEDED);
}
return true;
}
- if (!IsPredefinedApp(app_policy) && RESULT_CONSENT_NOT_REQIURED != result) {
- LOG4CXX_DEBUG(logger_, "Sending permissions for app: " << app_id);
+ if (RESULT_CONSENT_NOT_REQUIRED != result) {
SetPendingPermissions(app_policy, result);
AddResult(app_id, RESULT_CONSENT_NEEDED);
}
- // Don't sent notification for predefined apps (e.g. default, device etc.)
- if (!IsPredefinedApp(app_policy)) {
- LOG4CXX_DEBUG(logger_, "Sending permissions for app: " << app_id);
- SetPendingPermissions(app_policy, result);
- AddResult(app_id, result);
- }
+ SendPermissionsToApp(app_policy.first, app_policy.second.groups);
return true;
}
@@ -485,14 +554,16 @@ policy::PermissionsCheckResult policy::CheckAppPolicy::CheckPermissionsChanges(
const bool encryption_required_flag_changed =
IsEncryptionRequiredFlagChanged(app_policy);
+ bool has_updated_groups = HasUpdatedGroups(app_policy);
+
if (has_revoked_groups && has_consent_needed_groups) {
return RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED;
} else if (has_revoked_groups) {
return RESULT_PERMISSIONS_REVOKED;
} else if (has_consent_needed_groups) {
return RESULT_CONSENT_NEEDED;
- } else if (has_new_groups) {
- return RESULT_CONSENT_NOT_REQIURED;
+ } else if (has_new_groups || has_updated_groups) {
+ return RESULT_CONSENT_NOT_REQUIRED;
} else if (encryption_required_flag_changed) {
return RESULT_ENCRYPTION_REQUIRED_FLAG_CHANGED;
}
@@ -672,7 +743,7 @@ void FillActionsForAppPolicies::operator()(
case RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED:
actions_[app_id].is_consent_needed = true;
break;
- case RESULT_CONSENT_NOT_REQIURED:
+ case RESULT_CONSENT_NOT_REQUIRED:
case RESULT_PERMISSIONS_REVOKED:
case RESULT_REQUEST_TYPE_CHANGED:
case RESULT_REQUEST_SUBTYPE_CHANGED:
@@ -752,7 +823,7 @@ void FillNotificationData::UpdateParameters(
ParametersConstItr it_parameters_end = in_parameters.end();
for (; it_parameters != it_parameters_end; ++it_parameters) {
- out_parameter.insert(policy_table::EnumToJsonString(*it_parameters));
+ out_parameter.insert(*it_parameters);
}
}
diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc
index ee4c991183..7e3b7ccbe9 100644
--- a/src/components/policy/policy_regular/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc
@@ -167,7 +167,9 @@ void FilterInvalidFunctions(policy_table::Rpc& rpcs) {
* schema
* @param rpc_parameters parameters to filter
*/
-void FilterInvalidRPCParameters(policy_table::RpcParameters& rpc_parameters) {
+void FilterInvalidRPCParameters(
+ policy_table::RpcParameters& rpc_parameters,
+ const std::vector<policy_table::VehicleDataItem>& vehicle_data_items) {
policy_table::HmiLevels valid_hmi_levels;
for (const auto& hmi_level : rpc_parameters.hmi_levels) {
if (hmi_level.is_valid()) {
@@ -176,10 +178,31 @@ void FilterInvalidRPCParameters(policy_table::RpcParameters& rpc_parameters) {
}
rpc_parameters.hmi_levels.swap(valid_hmi_levels);
+ auto ParamExists =
+ [&vehicle_data_items](const rpc::String<0, 255>& param_name) {
+ policy_table::Parameter parameter_enum;
+ if (policy_table::EnumFromJsonString(param_name, &parameter_enum)) {
+ return true;
+ }
+
+ // In case when this collection is empty that means collection is not
+ // initialized
+ if (vehicle_data_items.empty()) {
+ return false;
+ }
+
+ for (const auto& vdi : vehicle_data_items) {
+ if (param_name == vdi.name) {
+ return true;
+ }
+ }
+ return false;
+ };
+
policy_table::Parameters valid_params;
const policy_table::Parameters& params = *(rpc_parameters.parameters);
for (const auto& param : params) {
- if (param.is_valid()) {
+ if (param.is_valid() && ParamExists(param)) {
valid_params.push_back(param);
}
}
@@ -264,7 +287,9 @@ void FilterInvalidApplicationParameters(
* @brief FilterPolicyTable filter values that not present in schema
* @param pt policy table to filter
*/
-void FilterPolicyTable(policy_table::PolicyTable& pt) {
+void FilterPolicyTable(
+ policy_table::PolicyTable& pt,
+ const std::vector<policy_table::VehicleDataItem>& current_vd_items) {
policy_table::ModuleConfig& module_config = pt.module_config;
if (module_config.is_initialized() &&
module_config.notifications_per_minute_by_priority.is_initialized()) {
@@ -283,8 +308,18 @@ void FilterPolicyTable(policy_table::PolicyTable& pt) {
policy_table::Rpc& rpcs = group.second.rpcs;
FilterInvalidFunctions(rpcs);
+ policy_table::VehicleDataItems vehicle_data_items;
+
+ if (!pt.vehicle_data->struct_empty()) {
+ vehicle_data_items =
+ pt.vehicle_data.is_initialized() &&
+ pt.vehicle_data->schema_items.is_initialized()
+ ? *pt.vehicle_data->schema_items
+ : current_vd_items;
+ }
+
for (auto& func : rpcs) {
- FilterInvalidRPCParameters(func.second);
+ FilterInvalidRPCParameters(func.second, vehicle_data_items);
}
}
}
@@ -314,10 +349,11 @@ bool PolicyManagerImpl::LoadPT(const std::string& file,
file_system::DeleteFile(file);
- FilterPolicyTable(pt_update->policy_table);
+ auto current_vd_items = GetVehicleDataItems();
+
+ FilterPolicyTable(pt_update->policy_table, current_vd_items);
if (!IsPTValid(pt_update, policy_table::PT_UPDATE)) {
wrong_ptu_update_received_ = true;
- ResetRetrySequence(ResetRetryCountType::kResetInternally);
update_status_manager_.OnWrongUpdateReceived();
return false;
}
@@ -345,13 +381,9 @@ bool PolicyManagerImpl::LoadPT(const std::string& file,
return false;
}
- // Checking of difference between PTU and current policy state
- // Must to be done before PTU applying since it is possible, that functional
- // groups, which had been present before are absent in PTU and will be
- // removed after update. So in case of revoked groups system has to know
- // names and ids of revoked groups before they will be removed.
- const auto results =
- CheckPermissionsChanges(pt_update, policy_table_snapshot);
+ // Replace predefined policies with its actual setting, e.g. "123":"default"
+ // to actual values of default section
+ UnwrapAppPolicies(pt_update->policy_table.app_policies_section.apps);
// Replace current data with updated
if (!cache_->ApplyUpdate(*pt_update)) {
@@ -363,6 +395,14 @@ bool PolicyManagerImpl::LoadPT(const std::string& file,
}
CheckPermissionsChangesAfterUpdate(*pt_update, *policy_table_snapshot);
+ // Checking of difference between PTU and current policy state
+ // Must to be done before PTU applying since it is possible, that functional
+ // groups, which had been present before are absent in PTU and will be
+ // removed after update. So in case of revoked groups system has to know
+ // names and ids of revoked groups before they will be removed.
+ const auto results =
+ CheckPermissionsChanges(pt_update, policy_table_snapshot);
+
ProcessAppPolicyCheckResults(
results, pt_update->policy_table.app_policies_section.apps);
@@ -650,9 +690,13 @@ const std::vector<std::string> PolicyManagerImpl::GetAppRequestSubTypes(
cache_->GetAppRequestSubTypes(policy_app_id, request_subtypes);
return request_subtypes;
}
+const std::vector<policy_table::VehicleDataItem>
+PolicyManagerImpl::GetVehicleDataItems() const {
+ return cache_->GetVehicleDataItems();
+}
-const VehicleInfo PolicyManagerImpl::GetVehicleInfo() const {
- return cache_->GetVehicleInfo();
+Json::Value PolicyManagerImpl::GetPolicyTableData() const {
+ return cache_->GetPolicyTableData();
}
void PolicyManagerImpl::GetEnabledCloudApps(
diff --git a/src/components/policy/policy_regular/src/policy_table/enums.cc b/src/components/policy/policy_regular/src/policy_table/enums.cc
index 56bbd53762..8aabf54c5d 100644
--- a/src/components/policy/policy_regular/src/policy_table/enums.cc
+++ b/src/components/policy/policy_regular/src/policy_table/enums.cc
@@ -3,1524 +3,6 @@
namespace rpc {
namespace policy_table_interface_base {
-bool IsValidEnum(Priority val) {
- switch (val) {
- case P_EMERGENCY:
- return true;
- case P_NAVIGATION:
- return true;
- case P_VOICECOM:
- return true;
- case P_COMMUNICATION:
- return true;
- case P_NORMAL:
- return true;
- case P_PROJECTION:
- return true;
- case P_NONE:
- return true;
- default:
- return false;
- }
-}
-const char* EnumToJsonString(Priority val) {
- switch (val) {
- case P_EMERGENCY:
- return "EMERGENCY";
- case P_NAVIGATION:
- return "NAVIGATION";
- case P_VOICECOM:
- return "VOICECOM";
- case P_COMMUNICATION:
- return "COMMUNICATION";
- case P_NORMAL:
- return "NORMAL";
- case P_PROJECTION:
- return "PROJECTION";
- case P_NONE:
- return "NONE";
- default:
- return "";
- }
-}
-bool EnumFromJsonString(const std::string& literal, Priority* result) {
- if ("EMERGENCY" == literal) {
- *result = P_EMERGENCY;
- return true;
- } else if ("NAVIGATION" == literal) {
- *result = P_NAVIGATION;
- return true;
- } else if ("VOICECOM" == literal) {
- *result = P_VOICECOM;
- return true;
- } else if ("COMMUNICATION" == literal) {
- *result = P_COMMUNICATION;
- return true;
- } else if ("NORMAL" == literal) {
- *result = P_NORMAL;
- return true;
- } else if ("PROJECTION" == literal) {
- *result = P_PROJECTION;
- return true;
- } else if ("NONE" == literal) {
- *result = P_NONE;
- return true;
- } else {
- return false;
- }
-}
-
-bool IsValidEnum(HmiLevel val) {
- switch (val) {
- case HL_BACKGROUND:
- return true;
- case HL_FULL:
- return true;
- case HL_LIMITED:
- return true;
- case HL_NONE:
- return true;
- default:
- return false;
- }
-}
-const char* EnumToJsonString(HmiLevel val) {
- switch (val) {
- case HL_BACKGROUND:
- return "BACKGROUND";
- case HL_FULL:
- return "FULL";
- case HL_LIMITED:
- return "LIMITED";
- case HL_NONE:
- return "NONE";
- default:
- return "";
- }
-}
-bool EnumFromJsonString(const std::string& literal, HmiLevel* result) {
- if ("BACKGROUND" == literal) {
- *result = HL_BACKGROUND;
- return true;
- } else if ("FULL" == literal) {
- *result = HL_FULL;
- return true;
- } else if ("LIMITED" == literal) {
- *result = HL_LIMITED;
- return true;
- } else if ("NONE" == literal) {
- *result = HL_NONE;
- return true;
- } else {
- return false;
- }
-}
-
-bool IsValidEnum(Parameter val) {
- switch (val) {
- case P_GPS:
- return true;
- case P_SPEED:
- return true;
- case P_ENGINETORQUE:
- return true;
- case P_EXTERNALTEMPERATURE:
- return true;
- case P_TURNSIGNAL:
- return true;
- case P_FUELLEVEL:
- return true;
- case P_FUELLEVEL_STATE:
- return true;
- case P_HEADLAMPSTATUS:
- return true;
- case P_INSTANTFUELCONSUMPTION:
- return true;
- case P_FUELRANGE:
- return true;
- case P_CLOUD_APP_VEHICLE_ID:
- return true;
- case P_ODOMETER:
- return true;
- case P_TIREPRESSURE:
- return true;
- case P_WIPERSTATUS:
- return true;
- case P_VIN:
- return true;
- case P_ACCPEDALPOSITION:
- return true;
- case P_BELTSTATUS:
- return true;
- case P_ELECTRONICPARKBRAKESTATUS:
- return true;
- case P_DRIVERBRAKING:
- return true;
- case P_PRNDL:
- return true;
- case P_RPM:
- return true;
- case P_STEERINGWHEELANGLE:
- return true;
- case P_ENGINEOILLIFE:
- return true;
- case P_MYKEY:
- return true;
- case P_AIRBAGSTATUS:
- return true;
- case P_BODYINFORMATION:
- return true;
- case P_CLUSTERMODESTATUS:
- return true;
- case P_DEVICESTATUS:
- return true;
- case P_EMERGENCYEVENT:
- return true;
- case P_ECALLINFO:
- return true;
- case P_EMPTY:
- return true;
- default:
- return false;
- }
-}
-const char* EnumToJsonString(Parameter val) {
- switch (val) {
- case P_GPS:
- return "gps";
- case P_SPEED:
- return "speed";
- case P_ENGINETORQUE:
- return "engineTorque";
- case P_EXTERNALTEMPERATURE:
- return "externalTemperature";
- case P_TURNSIGNAL:
- return "turnSignal";
- case P_FUELLEVEL:
- return "fuelLevel";
- case P_FUELLEVEL_STATE:
- return "fuelLevel_State";
- case P_HEADLAMPSTATUS:
- return "headLampStatus";
- case P_INSTANTFUELCONSUMPTION:
- return "instantFuelConsumption";
- case P_FUELRANGE:
- return "fuelRange";
- case P_CLOUD_APP_VEHICLE_ID:
- return "cloudAppVehicleID";
- case P_ODOMETER:
- return "odometer";
- case P_TIREPRESSURE:
- return "tirePressure";
- case P_WIPERSTATUS:
- return "wiperStatus";
- case P_VIN:
- return "vin";
- case P_ACCPEDALPOSITION:
- return "accPedalPosition";
- case P_BELTSTATUS:
- return "beltStatus";
- case P_ELECTRONICPARKBRAKESTATUS:
- return "electronicParkBrakeStatus";
- case P_DRIVERBRAKING:
- return "driverBraking";
- case P_PRNDL:
- return "prndl";
- case P_RPM:
- return "rpm";
- case P_STEERINGWHEELANGLE:
- return "steeringWheelAngle";
- case P_ENGINEOILLIFE:
- return "engineOilLife";
- case P_MYKEY:
- return "myKey";
- case P_AIRBAGSTATUS:
- return "airbagStatus";
- case P_BODYINFORMATION:
- return "bodyInformation";
- case P_CLUSTERMODESTATUS:
- return "clusterModeStatus";
- case P_DEVICESTATUS:
- return "deviceStatus";
- case P_EMERGENCYEVENT:
- return "emergencyEvent";
- case P_ECALLINFO:
- return "eCallInfo";
- case P_EMPTY:
- return "EMPTY";
- default:
- return "";
- }
-}
-
-bool EnumFromJsonString(const std::string& literal, Parameter* result) {
- if ("gps" == literal) {
- *result = P_GPS;
- return true;
- } else if ("speed" == literal) {
- *result = P_SPEED;
- return true;
- } else if ("engineTorque" == literal) {
- *result = P_ENGINETORQUE;
- return true;
- } else if ("externalTemperature" == literal) {
- *result = P_EXTERNALTEMPERATURE;
- return true;
- } else if ("turnSignal" == literal) {
- *result = P_TURNSIGNAL;
- return true;
- } else if ("fuelLevel" == literal) {
- *result = P_FUELLEVEL;
- return true;
- } else if ("fuelLevel_State" == literal) {
- *result = P_FUELLEVEL_STATE;
- return true;
- } else if ("headLampStatus" == literal) {
- *result = P_HEADLAMPSTATUS;
- return true;
- } else if ("instantFuelConsumption" == literal) {
- *result = P_INSTANTFUELCONSUMPTION;
- return true;
- } else if ("fuelRange" == literal) {
- *result = P_FUELRANGE;
- return true;
- } else if ("cloudAppVehicleID" == literal) {
- *result = P_CLOUD_APP_VEHICLE_ID;
- return true;
- } else if ("odometer" == literal) {
- *result = P_ODOMETER;
- return true;
- } else if ("tirePressure" == literal) {
- *result = P_TIREPRESSURE;
- return true;
- } else if ("wiperStatus" == literal) {
- *result = P_WIPERSTATUS;
- return true;
- } else if ("vin" == literal) {
- *result = P_VIN;
- return true;
- } else if ("accPedalPosition" == literal) {
- *result = P_ACCPEDALPOSITION;
- return true;
- } else if ("beltStatus" == literal) {
- *result = P_BELTSTATUS;
- return true;
- } else if ("electronicParkBrakeStatus" == literal) {
- *result = P_ELECTRONICPARKBRAKESTATUS;
- return true;
- } else if ("driverBraking" == literal) {
- *result = P_DRIVERBRAKING;
- return true;
- } else if ("prndl" == literal) {
- *result = P_PRNDL;
- return true;
- } else if ("rpm" == literal) {
- *result = P_RPM;
- return true;
- } else if ("steeringWheelAngle" == literal) {
- *result = P_STEERINGWHEELANGLE;
- return true;
- } else if ("engineOilLife" == literal) {
- *result = P_ENGINEOILLIFE;
- return true;
- } else if ("myKey" == literal) {
- *result = P_MYKEY;
- return true;
- } else if ("airbagStatus" == literal) {
- *result = P_AIRBAGSTATUS;
- return true;
- } else if ("bodyInformation" == literal) {
- *result = P_BODYINFORMATION;
- return true;
- } else if ("clusterModeStatus" == literal) {
- *result = P_CLUSTERMODESTATUS;
- return true;
- } else if ("deviceStatus" == literal) {
- *result = P_DEVICESTATUS;
- return true;
- } else if ("emergencyEvent" == literal) {
- *result = P_EMERGENCYEVENT;
- return true;
- } else if ("eCallInfo" == literal) {
- *result = P_ECALLINFO;
- return true;
- } else if ("EMPTY" == literal) {
- *result = P_EMPTY;
- return true;
- } else {
- return false;
- }
-}
-
-bool IsValidEnum(AppHMIType val) {
- switch (val) {
- case AHT_DEFAULT:
- return true;
- case AHT_COMMUNICATION:
- return true;
- case AHT_MEDIA:
- return true;
- case AHT_MESSAGING:
- return true;
- case AHT_NAVIGATION:
- return true;
- case AHT_INFORMATION:
- return true;
- case AHT_SOCIAL:
- return true;
- case AHT_BACKGROUND_PROCESS:
- return true;
- case AHT_TESTING:
- return true;
- case AHT_SYSTEM:
- return true;
- case AHT_PROJECTION:
- return true;
- case AHT_REMOTE_CONTROL:
- return true;
- default:
- return false;
- }
-}
-const char* EnumToJsonString(AppHMIType val) {
- switch (val) {
- case AHT_DEFAULT:
- return "DEFAULT";
- case AHT_COMMUNICATION:
- return "COMMUNICATION";
- case AHT_MEDIA:
- return "MEDIA";
- case AHT_MESSAGING:
- return "MESSAGING";
- case AHT_NAVIGATION:
- return "NAVIGATION";
- case AHT_INFORMATION:
- return "INFORMATION";
- case AHT_SOCIAL:
- return "SOCIAL";
- case AHT_BACKGROUND_PROCESS:
- return "BACKGROUND_PROCESS";
- case AHT_TESTING:
- return "TESTING";
- case AHT_SYSTEM:
- return "SYSTEM";
- case AHT_PROJECTION:
- return "PROJECTION";
- case AHT_REMOTE_CONTROL:
- return "REMOTE_CONTROL";
- default:
- return "";
- }
-}
-bool EnumFromJsonString(const std::string& literal, AppHMIType* result) {
- if ("DEFAULT" == literal) {
- *result = AHT_DEFAULT;
- return true;
- } else if ("COMMUNICATION" == literal) {
- *result = AHT_COMMUNICATION;
- return true;
- } else if ("MEDIA" == literal) {
- *result = AHT_MEDIA;
- return true;
- } else if ("MESSAGING" == literal) {
- *result = AHT_MESSAGING;
- return true;
- } else if ("NAVIGATION" == literal) {
- *result = AHT_NAVIGATION;
- return true;
- } else if ("INFORMATION" == literal) {
- *result = AHT_INFORMATION;
- return true;
- } else if ("SOCIAL" == literal) {
- *result = AHT_SOCIAL;
- return true;
- } else if ("BACKGROUND_PROCESS" == literal) {
- *result = AHT_BACKGROUND_PROCESS;
- return true;
- } else if ("TESTING" == literal) {
- *result = AHT_TESTING;
- return true;
- } else if ("SYSTEM" == literal) {
- *result = AHT_SYSTEM;
- return true;
- } else if ("PROJECTION" == literal) {
- *result = AHT_PROJECTION;
- return true;
- } else if ("REMOTE_CONTROL" == literal) {
- *result = AHT_REMOTE_CONTROL;
- return true;
- } else {
- return false;
- }
-}
-
-bool IsValidEnum(RequestType val) {
- switch (val) {
- case RT_HTTP:
- return true;
- case RT_FILE_RESUME:
- return true;
- case RT_AUTH_REQUEST:
- return true;
- case RT_AUTH_CHALLENGE:
- return true;
- case RT_AUTH_ACK:
- return true;
- case RT_PROPRIETARY:
- return true;
- case RT_QUERY_APPS:
- return true;
- case RT_LAUNCH_APP:
- return true;
- case RT_LOCK_SCREEN_ICON_URL:
- return true;
- case RT_TRAFFIC_MESSAGE_CHANNEL:
- return true;
- case RT_DRIVER_PROFILE:
- return true;
- case RT_VOICE_SEARCH:
- return true;
- case RT_NAVIGATION:
- return true;
- case RT_PHONE:
- return true;
- case RT_CLIMATE:
- return true;
- case RT_SETTINGS:
- return true;
- case RT_VEHICLE_DIAGNOSTICS:
- return true;
- case RT_EMERGENCY:
- return true;
- case RT_MEDIA:
- return true;
- case RT_FOTA:
- return true;
- case RT_OEM_SPECIFIC:
- return true;
- case RT_EMPTY:
- return true;
- default:
- return false;
- }
-}
-
-const char* EnumToJsonString(RequestType val) {
- switch (val) {
- case RT_HTTP:
- return "HTTP";
- case RT_FILE_RESUME:
- return "FILE_RESUME";
- case RT_AUTH_REQUEST:
- return "AUTH_REQUEST";
- case RT_AUTH_CHALLENGE:
- return "AUTH_CHALLENGE";
- case RT_AUTH_ACK:
- return "AUTH_ACK";
- case RT_PROPRIETARY:
- return "PROPRIETARY";
- case RT_QUERY_APPS:
- return "QUERY_APPS";
- case RT_LAUNCH_APP:
- return "LAUNCH_APP";
- case RT_LOCK_SCREEN_ICON_URL:
- return "LOCK_SCREEN_ICON_URL";
- case RT_TRAFFIC_MESSAGE_CHANNEL:
- return "TRAFFIC_MESSAGE_CHANNEL";
- case RT_DRIVER_PROFILE:
- return "DRIVER_PROFILE";
- case RT_VOICE_SEARCH:
- return "VOICE_SEARCH";
- case RT_NAVIGATION:
- return "NAVIGATION";
- case RT_PHONE:
- return "PHONE";
- case RT_CLIMATE:
- return "CLIMATE";
- case RT_SETTINGS:
- return "SETTINGS";
- case RT_VEHICLE_DIAGNOSTICS:
- return "VEHICLE_DIAGNOSTICS";
- case RT_EMERGENCY:
- return "EMERGENCY";
- case RT_MEDIA:
- return "MEDIA";
- case RT_FOTA:
- return "FOTA";
- case RT_OEM_SPECIFIC:
- return "OEM_SPECIFIC";
- case RT_EMPTY:
- return "EMPTY";
- default:
- return "";
- }
-}
-
-bool EnumFromJsonString(const std::string& literal, RequestType* result) {
- if ("HTTP" == literal) {
- *result = RT_HTTP;
- return true;
- }
- if ("FILE_RESUME" == literal) {
- *result = RT_FILE_RESUME;
- return true;
- }
- if ("AUTH_REQUEST" == literal) {
- *result = RT_AUTH_REQUEST;
- return true;
- }
- if ("AUTH_CHALLENGE" == literal) {
- *result = RT_AUTH_CHALLENGE;
- return true;
- }
- if ("AUTH_ACK" == literal) {
- *result = RT_AUTH_ACK;
- return true;
- }
- if ("PROPRIETARY" == literal) {
- *result = RT_PROPRIETARY;
- return true;
- }
- if ("QUERY_APPS" == literal) {
- *result = RT_QUERY_APPS;
- return true;
- }
- if ("LAUNCH_APP" == literal) {
- *result = RT_LAUNCH_APP;
- return true;
- }
- if ("LOCK_SCREEN_ICON_URL" == literal) {
- *result = RT_LOCK_SCREEN_ICON_URL;
- return true;
- }
- if ("TRAFFIC_MESSAGE_CHANNEL" == literal) {
- *result = RT_TRAFFIC_MESSAGE_CHANNEL;
- return true;
- }
- if ("DRIVER_PROFILE" == literal) {
- *result = RT_DRIVER_PROFILE;
- return true;
- }
- if ("VOICE_SEARCH" == literal) {
- *result = RT_VOICE_SEARCH;
- return true;
- }
- if ("NAVIGATION" == literal) {
- *result = RT_NAVIGATION;
- return true;
- }
- if ("PHONE" == literal) {
- *result = RT_PHONE;
- return true;
- }
- if ("CLIMATE" == literal) {
- *result = RT_CLIMATE;
- return true;
- }
- if ("SETTINGS" == literal) {
- *result = RT_SETTINGS;
- return true;
- }
- if ("VEHICLE_DIAGNOSTICS" == literal) {
- *result = RT_VEHICLE_DIAGNOSTICS;
- return true;
- }
- if ("EMERGENCY" == literal) {
- *result = RT_EMERGENCY;
- return true;
- }
- if ("MEDIA" == literal) {
- *result = RT_MEDIA;
- return true;
- }
- if ("FOTA" == literal) {
- *result = RT_FOTA;
- return true;
- }
- if ("OEM_SPECIFIC" == literal) {
- *result = RT_OEM_SPECIFIC;
- return true;
- }
- if ("EMPTY" == literal) {
- *result = RT_EMPTY;
- return true;
- } else {
- return false;
- }
-}
-
-bool IsValidEnum(ModuleType val) {
- switch (val) {
- case MT_CLIMATE:
- return true;
- case MT_RADIO:
- return true;
- case MT_SEAT:
- return true;
- case MT_AUDIO:
- return true;
- case MT_LIGHT:
- return true;
- case MT_HMI_SETTINGS:
- return true;
- case MT_EMPTY:
- return true;
- default:
- return false;
- }
-}
-
-const char* EnumToJsonString(ModuleType val) {
- switch (val) {
- case MT_CLIMATE:
- return "CLIMATE";
- case MT_RADIO:
- return "RADIO";
- case MT_SEAT:
- return "SEAT";
- case MT_AUDIO:
- return "AUDIO";
- case MT_LIGHT:
- return "LIGHT";
- case MT_HMI_SETTINGS:
- return "HMI_SETTINGS";
- case MT_EMPTY:
- return "EMPTY";
- default:
- return "";
- }
-}
-
-bool EnumFromJsonString(const std::string& literal, ModuleType* result) {
- if ("CLIMATE" == literal) {
- *result = MT_CLIMATE;
- return true;
- } else if ("RADIO" == literal) {
- *result = MT_RADIO;
- return true;
- } else if ("SEAT" == literal) {
- *result = MT_SEAT;
- return true;
- } else if ("AUDIO" == literal) {
- *result = MT_AUDIO;
- return true;
- } else if ("LIGHT" == literal) {
- *result = MT_LIGHT;
- return true;
- } else if ("HMI_SETTINGS" == literal) {
- *result = MT_HMI_SETTINGS;
- return true;
- } else if ("EMPTY" == literal) {
- *result = MT_EMPTY;
- return true;
- }
- return false;
-}
-
-bool IsValidEnum(HybridAppPreference val) {
- return strlen(EnumToJsonString(val)) > 0;
-}
-
-const char* EnumToJsonString(HybridAppPreference val) {
- switch (val) {
- case HAP_MOBILE:
- return "MOBILE";
- case HAP_CLOUD:
- return "CLOUD";
- case HAP_BOTH:
- return "BOTH";
- default:
- return "";
- }
-}
-
-bool EnumFromJsonString(const std::string& literal,
- HybridAppPreference* result) {
- if ("MOBILE" == literal) {
- *result = HAP_MOBILE;
- return true;
- } else if ("CLOUD" == literal) {
- *result = HAP_CLOUD;
- return true;
- } else if ("BOTH" == literal) {
- *result = HAP_BOTH;
- return true;
- }
- return false;
-}
-
-bool IsValidEnum(FunctionID val) {
- switch (val) {
- case RegisterAppInterfaceID:
- return true;
- case UnregisterAppInterfaceID:
- return true;
- case SetGlobalPropertiesID:
- return true;
- case ResetGlobalPropertiesID:
- return true;
- case AddCommandID:
- return true;
- case DeleteCommandID:
- return true;
- case AddSubMenuID:
- return true;
- case DeleteSubMenuID:
- return true;
- case CreateInteractionChoiceSetID:
- return true;
- case PerformInteractionID:
- return true;
- case DeleteInteractionChoiceSetID:
- return true;
- case AlertID:
- return true;
- case ShowID:
- return true;
- case SpeakID:
- return true;
- case SetMediaClockTimerID:
- return true;
- case PerformAudioPassThruID:
- return true;
- case EndAudioPassThruID:
- return true;
- case SubscribeButtonID:
- return true;
- case UnsubscribeButtonID:
- return true;
- case SubscribeVehicleDataID:
- return true;
- case UnsubscribeVehicleDataID:
- return true;
- case GetVehicleDataID:
- return true;
- case ReadDIDID:
- return true;
- case GetDTCsID:
- return true;
- case ScrollableMessageID:
- return true;
- case SliderID:
- return true;
- case ShowConstantTBTID:
- return true;
- case AlertManeuverID:
- return true;
- case UpdateTurnListID:
- return true;
- case ChangeRegistrationID:
- return true;
- case GenericResponseID:
- return true;
- case PutFileID:
- return true;
- case DeleteFileID:
- return true;
- case ListFilesID:
- return true;
- case SetAppIconID:
- return true;
- case SetDisplayLayoutID:
- return true;
- case DiagnosticMessageID:
- return true;
- case SystemRequestID:
- return true;
- case SendLocationID:
- return true;
- case DialNumberID:
- return true;
- case ButtonPressID:
- return true;
- case GetInteriorVehicleDataID:
- return true;
- case SetInteriorVehicleDataID:
- return true;
- case GetWayPointsID:
- return true;
- case SubscribeWayPointsID:
- return true;
- case UnsubscribeWayPointsID:
- return true;
- case GetSystemCapabilityID:
- return true;
- case SendHapticDataID:
- return true;
- case SetCloudAppPropertiesID:
- return true;
- case GetCloudAppPropertiesID:
- return true;
- case PublishAppServiceID:
- return true;
- case GetFileID:
- return true;
- case GetAppServiceDataID:
- return true;
- case PerformAppServiceInteractionID:
- return true;
- case UnpublishAppServiceID:
- return true;
- case CancelInteractionID:
- return true;
- case CreateWindowID:
- return true;
- case DeleteWindowID:
- return true;
- case CloseApplicationID:
- return true;
- case ShowAppMenuID:
- return true;
- case OnHMIStatusID:
- return true;
- case OnAppInterfaceUnregisteredID:
- return true;
- case OnButtonEventID:
- return true;
- case OnButtonPressID:
- return true;
- case OnVehicleDataID:
- return true;
- case OnCommandID:
- return true;
- case OnTBTClientStateID:
- return true;
- case OnDriverDistractionID:
- return true;
- case OnPermissionsChangeID:
- return true;
- case OnAudioPassThruID:
- return true;
- case OnLanguageChangeID:
- return true;
- case OnKeyboardInputID:
- return true;
- case OnTouchEventID:
- return true;
- case OnSystemRequestID:
- return true;
- case OnHashChangeID:
- return true;
- case OnInteriorVehicleDataID:
- return true;
- case OnWayPointChangeID:
- return true;
- case OnRCStatusID:
- return true;
- case OnAppServiceDataID:
- return true;
- case EncodedSyncPDataID:
- return true;
- case SyncPDataID:
- return true;
- case OnEncodedSyncPDataID:
- return true;
- case OnSyncPDataID:
- return true;
- case OnSystemCapabilityUpdatedID:
- return true;
- default:
- return false;
- }
-};
-
-const char* EnumToJsonString(FunctionID val) {
- switch (val) {
- case RegisterAppInterfaceID:
- return "RegisterAppInterface";
- case UnregisterAppInterfaceID:
- return "UnregisterAppInterface";
- case SetGlobalPropertiesID:
- return "SetGlobalProperties";
- case ResetGlobalPropertiesID:
- return "ResetGlobalProperties";
- case AddCommandID:
- return "AddCommand";
- case DeleteCommandID:
- return "DeleteCommand";
- case AddSubMenuID:
- return "AddSubMenu";
- case DeleteSubMenuID:
- return "DeleteSubMenu";
- case CreateInteractionChoiceSetID:
- return "CreateInteractionChoiceSet";
- case PerformInteractionID:
- return "PerformInteraction";
- case DeleteInteractionChoiceSetID:
- return "DeleteInteractionChoiceSet";
- case AlertID:
- return "Alert";
- case ShowID:
- return "Show";
- case SpeakID:
- return "Speak";
- case SetMediaClockTimerID:
- return "SetMediaClockTimer";
- case PerformAudioPassThruID:
- return "PerformAudioPassThru";
- case EndAudioPassThruID:
- return "EndAudioPassThru";
- case SubscribeButtonID:
- return "SubscribeButton";
- case UnsubscribeButtonID:
- return "UnsubscribeButton";
- case SubscribeVehicleDataID:
- return "SubscribeVehicleData";
- case UnsubscribeVehicleDataID:
- return "UnsubscribeVehicleData";
- case GetVehicleDataID:
- return "GetVehicleData";
- case ReadDIDID:
- return "ReadDID";
- case GetDTCsID:
- return "GetDTCs";
- case ScrollableMessageID:
- return "ScrollableMessage";
- case SliderID:
- return "Slider";
- case ShowConstantTBTID:
- return "ShowConstantTBT";
- case AlertManeuverID:
- return "AlertManeuver";
- case UpdateTurnListID:
- return "UpdateTurnList";
- case ChangeRegistrationID:
- return "ChangeRegistration";
- case GenericResponseID:
- return "GenericResponse";
- case PutFileID:
- return "PutFile";
- case DeleteFileID:
- return "DeleteFile";
- case ListFilesID:
- return "ListFiles";
- case SetAppIconID:
- return "SetAppIcon";
- case SetDisplayLayoutID:
- return "SetDisplayLayout";
- case DiagnosticMessageID:
- return "DiagnosticMessage";
- case SystemRequestID:
- return "SystemRequest";
- case SendLocationID:
- return "SendLocation";
- case DialNumberID:
- return "DialNumber";
- case ButtonPressID:
- return "ButtonPress";
- case GetInteriorVehicleDataID:
- return "GetInteriorVehicleData";
- case SetInteriorVehicleDataID:
- return "SetInteriorVehicleData";
- case GetWayPointsID:
- return "GetWayPoints";
- case SubscribeWayPointsID:
- return "SubscribeWayPoints";
- case UnsubscribeWayPointsID:
- return "UnsubscribeWayPoints";
- case GetSystemCapabilityID:
- return "GetSystemCapability";
- case SendHapticDataID:
- return "SendHapticData";
- case SetCloudAppPropertiesID:
- return "SetCloudAppProperties";
- case GetCloudAppPropertiesID:
- return "GetCloudAppProperties";
- case PublishAppServiceID:
- return "PublishAppService";
- case GetFileID:
- return "GetFile";
- case GetAppServiceDataID:
- return "GetAppServiceData";
- case PerformAppServiceInteractionID:
- return "PerformAppServiceInteraction";
- case UnpublishAppServiceID:
- return "UnpublishAppService";
- case CancelInteractionID:
- return "CancelInteraction";
- case CreateWindowID:
- return "CreateWindow";
- case DeleteWindowID:
- return "DeleteWindow";
- case CloseApplicationID:
- return "CloseApplication";
- case ShowAppMenuID:
- return "ShowAppMenu";
- case OnHMIStatusID:
- return "OnHMIStatus";
- case OnAppInterfaceUnregisteredID:
- return "OnAppInterfaceUnregistered";
- case OnButtonEventID:
- return "OnButtonEvent";
- case OnButtonPressID:
- return "OnButtonPress";
- case OnVehicleDataID:
- return "OnVehicleData";
- case OnCommandID:
- return "OnCommand";
- case OnTBTClientStateID:
- return "OnTBTClientState";
- case OnDriverDistractionID:
- return "OnDriverDistraction";
- case OnPermissionsChangeID:
- return "OnPermissionsChange";
- case OnAudioPassThruID:
- return "OnAudioPassThru";
- case OnLanguageChangeID:
- return "OnLanguageChange";
- case OnKeyboardInputID:
- return "OnKeyboardInput";
- case OnTouchEventID:
- return "OnTouchEvent";
- case OnSystemRequestID:
- return "OnSystemRequest";
- case OnHashChangeID:
- return "OnHashChange";
- case OnInteriorVehicleDataID:
- return "OnInteriorVehicleData";
- case OnWayPointChangeID:
- return "OnWayPointChange";
- case OnRCStatusID:
- return "OnRCStatus";
- case OnAppServiceDataID:
- return "OnAppServiceData";
- case EncodedSyncPDataID:
- return "EncodedSyncPData";
- case SyncPDataID:
- return "SyncPData";
- case OnEncodedSyncPDataID:
- return "OnEncodedSyncPData";
- case OnSyncPDataID:
- return "OnSyncPData";
- case OnSystemCapabilityUpdatedID:
- return "OnSystemCapabilityUpdated";
- default:
- return "";
- }
-};
-
-bool EnumFromJsonString(const std::string& literal, FunctionID* result) {
- if ("RegisterAppInterface" == literal) {
- *result = RegisterAppInterfaceID;
- return true;
- }
-
- if ("UnregisterAppInterface" == literal) {
- *result = UnregisterAppInterfaceID;
- return true;
- }
-
- if ("SetGlobalProperties" == literal) {
- *result = SetGlobalPropertiesID;
- return true;
- }
-
- if ("ResetGlobalProperties" == literal) {
- *result = ResetGlobalPropertiesID;
- return true;
- }
-
- if ("AddCommand" == literal) {
- *result = AddCommandID;
- return true;
- }
-
- if ("DeleteCommand" == literal) {
- *result = DeleteCommandID;
- return true;
- }
-
- if ("AddSubMenu" == literal) {
- *result = AddSubMenuID;
- return true;
- }
-
- if ("DeleteSubMenu" == literal) {
- *result = DeleteSubMenuID;
- return true;
- }
-
- if ("CreateInteractionChoiceSet" == literal) {
- *result = CreateInteractionChoiceSetID;
- return true;
- }
-
- if ("PerformInteraction" == literal) {
- *result = PerformInteractionID;
- return true;
- }
-
- if ("DeleteInteractionChoiceSet" == literal) {
- *result = DeleteInteractionChoiceSetID;
- return true;
- }
-
- if ("Alert" == literal) {
- *result = AlertID;
- return true;
- }
-
- if ("Show" == literal) {
- *result = ShowID;
- return true;
- }
-
- if ("Speak" == literal) {
- *result = SpeakID;
- return true;
- }
-
- if ("SetMediaClockTimer" == literal) {
- *result = SetMediaClockTimerID;
- return true;
- }
-
- if ("PerformAudioPassThru" == literal) {
- *result = PerformAudioPassThruID;
- return true;
- }
-
- if ("EndAudioPassThru" == literal) {
- *result = EndAudioPassThruID;
- return true;
- }
-
- if ("SubscribeButton" == literal) {
- *result = SubscribeButtonID;
- return true;
- }
-
- if ("UnsubscribeButton" == literal) {
- *result = UnsubscribeButtonID;
- return true;
- }
-
- if ("SubscribeVehicleData" == literal) {
- *result = SubscribeVehicleDataID;
- return true;
- }
-
- if ("UnsubscribeVehicleData" == literal) {
- *result = UnsubscribeVehicleDataID;
- return true;
- }
-
- if ("GetVehicleData" == literal) {
- *result = GetVehicleDataID;
- return true;
- }
-
- if ("ReadDID" == literal) {
- *result = ReadDIDID;
- return true;
- }
-
- if ("GetDTCs" == literal) {
- *result = GetDTCsID;
- return true;
- }
-
- if ("ScrollableMessage" == literal) {
- *result = ScrollableMessageID;
- return true;
- }
-
- if ("Slider" == literal) {
- *result = SliderID;
- return true;
- }
-
- if ("ShowConstantTBT" == literal) {
- *result = ShowConstantTBTID;
- return true;
- }
-
- if ("AlertManeuver" == literal) {
- *result = AlertManeuverID;
- return true;
- }
-
- if ("UpdateTurnList" == literal) {
- *result = UpdateTurnListID;
- return true;
- }
-
- if ("ChangeRegistration" == literal) {
- *result = ChangeRegistrationID;
- return true;
- }
-
- if ("GenericResponse" == literal) {
- *result = GenericResponseID;
- return true;
- }
-
- if ("PutFile" == literal) {
- *result = PutFileID;
- return true;
- }
-
- if ("DeleteFile" == literal) {
- *result = DeleteFileID;
- return true;
- }
-
- if ("ListFiles" == literal) {
- *result = ListFilesID;
- return true;
- }
-
- if ("SetAppIcon" == literal) {
- *result = SetAppIconID;
- return true;
- }
-
- if ("SetDisplayLayout" == literal) {
- *result = SetDisplayLayoutID;
- return true;
- }
-
- if ("DiagnosticMessage" == literal) {
- *result = DiagnosticMessageID;
- return true;
- }
-
- if ("SystemRequest" == literal) {
- *result = SystemRequestID;
- return true;
- }
-
- if ("SendLocation" == literal) {
- *result = SendLocationID;
- return true;
- }
-
- if ("DialNumber" == literal) {
- *result = DialNumberID;
- return true;
- }
-
- if ("ButtonPress" == literal) {
- *result = ButtonPressID;
- return true;
- }
-
- if ("GetInteriorVehicleData" == literal) {
- *result = GetInteriorVehicleDataID;
- return true;
- }
-
- if ("SetInteriorVehicleData" == literal) {
- *result = SetInteriorVehicleDataID;
- return true;
- }
-
- if ("GetWayPoints" == literal) {
- *result = GetWayPointsID;
- return true;
- }
-
- if ("SubscribeWayPoints" == literal) {
- *result = SubscribeWayPointsID;
- return true;
- }
-
- if ("UnsubscribeWayPoints" == literal) {
- *result = UnsubscribeWayPointsID;
- return true;
- }
-
- if ("GetSystemCapability" == literal) {
- *result = GetSystemCapabilityID;
- return true;
- }
-
- if ("SendHapticData" == literal) {
- *result = SendHapticDataID;
- return true;
- }
-
- if ("SetCloudAppProperties" == literal) {
- *result = SetCloudAppPropertiesID;
- return true;
- }
-
- if ("GetCloudAppProperties" == literal) {
- *result = GetCloudAppPropertiesID;
- return true;
- }
-
- if ("PublishAppService" == literal) {
- *result = PublishAppServiceID;
- return true;
- }
-
- if ("GetFile" == literal) {
- *result = GetFileID;
- return true;
- }
-
- if ("GetAppServiceData" == literal) {
- *result = GetAppServiceDataID;
- return true;
- }
-
- if ("PerformAppServiceInteraction" == literal) {
- *result = PerformAppServiceInteractionID;
- return true;
- }
-
- if ("UnpublishAppService" == literal) {
- *result = UnpublishAppServiceID;
- return true;
- }
-
- if ("CancelInteraction" == literal) {
- *result = CancelInteractionID;
- return true;
- }
-
- if ("CreateWindow" == literal) {
- *result = CreateWindowID;
- return true;
- }
-
- if ("DeleteWindow" == literal) {
- *result = DeleteWindowID;
- return true;
- }
-
- if ("CloseApplication" == literal) {
- *result = CloseApplicationID;
- return true;
- }
-
- if ("ShowAppMenu" == literal) {
- *result = ShowAppMenuID;
- return true;
- }
-
- if ("OnHMIStatus" == literal) {
- *result = OnHMIStatusID;
- return true;
- }
-
- if ("OnAppInterfaceUnregistered" == literal) {
- *result = OnAppInterfaceUnregisteredID;
- return true;
- }
-
- if ("OnButtonEvent" == literal) {
- *result = OnButtonEventID;
- return true;
- }
-
- if ("OnButtonPress" == literal) {
- *result = OnButtonPressID;
- return true;
- }
-
- if ("OnVehicleData" == literal) {
- *result = OnVehicleDataID;
- return true;
- }
-
- if ("OnCommand" == literal) {
- *result = OnCommandID;
- return true;
- }
-
- if ("OnTBTClientState" == literal) {
- *result = OnTBTClientStateID;
- return true;
- }
-
- if ("OnDriverDistraction" == literal) {
- *result = OnDriverDistractionID;
- return true;
- }
-
- if ("OnPermissionsChange" == literal) {
- *result = OnPermissionsChangeID;
- return true;
- }
-
- if ("OnAudioPassThru" == literal) {
- *result = OnAudioPassThruID;
- return true;
- }
-
- if ("OnLanguageChange" == literal) {
- *result = OnLanguageChangeID;
- return true;
- }
-
- if ("OnKeyboardInput" == literal) {
- *result = OnKeyboardInputID;
- return true;
- }
-
- if ("OnTouchEvent" == literal) {
- *result = OnTouchEventID;
- return true;
- }
-
- if ("OnSystemRequest" == literal) {
- *result = OnSystemRequestID;
- return true;
- }
-
- if ("OnHashChange" == literal) {
- *result = OnHashChangeID;
- return true;
- }
-
- if ("OnInteriorVehicleData" == literal) {
- *result = OnInteriorVehicleDataID;
- return true;
- }
-
- if ("OnWayPointChange" == literal) {
- *result = OnWayPointChangeID;
- return true;
- }
-
- if ("OnRCStatus" == literal) {
- *result = OnRCStatusID;
- return true;
- }
-
- if ("OnAppServiceData" == literal) {
- *result = OnAppServiceDataID;
- return true;
- }
-
- if ("OnSystemCapabilityUpdated" == literal) {
- *result = OnSystemCapabilityUpdatedID;
- return true;
- }
-
- if ("EncodedSyncPData" == literal) {
- *result = EncodedSyncPDataID;
- return true;
- }
-
- if ("SyncPData" == literal) {
- *result = SyncPDataID;
- return true;
- }
-
- if ("OnEncodedSyncPData" == literal) {
- *result = OnEncodedSyncPDataID;
- return true;
- }
-
- if ("OnSyncPData" == literal) {
- *result = OnSyncPDataID;
- return true;
- }
- return false;
-};
const std::string kDefaultApp = "default";
const std::string kPreDataConsentApp = "pre_DataConsent";
diff --git a/src/components/policy/policy_regular/src/policy_table/types.cc b/src/components/policy/policy_regular/src/policy_table/types.cc
index 704cbacf4c..4032f27f99 100644
--- a/src/components/policy/policy_regular/src/policy_table/types.cc
+++ b/src/components/policy/policy_regular/src/policy_table/types.cc
@@ -658,9 +658,60 @@ void Rpcs::SetPolicyTableType(PolicyTableType pt_type) {
rpcs.SetPolicyTableType(pt_type);
}
+// EndpointProperties methods
+EndpointProperty::EndpointProperty() : CompositeType(kUninitialized) {}
+
+EndpointProperty::~EndpointProperty() {}
+
+EndpointProperty::EndpointProperty(const Json::Value* value__)
+ : CompositeType(InitHelper(value__, &Json::Value::isObject))
+ , version(impl::ValueMember(value__, "version")) {}
+
+Json::Value EndpointProperty::ToJsonValue() const {
+ Json::Value result__(Json::objectValue);
+ impl::WriteJsonField("version", version, &result__);
+ return result__;
+}
+
+bool EndpointProperty::is_valid() const {
+ if (!version.is_valid()) {
+ return false;
+ }
+ return Validate();
+}
+
+bool EndpointProperty::is_initialized() const {
+ return (initialization_state__ != kUninitialized) || (!struct_empty());
+}
+
+bool EndpointProperty::struct_empty() const {
+ if (version.is_initialized()) {
+ return false;
+ }
+
+ return true;
+}
+
+void EndpointProperty::ReportErrors(rpc::ValidationReport* report__) const {
+ if (struct_empty()) {
+ rpc::CompositeType::ReportErrors(report__);
+ }
+ if (!version.is_valid()) {
+ version.ReportErrors(&report__->ReportSubobject("version"));
+ }
+}
+
+void EndpointProperty::SetPolicyTableType(PolicyTableType pt_type) {
+ CompositeType::SetPolicyTableType(pt_type);
+ version.SetPolicyTableType(pt_type);
+}
+
// ModuleConfig methods
ModuleConfig::ModuleConfig() : CompositeType(kUninitialized) {}
+const std::string ModuleConfig::kDefaultOemMappingServiceName =
+ "custom_vehicle_data_mapping_url";
+
ModuleConfig::ModuleConfig(
uint8_t exchange_after_x_ignition_cycles,
int64_t exchange_after_x_kilometers,
@@ -668,6 +719,7 @@ ModuleConfig::ModuleConfig(
uint16_t timeout_after_x_seconds,
const SecondsBetweenRetries& seconds_between_retries,
const ServiceEndpoints& endpoints,
+ const ServiceEndpointProperties& endpoint_properties,
const NumberOfNotificationsPerMinute& notifications_per_minute_by_priority)
: CompositeType(kUninitialized)
, exchange_after_x_ignition_cycles(exchange_after_x_ignition_cycles)
@@ -676,6 +728,7 @@ ModuleConfig::ModuleConfig(
, timeout_after_x_seconds(timeout_after_x_seconds)
, seconds_between_retries(seconds_between_retries)
, endpoints(endpoints)
+ , endpoint_properties(endpoint_properties)
, notifications_per_minute_by_priority(
notifications_per_minute_by_priority) {}
@@ -696,6 +749,7 @@ ModuleConfig::ModuleConfig(const Json::Value* value__)
, seconds_between_retries(
impl::ValueMember(value__, "seconds_between_retries"))
, endpoints(impl::ValueMember(value__, "endpoints"))
+ , endpoint_properties(impl::ValueMember(value__, "endpoint_properties"))
, notifications_per_minute_by_priority(
impl::ValueMember(value__, "notifications_per_minute_by_priority"))
, vehicle_make(impl::ValueMember(value__, "vehicle_make"))
@@ -715,6 +769,7 @@ void ModuleConfig::SafeCopyFrom(const ModuleConfig& from) {
timeout_after_x_seconds = from.timeout_after_x_seconds;
seconds_between_retries = from.seconds_between_retries;
endpoints = from.endpoints;
+ endpoint_properties = from.endpoint_properties;
notifications_per_minute_by_priority =
from.notifications_per_minute_by_priority;
@@ -743,6 +798,7 @@ Json::Value ModuleConfig::ToJsonValue() const {
impl::WriteJsonField(
"seconds_between_retries", seconds_between_retries, &result__);
impl::WriteJsonField("endpoints", endpoints, &result__);
+ impl::WriteJsonField("endpoint_properties", endpoint_properties, &result__);
impl::WriteJsonField("notifications_per_minute_by_priority",
notifications_per_minute_by_priority,
&result__);
@@ -782,6 +838,9 @@ bool ModuleConfig::is_valid() const {
if (!endpoints.is_valid()) {
return false;
}
+ if (!endpoint_properties.is_valid()) {
+ return false;
+ }
if (!notifications_per_minute_by_priority.is_valid()) {
return false;
}
@@ -835,10 +894,15 @@ bool ModuleConfig::struct_empty() const {
if (seconds_between_retries.is_initialized()) {
return false;
}
+
if (endpoints.is_initialized()) {
return false;
}
+ if (endpoint_properties.is_initialized()) {
+ return false;
+ }
+
if (notifications_per_minute_by_priority.is_initialized()) {
return false;
}
@@ -896,6 +960,10 @@ void ModuleConfig::ReportErrors(rpc::ValidationReport* report__) const {
if (!endpoints.is_valid()) {
endpoints.ReportErrors(&report__->ReportSubobject("endpoints"));
}
+ if (!endpoint_properties.is_valid()) {
+ endpoint_properties.ReportErrors(
+ &report__->ReportSubobject("endpoint_properties"));
+ }
if (!notifications_per_minute_by_priority.is_valid()) {
notifications_per_minute_by_priority.ReportErrors(
&report__->ReportSubobject("notifications_per_minute_by_priority"));
@@ -942,6 +1010,7 @@ void ModuleConfig::SetPolicyTableType(PolicyTableType pt_type) {
timeout_after_x_seconds.SetPolicyTableType(pt_type);
seconds_between_retries.SetPolicyTableType(pt_type);
endpoints.SetPolicyTableType(pt_type);
+ endpoint_properties.SetPolicyTableType(pt_type);
notifications_per_minute_by_priority.SetPolicyTableType(pt_type);
lock_screen_dismissal_enabled.SetPolicyTableType(pt_type);
vehicle_make.SetPolicyTableType(pt_type);
@@ -1563,6 +1632,419 @@ void DeviceParams::ReportErrors(rpc::ValidationReport* report__) const {
}
}
+// VehicleDataItem methods
+VehicleDataItem::VehicleDataItem() : CompositeType(kUninitialized) {}
+
+VehicleDataItem::VehicleDataItem(const VehicleDataItem& vehicle_data)
+ : CompositeType(vehicle_data.initialization_state__)
+ , name(vehicle_data.name)
+ , type(vehicle_data.type)
+ , key(vehicle_data.key)
+ , mandatory(vehicle_data.mandatory)
+ , params(vehicle_data.params)
+ , array(vehicle_data.array)
+ , since(vehicle_data.since)
+ , until(vehicle_data.until)
+ , removed(vehicle_data.removed)
+ , deprecated(vehicle_data.deprecated)
+ , minvalue(vehicle_data.minvalue)
+ , maxvalue(vehicle_data.maxvalue)
+ , minsize(vehicle_data.minsize)
+ , maxsize(vehicle_data.maxsize)
+ , minlength(vehicle_data.minlength)
+ , maxlength(vehicle_data.maxlength) {}
+
+VehicleDataItem::VehicleDataItem(const Json::Value* value__)
+ : CompositeType(InitHelper(value__, &Json::Value::isObject))
+ , name(impl::ValueMember(value__, "name"))
+ , type(impl::ValueMember(value__, "type"))
+ , key(impl::ValueMember(value__, "key"))
+ , mandatory(impl::ValueMember(value__, "mandatory"))
+ , params(impl::ValueMember(value__, "params"))
+ , array(impl::ValueMember(value__, "array"))
+ , since(impl::ValueMember(value__, "since"))
+ , until(impl::ValueMember(value__, "until"))
+ , removed(impl::ValueMember(value__, "removed"))
+ , deprecated(impl::ValueMember(value__, "deprecated"))
+ , minvalue(impl::ValueMember(value__, "minvalue"))
+ , maxvalue(impl::ValueMember(value__, "maxvalue"))
+ , minsize(impl::ValueMember(value__, "minsize"))
+ , maxsize(impl::ValueMember(value__, "maxsize"))
+ , minlength(impl::ValueMember(value__, "minlength"))
+ , maxlength(impl::ValueMember(value__, "maxlength")) {}
+
+VehicleDataItem::~VehicleDataItem() {}
+
+const std::string VehicleDataItem::kInteger = "Integer";
+const std::string VehicleDataItem::kStruct = "Struct";
+const std::string VehicleDataItem::kString = "String";
+const std::string VehicleDataItem::kFloat = "Float";
+const std::string VehicleDataItem::kDouble = "Double";
+const std::string VehicleDataItem::kBoolean = "Boolean";
+
+const std::vector<std::string> VehicleDataItem::kPODTypes = {
+ kInteger, kFloat, kDouble, kString, kBoolean};
+
+Json::Value VehicleDataItem::ToJsonValue() const {
+ Json::Value ret(Json::objectValue);
+ impl::WriteJsonField("name", name, &ret);
+ impl::WriteJsonField("type", type, &ret);
+ impl::WriteJsonField("key", key, &ret);
+ impl::WriteJsonField("array", array, &ret);
+ impl::WriteJsonField("mandatory", mandatory, &ret);
+ impl::WriteJsonField("params", params, &ret);
+ impl::WriteJsonField("since", since, &ret);
+ impl::WriteJsonField("until", until, &ret);
+ impl::WriteJsonField("removed", removed, &ret);
+ impl::WriteJsonField("deprecated", deprecated, &ret);
+ impl::WriteJsonField("minvalue", minvalue, &ret);
+ impl::WriteJsonField("maxvalue", maxvalue, &ret);
+ impl::WriteJsonField("minsize", minsize, &ret);
+ impl::WriteJsonField("maxsize", maxsize, &ret);
+ impl::WriteJsonField("minlength", minlength, &ret);
+ impl::WriteJsonField("maxlength", maxlength, &ret);
+ return ret;
+}
+
+bool VehicleDataItem::operator==(const VehicleDataItem& vd) {
+ return (name == vd.name && type == vd.type && key == vd.key &&
+ mandatory == vd.mandatory && params == vd.params &&
+ array == vd.array && since == vd.since && until == vd.until &&
+ removed == vd.removed && deprecated == vd.deprecated &&
+ minvalue == vd.minvalue && maxvalue == vd.maxvalue &&
+ minsize == vd.minsize && maxsize == vd.maxsize &&
+ minlength == vd.minlength && maxlength == vd.maxlength);
+}
+
+bool VehicleDataItem::is_valid() const {
+ if (!name.is_valid()) {
+ return false;
+ }
+ if (!type.is_valid()) {
+ return false;
+ }
+ if (!key.is_valid()) {
+ return false;
+ }
+ if (!array.is_valid()) {
+ return false;
+ }
+ if (!mandatory.is_valid()) {
+ return false;
+ }
+ if (!params.is_valid()) {
+ return false;
+ }
+ if (!since.is_valid()) {
+ return false;
+ }
+ if (!until.is_valid()) {
+ return false;
+ }
+ if (!removed.is_valid()) {
+ return false;
+ }
+ if (!deprecated.is_valid()) {
+ return false;
+ }
+ if (!minvalue.is_valid()) {
+ return false;
+ }
+ if (!maxvalue.is_valid()) {
+ return false;
+ }
+ if (!minsize.is_valid()) {
+ return false;
+ }
+ if (!maxsize.is_valid()) {
+ return false;
+ }
+ if (!minlength.is_valid()) {
+ return false;
+ }
+ if (!maxlength.is_valid()) {
+ return false;
+ }
+ return Validate();
+}
+
+bool VehicleDataItem::is_initialized() const {
+ return (initialization_state__ != kUninitialized) || (struct_not_empty());
+}
+
+bool VehicleDataItem::struct_not_empty() const {
+ if (!name.is_initialized()) {
+ return false;
+ }
+ if (!type.is_initialized()) {
+ return false;
+ }
+ if (!key.is_initialized()) {
+ return false;
+ }
+ if (!array.is_initialized()) {
+ return false;
+ }
+ if (!mandatory.is_initialized()) {
+ return false;
+ }
+ if (!params.is_initialized()) {
+ return false;
+ }
+ if (!since.is_initialized()) {
+ return false;
+ }
+ if (!until.is_initialized()) {
+ return false;
+ }
+ if (!removed.is_initialized()) {
+ return false;
+ }
+ if (!deprecated.is_initialized()) {
+ return false;
+ }
+ if (!minvalue.is_initialized()) {
+ return false;
+ }
+ if (!maxvalue.is_initialized()) {
+ return false;
+ }
+ if (!minsize.is_initialized()) {
+ return false;
+ }
+ if (!maxsize.is_initialized()) {
+ return false;
+ }
+ if (!minlength.is_initialized()) {
+ return false;
+ }
+ if (!maxlength.is_initialized()) {
+ return false;
+ }
+ return true;
+}
+
+void VehicleDataItem::ReportErrors(rpc::ValidationReport* report__) const {
+ if (!struct_not_empty()) {
+ rpc::CompositeType::ReportErrors(report__);
+ }
+ if (!name.is_valid()) {
+ name.ReportErrors(&report__->ReportSubobject("name"));
+ }
+ if (!ValidateNaming(std::string(name))) {
+ report__->set_validation_info(
+ "Invalid name values [" + std::string(name) +
+ "]. It should not contain spaces or invalid chars.");
+ }
+ if (!type.is_valid()) {
+ type.ReportErrors(&report__->ReportSubobject("type"));
+ }
+ if (type.is_initialized() && !ValidateTypes()) {
+ report__->set_validation_info("Unknown type [" + std::string(name) +
+ "]: '" + std::string(type) + "'.");
+ }
+ if (!key.is_valid()) {
+ key.ReportErrors(&report__->ReportSubobject("key"));
+ }
+ if (!ValidateNaming(std::string(key))) {
+ report__->set_validation_info(
+ "Invalid key values [" + std::string(key) +
+ "]. It should not contain spaces or invalid chars.");
+ }
+ if (!array.is_valid()) {
+ array.ReportErrors(&report__->ReportSubobject("array"));
+ }
+ if (!mandatory.is_valid()) {
+ mandatory.ReportErrors(&report__->ReportSubobject("mandatory"));
+ }
+ if (!params.is_valid()) {
+ params.ReportErrors(&report__->ReportSubobject("params"));
+ }
+ if (!since.is_valid()) {
+ since.ReportErrors(&report__->ReportSubobject("since"));
+ }
+ if (!until.is_valid()) {
+ until.ReportErrors(&report__->ReportSubobject("until"));
+ }
+ if (!removed.is_valid()) {
+ removed.ReportErrors(&report__->ReportSubobject("removed"));
+ }
+ if (!deprecated.is_valid()) {
+ deprecated.ReportErrors(&report__->ReportSubobject("deprecated"));
+ }
+ if (!minvalue.is_valid()) {
+ minvalue.ReportErrors(&report__->ReportSubobject("minvalue"));
+ }
+ if (!maxvalue.is_valid()) {
+ maxvalue.ReportErrors(&report__->ReportSubobject("maxvalue"));
+ }
+ if (!minsize.is_valid()) {
+ minsize.ReportErrors(&report__->ReportSubobject("minsize"));
+ }
+ if (!maxsize.is_valid()) {
+ maxsize.ReportErrors(&report__->ReportSubobject("maxsize"));
+ }
+ if (!minlength.is_valid()) {
+ minlength.ReportErrors(&report__->ReportSubobject("minlength"));
+ }
+ if (!maxlength.is_valid()) {
+ maxlength.ReportErrors(&report__->ReportSubobject("maxlength"));
+ }
+}
+
+void VehicleDataItem::SetPolicyTableType(PolicyTableType pt_type) {
+ CompositeType::SetPolicyTableType(pt_type);
+ name.SetPolicyTableType(pt_type);
+ type.SetPolicyTableType(pt_type);
+ key.SetPolicyTableType(pt_type);
+ array.SetPolicyTableType(pt_type);
+ mandatory.SetPolicyTableType(pt_type);
+ params.SetPolicyTableType(pt_type);
+ since.SetPolicyTableType(pt_type);
+ until.SetPolicyTableType(pt_type);
+ removed.SetPolicyTableType(pt_type);
+ deprecated.SetPolicyTableType(pt_type);
+ minvalue.SetPolicyTableType(pt_type);
+ maxvalue.SetPolicyTableType(pt_type);
+ minsize.SetPolicyTableType(pt_type);
+ maxsize.SetPolicyTableType(pt_type);
+ minlength.SetPolicyTableType(pt_type);
+ maxlength.SetPolicyTableType(pt_type);
+}
+
+bool VehicleDataItem::ValidateNaming(std::string str) const {
+ auto contains_spec_chars = [](std::string str) {
+ const auto invalid_chars = "!@#$%^&*";
+ return str.npos != str.find_first_of(invalid_chars);
+ };
+
+ auto contains_spaces = [](std::string str) {
+ const auto found_space =
+ std::find_if(str.begin(), str.end(), [](unsigned char ch) {
+ return std::isspace(ch);
+ });
+
+ return found_space != str.end();
+ };
+
+ auto empty_string = [](std::string str) {
+ str.erase(std::remove_if(str.begin(),
+ str.end(),
+ [](unsigned char ch) { return std::isspace(ch); }),
+ str.end());
+ return str.length() < 1;
+ };
+
+ return !empty_string(str) && !contains_spaces(str) &&
+ !contains_spec_chars(str);
+}
+
+bool VehicleDataItem::ValidateTypes() const {
+ if (IsPrimitiveType() || NULL != EnumSchemaItemFactory::Get(type)) {
+ // params should be empty for POD types
+ // and for enum values, generated from API
+ return (!(params.is_initialized()) || params->empty());
+ }
+
+ if ("Struct" == std::string(type)) {
+ return params.is_initialized() && !(params->empty()) && params.is_valid();
+ }
+ return false;
+}
+
+bool VehicleDataItem::IsPrimitiveType() const {
+ return helpers::in_range(kPODTypes, std::string(type));
+}
+
+// VehicleData methods
+VehicleData::VehicleData() : CompositeType(kUninitialized) {}
+
+VehicleData::VehicleData(const VehicleData& vehicle_data)
+ : CompositeType(vehicle_data.initialization_state__)
+ , schema_version(vehicle_data.schema_version)
+ , schema_items(vehicle_data.schema_items) {}
+
+VehicleData::VehicleData(const Json::Value* value__)
+ : CompositeType(InitHelper(value__, &Json::Value::isObject))
+ , schema_version(impl::ValueMember(value__, "schema_version"))
+ , schema_items(impl::ValueMember(value__, "schema_items")) {}
+
+VehicleData::~VehicleData() {}
+
+bool VehicleData::is_valid() const {
+ if (!schema_version.is_valid()) {
+ return false;
+ }
+ if (!schema_items.is_valid()) {
+ return false;
+ }
+ return Validate();
+}
+
+bool VehicleData::is_initialized() const {
+ return (initialization_state__ != kUninitialized) || (!struct_empty());
+}
+
+bool VehicleData::struct_empty() const {
+ if (schema_version.is_initialized()) {
+ return false;
+ }
+ if (schema_items.is_initialized()) {
+ return false;
+ }
+ return true;
+}
+
+Json::Value VehicleData::ToJsonValue() const {
+ Json::Value ret(Json::objectValue);
+ impl::WriteJsonField("schema_version", schema_version, &ret);
+ impl::WriteJsonField("schema_items", schema_items, &ret);
+ return ret;
+}
+
+void VehicleData::ReportErrors(rpc::ValidationReport* report__) const {
+ if (struct_empty()) {
+ rpc::CompositeType::ReportErrors(report__);
+ }
+ const auto pt_type = GetPolicyTableType();
+ const auto pt_type_str = PolicyTableTypeToString(pt_type);
+ std::string validation_info = "";
+
+ if (PT_SNAPSHOT == pt_type) {
+ if (schema_items.is_initialized()) {
+ validation_info +=
+ "; schema_items " + omitted_validation_info + pt_type_str;
+ }
+ if (!schema_version.is_initialized()) {
+ validation_info +=
+ "; schema_version " + required_validation_info + pt_type_str;
+ }
+ report__->set_validation_info(validation_info);
+ }
+
+ if (PT_UPDATE == pt_type || PT_PRELOADED == pt_type) {
+ if ((schema_version.is_initialized() && !schema_items.is_initialized()) ||
+ (!schema_version.is_initialized() && schema_items.is_initialized())) {
+ validation_info += "; schema_version and schema_items " +
+ required_validation_info + pt_type_str;
+ }
+ report__->set_validation_info(validation_info);
+ }
+
+ if (!schema_version.is_valid()) {
+ schema_version.ReportErrors(&report__->ReportSubobject("schema_version"));
+ }
+ if (!schema_items.is_valid()) {
+ schema_items.ReportErrors(&report__->ReportSubobject("schema_items"));
+ }
+}
+
+void VehicleData::SetPolicyTableType(PolicyTableType pt_type) {
+ CompositeType::SetPolicyTableType(pt_type);
+ schema_version.SetPolicyTableType(pt_type);
+ schema_items.SetPolicyTableType(pt_type);
+}
+
// PolicyTable methods
PolicyTable::PolicyTable() : CompositeType(kUninitialized) {}
@@ -1589,7 +2071,8 @@ PolicyTable::PolicyTable(const Json::Value* value__)
, module_meta(impl::ValueMember(value__, "module_meta"))
, usage_and_error_counts(
impl::ValueMember(value__, "usage_and_error_counts"))
- , device_data(impl::ValueMember(value__, "device_data")) {}
+ , device_data(impl::ValueMember(value__, "device_data"))
+ , vehicle_data(impl::ValueMember(value__, "vehicle_data")) {}
Json::Value PolicyTable::ToJsonValue() const {
Json::Value result__(Json::objectValue);
@@ -1602,6 +2085,7 @@ Json::Value PolicyTable::ToJsonValue() const {
impl::WriteJsonField(
"usage_and_error_counts", usage_and_error_counts, &result__);
impl::WriteJsonField("device_data", device_data, &result__);
+ impl::WriteJsonField("vehicle_data", vehicle_data, &result__);
return result__;
}
@@ -1627,6 +2111,9 @@ bool PolicyTable::is_valid() const {
if (!device_data.is_valid()) {
return false;
}
+ if (!vehicle_data.is_valid()) {
+ return false;
+ }
return Validate();
}
@@ -1659,6 +2146,9 @@ bool PolicyTable::struct_empty() const {
if (device_data.is_initialized()) {
return false;
}
+ if (vehicle_data.is_initialized()) {
+ return false;
+ }
return true;
}
@@ -1701,6 +2191,9 @@ void PolicyTable::ReportErrors(rpc::ValidationReport* report__) const {
if (!device_data.is_valid()) {
device_data.ReportErrors(&report__->ReportSubobject("device_data"));
}
+ if (!vehicle_data.is_valid()) {
+ vehicle_data.ReportErrors(&report__->ReportSubobject("vehicle_data"));
+ }
}
void PolicyTable::SetPolicyTableType(PolicyTableType pt_type) {
@@ -1712,6 +2205,7 @@ void PolicyTable::SetPolicyTableType(PolicyTableType pt_type) {
module_meta.SetPolicyTableType(pt_type);
usage_and_error_counts.SetPolicyTableType(pt_type);
device_data.SetPolicyTableType(pt_type);
+ vehicle_data.SetPolicyTableType(pt_type);
}
// Table methods
diff --git a/src/components/policy/policy_regular/src/policy_table/validation.cc b/src/components/policy/policy_regular/src/policy_table/validation.cc
index 059c18d00e..14b6d657c2 100644
--- a/src/components/policy/policy_regular/src/policy_table/validation.cc
+++ b/src/components/policy/policy_regular/src/policy_table/validation.cc
@@ -196,6 +196,14 @@ bool Rpcs::Validate() const {
return true;
}
+bool EndpointProperty::Validate() const {
+ if (!version.is_valid()) {
+ return false;
+ }
+
+ return true;
+}
+
bool ModuleConfig::Validate() const {
if (PT_PRELOADED == GetPolicyTableType()) {
if (vehicle_make.is_initialized()) {
@@ -221,6 +229,14 @@ bool ModuleConfig::Validate() const {
}
}
+ if (endpoint_properties.is_initialized()) {
+ const auto& endpoint_property =
+ endpoint_properties->find(kDefaultOemMappingServiceName);
+ if (endpoint_properties->end() != endpoint_property) {
+ return (*endpoint_property).second.version.is_initialized();
+ }
+ }
+
return true;
}
@@ -268,6 +284,39 @@ bool DeviceParams::Validate() const {
return true;
}
+bool VehicleDataItem::Validate() const {
+ if (!ValidateNaming(std::string(name))) {
+ return false;
+ };
+
+ if (!ValidateNaming(std::string(key))) {
+ return false;
+ };
+
+ if (!ValidateTypes()) {
+ LOG4CXX_ERROR(
+ logger_,
+ "Unknown type: " << std::string(type) << " of " << std::string(key));
+ return false;
+ }
+ return true;
+}
+
+bool VehicleData::Validate() const {
+ const PolicyTableType policy_table_type = GetPolicyTableType();
+ bool result = true;
+ if (PT_SNAPSHOT == policy_table_type) {
+ result =
+ (!schema_items.is_initialized()) && schema_version.is_initialized();
+ }
+ if (PT_UPDATE == policy_table_type || PT_PRELOADED == policy_table_type) {
+ result =
+ (schema_version.is_initialized() && schema_items.is_initialized()) ||
+ (!schema_version.is_initialized() && !schema_items.is_initialized());
+ }
+ return result;
+}
+
bool PolicyTable::Validate() const {
const PolicyTableType policy_table_type = GetPolicyTableType();
diff --git a/src/components/policy/policy_regular/src/sql_pt_queries.cc b/src/components/policy/policy_regular/src/sql_pt_queries.cc
index 760a647853..6c961a8db3 100644
--- a/src/components/policy/policy_regular/src/sql_pt_queries.cc
+++ b/src/components/policy/policy_regular/src/sql_pt_queries.cc
@@ -352,6 +352,13 @@ const std::string kCreateSchema =
"); "
"CREATE INDEX IF NOT EXISTS `endpoint.fk_endpoint_application1_idx` "
" ON `endpoint`(`application_id` COLLATE NOCASE); "
+
+ /*endpoint properties*/
+ "CREATE TABLE IF NOT EXISTS `endpoint_properties`( "
+ " `service` VARCHAR(100) NOT NULL, "
+ " `version` VARCHAR(100) NOT NULL "
+ ");"
+
"CREATE TABLE IF NOT EXISTS `message`( "
" `id` INTEGER PRIMARY KEY NOT NULL, "
" `tts` TEXT, "
@@ -409,6 +416,42 @@ const std::string kCreateSchema =
"CREATE TABLE IF NOT EXISTS `_internal_data`( "
" `db_version_hash` INTEGER "
" ); "
+
+ /*vehicle data*/
+ "CREATE TABLE IF NOT EXISTS `vehicle_data`( "
+ " `schema_version` VARCHAR(100) NOT NULL "
+ ");"
+
+ /* vehicle data item definition*/
+ "CREATE TABLE IF NOT EXISTS `vehicle_data_item_definition`( "
+ " `name` VARCHAR(255) NOT NULL, "
+ " `type` VARCHAR(255) NOT NULL, "
+ " `key` VARCHAR(255) NOT NULL, "
+ " `mandatory` BOOL NOT NULL, "
+ " `array` BOOL, "
+ " `since` VARCHAR(45), "
+ " `until` VARCHAR(45), "
+ " `removed` BOOL, "
+ " `deprecated` BOOL, "
+ " `minvalue` INTEGER, "
+ " `maxvalue` INTEGER, "
+ " `minsize` INTEGER, "
+ " `maxsize` INTEGER, "
+ " `minlength` INTEGER, "
+ " `maxlength` INTEGER "
+ "); "
+ "CREATE TABLE IF NOT EXISTS `vehicle_data_item_parameters`( "
+ " `parent_name` VARCHAR(255) NOT NULL, "
+ " `parent_key` VARCHAR(255) NOT NULL, "
+ " `param_name` VARCHAR(255) NOT NULL, "
+ " `param_key` VARCHAR(255) NOT NULL, "
+ " CONSTRAINT `fk_vdi_id` "
+ " FOREIGN KEY(`parent_name`, `parent_key`) "
+ " REFERENCES `vehicle_data_item_definition`(`name`, `key`), "
+ " CONSTRAINT `fk_vdi_param_id` "
+ " FOREIGN KEY(`param_name`, `param_key`) "
+ " REFERENCES `vehicle_data_item_definition`(`name`, `key`) "
+ "); "
"COMMIT;";
const std::string kInsertInitData =
@@ -424,6 +467,8 @@ const std::string kInsertInitData =
" `exchange_after_x_ignition_cycles`, `exchange_after_x_kilometers`, "
" `exchange_after_x_days`, `timeout_after_x_seconds`)"
" VALUES(1, 0, 0, 0, 0, 0); "
+ "INSERT OR IGNORE INTO `vehicle_data` (`schema_version`) "
+ "VALUES('0'); "
"INSERT OR IGNORE INTO `priority`(`value`) VALUES ('EMERGENCY'); "
"INSERT OR IGNORE INTO `priority`(`value`) VALUES ('NAVIGATION'); "
"INSERT OR IGNORE INTO `priority`(`value`) VALUES ('VOICECOMMUNICATION'); "
@@ -488,6 +533,7 @@ const std::string kDropSchema =
"DROP TABLE IF EXISTS `message`; "
"DROP INDEX IF EXISTS `endpoint.fk_endpoint_application1_idx`; "
"DROP TABLE IF EXISTS `endpoint`; "
+ "DROP TABLE IF EXISTS `endpoint_properties`; "
"DROP INDEX IF EXISTS `consent_group.fk_consent_group_device1_idx`; "
"DROP INDEX IF EXISTS "
"`consent_group.fk_consent_group_functional_group1_idx`; "
@@ -550,6 +596,9 @@ const std::string kDropSchema =
"DROP TABLE IF EXISTS `usage_and_error_count`; "
"DROP TABLE IF EXISTS `device`; "
"DROP TABLE IF EXISTS `_internal_data`; "
+ "DROP TABLE IF EXISTS `vehicle_data`; "
+ "DROP TABLE IF EXISTS `vehicle_data_item_definition`; "
+ "DROP TABLE IF EXISTS `vehicle_data_item_parameters`; "
"COMMIT; "
"VACUUM;";
@@ -558,6 +607,7 @@ const std::string kDeleteData =
"DELETE FROM `message`; "
"DELETE FROM `module_type`; "
"DELETE FROM `endpoint`; "
+ "DELETE FROM `endpoint_properties`; "
"DELETE FROM `consent_group`; "
"DELETE FROM `app_type`; "
"DELETE FROM `nickname`; "
@@ -581,6 +631,9 @@ const std::string kDeleteData =
"DELETE FROM `remote_rpc`; "
"DELETE FROM `usage_and_error_count`; "
"DELETE FROM `device`; "
+ "DELETE FROM `vehicle_data`; "
+ "DELETE FROM `vehicle_data_item_definition`; "
+ "DELETE FROM `vehicle_data_item_parameters`; "
"COMMIT; "
"VACUUM;";
@@ -588,6 +641,82 @@ const std::string kCheckDBIntegrity = "PRAGMA integrity_check";
const std::string kCheckPgNumber = "PRAGMA page_count";
+const std::string kSelectEndpointProperties =
+ "SELECT `service`, `version` FROM `endpoint_properties`";
+
+const std::string kSelectVehicleDataSchemaVersion =
+ "SELECT `schema_version` FROM `vehicle_data` ";
+
+const std::string kSelectVehicleDataItem =
+ "SELECT * FROM `vehicle_data_item_definition` "
+ "WHERE `name` IS ? AND `key` IS ?";
+
+const std::string kSelectVehicleDataItemWithVersion =
+ "SELECT * FROM `vehicle_data_item_definition` "
+ "WHERE `name` IS ? AND `key` IS ? AND `since` IS ? AND `until` IS ?";
+
+const std::string kSelectVehicleDataItemParams =
+ "SELECT * FROM `vehicle_data_item_parameters` "
+ "WHERE `parent_name` IS ? AND `parent_key` IS ?";
+
+const std::string kSelectCompositeVehicleDataItemsKey =
+ "SELECT DISTINCT `parent_name`, `parent_key` FROM "
+ "`vehicle_data_item_parameters` "
+ "LEFT JOIN "
+ "(SELECT DISTINCT `param_name`, `param_key` FROM "
+ "`vehicle_data_item_parameters`) `vdi_params` ON "
+ "`vehicle_data_item_parameters`.`parent_name` = `vdi_params`.`param_name` "
+ "AND "
+ "`vehicle_data_item_parameters`.`parent_key` = `vdi_params`.`param_key` "
+ "where `vdi_params`.`param_key` is null";
+
+const std::string kSelectPrimitiveVehicleDataItems =
+ "SELECT * FROM `vehicle_data_item_definition` "
+ "LEFT JOIN ( "
+ "SELECT `parent_name`, `parent_key` FROM `vehicle_data_item_parameters` "
+ "UNION "
+ "SELECT `param_name`, `param_key` FROM `vehicle_data_item_parameters`) "
+ "`vdi_params` ON "
+ "`vehicle_data_item_definition`.`name` = `vdi_params`.`parent_name` "
+ "AND "
+ "`vehicle_data_item_definition`.`key` = `vdi_params`.`parent_key` "
+ "WHERE `vdi_params`.`parent_key` IS NULL";
+
+const std::string kInsertVehicleDataSchemaVersion =
+ "UPDATE `vehicle_data` SET `schema_version` = ?";
+
+const std::string kInsertEndpointVersion =
+ "INSERT OR REPLACE INTO `endpoint_properties`(`service`, "
+ "`version`) "
+ "VALUES(?, ?)";
+
+const std::string kInsertVehicleDataItem =
+ "INSERT INTO `vehicle_data_item_definition` ("
+ " `name`, "
+ " `type`, "
+ " `key`, "
+ " `mandatory`, "
+ " `array`, "
+ " `since`, "
+ " `until`, "
+ " `removed`, "
+ " `deprecated`, "
+ " `minvalue`, "
+ " `maxvalue`, "
+ " `minsize`, "
+ " `maxsize`, "
+ " `minlength`, "
+ " `maxlength`) "
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ";
+
+const std::string kInsertVehicleDataItemParams =
+ "INSERT INTO `vehicle_data_item_parameters` ("
+ " `parent_name`, "
+ " `parent_key`, "
+ " `param_name`, "
+ " `param_key`) "
+ "VALUES (?, ?, ?, ?) ";
+
const std::string kSelectRpc =
"SELECT DISTINCT `rpc`.`parameter` FROM `rpc` "
" JOIN `app_group` AS `g` ON (`g`.`functional_group_id` = "
@@ -860,6 +989,12 @@ const std::string kDeleteAppServiceNames = "DELETE FROM `app_service_names`";
const std::string kDeleteAppServiceHandledRpcs =
"DELETE FROM `app_service_handled_rpcs`";
+const std::string kDeleteVehicleDataItems =
+ "DELETE FROM `vehicle_data_item_definition`";
+
+const std::string kDeleteVehicleDataItemParams =
+ "DELETE FROM `vehicle_data_item_parameters`";
+
const std::string kSelectApplicationRevoked =
"SELECT `is_revoked` FROM `application` WHERE `id` = ?";
diff --git a/src/components/policy/policy_regular/src/sql_pt_representation.cc b/src/components/policy/policy_regular/src/sql_pt_representation.cc
index 50d5e282e1..ce0527600a 100644
--- a/src/components/policy/policy_regular/src/sql_pt_representation.cc
+++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc
@@ -421,16 +421,6 @@ bool SQLPTRepresentation::Close() {
return db_->LastError().number() == utils::dbms::OK;
}
-const VehicleInfo SQLPTRepresentation::GetVehicleInfo() const {
- policy_table::ModuleConfig module_config;
- GatherModuleConfig(&module_config);
- VehicleInfo vehicle_info;
- vehicle_info.vehicle_make = *module_config.vehicle_make;
- vehicle_info.vehicle_model = *module_config.vehicle_model;
- vehicle_info.vehicle_year = *module_config.vehicle_year;
- return vehicle_info;
-}
-
bool SQLPTRepresentation::Drop() {
utils::dbms::SQLQuery query(db());
if (!query.Exec(sql_pt::kDropSchema)) {
@@ -495,6 +485,11 @@ std::shared_ptr<policy_table::Table> SQLPTRepresentation::GenerateSnapshot()
GatherConsumerFriendlyMessages(
&*table->policy_table.consumer_friendly_messages);
GatherApplicationPoliciesSection(&table->policy_table.app_policies_section);
+ GatherVehicleData(&*table->policy_table.vehicle_data);
+ if (!table->policy_table.vehicle_data.is_initialized()) {
+ rpc::Optional<rpc::String<0, 100> > null_version;
+ table->policy_table.vehicle_data->schema_version = null_version;
+ }
return table;
}
@@ -542,6 +537,18 @@ void SQLPTRepresentation::GatherModuleConfig(
}
}
+ utils::dbms::SQLQuery endpoint_properties(db());
+ if (!endpoint_properties.Prepare(sql_pt::kSelectEndpointProperties)) {
+ LOG4CXX_ERROR(logger_, "Incorrect statement for Endpoint properties");
+ } else {
+ while (endpoint_properties.Next()) {
+ const std::string& service = endpoint_properties.GetString(0);
+ const std::string& version = endpoint_properties.GetString(1);
+ auto& ep_properties = (*config->endpoint_properties);
+ *ep_properties[service].version = version;
+ }
+ }
+
utils::dbms::SQLQuery notifications(db());
if (!notifications.Prepare(sql_pt::kSelectNotificationsPerMin)) {
LOG4CXX_WARN(logger_, "Incorrect select statement for notifications");
@@ -633,18 +640,17 @@ bool SQLPTRepresentation::GatherFunctionalGroupings(
}
}
if (!rpcs.IsNull(2)) {
- policy_table::Parameter param;
- if (EnumFromJsonString(rpcs.GetString(2), &param)) {
- // EMPTY is a special mark to specify that 'parameters' section is
- // present, but has no parameters. It is not valid parameter value.
- if (policy_table::P_EMPTY == param) {
- (*rpcs_structure.rpcs[rpcs.GetString(0)].parameters)
- .mark_initialized();
- continue;
- }
- InsertUnique(param,
- &(*rpcs_structure.rpcs[rpcs.GetString(0)].parameters));
+ std::string param = rpcs.GetString(2);
+ // EMPTY is a special mark to specify that 'parameters' section is
+ // present, but has no parameters. It is not valid parameter value.
+ if (policy_table::EnumToJsonString(policy_table::P_EMPTY) == param) {
+ (*rpcs_structure.rpcs[rpcs.GetString(0)].parameters)
+ .mark_initialized();
+ continue;
}
+
+ InsertUnique(param,
+ &(*rpcs_structure.rpcs[rpcs.GetString(0)].parameters));
}
}
@@ -789,6 +795,44 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection(
return true;
}
+bool SQLPTRepresentation::GatherVehicleData(
+ policy_table::VehicleData* vehicle_data) const {
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kSelectVehicleDataSchemaVersion) ||
+ !query.Next()) {
+ LOG4CXX_ERROR(logger_,
+ "Incorrect statement for vehicle data schema version");
+ return false;
+ }
+ *vehicle_data->schema_version = query.GetString(0);
+
+ vehicle_data->mark_initialized();
+ return GatherVehicleDataItems(&*vehicle_data->schema_items);
+}
+
+bool SQLPTRepresentation::GatherVehicleDataItems(
+ policy_table::VehicleDataItems* vehicle_data_items) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ auto parameterized_vdi = SelectCompositeVehicleDataItems();
+ if (!parameterized_vdi.is_initialized()) {
+ return false;
+ }
+
+ auto non_parameterized_vdi = SelectPrimitiveVehicleDataItems();
+ if (!non_parameterized_vdi.is_initialized()) {
+ return false;
+ }
+
+ vehicle_data_items->insert(vehicle_data_items->end(),
+ parameterized_vdi.begin(),
+ parameterized_vdi.end());
+ vehicle_data_items->insert(vehicle_data_items->end(),
+ non_parameterized_vdi.begin(),
+ non_parameterized_vdi.end());
+
+ return true;
+}
+
bool SQLPTRepresentation::Save(const policy_table::Table& table) {
LOG4CXX_AUTO_TRACE(logger_);
db_->BeginTransaction();
@@ -823,6 +867,10 @@ bool SQLPTRepresentation::Save(const policy_table::Table& table) {
db_->RollbackTransaction();
return false;
}
+ if (!SaveVehicleData(*table.policy_table.vehicle_data)) {
+ db_->RollbackTransaction();
+ return false;
+ }
db_->CommitTransaction();
return true;
}
@@ -901,8 +949,7 @@ bool SQLPTRepresentation::SaveRpcs(int64_t group_id,
query_parameter.Bind(0, it->first);
query_parameter.Bind(
1, std::string(policy_table::EnumToJsonString(*hmi_it)));
- query_parameter.Bind(
- 2, std::string(policy_table::EnumToJsonString(*ps_it)));
+ query_parameter.Bind(2, std::string(*ps_it));
query_parameter.Bind(3, group_id);
if (!query_parameter.Exec() || !query_parameter.Reset()) {
LOG4CXX_WARN(logger_, "Incorrect insert into rpc with parameter");
@@ -1249,7 +1296,9 @@ bool SQLPTRepresentation::SaveRequestSubType(
} else if (request_subtypes.is_initialized()) {
LOG4CXX_WARN(logger_, "Request subtypes empty.");
query.Bind(0, app_id);
- query.Bind(1, std::string("EMPTY"));
+ query.Bind(1,
+ std::string(policy_table::EnumToJsonString(
+ policy_table::RequestType::RT_EMPTY)));
if (!query.Exec() || !query.Reset()) {
LOG4CXX_WARN(logger_, "Incorrect insert into request subtypes.");
return false;
@@ -1402,6 +1451,10 @@ bool SQLPTRepresentation::SaveModuleConfig(
return false;
}
+ if (!SaveServiceEndpointProperties(*config.endpoint_properties)) {
+ return false;
+ }
+
return true;
}
@@ -1440,6 +1493,31 @@ bool SQLPTRepresentation::SaveServiceEndpoints(
return true;
}
+bool SQLPTRepresentation::SaveServiceEndpointProperties(
+ const policy_table::ServiceEndpointProperties& endpoint_properties) {
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kInsertEndpointVersion)) {
+ LOG4CXX_WARN(
+ logger_,
+ "Incorrect insert of endpoint property to endpoint_properties.");
+ return false;
+ }
+
+ for (auto& endpoint_property : endpoint_properties) {
+ query.Bind(0, endpoint_property.first);
+ query.Bind(1, endpoint_property.second.version);
+
+ if (!query.Exec() || !query.Reset()) {
+ LOG4CXX_WARN(
+ logger_,
+ "Failed to insert endpoint property into endpoint_properties.");
+ return false;
+ }
+ }
+
+ return true;
+}
+
bool SQLPTRepresentation::SaveConsumerFriendlyMessages(
const policy_table::ConsumerFriendlyMessages& messages) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -1659,6 +1737,44 @@ bool SQLPTRepresentation::SaveUsageAndErrorCounts(
return true;
}
+bool SQLPTRepresentation::SaveVehicleData(
+ const policy_table::VehicleData& vehicle_data) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (vehicle_data.is_initialized() &&
+ vehicle_data.schema_version.is_initialized()) {
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kInsertVehicleDataSchemaVersion)) {
+ LOG4CXX_WARN(logger_,
+ "Incorrect insert of schema_version to vehicle_data.");
+ return false;
+ }
+ query.Bind(0, (*vehicle_data.schema_version));
+ if (!query.Exec() || !query.Reset()) {
+ LOG4CXX_WARN(logger_, "Failed to insert schema_version to vehicle_data.");
+ return false;
+ }
+ }
+
+ auto vehicle_data_items = vehicle_data.is_initialized() &&
+ vehicle_data.schema_items.is_initialized()
+ ? *(vehicle_data.schema_items)
+ : policy_table::VehicleDataItems();
+
+ return SaveVehicleDataItems(vehicle_data_items);
+}
+
+bool SQLPTRepresentation::SaveVehicleDataItems(
+ const policy_table::VehicleDataItems& vehicle_data_items) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ DeleteVehicleDataItems();
+ for (const auto& item : vehicle_data_items) {
+ if (!InsertVehicleDataItem(item)) {
+ return false;
+ }
+ }
+ return true;
+}
+
void SQLPTRepresentation::IncrementIgnitionCycles() {
utils::dbms::SQLQuery query(db());
if (!query.Exec(sql_pt::kIncrementIgnitionCycles)) {
@@ -1788,7 +1904,8 @@ bool SQLPTRepresentation::GatherRequestSubType(
query.Bind(0, app_id);
while (query.Next()) {
const std::string request_subtype = query.GetString(0);
- if ("EMPTY" == request_subtype) {
+ if (policy_table::EnumToJsonString(policy_table::RT_EMPTY) ==
+ request_subtype) {
request_subtypes->mark_initialized();
continue;
}
@@ -2368,4 +2485,306 @@ bool SQLPTRepresentation::SetVINValue(const std::string& value) {
return true;
}
+bool SQLPTRepresentation::VehicleDataItemExists(
+ const policy_table::VehicleDataItem& vehicle_data_item) const {
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kSelectVehicleDataItemWithVersion)) {
+ LOG4CXX_ERROR(logger_,
+ "Incorrent select statement for vehicle data item. "
+ << query.LastError().text());
+ return false;
+ }
+
+ query.Bind(0, vehicle_data_item.name);
+ query.Bind(1, vehicle_data_item.key);
+ vehicle_data_item.since.is_initialized()
+ ? query.Bind(2, std::string(*vehicle_data_item.since))
+ : query.Bind(2);
+ vehicle_data_item.until.is_initialized()
+ ? query.Bind(3, std::string(*vehicle_data_item.until))
+ : query.Bind(3);
+
+ if (!query.Exec()) {
+ LOG4CXX_ERROR(logger_,
+ "Failed to retrieve vehicle data item: "
+ << std::string(vehicle_data_item.key)
+ << ". Error: " << query.LastError().text());
+ return false;
+ }
+ return !query.IsNull(0);
+}
+
+policy_table::VehicleDataItems SQLPTRepresentation::GetVehicleDataItem(
+ const std::string& name, const std::string& key) const {
+ policy_table::VehicleDataItems result;
+ utils::dbms::SQLQuery query(db());
+
+ if (!query.Prepare(sql_pt::kSelectVehicleDataItem)) {
+ LOG4CXX_ERROR(logger_,
+ "Incorrent select statement of vehicle data item. "
+ << query.LastError().text());
+ return result;
+ }
+
+ query.Bind(0, name);
+ query.Bind(1, key);
+
+ while (query.Next()) {
+ auto vdi = PopulateVDIFromQuery(query);
+ if (!vdi.is_initialized()) {
+ return policy_table::VehicleDataItems();
+ }
+
+ utils::dbms::SQLQuery param_query(db());
+ if (policy_table::VehicleDataItem::kStruct ==
+ static_cast<std::string>(vdi.type)) {
+ if (!param_query.Prepare(sql_pt::kSelectVehicleDataItemParams)) {
+ LOG4CXX_ERROR(logger_,
+ "Incorrent select statement of vehicle data item. "
+ << param_query.LastError().text());
+ return policy_table::VehicleDataItems();
+ }
+
+ param_query.Bind(0, name);
+ param_query.Bind(1, key);
+
+ while (param_query.Next()) {
+ const auto param_with_diff_versions = GetVehicleDataItem(
+ param_query.GetString(2), param_query.GetString(3));
+ if (!param_with_diff_versions.is_initialized()) {
+ return policy_table::VehicleDataItems();
+ }
+ for (const auto& param : param_with_diff_versions) {
+ vdi.params->push_back(param);
+ }
+ }
+ }
+
+ result.push_back(vdi);
+ }
+ if (!result.empty()) {
+ result.mark_initialized();
+ }
+
+ return result;
+}
+
+policy_table::VehicleDataItem SQLPTRepresentation::PopulateVDIFromQuery(
+ const utils::dbms::SQLQuery& query) const {
+ policy_table::VehicleDataItem result;
+
+ result.name = query.GetString(0);
+ result.type = query.GetString(1);
+ result.key = query.GetString(2);
+ result.mandatory = query.GetBoolean(3);
+
+ if (!query.IsNull(4)) {
+ *result.array = query.GetBoolean(4);
+ }
+ if (!query.IsNull(5)) {
+ *result.since = query.GetString(5);
+ }
+ if (!query.IsNull(6)) {
+ *result.until = query.GetString(6);
+ }
+ if (!query.IsNull(7)) {
+ *result.removed = query.GetBoolean(7);
+ }
+ if (!query.IsNull(8)) {
+ *result.deprecated = query.GetBoolean(8);
+ }
+ if (!query.IsNull(9)) {
+ *result.minvalue = query.GetInteger(9);
+ }
+ if (!query.IsNull(10)) {
+ *result.maxvalue = query.GetInteger(10);
+ }
+ if (!query.IsNull(11)) {
+ *result.minsize = query.GetUInteger(11);
+ }
+ if (!query.IsNull(12)) {
+ *result.maxsize = query.GetUInteger(12);
+ }
+ if (!query.IsNull(13)) {
+ *result.minlength = query.GetUInteger(13);
+ }
+ if (!query.IsNull(14)) {
+ *result.maxlength = query.GetUInteger(14);
+ }
+ result.params->mark_initialized();
+
+ result.mark_initialized();
+ return result;
+}
+
+bool SQLPTRepresentation::InsertVehicleDataItem(
+ const policy_table::VehicleDataItem& vehicle_data_item) {
+ utils::dbms::SQLQuery query(db());
+
+ if (!vehicle_data_item.is_initialized() || !vehicle_data_item.is_valid()) {
+ LOG4CXX_ERROR(logger_, "Vehicle data item is not initialized.");
+ return false;
+ }
+
+ if (VehicleDataItemExists(vehicle_data_item)) {
+ LOG4CXX_INFO(logger_,
+ static_cast<std::string>(vehicle_data_item.key)
+ << " is already stored.");
+ return true;
+ }
+
+ if (!query.Prepare(sql_pt::kInsertVehicleDataItem)) {
+ LOG4CXX_ERROR(logger_,
+ "Incorrent select statement of vehicle data item. "
+ << query.LastError().text());
+ return false;
+ }
+
+ query.Bind(0, vehicle_data_item.name);
+ query.Bind(1, vehicle_data_item.type);
+ query.Bind(2, vehicle_data_item.key);
+ query.Bind(3, vehicle_data_item.mandatory);
+ vehicle_data_item.array.is_initialized()
+ ? query.Bind(4, *vehicle_data_item.array)
+ : query.Bind(4);
+ vehicle_data_item.since.is_initialized()
+ ? query.Bind(5, *vehicle_data_item.since)
+ : query.Bind(5);
+ vehicle_data_item.until.is_initialized()
+ ? query.Bind(6, *vehicle_data_item.until)
+ : query.Bind(6);
+ vehicle_data_item.removed.is_initialized()
+ ? query.Bind(7, *vehicle_data_item.removed)
+ : query.Bind(7);
+ vehicle_data_item.deprecated.is_initialized()
+ ? query.Bind(8, *vehicle_data_item.deprecated)
+ : query.Bind(8);
+ vehicle_data_item.minvalue.is_initialized()
+ ? query.Bind(9, *vehicle_data_item.minvalue)
+ : query.Bind(9);
+ vehicle_data_item.maxvalue.is_initialized()
+ ? query.Bind(10, *vehicle_data_item.maxvalue)
+ : query.Bind(10);
+ vehicle_data_item.minsize.is_initialized()
+ ? query.Bind(11, static_cast<int64_t>(*vehicle_data_item.minsize))
+ : query.Bind(11);
+ vehicle_data_item.maxsize.is_initialized()
+ ? query.Bind(12, static_cast<int64_t>(*vehicle_data_item.maxsize))
+ : query.Bind(12);
+ vehicle_data_item.minlength.is_initialized()
+ ? query.Bind(13, static_cast<int64_t>(*vehicle_data_item.minlength))
+ : query.Bind(13);
+ vehicle_data_item.maxlength.is_initialized()
+ ? query.Bind(14, static_cast<int64_t>(*vehicle_data_item.maxlength))
+ : query.Bind(14);
+
+ if (!query.Exec() || !query.Reset()) {
+ LOG4CXX_ERROR(logger_,
+ "Failed to insert vehicle data item: "
+ << static_cast<std::string>(vehicle_data_item.key)
+ << ". Error: " << query.LastError().text());
+ return false;
+ }
+
+ if (vehicle_data_item.params->is_initialized()) {
+ for (const auto& param : *(vehicle_data_item.params)) {
+ if (!InsertVehicleDataItem(param)) {
+ return false;
+ }
+
+ if (!query.Prepare(sql_pt::kInsertVehicleDataItemParams)) {
+ LOG4CXX_ERROR(logger_,
+ "Incorrent select statement of vehicle data item. "
+ << query.LastError().text());
+ return false;
+ }
+
+ query.Bind(0, vehicle_data_item.name);
+ query.Bind(1, vehicle_data_item.key);
+ query.Bind(2, param.name);
+ query.Bind(3, param.key);
+
+ if (!query.Exec() || !query.Reset()) {
+ LOG4CXX_ERROR(
+ logger_,
+ "Failed to insert to vehicle data item relations helper table: "
+ << static_cast<std::string>(param.key)
+ << ". Error: " << query.LastError().text());
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+policy_table::VehicleDataItems
+SQLPTRepresentation::SelectCompositeVehicleDataItems() const {
+ utils::dbms::SQLQuery query(db());
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (!query.Prepare(sql_pt::kSelectCompositeVehicleDataItemsKey)) {
+ LOG4CXX_ERROR(logger_,
+ "Incorrect statement for parameterized vehicle data items");
+ return policy_table::VehicleDataItems();
+ }
+
+ policy_table::VehicleDataItems result;
+ result.mark_initialized();
+
+ while (query.Next()) {
+ const auto vdi = GetVehicleDataItem(query.GetString(0), query.GetString(1));
+ if (!vdi.is_initialized()) {
+ return policy_table::VehicleDataItems();
+ }
+ for (const auto& item : vdi) {
+ result.push_back(item);
+ }
+ }
+
+ return result;
+}
+
+policy_table::VehicleDataItems
+SQLPTRepresentation::SelectPrimitiveVehicleDataItems() const {
+ utils::dbms::SQLQuery query(db());
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (!query.Prepare(sql_pt::kSelectPrimitiveVehicleDataItems)) {
+ LOG4CXX_ERROR(
+ logger_,
+ "Incorrect statement for non parameterized vehicle data items");
+ return policy_table::VehicleDataItems();
+ }
+
+ auto result = policy_table::VehicleDataItems();
+ result.mark_initialized();
+
+ while (query.Next()) {
+ const auto vdi = PopulateVDIFromQuery(query);
+ if (!vdi.is_initialized()) {
+ return policy_table::VehicleDataItems();
+ }
+ result.push_back(vdi);
+ }
+ return result;
+}
+
+bool SQLPTRepresentation::DeleteVehicleDataItems() const {
+ utils::dbms::SQLQuery query(db());
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ if (!query.Exec(sql_pt::kDeleteVehicleDataItems)) {
+ LOG4CXX_ERROR(logger_,
+ "Failed clearing database: " << query.LastError().text());
+ return false;
+ }
+
+ if (!query.Exec(sql_pt::kDeleteVehicleDataItemParams)) {
+ LOG4CXX_ERROR(logger_,
+ "Failed clearing database: " << query.LastError().text());
+ return false;
+ }
+
+ return true;
+}
+
} // namespace policy
diff --git a/src/components/policy/policy_regular/test/include/policy/mock_pt_representation.h b/src/components/policy/policy_regular/test/include/policy/mock_pt_representation.h
index 44f7733985..8cf3884c11 100644
--- a/src/components/policy/policy_regular/test/include/policy/mock_pt_representation.h
+++ b/src/components/policy/policy_regular/test/include/policy/mock_pt_representation.h
@@ -64,7 +64,6 @@ class MockPTRepresentation : virtual public PTRepresentation {
MOCK_METHOD1(SecondsBetweenRetries, bool(std::vector<int>* seconds));
MOCK_METHOD2(GetPriority,
bool(const std::string& app_id, std::string* priority));
- MOCK_CONST_METHOD0(GetVehicleInfo, const VehicleInfo());
MOCK_METHOD1(SetVINValue, bool(const std::string& value));
MOCK_METHOD2(
GetUserFriendlyMsg,
diff --git a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc
index ed80e904b4..ce0d3f5941 100644
--- a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc
+++ b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc
@@ -51,10 +51,10 @@
#include "utils/date_time.h"
#include "utils/file_system.h"
+#include "utils/gen_hash.h"
#include "utils/macro.h"
#include "policy/mock_access_remote.h"
-#include "utils/gen_hash.h"
using ::testing::_;
using ::testing::AtLeast;
@@ -77,6 +77,12 @@ namespace custom_str = utils::custom_string;
typedef std::multimap<std::string, policy_table::Rpcs&>
UserConsentPromptToRpcsConnections;
+namespace {
+std::string kSpeed = "speed";
+std::string kRPM = "rpm";
+std::string kFuelLevel = "fuelLevel";
+} // namespace
+
template <typename T>
std::string NumberToString(T Number) {
std::ostringstream ss;
@@ -142,17 +148,18 @@ class PolicyManagerImplTest : public ::testing::Test {
protected:
PolicyManagerImpl* manager;
- MockCacheManagerInterface* cache_manager;
+ NiceMock<MockCacheManagerInterface>* cache_manager;
NiceMock<MockPolicyListener> listener;
+ NiceMock<MockUpdateStatusManager> update_status_manager;
const std::string device_id;
std::shared_ptr<access_remote_test::MockAccessRemote> access_remote;
void SetUp() OVERRIDE {
manager = new PolicyManagerImpl();
manager->set_listener(&listener);
- cache_manager = new MockCacheManagerInterface();
+ cache_manager = new NiceMock<MockCacheManagerInterface>();
manager->set_cache_manager(cache_manager);
- access_remote = std::shared_ptr<access_remote_test::MockAccessRemote>();
+ access_remote = std::make_shared<access_remote_test::MockAccessRemote>();
manager->set_access_remote(access_remote);
}
@@ -169,6 +176,78 @@ class PolicyManagerImplTest : public ::testing::Test {
return ::testing::AssertionFailure() << ::rpc::PrettyFormat(report);
}
}
+
+ void PrepareUpdateWithFunctionalGroupingContent(policy_table::Table& update) {
+ using namespace application_manager;
+
+ update.SetPolicyTableType(rpc::policy_table_interface_base::PT_UPDATE);
+
+ policy_table::Rpcs rpcs;
+ rpcs.mark_initialized();
+
+ policy_table::Rpc rpc;
+ rpc.mark_initialized();
+
+ policy_table::RpcParameters rpc_params;
+ rpc_params.mark_initialized();
+ rpc_params.hmi_levels.push_back(
+ rpc::policy_table_interface_base::HmiLevel::HL_FULL);
+ rpc_params.hmi_levels.push_back(
+ rpc::policy_table_interface_base::HmiLevel::HL_BACKGROUND);
+
+ (*rpc_params.parameters).push_back(kRPM);
+ (*rpc_params.parameters).push_back(kSpeed);
+
+ rpc["GetVehicleData"] = rpc_params;
+ rpcs.rpcs = rpc;
+
+ policy_table::FunctionalGroupings fg;
+ fg["TestGroup1"] = rpcs;
+
+ update.policy_table.functional_groupings = fg;
+
+ policy_table::ApplicationParams app_params;
+ app_params.mark_initialized();
+ app_params.priority =
+ rpc::policy_table_interface_base::Priority::P_COMMUNICATION;
+ app_params.groups.push_back("TestGroup1");
+ update.policy_table.app_policies_section.apps["1234"] = app_params;
+ }
+
+ void ExpectOnPermissionsUpdated() {
+ std::string dev_id_1 = "dev_id_1";
+ std::string app_id = "1234";
+
+ EXPECT_CALL(*cache_manager, IsDefaultPolicy(app_id)).WillOnce(Return(true));
+ EXPECT_CALL(*access_remote, IsAppRemoteControl(_)).WillOnce(Return(true));
+
+ FunctionalGroupNames fg_names;
+ fg_names[0] =
+ std::make_pair<std::string, std::string>("fg_name_1", "fg_name_2");
+ EXPECT_CALL(*cache_manager, GetFunctionalGroupNames(_))
+ .WillOnce(DoAll(SetArgReferee<0>(fg_names), Return(true)));
+
+ std::vector<std::string> device_ids;
+ device_ids.push_back(dev_id_1);
+ EXPECT_CALL(listener, GetDevicesIds(app_id))
+ .WillRepeatedly(Return(device_ids));
+
+ int32_t group_id = 0;
+ FunctionalGroupIDs group_ids;
+ group_ids.push_back(group_id);
+ FunctionalIdType group_types;
+ group_types[GroupType::kTypeGeneral] = group_ids;
+ EXPECT_CALL(*access_remote, GetPermissionsForApp(dev_id_1, app_id, _))
+ .WillRepeatedly(DoAll(SetArgReferee<2>(group_types), Return(true)));
+
+ EXPECT_CALL(listener, OnPermissionsUpdated(dev_id_1, app_id, _, _))
+ .Times(1);
+
+ EXPECT_CALL(listener, GetAppName(_))
+ .WillOnce(Return(custom_str::CustomString("")));
+
+ EXPECT_CALL(listener, OnUpdateStatusChanged(_)).Times(1);
+ }
};
class PolicyManagerImplTest2 : public ::testing::Test {
@@ -208,7 +287,7 @@ class PolicyManagerImplTest2 : public ::testing::Test {
.WillByDefault(ReturnRef(kAppStorageFolder));
ON_CALL(policy_settings_, use_full_app_id()).WillByDefault(Return(true));
manager->set_listener(&listener);
- const char* levels[] = {"BACKGROUND", "FULL", "LIMITED", "NONE"};
+ const char* levels[] = {"FULL", "LIMITED", "BACKGROUND", "NONE"};
hmi_level.assign(levels, levels + sizeof(levels) / sizeof(levels[0]));
srand(time(NULL));
index = rand() % 3;
@@ -899,13 +978,207 @@ TEST_F(PolicyManagerImplTest, LoadPT_SetPT_PTIsLoaded) {
std::make_shared<policy_table::Table>(update.policy_table);
// Assert
EXPECT_CALL(*cache_manager, GenerateSnapshot()).WillOnce(Return(snapshot));
+ EXPECT_CALL(*cache_manager, GetVehicleDataItems())
+ .WillOnce(Return(std::vector<policy_table::VehicleDataItem>()));
EXPECT_CALL(*cache_manager, ApplyUpdate(_)).WillOnce(Return(true));
- EXPECT_CALL(listener, GetAppName("1234"))
- .WillOnce(Return(custom_str::CustomString("")));
- EXPECT_CALL(listener, OnUpdateStatusChanged(_));
+ EXPECT_CALL(listener, GetDevicesIds("1234"))
+ .WillRepeatedly(Return(transport_manager::DeviceList()));
EXPECT_CALL(*cache_manager, SaveUpdateRequired(false));
EXPECT_CALL(*cache_manager, TimeoutResponse());
EXPECT_CALL(*cache_manager, SecondsBetweenRetries(_));
+ EXPECT_TRUE(manager->LoadPT("file_pt_update.json", msg));
+}
+
+TEST_F(PolicyManagerImplTest, LoadPT_FunctionalGroup_removeRPC_SendUpdate) {
+ // Arrange
+ manager->ForcePTExchange();
+ manager->OnUpdateStarted();
+ Json::Value table = CreatePTforLoad();
+ policy_table::Table update(&table);
+
+ PrepareUpdateWithFunctionalGroupingContent(update);
+
+ std::shared_ptr<policy_table::Table> snapshot =
+ std::make_shared<policy_table::Table>(update.policy_table);
+
+ const auto& fg_found =
+ update.policy_table.functional_groupings.find("TestGroup1");
+ fg_found->second.rpcs.erase("GetVehicleData");
+
+ ASSERT_TRUE(IsValid(update));
+
+ const std::string json = update.ToJsonValue().toStyledString();
+ ::policy::BinaryMessage msg(json.begin(), json.end());
+
+ // Assert
+ EXPECT_CALL(*cache_manager, GetVehicleDataItems())
+ .WillOnce(Return(std::vector<policy_table::VehicleDataItem>()));
+ EXPECT_CALL(*cache_manager, GenerateSnapshot()).WillOnce(Return(snapshot));
+ EXPECT_CALL(*cache_manager, ApplyUpdate(_)).WillOnce(Return(true));
+ ExpectOnPermissionsUpdated();
+
+ EXPECT_TRUE(manager->LoadPT("file_pt_update.json", msg));
+}
+
+TEST_F(PolicyManagerImplTest,
+ LoadPT_FunctionalGroup_removeRPCParams_SendUpdate) {
+ // Arrange
+ manager->ForcePTExchange();
+ manager->OnUpdateStarted();
+ Json::Value table = CreatePTforLoad();
+ policy_table::Table update(&table);
+
+ PrepareUpdateWithFunctionalGroupingContent(update);
+
+ std::shared_ptr<policy_table::Table> snapshot =
+ std::make_shared<policy_table::Table>(update.policy_table);
+
+ const auto& fg_found =
+ update.policy_table.functional_groupings.find("TestGroup1");
+ policy_table::RpcParameters& new_rpc_params =
+ fg_found->second.rpcs["GetVehicleData"];
+ new_rpc_params.parameters->erase(new_rpc_params.parameters->begin());
+
+ ASSERT_TRUE(IsValid(update));
+
+ const std::string json = update.ToJsonValue().toStyledString();
+ ::policy::BinaryMessage msg(json.begin(), json.end());
+
+ // Assert
+ EXPECT_CALL(*cache_manager, GenerateSnapshot()).WillOnce(Return(snapshot));
+ EXPECT_CALL(*cache_manager, GetVehicleDataItems())
+ .WillOnce(Return(std::vector<policy_table::VehicleDataItem>()));
+ EXPECT_CALL(*cache_manager, ApplyUpdate(_)).WillOnce(Return(true));
+ ExpectOnPermissionsUpdated();
+
+ EXPECT_TRUE(manager->LoadPT("file_pt_update.json", msg));
+}
+
+TEST_F(PolicyManagerImplTest,
+ LoadPT_FunctionalGroup_removeRPC_HMILevels_SendUpdate) {
+ // Arrange
+ manager->ForcePTExchange();
+ manager->OnUpdateStarted();
+ Json::Value table = CreatePTforLoad();
+ policy_table::Table update(&table);
+
+ PrepareUpdateWithFunctionalGroupingContent(update);
+
+ std::shared_ptr<policy_table::Table> snapshot =
+ std::make_shared<policy_table::Table>(update.policy_table);
+
+ const auto& fg_found =
+ update.policy_table.functional_groupings.find("TestGroup1");
+ policy_table::RpcParameters& new_rpc_params =
+ fg_found->second.rpcs["GetVehicleData"];
+ new_rpc_params.hmi_levels.erase(new_rpc_params.hmi_levels.begin());
+
+ ASSERT_TRUE(IsValid(update));
+
+ const std::string json = update.ToJsonValue().toStyledString();
+ ::policy::BinaryMessage msg(json.begin(), json.end());
+
+ // Assert
+ EXPECT_CALL(*cache_manager, GenerateSnapshot()).WillOnce(Return(snapshot));
+ EXPECT_CALL(*cache_manager, GetVehicleDataItems())
+ .WillOnce(Return(std::vector<policy_table::VehicleDataItem>()));
+ EXPECT_CALL(*cache_manager, ApplyUpdate(_)).WillOnce(Return(true));
+ ExpectOnPermissionsUpdated();
+
+ EXPECT_TRUE(manager->LoadPT("file_pt_update.json", msg));
+}
+
+TEST_F(PolicyManagerImplTest,
+ LoadPT_FunctionalGroup_addRPC_HMILevels_SendUpdate) {
+ // Arrange
+ manager->ForcePTExchange();
+ manager->OnUpdateStarted();
+ Json::Value table = CreatePTforLoad();
+ policy_table::Table update(&table);
+
+ PrepareUpdateWithFunctionalGroupingContent(update);
+
+ std::shared_ptr<policy_table::Table> snapshot =
+ std::make_shared<policy_table::Table>(update.policy_table);
+
+ const auto& fg_found =
+ update.policy_table.functional_groupings.find("TestGroup1");
+ policy_table::RpcParameters& new_rpc_params =
+ fg_found->second.rpcs["GetVehicleData"];
+ new_rpc_params.hmi_levels.push_back(
+ rpc::policy_table_interface_base::HmiLevel::HL_LIMITED);
+
+ ASSERT_TRUE(IsValid(update));
+
+ const std::string json = update.ToJsonValue().toStyledString();
+ ::policy::BinaryMessage msg(json.begin(), json.end());
+
+ // Assert
+ EXPECT_CALL(*cache_manager, GenerateSnapshot()).WillOnce(Return(snapshot));
+ EXPECT_CALL(*cache_manager, GetVehicleDataItems())
+ .WillOnce(Return(std::vector<policy_table::VehicleDataItem>()));
+ EXPECT_CALL(*cache_manager, ApplyUpdate(_)).WillOnce(Return(true));
+ ExpectOnPermissionsUpdated();
+
+ EXPECT_TRUE(manager->LoadPT("file_pt_update.json", msg));
+}
+
+TEST_F(PolicyManagerImplTest, LoadPT_FunctionalGroup_addRPCParams_SendUpdate) {
+ using namespace application_manager;
+ // Arrange
+ manager->ForcePTExchange();
+ manager->OnUpdateStarted();
+ Json::Value table = CreatePTforLoad();
+ policy_table::Table update(&table);
+
+ PrepareUpdateWithFunctionalGroupingContent(update);
+
+ std::shared_ptr<policy_table::Table> snapshot =
+ std::make_shared<policy_table::Table>(update.policy_table);
+
+ const auto& fg_found =
+ update.policy_table.functional_groupings.find("TestGroup1");
+ policy_table::RpcParameters& new_rpc_params =
+ fg_found->second.rpcs["GetVehicleData"];
+ (*new_rpc_params.parameters).push_back(kFuelLevel);
+
+ ASSERT_TRUE(IsValid(update));
+
+ const std::string json = update.ToJsonValue().toStyledString();
+ ::policy::BinaryMessage msg(json.begin(), json.end());
+
+ // Assert
+ EXPECT_CALL(*cache_manager, GenerateSnapshot()).WillOnce(Return(snapshot));
+ EXPECT_CALL(*cache_manager, GetVehicleDataItems())
+ .WillOnce(Return(std::vector<policy_table::VehicleDataItem>()));
+ EXPECT_CALL(*cache_manager, ApplyUpdate(_)).WillOnce(Return(true));
+ ExpectOnPermissionsUpdated();
+
+ EXPECT_TRUE(manager->LoadPT("file_pt_update.json", msg));
+}
+
+TEST_F(PolicyManagerImplTest, LoadPT_FunctionalGroup_NoUpdate_DONT_SendUpdate) {
+ // Arrange
+ manager->ForcePTExchange();
+ manager->OnUpdateStarted();
+ Json::Value table = CreatePTforLoad();
+ policy_table::Table update(&table);
+
+ PrepareUpdateWithFunctionalGroupingContent(update);
+
+ std::shared_ptr<policy_table::Table> snapshot =
+ std::make_shared<policy_table::Table>(update.policy_table);
+
+ ASSERT_TRUE(IsValid(update));
+
+ const std::string json = update.ToJsonValue().toStyledString();
+ ::policy::BinaryMessage msg(json.begin(), json.end());
+
+ // Assert
+ EXPECT_CALL(*cache_manager, GenerateSnapshot()).WillOnce(Return(snapshot));
+ EXPECT_CALL(*cache_manager, GetVehicleDataItems())
+ .WillOnce(Return(std::vector<policy_table::VehicleDataItem>()));
+ EXPECT_CALL(*cache_manager, ApplyUpdate(_)).WillOnce(Return(true));
EXPECT_TRUE(manager->LoadPT("file_pt_update.json", msg));
}
@@ -926,8 +1199,13 @@ TEST_F(PolicyManagerImplTest, LoadPT_SetInvalidUpdatePT_PTIsNotLoaded) {
std::string json = table.toStyledString();
::policy::BinaryMessage msg(json.begin(), json.end());
+ std::shared_ptr<policy_table::Table> snapshot =
+ std::make_shared<policy_table::Table>(update.policy_table);
+ ON_CALL(*cache_manager, GenerateSnapshot()).WillByDefault(Return(snapshot));
+ ON_CALL(*cache_manager, GetVehicleDataItems())
+ .WillByDefault(Return(std::vector<policy_table::VehicleDataItem>()));
+
// Assert
- EXPECT_CALL(*cache_manager, GenerateSnapshot()).Times(0);
EXPECT_CALL(*cache_manager, ApplyUpdate(_)).Times(0);
EXPECT_CALL(listener, GetAppName(_)).Times(0);
EXPECT_CALL(listener, OnUpdateStatusChanged(_)).Times(1);
@@ -1476,23 +1754,6 @@ TEST_F(PolicyManagerImplTest2, GetCurrentDeviceId) {
EXPECT_EQ("", manager->GetCurrentDeviceId(dev_handle2, app_id2));
}
-TEST_F(PolicyManagerImplTest2,
- GetVehicleInfo_SetVehicleInfo_ExpectReceivedInfoCorrect) {
- // Arrange
- CreateLocalPT("sdl_preloaded_pt.json");
- GetPTU("valid_sdl_pt_update.json");
- std::shared_ptr<policy_table::Table> pt = (manager->GetCache())->pt();
- policy_table::ModuleConfig& module_config = pt->policy_table.module_config;
- ::policy::VehicleInfo vehicle_info = manager->GetVehicleInfo();
-
- EXPECT_EQ(static_cast<std::string>(*module_config.vehicle_make),
- vehicle_info.vehicle_make);
- EXPECT_EQ(static_cast<std::string>(*module_config.vehicle_model),
- vehicle_info.vehicle_model);
- EXPECT_EQ(static_cast<std::string>(*module_config.vehicle_year),
- vehicle_info.vehicle_year);
-}
-
TEST_F(
PolicyManagerImplTest2,
GetPermissionsForApp_SetUserConsentForApp_ExpectReceivedPermissionsCorrect) {
@@ -1602,6 +1863,80 @@ TEST_F(
EXPECT_EQ(heart_beat_timeout.asUInt(), result);
}
+TEST_F(PolicyManagerImplTest2, CacheManager_RemoveRPCSpecVehicleDataItems) {
+ policy_table::VehicleDataItems init;
+ policy_table::VehicleDataItem test_item;
+ test_item.name = "headLampStatus";
+ init.push_back(test_item);
+
+ const auto ret = CacheManager::CollectCustomVDItems(init);
+
+ EXPECT_EQ(0u, ret.size());
+}
+
+TEST_F(PolicyManagerImplTest2,
+ CacheManager_RemoveRPCSpecVehicleDataItemsAndRemainCustom) {
+ policy_table::VehicleDataItems init;
+ policy_table::VehicleDataItem rpc_spec_item;
+ rpc_spec_item.name = "headLampStatus";
+ policy_table::VehicleDataItem custom_item;
+ custom_item.name = "Custom";
+ init.push_back(rpc_spec_item);
+ init.push_back(custom_item);
+
+ EXPECT_EQ(2u, init.size());
+
+ const auto ret = CacheManager::CollectCustomVDItems(init);
+
+ EXPECT_EQ(1u, ret.size());
+ EXPECT_EQ(ret.at(0).name, "Custom");
+}
+
+TEST_F(PolicyManagerImplTest2, CacheManager_RemainCustomVehicleDataItems) {
+ policy_table::VehicleDataItems init;
+ policy_table::VehicleDataItem custom_item;
+ custom_item.name = "Custom";
+ init.push_back(custom_item);
+
+ EXPECT_EQ(1u, init.size());
+
+ const auto& ret = CacheManager::CollectCustomVDItems(init);
+
+ EXPECT_EQ(1u, ret.size());
+}
+
+TEST_F(PolicyManagerImplTest2,
+ CacheManager_CollectCustomItemWithRemainingRPCSpecItem) {
+ policy_table::VehicleDataItems init;
+ policy_table::VehicleDataItem rpc_spec_item;
+ rpc_spec_item.name = "headLampStatus";
+ policy_table::VehicleDataItem custom_item;
+ custom_item.name = "Custom";
+ init.push_back(rpc_spec_item);
+ init.push_back(custom_item);
+
+ EXPECT_EQ(2u, init.size());
+
+ const auto& ret = CacheManager::CollectCustomVDItems(init);
+
+ EXPECT_EQ(1u, ret.size());
+ EXPECT_EQ(ret.at(0).name, custom_item.name);
+}
+
+TEST_F(PolicyManagerImplTest2,
+ CacheManager_RemainRPCSpecVehicleDataItemsNoCustomItems) {
+ policy_table::VehicleDataItems init;
+ policy_table::VehicleDataItem custom_item;
+ custom_item.name = "headLampStatus";
+ init.push_back(custom_item);
+
+ EXPECT_EQ(1u, init.size());
+
+ const auto& ret = CacheManager::CollectCustomVDItems(init);
+
+ EXPECT_EQ(0u, ret.size());
+}
+
} // namespace policy_test
} // namespace components
} // namespace test
diff --git a/src/components/policy/policy_regular/test/sql_pt_representation_test.cc b/src/components/policy/policy_regular/test/sql_pt_representation_test.cc
index d456aa26e4..8bb0fb22c6 100644
--- a/src/components/policy/policy_regular/test/sql_pt_representation_test.cc
+++ b/src/components/policy/policy_regular/test/sql_pt_representation_test.cc
@@ -69,7 +69,7 @@ namespace policy_test {
using policy_handler_test::MockPolicySettings;
-class SQLPTRepresentationTest : public SQLPTRepresentation,
+class SQLPTRepresentationTest : protected SQLPTRepresentation,
public ::testing::Test {
protected:
DBMS* dbms;
@@ -398,7 +398,7 @@ class SQLPTRepresentationTest2 : public ::testing::Test {
}
void TearDown() OVERRIDE {
- file_system::RemoveDirectory(kAppStorageFolder, true);
+ ASSERT_TRUE(file_system::RemoveDirectory(kAppStorageFolder, true));
delete reps;
}
@@ -428,6 +428,148 @@ class SQLPTRepresentationTest3 : public ::testing::Test {
const std::string kAppStorageFolder;
};
+TEST_F(SQLPTRepresentationTest, VehicleDataItem_Store_Item) {
+ policy_table::VehicleDataItem rpm;
+ rpm.mark_initialized();
+ rpm.name = "rpm";
+ rpm.type = "Integer";
+ rpm.key = "OEM_REF_RPM";
+ rpm.mandatory = false;
+ *rpm.array = false;
+ rpm.params->mark_initialized();
+ ASSERT_FALSE(reps->VehicleDataItemExists(rpm));
+ ASSERT_TRUE(reps->InsertVehicleDataItem(rpm));
+ ASSERT_TRUE(reps->VehicleDataItemExists(rpm));
+
+ auto rpm_retrieved = reps->GetVehicleDataItem(rpm.name, rpm.key);
+ ASSERT_EQ(rpm.ToJsonValue(), rpm_retrieved.begin()->ToJsonValue());
+}
+
+TEST_F(SQLPTRepresentationTest, VehicleDataItem_Store_Complete_Item) {
+ policy_table::VehicleDataItem message;
+ message.mark_initialized();
+ message.name = "messsageName";
+ message.type = "String";
+ message.key = "OEM_REF_MSG";
+ message.mandatory = false;
+ *message.array = false;
+ message.params->mark_initialized();
+ *message.since = "1.0";
+ *message.until = "5.0";
+ *message.removed = false;
+ *message.deprecated = false;
+ *message.minvalue = 0;
+ *message.maxvalue = 255;
+ *message.minsize = 0;
+ *message.maxsize = 255;
+ *message.minlength = 0;
+ *message.maxlength = 255;
+ ASSERT_TRUE(reps->InsertVehicleDataItem(message));
+
+ auto message_retrieved = reps->GetVehicleDataItem(message.name, message.key);
+ ASSERT_EQ(message.ToJsonValue(), message_retrieved.begin()->ToJsonValue());
+}
+
+TEST_F(SQLPTRepresentationTest, VehicleDataItem_Store_Struct) {
+ policy_table::VehicleDataItem alss;
+ alss.mark_initialized();
+ alss.name = "ambientLightSensorStatus";
+ alss.type = "AmbientLightStatus";
+ alss.key = "OEM_REF_AMB_LIGHT";
+ alss.mandatory = false;
+ alss.params->mark_initialized();
+ policy_table::VehicleDataItem lss;
+ lss.mark_initialized();
+ lss.name = "LightSensorStatus";
+ lss.type = "Struct";
+ lss.key = "OEM_REF_SEN_LIGHT";
+ lss.mandatory = false;
+ lss.params->mark_initialized();
+ lss.params->push_back(alss);
+
+ policy_table::VehicleDataItem hbo;
+ hbo.mark_initialized();
+ hbo.name = "highBeamsOn";
+ hbo.type = "Boolean";
+ hbo.key = "OEM_REF_HIGH_BEAM";
+ hbo.mandatory = true;
+ hbo.params->mark_initialized();
+ policy_table::VehicleDataItem lbo;
+ lbo.mark_initialized();
+ lbo.name = "lowBeamsOn";
+ lbo.type = "Boolean";
+ lbo.key = "OEM_REF_LOW_BEAM";
+ lbo.mandatory = false;
+ lbo.params->mark_initialized();
+ policy_table::VehicleDataItem hls;
+ hls.mark_initialized();
+ hls.name = "headLampStatus";
+ hls.type = "Struct";
+ hls.key = "OEM_REF_HLSTATUS";
+ hls.mandatory = false;
+ hls.params->mark_initialized();
+ hls.params->push_back(lss);
+ hls.params->push_back(lbo);
+ hls.params->push_back(hbo);
+ ASSERT_TRUE(reps->InsertVehicleDataItem(alss));
+ ASSERT_TRUE(reps->InsertVehicleDataItem(hls));
+
+ auto hls_retrieved = reps->GetVehicleDataItem(hls.name, hls.key);
+ ASSERT_EQ(hls.ToJsonValue(), hls_retrieved.begin()->ToJsonValue());
+}
+
+TEST_F(SQLPTRepresentationTest, VehicleDataItem_Select_NonParameterizedVDI) {
+ policy_table::VehicleDataItems non_parameterized_vdis;
+ policy_table::VehicleDataItem rpm;
+ rpm.mark_initialized();
+ rpm.name = "rpm";
+ rpm.type = "Integer";
+ rpm.key = "OEM_REF_RPM";
+ rpm.mandatory = false;
+ *rpm.array = false;
+ rpm.params->mark_initialized();
+ ASSERT_TRUE(reps->InsertVehicleDataItem(rpm));
+ policy_table::VehicleDataItem message;
+ message.mark_initialized();
+ message.name = "rpm";
+ message.type = "String";
+ message.key = "OEM_REF_MSG";
+ message.mandatory = false;
+ *message.array = false;
+ message.params->mark_initialized();
+ ASSERT_TRUE(reps->InsertVehicleDataItem(message));
+ non_parameterized_vdis.push_back(rpm);
+ non_parameterized_vdis.push_back(message);
+
+ policy_table::VehicleDataItems parameterized_vdis;
+ policy_table::VehicleDataItem alss;
+ alss.mark_initialized();
+ alss.name = "ambientLightSensorStatus";
+ alss.type = "AmbientLightStatus";
+ alss.key = "OEM_REF_AMB_LIGHT";
+ alss.mandatory = false;
+ alss.params->mark_initialized();
+ policy_table::VehicleDataItem lss;
+ lss.mark_initialized();
+ lss.name = "LightSensorStatus";
+ lss.type = "Struct";
+ lss.key = "OEM_REF_SEN_LIGHT";
+ lss.mandatory = false;
+ lss.params->mark_initialized();
+ lss.params->push_back(alss);
+ ASSERT_TRUE(reps->InsertVehicleDataItem(lss));
+ parameterized_vdis.push_back(lss);
+
+ auto non_param_vdi_retrieved = reps->SelectPrimitiveVehicleDataItems();
+
+ ASSERT_EQ(non_parameterized_vdis.ToJsonValue(),
+ non_param_vdi_retrieved.ToJsonValue());
+
+ auto param_vdi_retrieved = reps->SelectCompositeVehicleDataItems();
+ ASSERT_EQ(parameterized_vdis.ToJsonValue(),
+ param_vdi_retrieved.ToJsonValue());
+}
+
// {AKozoriz} : Unknown behavior (must try 8 times, tried 2 and opened)
TEST_F(SQLPTRepresentationTest2,
DISABLED_OpenAttemptTimeOut_ExpectCorrectNumber) {
@@ -450,8 +592,8 @@ TEST_F(SQLPTRepresentationTest,
ASSERT_TRUE(reps->RefreshDB());
// Check PT structure destroyed and tables number is 0
- // There are 33 tables in the database, now.
- const int32_t total_tables_number = 33;
+ // There are 35 tables in the database, now.
+ const int32_t total_tables_number = 37;
ASSERT_EQ(total_tables_number, dbms->FetchOneInt(query_select));
const char* query_select_count_of_iap_buffer_full =
"SELECT `count_of_iap_buffer_full` FROM `usage_and_error_count`";
@@ -1644,9 +1786,11 @@ TEST_F(SQLPTRepresentationTest, Save_SetPolicyTableThenSave_ExpectSavedToPT) {
const ::policy_table::Parameters& parameters = *(rpc_iter->second.parameters);
EXPECT_EQ(1u, parameters.size());
- EXPECT_TRUE(parameters.end() != std::find(parameters.begin(),
- parameters.end(),
- policy_table::Parameter::P_SPEED));
+ EXPECT_TRUE(parameters.end() !=
+ std::find(parameters.begin(),
+ parameters.end(),
+ policy_table::EnumToJsonString(
+ policy_table::Parameter::P_SPEED)));
// Check Application Policies Section
GatherApplicationPoliciesSection(&policies);
const uint32_t apps_size = 3u;
diff --git a/src/components/policy/policy_regular/test/vehicle_data_item_type_test.cc b/src/components/policy/policy_regular/test/vehicle_data_item_type_test.cc
new file mode 100644
index 0000000000..a2f7757936
--- /dev/null
+++ b/src/components/policy/policy_regular/test/vehicle_data_item_type_test.cc
@@ -0,0 +1,250 @@
+/*
+ * Copyright (c) 2019, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE. */
+
+#include "gtest/gtest.h"
+#include "json/reader.h"
+#include "policy/policy_table/types.h"
+
+#include <type_traits>
+
+namespace test {
+namespace vehicle_info_plugin_test {
+
+using namespace rpc::policy_table_interface_base;
+
+namespace {
+/*
+ * class TestString should be used for compact string creation with json value
+ */
+class TestString {
+ /**
+ * @brief Field contains json structure
+ */
+ std::string text_;
+ /**
+ * @brief Need for validate should not be returned closed json or empty string
+ */
+ bool is_initialized_;
+
+ public:
+ TestString() : is_initialized_(false) {}
+
+ /**
+ * @brief This method handling all types except string
+ * the name:value will be added to json string
+ * @param std::string& name - name of json filed
+ * @param const T& value - value of json filed
+ */
+ template <class T>
+ void AddField(const std::string& name, const T& value) {
+ const bool is_bool = std::is_same<T, bool>::value;
+ // Should be writed to json true/false not 1/0
+ const std::string text_value =
+ (is_bool ? (value ? "true" : "false") : std::to_string(value));
+ if (text_.empty()) {
+ is_initialized_ = true;
+ text_ = "{\"" + name + "\":" + text_value;
+ return;
+ }
+ text_ += ",\"" + name + "\":" + text_value;
+ }
+
+ /**
+ * @brief This method handling only string values
+ * the name:"value" will be added to json string
+ * this method is coverring value in quotes
+ * @param std::string& name - name of json filed
+ * @param const T& value - value of json filed
+ */
+ void AddField(const std::string& name, const char* value) {
+ if (text_.empty()) {
+ is_initialized_ = true;
+ text_ = "{\"" + name + "\":";
+ } else {
+ text_ += ",\"" + name + "\":";
+ }
+
+ text_ += value[0] == '{' || value[0] == '['
+ ? std::string(value)
+ : "\"" + std::string(value) + "\"";
+ }
+
+ /**
+ * @brief This method close json string before return
+ * @return all string and close json form by right bracket "}"
+ * or empty string if json structure is empty
+ */
+ std::string GetValue() {
+ return is_initialized_ ? text_ + "}" : "";
+ }
+};
+
+} // namespace
+
+class VehicleDataItemTypeTest : public ::testing::Test {
+ public:
+ std::string GetFullJsonString(const std::string& params_array = "") {
+ TestString str;
+ str.AddField("name", "VehicleDataItem");
+ str.AddField("type", "String");
+ str.AddField("key", "OEMDataRef");
+ str.AddField("array", true);
+ str.AddField("mandatory", true);
+ str.AddField("params", ("[" + params_array + "]").c_str());
+ str.AddField("since", "4.0");
+ str.AddField("until", "5.0");
+ str.AddField("removed", true);
+ str.AddField("deprecated", true);
+ str.AddField("minvalue", 1);
+ str.AddField("maxvalue", 2);
+ str.AddField("minsize", 10);
+ str.AddField("maxsize", 20);
+ str.AddField("minlength", 100);
+ str.AddField("maxlength", 200);
+
+ return str.GetValue();
+ }
+
+ protected:
+ virtual void TearDown() {
+ json_.clear();
+ }
+
+ Json::Value json_;
+ Json::Reader reader_;
+};
+
+TEST_F(VehicleDataItemTypeTest, Initialize_Success) {
+ reader_.parse(GetFullJsonString(), json_);
+ VehicleDataItem vdi(&json_);
+
+ EXPECT_TRUE(vdi.is_initialized());
+}
+
+TEST_F(VehicleDataItemTypeTest, Initialize_Failed) {
+ VehicleDataItem vdi;
+
+ EXPECT_FALSE(vdi.is_initialized());
+}
+
+TEST_F(VehicleDataItemTypeTest, CheckConvertFromJsonToVehicleDataItem_Success) {
+ reader_.parse(GetFullJsonString(), json_);
+ VehicleDataItem vdi(&json_);
+
+ EXPECT_TRUE((std::string)vdi.name == "VehicleDataItem");
+ EXPECT_TRUE((std::string)vdi.type == "String");
+ EXPECT_TRUE((std::string)vdi.key == "OEMDataRef");
+ EXPECT_TRUE(*vdi.array == true);
+ EXPECT_TRUE(vdi.mandatory == true);
+ EXPECT_TRUE(vdi.params->empty());
+ EXPECT_TRUE((std::string)*vdi.since == "4.0");
+ EXPECT_TRUE((std::string)*vdi.until == "5.0");
+ EXPECT_TRUE(*vdi.removed == true);
+ EXPECT_TRUE(*vdi.deprecated == true);
+ EXPECT_TRUE(*vdi.minvalue == 1);
+ EXPECT_TRUE(*vdi.maxvalue == 2);
+ EXPECT_TRUE(*vdi.minsize == 10);
+ EXPECT_TRUE(*vdi.maxsize == 20);
+ EXPECT_TRUE(*vdi.minlength == 100);
+ EXPECT_TRUE(*vdi.maxlength == 200);
+}
+
+TEST_F(VehicleDataItemTypeTest, CheckConvertFromVehicleDataItemToJson_Success) {
+ reader_.parse(GetFullJsonString(), json_);
+ VehicleDataItem vdi(&json_);
+
+ auto jsonFrom = vdi.ToJsonValue();
+ VehicleDataItem vdi2(&jsonFrom);
+ EXPECT_TRUE(vdi == vdi2);
+}
+
+TEST_F(VehicleDataItemTypeTest, CheckIsValid_Failed) {
+ VehicleDataItem vdi;
+
+ EXPECT_FALSE(vdi.is_valid());
+}
+
+TEST_F(VehicleDataItemTypeTest, CheckIsValid_Struct_Success) {
+ reader_.parse(GetFullJsonString(GetFullJsonString()), json_);
+ VehicleDataItem vdi(&json_);
+
+ vdi.type = "Struct";
+ EXPECT_TRUE(vdi.is_valid());
+}
+
+TEST_F(VehicleDataItemTypeTest, CheckIsValid_Struct_EmptyParams_Failed) {
+ reader_.parse(GetFullJsonString(), json_);
+ VehicleDataItem vdi(&json_);
+
+ vdi.type = "Struct";
+ EXPECT_FALSE(vdi.is_valid());
+}
+
+TEST_F(VehicleDataItemTypeTest, CheckIsValid_PODTypes_Success) {
+ reader_.parse(GetFullJsonString(), json_);
+ VehicleDataItem vdi(&json_);
+
+ vdi.type = "Integer";
+ EXPECT_TRUE(vdi.is_valid());
+
+ vdi.type = "Float";
+ EXPECT_TRUE(vdi.is_valid());
+
+ vdi.type = "String";
+ EXPECT_TRUE(vdi.is_valid());
+
+ vdi.type = "Boolean";
+ EXPECT_TRUE(vdi.is_valid());
+}
+
+TEST_F(VehicleDataItemTypeTest, CheckEmptiness_True) {
+ VehicleDataItem vdi;
+ EXPECT_FALSE(vdi.struct_not_empty());
+}
+
+TEST_F(VehicleDataItemTypeTest, CheckEmptiness_False) {
+ reader_.parse(GetFullJsonString(), json_);
+
+ VehicleDataItem vdi(&json_);
+ EXPECT_TRUE(vdi.struct_not_empty());
+}
+
+TEST_F(VehicleDataItemTypeTest, CheckCopyConstructor) {
+ reader_.parse(GetFullJsonString(), json_);
+
+ VehicleDataItem vdi1(&json_);
+ VehicleDataItem vdi2(vdi1);
+
+ EXPECT_TRUE(vdi1 == vdi2);
+}
+
+} // namespace vehicle_info_plugin_test
+} // namespace test