summaryrefslogtreecommitdiff
path: root/src/components/policy/policy_external
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/policy/policy_external')
-rw-r--r--src/components/policy/policy_external/.gitignore2
-rw-r--r--src/components/policy/policy_external/CMakeLists.txt84
-rw-r--r--src/components/policy/policy_external/doc/doxygen/components/JSONHandler/Formatters/index.txt6
-rw-r--r--src/components/policy/policy_external/doc/doxygen/components/SmartObjects/Smart Objects Types/Value representation.txt4
-rw-r--r--src/components/policy/policy_external/doc/doxygen/components/SmartObjects/Smart Objects Validation/Schema Structure.txt44
-rw-r--r--src/components/policy/policy_external/doc/doxygen/components/SmartObjects/Smart Objects Validation/Validation.txt6
-rw-r--r--src/components/policy/policy_external/doc/doxygen/components/TransportManager/Client Specification/ConnectionManagement.txt12
-rw-r--r--src/components/policy/policy_external/doc/doxygen/components/TransportManager/Client Specification/DataTransfer.txt10
-rw-r--r--src/components/policy/policy_external/doc/doxygen/components/TransportManager/Client Specification/DeviceManagement.txt8
-rw-r--r--src/components/policy/policy_external/doc/doxygen/components/TransportManager/Client Specification/index.txt6
-rw-r--r--src/components/policy/policy_external/doc/doxygen/components/TransportManager/Internal Design/Device Adapters/BluetoothAdapter.txt6
-rw-r--r--src/components/policy/policy_external/doc/doxygen/components/TransportManager/Internal Design/Device Adapters/TCPAdapter.txt4
-rw-r--r--src/components/policy/policy_external/doc/doxygen/components/TransportManager/Internal Design/Device Adapters/index.txt60
-rw-r--r--src/components/policy/policy_external/doc/doxygen/components/TransportManager/Internal Design/MultiThreading.txt4
-rw-r--r--src/components/policy/policy_external/doc/doxygen/components/TransportManager/Internal Design/TrasportManager.txt8
-rw-r--r--src/components/policy/policy_external/doc/doxygen/tools/InterfaceGenerator/How To Use.txt2
-rw-r--r--src/components/policy/policy_external/include/policy/access_remote.h2
-rw-r--r--src/components/policy/policy_external/include/policy/access_remote_impl.h6
-rw-r--r--src/components/policy/policy_external/include/policy/cache_manager.h270
-rw-r--r--src/components/policy/policy_external/include/policy/cache_manager_interface.h249
-rw-r--r--src/components/policy/policy_external/include/policy/policy_helper.h93
-rw-r--r--src/components/policy/policy_external/include/policy/policy_manager_impl.h414
-rw-r--r--src/components/policy/policy_external/include/policy/policy_table.h9
-rw-r--r--src/components/policy/policy_external/include/policy/policy_table/enums.h131
-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.h179
-rw-r--r--src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml29
-rw-r--r--src/components/policy/policy_external/include/policy/policy_types.h103
-rw-r--r--src/components/policy/policy_external/include/policy/pt_ext_representation.h8
-rw-r--r--src/components/policy/policy_external/include/policy/pt_representation.h29
-rw-r--r--src/components/policy/policy_external/include/policy/ptu_retry_handler.h57
-rw-r--r--src/components/policy/policy_external/include/policy/sql_pt_ext_representation.h2
-rw-r--r--src/components/policy/policy_external/include/policy/sql_pt_queries.h27
-rw-r--r--src/components/policy/policy_external/include/policy/sql_pt_representation.h45
-rw-r--r--src/components/policy/policy_external/include/policy/status.h119
-rw-r--r--src/components/policy/policy_external/include/policy/update_status_manager.h46
-rw-r--r--src/components/policy/policy_external/include/policy/usage_statistics/counter.h24
-rw-r--r--src/components/policy/policy_external/src/access_remote_impl.cc2
-rw-r--r--src/components/policy/policy_external/src/cache_manager.cc609
-rw-r--r--src/components/policy/policy_external/src/policy_helper.cc460
-rw-r--r--src/components/policy/policy_external/src/policy_manager_impl.cc983
-rw-r--r--src/components/policy/policy_external/src/policy_table.cc2
-rw-r--r--src/components/policy/policy_external/src/policy_table/enums.cc758
-rw-r--r--src/components/policy/policy_external/src/policy_table/types.cc775
-rw-r--r--src/components/policy/policy_external/src/policy_table/validation.cc71
-rw-r--r--src/components/policy/policy_external/src/sql_pt_ext_queries.cc14
-rw-r--r--src/components/policy/policy_external/src/sql_pt_ext_representation.cc143
-rw-r--r--src/components/policy/policy_external/src/sql_pt_queries.cc277
-rw-r--r--src/components/policy/policy_external/src/sql_pt_representation.cc883
-rw-r--r--src/components/policy/policy_external/src/status.cc59
-rw-r--r--src/components/policy/policy_external/src/update_status_manager.cc56
-rw-r--r--src/components/policy/policy_external/src/usage_statistics/counter.cc17
-rw-r--r--src/components/policy/policy_external/test/CMakeLists.txt2
-rw-r--r--src/components/policy/policy_external/test/counter_test.cc27
-rw-r--r--src/components/policy/policy_external/test/generated_code_test.cc10
-rw-r--r--src/components/policy/policy_external/test/include/policy/mock_pt_ext_representation.h4
-rw-r--r--src/components/policy/policy_external/test/include/policy/mock_pt_representation.h5
-rw-r--r--src/components/policy/policy_external/test/include/policy/mock_update_status_manager.h3
-rw-r--r--src/components/policy/policy_external/test/include/policy/policy_manager_impl_test_base.h16
-rw-r--r--src/components/policy/policy_external/test/json/PTU.json8
-rw-r--r--src/components/policy/policy_external/test/json/PTU2.json8
-rw-r--r--src/components/policy/policy_external/test/json/PTU3.json8
-rw-r--r--src/components/policy/policy_external/test/json/PTU_with_empty_requestType_array.json8
-rw-r--r--src/components/policy/policy_external/test/json/PTU_with_invalid_requestType_between_correct.json8
-rw-r--r--src/components/policy/policy_external/test/json/PTU_with_one_invalid_requestType.json8
-rw-r--r--src/components/policy/policy_external/test/json/PTU_without_requestType_field.json8
-rw-r--r--src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_reqestType_between_valid.json8
-rw-r--r--src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_requestType.json8
-rw-r--r--src/components/policy/policy_external/test/json/preloadedPT_with_several_invalid_default_requestTypes.json8
-rw-r--r--src/components/policy/policy_external/test/json/ptu2_requestType.json8
-rw-r--r--src/components/policy/policy_external/test/json/ptu_requestType.json8
-rw-r--r--src/components/policy/policy_external/test/json/sdl_preloaded_pt.json8
-rw-r--r--src/components/policy/policy_external/test/json/sdl_preloaded_pt1.json8
-rw-r--r--src/components/policy/policy_external/test/json/sdl_preloaded_pt_send_location.json8
-rw-r--r--src/components/policy/policy_external/test/json/sdl_pt_first_update.json8
-rw-r--r--src/components/policy/policy_external/test/json/sdl_pt_second_update.json8
-rw-r--r--src/components/policy/policy_external/test/json/sdl_pt_update.json8
-rw-r--r--src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_have_params.json8
-rw-r--r--src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1.json8
-rw-r--r--src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1_omitted_in2.json8
-rw-r--r--src/components/policy/policy_external/test/json/sdl_update_pt_send_location.json8
-rw-r--r--src/components/policy/policy_external/test/json/sdl_update_pt_send_location_all_params.json8
-rw-r--r--src/components/policy/policy_external/test/json/sdl_update_pt_send_location_no_params.json8
-rw-r--r--src/components/policy/policy_external/test/json/sdl_update_pt_send_location_some_params.json8
-rw-r--r--src/components/policy/policy_external/test/json/valid_sdl_pt_update.json16
-rw-r--r--src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc537
-rw-r--r--src/components/policy/policy_external/test/policy_manager_impl_snapshot_test.cc44
-rw-r--r--src/components/policy/policy_external/test/policy_manager_impl_stress_test.cc6
-rw-r--r--src/components/policy/policy_external/test/policy_manager_impl_test.cc261
-rw-r--r--src/components/policy/policy_external/test/policy_manager_impl_test_base.cc175
-rw-r--r--src/components/policy/policy_external/test/policy_manager_impl_user_consent_test.cc170
-rw-r--r--src/components/policy/policy_external/test/sql_pt_ext_representation_test.cc50
-rw-r--r--src/components/policy/policy_external/test/sql_pt_representation_test.cc178
-rw-r--r--src/components/policy/policy_external/test/update_status_manager_test.cc100
94 files changed, 6579 insertions, 2504 deletions
diff --git a/src/components/policy/policy_external/.gitignore b/src/components/policy/policy_external/.gitignore
index d67909069a..d6052d61da 100644
--- a/src/components/policy/policy_external/.gitignore
+++ b/src/components/policy/policy_external/.gitignore
@@ -29,8 +29,6 @@ src/appMain/hmi_link
src/appMain/smartDeviceLinkCore
test/components/application_manager/policies_manager/test_policies_table
test/components/application_manager/test_formatters_commands
-test/components/dbus/test_DBusAdapter
-test/components/dbus/test_DBusSchema
test/components/protocol_handler/test_ProtocolHandler
test/components/request_watchdog/test_RequestWatchdog
test/components/smart_objects/SchemaItem/test_SmartObject_AlwaysFalseSchemaItemTest
diff --git a/src/components/policy/policy_external/CMakeLists.txt b/src/components/policy/policy_external/CMakeLists.txt
index c66313240f..361c48a598 100644
--- a/src/components/policy/policy_external/CMakeLists.txt
+++ b/src/components/policy/policy_external/CMakeLists.txt
@@ -28,20 +28,25 @@
# 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(target Policy)
set(install_destination bin)
set(copy_destination ${CMAKE_BINARY_DIR}/src/appMain)
-set(library_name ${CMAKE_SHARED_LIBRARY_PREFIX}${target}${CMAKE_SHARED_LIBRARY_SUFFIX})
+set(library_name ${CMAKE_SHARED_LIBRARY_PREFIX}Policy${CMAKE_SHARED_LIBRARY_SUFFIX})
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}/
+ ${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)
@@ -74,21 +121,25 @@ else ()
list(APPEND LIBRARIES sqlite3)
endif ()
-add_library(${target} SHARED ${SOURCES})
-target_link_libraries(${target} ${LIBRARIES} )
+add_library(PolicyStatic ${SOURCES})
+target_link_libraries(PolicyStatic ${LIBRARIES})
+
+
+add_library(Policy SHARED "src/policy_manager_impl.cc")
+target_link_libraries(Policy PolicyStatic)
if (ENABLE_LOG)
- target_link_libraries(${target} log4cxx -L${LOG4CXX_LIBS_DIRECTORY})
+ target_link_libraries(Policy log4cxx -L${LOG4CXX_LIBS_DIRECTORY})
endif()
-add_custom_target(copy_library_${target} ALL
+add_custom_target(copy_library_Policy ALL
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_BINARY_DIR}/${library_name}
${copy_destination}
- DEPENDS ${target}
+ DEPENDS Policy
COMMENT "Copying library ${library_name}")
-install(TARGETS ${target}
+install(TARGETS Policy
DESTINATION ${install_destination}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
@@ -99,13 +150,22 @@ install(TARGETS ${target}
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/JSONHandler/Formatters/index.txt b/src/components/policy/policy_external/doc/doxygen/components/JSONHandler/Formatters/index.txt
index 9854b88d5f..0144efaf7f 100644
--- a/src/components/policy/policy_external/doc/doxygen/components/JSONHandler/Formatters/index.txt
+++ b/src/components/policy/policy_external/doc/doxygen/components/JSONHandler/Formatters/index.txt
@@ -1,9 +1,9 @@
-/*! \page components_jsonhandler_formatters Smart Objects Formatters
+/*! \page components_jsonhandler_formatters Smart Objects formatters
In order to create JSON string representation from Smart Object or create Smart Object data structure from JSON string representation JSON Handler component has special classes called formatters.
-The interface of formatter is quite simple and defined by NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonBase class. Actually it has two methods - NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonBase::objToJsonValue to convert JSON string to object and NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonBase::jsonValueToObj to create JSON string from object.
+The interface of formatter is quite simple and defined by ns_smart_device_link::ns_json_handler::formatters::CFormatterJsonBase class. Actually it has two methods - ns_smart_device_link::ns_json_handler::formatters::CFormatterJsonBase::objToJsonValue to convert JSON string to object and ns_smart_device_link::ns_json_handler::formatters::CFormatterJsonBase::jsonValueToObj to create JSON string from object.
-Current implementation has two different implementations of NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonBase class: NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonALRPCv1 for ALRPC.v1 and NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonALRPCv2 for ALRPC.v2. These implementations handle specifics of each format.
+Current implementation has two different implementations of ns_smart_device_link::ns_json_handler::formatters::CFormatterJsonBase class: ns_smart_device_link::ns_json_handler::formatters::CFormatterJsonALRPCv1 for ALRPC.v1 and ns_smart_device_link::ns_json_handler::formatters::CFormatterJsonALRPCv2 for ALRPC.v2. These implementations handle specifics of each format.
*/
diff --git a/src/components/policy/policy_external/doc/doxygen/components/SmartObjects/Smart Objects Types/Value representation.txt b/src/components/policy/policy_external/doc/doxygen/components/SmartObjects/Smart Objects Types/Value representation.txt
index 6505ae6f43..2c23555902 100644
--- a/src/components/policy/policy_external/doc/doxygen/components/SmartObjects/Smart Objects Types/Value representation.txt
+++ b/src/components/policy/policy_external/doc/doxygen/components/SmartObjects/Smart Objects Types/Value representation.txt
@@ -1,11 +1,11 @@
/*! \page components_smartobjects_types_repr Type value representation methods for SmartObjects
-As alternative to the type casts NsSmartDeviceLink::NsSmartObjects::CSmartObject class defines set of usable methods that allow to represent object values as desired type. Use of these methods may change code style and readability but functionally it completely similar to the type casts of Smart Objects.
+As alternative to the type casts ns_smart_device_link::ns_smart_objects::CSmartObject class defines set of usable methods that allow to represent object values as desired type. Use of these methods may change code style and readability but functionally it completely similar to the type casts of Smart Objects.
Example:
<pre>
-NsSmartDeviceLink::NsSmartObjects::CSmartObject obj;
+ns_smart_device_link::ns_smart_objects::CSmartObject obj;
obj[0] = 1;
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 2e611f74b9..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
@@ -1,25 +1,25 @@
/*! \page components_smartobjects_validation_items Schema structure: Schema Items
-In order to create new Schema (new object of class NsSmartDeviceLink::NsSmartObjects::CSmartSchema) client first must define all required Schema Items. Actually every Schema is a tree of respective Schema Items. Each node and leaf of that tree defines structural rules for some Smart Object data structure.
+In order to create new Schema (new object of class ns_smart_device_link::ns_smart_objects::CSmartSchema) client first must define all required Schema Items. Actually every Schema is a tree of respective Schema Items. Each node and leaf of that tree defines structural rules for some Smart Object data structure.
-Schema Items are represented as class hierarchy. The base class for all schema items is a NsSmartDeviceLink::NsSmartObjects::ISchemaItem class. This base class defines generic validation interface for Schema Items.
+Schema Items are represented as class hierarchy. The base class for all schema items is a ns_smart_device_link::ns_smart_objects::ISchemaItem class. This base class defines generic validation interface for Schema Items.
-To define special elements with always successful or always failing validation there are two special Schema Items: NsSmartDeviceLink::NsSmartObjects::CAlwaysTrueSchemaItem and NsSmartDeviceLink::NsSmartObjects::CAlwaysFalseSchemaItem.
+To define special elements with always successful or always failing validation there are two special Schema Items: ns_smart_device_link::ns_smart_objects::CAlwaysTrueSchemaItem and ns_smart_device_link::ns_smart_objects::CAlwaysFalseSchemaItem.
-NsSmartDeviceLink::NsSmartObjects::CBoolSchemaItem is used for boolean values and has no parameters (only verifies that respective Smart Object is really has boolean value).
+ns_smart_device_link::ns_smart_objects::CBoolSchemaItem is used for boolean values and has no parameters (only verifies that respective Smart Object is really has boolean value).
-NsSmartDeviceLink::NsSmartObjects::TNumberSchemaItem is template Schema Item that can be used for both integer and floating point values. In addition to the regular type verification it is possible to set min and max value range (these values are optional).
+ns_smart_device_link::ns_smart_objects::TNumberSchemaItem is template Schema Item that can be used for both integer and floating point values. In addition to the regular type verification it is possible to set min and max value range (these values are optional).
-NsSmartDeviceLink::NsSmartObjects::TEnumSchemaItem is used to verify any custom client-defined enum.
+ns_smart_device_link::ns_smart_objects::TEnumSchemaItem is used to verify any custom client-defined enum.
-NsSmartDeviceLink::NsSmartObjects::CStringSchemaItem is used to verify a string values. As optional parameter max length of the string could be set.
+ns_smart_device_link::ns_smart_objects::CStringSchemaItem is used to verify a string values. As optional parameter max length of the string could be set.
-NsSmartDeviceLink::NsSmartObjects::CArraySchemaItem provides validation for array. Can be used to verify special type and array size.
+ns_smart_device_link::ns_smart_objects::CArraySchemaItem provides validation for array. Can be used to verify special type and array size.
-NsSmartDeviceLink::NsSmartObjects::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.
+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 NsSmartDeviceLink::NsSmartObjects::CObjectSchemaItem::SMember class). So every root item (NsSmartDeviceLink::NsSmartObjects::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[NsSmartDeviceLink::NsJSONHandler::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[NsSmartDeviceLink::NsJSONHandler::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[NsSmartDeviceLink::NsJSONHandler::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[NsSmartDeviceLink::NsJSONHandler::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[NsSmartDeviceLink::NsJSONHandler::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[NsSmartDeviceLink::NsJSONHandler::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[NsSmartDeviceLink::NsJSONHandler::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/doc/doxygen/components/SmartObjects/Smart Objects Validation/Validation.txt b/src/components/policy/policy_external/doc/doxygen/components/SmartObjects/Smart Objects Validation/Validation.txt
index a02f0be4bd..c651af5294 100644
--- a/src/components/policy/policy_external/doc/doxygen/components/SmartObjects/Smart Objects Validation/Validation.txt
+++ b/src/components/policy/policy_external/doc/doxygen/components/SmartObjects/Smart Objects Validation/Validation.txt
@@ -1,9 +1,9 @@
/*! \page components_smartobjects_validation_use Using Schema for validation
-The main purpose of Schema is validation of existing Smart Object. This process includes type and value validation. The client can use results of validation to determine if given Smart Object is valid or not. Validation of specific Smart Object can be triggered by using NsSmartDeviceLink::NsSmartObjects::CSmartSchema::validate method. Internally Schema triggers respective validate method of every Schema Item in order to perform validation.
+The main purpose of Schema is validation of existing Smart Object. This process includes type and value validation. The client can use results of validation to determine if given Smart Object is valid or not. Validation of specific Smart Object can be triggered by using ns_smart_device_link::ns_smart_objects::CSmartSchema::validate method. Internally Schema triggers respective validate method of every Schema Item in order to perform validation.
-Another feature of Schema is capability to be applied to the Smart Object. Applying means that Schema tries to modify object to "normalize" data. Currently this "normalization" effects on string representation of enums. Applying of the Schema can be triggered by using NsSmartDeviceLink::NsSmartObjects::CSmartSchema::applySchema method. Internally Schema triggers respective apply method of every Schema Item and at the moment only enum Schema Items try to covert string representation to enum values.
+Another feature of Schema is capability to be applied to the Smart Object. Applying means that Schema tries to modify object to "normalize" data. Currently this "normalization" effects on string representation of enums. Applying of the Schema can be triggered by using ns_smart_device_link::ns_smart_objects::CSmartSchema::applySchema method. Internally Schema triggers respective apply method of every Schema Item and at the moment only enum Schema Items try to covert string representation to enum values.
-To "unapply" modifications done by apply feature Schema has NsSmartDeviceLink::NsSmartObjects::CSmartSchema::unapplySchema method. It can be used to make string representations of enums.
+To "unapply" modifications done by apply feature Schema has ns_smart_device_link::ns_smart_objects::CSmartSchema::unapplySchema method. It can be used to make string representations of enums.
*/
diff --git a/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Client Specification/ConnectionManagement.txt b/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Client Specification/ConnectionManagement.txt
index 2ba273e9d4..dab3df104d 100644
--- a/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Client Specification/ConnectionManagement.txt
+++ b/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Client Specification/ConnectionManagement.txt
@@ -1,11 +1,11 @@
/** @page components_transportmanager_client_connection_management Connection Management
*
- * As all requests to TransportManager are asynchronous, client must implement NsSmartDeviceLink::NsTransportManager::ITransportManagerDeviceListener
- * interface and add itself as a device listener with NsSmartDeviceLink::NsTransportManager::ITransportManager::addDeviceListener()
+ * As all requests to TransportManager are asynchronous, client must implement ns_smart_device_link::ns_transport_manager::ITransportManagerDeviceListener
+ * interface and add itself as a device listener with ns_smart_device_link::ns_transport_manager::ITransportManager::addDeviceListener()
* in order to receive notifications.
- * To connect remote device client must use NsSmartDeviceLink::NsTransportManager::ITransportManager::connectDevice(). It will initiate connections to all
+ * To connect remote device client must use ns_smart_device_link::ns_transport_manager::ITransportManager::connectDevice(). It will initiate connections to all
* applications running on remove device. For TCP device this call has no effect as TCP connections are initiated by remote devices.
- * Client will be notified about each connected application with NsSmartDeviceLink::NsTransportManager::ITransportManagerDeviceListener::onApplicationConnected().
- * To disconnect all applications running on remote device client must use NsSmartDeviceLink::NsTransportManager::ITransportManager::disconnectDevice().
- * Client will be notified about each disconnected application with NsSmartDeviceLink::NsTransportManager::ITransportManagerDeviceListener::onApplicationDisconnected().
+ * Client will be notified about each connected application with ns_smart_device_link::ns_transport_manager::ITransportManagerDeviceListener::onApplicationConnected().
+ * To disconnect all applications running on remote device client must use ns_smart_device_link::ns_transport_manager::ITransportManager::disconnectDevice().
+ * Client will be notified about each disconnected application with ns_smart_device_link::ns_transport_manager::ITransportManagerDeviceListener::onApplicationDisconnected().
*/
diff --git a/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Client Specification/DataTransfer.txt b/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Client Specification/DataTransfer.txt
index 98dd7426be..831a0c7818 100644
--- a/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Client Specification/DataTransfer.txt
+++ b/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Client Specification/DataTransfer.txt
@@ -1,11 +1,11 @@
/** @page components_transportmanager_client_data_transfer Data Transfer
*
- * As all requests to TransportManager are asynchronous, client must implement NsSmartDeviceLink::NsTransportManager::ITransportManagerDataListener
- * interface and add itself as a data listener with NsSmartDeviceLink::NsTransportManager::ITransportManager::addDataListener()
+ * As all requests to TransportManager are asynchronous, client must implement ns_smart_device_link::ns_transport_manager::ITransportManagerDataListener
+ * interface and add itself as a data listener with ns_smart_device_link::ns_transport_manager::ITransportManager::addDataListener()
* in order to receive notifications.
- * To send frame to remote device client must use NsSmartDeviceLink::NsTransportManager::ITransportManager::sendFrame() poviding connection handle,
+ * To send frame to remote device client must use ns_smart_device_link::ns_transport_manager::ITransportManager::sendFrame() poviding connection handle,
* frame data, data size and user data. User data is an integer that is assigned to a frame and will be sent back to client when sending of frame
* will be completed. Client may use this data to identify frame when send result will be reported. When sending of frame is completed
- * client is notified via NsSmartDeviceLink::NsTransportManager::ITransportManagerDataListener::onFrameSendCompleted(). When frame is received from a remote
- * device client is notified via NsSmartDeviceLink::NsTransportManager::ITransportManagerDataListener::onFrameReceived().
+ * client is notified via ns_smart_device_link::ns_transport_manager::ITransportManagerDataListener::onFrameSendCompleted(). When frame is received from a remote
+ * device client is notified via ns_smart_device_link::ns_transport_manager::ITransportManagerDataListener::onFrameReceived().
*/
diff --git a/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Client Specification/DeviceManagement.txt b/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Client Specification/DeviceManagement.txt
index eb5f3e477e..4b5b63bf87 100644
--- a/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Client Specification/DeviceManagement.txt
+++ b/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Client Specification/DeviceManagement.txt
@@ -1,11 +1,11 @@
/** @page components_transportmanager_client_device_management Device Management
*
- * As all requests to TransportManager are asynchronous, client must implement NsSmartDeviceLink::NsTransportManager::ITransportManagerDeviceListener
- * interface and add itself as a device listener with NsSmartDeviceLink::NsTransportManager::ITransportManager::addDeviceListener()
+ * As all requests to TransportManager are asynchronous, client must implement ns_smart_device_link::ns_transport_manager::ITransportManagerDeviceListener
+ * interface and add itself as a device listener with ns_smart_device_link::ns_transport_manager::ITransportManager::addDeviceListener()
* in order to receive notifications.
- * Client of TransportManager may use NsSmartDeviceLink::NsTransportManager::ITransportManager::scanForNewDevices()
+ * Client of TransportManager may use ns_smart_device_link::ns_transport_manager::ITransportManager::scanForNewDevices()
* to initiate device scan on all device adapters that support this feature. In order to get list of available
- * devices client must override NsSmartDeviceLink::NsTransportManager::ITransportManagerDeviceListener::onDeviceListUpdated().
+ * devices client must override ns_smart_device_link::ns_transport_manager::ITransportManagerDeviceListener::onDeviceListUpdated().
* Each device adapter will perform scan independently from other device adapters and device list might be updated
* several times (after each adapter that supports scanning finishes scanning operation). Device list might also be
* updated without device scan request, e.g. if new client connects via TCP this device will be added to device list
diff --git a/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Client Specification/index.txt b/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Client Specification/index.txt
index 8916dbeb55..d4d0efeb7b 100644
--- a/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Client Specification/index.txt
+++ b/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Client Specification/index.txt
@@ -3,12 +3,12 @@
This chapter describes details of correct use of Transport Manager on the client side. In other words this chapter can be called "How to create effective and safe client of Transport Manager".
Transport Manager defines set of asynchronous requests (means that operations are non-blocking in the calling thread) and provides two different interfaces to monitor asynchronous responses and notifications about data update.
-Clients of Transport Manager should use NsSmartDeviceLink::NsTransportManager::ITransportManager interface to initiate any request to the component.
+Clients of Transport Manager should use ns_smart_device_link::ns_transport_manager::ITransportManager interface to initiate any request to the component.
Also Transport Manager provides two different interfaces:
-1) NsSmartDeviceLink::NsTransportManager::ITransportManagerDataListener. Client can implement this interface if it needs information about data frame send/receive.
+1) ns_smart_device_link::ns_transport_manager::ITransportManagerDataListener. Client can implement this interface if it needs information about data frame send/receive.
-2) NsSmartDeviceLink::NsTransportManager::ITransportManagerDeviceListener. Client can implement this interface if it needs information about updates of devices available for communication and current client applications status.
+2) ns_smart_device_link::ns_transport_manager::ITransportManagerDeviceListener. Client can implement this interface if it needs information about updates of devices available for communication and current client applications status.
For more information about typical use of Transport Manager please read the following topics:
- \subpage components_transportmanager_client_device_management "Device Management"
diff --git a/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Internal Design/Device Adapters/BluetoothAdapter.txt b/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Internal Design/Device Adapters/BluetoothAdapter.txt
index 970aeffd83..eb5de23e35 100644
--- a/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Internal Design/Device Adapters/BluetoothAdapter.txt
+++ b/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Internal Design/Device Adapters/BluetoothAdapter.txt
@@ -1,18 +1,18 @@
/** @page components_transportmanager_internal_design_transport_adapters_bluetooth_adapter Bluetooth Adapter
*
* Bluetooth adapter handles communication with external devices via bluetooth. It is implemented in
- * NsSmartDeviceLink::NsTransportManager::CBluetoothAdapter.
+ * ns_smart_device_link::ns_transport_manager::CBluetoothAdapter.
*
* @section components_transportmanager_internal_design_transport_adapters_bluetooth_adapter_discovery Device discovery
*
- * When requested by a call to NsSmartDeviceLink::NsTransportManager::CTransportAdapter::scanForNewDevices() bluetooth adapter
+ * When requested by a call to ns_smart_device_link::ns_transport_manager::CTransportAdapter::scanForNewDevices() bluetooth adapter
* searches for bluetooth devices. For each found device it runs SDP query for service with SmartDeviceLink UUID
* (936DA01F-9ABD-4D9D-80C7-02AF85C822A8). Devices that support this service are added to bluetooth adapter device list.
* Bluetooth device scans are performed only when explicitly requested.
*
* @section components_transportmanager_internal_design_transport_adapters_bluetooth_adapter_connecting_devices Connecting devices
*
- * NsSmartDeviceLink::NsTransportManager::CBluetoothAdapter::createConnectionsListForDevice() runs SDP query for specified device
+ * ns_smart_device_link::ns_transport_manager::CBluetoothAdapter::createConnectionsListForDevice() runs SDP query for specified device
* and fills connection list with connections to all RFCOMM channels on remote device where SmartDeviceLink service has been discovered.
*
* @see @ref components_transportmanager_internal_design_transport_adapters_common_connecting_devices
diff --git a/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Internal Design/Device Adapters/TCPAdapter.txt b/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Internal Design/Device Adapters/TCPAdapter.txt
index d81b70dfe8..2fbd835ec9 100644
--- a/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Internal Design/Device Adapters/TCPAdapter.txt
+++ b/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Internal Design/Device Adapters/TCPAdapter.txt
@@ -1,11 +1,11 @@
/** @page components_transportmanager_internal_design_transport_adapters_tcp_adapter TCP Adapter
*
* TCP adapter handles communication with remote devices via TCP/IP socket. It is implemented in
- * NsSmartDeviceLink::NsTransportManager::CTCPAdapter.
+ * ns_smart_device_link::ns_transport_manager::CTCPAdapter.
*
* @section components_transportmanager_internal_design_transport_adapters_tcp_adapter_listen Listening for connections
*
- * TCP adapter creates listening TCP socket (TCP port is specified in NsSmartDeviceLink::NsTransportManager::CTCPAdapter::cTCPAdapterPort)
+ * TCP adapter creates listening TCP socket (TCP port is specified in ns_smart_device_link::ns_transport_manager::CTCPAdapter::cTCPAdapterPort)
* and listens for incoming connections. Devices are identified by their IP address.
*
* @section components_transportmanager_internal_design_transport_adapters_tcp_adapter_accept Accepting connection
diff --git a/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Internal Design/Device Adapters/index.txt b/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Internal Design/Device Adapters/index.txt
index 3a5d0f0e91..015978b773 100644
--- a/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Internal Design/Device Adapters/index.txt
+++ b/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Internal Design/Device Adapters/index.txt
@@ -4,80 +4,80 @@
*
* @section components_transportmanager_internal_design_transport_adapters_common Common logic
*
- * Logic common to all device adapters is implemented in class NsSmartDeviceLink::NsTransportManager::CTransportAdapter.
+ * Logic common to all device adapters is implemented in class ns_smart_device_link::ns_transport_manager::CTransportAdapter.
*
* @subsection components_transportmanager_internal_design_transport_adapters_common_devices_map Devices map
*
- * Devices map is a map of device handle to internal device structure NsSmartDeviceLink::NsTransportManager::CTransportAdapter::SDevice.
- * Devices map is stored in NsSmartDeviceLink::NsTransportManager::CTransportAdapter::mDevices. Any access to this map must be performed
- * with NsSmartDeviceLink::NsTransportManager::CTransportAdapter::mDevicesMutex locked.
+ * Devices map is a map of device handle to internal device structure ns_smart_device_link::ns_transport_manager::CTransportAdapter::SDevice.
+ * Devices map is stored in ns_smart_device_link::ns_transport_manager::CTransportAdapter::mDevices. Any access to this map must be performed
+ * with ns_smart_device_link::ns_transport_manager::CTransportAdapter::mDevicesMutex locked.
*
* @subsection components_transportmanager_internal_design_transport_adapters_common_connections_map Connections map
*
- * Connections map is a map of connection handle to internal connection structure NsSmartDeviceLink::NsTransportManager::CTransportAdapter::SConnection.
- * Connections map is stored in NsSmartDeviceLink::NsTransportManager::CTransportAdapter::mConnections. Any access to this map must be performed
- * with NsSmartDeviceLink::NsTransportManager::CTransportAdapter::mConnectionsMutex locked.
+ * Connections map is a map of connection handle to internal connection structure ns_smart_device_link::ns_transport_manager::CTransportAdapter::SConnection.
+ * Connections map is stored in ns_smart_device_link::ns_transport_manager::CTransportAdapter::mConnections. Any access to this map must be performed
+ * with ns_smart_device_link::ns_transport_manager::CTransportAdapter::mConnectionsMutex locked.
*
* @subsection components_transportmanager_internal_design_transport_adapters_common_main_thread Device adapter main thread
*
- * Device adapter main thread is started in NsSmartDeviceLink::NsTransportManager::CTransportAdapter::run().
- * Specific device adapter must implement virtual function NsSmartDeviceLink::NsTransportManager::CTransportAdapter::mainThread()
+ * Device adapter main thread is started in ns_smart_device_link::ns_transport_manager::CTransportAdapter::run().
+ * Specific device adapter must implement virtual function ns_smart_device_link::ns_transport_manager::CTransportAdapter::mainThread()
* and implement its specific main thread logic there.
*
* @subsection components_transportmanager_internal_design_transport_adapters_common_connection_thread Device adapter connection thread
*
- * Device adapter connection thread is started in NsSmartDeviceLink::NsTransportManager::CTransportAdapter::startConnection().
- * Specific device adapter must implement virtual function NsSmartDeviceLink::NsTransportManager::CTransportAdapter::connectionThread()
+ * Device adapter connection thread is started in ns_smart_device_link::ns_transport_manager::CTransportAdapter::startConnection().
+ * Specific device adapter must implement virtual function ns_smart_device_link::ns_transport_manager::CTransportAdapter::connectionThread()
* and implement its specific connection thread logic there. When connection is established and socket file descriptor is set
- * in NsSmartDeviceLink::NsTransportManager::CTransportAdapter::SConnection::mConnectionSocket specific device adapter may call
- * NsSmartDeviceLink::NsTransportManager::CTransportAdapter::handleCommunication() to handle all communication through this socket
+ * in ns_smart_device_link::ns_transport_manager::CTransportAdapter::SConnection::mConnectionSocket specific device adapter may call
+ * ns_smart_device_link::ns_transport_manager::CTransportAdapter::handleCommunication() to handle all communication through this socket
* until connection is terminated.
*
* @subsection components_transportmanager_internal_design_transport_adapters_common_threads_termination Termination of device adapter threads
*
- * Specific device adapter implementation must call in its destructor NsSmartDeviceLink::NsTransportManager::CTransportAdapter::waitForThreadsTermination()
+ * Specific device adapter implementation must call in its destructor ns_smart_device_link::ns_transport_manager::CTransportAdapter::waitForThreadsTermination()
* to wait for termination of all threads (main thread and connection threads). Device adapter threads must be terminated before specific
* device adapter class is destructed, so it can't be called in the destructor of base class and must be called explicitly from the inherited
* class's destructor.
*
* @subsection components_transportmanager_internal_design_transport_adapters_common_device_scan Requesting scan for new devices
*
- * Device scan is requested by setting flag NsSmartDeviceLink::NsTransportManager::CTransportAdapter::mDeviceScanRequested
- * and signaling conditional variable NsSmartDeviceLink::NsTransportManager::CTransportAdapter::mDeviceScanRequestedCond, which may be monitored
+ * Device scan is requested by setting flag ns_smart_device_link::ns_transport_manager::CTransportAdapter::mDeviceScanRequested
+ * and signaling conditional variable ns_smart_device_link::ns_transport_manager::CTransportAdapter::mDeviceScanRequestedCond, which may be monitored
* by specific device adapter if it supports device scanning. Specific device adaptere may call for this purpose
- * NsSmartDeviceLink::NsTransportManager::CTransportAdapter::waitForDeviceScanRequest() which will wait on this conditional variable
+ * ns_smart_device_link::ns_transport_manager::CTransportAdapter::waitForDeviceScanRequest() which will wait on this conditional variable
* until it's signaled or specified timeout expires.
*
* @subsection components_transportmanager_internal_design_transport_adapters_common_connecting_devices Connecting devices
*
- * Device connection is initiated with a call to NsSmartDeviceLink::NsTransportManager::CTransportAdapter::connectDevice().
- * This method calls virtual function NsSmartDeviceLink::NsTransportManager::CTransportAdapter::createConnectionsListForDevice()
+ * Device connection is initiated with a call to ns_smart_device_link::ns_transport_manager::CTransportAdapter::connectDevice().
+ * This method calls virtual function ns_smart_device_link::ns_transport_manager::CTransportAdapter::createConnectionsListForDevice()
* which may be implemented by specific device adapter to create a list of connections that must be established for the device.
- * For each connection created by device adapter it calls NsSmartDeviceLink::NsTransportManager::CTransportAdapter::startConnection()
+ * For each connection created by device adapter it calls ns_smart_device_link::ns_transport_manager::CTransportAdapter::startConnection()
* which adds connection to connections map and starts connection thread.
*
* @subsection components_transportmanager_internal_design_transport_adapters_common_disconnecting_devices Disconnecting devices
*
- * Device disconnection is initiated with a call to NsSmartDeviceLink::NsTransportManager::CTransportAdapter::disconnectDevice().
+ * Device disconnection is initiated with a call to ns_smart_device_link::ns_transport_manager::CTransportAdapter::disconnectDevice().
* This method finds all connections in connections map that corresponds to specified device and calls
- * NsSmartDeviceLink::NsTransportManager::CTransportAdapter::stopConnection() for each of them.
+ * ns_smart_device_link::ns_transport_manager::CTransportAdapter::stopConnection() for each of them.
*
* @subsection components_transportmanager_internal_design_transport_adapters_common_handling_communication Handling communication
*
- * All frames requested to be sent via NsSmartDeviceLink::NsTransportManager::CTransportAdapter::sendFrame() are stored in
- * NsSmartDeviceLink::NsTransportManager::CTransportAdapter::SConnection::mFramesToSend. Pipe
- * NsSmartDeviceLink::NsTransportManager::CTransportAdapter::SConnection::mNotificationPipeFds is used by
- * NsSmartDeviceLink::NsTransportManager::CTransportAdapter::sendFrame() to notify connection thread that data is available
- * to be sent. NsSmartDeviceLink::NsTransportManager::CTransportAdapter::sendFrame() writes one byte to the write end of this pipe.
- * NsSmartDeviceLink::NsTransportManager::CTransportAdapter::handleCommunication() uses poll() to wait for
+ * All frames requested to be sent via ns_smart_device_link::ns_transport_manager::CTransportAdapter::sendFrame() are stored in
+ * ns_smart_device_link::ns_transport_manager::CTransportAdapter::SConnection::mFramesToSend. Pipe
+ * ns_smart_device_link::ns_transport_manager::CTransportAdapter::SConnection::mNotificationPipeFds is used by
+ * ns_smart_device_link::ns_transport_manager::CTransportAdapter::sendFrame() to notify connection thread that data is available
+ * to be sent. ns_smart_device_link::ns_transport_manager::CTransportAdapter::sendFrame() writes one byte to the write end of this pipe.
+ * ns_smart_device_link::ns_transport_manager::CTransportAdapter::handleCommunication() uses poll() to wait for
* incoming data using connection socket file descriptor and outgoing data using file descriptor of the read end of this pipe.
* When either of them become available for reading or some error occurs (e.g. socket gets disconnected) connection thread
* wakes up and handles this event. Notification pipe is also used to notify connection thread that connection has to be
- * terminated using NsSmartDeviceLink::NsTransportManager::CTransportAdapter::SConnection::mTerminateFlag.
+ * terminated using ns_smart_device_link::ns_transport_manager::CTransportAdapter::SConnection::mTerminateFlag.
*
* @subsection components_transportmanager_internal_design_transport_adapters_common_update_client_device_list Updating client device list.
*
- * Specific device adapter may call NsSmartDeviceLink::NsTransportManager::CTransportAdapter::updateClientDeviceList() when its internal
+ * Specific device adapter may call ns_smart_device_link::ns_transport_manager::CTransportAdapter::updateClientDeviceList() when its internal
* knowledge about available devices is updated to notify device adapter client (TransportManager) about this update.
*
* @section components_transportmanager_internal_design_transport_adapters_common_specific Specific device adapters
diff --git a/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Internal Design/MultiThreading.txt b/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Internal Design/MultiThreading.txt
index 6c35f0962f..3d2fcb5094 100644
--- a/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Internal Design/MultiThreading.txt
+++ b/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Internal Design/MultiThreading.txt
@@ -2,8 +2,8 @@
Internally Transport Manager uses different threads for different operations. This design solution was used to provide efficient asynchronous communication with clients and underlying Device Adapters.
-Transport Manager uses one thread to operate with all device-related callbacks. In other word all callbacks declared in NsSmartDeviceLink::NsTransportManager::ITransportManagerDeviceListener will be called from that thread.
+Transport Manager uses one thread to operate with all device-related callbacks. In other word all callbacks declared in ns_smart_device_link::ns_transport_manager::ITransportManagerDeviceListener will be called from that thread.
-For every active connection one service thread will be created. This thread will be used for all connection-related callbacks. Therefore every implementation of NsSmartDeviceLink::NsTransportManager::ITransportManagerDataListener will be called in separated thread that allows client to support multiple connection simultaneously.
+For every active connection one service thread will be created. This thread will be used for all connection-related callbacks. Therefore every implementation of ns_smart_device_link::ns_transport_manager::ITransportManagerDataListener will be called in separated thread that allows client to support multiple connection simultaneously.
*/
diff --git a/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Internal Design/TrasportManager.txt b/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Internal Design/TrasportManager.txt
index c96fd46a22..164fad9140 100644
--- a/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Internal Design/TrasportManager.txt
+++ b/src/components/policy/policy_external/doc/doxygen/components/TransportManager/Internal Design/TrasportManager.txt
@@ -2,13 +2,13 @@
Actually Transport Manager component is implemented as classical manager component. It manages connections and abstract devices and provides unified information for the clients.
-Connection-related information encapsulated in structure NsSmartDeviceLink::NsTransportManager::CTransportManager::SConnectionInfo. Transport Manager manages these structures to store information about every active connection.
+Connection-related information encapsulated in structure ns_smart_device_link::ns_transport_manager::CTransportManager::SConnectionInfo. Transport Manager manages these structures to store information about every active connection.
-Frame processing encapsulated in structure NsSmartDeviceLink::NsTransportManager::CTransportManager::SFrameDataForConnection. Transport Manager manages these structures to store information related to data for specific connection.
+Frame processing encapsulated in structure ns_smart_device_link::ns_transport_manager::CTransportManager::SFrameDataForConnection. Transport Manager manages these structures to store information related to data for specific connection.
Callback information between transport manager threads passed in form of special structures:
-NsSmartDeviceLink::NsTransportManager::CTransportManager::SDeviceListenerCallback.
-NsSmartDeviceLink::NsTransportManager::CTransportManager::SDataListenerCallback.
+ns_smart_device_link::ns_transport_manager::CTransportManager::SDeviceListenerCallback.
+ns_smart_device_link::ns_transport_manager::CTransportManager::SDataListenerCallback.
Client calls to TM guarded by separate mutex. This allows use component from different threads without any risk.
diff --git a/src/components/policy/policy_external/doc/doxygen/tools/InterfaceGenerator/How To Use.txt b/src/components/policy/policy_external/doc/doxygen/tools/InterfaceGenerator/How To Use.txt
index 0f9e340bc5..e7b14b0da1 100644
--- a/src/components/policy/policy_external/doc/doxygen/tools/InterfaceGenerator/How To Use.txt
+++ b/src/components/policy/policy_external/doc/doxygen/tools/InterfaceGenerator/How To Use.txt
@@ -1,6 +1,6 @@
/*! \page tools_interfacegenerator_usage How to use InterfaceGenerator
-To run InterfaceGenerator the Python 2.7 interpreter should be installed. As input InterfaceGenerator requires full path to the source XML file, namespace to generate result code in, full path to the output directory where result source code C++ will be created and optionally explicit specification of parser type.
+To run InterfaceGenerator the Python 3.5+ interpreter should be installed. As input InterfaceGenerator requires full path to the source XML file, namespace to generate result code in, full path to the output directory where result source code C++ will be created and optionally explicit specification of parser type.
Example1 (Run Generator.py to display help):
diff --git a/src/components/policy/policy_external/include/policy/access_remote.h b/src/components/policy/policy_external/include/policy/access_remote.h
index fd185af075..eadef088ad 100644
--- a/src/components/policy/policy_external/include/policy/access_remote.h
+++ b/src/components/policy/policy_external/include/policy/access_remote.h
@@ -32,9 +32,9 @@
#ifndef SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_ACCESS_REMOTE_H_
#define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_ACCESS_REMOTE_H_
-#include <vector>
#include <ostream>
#include <string>
+#include <vector>
#include "policy/policy_table/types.h"
#include "policy/policy_types.h"
diff --git a/src/components/policy/policy_external/include/policy/access_remote_impl.h b/src/components/policy/policy_external/include/policy/access_remote_impl.h
index 0fa53b0237..cee2a8774f 100644
--- a/src/components/policy/policy_external/include/policy/access_remote_impl.h
+++ b/src/components/policy/policy_external/include/policy/access_remote_impl.h
@@ -35,7 +35,7 @@
#include <map>
#include "policy/policy_table/types.h"
#include "utils/macro.h"
-#include "utils/shared_ptr.h"
+
#include "policy/access_remote.h"
#include "policy/cache_manager.h"
@@ -46,7 +46,7 @@ namespace policy {
class AccessRemoteImpl : public AccessRemote {
public:
AccessRemoteImpl();
- explicit AccessRemoteImpl(utils::SharedPtr<CacheManager> cache);
+ explicit AccessRemoteImpl(std::shared_ptr<CacheManager> cache);
/**
* @brief CheckModuleType check if module type is allowed for application
* @param app_id application id
@@ -144,7 +144,7 @@ class AccessRemoteImpl : public AccessRemote {
/**
* @brief cache_ contains pointer to cache manager instance
*/
- utils::SharedPtr<CacheManager> cache_;
+ std::shared_ptr<CacheManager> cache_;
/**
* @brief hmi_types_ contains list of default HMI types for applications
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 f41ddb14cd..b826f4e5ce 100644
--- a/src/components/policy/policy_external/include/policy/cache_manager.h
+++ b/src/components/policy/policy_external/include/policy/cache_manager.h
@@ -33,18 +33,19 @@
#ifndef SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_CACHE_MANAGER_H_
#define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_CACHE_MANAGER_H_
+#include <atomic>
#include <map>
+#include "boost/optional.hpp"
-#include "utils/shared_ptr.h"
-#include "policy/pt_representation.h"
+#include "policy/cache_manager_interface.h"
#include "policy/pt_ext_representation.h"
+#include "policy/pt_representation.h"
#include "policy/usage_statistics/statistics_manager.h"
-#include "policy/cache_manager_interface.h"
#include "utils/threads/thread.h"
#include "utils/threads/thread_delegate.h"
-#include "utils/lock.h"
#include "utils/conditional_variable.h"
+#include "utils/lock.h"
namespace policy {
class PolicySettings;
@@ -154,10 +155,114 @@ class CacheManager : public CacheManagerInterface {
*/
virtual bool SecondsBetweenRetries(std::vector<int>& seconds);
+ 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;
+
+ std::vector<policy_table::VehicleDataItem> GetRemovedVehicleDataItems()
+ 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
+ */
+ void GetEnabledCloudApps(
+ std::vector<std::string>& enabled_apps) const OVERRIDE;
+
+ /**
+ * @brief Get a list of enabled local applications
+ * @return enabled_apps List filled with the policy app id
+ * of each enabled local application
+ */
+ std::vector<std::string> GetEnabledLocalApps() const OVERRIDE;
+
+ bool GetAppProperties(const std::string& policy_app_id,
+ AppProperties& out_app_properties) const OVERRIDE;
+
+ /**
+ * Initializes a new cloud application with default policies
+ * Then adds cloud specific policies
+ * @param app_id application id
+ * @return true if success
+ */
+ virtual void InitCloudApp(const std::string& policy_app_id);
+
+ /**
+ * @brief Enable or disable a cloud application in the HMI
+ * @param enabled Cloud app enabled state
+ */
+ virtual void SetCloudAppEnabled(const std::string& policy_app_id,
+ const bool enabled);
+
+ /**
+ * @brief Set an app's auth token
+ * @param auth_token Cloud app authentication token
+ */
+ virtual void SetAppAuthToken(const std::string& policy_app_id,
+ const std::string& auth_token);
+
+ /**
+ * @brief Set a cloud app's transport type
+ * @param cloud_transport_type Cloud app transport type
+ */
+ virtual void SetAppCloudTransportType(
+ const std::string& policy_app_id,
+ const std::string& cloud_transport_type);
+
+ /**
+ * @brief Set a cloud app's endpoint url
+ * @param endpoint URL for websocket connection
+ */
+ virtual void SetAppEndpoint(const std::string& policy_app_id,
+ const std::string& endpoint);
+
+ /**
+ * @brief Set a cloud app's nicknames
+ * @param nicknames Nicknames for cloud app
+ */
+ virtual void SetAppNicknames(const std::string& policy_app_id,
+ const StringArray& nicknames);
+
/**
- * @brief Gets information about vehicle
+ * @brief Set the user preference for how a hybrid (cloud and mobile) app
+ * should be used
+ * @param hybrid_app_preference Hybrid app user preference
*/
- virtual const VehicleInfo GetVehicleInfo() const;
+ virtual void SetHybridAppPreference(const std::string& policy_app_id,
+ const std::string& hybrid_app_preference);
+
+ /**
+ * @brief Get app service parameters from the policy table
+ * @param policy_app_id Unique application id
+ * @param app_service_parameters Pointer to struct containing all app service
+ * information
+ */
+ virtual void GetAppServiceParameters(
+ const std::string& policy_app_id,
+ policy_table::AppServiceParameters* app_service_parameters) const;
+
+ /**
+ * @brief Check if an app can send unknown rpc requests to an app service
+ * provider
+ * @param policy_app_id Unique application id
+ */
+ virtual bool UnknownRPCPassthroughAllowed(
+ const std::string& policy_app_id) const;
/**
* @brief Allows to update 'vin' field in module_meta table.
@@ -182,26 +287,27 @@ class CacheManager : public CacheManagerInterface {
std::vector<UserFriendlyMessage> GetUserFriendlyMsg(
const std::vector<std::string>& msg_codes,
const std::string& language,
- const std::string& active_hmi_language);
+ const std::string& active_hmi_language) const;
/**
- * @brief GetLockScreenIcon allows to obtain lock screen icon url;
+ * @brief Get Icon Url used for showing a cloud apps icon before the intial
+ *registration
*
- * @return url which point to the resourse where lock screen icon could be
+ * @return url which point to the resourse where icon could be
*obtained.
*/
- virtual std::string GetLockScreenIconUrl() const;
+ virtual std::string GetIconUrl(const std::string& policy_app_id) const;
/**
* @brief Gets list of URL to send PTS to
* @param service_type If URLs for specific service are preset,
* return them otherwise default URLs.
*/
- virtual void GetUpdateUrls(const std::string& service_type,
- EndpointUrls& out_end_points);
+ void GetUpdateUrls(const std::string& service_type,
+ EndpointUrls& out_end_points) const OVERRIDE;
- virtual void GetUpdateUrls(const uint32_t service_type,
- EndpointUrls& out_end_points);
+ void GetUpdateUrls(const uint32_t service_type,
+ EndpointUrls& out_end_points) const OVERRIDE;
/**
* @brief Gets allowed number of notifications
@@ -232,7 +338,7 @@ class CacheManager : public CacheManagerInterface {
* device_info, statistics, excluding user messages
* @return Generated structure for obtaining Json string.
*/
- virtual utils::SharedPtr<policy_table::Table> GenerateSnapshot();
+ virtual std::shared_ptr<policy_table::Table> GenerateSnapshot();
/**
* Applies policy table to the current table
@@ -298,6 +404,12 @@ class CacheManager : public CacheManagerInterface {
bool GetFunctionalGroupings(policy_table::FunctionalGroupings& groups);
/**
+ * @brief Get policy app names from PT
+ * @return container of strings representing policy application names
+ */
+ const policy_table::Strings GetPolicyAppIDs() const OVERRIDE;
+
+ /**
* Checks if the application is represented in policy table
* @param app_id application id
* @return true if application is represented in policy table
@@ -688,39 +800,40 @@ class CacheManager : public CacheManagerInterface {
ExternalConsentStatus GetExternalConsentEntities() OVERRIDE;
/**
- * @brief Creates collection of ExternalConsent items known by current
- * functional
- * groupings and appropiate section
- * (disallowed_by_external_consent_entities_on/off) where
- * is item is being holded. If item is not found it's not included into
- * collection
- * @param status Current status containing collection of ExternalConsent items
- * @return Collection of ExternalConsent items mapped to list of groups with
- * section
- * marker where the item is found
- */
+ * @brief Creates collection of ExternalConsent items known by current
+ * functional
+ * groupings and appropiate section
+ * (disallowed_by_external_consent_entities_on/off) where
+ * is item is being holded. If item is not found it's not included into
+ * collection
+ * @param status Current status containing collection of ExternalConsent items
+ * @return Collection of ExternalConsent items mapped to list of groups with
+ * section
+ * marker where the item is found
+ */
GroupsByExternalConsentStatus GetGroupsWithSameEntities(
const ExternalConsentStatus& status) OVERRIDE;
/**
- * @brief Gets collection of links device-to-application from device_data
- * section of policy table if there any application records present, i.e. if
- * any specific user consent is present
- * @return Collection of device-to-application links
- */
+ * @brief Gets collection of links device-to-application from device_data
+ * section of policy table if there any application records present, i.e. if
+ * any specific user consent is present
+ * @return Collection of device-to-application links
+ */
std::map<std::string, std::string> GetKnownLinksFromPT() OVERRIDE;
/**
- * @brief Sets groups permissions affected by customer connectivity settings
- * entities status, i.e. groups assigned to particular application on
- * particular device which have same entities as current ExternalConsent status
- * @param permissions Groups permissions which result current ExternalConsent
- * status
- */
+ * @brief Sets groups permissions affected by customer connectivity settings
+ * entities status, i.e. groups assigned to particular application on
+ * particular device which have same entities as current ExternalConsent
+ * status
+ * @param permissions Groups permissions which result current ExternalConsent
+ * status
+ */
void SetExternalConsentForApp(const PermissionConsent& permissions) OVERRIDE;
#ifdef BUILD_TESTS
- utils::SharedPtr<policy_table::Table> GetPT() const {
+ std::shared_ptr<policy_table::Table> GetPT() const {
return pt_;
}
#endif
@@ -736,6 +849,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 {
@@ -754,6 +875,24 @@ class CacheManager : public CacheManagerInterface {
*/
void CheckSnapshotInitialization();
+ /**
+ * @brief Calculates difference between two provided custom vehicle data items
+ * @param items_before list of vehicle data items before PTU was applied
+ * @param items_after list of vehicle data items after PTU was applied
+ * @return list with calculated difference or empty list if two input lists
+ * are equal
+ */
+ policy_table::VehicleDataItems CalculateCustomVdItemsDiff(
+ const policy_table::VehicleDataItems& items_before,
+ const policy_table::VehicleDataItems& items_after) const;
+
+ /**
+ * @brief Sets the custom vehicle data items
+ * @param removed_items list of vehicle data items to set
+ */
+ void SetRemovedCustomVdItems(
+ const policy_table::VehicleDataItems& removed_items);
+
void PersistData();
/**
@@ -781,16 +920,27 @@ class CacheManager : public CacheManagerInterface {
const std::string& policy_app_id,
policy::Permissions& permission);
+ EncryptionRequired GetAppEncryptionRequiredFlag(
+ const std::string& application_policy_name) const OVERRIDE;
+
+ EncryptionRequired GetFunctionalGroupingEncryptionRequiredFlag(
+ const std::string& functional_group) const OVERRIDE;
+
+ void GetApplicationParams(
+ const std::string& application_name,
+ policy_table::ApplicationParams& application_policies) const OVERRIDE;
+
private:
- utils::SharedPtr<policy_table::Table> pt_;
- utils::SharedPtr<policy_table::Table> snapshot_;
- utils::SharedPtr<PTRepresentation> backup_;
- utils::SharedPtr<PTExtRepresentation> ex_backup_;
+ std::shared_ptr<policy_table::Table> pt_;
+ std::shared_ptr<policy_table::Table> snapshot_;
+ std::shared_ptr<PTRepresentation> backup_;
+ std::shared_ptr<PTExtRepresentation> ex_backup_;
bool update_required;
typedef std::set<std::string> UnpairedDevices;
UnpairedDevices is_unpaired_;
+ policy_table::VehicleDataItems removed_custom_vd_items_;
- mutable sync_primitives::Lock cache_lock_;
+ mutable sync_primitives::RecursiveLock cache_lock_;
sync_primitives::Lock unpaired_lock_;
typedef std::map<std::string, Permissions> AppCalculatedPermissions;
@@ -910,6 +1060,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();
/**
@@ -940,12 +1108,28 @@ class CacheManager : public CacheManagerInterface {
~BackgroundBackuper();
virtual void threadMain();
virtual void exitThreadMain();
+
+ /**
+ * @brief Notifies BackgroundBackuper thread that new data is available and
+ * new backup iteration should be scheduled
+ */
void DoBackup();
+ /**
+ * @brief Waits for BackgroundBackuper thread finish its own backup
+ * iteration. If currently no backup iteration in progress - function just
+ * returns the control back
+ */
+ void WaitForBackupIsDone();
+
private:
void InternalBackup();
CacheManager* cache_manager_;
sync_primitives::ConditionalVariable backup_notifier_;
+ sync_primitives::ConditionalVariable backup_done_;
+ sync_primitives::Lock backup_done_lock_;
+
+ std::atomic_bool backup_is_in_progress_;
volatile bool stop_flag_;
volatile bool new_data_available_;
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 1d74780f19..3e3de694d6 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
@@ -35,13 +35,14 @@
#include <string>
#include <vector>
+#include "boost/optional.hpp"
#include "policy/policy_table/types.h"
#include "policy/pt_representation.h"
-#include "utils/shared_ptr.h"
-#include "policy/usage_statistics/counter.h"
-#include "policy/policy_types.h"
+
#include "policy/policy_settings.h"
+#include "policy/policy_types.h"
+#include "policy/usage_statistics/counter.h"
namespace policy_table = rpc::policy_table_interface_base;
@@ -161,9 +162,138 @@ 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 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 Gets vehicle data items removed after the last PTU
+ * @return List of removed vehicle data items
+ */
+ virtual std::vector<policy_table::VehicleDataItem>
+ GetRemovedVehicleDataItems() const = 0;
+
+ /**
+ * @brief Get a list of enabled cloud applications
+ * @param enabled_apps List filled with the policy app id of each enabled
+ * cloud application
+ */
+ virtual void GetEnabledCloudApps(
+ std::vector<std::string>& enabled_apps) const = 0;
+
+ /**
+ * @brief Get a list of enabled local applications
+ * @return enabled_apps List filled with the policy app id of each enabled
+ * local application
+ */
+ virtual std::vector<std::string> GetEnabledLocalApps() const = 0;
+
+ /**
+ * @brief Get app policy information, all fields that aren't set for a
+ * given app will be filled with empty strings
+ * @param policy_app_id policy app id
+ * @param out_app_properties application properties
+ * @return true if application presents in database, otherwise - false
+ */
+ virtual bool GetAppProperties(const std::string& policy_app_id,
+ AppProperties& out_app_properties) const = 0;
+
+ /**
+ * Initializes a new cloud application with default policies
+ * Then adds cloud specific policies
+ * @param app_id application id
+ * @return true if success
+ */
+ virtual void InitCloudApp(const std::string& policy_app_id) = 0;
+
+ /**
+ * @brief Enable or disable a cloud application in the HMI
+ * @param enabled Cloud app enabled state
+ */
+ virtual void SetCloudAppEnabled(const std::string& policy_app_id,
+ const bool enabled) = 0;
+
+ /**
+ * @brief Set an app's auth token
+ * @param auth_token Cloud app authentication token
+ */
+ virtual void SetAppAuthToken(const std::string& policy_app_id,
+ const std::string& auth_token) = 0;
+
+ /**
+ * @brief Set a cloud app's transport type
+ * @param cloud_transport_type Cloud app transport type
+ */
+ virtual void SetAppCloudTransportType(
+ const std::string& policy_app_id,
+ const std::string& cloud_transport_type) = 0;
+
+ /**
+ * @brief Set a cloud app's endpoint url
+ * @param endpoint URL for websocket connection
+ */
+ virtual void SetAppEndpoint(const std::string& policy_app_id,
+ const std::string& endpoint) = 0;
+
+ /**
+ * @brief Set a cloud app's nicknames
+ * @param nicknames Nicknames for cloud app
+ */
+ virtual void SetAppNicknames(const std::string& policy_app_id,
+ const StringArray& nicknames) = 0;
+
+ /**
+ * @brief Set the user preference for how a hybrid (cloud and mobile) app
+ * should be used
+ * @param hybrid_app_preference Hybrid app user preference
+ */
+ virtual void SetHybridAppPreference(
+ const std::string& policy_app_id,
+ const std::string& hybrid_app_preference) = 0;
+
+ /**
+ * @brief Get app service parameters from the policy table
+ * @param policy_app_id Unique application id
+ * @param app_service_parameters Pointer to struct containing all app service
+ * information
+ */
+ virtual void GetAppServiceParameters(
+ const std::string& policy_app_id,
+ policy_table::AppServiceParameters* app_service_parameters) const = 0;
+
+ /**
+ * @brief Check if an app can send unknown rpc requests to an app service
+ * provider
+ * @param policy_app_id Unique application id
+ */
+ virtual bool UnknownRPCPassthroughAllowed(
+ const std::string& policy_app_id) const = 0;
+
+ /**
+ * @brief Returns state of the lock screen that could be able to be dismissed
+ * while connected to SDL, allowing users the ability to interact with the
+ * app.
+ * @return bool True if lock screen can be dismissed.
+ */
+ virtual const boost::optional<bool> LockScreenDismissalEnabledState()
+ const = 0;
+
+ /**
+ * @brief Returns lock screen warning message. In case when specified language
+ * is absent in policy table will be returned message on default language
+ * ("en-us"). Otherwise returns uninitialized boost::optional<std::string>
+ * @return std::string Lock screen warning message
*/
- virtual const VehicleInfo GetVehicleInfo() const = 0;
+ virtual const boost::optional<std::string> LockScreenDismissalWarningMessage(
+ const std::string& language) const = 0;
/**
* @brief Allows to update 'vin' field in module_meta table.
@@ -186,7 +316,7 @@ class CacheManagerInterface {
virtual std::vector<UserFriendlyMessage> GetUserFriendlyMsg(
const std::vector<std::string>& msg_codes,
const std::string& language,
- const std::string& active_hmi_language) = 0;
+ const std::string& active_hmi_language) const = 0;
/**
* @brief Get list of URL to send PTS to
@@ -194,18 +324,19 @@ class CacheManagerInterface {
* return them otherwise default URLs.
*/
virtual void GetUpdateUrls(const std::string& service_type,
- EndpointUrls& out_end_points) = 0;
+ EndpointUrls& out_end_points) const = 0;
virtual void GetUpdateUrls(const uint32_t service_type,
- EndpointUrls& out_end_points) = 0;
+ EndpointUrls& out_end_points) const = 0;
/**
- * @brief GetLockScreenIcon allows to obtain lock screen icon url;
+ * @brief Get Icon Url used for showing a cloud apps icon before the intial
+ *registration
*
- * @return url which point to the resourse where lock screen icon could be
+ * @return url which point to the resourse where icon could be
*obtained.
*/
- virtual std::string GetLockScreenIconUrl() const = 0;
+ virtual std::string GetIconUrl(const std::string& policy_app_id) const = 0;
/**
* @brief Get allowed number of notifications
@@ -237,7 +368,7 @@ class CacheManagerInterface {
* device_info, statistics, excluding user messages
* @return Generated structure for obtaining Json string.
*/
- virtual utils::SharedPtr<policy_table::Table> GenerateSnapshot() = 0;
+ virtual std::shared_ptr<policy_table::Table> GenerateSnapshot() = 0;
/**
* Applies policy table to the current table
@@ -304,6 +435,12 @@ class CacheManagerInterface {
policy_table::FunctionalGroupings& groups) = 0;
/**
+ * @brief Get policy app names from PT
+ * @return container of strings representing policy application names
+ */
+ virtual const policy_table::Strings GetPolicyAppIDs() const = 0;
+
+ /**
* Checks if the application is represented in policy table
* @param app_id application id
* @return true if application is represented in policy table
@@ -754,9 +891,9 @@ class CacheManagerInterface {
virtual std::string GetCertificate() const = 0;
/**
- * @brief Sets decrypted certificate in policy table
- * @param certificate content of certificate
- */
+ * @brief Sets decrypted certificate in policy table
+ * @param certificate content of certificate
+ */
virtual void SetDecryptedCertificate(const std::string& certificate) = 0;
/**
@@ -781,34 +918,35 @@ class CacheManagerInterface {
virtual ExternalConsentStatus GetExternalConsentEntities() = 0;
/**
- * @brief Creates collection of ExternalConsent items known by current
- * functional
- * groupings and appropiate section
- * (disallowed_by_external_consent_entities_on/off) where
- * is item is being holded
- * @param status Current status containing collection of ExternalConsent items
- * @return Collection of ExternalConsent items mapped to list of groups with
- * section
- * marker where the item is found
- */
+ * @brief Creates collection of ExternalConsent items known by current
+ * functional
+ * groupings and appropiate section
+ * (disallowed_by_external_consent_entities_on/off) where
+ * is item is being holded
+ * @param status Current status containing collection of ExternalConsent items
+ * @return Collection of ExternalConsent items mapped to list of groups with
+ * section
+ * marker where the item is found
+ */
virtual GroupsByExternalConsentStatus GetGroupsWithSameEntities(
const ExternalConsentStatus& status) = 0;
/**
- * @brief Gets collection of links device-to-application from device_data
- * section of policy table if there any application records present, i.e. if
- * any specific user consent is present
- * @return Collection of device-to-application links
- */
+ * @brief Gets collection of links device-to-application from device_data
+ * section of policy table if there any application records present, i.e. if
+ * any specific user consent is present
+ * @return Collection of device-to-application links
+ */
virtual std::map<std::string, std::string> GetKnownLinksFromPT() = 0;
/**
- * @brief Sets groups permissions affected by customer connectivity settings
- * entities status, i.e. groups assigned to particular application on
- * particular device which have same entities as current ExternalConsent status
- * @param permissions Groups permissions which result current ExternalConsent
- * status
- */
+ * @brief Sets groups permissions affected by customer connectivity settings
+ * entities status, i.e. groups assigned to particular application on
+ * particular device which have same entities as current ExternalConsent
+ * status
+ * @param permissions Groups permissions which result current ExternalConsent
+ * status
+ */
virtual void SetExternalConsentForApp(
const PermissionConsent& permissions) = 0;
@@ -821,18 +959,49 @@ class CacheManagerInterface {
virtual void OnDeviceSwitching(const std::string& device_id_from,
const std::string& device_id_to) = 0;
+ /**
+ * @brief GetAppEncryptionRequiredFlag retrieves encryption required flag
+ * for
+ * given application
+ * @param application policy application name
+ * @return optional object containing encryption required flag
+ */
+ virtual rpc::Optional<rpc::Boolean> GetAppEncryptionRequiredFlag(
+ const std::string& application_policy_name) const = 0;
+
+ /**
+ * @brief GetFunctionalGroupingEncryptionRequiredFlag retrieves encryption
+ * required flag
+ * for
+ * given functional grouping
+ * @param functional_group policy functional group name
+ * @return optional object containing encryption required flag
+ */
+ virtual rpc::Optional<rpc::Boolean>
+ GetFunctionalGroupingEncryptionRequiredFlag(
+ const std::string& functional_group) const = 0;
+
+ /**
+ * @brief retreives application params
+ * @param application_name policy applicatoin name
+ * @param application_params application params
+ */
+ virtual void GetApplicationParams(
+ const std::string& application_name,
+ policy_table::ApplicationParams& application_params) const = 0;
+
#ifdef BUILD_TESTS
/**
- * @brief GetPT allows to obtain SharedPtr to PT.
+ * @brief GetPT allows to obtain std::shared_ptr to PT.
* Used ONLY in Unit tests
- * @return SharedPTR to PT
+ * @return std::shared_ptr to PT
*
*/
- virtual utils::SharedPtr<policy_table::Table> GetPT() const = 0;
+ virtual std::shared_ptr<policy_table::Table> GetPT() const = 0;
#endif
};
-typedef utils::SharedPtr<CacheManagerInterface> CacheManagerInterfaceSPtr;
+typedef std::shared_ptr<CacheManagerInterface> CacheManagerInterfaceSPtr;
} // namespace policy
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 e399b44719..69ba8806d4 100644
--- a/src/components/policy/policy_external/include/policy/policy_helper.h
+++ b/src/components/policy/policy_external/include/policy/policy_helper.h
@@ -1,4 +1,4 @@
-/*
+/*
Copyright (c) 2013, Ford Motor Company
All rights reserved.
@@ -34,7 +34,7 @@
#define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_POLICY_HELPER_H_
#include "policy/policy_table/functions.h"
-#include "utils/shared_ptr.h"
+
#include "policy/policy_types.h"
namespace policy {
@@ -85,8 +85,8 @@ bool operator!=(const policy_table::ApplicationParams& first,
*/
struct CheckAppPolicy {
CheckAppPolicy(PolicyManagerImpl* pm,
- const utils::SharedPtr<policy_table::Table> update,
- const utils::SharedPtr<policy_table::Table> snapshot,
+ const std::shared_ptr<policy_table::Table> update,
+ const std::shared_ptr<policy_table::Table> snapshot,
CheckAppPolicyResults& out_results);
bool operator()(const AppPoliciesValueType& app_policy);
@@ -100,7 +100,8 @@ struct CheckAppPolicy {
* @param result Result of check of updated policy
*/
void SetPendingPermissions(const AppPoliciesValueType& app_policy,
- PermissionsCheckResult result) const;
+ PermissionsCheckResult result,
+ AppPermissions& permissions_diff) const;
/**
* @brief Analyzes updated application policy whether any changes received. If
* yes - provides appropriate result code
@@ -128,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
@@ -200,10 +210,35 @@ struct CheckAppPolicy {
*/
bool IsRequestSubTypeChanged(const AppPoliciesValueType& app_policy) const;
+ /**
+ * @brief IsEncryptionRequiredFlagChanged check if encryption_needed flag was
+ * changed for application or application groups
+ * @param app_policy application policies
+ * @return true if encryption_needed state was changed otherwise - false
+ */
+ bool IsEncryptionRequiredFlagChanged(
+ const AppPoliciesValueType& app_policy) const;
+
+ /**
+ * @brief Helper function that inserts permissions into app_permissions_diff_
+ * map.
+ * udpated
+ * @param app_policy Reference to updated application policy
+ * @param permissions_diff Reference to app permissions to be inserted into
+ * map.
+ * @return void
+ */
+ void InsertPermission(const std::string& app_id,
+ const AppPermissions& permissions_diff);
+
+ bool IsAppPropertiesChanged(const AppPoliciesValueType& app_policy) const;
+
+ bool IsAppPropertiesProvided(const AppPoliciesValueType& app_policy) const;
+
private:
PolicyManagerImpl* pm_;
- const utils::SharedPtr<policy_table::Table> update_;
- const utils::SharedPtr<policy_table::Table> snapshot_;
+ const std::shared_ptr<policy_table::Table> update_;
+ const std::shared_ptr<policy_table::Table> snapshot_;
CheckAppPolicyResults& out_results_;
};
@@ -230,13 +265,13 @@ struct FillActionsForAppPolicies {
*/
struct FillNotificationData {
/**
- * @brief Constructor
- * @param data Output structure with filled data
- * @param group_state Consent of the group processed by instance
- * @param undefined_group_consent Defines how to treat 'undefined' consent
- * @param does_require_user_consent Specifies whether processed group requires
- * user consent
- */
+ * @brief Constructor
+ * @param data Output structure with filled data
+ * @param group_state Consent of the group processed by instance
+ * @param undefined_group_consent Defines how to treat 'undefined' consent
+ * @param does_require_user_consent Specifies whether processed group requires
+ * user consent
+ */
FillNotificationData(Permissions& data,
GroupConsent group_state,
GroupConsent undefined_group_consent,
@@ -255,8 +290,26 @@ struct FillNotificationData {
const std::set<Parameter>& target);
void InitRpcKeys(const std::string& rpc_name);
bool RpcParametersEmpty(RpcPermissions& rpc);
- bool IsSectionEmpty(ParameterPermissions& permissions,
- const std::string& section);
+
+ /**
+ * @brief Checks if specific section in specified permissions is empty
+ * @param permissions reference to the permissions structure
+ * @param section reference to the section name
+ * @return true if specified section in permissions is empty otherwise returns
+ * false
+ */
+ bool IsSectionEmpty(const ParameterPermissions& permissions,
+ const std::string& section) const;
+
+ /**
+ * @brief Checks if at least one parameter is allowed for the specified
+ * permissions
+ * @param permissions reference to the permissions structure
+ * @return true if at least one parameter is allowed for the specified
+ * permissions otherwise returns false
+ */
+ bool IsSomeParameterAllowed(const ParameterPermissions& permissions) const;
+
std::string current_key_;
Permissions& data_;
const bool does_require_user_consent_;
@@ -276,6 +329,14 @@ struct ProcessFunctionalGroup {
private:
GroupConsent GetGroupState(const std::string& group_name);
+ /*
+ * @brief Fills encryption required flags for all rpcs in functional group
+ * @param encryption_required Optional object containing encryption required
+ * flag
+ */
+ void FillEncryptionFlagForRpcs(
+ const policy_table::Rpc& rpcs,
+ const policy::EncryptionRequired encryption_required);
const policy_table::FunctionalGroupings& fg_;
const std::vector<FunctionalGroupPermission>& group_permissions_;
Permissions& data_;
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 67756c053d..5c55be50d1 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
@@ -34,16 +34,17 @@
#define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_POLICY_MANAGER_IMPL_H_
#include <list>
-#include "utils/shared_ptr.h"
-#include "utils/lock.h"
+
+#include "policy/access_remote.h"
+#include "policy/access_remote_impl.h"
+#include "policy/cache_manager_interface.h"
#include "policy/policy_manager.h"
#include "policy/policy_table.h"
-#include "policy/cache_manager_interface.h"
-#include "policy/update_status_manager.h"
#include "policy/policy_table/functions.h"
+#include "policy/update_status_manager.h"
#include "policy/usage_statistics/statistics_manager.h"
-#include "policy/access_remote.h"
-#include "policy/access_remote_impl.h"
+#include "utils/lock.h"
+#include "utils/timer.h"
namespace policy_table = rpc::policy_table_interface_base;
@@ -54,7 +55,47 @@ class PolicyManagerImpl : public PolicyManager {
public:
PolicyManagerImpl();
explicit PolicyManagerImpl(bool in_memory);
+ /*
+ * \param policy_app_id policy app id
+ * \return true if the app need encryption
+ */
+ bool AppNeedEncryption(const std::string& policy_app_id) const OVERRIDE;
+
+ /*
+ * \param policy_app_id policy app id
+ * \return Optional app need encryption
+ */
+ const rpc::Optional<rpc::Boolean> GetAppEncryptionRequired(
+ const std::string& policy_app_id) const OVERRIDE;
+
+ /*
+ * \param policy_app_id policy app id
+ * \return groups that exist for app
+ */
+ const std::vector<std::string> GetFunctionalGroupsForApp(
+ const std::string& policy_app_id) const OVERRIDE;
+ const std::vector<std::string> GetApplicationPolicyIDs() const OVERRIDE;
+
+ /*
+ * \param policy_group group
+ * \return true if the group need encryption
+ */
+ bool FunctionGroupNeedEncryption(
+ const std::string& policy_group) const OVERRIDE;
+
+ /*
+ * \param policy_group group\
+ * \return RPCs that exists in group
+ */
+ const std::vector<std::string> GetRPCsForFunctionGroup(
+ const std::string& group) const OVERRIDE;
+ /*
+ * \param function_id function id
+ * \return policy function name
+ */
+ const std::string GetPolicyFunctionName(
+ const uint32_t function_id) const OVERRIDE;
/**
* @brief set_listener set new policy listener instance
* @param listener new policy listener
@@ -86,8 +127,10 @@ class PolicyManagerImpl : public PolicyManager {
* @param pt_content PTU as binary string
* @return true if successfully
*/
- bool LoadPT(const std::string& file,
- const BinaryMessage& pt_content) OVERRIDE;
+ PtProcessingResult LoadPT(const std::string& file,
+ const BinaryMessage& pt_content) OVERRIDE;
+
+ void OnPTUFinished(const PtProcessingResult ptu_result) OVERRIDE;
/**
* @brief Resets Policy Table
@@ -109,9 +152,9 @@ class PolicyManagerImpl : public PolicyManager {
* @param out_end_points output vector of urls
*/
void GetUpdateUrls(const uint32_t service_type,
- EndpointUrls& out_end_points) OVERRIDE;
+ EndpointUrls& out_end_points) const OVERRIDE;
void GetUpdateUrls(const std::string& service_type,
- EndpointUrls& out_end_points) OVERRIDE;
+ EndpointUrls& out_end_points) const OVERRIDE;
/**
* @brief PTU is needed, for this PTS has to be formed and sent.
@@ -122,6 +165,7 @@ class PolicyManagerImpl : public PolicyManager {
* @brief Check if specified RPC for specified application
* has permission to be executed in specified HMI Level
* and also its permitted params.
+ * @param device_id device identifier
* @param app_id Id of application provided during registration
* @param hmi_level Current HMI Level of application
* @param rpc Name of RPC
@@ -129,7 +173,8 @@ class PolicyManagerImpl : public PolicyManager {
* @param result containing flag if HMI Level is allowed
* and list of allowed params.
*/
- void CheckPermissions(const PTString& app_id,
+ void CheckPermissions(const PTString& device_id,
+ const PTString& app_id,
const PTString& hmi_level,
const PTString& rpc,
const RPCParams& rpc_params,
@@ -148,6 +193,11 @@ class PolicyManagerImpl : public PolicyManager {
*/
void KmsChanged(int kilometers) OVERRIDE;
+ const boost::optional<bool> LockScreenDismissalEnabledState() const OVERRIDE;
+
+ const boost::optional<std::string> LockScreenDismissalWarningMessage(
+ const std::string& language) const OVERRIDE;
+
/**
* @brief Increments counter of ignition cycles
*/
@@ -159,6 +209,8 @@ class PolicyManagerImpl : public PolicyManager {
*/
std::string ForcePTExchange() OVERRIDE;
+ void StopRetrySequence() OVERRIDE;
+
/**
* @brief Exchange by user request
* @return Current status of policy table
@@ -173,8 +225,10 @@ class PolicyManagerImpl : public PolicyManager {
/**
* @brief Resets retry sequence
+ * @param send_event - if true corresponding event is sent to
+ * UpdateStatusManager
*/
- void ResetRetrySequence() OVERRIDE;
+ void ResetRetrySequence(const ResetRetryCountType reset_type) OVERRIDE;
/**
* @brief Gets timeout to wait before next retry updating PT
@@ -202,11 +256,13 @@ class PolicyManagerImpl : public PolicyManager {
void OnExceededTimeout() OVERRIDE;
/**
- * @brief GetLockScreenIcon allows to obtain lock screen icon url;
- * @return url which point to the resourse where lock screen icon could be
+ * @brief Get Icon Url used for showing a cloud apps icon before the intial
+ *registration
+ *
+ * @return url which point to the resourse where icon could be
*obtained.
*/
- std::string GetLockScreenIconUrl() const OVERRIDE;
+ std::string GetIconUrl(const std::string& policy_app_id) const OVERRIDE;
/**
* @brief Handler of PTS sending out
@@ -253,12 +309,15 @@ class PolicyManagerImpl : public PolicyManager {
/**
* @brief Update Application Policies as reaction
* on User allowing/disallowing device this app is running on.
+ * @param device_handle device identifier
* @param app_id Unique application id
* @param is_device_allowed true if user allowing device otherwise false
* @return true if operation was successful
*/
- bool ReactOnUserDevConsentForApp(const std::string& app_id,
- const bool is_device_allowed) OVERRIDE;
+ bool ReactOnUserDevConsentForApp(
+ const transport_manager::DeviceHandle& device_handle,
+ const std::string& app_id,
+ const bool is_device_allowed) OVERRIDE;
/**
* @brief Retrieves data from app_policies about app on its registration:
@@ -301,12 +360,14 @@ class PolicyManagerImpl : public PolicyManager {
/**
* @brief Get default HMI level for application
+ * @param device_id device identifier
* @param policy_app_id Unique application id
* @param default_hmi Default HMI level for application or empty, if value
* was not set
* @return true, if succedeed, otherwise - false
*/
- bool GetDefaultHmi(const std::string& policy_app_id,
+ bool GetDefaultHmi(const std::string& device_id,
+ const std::string& policy_app_id,
std::string* default_hmi) const OVERRIDE;
/**
@@ -351,9 +412,11 @@ class PolicyManagerImpl : public PolicyManager {
/**
* @brief Return device id, which hosts specific application
+ * @param device_id device identifier
* @param policy_app_id Application id, which is required to update device id
*/
std::string& GetCurrentDeviceId(
+ const transport_manager::DeviceHandle& device_id,
const std::string& policy_app_id) const OVERRIDE;
/**
@@ -373,13 +436,6 @@ class PolicyManagerImpl : public PolicyManager {
const std::string& language) OVERRIDE;
/**
- * @brief Runs necessary operations, which is depends on external system
- * state, e.g. getting system-specific parameters which are need to be
- * filled into policy table
- */
- void OnSystemReady() OVERRIDE;
-
- /**
* @brief Get number of notification by priority
* @param priority Specified priority
* @return notification number
@@ -395,11 +451,12 @@ class PolicyManagerImpl : public PolicyManager {
/**
* @brief Gets specific application permissions changes since last policy
* table update
+ * @param device_id device identifier
* @param policy_app_id Unique application id
* @return Permissions changes
*/
AppPermissions GetAppPermissionsChanges(
- const std::string& policy_app_id) OVERRIDE;
+ const std::string& device_id, const std::string& policy_app_id) OVERRIDE;
/**
* @brief Removes specific application permissions changes
@@ -409,10 +466,11 @@ class PolicyManagerImpl : public PolicyManager {
/**
* @brief Send OnPermissionsUpdated for choosen application
+ * @param device_id device identifier
* @param application_id Unique application id
*/
void SendNotificationOnPermissionsUpdated(
- const std::string& application_id) OVERRIDE;
+ const std::string& device_id, const std::string& application_id) OVERRIDE;
/**
* @brief Removes unpaired device records and related records from DB
@@ -443,20 +501,24 @@ class PolicyManagerImpl : public PolicyManager {
/**
* @brief Adds, application to the db or update existed one
* run PTU if policy update is necessary for application.
+ * @param device_id device identifier
* @param application_id Unique application id
* @param hmi_types application HMI types
* @return function that will notify update manager about new application
*/
StatusNotifier AddApplication(
+ const std::string& device_id,
const std::string& application_id,
const rpc::policy_table_interface_base::AppHmiTypes& hmi_types) OVERRIDE;
/**
* @brief Assigns new HMI types for specified application
+ * @param device_handle device identifier
* @param application_id Unique application id
* @param hmi_types new HMI types list
*/
- void SetDefaultHmiTypes(const std::string& application_id,
+ void SetDefaultHmiTypes(const transport_manager::DeviceHandle& device_handle,
+ const std::string& application_id,
const std::vector<int>& hmi_types) OVERRIDE;
/**
@@ -472,7 +534,7 @@ class PolicyManagerImpl : public PolicyManager {
* @brief Setter for access_remote instance
* @param access_remote pointer to new access_remote instance
*/
- void set_access_remote(utils::SharedPtr<AccessRemote> access_remote) OVERRIDE;
+ void set_access_remote(std::shared_ptr<AccessRemote> access_remote) OVERRIDE;
/**
* @brief Sends notification about application HMI level changed
@@ -532,11 +594,13 @@ class PolicyManagerImpl : public PolicyManager {
*/
void OnAppsSearchCompleted(const bool trigger_ptu) OVERRIDE;
+ void UpdatePTUReadyAppsCount(const uint32_t new_app_count) OVERRIDE;
+
/**
- * @brief Get state of request types for given application
- * @param policy_app_id Unique application id
- * @return request type state
- */
+ * @brief Get state of request types for given application
+ * @param policy_app_id Unique application id
+ * @return request type state
+ */
RequestType::State GetAppRequestTypesState(
const std::string& policy_app_id) const OVERRIDE;
@@ -550,33 +614,136 @@ class PolicyManagerImpl : public PolicyManager {
/**
* @brief Gets request types for application
+ * @param device_handle device identifier
* @param policy_app_id Unique application id
* @return request types of application
*/
const std::vector<std::string> GetAppRequestTypes(
+ const transport_manager::DeviceHandle& device_handle,
const std::string policy_app_id) const OVERRIDE;
/**
- * @brief Gets request subtypes for application
- * @param policy_app_id Unique application id
- * @return request subtypes of application
- */
+ * @brief Gets request subtypes for application
+ * @param policy_app_id Unique application id
+ * @return request subtypes of application
+ */
const std::vector<std::string> GetAppRequestSubTypes(
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
+ */
+ 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;
+
+ std::vector<policy_table::VehicleDataItem> GetRemovedVehicleDataItems()
+ 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
*/
- const VehicleInfo GetVehicleInfo() const OVERRIDE;
+ void GetEnabledCloudApps(
+ std::vector<std::string>& enabled_apps) const OVERRIDE;
+
+ /**
+ * @brief Get a list of enabled local applications
+ * @return enabled_apps List filled with the policy app id of each enabled
+ * local application
+ */
+ std::vector<std::string> GetEnabledLocalApps() const OVERRIDE;
+
+ bool GetAppProperties(const std::string& policy_app_id,
+ AppProperties& out_app_properties) const OVERRIDE;
+
+ /**
+ * @ brief Initialize new cloud app in the policy table
+ * @ param policy_app_id Application ID
+ */
+ void InitCloudApp(const std::string& policy_app_id) OVERRIDE;
+
+ /**
+ * @brief Enable or disable a cloud application in the HMI
+ * @param enabled Cloud app enabled state
+ */
+ void SetCloudAppEnabled(const std::string& policy_app_id,
+ const bool enabled) OVERRIDE;
+
+ /**
+ * @brief Set an app's auth token
+ * @param auth_token Cloud app authentication token
+ */
+ void SetAppAuthToken(const std::string& policy_app_id,
+ const std::string& auth_token) OVERRIDE;
+
+ /**
+ * @brief Set a cloud app's transport type
+ * @param cloud_transport_type Cloud app transport type
+ */
+ void SetAppCloudTransportType(
+ const std::string& policy_app_id,
+ const std::string& cloud_transport_type) OVERRIDE;
+
+ /**
+ * @brief Set a cloud app's endpoint url
+ * @param endpoint URL for websocket connection
+ */
+ void SetAppEndpoint(const std::string& policy_app_id,
+ const std::string& endpoint) OVERRIDE;
+
+ /**
+ * @brief Set a cloud app's nicknames
+ * @param nicknames Nicknames for cloud app
+ */
+ void SetAppNicknames(const std::string& policy_app_id,
+ const StringArray& nicknames) OVERRIDE;
+
+ /**
+ * @brief Set the user preference for how a hybrid (cloud and mobile) app
+ * should be used
+ * @param hybrid_app_preference Hybrid app user preference
+ */
+ void SetHybridAppPreference(
+ const std::string& policy_app_id,
+ const std::string& hybrid_app_preference) OVERRIDE;
+
+ /**
+ * @brief Get app service parameters from the policy table
+ * @param policy_app_id Unique application id
+ * @param app_service_parameters Pointer to struct containing all app service
+ * information
+ */
+ void GetAppServiceParameters(const std::string& policy_app_id,
+ policy_table::AppServiceParameters*
+ app_service_parameters) const OVERRIDE;
+
+ /**
+ * @brief Check if an app can send unknown rpc requests to an app service
+ * provider
+ * @param policy_app_id Unique application id
+ * @return bool true if allowed
+ */
+ bool UnknownRPCPassthroughAllowed(
+ const std::string& policy_app_id) const OVERRIDE;
/**
* @brief OnAppRegisteredOnMobile allows to handle event when application were
* succesfully registered on mobile device.
- * It will send OnAppPermissionSend notification and will try to start PTU. *
+ * It will send OnAppPermissionSend notification and will try to start PTU.
+ *
+ * @param device_id device identifier
* @param application_id registered application.
*/
- void OnAppRegisteredOnMobile(const std::string& application_id) OVERRIDE;
+ void OnAppRegisteredOnMobile(const std::string& device_id,
+ const std::string& application_id) OVERRIDE;
void OnDeviceSwitching(const std::string& device_id_from,
const std::string& device_id_to) OVERRIDE;
@@ -619,7 +786,7 @@ class PolicyManagerImpl : public PolicyManager {
* @return Pair of policy application id and application url id from the
* urls vector
*/
- AppIdURL GetNextUpdateUrl(const EndpointUrls& urls) OVERRIDE;
+ DEPRECATED AppIdURL GetNextUpdateUrl(const EndpointUrls& urls) OVERRIDE;
/**
* @brief Checks if there is existing URL in the EndpointUrls vector with
@@ -665,14 +832,11 @@ class PolicyManagerImpl : public PolicyManager {
}
/**
- * @brief Setter for send_on_update_sent_out and wrong_ptu_update_received
+ * @brief Setter for send_on_update_sent_out
* @param send_on_update_sent_out new value of this flag
- * @param wrong_ptu_update_received new value of this flag
*/
- inline void SetSendOnUpdateFlags(const bool send_on_update_sent_out,
- const bool wrong_ptu_update_received) {
+ inline void SetSendOnUpdateFlags(const bool send_on_update_sent_out) {
send_on_update_sent_out_ = send_on_update_sent_out;
- wrong_ptu_update_received_ = wrong_ptu_update_received;
}
#endif // BUILD_TESTS
@@ -709,19 +873,48 @@ class PolicyManagerImpl : public PolicyManager {
void Add(const std::string& app_id,
usage_statistics::AppStopwatchId type,
int32_t timespan_seconds) OVERRIDE;
+
// Interface StatisticsManager (end)
+ /**
+ * @brief Check whether allowed retry sequence count is exceeded
+ * @return bool value - true is allowed count is exceeded, otherwise - false
+ */
+ bool IsAllowedRetryCountExceeded() const OVERRIDE;
+
+ /**
+ * @brief Finish PTU retry requence
+ */
+ void RetrySequenceFailed() OVERRIDE;
+
+ /**
+ * @brief In EXTERNAL_PROPRIETARY_MODE PTU sequence is driven by HMI and
+ * begins with OnSystemRequest from HMI. Following function is called when
+ * this notification is received to track number of PTU retries and react
+ * accordingly once allowed retry count is exceeded
+ */
+ void OnSystemRequestReceived() OVERRIDE;
+
+ void OnLocalAppAdded() OVERRIDE;
+
+ bool IsNewApplication(const std::string& application_id) const OVERRIDE;
+
protected:
/**
* @brief Parse policy table content and convert to PT object
* @param pt_content binary content of PT
* @return pointer to converted PT
*/
- virtual utils::SharedPtr<policy_table::Table> Parse(
+ virtual std::shared_ptr<policy_table::Table> Parse(
const BinaryMessage& pt_content);
private:
/**
+ * @brief Increments PTU retry index for external flow
+ */
+ void IncrementRetryIndex();
+
+ /**
* @brief Checks if PT update should be started and schedules it if needed
*/
void CheckTriggers();
@@ -736,8 +929,19 @@ class PolicyManagerImpl : public PolicyManager {
* @return Collection per-application results
*/
CheckAppPolicyResults CheckPermissionsChanges(
- const utils::SharedPtr<policy_table::Table> update,
- const utils::SharedPtr<policy_table::Table> snapshot);
+ const std::shared_ptr<policy_table::Table> update,
+ const std::shared_ptr<policy_table::Table> snapshot);
+
+ /**
+ * @brief Compares current policies to the updated one.
+ * Trigger actions in case if certain fields after udate was changes.
+ * This function should be called after PT update.
+ * Actions require already updated policy table
+ * @param update Shared pointer to policy table udpate
+ * @param snapshot Shared pointer to old copy of policy table
+ */
+ void CheckPermissionsChangesAfterUpdate(const policy_table::Table& update,
+ const policy_table::Table& snapshot);
/**
* @brief Processes results from policy table update analysis done by
@@ -791,29 +995,26 @@ class PolicyManagerImpl : public PolicyManager {
/**
* @brief Allows to process case when added application is not present in
* policy db.
+ * @param device_id device identifier
* @param policy application id.
* @param cuuren consent for application's device.
*/
- void AddNewApplication(const std::string& application_id,
+ void AddNewApplication(const std::string& device_id,
+ const std::string& application_id,
DeviceConsent device_consent);
/**
* @brief Allows to process case when added application is already
* in policy db.
+ * @param device_id device identifier
* @param policy application id.
* @param cuuren consent for application's device.
*/
- void PromoteExistedApplication(const std::string& application_id,
+ void PromoteExistedApplication(const std::string& device_id,
+ const std::string& application_id,
DeviceConsent device_consent);
/**
- * @brief Check if certain application already in policy db.
- * @param policy application id.
- * @return true if application presents false otherwise.
- */
- bool IsNewApplication(const std::string& application_id) const;
-
- /**
* Checks existing and permissions of AppStorageFolder
* @return true if AppStorageFolder exists and has permissions read/write
*/
@@ -821,9 +1022,12 @@ class PolicyManagerImpl : public PolicyManager {
/**
* @brief Checks whether need ask the permission of users
+ * @param device_id device identifier
+ * @param appid policy application id
* @return true if user consent is needed
*/
- virtual bool IsConsentNeeded(const std::string& app_id);
+ virtual bool IsConsentNeeded(const std::string& device_id,
+ const std::string& app_id);
/**
* @brief Changes isConsentNeeded for app pending permissions, in case
@@ -860,10 +1064,15 @@ class PolicyManagerImpl : public PolicyManager {
* @param type policy table type
* @return true if policy table valid, otherwise false
*/
- bool IsPTValid(utils::SharedPtr<policy_table::Table> policy_table,
+ bool IsPTValid(std::shared_ptr<policy_table::Table> policy_table,
policy_table::PolicyTableType type) const;
/**
+ * @brief Check that new applications for PTU were registered
+ */
+ bool HasApplicationForPTU() const;
+
+ /**
* @brief Get resulting RPCs permissions for application which started on
* specific device
* @param device_id Device id
@@ -891,23 +1100,36 @@ class PolicyManagerImpl : public PolicyManager {
void SendAppPermissionsChanged(const std::string& device_id,
const std::string& application_id) OVERRIDE;
+ void SendOnAppPropertiesChangeNotification(
+ const std::string& policy_app_id) const OVERRIDE;
+
/**
- * @brief Gets all allowed module types
- * @param policy_app_id unique identifier of application
- * @param modules list of allowed module types
- * @return true if application has allowed modules
- */
+ * @brief notify listener of updated auth token for a given policy id
+ * @param policy_app_id the app id that has an updated auth token
+ */
+ void SendAuthTokenUpdated(const std::string policy_app_id);
+
+ /**
+ * @brief Gets all allowed module types
+ * @param policy_app_id unique identifier of application
+ * @param modules list of allowed module types
+ * @return true if application has allowed modules
+ */
bool GetModuleTypes(const std::string& policy_app_id,
std::vector<std::string>* modules) const OVERRIDE;
+ void ResetTimeout() OVERRIDE;
+
/**
* @brief Notify application about its permissions changes by preparing and
* sending OnPermissionsChanged notification
+ * @param device_id device identifier
* @param policy_app_id Application id to send notification to
* @param app_group_permissons Current permissions for groups assigned to
* application
*/
void NotifyPermissionsChanges(
+ const std::string& device_id,
const std::string& policy_app_id,
const std::vector<FunctionalGroupPermission>& app_group_permissions);
@@ -932,11 +1154,13 @@ class PolicyManagerImpl : public PolicyManager {
* user consents (if any) and ExternalConsent consents (if any) will be
* updated
* appropiately to current ExternalConsent status stored by policy table
+ * @param device_id device identifier
* @param application_id Application id
* @param processing_policy Defines whether consents timestamps must be
* considered or external consents take over
*/
void ProcessExternalConsentStatusForApp(
+ const std::string& device_id,
const std::string& application_id,
const ConsentProcessingPolicy processing_policy);
/**
@@ -964,16 +1188,26 @@ class PolicyManagerImpl : public PolicyManager {
/**
* @brief Notifies system by sending OnAppPermissionChanged notification
+ * @param device_id device identifier
* @param app_policy Reference to application policy
*/
- void NotifySystem(const AppPoliciesValueType& app_policy) const;
+ void NotifySystem(const std::string& device_id,
+ const AppPoliciesValueType& app_policy) const;
/**
* @brief Sends OnPermissionChange notification to application if its
* currently registered
+ * @param device_id device identifier
* @param app_policy Reference to application policy
*/
- void SendPermissionsToApp(const AppPoliciesValueType& app_policy);
+ void SendPermissionsToApp(const std::string& device_id,
+ const AppPoliciesValueType& app_policy);
+
+ /**
+ * @brief Resumes all policy actions for all apps, suspended during
+ * PTU applying
+ */
+ void ResumePendingAppPolicyActions();
/**
* @brief Gets groups names from collection of groups permissions
@@ -1017,7 +1251,7 @@ class PolicyManagerImpl : public PolicyManager {
/**
* @brief pointer to AccessRemote instance for working with RC applications
*/
- utils::SharedPtr<AccessRemote> access_remote_;
+ std::shared_ptr<AccessRemote> access_remote_;
/**
* @brief lock guard for protecting applications list access
@@ -1053,9 +1287,14 @@ class PolicyManagerImpl : public PolicyManager {
uint32_t retry_sequence_index_;
/**
+ * @brief Applications pending count ready for PTU
+ */
+ uint32_t applications_pending_ptu_count_;
+
+ /**
* @brief Lock for guarding retry sequence
*/
- sync_primitives::Lock retry_sequence_lock_;
+ mutable sync_primitives::Lock retry_sequence_lock_;
/**
* @brief Device id, which is used during PTU handling for specific
@@ -1082,19 +1321,42 @@ class PolicyManagerImpl : public PolicyManager {
friend struct ProccessAppGroups;
/**
- * @brief Flag for notifying that invalid PTU was received
- */
- bool wrong_ptu_update_received_;
-
- /**
* @brief Flag for notifying that PTU was started
*/
bool send_on_update_sent_out_;
+ std::vector<std::string> app_properties_changed_list_;
+
/**
* @brief Flag for notifying that invalid PTU should be triggered
*/
bool trigger_ptu_;
+
+ /**
+ * @brief Flag for notifying that PTU was requested
+ */
+ bool ptu_requested_;
+
+ /**
+ * @brief Flag that indicates whether a PTU sequence (including retries) is in
+ * progress
+ */
+ bool is_ptu_in_progress_;
+
+ typedef std::list<std::pair<std::string, AppPoliciesValueType> >
+ PendingAppPolicyActionsList;
+
+ /**
+ * @brief List containing device_id and pending permissions structure pairs
+ * which can be processed later on demand
+ */
+ PendingAppPolicyActionsList notify_system_list_;
+
+ /**
+ * @brief List containing device_id and pending permissions structure pairs
+ * which can be processed later on demand
+ */
+ PendingAppPolicyActionsList send_permissions_list_;
};
} // namespace policy
diff --git a/src/components/policy/policy_external/include/policy/policy_table.h b/src/components/policy/policy_external/include/policy/policy_table.h
index ecbd56c2e4..8f0d5f7efb 100644
--- a/src/components/policy/policy_external/include/policy/policy_table.h
+++ b/src/components/policy/policy_external/include/policy/policy_table.h
@@ -33,16 +33,15 @@
#ifndef SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_POLICY_TABLE_H_
#define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_POLICY_TABLE_H_
-#include "utils/shared_ptr.h"
-#include "policy/pt_representation.h"
#include "policy/pt_ext_representation.h"
+#include "policy/pt_representation.h"
namespace policy {
class PolicyTable {
public:
PolicyTable();
- explicit PolicyTable(utils::SharedPtr<PTRepresentation> pt_data);
+ explicit PolicyTable(std::shared_ptr<PTRepresentation> pt_data);
virtual ~PolicyTable();
/**
@@ -50,12 +49,12 @@ class PolicyTable {
* actual class storing policy table.
* @return PTRepresentation* Policy Table Content Handler
*/
- utils::SharedPtr<PTRepresentation> pt_data() const {
+ std::shared_ptr<PTRepresentation> pt_data() const {
return pt_data_;
}
private:
- utils::SharedPtr<PTRepresentation> pt_data_;
+ std::shared_ptr<PTRepresentation> pt_data_;
};
} // namespace policy
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 2804166f17..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,129 +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_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_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_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_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,
@@ -166,14 +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,
-};
-bool IsValidEnum(ModuleType val);
-const char* EnumToJsonString(ModuleType val);
-bool EnumFromJsonString(const std::string& literal, ModuleType* 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 b062fa0966..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,10 +50,13 @@ struct AppLevel;
struct ApplicationParams;
struct ConsentRecords;
struct DeviceParams;
+struct EndpointProperty;
struct MessageLanguages;
struct MessageString;
struct RpcParameters;
struct Rpcs;
+struct AppServiceHandledRpc;
+struct AppServiceInfo;
} // namespace policy_table_interface_base
} // namespace rpc
@@ -67,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;
@@ -104,13 +111,58 @@ typedef Array<Enum<RequestType>, 0, 255> RequestsTypeArray;
typedef Strings RequestSubTypes;
+typedef String<0, 255> AppServiceType;
+typedef String<0, 255> AppServiceName;
+typedef Array<AppServiceName, 0, 255> AppServiceNames;
+typedef Array<AppServiceHandledRpc, 0, 255> AppServiceHandledRpcs;
+typedef Map<AppServiceInfo, 0, 255> AppServiceParameters;
+typedef Integer<int32_t, 0, INT32_MAX> FunctionIDInt;
+
typedef Map<Strings, 0, 255> RemoteRpcs;
typedef Map<RemoteRpcs, 0, 255> AccessModules;
typedef Array<Enum<ModuleType>, 0, 255> ModuleTypes;
-
typedef AppHMIType AppHmiType;
typedef std::vector<AppHMIType> AppHmiTypes;
+struct AppServiceHandledRpc : CompositeType {
+ public:
+ FunctionIDInt function_id;
+
+ public:
+ AppServiceHandledRpc();
+ ~AppServiceHandledRpc();
+ AppServiceHandledRpc(const Json::Value* value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+ void ReportErrors(rpc::ValidationReport* report__) const;
+
+ private:
+ bool Validate() const;
+};
+
+struct AppServiceInfo : CompositeType {
+ public:
+ Optional<AppServiceNames> service_names;
+ AppServiceHandledRpcs handled_rpcs;
+
+ public:
+ AppServiceInfo();
+ ~AppServiceInfo();
+ AppServiceInfo(const Json::Value* value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+ void ReportErrors(rpc::ValidationReport* report__) const;
+
+ private:
+ bool Validate() const;
+};
+
struct RequestTypes : public RequestsTypeArray {
RequestTypes();
explicit RequestTypes(Json::Value* value);
@@ -177,6 +229,19 @@ struct ApplicationParams : PolicyBase {
Optional<Integer<uint16_t, 0, 65225> > memory_kb;
Optional<Integer<uint32_t, 0, UINT_MAX> > heart_beat_timeout_ms;
mutable Optional<ModuleTypes> moduleType;
+ Optional<String<0, 65535> > certificate;
+ // Cloud application params
+ Optional<Enum<HybridAppPreference> > hybrid_app_preference;
+ Optional<String<0, 255> > endpoint;
+ Optional<Boolean> enabled;
+ Optional<String<0, 65535> > auth_token;
+ Optional<String<0, 255> > cloud_transport_type;
+ Optional<String<0, 65535> > icon_url;
+
+ // App Service Params
+ Optional<AppServiceParameters> app_service_parameters;
+ Optional<Boolean> allow_unknown_rpc_passthrough;
+ Optional<Boolean> encryption_required;
public:
ApplicationParams();
@@ -271,6 +336,7 @@ struct Rpcs : CompositeType {
disallowed_by_external_consent_entities_on;
Optional<DisallowedByExternalConsentEntities>
disallowed_by_external_consent_entities_off;
+ Optional<Boolean> encryption_required;
public:
Rpcs();
@@ -288,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;
@@ -296,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;
@@ -303,6 +388,10 @@ struct ModuleConfig : CompositeType {
Optional<String<0, 10> > preloaded_date;
Optional<String<0, 65535> > certificate;
Optional<Boolean> preloaded_pt;
+ Optional<Boolean> full_app_id_supported;
+ Optional<Boolean> lock_screen_dismissal_enabled;
+
+ static const std::string kDefaultOemMappingServiceName;
public:
ModuleConfig();
@@ -312,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();
@@ -538,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;
@@ -547,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_table_interface_ext.xml b/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml
index 401a5dcb9f..af7effd97f 100644
--- a/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml
+++ b/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml
@@ -38,6 +38,7 @@
<element name="vin" />
<element name="accPedalPosition" />
<element name="beltStatus" />
+ <element name="electronicParkBrakeStatus" />
<element name="driverBraking" />
<element name="prndl" />
<element name="rpm" />
@@ -55,6 +56,7 @@
<element name="fuelRange" />
<element name="tirePressureValue" />
<element name="tpms" />
+ <element name="cloudAppVehicleID" />
</enum>
<enum name="AppHMIType">
@@ -69,6 +71,12 @@
<element name="TESTING" />
<element name="SYSTEM" />
</enum>
+
+ <enum name="HybridAppPreference">
+ <element name="MOBILE" />
+ <element name="CLOUD" />
+ <element name="BOTH" />
+ </enum>
<!-- Common parameters end -->
<!-- app_policies section start -->
@@ -91,14 +99,27 @@
<param name="memory_kb" type="Integer" minvalue="1" maxvalue="65225" mandatory="false"/>
<param name="watchdog_timer_ms" type="Integer" minvalue="1"
maxvalue="65225" mandatory="false"/>
- <param name="certificate" type="String" minlength="0" maxlength="255"
+ <param name="certificate" type="String" minlength="0" maxlength="65535"
+ mandatory="false" />
+ <param name="endpoint" type="String" minlength="0" maxlength="255" mandatory="false" />
+ <param name="enabled" type="Boolean" mandatory="false" />
+ <param name="auth_token" type="String" minlength="0" maxlength="65535"
+ mandatory="false" />
+ <param name="cloud_transport_type" type="String" minlength="0" maxlength="255"
+ mandatory="false" />
+ <param name="hybrid_app_preference" type="HybridAppPreference" mandatory="false" />
+ <param name="icon_url" type="String" minlength="0" maxlength="65535"
mandatory="false" />
+ <param name="service_name" type="String" mandatory="false" />
+ <param name="service_type" type="String" mandatory="false" />
+ <param name="handled_rpcs" array="true" mandatory="false" />
+ <param name="allow_unknown_rpc_passthrough" type="Boolean" mandatory="false" />
+ <param name="encryption_required" type="Boolean" mandatory="false"/>
</struct>
<typedef name="HmiLevels" type="HmiLevel" array="true"
maxsize="4" />
- <typedef name="Parameters" type="Parameter" array="true"
- maxsize="24" />
+ <typedef name="Parameters" type="Parameter" array="true"/>
<struct name="RpcParameters">
<!-- maxsizes are equal to number of currently known elements of
@@ -115,6 +136,7 @@
<param name="user_consent_prompt" type="String" minlegth="1"
maxlength="255" mandatory="false"/>
<param name="rpcs" type="Rpc" null_values_allowed="true"/>
+ <param name="encryption_required" type="Boolean" mandatory="false"/>
</struct>
<!-- app_policies section end -->
@@ -139,6 +161,7 @@
<struct name="ModuleConfig">
<param name="device_certificates" type="String" minlength="1" maxlength="100" mandatory="false" map="true" minsize="1" maxsize="255" />
<param name="preloaded_pt" type="Boolean" mandatory="false" />
+ <param name="full_app_id_supported" type="Boolean" mandatory="false" />
<param name="exchange_after_x_ignition_cycles" type="Integer"
maxvalue="255" />
<param name="exchange_after_x_kilometers" type="Integer"
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 9682b3d58d..7e8abd5989 100644
--- a/src/components/policy/policy_external/include/policy/policy_types.h
+++ b/src/components/policy/policy_external/include/policy/policy_types.h
@@ -34,14 +34,16 @@
#define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_POLICY_TYPES_H_
#include <algorithm>
-#include <string>
-#include <vector>
#include <map>
+#include <memory>
#include <set>
+#include <string>
#include <utility>
-#include "utils/shared_ptr.h"
-#include "utils/helpers.h"
+#include <vector>
+
+#include "policy/policy_table/types.h"
#include "transport_manager/common.h"
+#include "utils/helpers.h"
namespace policy {
@@ -73,19 +75,22 @@ enum PolicyTableStatus {
StatusUpToDate = 0,
StatusUpdatePending,
StatusUpdateRequired,
- StatusUnknown
+ StatusUnknown,
+ StatusProcessingSnapshot
};
// Code generator uses String class name, so this typedef was renamed to PTSring
typedef std::string PTString;
typedef std::vector<uint8_t> BinaryMessage;
-typedef utils::SharedPtr<BinaryMessage> BinaryMessageSptr;
+typedef std::shared_ptr<BinaryMessage> BinaryMessageSptr;
typedef std::string HMILevel;
typedef std::string Parameter;
typedef std::string RpcName;
typedef std::set<std::string> RPCParams;
+typedef rpc::Optional<rpc::Boolean> EncryptionRequired;
+
typedef std::map<std::string, std::set<policy::HMILevel> > HMIPermissions;
struct ParameterPermissions
: std::map<std::string, std::set<policy::Parameter> > {
@@ -101,6 +106,7 @@ struct ParameterPermissions
struct RpcPermissions {
HMIPermissions hmi_permissions;
ParameterPermissions parameter_permissions;
+ EncryptionRequired require_encryption;
};
typedef std::map<RpcName, RpcPermissions> Permissions;
@@ -117,11 +123,13 @@ typedef std::vector<std::string> StringArray;
enum PermitResult { kRpcAllowed = 0, kRpcDisallowed, kRpcUserDisallowed };
+enum class ResetRetryCountType { kResetWithStatusUpdate = 0, kResetInternally };
+
/**
- * @struct Stores result of check:
- * if HMI Level was allowed for RPC to work in
- * and list of parameters allowed for RPC if specified in PT.
- */
+ * @struct Stores result of check:
+ * if HMI Level was allowed for RPC to work in
+ * and list of parameters allowed for RPC if specified in PT.
+ */
struct CheckPermissionResult {
CheckPermissionResult() : hmi_level_permitted(kRpcDisallowed) {}
@@ -224,8 +232,11 @@ struct DeviceInfo {
using namespace helpers;
static const std::string bluetooth("BLUETOOTH");
static const std::string wifi("WIFI");
+ static const std::string webengine("WEBENGINE_WEBSOCKET");
if (Compare<std::string, EQ, ONE>(deviceType, bluetooth, wifi)) {
connection_type.assign("BTMAC");
+ } else if (Compare<std::string, EQ, ONE>(deviceType, webengine)) {
+ connection_type.assign("");
}
}
};
@@ -444,11 +455,13 @@ struct ApplicationPolicyActions {
ApplicationPolicyActions()
: is_notify_system(false)
, is_send_permissions_to_app(false)
- , is_consent_needed(false) {}
+ , is_consent_needed(false)
+ , app_properties_changed(false) {}
bool is_notify_system;
bool is_send_permissions_to_app;
bool is_consent_needed;
+ bool app_properties_changed;
};
/**
@@ -504,10 +517,12 @@ 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
+ RESULT_REQUEST_SUBTYPE_CHANGED,
+ RESULT_ENCRYPTION_REQUIRED_FLAG_CHANGED,
+ RESULT_APP_PROPERTIES_CHANGED
};
/**
@@ -530,6 +545,68 @@ enum ConsentPriorityType { kUserConsentPrio, kExternalConsentPrio };
*/
enum ConsentProcessingPolicy { kTimestampBased, kExternalConsentBased };
+/**
+ * @brief The AppProperties struct contains application properties
+ */
+struct AppProperties {
+ AppProperties()
+ : endpoint()
+ , certificate()
+ , enabled(false)
+ , auth_token()
+ , transport_type()
+ , hybrid_app_preference() {}
+
+ AppProperties(std::string endpoint,
+ std::string certificate,
+ bool enabled,
+ std::string auth_token,
+ std::string transport_type,
+ std::string hybrid_app_preference)
+ : endpoint(endpoint)
+ , certificate(certificate)
+ , enabled(enabled)
+ , auth_token(auth_token)
+ , transport_type(transport_type)
+ , hybrid_app_preference(hybrid_app_preference) {}
+
+ /**
+ * @brief endpoint Filled with the endpoint used to connect to the cloud
+ * application.
+ * @note should be absent for local applications
+ */
+ std::string endpoint;
+
+ /**
+ * @brief certificate Filled with the certificate used for creation
+ * of a secure connection to the cloud application
+ */
+ std::string certificate;
+
+ /**
+ * @brief enabled Whether or not the app is enabled
+ */
+ bool enabled;
+
+ /**
+ * @brief auth_token Filled with the token used for authentication when
+ * reconnecting to the cloud app
+ */
+ std::string auth_token;
+
+ /**
+ * @brief transport_type Filled with the transport type used by the
+ * cloud/local application (ex. "WSS")
+ */
+ std::string transport_type;
+
+ /**
+ * @brief hybrid_app_preference Filled with the hybrid app preference for the
+ * application set by the user
+ */
+ std::string hybrid_app_preference;
+};
+
} // namespace policy
#endif // SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_POLICY_TYPES_H_
diff --git a/src/components/policy/policy_external/include/policy/pt_ext_representation.h b/src/components/policy/policy_external/include/policy/pt_ext_representation.h
index 0aa284b707..f03947268a 100644
--- a/src/components/policy/policy_external/include/policy/pt_ext_representation.h
+++ b/src/components/policy/policy_external/include/policy/pt_ext_representation.h
@@ -280,10 +280,10 @@ class PTExtRepresentation : public virtual PTRepresentation {
virtual bool GetFunctionalGroupNames(policy::FunctionalGroupNames& names) = 0;
/**
- * @brief Set app policy to pre_DataConsented policy
- * @param app_id Policy ID of application to be changed
- * @return true, if succeeded, otherwise - false
- */
+ * @brief Set app policy to pre_DataConsented policy
+ * @param app_id Policy ID of application to be changed
+ * @return true, if succeeded, otherwise - false
+ */
virtual bool SetPredataPolicy(const std::string& app_id) = 0;
/**
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 66a9218771..459b689393 100644
--- a/src/components/policy/policy_external/include/policy/pt_representation.h
+++ b/src/components/policy/policy_external/include/policy/pt_representation.h
@@ -33,11 +33,11 @@
#ifndef SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_PT_REPRESENTATION_H_
#define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_PT_REPRESENTATION_H_
-#include <vector>
#include <string>
-#include "policy/policy_types.h"
-#include "policy/policy_table/types.h"
+#include <vector>
#include "policy/policy_settings.h"
+#include "policy/policy_table/types.h"
+#include "policy/policy_types.h"
namespace policy_table = rpc::policy_table_interface_base;
@@ -71,14 +71,6 @@ class PTRepresentation {
virtual bool IsPTPreloaded() = 0;
/**
- * @brief GetLockScreenIcon allows to obtain lock screen icon url;
- *
- * @return url which point to the resourse where lock screen icon could be
- *obtained.
- */
- virtual std::string GetLockScreenIconUrl() const = 0;
-
- /**
* @brief Re-creates schema in DB, drops all data
* @return true, if succedeed, otherwise - false
*/
@@ -134,11 +126,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.
@@ -213,7 +200,7 @@ class PTRepresentation {
* device_info, statistics, excluding user messages
* @return Generated structure for obtaining Json string.
*/
- virtual utils::SharedPtr<policy_table::Table> GenerateSnapshot() const = 0;
+ virtual std::shared_ptr<policy_table::Table> GenerateSnapshot() const = 0;
virtual bool Save(const policy_table::Table& table) = 0;
@@ -268,10 +255,10 @@ class PTRepresentation {
virtual bool IsDefaultPolicy(const std::string& app_id) const = 0;
/**
- * Checks if the application has pre_data policy
- * @param app_id application id
- * @return true if application has pre_data policy
- */
+ * Checks if the application has pre_data policy
+ * @param app_id application id
+ * @return true if application has pre_data policy
+ */
virtual bool IsPredataPolicy(const std::string& app_id) const = 0;
/**
diff --git a/src/components/policy/policy_external/include/policy/ptu_retry_handler.h b/src/components/policy/policy_external/include/policy/ptu_retry_handler.h
new file mode 100644
index 0000000000..79623124e3
--- /dev/null
+++ b/src/components/policy/policy_external/include/policy/ptu_retry_handler.h
@@ -0,0 +1,57 @@
+/*
+ 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.
+ */
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICIES_PTU_RETRY_HANDLER_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICIES_PTU_RETRY_HANDLER_H_
+
+namespace policy {
+
+class PTURetryHandler {
+ public:
+ /**
+ * @brief Check whether allowed retry sequence count is exceeded
+ * @return bool value - true is allowed count is exceeded, otherwise - false
+ */
+ virtual bool IsAllowedRetryCountExceeded() const = 0;
+
+ /**
+ * @brief Begins new retry sequence
+ */
+ virtual void OnSystemRequestReceived() = 0;
+
+ /**
+ * @brief Handle OnSystemRequest from HMI timeout
+ */
+ virtual void RetrySequenceFailed() = 0;
+};
+} // namespace policy
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICIES_PTU_RETRY_HANDLER_H_
diff --git a/src/components/policy/policy_external/include/policy/sql_pt_ext_representation.h b/src/components/policy/policy_external/include/policy/sql_pt_ext_representation.h
index bd2097cfe3..889ede9d20 100644
--- a/src/components/policy/policy_external/include/policy/sql_pt_ext_representation.h
+++ b/src/components/policy/policy_external/include/policy/sql_pt_ext_representation.h
@@ -34,8 +34,8 @@
#define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_SQL_PT_EXT_REPRESENTATION_H_
#include <string>
-#include "policy/sql_pt_representation.h"
#include "policy/pt_ext_representation.h"
+#include "policy/sql_pt_representation.h"
namespace policy {
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 646cc7663b..8a3ad1f7df 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
@@ -49,7 +49,6 @@ extern const std::string kSelectPreloaded;
extern const std::string kIsFirstRun;
extern const std::string kSetNotFirstRun;
extern const std::string kSelectEndpoint;
-extern const std::string kSelectLockScreenIcon;
extern const std::string kSelectModuleConfig;
extern const std::string kSelectEndpoints;
extern const std::string kSelectNotificationsPerMin;
@@ -66,6 +65,9 @@ extern const std::string kSelectNicknames;
extern const std::string kSelectAppTypes;
extern const std::string kSelectRequestTypes;
extern const std::string kSelectRequestSubTypes;
+extern const std::string kSelectAppServiceTypes;
+extern const std::string kSelectAppServiceNames;
+extern const std::string kSelectAppServiceHandledRpcs;
extern const std::string kSelectSecondsBetweenRetries;
extern const std::string kSelectIgnitionCycles;
extern const std::string kSelectKilometers;
@@ -79,9 +81,10 @@ extern const std::string kInsertAppGroup;
extern const std::string kInsertNickname;
extern const std::string kInsertAppType;
extern const std::string kInsertRequestType;
-extern const std::string kInsertOmittedRequestType;
-extern const std::string kInsertOmittedRequestSubType;
extern const std::string kInsertRequestSubType;
+extern const std::string kInsertAppServiceTypes;
+extern const std::string kInsertAppServiceNames;
+extern const std::string kInsertAppServiceHandledRpcs;
extern const std::string kInsertMessageType;
extern const std::string kInsertLanguage;
extern const std::string kInsertMessageString;
@@ -103,6 +106,9 @@ extern const std::string kDeleteAppGroup;
extern const std::string kDeleteApplication;
extern const std::string kDeleteRequestType;
extern const std::string kDeleteRequestSubType;
+extern const std::string kDeleteAppServiceTypes;
+extern const std::string kDeleteAppServiceNames;
+extern const std::string kDeleteAppServiceHandledRpcs;
extern const std::string kDeleteDevice;
extern const std::string kIncrementIgnitionCycles;
extern const std::string kResetIgnitionCycles;
@@ -135,6 +141,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 d56f6aeba2..574806b3fb 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
@@ -35,15 +35,16 @@
#include <string>
#include <vector>
+#include "policy/policy_table/types.h"
#include "policy/pt_representation.h"
#include "rpc_base/rpc_base.h"
-#include "policy/policy_table/types.h"
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);
@@ -85,7 +84,7 @@ class SQLPTRepresentation : public virtual PTRepresentation {
bool Clear();
bool Drop();
virtual void WriteDb();
- virtual utils::SharedPtr<policy_table::Table> GenerateSnapshot() const;
+ virtual std::shared_ptr<policy_table::Table> GenerateSnapshot() const;
virtual bool Save(const policy_table::Table& table);
bool GetInitialAppData(const std::string& app_id,
StringArray* nicknames = NULL,
@@ -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;
@@ -134,6 +136,9 @@ class SQLPTRepresentation : public virtual PTRepresentation {
bool GatherRequestSubType(
const std::string& app_id,
policy_table::RequestSubTypes* request_subtypes) const;
+ bool GatherAppServiceParameters(
+ const std::string& app_id,
+ policy_table::AppServiceParameters* app_service_parameters) const;
bool GatherNickName(const std::string& app_id,
policy_table::Strings* nicknames) const;
@@ -156,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,
@@ -172,9 +180,11 @@ class SQLPTRepresentation : public virtual PTRepresentation {
bool SaveRequestSubType(
const std::string& app_id,
const policy_table::RequestSubTypes& request_subtypes);
+ bool SaveAppServiceParameters(
+ const std::string& app_id,
+ const policy_table::AppServiceParameters& app_service_parameters);
public:
- virtual std::string GetLockScreenIconUrl() const;
bool UpdateRequired() const;
void SaveUpdateRequired(bool value);
@@ -197,6 +207,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_;
@@ -214,12 +244,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/include/policy/status.h b/src/components/policy/policy_external/include/policy/status.h
index 18789ecf99..f51888c853 100644
--- a/src/components/policy/policy_external/include/policy/status.h
+++ b/src/components/policy/policy_external/include/policy/status.h
@@ -52,6 +52,7 @@ enum UpdateEvent {
kOnResetPolicyTableRequireUpdate,
kOnResetPolicyTableNoUpdate,
kScheduleUpdate,
+ kPendingUpdate,
kScheduleManualUpdate,
kOnResetRetrySequence,
kNoEvent
@@ -75,41 +76,41 @@ class Status {
const policy::PolicyTableStatus enum_status);
/**
- * @brief Destructor
- */
+ * @brief Destructor
+ */
virtual ~Status();
/**
- * @brief Process event by setting next status in case event can affect
- * current status or ignores the event
- * @param manager Status manager pointer
- * @param event Event which needs to be processed
- */
+ * @brief Process event by setting next status in case event can affect
+ * current status or ignores the event
+ * @param manager Status manager pointer
+ * @param event Event which needs to be processed
+ */
virtual void ProcessEvent(UpdateStatusManager* manager,
UpdateEvent event) = 0;
/**
- * @brief Return current status as string value
- * @return Status as string
- */
+ * @brief Return current status as string value
+ * @return Status as string
+ */
const std::string get_status_string() const;
/**
- * @brief Return status as enum value
- * @return Status as enum value
- */
+ * @brief Return status as enum value
+ * @return Status as enum value
+ */
PolicyTableStatus get_status() const;
/**
- * @brief Check whether update is required in terms of status
- * @return True if update is required, otherwise - false
- */
+ * @brief Check whether update is required in terms of status
+ * @return True if update is required, otherwise - false
+ */
virtual bool IsUpdateRequired() const;
/**
- * @brief Check whether update is pending in terms of status
- * @return True if update is pending, otherwise - false
- */
+ * @brief Check whether update is pending in terms of status
+ * @return True if update is pending, otherwise - false
+ */
virtual bool IsUpdatePending() const;
private:
@@ -128,11 +129,11 @@ class UpToDateStatus : public Status {
UpToDateStatus();
/**
- * @brief Process event by setting next status in case event can affect
- * current status or ignores the event
- * @param manager Status manager pointer
- * @param event Event which needs to be processed
- */
+ * @brief Process event by setting next status in case event can affect
+ * current status or ignores the event
+ * @param manager Status manager pointer
+ * @param event Event which needs to be processed
+ */
void ProcessEvent(UpdateStatusManager* manager, UpdateEvent event) OVERRIDE;
};
@@ -147,18 +148,50 @@ class UpdateNeededStatus : public Status {
UpdateNeededStatus();
/**
- * @brief Process event by setting next status in case event can affect
- * current status or ignores the event
- * @param manager Status manager pointer
- * @param event Event which needs to be processed
- */
+ * @brief Process event by setting next status in case event can affect
+ * current status or ignores the event
+ * @param manager Status manager pointer
+ * @param event Event which needs to be processed
+ */
void ProcessEvent(UpdateStatusManager* manager, UpdateEvent event) OVERRIDE;
/**
- * @brief Check whether update is required in terms of status
- * @return True if update is required, otherwise - false
+ * @brief Check whether update is required in terms of status
+ * @return True if update is required, otherwise - false
+ */
+ bool IsUpdateRequired() const OVERRIDE;
+};
+
+/**
+ * @brief The UpdatePendingStatus class represents cases when SDL knows that an
+ * update is required and but before the snapshot is sent to the HMI
*/
+class UpdatePendingStatus : public Status {
+ public:
+ /**
+ * @brief Constructor
+ */
+ UpdatePendingStatus();
+
+ /**
+ * @brief Process event by setting next status in case event can affect
+ * current status or ignores the event
+ * @param manager Status manager pointer
+ * @param event Event which needs to be processed
+ */
+ void ProcessEvent(UpdateStatusManager* manager, UpdateEvent event) OVERRIDE;
+
+ /**
+ * @brief Check whether update is required in terms of status
+ * @return True if update is required, otherwise - false
+ */
bool IsUpdateRequired() const OVERRIDE;
+
+ /**
+ * @brief Check whether update is pending in terms of status
+ * @return True if update is pending, otherwise - false
+ */
+ bool IsUpdatePending() const OVERRIDE;
};
/**
@@ -172,25 +205,25 @@ class UpdatingStatus : public Status {
UpdatingStatus();
/**
- * @brief Process event by setting next status in case event can affect
- * current status or ignores the event
- * @param manager Status manager pointer
- * @param event Event which needs to be processed
- */
+ * @brief Process event by setting next status in case event can affect
+ * current status or ignores the event
+ * @param manager Status manager pointer
+ * @param event Event which needs to be processed
+ */
void ProcessEvent(UpdateStatusManager* manager, UpdateEvent event) OVERRIDE;
/**
- * @brief Check whether update is required in terms of status
- * @return True if update is required, otherwise - false
- */
+ * @brief Check whether update is required in terms of status
+ * @return True if update is required, otherwise - false
+ */
bool IsUpdateRequired() const OVERRIDE;
/**
- * @brief Check whether update is pending in terms of status
- * @return True if update is pending, otherwise - false
- */
+ * @brief Check whether update is pending in terms of status
+ * @return True if update is pending, otherwise - false
+ */
bool IsUpdatePending() const OVERRIDE;
};
-}
+} // namespace policy
#endif // SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_STATUS_H_
diff --git a/src/components/policy/policy_external/include/policy/update_status_manager.h b/src/components/policy/policy_external/include/policy/update_status_manager.h
index b663610a5b..018bab7f99 100644
--- a/src/components/policy/policy_external/include/policy/update_status_manager.h
+++ b/src/components/policy/policy_external/include/policy/update_status_manager.h
@@ -34,14 +34,13 @@
#define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_UPDATE_STATUS_MANAGER_H_
#include "policy/policy_types.h"
-#include "utils/lock.h"
-#include "utils/threads/thread.h"
-#include "utils/threads/thread_delegate.h"
+#include "policy/status.h"
#include "utils/conditional_variable.h"
#include "utils/lock.h"
#include "utils/logger.h"
#include "utils/macro.h"
-#include "policy/status.h"
+#include "utils/threads/thread.h"
+#include "utils/threads/thread_delegate.h"
namespace policy {
@@ -66,14 +65,14 @@ class UpdateStatusManager {
* @brief Set next status during event processing
* @param status Status shared pointer
*/
- void SetNextStatus(utils::SharedPtr<Status> status);
+ void SetNextStatus(std::shared_ptr<Status> status);
/**
* @brief Set postponed status (will be set after next status) during event
* processing
* @param status Status shared pointer
*/
- void SetPostponedStatus(utils::SharedPtr<Status> status);
+ void SetPostponedStatus(std::shared_ptr<Status> status);
/**
* @brief Sets listener pointer
@@ -93,6 +92,12 @@ class UpdateStatusManager {
void OnUpdateTimeoutOccurs();
/**
+ * @brief Update status for next in queue application
+ * after previous update been has finished
+ */
+ void OnUpdateForNextInQueue();
+
+ /**
* @brief Update status handler for valid PTU receiving
*/
void OnValidUpdateReceived();
@@ -114,15 +119,15 @@ class UpdateStatusManager {
void OnResetRetrySequence();
/**
- * @brief Update status handler on new application registering
+ * @brief Update status handler on existed application registering
+ * @param is_update_required Update necessity flag
*/
- void OnNewApplicationAdded(const DeviceConsent consent);
+ void OnExistedApplicationAdded(const bool is_update_required);
/**
- * @brief Update status handler for policy initialization
- * @param is_update_required Update necessity flag
+ * @brief Update status handler on new application registering
*/
- void OnPolicyInit(bool is_update_required);
+ void OnNewApplicationAdded(const DeviceConsent consent);
/**
* @brief In case application from non-consented device has been registered
@@ -151,6 +156,12 @@ class UpdateStatusManager {
void ScheduleUpdate();
/**
+ * @brief PendingUpdate will change state from Update_Needed
+ * to Update_Pending
+ */
+ void PendingUpdate();
+
+ /**
* @brief ScheduleUpdate allows to schedule next update.
* It will change state to Update_Needed, that's is
* and will not send any notifications about updating to HMI
@@ -180,6 +191,8 @@ class UpdateStatusManager {
*/
bool IsAppsSearchInProgress();
+ void ResetTimeout(uint32_t update_timeout);
+
#ifdef BUILD_TESTS
PolicyTableStatus GetLastUpdateStatus() const {
return current_status_->get_status();
@@ -199,22 +212,23 @@ class UpdateStatusManager {
/**
* @brief Current update status
*/
- utils::SharedPtr<Status> current_status_;
+ std::shared_ptr<Status> current_status_;
/**
* @brief Next status after current to be set
*/
- utils::SharedPtr<Status> next_status_;
+ std::shared_ptr<Status> next_status_;
/**
* @brief Status to be set after 'next' status
*/
- utils::SharedPtr<Status> postponed_status_;
+ std::shared_ptr<Status> postponed_status_;
sync_primitives::Lock status_lock_;
UpdateEvent last_processed_event_;
bool apps_search_in_progress_;
bool app_registered_from_non_consented_device_;
+ bool last_update_was_failed_;
sync_primitives::Lock apps_search_in_progress_lock_;
class UpdateThreadDelegate : public threads::ThreadDelegate {
@@ -227,7 +241,7 @@ class UpdateStatusManager {
volatile uint32_t timeout_;
volatile bool stop_flag_;
- sync_primitives::Lock state_lock_;
+ sync_primitives::RecursiveLock state_lock_;
sync_primitives::ConditionalVariable termination_condition_;
UpdateStatusManager* update_status_manager_;
};
@@ -235,6 +249,6 @@ class UpdateStatusManager {
UpdateThreadDelegate* update_status_thread_delegate_;
threads::Thread* thread_;
};
-}
+} // namespace policy
#endif // SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_UPDATE_STATUS_MANAGER_H_
diff --git a/src/components/policy/policy_external/include/policy/usage_statistics/counter.h b/src/components/policy/policy_external/include/policy/usage_statistics/counter.h
index adaef0eb28..047a545150 100644
--- a/src/components/policy/policy_external/include/policy/usage_statistics/counter.h
+++ b/src/components/policy/policy_external/include/policy/usage_statistics/counter.h
@@ -34,11 +34,11 @@
#define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_USAGE_STATISTICS_COUNTER_H_
#include <ctime>
-#include "policy/usage_statistics/statistics_manager.h"
#include "policy/usage_statistics/app_stopwatch.h"
-#include "utils/shared_ptr.h"
-#include "utils/timer.h"
+#include "policy/usage_statistics/statistics_manager.h"
+
#include "utils/macro.h"
+#include "utils/timer.h"
namespace usage_statistics {
@@ -46,18 +46,18 @@ using timer::Timer;
class GlobalCounter {
public:
- GlobalCounter(utils::SharedPtr<StatisticsManager> statistics_manager,
+ GlobalCounter(std::shared_ptr<StatisticsManager> statistics_manager,
GlobalCounterId counter_type);
void operator++() const;
private:
GlobalCounterId counter_type_;
- utils::SharedPtr<StatisticsManager> statistics_manager_;
+ std::shared_ptr<StatisticsManager> statistics_manager_;
};
class AppCounter {
public:
- AppCounter(utils::SharedPtr<StatisticsManager> statistics_manager,
+ AppCounter(std::shared_ptr<StatisticsManager> statistics_manager,
const std::string& app_id,
AppCounterId counter_type);
void operator++() const;
@@ -65,12 +65,12 @@ class AppCounter {
private:
std::string app_id_;
AppCounterId counter_type_;
- utils::SharedPtr<StatisticsManager> statistics_manager_;
+ std::shared_ptr<StatisticsManager> statistics_manager_;
};
class AppInfo {
public:
- AppInfo(utils::SharedPtr<StatisticsManager> statistics_manager,
+ AppInfo(std::shared_ptr<StatisticsManager> statistics_manager,
const std::string& app_id,
AppInfoId info_type);
void Update(const std::string& new_info) const;
@@ -78,14 +78,14 @@ class AppInfo {
private:
std::string app_id_;
AppInfoId info_type_;
- utils::SharedPtr<StatisticsManager> statistics_manager_;
+ std::shared_ptr<StatisticsManager> statistics_manager_;
};
class AppStopwatchImpl : public AppStopwatch {
public:
- AppStopwatchImpl(utils::SharedPtr<StatisticsManager> statistics_manager,
+ AppStopwatchImpl(std::shared_ptr<StatisticsManager> statistics_manager,
const std::string& app_id);
- AppStopwatchImpl(utils::SharedPtr<StatisticsManager> statistics_manager,
+ AppStopwatchImpl(std::shared_ptr<StatisticsManager> statistics_manager,
const std::string& app_id,
std::uint32_t timeout);
~AppStopwatchImpl();
@@ -97,7 +97,7 @@ class AppStopwatchImpl : public AppStopwatch {
// Fields
std::string app_id_;
AppStopwatchId stopwatch_type_;
- utils::SharedPtr<StatisticsManager> statistics_manager_;
+ std::shared_ptr<StatisticsManager> statistics_manager_;
timer::Timer timer_;
const std::uint32_t time_out_;
DISALLOW_COPY_AND_ASSIGN(AppStopwatchImpl);
diff --git a/src/components/policy/policy_external/src/access_remote_impl.cc b/src/components/policy/policy_external/src/access_remote_impl.cc
index d042d8c402..26c8c5e38e 100644
--- a/src/components/policy/policy_external/src/access_remote_impl.cc
+++ b/src/components/policy/policy_external/src/access_remote_impl.cc
@@ -89,7 +89,7 @@ struct ToModuleType {
AccessRemoteImpl::AccessRemoteImpl() : cache_(new CacheManager()) {}
-AccessRemoteImpl::AccessRemoteImpl(utils::SharedPtr<CacheManager> cache)
+AccessRemoteImpl::AccessRemoteImpl(std::shared_ptr<CacheManager> cache)
: cache_(cache) {}
bool AccessRemoteImpl::CheckModuleType(const PTString& app_id,
diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc
index 00bb1e4a1c..d8819b6bad 100644
--- a/src/components/policy/policy_external/src/cache_manager.cc
+++ b/src/components/policy/policy_external/src/cache_manager.cc
@@ -33,27 +33,27 @@
#include "policy/cache_manager.h"
#include <algorithm>
-#include <functional>
-#include <ctime>
+#include <boost/algorithm/string.hpp>
#include <cmath>
-#include <utility>
+#include <ctime>
+#include <functional>
#include <string>
+#include <utility>
#include <vector>
-#include "utils/file_system.h"
-#include "utils/helpers.h"
-#include "json/reader.h"
-#include "json/features.h"
#include "json/writer.h"
-#include "utils/logger.h"
+#include "policy/policy_helper.h"
+#include "policy/policy_table/enums.h"
+#include "policy/sql_pt_ext_representation.h"
+#include "rpc_base/rpc_base.h"
#include "utils/date_time.h"
+#include "utils/file_system.h"
#include "utils/gen_hash.h"
+#include "utils/helpers.h"
+#include "utils/jsoncpp_reader_wrapper.h"
+#include "utils/logger.h"
#include "utils/threads/thread.h"
#include "utils/threads/thread_delegate.h"
-#include "rpc_base/rpc_base.h"
-#include "policy/policy_table/enums.h"
-#include "policy/policy_helper.h"
-#include "policy/sql_pt_ext_representation.h"
namespace policy_table = rpc::policy_table_interface_base;
@@ -207,6 +207,21 @@ struct ExternalConsentConsentGroupAppender
}
};
+struct DefaultPolicyUpdater {
+ DefaultPolicyUpdater(const policy_table::ApplicationParams& default_params)
+ : default_params_(default_params) {}
+
+ void operator()(policy_table::ApplicationPolicies::value_type& pt_value) {
+ if (policy::kDefaultId == pt_value.second.get_string()) {
+ pt_value.second = default_params_;
+ pt_value.second.set_to_string(policy::kDefaultId);
+ }
+ }
+
+ private:
+ const policy_table::ApplicationParams& default_params_;
+};
+
} // namespace
namespace policy {
@@ -254,7 +269,7 @@ CacheManager::CacheManager()
, pt_(new policy_table::Table)
, backup_(new SQLPTExtRepresentation())
, update_required(false)
- , cache_lock_(true) {
+ , removed_custom_vd_items_() {
InitBackupThread();
}
@@ -262,8 +277,7 @@ CacheManager::CacheManager(bool in_memory)
: CacheManagerInterface()
, pt_(new policy_table::Table)
, backup_(new SQLPTExtRepresentation(in_memory))
- , update_required(false)
- , cache_lock_(true) {
+ , update_required(false) {
InitBackupThread();
}
@@ -312,6 +326,20 @@ const policy_table::Strings& CacheManager::GetGroups(const PTString& app_id) {
return pt_->policy_table.app_policies_section.apps[app_id].groups;
}
+const policy_table::Strings CacheManager::GetPolicyAppIDs() const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
+
+ const auto apps = pt_->policy_table.app_policies_section.apps;
+
+ policy_table::Strings policy_app_ids;
+ for (const auto& app : apps) {
+ policy_app_ids.push_back(app.first);
+ }
+
+ return policy_app_ids;
+}
+
bool CacheManager::CanAppKeepContext(const std::string& app_id) const {
CACHE_MANAGER_CHECK(false);
sync_primitives::AutoLock auto_lock(cache_lock_);
@@ -683,6 +711,13 @@ void CacheManager::ProcessUpdate(
initial_policy_iter->second;
*(pt_->policy_table.app_policies_section.apps[app_id].RequestType) =
merged_pt_request_types;
+
+ if (app_id == kDefaultId) {
+ std::for_each(pt_->policy_table.app_policies_section.apps.begin(),
+ pt_->policy_table.app_policies_section.apps.end(),
+ DefaultPolicyUpdater(
+ pt_->policy_table.app_policies_section.apps[app_id]));
+ }
}
bool CacheManager::ApplyUpdate(const policy_table::Table& update_pt) {
@@ -718,6 +753,38 @@ 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()) {
+ policy_table::VehicleDataItems custom_items_before_apply;
+ if (pt_->policy_table.vehicle_data->schema_items.is_initialized()) {
+ custom_items_before_apply =
+ CollectCustomVDItems(*pt_->policy_table.vehicle_data->schema_items);
+ }
+
+ 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);
+ }
+
+ policy_table::VehicleDataItems custom_items_after_apply =
+ *pt_->policy_table.vehicle_data->schema_items;
+ const auto& items_diff = CalculateCustomVdItemsDiff(
+ custom_items_before_apply, custom_items_after_apply);
+ SetRemovedCustomVdItems(items_diff);
+ }
+
ResetCalculatedPermissions();
Backup();
@@ -728,6 +795,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_);
@@ -884,9 +966,9 @@ bool CacheManager::HasDeviceSpecifiedConsent(const std::string& device_id,
return false;
}
const std::string consent = is_allowed ? "allowed" : "disallowed";
- LOG4CXX_INFO(logger_,
- "DeviceGetDeviceGroupsFromPolicies is already " << consent
- << ".");
+ LOG4CXX_INFO(
+ logger_,
+ "DeviceGetDeviceGroupsFromPolicies is already " << consent << ".");
return true;
}
@@ -1119,8 +1201,8 @@ bool CacheManager::SetUserPermissionsForApp(
it_group->second != is_allowed) {
*out_app_permissions_changed = true;
- const TimevalStruct tm = date_time::DateTime::getCurrentTime();
- int64_t current_time_msec = date_time::DateTime::getmSecs(tm);
+ const date_time::TimeDuration tm = date_time::getCurrentTime();
+ int64_t current_time_msec = date_time::getmSecs(tm);
ucr.consent_last_updated = current_time_msec;
LOG4CXX_DEBUG(logger_, "Updating consents time " << current_time_msec);
}
@@ -1197,14 +1279,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));
}
}
}
@@ -1333,7 +1409,7 @@ int CacheManager::TimeoutResponse() {
CACHE_MANAGER_CHECK(0);
sync_primitives::AutoLock auto_lock(cache_lock_);
return pt_->policy_table.module_config.timeout_after_x_seconds *
- date_time::DateTime::MILLISECONDS_IN_SECOND;
+ date_time::MILLISECONDS_IN_SECOND;
}
bool CacheManager::SecondsBetweenRetries(std::vector<int>& seconds) {
@@ -1353,26 +1429,259 @@ 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_);
+
+ 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>();
+}
+
+std::vector<policy_table::VehicleDataItem>
+CacheManager::GetRemovedVehicleDataItems() const {
+ CACHE_MANAGER_CHECK(std::vector<policy_table::VehicleDataItem>());
+ return removed_custom_vd_items_;
+}
+
+Json::Value CacheManager::GetPolicyTableData() const {
+ return pt_->policy_table.ToJsonValue();
+}
+
+void CacheManager::GetEnabledCloudApps(
+ std::vector<std::string>& enabled_apps) const {
+#if !defined(CLOUD_APP_WEBSOCKET_TRANSPORT_SUPPORT)
+ enabled_apps.clear();
+ return;
+#else
+ const policy_table::ApplicationPolicies& policies =
+ pt_->policy_table.app_policies_section.apps;
+ for (policy_table::ApplicationPolicies::const_iterator it = policies.begin();
+ it != policies.end();
+ ++it) {
+ auto app_policy = (*it).second;
+ if (app_policy.enabled.is_initialized() && *app_policy.enabled) {
+ enabled_apps.push_back((*it).first);
+ }
+ }
+#endif // CLOUD_APP_WEBSOCKET_TRANSPORT_SUPPORT
+}
+
+bool CacheManager::GetAppProperties(const std::string& policy_app_id,
+ AppProperties& out_app_properties) const {
+ const policy_table::ApplicationPolicies& policies =
+ pt_->policy_table.app_policies_section.apps;
+ policy_table::ApplicationPolicies::const_iterator policy_iter =
+ policies.find(policy_app_id);
+ if (policies.end() != policy_iter) {
+ auto app_policy = (*policy_iter).second;
+ out_app_properties.endpoint = app_policy.endpoint.is_initialized()
+ ? *app_policy.endpoint
+ : std::string();
+ out_app_properties.auth_token = app_policy.auth_token.is_initialized()
+ ? *app_policy.auth_token
+ : std::string();
+ out_app_properties.transport_type =
+ app_policy.cloud_transport_type.is_initialized()
+ ? *app_policy.cloud_transport_type
+ : std::string();
+ out_app_properties.certificate = app_policy.certificate.is_initialized()
+ ? *app_policy.certificate
+ : std::string();
+ out_app_properties.hybrid_app_preference =
+ app_policy.hybrid_app_preference.is_initialized()
+ ? EnumToJsonString(*app_policy.hybrid_app_preference)
+ : std::string();
+ out_app_properties.enabled =
+ app_policy.enabled.is_initialized() && *app_policy.enabled;
+ return true;
+ }
+ return false;
+}
+
+std::vector<std::string> CacheManager::GetEnabledLocalApps() const {
+#if !defined(WEBSOCKET_SERVER_TRANSPORT_SUPPORT)
+ return std::vector<std::string>();
+#else
+ std::vector<std::string> enabled_apps;
+ const policy_table::ApplicationPolicies& app_policies =
+ pt_->policy_table.app_policies_section.apps;
+ for (const auto& app_policies_item : app_policies) {
+ const auto app_policy = app_policies_item.second;
+ // Local (WebEngine) applications
+ // should not have "endpoint" field
+ if (app_policy.endpoint.is_initialized()) {
+ continue;
+ }
+ if (app_policy.enabled.is_initialized() && *app_policy.enabled) {
+ enabled_apps.push_back(app_policies_item.first);
+ }
+ }
+ return enabled_apps;
+#endif // WEBSOCKET_SERVER_TRANSPORT_SUPPORT
+}
+
+void CacheManager::InitCloudApp(const std::string& policy_app_id) {
+ CACHE_MANAGER_CHECK_VOID();
+ sync_primitives::AutoLock auto_lock(cache_lock_);
+
+ policy_table::ApplicationPolicies& policies =
+ pt_->policy_table.app_policies_section.apps;
+ policy_table::ApplicationPolicies::const_iterator default_iter =
+ policies.find(kDefaultId);
+ policy_table::ApplicationPolicies::const_iterator app_iter =
+ policies.find(policy_app_id);
+ if (default_iter != policies.end()) {
+ if (app_iter == policies.end()) {
+ policies[policy_app_id] = policies[kDefaultId];
+ }
+ }
+ // Add cloud app specific policies
+ Backup();
+}
+
+void CacheManager::SetCloudAppEnabled(const std::string& policy_app_id,
+ const bool enabled) {
+ policy_table::ApplicationPolicies& policies =
+ pt_->policy_table.app_policies_section.apps;
+ policy_table::ApplicationPolicies::iterator policy_iter =
+ policies.find(policy_app_id);
+ if (policies.end() != policy_iter) {
+ *(*policy_iter).second.enabled = enabled;
+ }
+}
+
+void CacheManager::SetAppAuthToken(const std::string& policy_app_id,
+ const std::string& auth_token) {
+ policy_table::ApplicationPolicies& policies =
+ pt_->policy_table.app_policies_section.apps;
+ policy_table::ApplicationPolicies::iterator policy_iter =
+ policies.find(policy_app_id);
+ if (policies.end() != policy_iter) {
+ *(*policy_iter).second.auth_token = auth_token;
+ }
+}
+
+void CacheManager::SetAppCloudTransportType(
+ const std::string& policy_app_id, const std::string& cloud_transport_type) {
+ policy_table::ApplicationPolicies& policies =
+ pt_->policy_table.app_policies_section.apps;
+ policy_table::ApplicationPolicies::iterator policy_iter =
+ policies.find(policy_app_id);
+ if (policies.end() != policy_iter) {
+ *(*policy_iter).second.cloud_transport_type = cloud_transport_type;
+ }
+}
+
+void CacheManager::SetAppEndpoint(const std::string& policy_app_id,
+ const std::string& endpoint) {
+ policy_table::ApplicationPolicies& policies =
+ pt_->policy_table.app_policies_section.apps;
+ policy_table::ApplicationPolicies::iterator policy_iter =
+ policies.find(policy_app_id);
+ if (policies.end() != policy_iter) {
+ *(*policy_iter).second.endpoint = endpoint;
+ }
+}
+
+void CacheManager::SetAppNicknames(const std::string& policy_app_id,
+ const StringArray& nicknames) {
+ policy_table::ApplicationPolicies& policies =
+ pt_->policy_table.app_policies_section.apps;
+ policy_table::ApplicationPolicies::iterator policy_iter =
+ policies.find(policy_app_id);
+ if (policies.end() != policy_iter) {
+ (*(*policy_iter).second.nicknames) = nicknames;
+ }
+}
+
+void CacheManager::SetHybridAppPreference(
+ const std::string& policy_app_id,
+ const std::string& hybrid_app_preference) {
+ policy_table::HybridAppPreference value;
+ bool valid = EnumFromJsonString(hybrid_app_preference, &value);
+ policy_table::ApplicationPolicies& policies =
+ pt_->policy_table.app_policies_section.apps;
+ policy_table::ApplicationPolicies::iterator policy_iter =
+ policies.find(policy_app_id);
+ if (policies.end() != policy_iter && valid) {
+ *(*policy_iter).second.hybrid_app_preference = value;
+ }
+}
+
+void CacheManager::GetAppServiceParameters(
+ const std::string& policy_app_id,
+ policy_table::AppServiceParameters* app_service_parameters) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ const policy_table::ApplicationPolicies& policies =
+ pt_->policy_table.app_policies_section.apps;
+ policy_table::ApplicationPolicies::const_iterator policy_iter =
+ policies.find(policy_app_id);
+ if (policies.end() != policy_iter) {
+ auto app_policy = (*policy_iter).second;
+ if (app_policy.app_service_parameters.is_initialized()) {
+ *app_service_parameters = *(app_policy.app_service_parameters);
+ }
+ }
+}
+
+bool CacheManager::UnknownRPCPassthroughAllowed(
+ const std::string& policy_app_id) const {
+ const policy_table::ApplicationPolicies& policies =
+ pt_->policy_table.app_policies_section.apps;
+ policy_table::ApplicationPolicies::const_iterator policy_iter =
+ policies.find(policy_app_id);
+ if (policies.end() != policy_iter) {
+ const auto app_policy = (*policy_iter).second;
+ if (app_policy.allow_unknown_rpc_passthrough.is_initialized()) {
+ return *(app_policy.allow_unknown_rpc_passthrough);
+ }
+ }
+ return false;
+}
+
+const boost::optional<bool> CacheManager::LockScreenDismissalEnabledState()
+ const {
+ boost::optional<bool> empty;
+ CACHE_MANAGER_CHECK(empty);
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 (module_config.lock_screen_dismissal_enabled.is_initialized()) {
+ return boost::optional<bool>(*module_config.lock_screen_dismissal_enabled);
+ }
+ return empty;
+}
+
+const boost::optional<std::string>
+CacheManager::LockScreenDismissalWarningMessage(
+ const std::string& language) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ boost::optional<std::string> empty;
+ CACHE_MANAGER_CHECK(empty);
+
+ const std::string lock_screen_dismissal_warning_message =
+ "LockScreenDismissalWarning";
+ sync_primitives::AutoLock auto_lock(cache_lock_);
+
+ std::vector<std::string> msg_codes{lock_screen_dismissal_warning_message};
+
+ const auto messages = GetUserFriendlyMsg(msg_codes, language, "en-us");
+
+ if (messages.empty() || messages[0].text_body.empty()) {
+ return empty;
+ }
+
+ return boost::optional<std::string>(messages[0].text_body);
}
std::vector<UserFriendlyMessage> CacheManager::GetUserFriendlyMsg(
const std::vector<std::string>& msg_codes,
const std::string& language,
- const std::string& active_hmi_language) {
+ const std::string& active_hmi_language) const {
LOG4CXX_AUTO_TRACE(logger_);
std::vector<UserFriendlyMessage> result;
CACHE_MANAGER_CHECK(result);
@@ -1428,16 +1737,24 @@ 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);
+ EndpointUrls& out_end_points) const {
+ 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,
- EndpointUrls& out_end_points) {
+ EndpointUrls& out_end_points) const {
LOG4CXX_AUTO_TRACE(logger_);
CACHE_MANAGER_CHECK_VOID();
@@ -1464,11 +1781,19 @@ void CacheManager::GetUpdateUrls(const std::string& service_type,
}
}
-std::string CacheManager::GetLockScreenIconUrl() const {
- if (backup_) {
- return backup_->GetLockScreenIconUrl();
+std::string CacheManager::GetIconUrl(const std::string& policy_app_id) const {
+ CACHE_MANAGER_CHECK(std::string());
+ std::string url;
+ const policy_table::ApplicationPolicies& policies =
+ pt_->policy_table.app_policies_section.apps;
+ policy_table::ApplicationPolicies::const_iterator policy_iter =
+ policies.find(policy_app_id);
+ if (policies.end() != policy_iter) {
+ auto app_policy = (*policy_iter).second;
+ url = app_policy.icon_url.is_initialized() ? *app_policy.icon_url
+ : std::string();
}
- return std::string("");
+ return url;
}
rpc::policy_table_interface_base::NumberOfNotificationsType
@@ -1519,6 +1844,9 @@ void CacheManager::CheckSnapshotInitialization() {
*(snapshot_->policy_table.module_config.preloaded_pt) = false;
+ *(snapshot_->policy_table.module_config.full_app_id_supported) =
+ settings_->use_full_app_id();
+
// SDL must not send certificate in snapshot
snapshot_->policy_table.module_config.certificate =
rpc::Optional<rpc::String<0, 65535> >();
@@ -1625,10 +1953,50 @@ void CacheManager::CheckSnapshotInitialization() {
}
}
+policy_table::VehicleDataItems CacheManager::CalculateCustomVdItemsDiff(
+ const policy_table::VehicleDataItems& items_before,
+ const policy_table::VehicleDataItems& items_after) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (items_before.empty()) {
+ LOG4CXX_DEBUG(logger_, "No custom VD items found in policy");
+ return policy_table::VehicleDataItems();
+ }
+
+ if (items_after.empty()) {
+ LOG4CXX_DEBUG(logger_,
+ "All custom VD items were removed after policy update");
+ return items_before;
+ }
+
+ policy_table::VehicleDataItems removed_items;
+ for (auto& item_to_search : items_before) {
+ auto item_predicate =
+ [&item_to_search](const policy_table::VehicleDataItem& item_to_check) {
+ return item_to_search.name == item_to_check.name;
+ };
+
+ auto it =
+ std::find_if(items_after.begin(), items_after.end(), item_predicate);
+ if (items_after.end() == it) {
+ removed_items.push_back(item_to_search);
+ }
+ }
+
+ LOG4CXX_DEBUG(logger_,
+ "Found " << removed_items.size() << " removed VD items");
+ return removed_items;
+}
+
+void CacheManager::SetRemovedCustomVdItems(
+ const policy_table::VehicleDataItems& removed_items) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ removed_custom_vd_items_ = removed_items;
+}
+
void CacheManager::PersistData() {
LOG4CXX_AUTO_TRACE(logger_);
- if (backup_.valid()) {
- if (pt_.valid()) {
+ if (backup_.use_count() != 0) {
+ if (pt_.use_count() != 0) {
// Comma expression is used to hold the lock only during the constructor
// call
policy_table::Table copy_pt(
@@ -1670,7 +2038,7 @@ void CacheManager::PersistData() {
}
// In case of extended policy the meta info should be backuped as well.
- if (ex_backup_.valid()) {
+ if (ex_backup_.use_count() != 0) {
ex_backup_->SetMetaInfo(
*(*copy_pt.policy_table.module_meta).ccpu_version,
*(*copy_pt.policy_table.module_meta).wers_country_code,
@@ -1750,12 +2118,20 @@ bool CacheManager::IsPermissionsCalculated(const std::string& device_id,
return false;
}
-utils::SharedPtr<policy_table::Table> CacheManager::GenerateSnapshot() {
+std::shared_ptr<policy_table::Table> CacheManager::GenerateSnapshot() {
CACHE_MANAGER_CHECK(snapshot_);
- snapshot_ = new policy_table::Table();
+ snapshot_ = std::make_shared<policy_table::Table>();
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();
@@ -1979,9 +2355,9 @@ bool CacheManager::CleanupUnpairedDevices() {
LOG4CXX_DEBUG(logger_, "Device_data size is: " << device_data.size());
device_data.erase(it_device);
- LOG4CXX_INFO(logger_,
- "Device id " << *iter
- << " had been deleted from device_data section.");
+ LOG4CXX_INFO(
+ logger_,
+ "Device id " << *iter << " had been deleted from device_data section.");
LOG4CXX_DEBUG(logger_, "Device_data size is: " << device_data.size());
}
is_unpaired_.clear();
@@ -2237,8 +2613,7 @@ bool CacheManager::Init(const std::string& file_name,
LOG4CXX_AUTO_TRACE(logger_);
settings_ = settings;
InitResult init_result = backup_->Init(settings);
- ex_backup_ = utils::SharedPtr<PTRepresentation>::dynamic_pointer_cast<
- PTExtRepresentation>(backup_);
+ ex_backup_ = std::dynamic_pointer_cast<PTExtRepresentation>(backup_);
bool result = true;
switch (init_result) {
@@ -2261,12 +2636,16 @@ bool CacheManager::Init(const std::string& file_name,
case InitResult::SUCCESS: {
LOG4CXX_INFO(logger_, "Policy Table was inited successfully");
result = LoadFromFile(file_name, *pt_);
- utils::SharedPtr<policy_table::Table> snapshot = GenerateSnapshot();
+ std::shared_ptr<policy_table::Table> snapshot = GenerateSnapshot();
result &= snapshot->is_valid();
LOG4CXX_DEBUG(logger_,
"Check if snapshot valid: " << std::boolalpha << result);
+ if (!UnwrapAppPolicies(pt_->policy_table.app_policies_section.apps)) {
+ LOG4CXX_ERROR(logger_, "Cannot unwrap application policies");
+ }
+
if (result) {
backup_->UpdateDBVersion();
Backup();
@@ -2274,6 +2653,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;
@@ -2339,13 +2720,12 @@ bool CacheManager::LoadFromFile(const std::string& file_name,
return false;
}
+ utils::JsonReader reader;
Json::Value value;
- Json::Reader reader(Json::Features::strictMode());
+
std::string json(json_string.begin(), json_string.end());
- if (!reader.parse(json.c_str(), value)) {
- LOG4CXX_FATAL(
- logger_,
- "Preloaded PT is corrupted: " << reader.getFormattedErrorMessages());
+ if (!reader.parse(json, &value)) {
+ LOG4CXX_FATAL(logger_, "Preloaded PT is corrupted.");
return false;
}
@@ -2356,10 +2736,10 @@ bool CacheManager::LoadFromFile(const std::string& file_name,
table = policy_table::Table(&value);
#ifdef ENABLE_LOG
- Json::StyledWriter s_writer;
- LOG4CXX_DEBUG(
- logger_,
- "Policy table content loaded:" << s_writer.write(table.ToJsonValue()));
+ Json::StreamWriterBuilder writer_builder;
+ LOG4CXX_DEBUG(logger_,
+ "Policy table content loaded:" << Json::writeString(
+ writer_builder, table.ToJsonValue()));
#endif // ENABLE_LOG
MakeLowerCaseAppNames(table);
@@ -2377,10 +2757,14 @@ bool CacheManager::LoadFromFile(const std::string& file_name,
bool CacheManager::ResetPT(const std::string& file_name) {
LOG4CXX_AUTO_TRACE(logger_);
is_unpaired_.clear();
+
+ backuper_->WaitForBackupIsDone();
+
if (!backup_->RefreshDB()) {
LOG4CXX_ERROR(logger_, "Can't re-create policy database. Reset failed.");
return false;
}
+
sync_primitives::AutoLock lock(cache_lock_);
pt_.reset(new policy_table::Table());
const bool result = LoadFromFile(file_name, *pt_);
@@ -2559,7 +2943,7 @@ ExternalConsentStatus CacheManager::GetExternalConsentEntities() {
policy_table::DisallowedByExternalConsentEntities::const_iterator it_2 =
(*it->second.disallowed_by_external_consent_entities_off).begin();
for (; it_2 !=
- (*it->second.disallowed_by_external_consent_entities_off).end();
+ (*it->second.disallowed_by_external_consent_entities_off).end();
++it_2) {
items.insert(ExternalConsentStatusItem(
it_2->entity_type, it_2->entity_id, EntityStatus::kStatusOff));
@@ -2651,8 +3035,8 @@ void CacheManager::SetExternalConsentForApp(
(*(*pt_->policy_table.device_data)[permissions.device_id]
.user_consent_records)[permissions.policy_app_id];
- const TimevalStruct tm = date_time::DateTime::getCurrentTime();
- int64_t current_time_msec = date_time::DateTime::getmSecs(tm);
+ const date_time::TimeDuration tm = date_time::getCurrentTime();
+ int64_t current_time_msec = date_time::getmSecs(tm);
app_consent_records.ext_consent_last_updated = current_time_msec;
LOG4CXX_DEBUG(logger_, "Updating consents time " << current_time_msec);
@@ -2677,6 +3061,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;
@@ -2708,8 +3093,9 @@ void CacheManager::MergeFG(const policy_table::PolicyTable& new_pt,
void CacheManager::MergeAP(const policy_table::PolicyTable& new_pt,
policy_table::PolicyTable& pt) {
LOG4CXX_AUTO_TRACE(logger_);
- pt.app_policies_section.device = const_cast<policy_table::PolicyTable&>(
- new_pt).app_policies_section.device;
+ pt.app_policies_section.device =
+ const_cast<policy_table::PolicyTable&>(new_pt)
+ .app_policies_section.device;
pt.app_policies_section.apps[kDefaultId] =
const_cast<policy_table::PolicyTable&>(new_pt)
@@ -2743,6 +3129,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);
@@ -2784,6 +3176,7 @@ void CacheManager::OnDeviceSwitching(const std::string& device_id_from,
CacheManager::BackgroundBackuper::BackgroundBackuper(
CacheManager* cache_manager)
: cache_manager_(cache_manager)
+ , backup_is_in_progress_(false)
, stop_flag_(false)
, new_data_available_(false) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -2808,13 +3201,23 @@ void CacheManager::BackgroundBackuper::threadMain() {
LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock lock(need_backup_lock_);
while (!stop_flag_) {
+ backup_is_in_progress_.exchange(true);
{
sync_primitives::AutoUnlock need_backup_lock(need_backup_lock_);
InternalBackup();
}
+
+ {
+ LOG4CXX_DEBUG(logger_, "Backup is done");
+ sync_primitives::AutoLock auto_lock(backup_done_lock_);
+ backup_is_in_progress_.exchange(false);
+ backup_done_.Broadcast();
+ }
+
if (new_data_available_ || stop_flag_) {
continue;
}
+
LOG4CXX_DEBUG(logger_, "Wait for a next backup");
backup_notifier_.Wait(need_backup_lock_);
}
@@ -2834,4 +3237,54 @@ void CacheManager::BackgroundBackuper::DoBackup() {
backup_notifier_.NotifyOne();
}
+void CacheManager::BackgroundBackuper::WaitForBackupIsDone() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock auto_lock(backup_done_lock_);
+ if (backup_is_in_progress_) {
+ backup_done_.Wait(auto_lock);
+ }
+}
+
+EncryptionRequired CacheManager::GetAppEncryptionRequiredFlag(
+ const std::string& application) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
+
+ return pt_->policy_table.app_policies_section.apps[application]
+ .encryption_required;
+}
+
+EncryptionRequired CacheManager::GetFunctionalGroupingEncryptionRequiredFlag(
+ const std::string& functional_group) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
+
+ const auto& functional_groupings = pt_->policy_table.functional_groupings;
+
+ const auto& grouping_itr = functional_groupings.find(functional_group);
+ if (grouping_itr == functional_groupings.end()) {
+ LOG4CXX_WARN(logger_, "Group " << functional_group << " not found");
+ return rpc::Optional<rpc::Boolean>(rpc::Boolean(false));
+ }
+
+ return (*grouping_itr).second.encryption_required;
+}
+
+void CacheManager::GetApplicationParams(
+ const std::string& application_name,
+ policy_table::ApplicationParams& application_params) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
+
+ const auto apps = pt_->policy_table.app_policies_section.apps;
+ const auto it = apps.find(application_name);
+ if (apps.end() == it) {
+ LOG4CXX_WARN(logger_,
+ "Application " << application_name << " was not found");
+ return;
+ }
+
+ application_params = (*it).second;
+}
+
} // namespace policy
diff --git a/src/components/policy/policy_external/src/policy_helper.cc b/src/components/policy/policy_external/src/policy_helper.cc
index 39b9399c24..b8bbb1682c 100644
--- a/src/components/policy/policy_external/src/policy_helper.cc
+++ b/src/components/policy/policy_external/src/policy_helper.cc
@@ -30,13 +30,13 @@
POSSIBILITY OF SUCH DAMAGE.
*/
+#include "policy/policy_helper.h"
+#include <string.h>
#include <algorithm>
#include <sstream>
-#include <string.h>
-#include "utils/logger.h"
-#include "utils/custom_string.h"
-#include "policy/policy_helper.h"
#include "policy/policy_manager_impl.h"
+#include "utils/custom_string.h"
+#include "utils/logger.h"
namespace policy {
@@ -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);
@@ -113,7 +114,7 @@ bool operator!=(const policy_table::ApplicationParams& first,
for (; it_first != it_first_end; ++it_first) {
CompareGroupName gp(*it_first);
StringsConstItr it = std::find_if(it_second, it_second_end, gp);
- if (it_first_end == it) {
+ if (it_second_end == it) {
return true;
}
}
@@ -122,8 +123,8 @@ bool operator!=(const policy_table::ApplicationParams& first,
CheckAppPolicy::CheckAppPolicy(
PolicyManagerImpl* pm,
- const utils::SharedPtr<policy_table::Table> update,
- const utils::SharedPtr<policy_table::Table> snapshot,
+ const std::shared_ptr<policy_table::Table> update,
+ const std::shared_ptr<policy_table::Table> snapshot,
CheckAppPolicyResults& out_results)
: pm_(pm)
, update_(update)
@@ -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;
}
}
@@ -299,9 +421,27 @@ void CheckAppPolicy::AddResult(const std::string& app_id,
out_results_.insert(std::make_pair(app_id, result));
}
+void CheckAppPolicy::InsertPermission(const std::string& app_id,
+ const AppPermissions& permissions_diff) {
+ pm_->app_permissions_diff_lock_.Acquire();
+ auto result = pm_->app_permissions_diff_.insert(
+ std::make_pair(app_id, permissions_diff));
+ if (!result.second) {
+ LOG4CXX_ERROR(logger_, "App ID: " << app_id << " already exists in map.");
+ }
+ pm_->app_permissions_diff_lock_.Release();
+}
+
bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) {
const std::string app_id = app_policy.first;
+ const bool app_properties_changed = IsAppPropertiesChanged(app_policy);
+ const bool is_predefined_app = IsPredefinedApp(app_policy);
+ if (!is_predefined_app && app_properties_changed) {
+ AddResult(app_id, RESULT_APP_PROPERTIES_CHANGED);
+ }
+
+ AppPermissions permissions_diff(app_id);
if (!IsKnownAppication(app_id)) {
LOG4CXX_WARN(logger_,
"Application:" << app_id << " is not present in snapshot.");
@@ -309,14 +449,17 @@ bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) {
}
if (!IsPredefinedApp(app_policy) && IsAppRevoked(app_policy)) {
- SetPendingPermissions(app_policy, RESULT_APP_REVOKED);
+ SetPendingPermissions(app_policy, RESULT_APP_REVOKED, permissions_diff);
AddResult(app_id, RESULT_APP_REVOKED);
+ InsertPermission(app_id, permissions_diff);
return true;
}
if (!IsPredefinedApp(app_policy) && !NicknamesMatch(app_policy)) {
- SetPendingPermissions(app_policy, RESULT_NICKNAME_MISMATCH);
+ SetPendingPermissions(
+ app_policy, RESULT_NICKNAME_MISMATCH, permissions_diff);
AddResult(app_id, RESULT_NICKNAME_MISMATCH);
+ InsertPermission(app_id, permissions_diff);
return true;
}
@@ -328,43 +471,50 @@ bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) {
if (is_request_type_changed) {
LOG4CXX_TRACE(logger_,
"Request types were changed for application: " << app_id);
- SetPendingPermissions(app_policy, RESULT_REQUEST_TYPE_CHANGED);
+ SetPendingPermissions(
+ app_policy, RESULT_REQUEST_TYPE_CHANGED, permissions_diff);
AddResult(app_id, RESULT_REQUEST_TYPE_CHANGED);
+ result =
+ (RESULT_NO_CHANGES == result) ? RESULT_REQUEST_TYPE_CHANGED : result;
}
if (is_request_subtype_changed) {
LOG4CXX_TRACE(
logger_, "Request subtypes were changed for application: " << app_id);
- SetPendingPermissions(app_policy, RESULT_REQUEST_SUBTYPE_CHANGED);
+ SetPendingPermissions(
+ app_policy, RESULT_REQUEST_SUBTYPE_CHANGED, permissions_diff);
AddResult(app_id, RESULT_REQUEST_SUBTYPE_CHANGED);
+ result = (RESULT_NO_CHANGES == result) ? RESULT_REQUEST_SUBTYPE_CHANGED
+ : result;
}
}
if (RESULT_NO_CHANGES == result) {
- LOG4CXX_INFO(logger_,
- "Permissions for application:" << app_id
- << " wasn't changed.");
+ LOG4CXX_INFO(
+ logger_,
+ "Permissions for application:" << app_id << " wasn't changed.");
AddResult(app_id, result);
return true;
}
- LOG4CXX_INFO(logger_,
- "Permissions for application:" << app_id
- << " have been changed.");
+ LOG4CXX_INFO(
+ logger_,
+ "Permissions for application:" << app_id << " have been changed.");
if (!IsPredefinedApp(app_policy)) {
- SetPendingPermissions(app_policy, result);
+ SetPendingPermissions(app_policy, result, permissions_diff);
AddResult(app_id, result);
}
+ InsertPermission(app_id, permissions_diff);
return true;
}
void policy::CheckAppPolicy::SetPendingPermissions(
const AppPoliciesValueType& app_policy,
- PermissionsCheckResult result) const {
+ PermissionsCheckResult result,
+ AppPermissions& permissions_diff) const {
using namespace rpc::policy_table_interface_base;
const std::string app_id = app_policy.first;
- AppPermissions permissions_diff(app_id);
const std::string priority =
policy_table::EnumToJsonString(app_policy.second.priority);
@@ -421,10 +571,6 @@ void policy::CheckAppPolicy::SetPendingPermissions(
if (need_send_priority) {
permissions_diff.priority = priority;
}
-
- pm_->app_permissions_diff_lock_.Acquire();
- pm_->app_permissions_diff_.insert(std::make_pair(app_id, permissions_diff));
- pm_->app_permissions_diff_lock_.Release();
}
PermissionsCheckResult CheckAppPolicy::CheckPermissionsChanges(
@@ -435,14 +581,20 @@ PermissionsCheckResult CheckAppPolicy::CheckPermissionsChanges(
bool has_new_groups = HasNewGroups(app_policy);
+ 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;
}
return RESULT_NO_CHANGES;
@@ -523,11 +675,166 @@ bool CheckAppPolicy::IsRequestSubTypeChanged(
return diff.size();
}
+bool CheckAppPolicy::IsAppPropertiesProvided(
+ const AppPoliciesValueType& app_policy) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (app_policy.second.hybrid_app_preference.is_initialized() ||
+ app_policy.second.endpoint.is_initialized() ||
+ app_policy.second.enabled.is_initialized() ||
+ app_policy.second.auth_token.is_initialized() ||
+ app_policy.second.cloud_transport_type.is_initialized() ||
+ app_policy.second.nicknames.is_initialized()) {
+ return true;
+ }
+ return false;
+}
+
+bool CheckAppPolicy::IsAppPropertiesChanged(
+ const AppPoliciesValueType& app_policy) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ if (!IsAppPropertiesProvided(app_policy)) {
+ return false;
+ }
+
+ if (!IsKnownAppication(app_policy.first)) {
+ LOG4CXX_DEBUG(
+ logger_,
+ "AppProperties provided for new application: " << app_policy.first);
+ return true;
+ }
+
+ policy::AppPoliciesConstItr it =
+ snapshot_->policy_table.app_policies_section.apps.find(app_policy.first);
+ const auto snapshot_properties = *it;
+
+ if (app_policy.second.enabled.is_initialized() &&
+ app_policy.second.enabled != snapshot_properties.second.enabled) {
+ LOG4CXX_DEBUG(logger_, "\"enabled\" was changed");
+ return true;
+ }
+
+ if (app_policy.second.endpoint.is_initialized() &&
+ app_policy.second.endpoint != snapshot_properties.second.endpoint) {
+ LOG4CXX_DEBUG(logger_, "\"endpoint\" was changed");
+ return true;
+ }
+
+ if (app_policy.second.hybrid_app_preference.is_initialized() &&
+ app_policy.second.hybrid_app_preference !=
+ snapshot_properties.second.hybrid_app_preference) {
+ LOG4CXX_DEBUG(logger_, "\"hybrid_app_preference\" was changed");
+ return true;
+ }
+
+ if (app_policy.second.auth_token.is_initialized() &&
+ app_policy.second.auth_token != snapshot_properties.second.auth_token) {
+ LOG4CXX_DEBUG(logger_, "\"auth_token\" was changed");
+ return true;
+ }
+
+ if (app_policy.second.cloud_transport_type.is_initialized() &&
+ app_policy.second.cloud_transport_type !=
+ snapshot_properties.second.cloud_transport_type) {
+ LOG4CXX_DEBUG(logger_, "\"cloud_transport_type\" was changed");
+ return true;
+ }
+
+ return false;
+}
+
+bool CheckAppPolicy::IsEncryptionRequiredFlagChanged(
+ const AppPoliciesValueType& app_policy) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ auto get_app_encryption_needed =
+ [](const std::string& policy_app_id,
+ policy_table::ApplicationPolicies& policies)
+ -> rpc::Optional<rpc::Boolean> {
+ auto it = policies.find(policy_app_id);
+ if (policies.end() == it) {
+ LOG4CXX_WARN(logger_, "App is not present in policies" << policy_app_id);
+ return rpc::Optional<rpc::Boolean>(false);
+ }
+ return it->second.encryption_required;
+ };
+
+ auto get_app_groups =
+ [](const std::string& policy_app_id,
+ policy_table::ApplicationPolicies& policies) -> policy_table::Strings {
+ policy_table::Strings result;
+ auto it = policies.find(policy_app_id);
+ if (policies.end() == it) {
+ LOG4CXX_WARN(logger_, "App is not present in policies" << policy_app_id);
+ return result;
+ }
+ auto& groups = it->second.groups;
+ std::copy(groups.begin(), groups.end(), std::back_inserter(result));
+ return result;
+ };
+
+ auto get_app_rpcs = [](const std::string group_name,
+ const FunctionalGroupings& groups)
+ -> rpc::Optional<policy_table::Rpcs> {
+ auto it = groups.find(group_name);
+ if (it == groups.end()) {
+ return rpc::Optional<policy_table::Rpcs>();
+ }
+ return rpc::Optional<policy_table::Rpcs>(it->second);
+ };
+
+ const auto snapshot_groups = get_app_groups(
+ app_policy.first, snapshot_->policy_table.app_policies_section.apps);
+ const auto update_groups = get_app_groups(
+ app_policy.first, update_->policy_table.app_policies_section.apps);
+
+ auto get_resulting_encryption_required_flag_for_app_groups =
+ [this, &get_app_rpcs](
+ const rpc::policy_table_interface_base::Strings& app_groups,
+ const std::shared_ptr<rpc::policy_table_interface_base::Table> pt) {
+ for (const auto& group : app_groups) {
+ const auto rpcs =
+ get_app_rpcs(group, pt->policy_table.functional_groupings);
+ if (*rpcs->encryption_required) {
+ return true;
+ }
+ }
+
+ return false;
+ };
+
+ auto group_res_en_flag_changed =
+ [this, &get_resulting_encryption_required_flag_for_app_groups](
+ const rpc::policy_table_interface_base::Strings& snapshot_groups,
+ const rpc::policy_table_interface_base::Strings& update_groups) {
+ return get_resulting_encryption_required_flag_for_app_groups(
+ snapshot_groups, snapshot_) !=
+ get_resulting_encryption_required_flag_for_app_groups(
+ update_groups, update_);
+ };
+
+ const auto snapshot_app_encryption_needed = get_app_encryption_needed(
+ app_policy.first, snapshot_->policy_table.app_policies_section.apps);
+ const auto update_app_encryption_needed = get_app_encryption_needed(
+ app_policy.first, update_->policy_table.app_policies_section.apps);
+
+ const bool app_encryption_needed_changed =
+ (snapshot_app_encryption_needed.is_initialized() !=
+ update_app_encryption_needed.is_initialized()) ||
+ (*snapshot_app_encryption_needed != *update_app_encryption_needed);
+
+ if ((!update_app_encryption_needed.is_initialized() ||
+ *update_app_encryption_needed) &&
+ group_res_en_flag_changed(snapshot_groups, update_groups)) {
+ return true;
+ }
+
+ return app_encryption_needed_changed;
+}
+
void FillActionsForAppPolicies::operator()(
const policy::CheckAppPolicyResults::value_type& value) {
const std::string app_id = value.first;
- const policy_table::ApplicationPolicies::const_iterator app_policy =
- app_policies_.find(app_id);
+ const auto app_policy = app_policies_.find(app_id);
if (app_policies_.end() == app_policy) {
return;
@@ -546,10 +853,14 @@ 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_APP_PROPERTIES_CHANGED:
+ actions_[app_id].app_properties_changed = true;
+ break;
+ case RESULT_CONSENT_NOT_REQUIRED:
case RESULT_PERMISSIONS_REVOKED:
case RESULT_REQUEST_TYPE_CHANGED:
case RESULT_REQUEST_SUBTYPE_CHANGED:
+ case RESULT_ENCRYPTION_REQUIRED_FLAG_CHANGED:
break;
case RESULT_NO_CHANGES:
default:
@@ -620,7 +931,18 @@ void FillNotificationData::UpdateParameters(
ParametersConstItr it_parameters = in_parameters.begin();
ParametersConstItr it_parameters_end = in_parameters.end();
- // Due to APPLINK-24201 SDL must consider cases when 'parameters' section is
+ // To determine consent for a particular RPC in a particular HMI level with
+ // particular parameters (if applicable), the system shall find all of the
+ // functional groups the RPC is included in. If user consent is needed as
+ // listed within the functional group in the policy table, the system shall
+ // use a logical AND: backend permissions AND User permissions. If the RPC
+ // is
+ // listed under more than one group, the system shall perform a logical OR
+ // among all of the possible allowed permissions scenarios for the RPC
+ // (and
+ // parameter/or HMI level) defined by each of the functional groups.
+
+ // Due to requirements SDL must consider cases when 'parameters' section is
// not present for RPC or present, but is empty.
// If 'parameters' section is like: 'parameters' : []
@@ -635,17 +957,21 @@ void FillNotificationData::UpdateParameters(
// If 'parameters' section is omitted
if (!in_parameters.is_initialized()) {
- if (!does_require_user_consent_) {
- out_parameter.any_parameter_allowed = true;
- }
- if (does_require_user_consent_ && kAllowedKey == current_key_) {
+ if (!does_require_user_consent_ ||
+ (does_require_user_consent_ && kAllowedKey == current_key_)) {
out_parameter.any_parameter_allowed = true;
}
}
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
+ // due to a logical OR permissions check
+ if (IsSomeParameterAllowed(out_parameter)) {
+ out_parameter.any_parameter_disallowed_by_policy = false;
+ out_parameter.any_parameter_disallowed_by_user = false;
}
}
@@ -703,7 +1029,8 @@ void FillNotificationData::ExcludeSame(RpcPermissions& rpc) {
}
}
- // Removing disallowed parameters from allowed and undefined (by user consent)
+ // Removing disallowed parameters from allowed and undefined (by user
+ // consent)
if (rpc.parameter_permissions.end() != it_parameter_user_disallowed) {
if (rpc.parameter_permissions.end() != it_parameter_allowed) {
ExcludeSameParameters(rpc.parameter_permissions[kAllowedKey],
@@ -769,16 +1096,24 @@ bool FillNotificationData::RpcParametersEmpty(RpcPermissions& rpc) {
no_user_disallowed_parameters;
}
-bool FillNotificationData::IsSectionEmpty(ParameterPermissions& permissions,
- const std::string& section) {
+bool FillNotificationData::IsSectionEmpty(
+ const ParameterPermissions& permissions, const std::string& section) const {
ParameterPermissions::const_iterator it_section = permissions.find(section);
ParameterPermissions::const_iterator end = permissions.end();
if (end != it_section) {
- return permissions[section].empty();
+ return it_section->second.empty();
}
return true;
}
+bool FillNotificationData::IsSomeParameterAllowed(
+ const ParameterPermissions& permissions) const {
+ const bool are_any_consented_parameters_allowed =
+ kAllowedKey == current_key_ && !IsSectionEmpty(permissions, current_key_);
+ return permissions.any_parameter_allowed ||
+ are_any_consented_parameters_allowed;
+}
+
ProcessFunctionalGroup::ProcessFunctionalGroup(
const policy_table::FunctionalGroupings& fg,
const std::vector<FunctionalGroupPermission>& group_permissions,
@@ -802,10 +1137,31 @@ bool ProcessFunctionalGroup::operator()(const StringsValueType& group_name) {
undefined_group_consent_,
does_require_user_consent);
std::for_each(rpcs.begin(), rpcs.end(), filler);
+ const auto encryption_required = (*it).second.encryption_required;
+ FillEncryptionFlagForRpcs(rpcs, encryption_required);
}
return true;
}
+void ProcessFunctionalGroup::FillEncryptionFlagForRpcs(
+ const policy_table::Rpc& rpcs,
+ const EncryptionRequired encryption_required) {
+ auto update_encryption_required = [](EncryptionRequired& current,
+ const EncryptionRequired& incoming) {
+ if (!incoming.is_initialized()) {
+ return;
+ }
+ if (current.is_initialized() && *current) {
+ return;
+ }
+ current = incoming;
+ };
+ for (const auto& rpc : rpcs) {
+ auto& item = data_[rpc.first];
+ update_encryption_required(item.require_encryption, encryption_required);
+ }
+}
+
GroupConsent ProcessFunctionalGroup::GetGroupState(
const std::string& group_name) {
std::vector<FunctionalGroupPermission>::const_iterator it =
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 4ac66c0d53..082d4a37ba 100644
--- a/src/components/policy/policy_external/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_external/src/policy_manager_impl.cc
@@ -32,33 +32,28 @@
#include "policy/policy_manager_impl.h"
#include <algorithm>
-#include <set>
-#include <queue>
+#include <functional>
#include <iterator>
#include <limits>
+#include <queue>
+#include <set>
#include <vector>
-#include <functional>
-#include "json/reader.h"
+#include "config_profile/profile.h"
#include "json/writer.h"
+#include "policy/cache_manager.h"
+#include "policy/policy_helper.h"
#include "policy/policy_table.h"
#include "policy/pt_representation.h"
-#include "policy/policy_helper.h"
+#include "policy/update_status_manager.h"
+#include "utils/date_time.h"
#include "utils/file_system.h"
+#include "utils/jsoncpp_reader_wrapper.h"
#include "utils/logger.h"
-#include "utils/date_time.h"
-#include "policy/cache_manager.h"
-#include "policy/update_status_manager.h"
-#include "config_profile/profile.h"
-#include "utils/make_shared.h"
+
#include "policy/access_remote.h"
#include "policy/access_remote_impl.h"
+#include "utils/timer_task_impl.h"
-policy::PolicyManager* CreateManager() {
- return new policy::PolicyManagerImpl();
-}
-void DeleteManager(policy::PolicyManager* pm) {
- delete pm;
-}
namespace {
/**
@@ -213,41 +208,47 @@ PolicyManagerImpl::PolicyManagerImpl()
: PolicyManager()
, listener_(NULL)
, cache_(new CacheManager)
- , access_remote_(new AccessRemoteImpl(
- CacheManagerInterfaceSPtr::static_pointer_cast<CacheManager>(cache_)))
+ , access_remote_(
+ new AccessRemoteImpl(std::static_pointer_cast<CacheManager>(cache_)))
, retry_sequence_timeout_(60)
, retry_sequence_index_(0)
+ , applications_pending_ptu_count_(0)
, ignition_check(true)
- , retry_sequence_url_(0, 0, "") {}
+ , retry_sequence_url_(0, 0, "")
+ , ptu_requested_(false)
+ , is_ptu_in_progress_(false) {}
PolicyManagerImpl::PolicyManagerImpl(bool in_memory)
: PolicyManager()
, listener_(NULL)
, cache_(new CacheManager(in_memory))
- , access_remote_(new AccessRemoteImpl(
- CacheManagerInterfaceSPtr::static_pointer_cast<CacheManager>(cache_)))
+ , access_remote_(
+ new AccessRemoteImpl(std::static_pointer_cast<CacheManager>(cache_)))
, retry_sequence_timeout_(60)
, retry_sequence_index_(0)
+ , applications_pending_ptu_count_(0)
, ignition_check(true)
, retry_sequence_url_(0, 0, "")
- , wrong_ptu_update_received_(false)
, send_on_update_sent_out_(false)
- , trigger_ptu_(false) {}
+ , trigger_ptu_(false)
+ , ptu_requested_(false)
+ , is_ptu_in_progress_(false) {}
void PolicyManagerImpl::set_listener(PolicyListener* listener) {
listener_ = listener;
update_status_manager_.set_listener(listener);
}
-utils::SharedPtr<policy_table::Table> PolicyManagerImpl::Parse(
+std::shared_ptr<policy_table::Table> PolicyManagerImpl::Parse(
const BinaryMessage& pt_content) {
std::string json(pt_content.begin(), pt_content.end());
+ utils::JsonReader reader;
Json::Value value;
- Json::Reader reader;
- if (reader.parse(json.c_str(), value)) {
- return new policy_table::Table(&value);
+
+ if (reader.parse(json, &value)) {
+ return std::make_shared<policy_table::Table>(&value);
} else {
- return utils::SharedPtr<policy_table::Table>();
+ return std::make_shared<policy_table::Table>();
}
}
@@ -267,105 +268,316 @@ void PolicyManagerImpl::CheckTriggers() {
}
}
-std::string PolicyManagerImpl::GetLockScreenIconUrl() const {
- return cache_->GetLockScreenIconUrl();
+std::string PolicyManagerImpl::GetIconUrl(
+ const std::string& policy_app_id) const {
+ return cache_->GetIconUrl(policy_app_id);
}
-bool PolicyManagerImpl::LoadPT(const std::string& file,
- const BinaryMessage& pt_content) {
+/**
+ * @brief FilterInvalidFunctions filter functions that are absent in schema
+ * @param rpcs list of functions to filter
+ */
+void FilterInvalidFunctions(policy_table::Rpc& rpcs) {
+ policy_table::Rpc valid_rpcs;
+ for (const auto& rpc : rpcs) {
+ const std::string& rpc_name = rpc.first;
+ policy_table::FunctionID function_id;
+ if (policy_table::EnumFromJsonString(rpc_name, &function_id)) {
+ valid_rpcs.insert(rpc);
+ }
+ }
+ rpcs.swap(valid_rpcs);
+}
+
+/**
+ * @brief FilterInvalidRPCParameters filter parameters that not present in
+ * schema
+ * @param rpc_parameters parameters to filter
+ */
+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()) {
+ valid_hmi_levels.push_back(hmi_level);
+ }
+ }
+ 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() && ParamExists(param)) {
+ valid_params.push_back(param);
+ }
+ }
+ rpc_parameters.parameters->swap(valid_params);
+}
+
+/**
+ * @brief FilterInvalidPriorityValues filter notification priorities that are
+ * not present in schema
+ * @param notifications priorities to filter
+ */
+void FilterInvalidPriorityValues(
+ policy_table::NumberOfNotificationsPerMinute& notifications) {
+ policy_table::NumberOfNotificationsPerMinute valid_notifications;
+ for (const auto& notification : notifications) {
+ policy_table::Priority priority;
+ if (policy_table::EnumFromJsonString(notification.first, &priority)) {
+ valid_notifications.insert(notification);
+ }
+ }
+ notifications.swap(valid_notifications);
+}
+
+/**
+ * @brief FilterInvalidApplicationParameters filter app params that are not
+ * present in schema
+ * @param app_params object of app policy params to filter
+ */
+void FilterInvalidApplicationParameters(
+ policy_table::ApplicationParams& app_params) {
+ // Filter AppHMIType array
+ policy_table::AppHMITypes valid_app_hmi_types;
+ const policy_table::AppHMITypes& app_hmi_types = *(app_params.AppHMIType);
+ for (const auto& app_hmi_type : app_hmi_types) {
+ if (app_hmi_type.is_valid()) {
+ valid_app_hmi_types.push_back(app_hmi_type);
+ }
+ }
+ app_params.AppHMIType->swap(valid_app_hmi_types);
+
+ // Filter RquestTypes array
+ policy_table::RequestTypes valid_request_types;
+ const policy_table::RequestTypes& request_types = *(app_params.RequestType);
+ for (const auto& request_type : request_types) {
+ if (request_type.is_valid()) {
+ valid_request_types.push_back(request_type);
+ }
+ }
+ if (valid_request_types.empty() && !request_types.empty()) {
+ // An empty RequestType array will allow all request types. No valid
+ // parameters are in the filtered array, so assign an uninitialized value to
+ // for array to be "omitted"
+ *(app_params.RequestType) = policy_table::RequestTypes();
+ } else {
+ app_params.RequestType->swap(valid_request_types);
+ }
+
+ // Filter moduleType array
+ policy_table::ModuleTypes valid_module_types;
+ const policy_table::ModuleTypes& module_types = *(app_params.moduleType);
+ for (const auto& module_type : module_types) {
+ if (module_type.is_valid()) {
+ valid_module_types.push_back(module_type);
+ }
+ }
+ if (valid_module_types.empty() && !module_types.empty()) {
+ // An empty moduleType array will allow all request types. No valid
+ // parameters are in the filtered array, so assign an uninitialized value to
+ // for array to be "omitted"
+ *(app_params.moduleType) = policy_table::ModuleTypes();
+ } else {
+ app_params.moduleType->swap(valid_module_types);
+ }
+
+ // Filter default_hmi
+ if (!app_params.default_hmi.is_valid()) {
+ app_params.default_hmi = policy_table::HmiLevel();
+ }
+
+ // Filter priority
+ if (!app_params.priority.is_valid()) {
+ app_params.priority = policy_table::Priority();
+ }
+}
+
+/**
+ * @brief FilterPolicyTable filter values that not present in schema
+ * @param pt policy table to filter
+ */
+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()) {
+ FilterInvalidPriorityValues(
+ module_config.notifications_per_minute_by_priority);
+ }
+
+ if (pt.app_policies_section.is_initialized()) {
+ policy_table::ApplicationPolicies& apps = pt.app_policies_section.apps;
+ for (auto& app_policy : apps) {
+ FilterInvalidApplicationParameters(app_policy.second);
+ }
+ }
+
+ for (auto& group : pt.functional_groupings) {
+ 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, vehicle_data_items);
+ }
+ }
+}
+
+PolicyManager::PtProcessingResult PolicyManagerImpl::LoadPT(
+ const std::string& file, const BinaryMessage& pt_content) {
LOG4CXX_INFO(logger_, "LoadPT of size " << pt_content.size());
LOG4CXX_DEBUG(
logger_,
"PTU content is: " << std::string(pt_content.begin(), pt_content.end()));
// Parse message into table struct
- utils::SharedPtr<policy_table::Table> pt_update = Parse(pt_content);
+ std::shared_ptr<policy_table::Table> pt_update = Parse(pt_content);
if (!pt_update) {
LOG4CXX_WARN(logger_, "Parsed table pointer is NULL.");
- update_status_manager_.OnWrongUpdateReceived();
- return false;
+ return PtProcessingResult::kWrongPtReceived;
}
file_system::DeleteFile(file);
+ 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();
- return false;
+ LOG4CXX_WARN(logger_, "Received policy table update is not valid");
+ return PtProcessingResult::kWrongPtReceived;
}
- update_status_manager_.OnValidUpdateReceived();
cache_->SaveUpdateRequired(false);
+ sync_primitives::AutoLock lock(apps_registration_lock_);
- {
- sync_primitives::AutoLock lock(apps_registration_lock_);
+ // Get current DB data, since it could be updated during awaiting of PTU
+ auto policy_table_snapshot = cache_->GenerateSnapshot();
+ if (!policy_table_snapshot) {
+ LOG4CXX_ERROR(
+ logger_,
+ "Failed to create snapshot of policy table, trying another exchange");
+ return PtProcessingResult::kNewPtRequired;
+ }
- // Get current DB data, since it could be updated during awaiting of PTU
- utils::SharedPtr<policy_table::Table> policy_table_snapshot =
- cache_->GenerateSnapshot();
- if (!policy_table_snapshot) {
- LOG4CXX_ERROR(
- logger_,
- "Failed to create snapshot of policy table, trying another exchange");
- ForcePTExchange();
- 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);
- // 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 current data with updated
- if (!cache_->ApplyUpdate(*pt_update)) {
- LOG4CXX_WARN(
- logger_,
- "Unsuccessful save of updated policy table, trying another exchange");
- ForcePTExchange();
- return false;
- }
+ // Replace current data with updated
+ if (!cache_->ApplyUpdate(*pt_update)) {
+ LOG4CXX_WARN(
+ logger_,
+ "Unsuccessful save of updated policy table, trying another exchange");
+ return PtProcessingResult::kNewPtRequired;
+ }
- ExternalConsentStatus status = cache_->GetExternalConsentStatus();
- GroupsByExternalConsentStatus groups_by_status =
- cache_->GetGroupsWithSameEntities(status);
+ ExternalConsentStatus status = cache_->GetExternalConsentStatus();
+ GroupsByExternalConsentStatus groups_by_status =
+ cache_->GetGroupsWithSameEntities(status);
- ProcessExternalConsentStatusUpdate(
- groups_by_status, ConsentProcessingPolicy::kExternalConsentBased);
+ ProcessExternalConsentStatusUpdate(
+ groups_by_status, ConsentProcessingPolicy::kExternalConsentBased);
- ProcessAppPolicyCheckResults(
- results, pt_update->policy_table.app_policies_section.apps);
+ ProcessAppPolicyCheckResults(
+ results, pt_update->policy_table.app_policies_section.apps);
- listener_->OnCertificateUpdated(
- *(pt_update->policy_table.module_config.certificate));
+ CheckPermissionsChangesAfterUpdate(*pt_update, *policy_table_snapshot);
- std::map<std::string, StringArray> app_hmi_types;
- cache_->GetHMIAppTypeAfterUpdate(app_hmi_types);
- if (!app_hmi_types.empty()) {
- LOG4CXX_INFO(logger_, "app_hmi_types is full calling OnUpdateHMIAppType");
- listener_->OnUpdateHMIAppType(app_hmi_types);
- } else {
- LOG4CXX_INFO(logger_, "app_hmi_types empty");
- }
+ listener_->OnCertificateUpdated(
+ *(pt_update->policy_table.module_config.certificate));
+
+ std::map<std::string, StringArray> app_hmi_types;
+ cache_->GetHMIAppTypeAfterUpdate(app_hmi_types);
+ if (!app_hmi_types.empty()) {
+ LOG4CXX_INFO(logger_, "app_hmi_types is full calling OnUpdateHMIAppType");
+ listener_->OnUpdateHMIAppType(app_hmi_types);
+ } else {
+ LOG4CXX_INFO(logger_, "app_hmi_types empty");
+ }
+
+ std::vector<std::string> enabled_apps;
+ cache_->GetEnabledCloudApps(enabled_apps);
+ for (auto it = enabled_apps.begin(); it != enabled_apps.end(); ++it) {
+ SendAuthTokenUpdated(*it);
+ }
+
+ return PtProcessingResult::kSuccess;
+}
+
+void PolicyManagerImpl::OnPTUFinished(const PtProcessingResult ptu_result) {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ ptu_requested_ = false;
+ if (PtProcessingResult::kWrongPtReceived == ptu_result) {
+ LOG4CXX_DEBUG(logger_, "Wrong PT was received");
+ update_status_manager_.OnWrongUpdateReceived();
+ return;
}
+ update_status_manager_.OnValidUpdateReceived();
+
+ if (HasApplicationForPTU()) {
+ update_status_manager_.OnExistedApplicationAdded(true);
+ } else if (PtProcessingResult::kNewPtRequired == ptu_result) {
+ LOG4CXX_DEBUG(logger_, "New PTU interation is required");
+ ForcePTExchange();
+ return;
+ }
+
+ ResumePendingAppPolicyActions();
+
// If there was a user request for policy table update, it should be started
// right after current update is finished
if (update_status_manager_.IsUpdateRequired()) {
+ LOG4CXX_DEBUG(logger_,
+ "PTU was successful and new PTU iteration was scheduled");
StartPTExchange();
- return true;
+ return;
}
RefreshRetrySequence();
- return true;
}
CheckAppPolicyResults PolicyManagerImpl::CheckPermissionsChanges(
- const utils::SharedPtr<policy_table::Table> pt_update,
- const utils::SharedPtr<policy_table::Table> snapshot) {
- LOG4CXX_INFO(logger_, "Checking incoming permissions.");
+ const std::shared_ptr<policy_table::Table> pt_update,
+ 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
@@ -379,6 +591,17 @@ CheckAppPolicyResults PolicyManagerImpl::CheckPermissionsChanges(
return out_results;
}
+void PolicyManagerImpl::CheckPermissionsChangesAfterUpdate(
+ const policy_table::Table& update, const policy_table::Table& snapshot) {
+ const auto new_lock_screen_dismissal_enabled =
+ update.policy_table.module_config.lock_screen_dismissal_enabled;
+ const auto old_lock_screen_dismissal_enabled =
+ snapshot.policy_table.module_config.lock_screen_dismissal_enabled;
+ if (new_lock_screen_dismissal_enabled != old_lock_screen_dismissal_enabled) {
+ listener()->OnLockScreenDismissalStateChanged();
+ }
+}
+
void PolicyManagerImpl::ProcessAppPolicyCheckResults(
const CheckAppPolicyResults& results,
const policy_table::ApplicationPolicies& app_policies) {
@@ -393,33 +616,43 @@ void PolicyManagerImpl::ProcessAppPolicyCheckResults(
void PolicyManagerImpl::ProcessActionsForAppPolicies(
const ApplicationsPoliciesActions& actions,
const policy_table::ApplicationPolicies& app_policies) {
- ApplicationsPoliciesActions::const_iterator it_actions = actions.begin();
- for (; it_actions != actions.end(); ++it_actions) {
- policy_table::ApplicationPolicies::const_iterator app_policy =
- app_policies.find(it_actions->first);
+ notify_system_list_.clear();
+ send_permissions_list_.clear();
+
+ for (const auto& action : actions) {
+ const auto& app_policy = app_policies.find(action.first);
if (app_policies.end() == app_policy) {
continue;
}
- if (it_actions->second.is_consent_needed) {
- // Post-check after ExternalConsent consent changes
- const std::string& policy_app_id = app_policy->first;
- if (!IsConsentNeeded(policy_app_id)) {
- sync_primitives::AutoLock lock(app_permissions_diff_lock_);
+ if (action.second.app_properties_changed) {
+ app_properties_changed_list_.push_back(app_policy->first);
+ }
+
+ const auto devices_ids = listener()->GetDevicesIds(app_policy->first);
+ for (const auto& device_id : devices_ids) {
+ if (action.second.is_consent_needed) {
+ // Post-check after ExternalConsent consent changes
+ const auto& policy_app_id = app_policy->first;
+ if (!IsConsentNeeded(device_id, policy_app_id)) {
+ sync_primitives::AutoLock lock(app_permissions_diff_lock_);
- PendingPermissions::iterator app_id_diff =
- app_permissions_diff_.find(policy_app_id);
+ const auto& app_id_diff = app_permissions_diff_.find(policy_app_id);
- if (app_permissions_diff_.end() != app_id_diff) {
- app_id_diff->second.appPermissionsConsentNeeded = false;
+ if (app_permissions_diff_.end() != app_id_diff) {
+ app_id_diff->second.appPermissionsConsentNeeded = false;
+ }
}
}
- }
- if (it_actions->second.is_notify_system) {
- NotifySystem(*app_policy);
- }
- if (it_actions->second.is_send_permissions_to_app) {
- SendPermissionsToApp(*app_policy);
+
+ if (action.second.is_notify_system) {
+ notify_system_list_.push_back(std::make_pair(device_id, *app_policy));
+ }
+
+ if (action.second.is_send_permissions_to_app) {
+ send_permissions_list_.push_back(
+ std::make_pair(device_id, *app_policy));
+ }
}
}
}
@@ -456,19 +689,19 @@ std::string PolicyManagerImpl::GetUpdateUrl(int service_type) {
}
void PolicyManagerImpl::GetUpdateUrls(const std::string& service_type,
- EndpointUrls& out_end_points) {
+ EndpointUrls& out_end_points) const {
LOG4CXX_AUTO_TRACE(logger_);
cache_->GetUpdateUrls(service_type, out_end_points);
}
void PolicyManagerImpl::GetUpdateUrls(const uint32_t service_type,
- EndpointUrls& out_end_points) {
+ EndpointUrls& out_end_points) const {
LOG4CXX_AUTO_TRACE(logger_);
cache_->GetUpdateUrls(service_type, out_end_points);
}
void PolicyManagerImpl::RequestPTUpdate() {
LOG4CXX_AUTO_TRACE(logger_);
- utils::SharedPtr<policy_table::Table> policy_table_snapshot =
+ std::shared_ptr<policy_table::Table> policy_table_snapshot =
cache_->GenerateSnapshot();
if (!policy_table_snapshot) {
LOG4CXX_ERROR(logger_, "Failed to create snapshot of policy table");
@@ -477,13 +710,14 @@ void PolicyManagerImpl::RequestPTUpdate() {
if (IsPTValid(policy_table_snapshot, policy_table::PT_SNAPSHOT)) {
Json::Value value = policy_table_snapshot->ToJsonValue();
- Json::FastWriter writer;
- std::string message_string = writer.write(value);
+ Json::StreamWriterBuilder writer_builder;
+ writer_builder["indentation"] = "";
+ std::string message_string = Json::writeString(writer_builder, value);
LOG4CXX_DEBUG(logger_, "Snapshot contents is : " << message_string);
BinaryMessage update(message_string.begin(), message_string.end());
-
+ ptu_requested_ = true;
listener_->OnSnapshotCreated(
update, RetrySequenceDelaysSeconds(), TimeoutExchangeMSec());
} else {
@@ -517,9 +751,10 @@ void PolicyManagerImpl::StartPTExchange() {
return;
}
LOG4CXX_INFO(logger_, "Policy want to call RequestPTUpdate");
- if (listener_ && listener_->CanUpdate()) {
+ if (listener_) {
LOG4CXX_INFO(logger_, "Listener CanUpdate");
if (update_status_manager_.IsUpdateRequired()) {
+ update_status_manager_.PendingUpdate();
LOG4CXX_INFO(logger_, "IsUpdateRequired");
RequestPTUpdate();
}
@@ -542,11 +777,16 @@ void PolicyManagerImpl::OnAppsSearchCompleted(const bool trigger_ptu) {
}
}
+void PolicyManagerImpl::UpdatePTUReadyAppsCount(const uint32_t new_app_count) {
+ applications_pending_ptu_count_ = new_app_count;
+}
+
const std::vector<std::string> PolicyManagerImpl::GetAppRequestTypes(
+ const transport_manager::DeviceHandle& device_handle,
const std::string policy_app_id) const {
std::vector<std::string> request_types;
- if (kDeviceDisallowed ==
- cache_->GetDeviceConsent(GetCurrentDeviceId(policy_app_id))) {
+ if (kDeviceAllowed != cache_->GetDeviceConsent(
+ GetCurrentDeviceId(device_handle, policy_app_id))) {
cache_->GetAppRequestTypes(kPreDataConsentId, request_types);
} else {
cache_->GetAppRequestTypes(policy_app_id, request_types);
@@ -573,11 +813,83 @@ 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();
+}
+
+std::vector<policy_table::VehicleDataItem>
+PolicyManagerImpl::GetRemovedVehicleDataItems() const {
+ return cache_->GetRemovedVehicleDataItems();
+}
+
+Json::Value PolicyManagerImpl::GetPolicyTableData() const {
+ return cache_->GetPolicyTableData();
+}
+
+void PolicyManagerImpl::GetEnabledCloudApps(
+ std::vector<std::string>& enabled_apps) const {
+ cache_->GetEnabledCloudApps(enabled_apps);
+}
+
+std::vector<std::string> PolicyManagerImpl::GetEnabledLocalApps() const {
+ return cache_->GetEnabledLocalApps();
+}
+
+bool PolicyManagerImpl::GetAppProperties(
+ const std::string& policy_app_id, AppProperties& out_app_properties) const {
+ return cache_->GetAppProperties(policy_app_id, out_app_properties);
+}
+
+void PolicyManagerImpl::InitCloudApp(const std::string& policy_app_id) {
+ cache_->InitCloudApp(policy_app_id);
+}
+
+void PolicyManagerImpl::SetCloudAppEnabled(const std::string& policy_app_id,
+ const bool enabled) {
+ cache_->SetCloudAppEnabled(policy_app_id, enabled);
+}
+
+void PolicyManagerImpl::SetAppAuthToken(const std::string& policy_app_id,
+ const std::string& auth_token) {
+ cache_->SetAppAuthToken(policy_app_id, auth_token);
+}
+
+void PolicyManagerImpl::SetAppCloudTransportType(
+ const std::string& policy_app_id, const std::string& cloud_transport_type) {
+ cache_->SetAppCloudTransportType(policy_app_id, cloud_transport_type);
+}
+
+void PolicyManagerImpl::SetAppEndpoint(const std::string& policy_app_id,
+ const std::string& endpoint) {
+ cache_->SetAppEndpoint(policy_app_id, endpoint);
+}
+
+void PolicyManagerImpl::SetAppNicknames(const std::string& policy_app_id,
+ const StringArray& nicknames) {
+ cache_->SetAppNicknames(policy_app_id, nicknames);
+}
+
+void PolicyManagerImpl::SetHybridAppPreference(
+ const std::string& policy_app_id,
+ const std::string& hybrid_app_preference) {
+ cache_->SetHybridAppPreference(policy_app_id, hybrid_app_preference);
+}
+
+void PolicyManagerImpl::GetAppServiceParameters(
+ const std::string& policy_app_id,
+ policy_table::AppServiceParameters* app_service_parameters) const {
+ cache_->GetAppServiceParameters(policy_app_id, app_service_parameters);
+}
+
+bool PolicyManagerImpl::UnknownRPCPassthroughAllowed(
+ const std::string& policy_app_id) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ return cache_->UnknownRPCPassthroughAllowed(policy_app_id);
}
-void PolicyManagerImpl::CheckPermissions(const PTString& app_id,
+void PolicyManagerImpl::CheckPermissions(const PTString& device_id,
+ const PTString& app_id,
const PTString& hmi_level,
const PTString& rpc,
const RPCParams& rpc_params,
@@ -586,8 +898,6 @@ void PolicyManagerImpl::CheckPermissions(const PTString& app_id,
"CheckPermissions for " << app_id << " and rpc " << rpc
<< " for " << hmi_level << " level.");
- const std::string device_id = GetCurrentDeviceId(app_id);
-
Permissions rpc_permissions;
// Check, if there are calculated permission present in cache
@@ -726,8 +1036,9 @@ void PolicyManagerImpl::CheckPermissions(const PTString& app_id,
for (; end != parameter; ++parameter) {
if (!result.HasParameter(*parameter)) {
LOG4CXX_DEBUG(logger_,
- "Parameter " << *parameter << " is unknown."
- " Adding to undefined list.");
+ "Parameter " << *parameter
+ << " is unknown."
+ " Adding to undefined list.");
result.list_of_undefined_params.insert(*parameter);
}
}
@@ -737,7 +1048,12 @@ void PolicyManagerImpl::CheckPermissions(const PTString& app_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;
+ }
}
}
@@ -756,13 +1072,13 @@ policy_table::Strings PolicyManagerImpl::GetGroupsNames(
}
void PolicyManagerImpl::SendNotificationOnPermissionsUpdated(
- const std::string& application_id) {
+ const std::string& device_id, const std::string& application_id) {
LOG4CXX_AUTO_TRACE(logger_);
- const std::string device_id = GetCurrentDeviceId(application_id);
if (device_id.empty()) {
LOG4CXX_WARN(logger_,
"Couldn't find device info for application id "
- "'" << application_id << "'");
+ "'" << application_id
+ << "'");
return;
}
@@ -785,15 +1101,16 @@ void PolicyManagerImpl::SendNotificationOnPermissionsUpdated(
const ApplicationOnDevice who = {device_id, application_id};
if (access_remote_->IsAppRemoteControl(who)) {
- listener()->OnPermissionsUpdated(application_id, notification_data);
+ listener()->OnPermissionsUpdated(
+ device_id, application_id, notification_data);
return;
}
std::string default_hmi;
- GetDefaultHmi(application_id, &default_hmi);
+ GetDefaultHmi(device_id, application_id, &default_hmi);
listener()->OnPermissionsUpdated(
- application_id, notification_data, default_hmi);
+ device_id, application_id, notification_data, default_hmi);
}
bool PolicyManagerImpl::CleanupUnpairedDevices() {
@@ -819,21 +1136,25 @@ void PolicyManagerImpl::SetUserConsentForDevice(const std::string& device_id,
"Event listener is not initialized. "
"Can't call OnDeviceConsentChanged");
}
- if (is_allowed) {
+ if (is_allowed && listener_->CanUpdate()) {
update_status_manager_.OnDeviceConsented();
}
StartPTExchange();
}
bool PolicyManagerImpl::ReactOnUserDevConsentForApp(
- const std::string& app_id, const bool is_device_allowed) {
- std::vector<std::string> current_request_types = GetAppRequestTypes(app_id);
+ const transport_manager::DeviceHandle& device_handle,
+ const std::string& app_id,
+ const bool is_device_allowed) {
+ std::vector<std::string> current_request_types =
+ GetAppRequestTypes(device_handle, app_id);
std::string current_priority, new_priority;
GetPriority(app_id, &current_priority);
bool result = cache_->ReactOnUserDevConsentForApp(app_id, is_device_allowed);
- std::vector<std::string> new_request_types = GetAppRequestTypes(app_id);
+ std::vector<std::string> new_request_types =
+ GetAppRequestTypes(device_handle, app_id);
GetPriority(app_id, &new_priority);
std::sort(current_request_types.begin(), current_request_types.end());
std::sort(new_request_types.begin(), new_request_types.end());
@@ -858,7 +1179,8 @@ bool PolicyManagerImpl::ReactOnUserDevConsentForApp(
}
if (permissions.requestTypeChanged || (!permissions.priority.empty())) {
- listener_->SendOnAppPermissionsChanged(permissions, app_id);
+ const auto& device_id = GetCurrentDeviceId(device_handle, app_id);
+ listener_->SendOnAppPermissionsChanged(permissions, device_id, app_id);
}
return result;
}
@@ -883,6 +1205,12 @@ void PolicyManagerImpl::AddDevice(const std::string& device_id,
}
}
+void PolicyManagerImpl::OnLocalAppAdded() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ update_status_manager_.ScheduleUpdate();
+ StartPTExchange();
+}
+
void PolicyManagerImpl::SetDeviceInfo(const std::string& device_id,
const DeviceInfo& device_info) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -976,6 +1304,7 @@ void PolicyManagerImpl::CheckPendingPermissionsChanges(
}
void PolicyManagerImpl::NotifyPermissionsChanges(
+ const std::string& device_id,
const std::string& policy_app_id,
const std::vector<FunctionalGroupPermission>& app_group_permissions) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -991,7 +1320,7 @@ void PolicyManagerImpl::NotifyPermissionsChanges(
PrepareNotificationData(
functional_groups, app_groups, app_group_permissions, notification_data);
- listener()->OnPermissionsUpdated(policy_app_id, notification_data);
+ listener()->OnPermissionsUpdated(device_id, policy_app_id, notification_data);
}
void PolicyManagerImpl::SetUserConsentForApp(
@@ -1030,14 +1359,64 @@ void PolicyManagerImpl::SetUserConsentForApp(
CheckPendingPermissionsChanges(verified_permissions.policy_app_id,
updated_app_group_permissons);
- NotifyPermissionsChanges(verified_permissions.policy_app_id,
+ NotifyPermissionsChanges(verified_permissions.device_id,
+ verified_permissions.policy_app_id,
updated_app_group_permissons);
}
-bool PolicyManagerImpl::GetDefaultHmi(const std::string& policy_app_id,
+bool PolicyManagerImpl::IsAllowedRetryCountExceeded() const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock auto_lock(retry_sequence_lock_);
+
+ return retry_sequence_index_ > retry_sequence_seconds_.size();
+}
+
+void PolicyManagerImpl::IncrementRetryIndex() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock auto_lock(retry_sequence_lock_);
+
+ if (!is_ptu_in_progress_) {
+ LOG4CXX_TRACE(logger_,
+ "First PTU iteration, skipping incrementing retry index");
+ is_ptu_in_progress_ = true;
+ return;
+ }
+
+ ++retry_sequence_index_;
+ LOG4CXX_DEBUG(logger_,
+ "current retry_sequence_index_ is: " << retry_sequence_index_);
+}
+
+void PolicyManagerImpl::RetrySequenceFailed() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ listener_->OnPTUFinished(false);
+ ResetRetrySequence(ResetRetryCountType::kResetWithStatusUpdate);
+
+ ptu_requested_ = false;
+ if (HasApplicationForPTU()) {
+ update_status_manager_.OnExistedApplicationAdded(true);
+ StartPTExchange();
+ }
+}
+
+void PolicyManagerImpl::ResetTimeout() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (update_status_manager_.IsUpdatePending()) {
+ uint32_t update_timeout = TimeoutExchangeMSec();
+ update_status_manager_.ResetTimeout(update_timeout);
+ }
+}
+
+void PolicyManagerImpl::OnSystemRequestReceived() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ IncrementRetryIndex();
+}
+
+bool PolicyManagerImpl::GetDefaultHmi(const std::string& device_id,
+ const std::string& policy_app_id,
std::string* default_hmi) const {
LOG4CXX_AUTO_TRACE(logger_);
- const std::string device_id = GetCurrentDeviceId(policy_app_id);
DeviceConsent device_consent = GetUserConsentForDevice(device_id);
const std::string app_id = policy::kDeviceAllowed != device_consent
? kPreDataConsentId
@@ -1098,10 +1477,6 @@ void PolicyManagerImpl::GetUserConsentForApp(
FunctionalGroupIDs preconsented_groups = group_types[kTypePreconsented];
FunctionalGroupIDs consent_allowed_groups = group_types[kTypeAllowed];
FunctionalGroupIDs consent_disallowed_groups = group_types[kTypeDisallowed];
- FunctionalGroupIDs default_groups = group_types[kTypeDefault];
- FunctionalGroupIDs predataconsented_groups =
- group_types[kTypePreDataConsented];
- FunctionalGroupIDs device_groups = group_types[kTypeDevice];
// Sorting groups by consent
FunctionalGroupIDs preconsented_wo_auto =
@@ -1113,15 +1488,8 @@ void PolicyManagerImpl::GetUserConsentForApp(
FunctionalGroupIDs allowed_groups =
Merge(consent_allowed_groups, preconsented_wo_disallowed_auto);
- FunctionalGroupIDs merged_stage_1 =
- Merge(default_groups, predataconsented_groups);
-
- FunctionalGroupIDs merged_stage_2 = Merge(merged_stage_1, device_groups);
-
- FunctionalGroupIDs merged_stage_3 =
- Merge(merged_stage_2, auto_allowed_groups);
-
- FunctionalGroupIDs excluded_stage_1 = ExcludeSame(all_groups, merged_stage_3);
+ FunctionalGroupIDs excluded_stage_1 =
+ ExcludeSame(all_groups, auto_allowed_groups);
FunctionalGroupIDs excluded_stage_2 =
ExcludeSame(excluded_stage_1, consent_disallowed_groups);
@@ -1153,11 +1521,13 @@ void PolicyManagerImpl::GetPermissionsForApp(
}
bool allowed_by_default = false;
- if (cache_->IsDefaultPolicy(policy_app_id)) {
+ const auto device_consent = GetUserConsentForDevice(device_id);
+ if ((policy::kDeviceAllowed == device_consent) &&
+ cache_->IsDefaultPolicy(policy_app_id)) {
app_id_to_check = kDefaultId;
allowed_by_default = true;
} else if (cache_->IsPredataPolicy(policy_app_id) ||
- policy::kDeviceDisallowed == GetUserConsentForDevice(device_id)) {
+ policy::kDeviceAllowed != device_consent) {
app_id_to_check = kPreDataConsentId;
allowed_by_default = true;
}
@@ -1241,9 +1611,11 @@ void PolicyManagerImpl::GetPermissionsForApp(
}
std::string& PolicyManagerImpl::GetCurrentDeviceId(
+ const transport_manager::DeviceHandle& device_handle,
const std::string& policy_app_id) const {
LOG4CXX_INFO(logger_, "GetDeviceInfo");
- last_device_id_ = listener()->OnCurrentDeviceIdUpdateRequired(policy_app_id);
+ last_device_id_ =
+ listener()->OnCurrentDeviceIdUpdateRequired(device_handle, policy_app_id);
return last_device_id_;
}
@@ -1258,13 +1630,6 @@ void PolicyManagerImpl::SetSystemInfo(const std::string& ccpu_version,
cache_->SetMetaInfo(ccpu_version, wers_country_code, language);
}
-void PolicyManagerImpl::OnSystemReady() {
- // Update policy table for the first time with system information
- if (!cache_->IsMetaInfoPresent()) {
- listener()->OnSystemInfoUpdateRequired();
- }
-}
-
uint32_t PolicyManagerImpl::GetNotificationsNumber(
const std::string& priority) const {
LOG4CXX_AUTO_TRACE(logger_);
@@ -1276,7 +1641,7 @@ bool PolicyManagerImpl::ExceededIgnitionCycles() {
}
bool PolicyManagerImpl::IsPTValid(
- utils::SharedPtr<policy_table::Table> policy_table,
+ std::shared_ptr<policy_table::Table> policy_table,
policy_table::PolicyTableType type) const {
policy_table->SetPolicyTableType(type);
if (!policy_table->is_valid()) {
@@ -1289,6 +1654,10 @@ bool PolicyManagerImpl::IsPTValid(
return true;
}
+bool PolicyManagerImpl::HasApplicationForPTU() const {
+ return applications_pending_ptu_count_ > 0;
+}
+
const PolicySettings& PolicyManagerImpl::get_settings() const {
DCHECK(settings_);
return *settings_;
@@ -1346,16 +1715,42 @@ void PolicyManagerImpl::UpdateAppConsentWithExternalConsent(
cache_->SetExternalConsentForApp(updated_external_consent_permissions);
}
+void PolicyManagerImpl::SendOnAppPropertiesChangeNotification(
+ const std::string& policy_app_id) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ listener_->SendOnAppPropertiesChangeNotification(policy_app_id);
+}
+
+void PolicyManagerImpl::ResumePendingAppPolicyActions() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ for (auto& notify_system_params : notify_system_list_) {
+ NotifySystem(notify_system_params.first, notify_system_params.second);
+ }
+ notify_system_list_.clear();
+
+ for (auto& send_permissions_params : send_permissions_list_) {
+ SendPermissionsToApp(send_permissions_params.first,
+ send_permissions_params.second);
+ }
+
+ for (auto& app : app_properties_changed_list_) {
+ SendOnAppPropertiesChangeNotification(app);
+ }
+ send_permissions_list_.clear();
+}
+
void PolicyManagerImpl::NotifySystem(
+ const std::string& device_id,
const PolicyManagerImpl::AppPoliciesValueType& app_policy) const {
- listener()->OnPendingPermissionChange(app_policy.first);
+ listener()->OnPendingPermissionChange(device_id, app_policy.first);
}
void PolicyManagerImpl::SendPermissionsToApp(
+ const std::string& device_id,
const PolicyManagerImpl::AppPoliciesValueType& app_policy) {
const std::string app_id = app_policy.first;
- const std::string device_id = GetCurrentDeviceId(app_id);
if (device_id.empty()) {
LOG4CXX_WARN(logger_,
"Couldn't find device info for application id: " << app_id);
@@ -1367,7 +1762,7 @@ void PolicyManagerImpl::SendPermissionsToApp(
Permissions notification_data;
// Need to get rid of this call
- utils::SharedPtr<policy_table::Table> policy_table_snapshot =
+ std::shared_ptr<policy_table::Table> policy_table_snapshot =
cache_->GenerateSnapshot();
PrepareNotificationData(
@@ -1378,6 +1773,7 @@ void PolicyManagerImpl::SendPermissionsToApp(
LOG4CXX_INFO(logger_, "Send notification for application_id: " << app_id);
listener()->OnPermissionsUpdated(
+ device_id,
app_id,
notification_data,
policy_table::EnumToJsonString(app_policy.second.default_hmi));
@@ -1496,9 +1892,9 @@ void PolicyManagerImpl::CalculateGroupsConsentFromExternalConsent(
bool PolicyManagerImpl::ExceededDays() {
LOG4CXX_AUTO_TRACE(logger_);
- TimevalStruct current_time = date_time::DateTime::getCurrentTime();
+ date_time::TimeDuration current_time = date_time::getCurrentTime();
const int kSecondsInDay = 60 * 60 * 24;
- const int days = current_time.tv_sec / kSecondsInDay;
+ const int days = date_time::getSecs(current_time) / kSecondsInDay;
DCHECK(std::numeric_limits<uint16_t>::max() >= days);
@@ -1519,6 +1915,19 @@ void PolicyManagerImpl::KmsChanged(int kilometers) {
}
}
+const boost::optional<bool> PolicyManagerImpl::LockScreenDismissalEnabledState()
+ const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ return cache_->LockScreenDismissalEnabledState();
+}
+
+const boost::optional<std::string>
+PolicyManagerImpl::LockScreenDismissalWarningMessage(
+ const std::string& language) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ return cache_->LockScreenDismissalWarningMessage(language);
+}
+
void PolicyManagerImpl::IncrementIgnitionCycles() {
cache_->IncrementIgnitionCycles();
}
@@ -1529,6 +1938,14 @@ std::string PolicyManagerImpl::ForcePTExchange() {
return update_status_manager_.StringifiedUpdateStatus();
}
+void policy::PolicyManagerImpl::StopRetrySequence() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ if (cache_->UpdateRequired()) {
+ ResetRetrySequence(ResetRetryCountType::kResetWithStatusUpdate);
+ }
+}
+
std::string PolicyManagerImpl::ForcePTExchangeAtUserRequest() {
LOG4CXX_AUTO_TRACE(logger_);
update_status_manager_.ScheduleManualUpdate();
@@ -1544,10 +1961,11 @@ int PolicyManagerImpl::NextRetryTimeout() {
sync_primitives::AutoLock auto_lock(retry_sequence_lock_);
LOG4CXX_DEBUG(logger_, "Index: " << retry_sequence_index_);
int next = 0;
+
if (!retry_sequence_seconds_.empty() &&
retry_sequence_index_ < retry_sequence_seconds_.size()) {
- next = retry_sequence_seconds_[retry_sequence_index_];
- ++retry_sequence_index_;
+ next = retry_sequence_seconds_[retry_sequence_index_] *
+ date_time::MILLISECONDS_IN_SECOND;
}
return next;
}
@@ -1559,10 +1977,15 @@ void PolicyManagerImpl::RefreshRetrySequence() {
cache_->SecondsBetweenRetries(retry_sequence_seconds_);
}
-void PolicyManagerImpl::ResetRetrySequence() {
+void PolicyManagerImpl::ResetRetrySequence(
+ const ResetRetryCountType reset_type) {
+ LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock auto_lock(retry_sequence_lock_);
retry_sequence_index_ = 0;
- update_status_manager_.OnResetRetrySequence();
+ is_ptu_in_progress_ = false;
+ if (ResetRetryCountType::kResetWithStatusUpdate == reset_type) {
+ update_status_manager_.OnResetRetrySequence();
+ }
}
uint32_t PolicyManagerImpl::TimeoutExchangeMSec() {
@@ -1575,6 +1998,8 @@ const std::vector<int> PolicyManagerImpl::RetrySequenceDelaysSeconds() {
}
void PolicyManagerImpl::OnExceededTimeout() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
update_status_manager_.OnUpdateTimeoutOccurs();
}
@@ -1582,7 +2007,8 @@ void PolicyManagerImpl::OnUpdateStarted() {
uint32_t update_timeout = TimeoutExchangeMSec();
LOG4CXX_DEBUG(logger_,
"Update timeout will be set to (milisec): " << update_timeout);
- send_on_update_sent_out_ = !update_status_manager_.IsUpdatePending();
+ send_on_update_sent_out_ =
+ policy::kUpdating != update_status_manager_.StringifiedUpdateStatus();
if (send_on_update_sent_out_) {
update_status_manager_.OnUpdateSentOut(update_timeout);
@@ -1625,10 +2051,10 @@ bool PolicyManagerImpl::IsApplicationRevoked(const std::string& app_id) const {
return cache_->IsApplicationRevoked(app_id);
}
-bool PolicyManagerImpl::IsConsentNeeded(const std::string& app_id) {
+bool PolicyManagerImpl::IsConsentNeeded(const std::string& device_id,
+ const std::string& app_id) {
LOG4CXX_AUTO_TRACE(logger_);
- const std::string device_id = GetCurrentDeviceId(app_id);
- int count = cache_->CountUnconsentedGroups(app_id, device_id);
+ const int count = cache_->CountUnconsentedGroups(app_id, device_id);
LOG4CXX_DEBUG(logger_, "There are: " << count << " unconsented groups.");
return count != 0;
}
@@ -1638,7 +2064,7 @@ void PolicyManagerImpl::SetVINValue(const std::string& value) {
}
AppPermissions PolicyManagerImpl::GetAppPermissionsChanges(
- const std::string& policy_app_id) {
+ const std::string& device_id, const std::string& policy_app_id) {
PendingPermissions::iterator app_id_diff =
app_permissions_diff_.find(policy_app_id);
@@ -1647,8 +2073,10 @@ AppPermissions PolicyManagerImpl::GetAppPermissionsChanges(
if (app_permissions_diff_.end() != app_id_diff) {
permissions = app_id_diff->second;
} else {
- permissions.appPermissionsConsentNeeded = IsConsentNeeded(policy_app_id);
+ permissions.appPermissionsConsentNeeded =
+ IsConsentNeeded(device_id, policy_app_id);
permissions.appRevoked = IsApplicationRevoked(policy_app_id);
+ permissions.isSDLAllowed = false;
GetPriority(permissions.application_id, &permissions.priority);
}
return permissions;
@@ -1676,9 +2104,11 @@ void PolicyManagerImpl::MarkUnpairedDevice(const std::string& device_id) {
}
void PolicyManagerImpl::OnAppRegisteredOnMobile(
- const std::string& application_id) {
- StartPTExchange();
- SendNotificationOnPermissionsUpdated(application_id);
+ const std::string& device_id, const std::string& application_id) {
+ if (!is_ptu_in_progress_) {
+ StartPTExchange();
+ }
+ SendNotificationOnPermissionsUpdated(device_id, application_id);
}
void PolicyManagerImpl::OnDeviceSwitching(const std::string& device_id_from,
@@ -1767,20 +2197,27 @@ class CallStatusChange : public utils::Callable {
};
StatusNotifier PolicyManagerImpl::AddApplication(
+ const std::string& device_id,
const std::string& application_id,
const rpc::policy_table_interface_base::AppHmiTypes& hmi_types) {
LOG4CXX_AUTO_TRACE(logger_);
- const std::string device_id = GetCurrentDeviceId(application_id);
- DeviceConsent device_consent = GetUserConsentForDevice(device_id);
+ auto device_consent = GetUserConsentForDevice(device_id);
+ LOG4CXX_DEBUG(logger_,
+ "check_device_id: " << device_id << " check_device_consent: "
+ << device_consent);
sync_primitives::AutoLock lock(apps_registration_lock_);
if (IsNewApplication(application_id)) {
- AddNewApplication(application_id, device_consent);
- return utils::MakeShared<CallStatusChange>(update_status_manager_,
- device_consent);
- } else {
- PromoteExistedApplication(application_id, device_consent);
- return utils::MakeShared<utils::CallNothing>();
+ LOG4CXX_DEBUG(logger_, "Adding new application");
+ AddNewApplication(device_id, application_id, device_consent);
+ return std::make_shared<CallStatusChange>(update_status_manager_,
+ device_consent);
+ }
+ LOG4CXX_DEBUG(logger_, "Promote existed application");
+ PromoteExistedApplication(device_id, application_id, device_consent);
+ if (!ptu_requested_) {
+ update_status_manager_.OnExistedApplicationAdded(cache_->UpdateRequired());
}
+ return std::make_shared<utils::CallNothing>();
}
void PolicyManagerImpl::RemoveAppConsentForGroup(
@@ -1795,6 +2232,7 @@ bool PolicyManagerImpl::IsPredataPolicy(
}
void PolicyManagerImpl::ProcessExternalConsentStatusForApp(
+ const std::string& device_id,
const std::string& application_id,
const ConsentProcessingPolicy processing_policy) {
ExternalConsentStatus status = cache_->GetExternalConsentStatus();
@@ -1806,7 +2244,7 @@ void PolicyManagerImpl::ProcessExternalConsentStatusForApp(
CalculateGroupsConsentFromExternalConsent(
groups_by_status, allowed_groups, disallowed_groups);
- const std::string device_id = GetCurrentDeviceId(application_id);
+ LOG4CXX_DEBUG(logger_, "check device_id: " << device_id);
UpdateAppConsentWithExternalConsent(device_id,
application_id,
allowed_groups,
@@ -1814,7 +2252,8 @@ void PolicyManagerImpl::ProcessExternalConsentStatusForApp(
processing_policy);
}
-void PolicyManagerImpl::AddNewApplication(const std::string& application_id,
+void PolicyManagerImpl::AddNewApplication(const std::string& device_id,
+ const std::string& application_id,
DeviceConsent device_consent) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -1834,19 +2273,31 @@ void PolicyManagerImpl::AddNewApplication(const std::string& application_id,
}
ProcessExternalConsentStatusForApp(
- application_id, ConsentProcessingPolicy::kExternalConsentBased);
+ device_id,
+ application_id,
+ ConsentProcessingPolicy::kExternalConsentBased);
}
void PolicyManagerImpl::PromoteExistedApplication(
- const std::string& application_id, DeviceConsent device_consent) {
+ const std::string& device_id,
+ const std::string& application_id,
+ DeviceConsent device_consent) {
// If device consent changed to allowed during application being
// disconnected, app permissions should be changed also
+ LOG4CXX_DEBUG(logger_,
+ "kDeviceAllowed == device_consent: "
+ << (kDeviceAllowed == device_consent)
+ << " device_consent: " << device_consent);
if (kDeviceAllowed == device_consent &&
cache_->IsPredataPolicy(application_id)) {
+ LOG4CXX_INFO(logger_,
+ "Setting "
+ << policy::kDefaultId
+ << " permissions for application id: " << application_id);
cache_->SetDefaultPolicy(application_id);
}
- ProcessExternalConsentStatusForApp(application_id,
- ConsentProcessingPolicy::kTimestampBased);
+ ProcessExternalConsentStatusForApp(
+ device_id, application_id, ConsentProcessingPolicy::kTimestampBased);
}
bool PolicyManagerImpl::IsNewApplication(
@@ -1894,7 +2345,11 @@ bool PolicyManagerImpl::InitPT(const std::string& file_name,
const bool ret = cache_->Init(file_name, settings);
if (ret) {
RefreshRetrySequence();
- update_status_manager_.OnPolicyInit(cache_->UpdateRequired());
+ std::vector<std::string> enabled_cloud_apps;
+ cache_->GetEnabledCloudApps(enabled_cloud_apps);
+ for (auto app : enabled_cloud_apps) {
+ SendAuthTokenUpdated(app);
+ }
}
return ret;
}
@@ -1904,12 +2359,17 @@ uint32_t PolicyManagerImpl::HeartBeatTimeout(const std::string& app_id) const {
}
void PolicyManagerImpl::SaveUpdateStatusRequired(bool is_update_needed) {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ if (!is_update_needed) {
+ ResetRetrySequence(ResetRetryCountType::kResetInternally);
+ }
cache_->SaveUpdateRequired(is_update_needed);
}
void PolicyManagerImpl::set_cache_manager(
CacheManagerInterface* cache_manager) {
- cache_ = cache_manager;
+ cache_ = std::shared_ptr<CacheManagerInterface>(cache_manager);
}
std::ostream& operator<<(std::ostream& output,
@@ -1922,10 +2382,12 @@ std::ostream& operator<<(std::ostream& output,
return output;
}
-void PolicyManagerImpl::SetDefaultHmiTypes(const std::string& application_id,
- const std::vector<int>& hmi_types) {
+void PolicyManagerImpl::SetDefaultHmiTypes(
+ const transport_manager::DeviceHandle& device_handle,
+ const std::string& application_id,
+ const std::vector<int>& hmi_types) {
LOG4CXX_INFO(logger_, "SetDefaultHmiTypes");
- const std::string device_id = GetCurrentDeviceId(application_id);
+ const auto device_id = GetCurrentDeviceId(device_handle, application_id);
ApplicationOnDevice who = {device_id, application_id};
access_remote_->SetDefaultHmiTypes(who, hmi_types);
}
@@ -1963,12 +2425,12 @@ bool PolicyManagerImpl::CheckModule(const PTString& app_id,
void PolicyManagerImpl::SendHMILevelChanged(const ApplicationOnDevice& who) {
std::string default_hmi("NONE");
- if (GetDefaultHmi(who.app_id, &default_hmi)) {
+ if (GetDefaultHmi(who.dev_id, who.app_id, &default_hmi)) {
listener()->OnUpdateHMIStatus(who.dev_id, who.app_id, default_hmi);
} else {
- LOG4CXX_WARN(logger_,
- "Couldn't get default HMI level for application "
- << who.app_id);
+ LOG4CXX_WARN(
+ logger_,
+ "Couldn't get default HMI level for application " << who.app_id);
}
}
@@ -2000,7 +2462,14 @@ void PolicyManagerImpl::SendAppPermissionsChanged(
const std::string& device_id, const std::string& application_id) {
Permissions notification_data;
GetPermissions(device_id, application_id, &notification_data);
- listener()->OnPermissionsUpdated(application_id, notification_data);
+ listener()->OnPermissionsUpdated(
+ device_id, application_id, notification_data);
+}
+
+void PolicyManagerImpl::SendAuthTokenUpdated(const std::string policy_app_id) {
+ AppProperties app_properties;
+ cache_->GetAppProperties(policy_app_id, app_properties);
+ listener_->OnAuthTokenUpdated(policy_app_id, app_properties.auth_token);
}
void PolicyManagerImpl::OnPrimaryGroupsChanged(
@@ -2024,8 +2493,108 @@ bool PolicyManagerImpl::GetModuleTypes(
}
void PolicyManagerImpl::set_access_remote(
- utils::SharedPtr<AccessRemote> access_remote) {
+ std::shared_ptr<AccessRemote> access_remote) {
access_remote_ = access_remote;
}
+bool PolicyManagerImpl::AppNeedEncryption(
+ const std::string& policy_app_id) const {
+ const auto encryption_required =
+ cache_->GetAppEncryptionRequiredFlag(policy_app_id);
+
+ return encryption_required.is_initialized() ? *encryption_required : true;
+}
+
+const rpc::Optional<rpc::Boolean> PolicyManagerImpl::GetAppEncryptionRequired(
+ const std::string& policy_app_id) const {
+ return cache_->GetAppEncryptionRequiredFlag(policy_app_id);
+}
+
+const std::vector<std::string> PolicyManagerImpl::GetFunctionalGroupsForApp(
+ const std::string& policy_app_id) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ using namespace rpc::policy_table_interface_base;
+ DCHECK(kDeviceId != policy_app_id);
+
+ std::vector<std::string> function_groups;
+
+ ApplicationParams app_params;
+ cache_->GetApplicationParams(policy_app_id, app_params);
+
+ const auto& policy_function_group = app_params.groups;
+
+ for (const auto& group : policy_function_group) {
+ function_groups.push_back(group);
+ }
+
+ return function_groups;
+}
+
+const std::vector<std::string> PolicyManagerImpl::GetApplicationPolicyIDs()
+ const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ std::vector<std::string> policy_app_ids;
+
+ const auto apps = cache_->GetPolicyAppIDs();
+
+ for (const auto& app : apps) {
+ policy_app_ids.push_back(app);
+ }
+
+ return policy_app_ids;
+}
+
+bool PolicyManagerImpl::FunctionGroupNeedEncryption(
+ const std::string& policy_group) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ FunctionalGroupings functional_groupings;
+ cache_->GetFunctionalGroupings(functional_groupings);
+
+ const auto& grouping_itr = functional_groupings.find(policy_group);
+
+ if (grouping_itr == functional_groupings.end()) {
+ LOG4CXX_WARN(logger_, "Group " << policy_group << " not found");
+ return false;
+ }
+
+ const auto& grouping = (*grouping_itr).second;
+
+ return grouping.encryption_required.is_initialized()
+ ? *grouping.encryption_required
+ : false;
+}
+
+const std::string PolicyManagerImpl::GetPolicyFunctionName(
+ const uint32_t function_id) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ return policy_table::EnumToJsonString(
+ static_cast<policy_table::FunctionID>(function_id));
+}
+
+const std::vector<std::string> PolicyManagerImpl::GetRPCsForFunctionGroup(
+ const std::string& group) const {
+ std::vector<std::string> rpcs_for_group;
+
+ FunctionalGroupings functional_groupings;
+ cache_->GetFunctionalGroupings(functional_groupings);
+
+ const auto& rpcs = functional_groupings[group].rpcs;
+
+ for (const auto& rpc : rpcs) {
+ rpcs_for_group.push_back(rpc.first);
+ }
+
+ return rpcs_for_group;
+}
+
} // namespace policy
+
+__attribute__((visibility("default"))) policy::PolicyManager* CreateManager() {
+ return new policy::PolicyManagerImpl();
+}
+
+__attribute__((visibility("default"))) void DeleteManager(
+ policy::PolicyManager* pm) {
+ delete pm;
+ DELETE_THREAD_LOGGER(policy::logger_);
+}
diff --git a/src/components/policy/policy_external/src/policy_table.cc b/src/components/policy/policy_external/src/policy_table.cc
index 7a63fac50d..8ca6b698d1 100644
--- a/src/components/policy/policy_external/src/policy_table.cc
+++ b/src/components/policy/policy_external/src/policy_table.cc
@@ -42,7 +42,7 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "Policy")
PolicyTable::PolicyTable() : pt_data_(new SQLPTExtRepresentation()) {}
-PolicyTable::PolicyTable(utils::SharedPtr<PTRepresentation> pt_data)
+PolicyTable::PolicyTable(std::shared_ptr<PTRepresentation> pt_data)
: pt_data_(pt_data) {}
PolicyTable::~PolicyTable() {
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 cb724e93b1..8f5d58aad2 100644
--- a/src/components/policy/policy_external/src/policy_table/enums.cc
+++ b/src/components/policy/policy_external/src/policy_table/enums.cc
@@ -1,535 +1,8 @@
#include "policy/policy_table/enums.h"
+#include <cstring>
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_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_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 ("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_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_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_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_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 ("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 ("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) {
@@ -541,6 +14,7 @@ bool IsValidEnum(Input val) {
return false;
}
}
+
const char* EnumToJsonString(Input val) {
switch (val) {
case I_GUI:
@@ -563,234 +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_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;
- default:
- return false;
- }
-}
-const char* EnumToJsonString(ModuleType val) {
- switch (val) {
- case MT_CLIMATE:
- return "CLIMATE";
- case MT_RADIO:
- return "RADIO";
- 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 {
- 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 8c4f454dfa..f0ea154f94 100644
--- a/src/components/policy/policy_external/src/policy_table/types.cc
+++ b/src/components/policy/policy_external/src/policy_table/types.cc
@@ -1,5 +1,5 @@
-#include <algorithm>
#include "policy/policy_table/types.h"
+#include <algorithm>
#include "rpc_base/rpc_base_json_inl.h"
namespace rpc {
@@ -45,7 +45,6 @@ PolicyBase::PolicyBase(const Json::Value* value__)
, default_hmi(impl::ValueMember(value__, "default_hmi"))
, keep_context(impl::ValueMember(value__, "keep_context"))
, steal_focus(impl::ValueMember(value__, "steal_focus")) {}
-
Json::Value PolicyBase::ToJsonValue() const {
Json::Value result__(Json::objectValue);
impl::WriteJsonField("groups", groups, &result__);
@@ -221,6 +220,110 @@ void ApplicationPoliciesSection::SetPolicyTableType(PolicyTableType pt_type) {
apps.SetPolicyTableType(pt_type);
}
+// Handled RPC Methods
+AppServiceHandledRpc::AppServiceHandledRpc() : CompositeType(kUninitialized) {}
+
+AppServiceHandledRpc::~AppServiceHandledRpc() {}
+
+AppServiceHandledRpc::AppServiceHandledRpc(const Json::Value* value__)
+ : CompositeType(InitHelper(value__, &Json::Value::isObject))
+ , function_id(impl::ValueMember(value__, "function_id")) {}
+
+Json::Value AppServiceHandledRpc::ToJsonValue() const {
+ Json::Value result__(Json::objectValue);
+ impl::WriteJsonField("function_id", function_id, &result__);
+ return result__;
+}
+
+bool AppServiceHandledRpc::is_valid() const {
+ if (!function_id.is_valid()) {
+ return false;
+ }
+ return Validate();
+}
+
+bool AppServiceHandledRpc::is_initialized() const {
+ return (initialization_state__ != kUninitialized) || (!struct_empty());
+}
+
+bool AppServiceHandledRpc::struct_empty() const {
+ if (function_id.is_initialized()) {
+ return false;
+ }
+ return true;
+}
+
+void AppServiceHandledRpc::SetPolicyTableType(PolicyTableType pt_type) {
+ function_id.SetPolicyTableType(pt_type);
+}
+
+void AppServiceHandledRpc::ReportErrors(rpc::ValidationReport* report__) const {
+ if (struct_empty()) {
+ rpc::CompositeType::ReportErrors(report__);
+ }
+ if (!function_id.is_valid()) {
+ function_id.ReportErrors(&report__->ReportSubobject("function_id"));
+ }
+}
+
+// AppServiceInfo methods
+AppServiceInfo::AppServiceInfo() : CompositeType(kUninitialized) {}
+
+AppServiceInfo::~AppServiceInfo() {}
+
+AppServiceInfo::AppServiceInfo(const Json::Value* value__)
+ : CompositeType(InitHelper(value__, &Json::Value::isObject))
+ , service_names(impl::ValueMember(value__, "service_names"))
+ , handled_rpcs(impl::ValueMember(value__, "handled_rpcs")) {}
+
+Json::Value AppServiceInfo::ToJsonValue() const {
+ Json::Value result__(Json::objectValue);
+ impl::WriteJsonField("service_names", service_names, &result__);
+ impl::WriteJsonField("parameters", handled_rpcs, &result__);
+ return result__;
+}
+
+bool AppServiceInfo::is_valid() const {
+ if (!service_names.is_valid()) {
+ return false;
+ }
+ if (!handled_rpcs.is_valid()) {
+ return false;
+ }
+ return Validate();
+}
+
+bool AppServiceInfo::is_initialized() const {
+ return (initialization_state__ != kUninitialized) || (!struct_empty());
+}
+
+bool AppServiceInfo::struct_empty() const {
+ if (service_names.is_initialized()) {
+ return false;
+ }
+ if (handled_rpcs.is_initialized()) {
+ return false;
+ }
+ return true;
+}
+
+void AppServiceInfo::SetPolicyTableType(PolicyTableType pt_type) {
+ service_names.SetPolicyTableType(pt_type);
+ handled_rpcs.SetPolicyTableType(pt_type);
+}
+
+void AppServiceInfo::ReportErrors(rpc::ValidationReport* report__) const {
+ if (struct_empty()) {
+ rpc::CompositeType::ReportErrors(report__);
+ }
+ if (!service_names.is_valid()) {
+ service_names.ReportErrors(&report__->ReportSubobject("service_names"));
+ }
+ if (!handled_rpcs.is_valid()) {
+ handled_rpcs.ReportErrors(&report__->ReportSubobject("handled_rpcs"));
+ }
+}
+
// ApplicationParams methods
ApplicationParams::ApplicationParams() : PolicyBase() {}
@@ -241,7 +344,18 @@ ApplicationParams::ApplicationParams(const Json::Value* value__)
, RequestSubType(impl::ValueMember(value__, "RequestSubType"))
, memory_kb(impl::ValueMember(value__, "memory_kb"), 0)
, heart_beat_timeout_ms(impl::ValueMember(value__, "heart_beat_timeout_ms"))
- , moduleType(impl::ValueMember(value__, "moduleType")) {}
+ , moduleType(impl::ValueMember(value__, "moduleType"))
+ , certificate(impl::ValueMember(value__, "certificate"))
+ , hybrid_app_preference(impl::ValueMember(value__, "hybrid_app_preference"))
+ , endpoint(impl::ValueMember(value__, "endpoint"))
+ , enabled(impl::ValueMember(value__, "enabled"))
+ , auth_token(impl::ValueMember(value__, "auth_token"))
+ , cloud_transport_type(impl::ValueMember(value__, "cloud_transport_type"))
+ , icon_url(impl::ValueMember(value__, "icon_url"))
+ , app_service_parameters(impl::ValueMember(value__, "app_services"))
+ , allow_unknown_rpc_passthrough(
+ impl::ValueMember(value__, "allow_unknown_rpc_passthrough"))
+ , encryption_required(impl::ValueMember(value__, "encryption_required")) {}
Json::Value ApplicationParams::ToJsonValue() const {
Json::Value result__(PolicyBase::ToJsonValue());
@@ -253,6 +367,19 @@ Json::Value ApplicationParams::ToJsonValue() const {
impl::WriteJsonField(
"heart_beat_timeout_ms", heart_beat_timeout_ms, &result__);
impl::WriteJsonField("moduleType", moduleType, &result__);
+ impl::WriteJsonField("certificate", certificate, &result__);
+ impl::WriteJsonField(
+ "hybrid_app_preference", hybrid_app_preference, &result__);
+ impl::WriteJsonField("endpoint", endpoint, &result__);
+ impl::WriteJsonField("enabled", enabled, &result__);
+ impl::WriteJsonField("auth_token", auth_token, &result__);
+ impl::WriteJsonField("cloud_transport_type", cloud_transport_type, &result__);
+ impl::WriteJsonField("icon_url", auth_token, &result__);
+ impl::WriteJsonField("app_services", app_service_parameters, &result__);
+ impl::WriteJsonField("allow_unknown_rpc_passthrough",
+ allow_unknown_rpc_passthrough,
+ &result__);
+ impl::WriteJsonField("encryption_required", encryption_required, &result__);
return result__;
}
@@ -277,6 +404,36 @@ bool ApplicationParams::is_valid() const {
if (!moduleType.is_valid()) {
return false;
}
+ if (!certificate.is_valid()) {
+ return false;
+ }
+ if (!endpoint.is_valid()) {
+ return false;
+ }
+ if (!enabled.is_valid()) {
+ return false;
+ }
+ if (!auth_token.is_valid()) {
+ return false;
+ }
+ if (!cloud_transport_type.is_valid()) {
+ return false;
+ }
+ if (!hybrid_app_preference.is_valid()) {
+ return false;
+ }
+ if (!icon_url.is_valid()) {
+ return false;
+ }
+ if (!app_service_parameters.is_valid()) {
+ return false;
+ }
+ if (!allow_unknown_rpc_passthrough.is_valid()) {
+ return false;
+ }
+ if (!encryption_required.is_valid()) {
+ return false;
+ }
return Validate();
}
@@ -309,6 +466,36 @@ bool ApplicationParams::struct_empty() const {
if (moduleType.is_initialized()) {
return false;
}
+ if (certificate.is_initialized()) {
+ return false;
+ }
+ if (endpoint.is_initialized()) {
+ return false;
+ }
+ if (enabled.is_initialized()) {
+ return false;
+ }
+ if (auth_token.is_initialized()) {
+ return false;
+ }
+ if (cloud_transport_type.is_initialized()) {
+ return false;
+ }
+ if (hybrid_app_preference.is_initialized()) {
+ return false;
+ }
+ if (icon_url.is_initialized()) {
+ return false;
+ }
+ if (app_service_parameters.is_initialized()) {
+ return false;
+ }
+ if (allow_unknown_rpc_passthrough.is_initialized()) {
+ return false;
+ }
+ if (!encryption_required.is_valid()) {
+ return false;
+ }
return true;
}
@@ -357,6 +544,40 @@ void ApplicationParams::ReportErrors(rpc::ValidationReport* report__) const {
if (!moduleType.is_valid()) {
moduleType.ReportErrors(&report__->ReportSubobject("moduleType"));
}
+ if (!certificate.is_valid()) {
+ certificate.ReportErrors(&report__->ReportSubobject("certificate"));
+ }
+ if (!endpoint.is_valid()) {
+ moduleType.ReportErrors(&report__->ReportSubobject("endpoint"));
+ }
+ if (!enabled.is_valid()) {
+ moduleType.ReportErrors(&report__->ReportSubobject("enabled"));
+ }
+ if (!auth_token.is_valid()) {
+ moduleType.ReportErrors(&report__->ReportSubobject("auth_token"));
+ }
+ if (!cloud_transport_type.is_valid()) {
+ moduleType.ReportErrors(&report__->ReportSubobject("cloud_transport_type"));
+ }
+ if (!hybrid_app_preference.is_valid()) {
+ moduleType.ReportErrors(
+ &report__->ReportSubobject("hybrid_app_preference"));
+ }
+ if (!icon_url.is_valid()) {
+ moduleType.ReportErrors(&report__->ReportSubobject("icon_url"));
+ }
+ if (!app_service_parameters.is_valid()) {
+ app_service_parameters.ReportErrors(
+ &report__->ReportSubobject("app_services"));
+ }
+ if (!allow_unknown_rpc_passthrough.is_valid()) {
+ allow_unknown_rpc_passthrough.ReportErrors(
+ &report__->ReportSubobject("allow_unknown_rpc_passthrough"));
+ }
+ if (!encryption_required.is_valid()) {
+ encryption_required.ReportErrors(
+ &report__->ReportSubobject("encryption_required"));
+ }
}
void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) {
@@ -367,6 +588,14 @@ void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) {
memory_kb.SetPolicyTableType(pt_type);
heart_beat_timeout_ms.SetPolicyTableType(pt_type);
moduleType.SetPolicyTableType(pt_type);
+ certificate.SetPolicyTableType(pt_type);
+ endpoint.SetPolicyTableType(pt_type);
+ enabled.SetPolicyTableType(pt_type);
+ cloud_transport_type.SetPolicyTableType(pt_type);
+ hybrid_app_preference.SetPolicyTableType(pt_type);
+ icon_url.SetPolicyTableType(pt_type);
+ app_service_parameters.SetPolicyTableType(pt_type);
+ allow_unknown_rpc_passthrough.SetPolicyTableType(pt_type);
}
// RpcParameters methods
@@ -445,7 +674,8 @@ Rpcs::Rpcs(const Json::Value* value__)
, disallowed_by_external_consent_entities_on(impl::ValueMember(
value__, "disallowed_by_external_consent_entities_on"))
, disallowed_by_external_consent_entities_off(impl::ValueMember(
- value__, "disallowed_by_external_consent_entities_off")) {}
+ value__, "disallowed_by_external_consent_entities_off"))
+ , encryption_required(impl::ValueMember(value__, "encryption_required")) {}
Json::Value Rpcs::ToJsonValue() const {
Json::Value result__(Json::objectValue);
@@ -457,6 +687,7 @@ Json::Value Rpcs::ToJsonValue() const {
impl::WriteJsonField("disallowed_by_external_consent_entities_off",
disallowed_by_external_consent_entities_off,
&result__);
+ impl::WriteJsonField("encryption_required", encryption_required, &result__);
return result__;
}
@@ -473,6 +704,9 @@ bool Rpcs::is_valid() const {
if (!disallowed_by_external_consent_entities_off.is_valid()) {
return false;
}
+ if (!encryption_required.is_valid()) {
+ return false;
+ }
return Validate();
}
@@ -493,6 +727,9 @@ bool Rpcs::struct_empty() const {
if (disallowed_by_external_consent_entities_off.is_initialized()) {
return false;
}
+ if (encryption_required.is_initialized()) {
+ return false;
+ }
return true;
}
@@ -517,6 +754,10 @@ void Rpcs::ReportErrors(rpc::ValidationReport* report__) const {
&report__->ReportSubobject(
"disallowed_by_external_consent_entities_off"));
}
+ if (!encryption_required.is_valid()) {
+ encryption_required.ReportErrors(
+ &report__->ReportSubobject("encryption_required"));
+ }
}
void Rpcs::SetPolicyTableType(PolicyTableType pt_type) {
@@ -527,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,
@@ -537,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)
@@ -545,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) {}
@@ -562,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"))
@@ -569,7 +864,10 @@ ModuleConfig::ModuleConfig(const Json::Value* value__)
, vehicle_year(impl::ValueMember(value__, "vehicle_year"))
, preloaded_date(impl::ValueMember(value__, "preloaded_date"))
, certificate(impl::ValueMember(value__, "certificate"))
- , preloaded_pt(impl::ValueMember(value__, "preloaded_pt")) {}
+ , preloaded_pt(impl::ValueMember(value__, "preloaded_pt"))
+ , full_app_id_supported(impl::ValueMember(value__, "full_app_id_supported"))
+ , lock_screen_dismissal_enabled(
+ impl::ValueMember(value__, "lock_screen_dismissal_enabled")) {}
void ModuleConfig::SafeCopyFrom(const ModuleConfig& from) {
exchange_after_x_days = from.exchange_after_x_days;
@@ -579,8 +877,10 @@ 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;
certificate.assign_if_valid(from.certificate);
vehicle_make.assign_if_valid(from.vehicle_make);
@@ -592,6 +892,8 @@ Json::Value ModuleConfig::ToJsonValue() const {
Json::Value result__(Json::objectValue);
impl::WriteJsonField("certificate", certificate, &result__);
impl::WriteJsonField("preloaded_pt", preloaded_pt, &result__);
+ impl::WriteJsonField(
+ "full_app_id_supported", full_app_id_supported, &result__);
impl::WriteJsonField("exchange_after_x_ignition_cycles",
exchange_after_x_ignition_cycles,
&result__);
@@ -604,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__);
@@ -612,6 +915,9 @@ Json::Value ModuleConfig::ToJsonValue() const {
impl::WriteJsonField("vehicle_year", vehicle_year, &result__);
impl::WriteJsonField("certificate", certificate, &result__);
impl::WriteJsonField("preloaded_date", preloaded_date, &result__);
+ impl::WriteJsonField("lock_screen_dismissal_enabled",
+ lock_screen_dismissal_enabled,
+ &result__);
return result__;
}
@@ -622,6 +928,9 @@ bool ModuleConfig::is_valid() const {
if (!preloaded_pt.is_valid()) {
return false;
}
+ if (!full_app_id_supported.is_valid()) {
+ return false;
+ }
if (!exchange_after_x_ignition_cycles.is_valid()) {
return false;
}
@@ -640,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;
}
@@ -658,6 +970,9 @@ bool ModuleConfig::is_valid() const {
if (!preloaded_date.is_valid()) {
return false;
}
+ if (!lock_screen_dismissal_enabled.is_valid()) {
+ return false;
+ }
return Validate();
}
@@ -672,6 +987,9 @@ bool ModuleConfig::struct_empty() const {
if (preloaded_pt.is_initialized()) {
return false;
}
+ if (full_app_id_supported.is_initialized()) {
+ return false;
+ }
if (exchange_after_x_ignition_cycles.is_initialized()) {
return false;
@@ -694,9 +1012,16 @@ bool ModuleConfig::struct_empty() const {
return false;
}
+ if (endpoint_properties.is_initialized()) {
+ return false;
+ }
+
if (notifications_per_minute_by_priority.is_initialized()) {
return false;
}
+ if (lock_screen_dismissal_enabled.is_initialized()) {
+ return false;
+ }
if (vehicle_make.is_initialized()) {
return false;
}
@@ -720,6 +1045,10 @@ void ModuleConfig::ReportErrors(rpc::ValidationReport* report__) const {
if (!preloaded_pt.is_valid()) {
preloaded_pt.ReportErrors(&report__->ReportSubobject("preloaded_pt"));
}
+ if (!full_app_id_supported.is_valid()) {
+ full_app_id_supported.ReportErrors(
+ &report__->ReportSubobject("full_app_id_supported"));
+ }
if (!exchange_after_x_ignition_cycles.is_valid()) {
exchange_after_x_ignition_cycles.ReportErrors(
&report__->ReportSubobject("exchange_after_x_ignition_cycles"));
@@ -743,10 +1072,18 @@ 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"));
}
+ if (!lock_screen_dismissal_enabled.is_valid()) {
+ lock_screen_dismissal_enabled.ReportErrors(
+ &report__->ReportSubobject("lock_screen_dismissal_enabled"));
+ }
if (!vehicle_make.is_valid()) {
vehicle_make.ReportErrors(&report__->ReportSubobject("vehicle_make"));
}
@@ -797,13 +1134,16 @@ void ModuleConfig::SetPolicyTableType(PolicyTableType pt_type) {
CompositeType::SetPolicyTableType(pt_type);
certificate.SetPolicyTableType(pt_type);
preloaded_pt.SetPolicyTableType(pt_type);
+ full_app_id_supported.SetPolicyTableType(pt_type);
exchange_after_x_ignition_cycles.SetPolicyTableType(pt_type);
exchange_after_x_kilometers.SetPolicyTableType(pt_type);
exchange_after_x_days.SetPolicyTableType(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);
vehicle_model.SetPolicyTableType(pt_type);
vehicle_year.SetPolicyTableType(pt_type);
@@ -1843,6 +2183,416 @@ 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 (VehicleDataItem::kStruct == std::string(type)) {
+ return params.is_initialized() && !(params->empty()) && params.is_valid();
+ }
+ // params should be empty for POD types and for enum values
+ return (!(params.is_initialized()) || params->empty());
+}
+
+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) {}
@@ -1869,7 +2619,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);
@@ -1882,6 +2633,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__;
}
@@ -1907,6 +2659,9 @@ bool PolicyTable::is_valid() const {
if (!device_data.is_valid()) {
return false;
}
+ if (!vehicle_data.is_valid()) {
+ return false;
+ }
return Validate();
}
@@ -1939,6 +2694,10 @@ bool PolicyTable::struct_empty() const {
if (device_data.is_initialized()) {
return false;
}
+
+ if (vehicle_data.is_initialized()) {
+ return false;
+ }
return true;
}
@@ -1981,6 +2740,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) {
@@ -1992,6 +2754,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 9b227615d8..12a79748d7 100644
--- a/src/components/policy/policy_external/src/policy_table/validation.cc
+++ b/src/components/policy/policy_external/src/policy_table/validation.cc
@@ -1,15 +1,15 @@
-#include <iostream>
#include <algorithm>
+#include <iostream>
#include "policy/policy_table/types.h"
-#include "utils/logger.h"
#include "utils/helpers.h"
+#include "utils/logger.h"
namespace {
bool IsPredefinedApplication(const std::string& app_id) {
using namespace rpc::policy_table_interface_base;
return kPreDataConsentApp == app_id || kDefaultApp == app_id;
}
-}
+} // namespace
namespace rpc {
namespace policy_table_interface_base {
@@ -102,9 +102,9 @@ bool ApplicationPoliciesSection::Validate() const {
}
if (!app_request_types.is_valid()) {
- LOG4CXX_WARN(logger_,
- "Invalid RequestTypes for " << app_id
- << " Will be cleaned up.");
+ LOG4CXX_WARN(
+ logger_,
+ "Invalid RequestTypes for " << app_id << " Will be cleaned up.");
app_request_types.CleanUp();
if (app_request_types.is_cleaned_up()) {
if (PT_PRELOADED == pt_type) {
@@ -194,6 +194,14 @@ bool ApplicationParams::ValidateModuleTypes() const {
return true;
}
+bool AppServiceHandledRpc::Validate() const {
+ return true;
+}
+
+bool AppServiceInfo::Validate() const {
+ return true;
+}
+
bool ApplicationParams::Validate() const {
if (is_initialized()) {
if (preconsented_groups.is_initialized()) {
@@ -213,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: {
@@ -250,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;
}
@@ -296,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_ext_queries.cc b/src/components/policy/policy_external/src/sql_pt_ext_queries.cc
index afb1180692..ea323908c0 100644
--- a/src/components/policy/policy_external/src/sql_pt_ext_queries.cc
+++ b/src/components/policy/policy_external/src/sql_pt_ext_queries.cc
@@ -205,7 +205,12 @@ const std::string kUpdateGroupPermissions =
const std::string kInsertApplication =
"INSERT OR IGNORE INTO `application`(`id`, `keep_context`, `steal_focus`, "
" `default_hmi`, `priority_value`, `is_revoked`, `memory_kb`, "
- " `heart_beat_timeout_ms`) VALUES( ?, ?, ?, ?, ?, ?, ?, ?) ";
+ " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, "
+ " `endpoint`, `enabled`, `auth_token`, "
+ " `cloud_transport_type`, `icon_url`, `allow_unknown_rpc_passthrough`, "
+ "`encryption_required`) "
+ "VALUES "
+ "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
const std::string kCollectFriendlyMsg = "SELECT * FROM `message`";
@@ -232,8 +237,11 @@ const std::string kSelectPreconsentedGroupsId =
const std::string kSelectAppPolicies =
"SELECT `id`, `priority_value`, `default_hmi`, `keep_context`, "
- "`steal_focus`, "
- " `memory_kb`, `heart_beat_timeout_ms` FROM `application`";
+ " `steal_focus`, `memory_kb`, `heart_beat_timeout_ms`, `certificate`, "
+ " `hybrid_app_preference_value`, `endpoint`, `enabled`, `auth_token`, "
+ " `cloud_transport_type`, `icon_url`, `allow_unknown_rpc_passthrough`, "
+ "`encryption_required`"
+ "FROM `application`";
const std::string kSelectFunctionalGroupNames =
"SELECT `id`, `user_consent_prompt`, `name`"
diff --git a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc
index 5bb602244e..c8a1b5d7ea 100644
--- a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc
+++ b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc
@@ -29,15 +29,15 @@
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
+#include "policy/sql_pt_ext_representation.h"
#include <algorithm>
#include <utility>
-#include "utils/logger.h"
-#include "policy/sql_pt_ext_representation.h"
-#include "policy/sql_wrapper.h"
-#include "policy/sql_pt_queries.h"
-#include "policy/sql_pt_ext_queries.h"
-#include "policy/policy_helper.h"
#include "policy/cache_manager.h"
+#include "policy/policy_helper.h"
+#include "policy/sql_pt_ext_queries.h"
+#include "policy/sql_pt_queries.h"
+#include "policy/sql_wrapper.h"
+#include "utils/logger.h"
namespace policy {
@@ -563,25 +563,23 @@ bool SQLPTExtRepresentation::GatherConsumerFriendlyMessages(
msg.message_code = query.GetString(7);
std::string language = query.GetString(6);
+ policy_table::Languages& languages =
+ (*messages->messages)[msg.message_code].languages;
+ policy_table::MessageString& specific_message = languages[language];
if (!msg.tts.empty()) {
- *(*messages->messages)[msg.message_code].languages[language].tts =
- msg.tts;
+ *(specific_message).tts = msg.tts;
}
if (!msg.label.empty()) {
- *(*messages->messages)[msg.message_code].languages[language].label =
- msg.label;
+ *(specific_message).label = msg.label;
}
if (!msg.line1.empty()) {
- *(*messages->messages)[msg.message_code].languages[language].line1 =
- msg.line1;
+ *(specific_message).line1 = msg.line1;
}
if (!msg.line2.empty()) {
- *(*messages->messages)[msg.message_code].languages[language].line2 =
- msg.line2;
+ *(specific_message).line2 = msg.line2;
}
if (!msg.text_body.empty()) {
- *(*messages->messages)[msg.message_code].languages[language].textBody =
- msg.text_body;
+ *(specific_message).textBody = msg.text_body;
}
}
} else {
@@ -675,6 +673,21 @@ bool SQLPTExtRepresentation::SaveApplicationPoliciesSection(
return false;
}
+ if (!query_delete.Exec(sql_pt::kDeleteAppServiceHandledRpcs)) {
+ LOG4CXX_WARN(logger_, "Incorrect delete from handled rpcs.");
+ return false;
+ }
+
+ if (!query_delete.Exec(sql_pt::kDeleteAppServiceNames)) {
+ LOG4CXX_WARN(logger_, "Incorrect delete from service names.");
+ return false;
+ }
+
+ if (!query_delete.Exec(sql_pt::kDeleteAppServiceTypes)) {
+ LOG4CXX_WARN(logger_, "Incorrect delete from handled service types.");
+ return false;
+ }
+
// First, all predefined apps (e.g. default, pre_DataConsent) should be saved,
// otherwise another app with the predefined permissions can get incorrect
// permissions
@@ -729,6 +742,10 @@ bool SQLPTExtRepresentation::SaveSpecificAppPolicy(
if (!SaveRequestSubType(app.first, *app.second.RequestSubType)) {
return false;
}
+ if (!SaveAppServiceParameters(app.first,
+ *app.second.app_service_parameters)) {
+ return false;
+ }
// Stop saving other params, since predefined permissions already set
return true;
}
@@ -752,6 +769,34 @@ bool SQLPTExtRepresentation::SaveSpecificAppPolicy(
app_query.Bind(5, app.second.is_null());
app_query.Bind(6, *app.second.memory_kb);
app_query.Bind(7, static_cast<int64_t>(*app.second.heart_beat_timeout_ms));
+ app.second.certificate.is_initialized()
+ ? app_query.Bind(8, *app.second.certificate)
+ : app_query.Bind(8);
+ app.second.hybrid_app_preference.is_initialized()
+ ? app_query.Bind(9,
+ std::string(policy_table::EnumToJsonString(
+ *app.second.hybrid_app_preference)))
+ : app_query.Bind(9);
+ app.second.endpoint.is_initialized()
+ ? app_query.Bind(10, *app.second.endpoint)
+ : app_query.Bind(10);
+ app.second.enabled.is_initialized() ? app_query.Bind(11, *app.second.enabled)
+ : app_query.Bind(11);
+ app.second.auth_token.is_initialized()
+ ? app_query.Bind(12, *app.second.auth_token)
+ : app_query.Bind(12);
+ app.second.cloud_transport_type.is_initialized()
+ ? app_query.Bind(13, *app.second.cloud_transport_type)
+ : app_query.Bind(13);
+ app.second.icon_url.is_initialized()
+ ? app_query.Bind(14, *app.second.icon_url)
+ : app_query.Bind(14);
+ app.second.allow_unknown_rpc_passthrough.is_initialized()
+ ? app_query.Bind(15, *app.second.allow_unknown_rpc_passthrough)
+ : app_query.Bind(15);
+ app.second.encryption_required.is_initialized()
+ ? app_query.Bind(16, *app.second.encryption_required)
+ : app_query.Bind(16);
if (!app_query.Exec() || !app_query.Reset()) {
LOG4CXX_WARN(logger_, "Incorrect insert into application.");
@@ -761,6 +806,13 @@ bool SQLPTExtRepresentation::SaveSpecificAppPolicy(
if (!SaveAppGroup(app.first, app.second.groups)) {
return false;
}
+
+ bool denied = !app.second.moduleType->is_initialized();
+ if (!SaveRemoteControlDenied(app.first, denied) ||
+ !SaveModuleType(app.first, *app.second.moduleType)) {
+ return false;
+ }
+
if (!SaveNickname(app.first, *app.second.nicknames)) {
return false;
}
@@ -779,6 +831,11 @@ bool SQLPTExtRepresentation::SaveSpecificAppPolicy(
return false;
}
+ if (!SaveAppServiceParameters(app.first,
+ *app.second.app_service_parameters)) {
+ return false;
+ }
+
return true;
}
@@ -866,20 +923,64 @@ bool SQLPTExtRepresentation::GatherApplicationPoliciesSection(
params.steal_focus = query.GetBoolean(4);
*params.memory_kb = query.GetInteger(5);
*params.heart_beat_timeout_ms = query.GetUInteger(6);
+ if (!query.IsNull(7)) {
+ *params.certificate = query.GetString(7);
+ }
+
+ // Read cloud app properties
+ policy_table::HybridAppPreference hap;
+ bool valid = policy_table::EnumFromJsonString(query.GetString(8), &hap);
+ if (valid) {
+ *params.hybrid_app_preference = hap;
+ }
+ *params.endpoint = query.GetString(9);
+ if (!query.IsNull(10)) {
+ *params.enabled = query.GetBoolean(10);
+ }
+ *params.auth_token = query.GetString(11);
+ *params.cloud_transport_type = query.GetString(12);
+ *params.icon_url = query.GetString(13);
+ *params.allow_unknown_rpc_passthrough = query.GetBoolean(14);
+ if (!query.IsNull(15)) {
+ *params.encryption_required = query.GetBoolean(15);
+ }
+ const auto& gather_app_id = ((*policies).apps[app_id].is_string())
+ ? (*policies).apps[app_id].get_string()
+ : app_id;
+ // Data should be gathered from db by "default" key if application has
+ // default policies
- if (!GatherAppGroup(app_id, &params.groups)) {
+ if (!GatherAppGroup(gather_app_id, &params.groups)) {
+ return false;
+ }
+
+ bool denied = false;
+ if (!GatherRemoteControlDenied(gather_app_id, &denied)) {
+ return false;
+ }
+ if (!denied) {
+ if (!GatherModuleType(gather_app_id, &*params.moduleType)) {
+ return false;
+ }
+ }
+
+ if (!GatherNickName(gather_app_id, &*params.nicknames)) {
+ return false;
+ }
+ if (!GatherAppType(gather_app_id, &*params.AppHMIType)) {
return false;
}
- if (!GatherNickName(app_id, &*params.nicknames)) {
+ if (!GatherRequestType(gather_app_id, &*params.RequestType)) {
return false;
}
- if (!GatherAppType(app_id, &*params.AppHMIType)) {
+ if (!GatherRequestSubType(gather_app_id, &*params.RequestSubType)) {
return false;
}
- if (!GatherRequestType(app_id, &*params.RequestType)) {
+ if (!GatherAppServiceParameters(gather_app_id,
+ &*params.app_service_parameters)) {
return false;
}
- GatherPreconsentedGroup(app_id, &*params.preconsented_groups);
+ GatherPreconsentedGroup(gather_app_id, &*params.preconsented_groups);
(*policies).apps[app_id] = params;
}
return true;
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 ee53eb1487..4f858637d7 100644
--- a/src/components/policy/policy_external/src/sql_pt_queries.cc
+++ b/src/components/policy/policy_external/src/sql_pt_queries.cc
@@ -76,12 +76,14 @@ const std::string kCreateSchema =
" `vehicle_model` VARCHAR(45), "
" `vehicle_year` VARCHAR(4), "
" `preloaded_date` VARCHAR (10), "
- " `certificate` VARCHAR (45) "
+ " `certificate` VARCHAR (45), "
+ " `lock_screen_dismissal_enabled` BOOL"
"); "
"CREATE TABLE IF NOT EXISTS `functional_group`( "
" `id` INTEGER PRIMARY KEY NOT NULL, "
" `user_consent_prompt` TEXT, "
- " `name` VARCHAR(100) NOT NULL "
+ " `name` VARCHAR(100) NOT NULL, "
+ " `encryption_required` BOOLEAN "
"); "
"CREATE TABLE IF NOT EXISTS `external_consent_entities`( "
" `group_id` INTEGER NOT NULL, "
@@ -98,6 +100,9 @@ const std::string kCreateSchema =
"CREATE TABLE IF NOT EXISTS `hmi_level`( "
" `value` VARCHAR(45) PRIMARY KEY NOT NULL "
"); "
+ "CREATE TABLE IF NOT EXISTS `hybrid_app_preference`( "
+ " `value` VARCHAR(45) PRIMARY KEY NOT NULL "
+ "); "
"CREATE TABLE IF NOT EXISTS `notifications_by_priority`( "
" `priority_value` VARCHAR(45) PRIMARY KEY NOT NULL, "
" `value` INTEGER NOT NULL, "
@@ -147,18 +152,33 @@ const std::string kCreateSchema =
" `is_predata` BOOLEAN, "
" `memory_kb` INTEGER NOT NULL, "
" `heart_beat_timeout_ms` INTEGER NOT NULL, "
+ " `certificate` VARCHAR(65535), "
+ " `hybrid_app_preference_value` VARCHAR(255), "
+ " `endpoint` VARCHAR(255), "
+ " `enabled` BOOLEAN, "
+ " `auth_token` VARCHAR(65535), "
+ " `cloud_transport_type` VARCHAR(255), "
+ " `icon_url` VARCHAR(65535), "
+ " `allow_unknown_rpc_passthrough` BOOLEAN, "
" `remote_control_denied` BOOLEAN NOT NULL DEFAULT 0, "
+ " `encryption_required` BOOLEAN, "
" CONSTRAINT `fk_application_hmi_level1` "
" FOREIGN KEY(`default_hmi`) "
" REFERENCES `hmi_level`(`value`), "
" CONSTRAINT `fk_application_priorities1` "
" FOREIGN KEY(`priority_value`) "
" REFERENCES `priority`(`value`) "
+ " CONSTRAINT `fk_application_hybrid_app_preference1` "
+ " FOREIGN KEY(`hybrid_app_preference_value`) "
+ " REFERENCES `hybrid_app_preference`(`value`) "
"); "
"CREATE INDEX IF NOT EXISTS `application.fk_application_hmi_level1_idx` "
" ON `application`(`default_hmi`); "
"CREATE INDEX IF NOT EXISTS `application.fk_application_priorities1_idx` "
" ON `application`(`priority_value`); "
+ "CREATE INDEX IF NOT EXISTS "
+ "`application.fk_application_hybrid_app_preference1` "
+ " ON `application`(`hybrid_app_preference_value`); "
"CREATE TABLE IF NOT EXISTS `app_group`( "
" `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, "
" `functional_group_id` INTEGER NOT NULL, "
@@ -286,6 +306,30 @@ const std::string kCreateSchema =
" FOREIGN KEY(`application_id`) "
" REFERENCES `application`(`id`) "
"); "
+ "CREATE TABLE IF NOT EXISTS `app_service_types`( "
+ " `id` INTEGER PRIMARY KEY NOT NULL, "
+ " `service_type` VARCHAR(50), "
+ " `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, "
+ " CONSTRAINT `fk_service_type_app_id` "
+ " FOREIGN KEY(`application_id`) "
+ " REFERENCES `application`(`id`) "
+ "); "
+ "CREATE TABLE IF NOT EXISTS `app_service_names`( "
+ " `service_type_id` INTEGER NOT NULL, "
+ " `service_name` VARCHAR(45), "
+ " PRIMARY KEY(`service_name`,`service_type_id`), "
+ " CONSTRAINT `fk_service_name_service_type_id` "
+ " FOREIGN KEY(`service_type_id`) "
+ " REFERENCES `app_service_types`(`id`) "
+ "); "
+ "CREATE TABLE IF NOT EXISTS `app_service_handled_rpcs`( "
+ " `service_type_id` INTEGER NOT NULL, "
+ " `function_id` INTEGER, "
+ " PRIMARY KEY(`function_id`,`service_type_id`), "
+ " CONSTRAINT `fk_function_id_service_type_id` "
+ " FOREIGN KEY(`service_type_id`) "
+ " REFERENCES `app_service_types`(`id`) "
+ "); "
"CREATE INDEX IF NOT EXISTS `app_type.fk_app_type_application1_idx` "
" ON `app_type`(`application_id` COLLATE NOCASE); "
"CREATE TABLE IF NOT EXISTS `consent_group`( "
@@ -342,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, "
@@ -405,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 =
@@ -418,8 +501,10 @@ const std::string kInsertInitData =
" VALUES (0, 0, 0, 0); "
"INSERT OR IGNORE INTO `module_config` (`preloaded_pt`, `is_first_run`,"
" `exchange_after_x_ignition_cycles`, `exchange_after_x_kilometers`, "
- " `exchange_after_x_days`, `timeout_after_x_seconds`) "
+ " `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'); "
@@ -430,6 +515,9 @@ const std::string kInsertInitData =
"INSERT OR IGNORE INTO `hmi_level`(`value`) VALUES ('LIMITED'); "
"INSERT OR IGNORE INTO `hmi_level`(`value`) VALUES ('BACKGROUND'); "
"INSERT OR IGNORE INTO `hmi_level`(`value`) VALUES ('NONE'); "
+ "INSERT OR IGNORE INTO `hybrid_app_preference`(`value`) VALUES ('MOBILE'); "
+ "INSERT OR IGNORE INTO `hybrid_app_preference`(`value`) VALUES ('CLOUD'); "
+ "INSERT OR IGNORE INTO `hybrid_app_preference`(`value`) VALUES ('BOTH'); "
"INSERT OR IGNORE INTO `version` (`number`) VALUES('0'); "
"INSERT OR IGNORE INTO `_internal_data` (`db_version_hash`) VALUES(0); "
"";
@@ -481,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`; "
@@ -491,6 +580,9 @@ const std::string kDropSchema =
"DROP TABLE IF EXISTS `app_type`; "
"DROP TABLE IF EXISTS `request_type`; "
"DROP TABLE IF EXISTS `request_subtype`; "
+ "DROP TABLE IF EXISTS `app_service_types`; "
+ "DROP TABLE IF EXISTS `app_service_names`; "
+ "DROP TABLE IF EXISTS `app_service_handled_rpcs`; "
"DROP INDEX IF EXISTS `nickname.fk_nickname_application1_idx`; "
"DROP TABLE IF EXISTS `nickname`; "
"DROP INDEX IF EXISTS `app_level.fk_app_level_language2_idx`; "
@@ -532,6 +624,7 @@ const std::string kDropSchema =
"`notifications_by_priority.fk_notifications_by_priority_priority1_idx`; "
"DROP TABLE IF EXISTS `notifications_by_priority`; "
"DROP TABLE IF EXISTS `hmi_level`; "
+ "DROP TABLE IF EXISTS `hybrid_app_preference`; "
"DROP TABLE IF EXISTS `priority`; "
"DROP TABLE IF EXISTS `functional_group`; "
"DROP TABLE IF EXISTS `module_config`; "
@@ -542,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;";
@@ -550,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`; "
@@ -576,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;";
@@ -583,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` = "
@@ -605,12 +781,10 @@ const std::string kSetNotFirstRun =
const std::string kSelectEndpoint =
"SELECT `url`, `application_id` FROM `endpoint` WHERE `service` = ? ";
-const std::string kSelectLockScreenIcon =
- "SELECT `url` FROM `endpoint` WHERE `service` = ? AND `application_id` = ?";
-
const std::string kInsertFunctionalGroup =
- "INSERT INTO `functional_group` (`id`, `name`, `user_consent_prompt`) "
- " VALUES (?, ?, ?)";
+ "INSERT INTO `functional_group` (`id`, `name`, `user_consent_prompt`, "
+ "`encryption_required`) "
+ " VALUES (?, ?, ?, ?)";
const std::string kInsertRpc =
"INSERT INTO `rpc` (`name`, `hmi_level_value`, `functional_group_id`) "
@@ -628,8 +802,12 @@ const std::string kInsertRpcWithParameter =
const std::string kInsertApplication =
"INSERT OR IGNORE INTO `application` (`id`, `priority_value`, "
- "`is_revoked`, `memory_kb`,"
- " `heart_beat_timeout_ms`) VALUES (?,?,?,?,?)";
+ "`is_revoked`, `memory_kb`, `heart_beat_timeout_ms`, `certificate`, "
+ "`hybrid_app_preference_value`, `endpoint`, `enabled`, `auth_token`, "
+ "`cloud_transport_type`, `icon_url`, `allow_unknown_rpc_passthrough`, "
+ "`encryption_required`) "
+ "VALUES "
+ "(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
const std::string kInsertAppGroup =
"INSERT INTO `app_group` (`application_id`, `functional_group_id`)"
@@ -645,18 +823,25 @@ const std::string kInsertRequestType =
"INSERT OR IGNORE INTO `request_type` (`application_id`, `request_type`) "
"VALUES (?, ?)";
-const std::string kInsertOmittedRequestType =
- "INSERT INTO `request_type` (`application_id`) "
- "VALUES (?)";
-
const std::string kInsertRequestSubType =
"INSERT INTO `request_subtype` (`application_id`, "
"`request_subtype`) "
"VALUES (?, ?)";
-const std::string kInsertOmittedRequestSubType =
- "INSERT INTO `request_subtype` (`application_id`) "
- "VALUES (?)";
+const std::string kInsertAppServiceTypes =
+ "INSERT INTO `app_service_types` (`id`, "
+ "`service_type`, `application_id`) "
+ "VALUES (?, ?, ?)";
+
+const std::string kInsertAppServiceNames =
+ "INSERT INTO `app_service_names` (`service_type_id`, "
+ "`service_name`) "
+ "VALUES (?, ?)";
+
+const std::string kInsertAppServiceHandledRpcs =
+ "INSERT INTO `app_service_handled_rpcs` (`service_type_id`, "
+ "`function_id`) "
+ "VALUES (?, ?)";
const std::string kUpdateVersion = "UPDATE `version` SET `number`= ?";
@@ -676,7 +861,7 @@ const std::string kUpdateModuleConfig =
" `exchange_after_x_kilometers` = ?, `exchange_after_x_days` = ?, "
" `timeout_after_x_seconds` = ?, `vehicle_make` = ?, "
" `vehicle_model` = ?, `vehicle_year` = ?, `preloaded_date` = ?, "
- " `certificate` = ? ";
+ " `certificate` = ?, lock_screen_dismissal_enabled = ?";
const std::string kInsertEndpoint =
"INSERT INTO `endpoint` (`service`, `url`, `application_id`) "
@@ -727,7 +912,8 @@ const std::string kSelectModuleConfig =
"SELECT `preloaded_pt`, `exchange_after_x_ignition_cycles`, "
" `exchange_after_x_kilometers`, `exchange_after_x_days`, "
" `timeout_after_x_seconds`, `vehicle_make`,"
- " `vehicle_model`, `vehicle_year`, `preloaded_date`, `certificate` "
+ " `vehicle_model`, `vehicle_year`, `preloaded_date`, `certificate`, "
+ " `lock_screen_dismissal_enabled` "
" FROM `module_config`";
const std::string kSelectEndpoints =
@@ -744,7 +930,7 @@ const std::string kSelectAppLevels = "SELECT `application_id` FROM `app_level`";
const std::string kSelectDeviceData = "SELECT * FROM `device`";
const std::string kSelectFunctionalGroups =
- "SELECT `id`,`name`, `user_consent_prompt` "
+ "SELECT `id`,`name`, `user_consent_prompt`, `encryption_required` "
"FROM `functional_group`";
const std::string kSelectAllRpcs =
@@ -760,7 +946,11 @@ const std::string kSelectUserMsgsVersion =
const std::string kSelectAppPolicies =
"SELECT `id`, `priority_value`, `memory_kb`, "
- " `heart_beat_timeout_ms` FROM `application`";
+ " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, "
+ " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, `icon_url`, "
+ " `allow_unknown_rpc_passthrough`, `encryption_required` "
+ "FROM "
+ " `application`";
const std::string kCollectFriendlyMsg = "SELECT * FROM `message`";
@@ -787,6 +977,21 @@ const std::string kSelectRequestSubTypes =
"`application_id` "
"= ?";
+const std::string kSelectAppServiceTypes =
+ "SELECT `id`, `service_type` FROM `app_service_types` WHERE "
+ "`application_id` "
+ "= ?";
+
+const std::string kSelectAppServiceNames =
+ "SELECT DISTINCT `service_name` FROM `app_service_names` WHERE "
+ "`service_type_id` "
+ "= ?";
+
+const std::string kSelectAppServiceHandledRpcs =
+ "SELECT DISTINCT `function_id` FROM `app_service_handled_rpcs` WHERE "
+ "`service_type_id` "
+ "= ?";
+
const std::string kSelectSecondsBetweenRetries =
"SELECT `value` FROM `seconds_between_retry` ORDER BY `index`";
@@ -834,6 +1039,19 @@ const std::string kDeleteRequestType = "DELETE FROM `request_type`";
const std::string kDeleteRequestSubType = "DELETE FROM `request_subtype`";
+const std::string kDeleteAppServiceTypes = "DELETE FROM `app_service_types`";
+
+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` = ?";
@@ -857,15 +1075,22 @@ const std::string kDeleteAppGroupByApplicationId =
const std::string kInsertApplicationFull =
"INSERT OR IGNORE INTO `application` (`id`, `keep_context`, `steal_focus`, "
- " `default_hmi`, `priority_value`, `is_revoked`, `is_default`, "
- "`is_predata`, "
- " `memory_kb`, `heart_beat_timeout_ms`) "
- " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+ " `default_hmi`, `priority_value`, `is_revoked`, `is_default`, "
+ " `is_predata`, `memory_kb`, `heart_beat_timeout_ms`, "
+ " `certificate`, `hybrid_app_preference_value`, `endpoint`, `enabled`, "
+ " `auth_token`, `cloud_transport_type`, `icon_url`, "
+ "`allow_unknown_rpc_passthrough`, `encryption_required`) "
+ " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
const std::string kSelectApplicationFull =
"SELECT `keep_context`, `steal_focus`, `default_hmi`, `priority_value`, "
" `is_revoked`, `is_default`, `is_predata`, `memory_kb`,"
- " `heart_beat_timeout_ms` FROM `application` WHERE `id` = ?";
+ " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, "
+ " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, "
+ "`icon_url`, "
+ " `allow_unknown_rpc_passthrough`, `encryption_required` "
+ "FROM `application` "
+ "WHERE `id` = ?";
const std::string kSelectDBVersion =
"SELECT `db_version_hash` from `_internal_data`";
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 3cd7388672..5e96d0bde0 100644
--- a/src/components/policy/policy_external/src/sql_pt_representation.cc
+++ b/src/components/policy/policy_external/src/sql_pt_representation.cc
@@ -30,24 +30,24 @@
POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sstream>
-#include <stdlib.h>
-#include <stdint.h>
#include <errno.h>
+#include <stdint.h>
+#include <stdlib.h>
#include <unistd.h>
+#include <sstream>
-#include "utils/logger.h"
+#include "config_profile/profile.h"
+#include "policy/cache_manager.h"
+#include "policy/policy_helper.h"
+#include "policy/sql_pt_ext_queries.h"
+#include "policy/sql_pt_queries.h"
+#include "policy/sql_pt_representation.h"
+#include "policy/sql_wrapper.h"
#include "utils/date_time.h"
-#include "utils/sqlite_wrapper/sql_database.h"
#include "utils/file_system.h"
#include "utils/gen_hash.h"
-#include "policy/sql_pt_representation.h"
-#include "policy/sql_wrapper.h"
-#include "policy/sql_pt_ext_queries.h"
-#include "policy/sql_pt_queries.h"
-#include "policy/policy_helper.h"
-#include "policy/cache_manager.h"
-#include "config_profile/profile.h"
+#include "utils/logger.h"
+#include "utils/sqlite_wrapper/sql_database.h"
namespace policy {
@@ -101,28 +101,6 @@ SQLPTRepresentation::~SQLPTRepresentation() {
delete db_;
}
-std::string SQLPTRepresentation::GetLockScreenIconUrl() const {
- utils::dbms::SQLQuery query(db());
- std::string ret;
- if (query.Prepare(sql_pt::kSelectLockScreenIcon)) {
- query.Bind(0, std::string("lock_screen_icon_url"));
- query.Bind(1, std::string("default"));
-
- if (!query.Exec()) {
- LOG4CXX_WARN(logger_, "Incorrect select from notifications by priority.");
- return ret;
- }
-
- if (!query.IsNull(0)) {
- ret = query.GetString(0);
- }
-
- } else {
- LOG4CXX_WARN(logger_, "Invalid select endpoints statement.");
- }
- return ret;
-}
-
void SQLPTRepresentation::CheckPermissions(const PTString& app_id,
const PTString& hmi_level,
const PTString& rpc,
@@ -130,9 +108,9 @@ void SQLPTRepresentation::CheckPermissions(const PTString& app_id,
utils::dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kSelectRpc)) {
- LOG4CXX_WARN(logger_,
- "Incorrect select statement from rpcs"
- << query.LastError().text());
+ LOG4CXX_WARN(
+ logger_,
+ "Incorrect select statement from rpcs" << query.LastError().text());
return;
}
query.Bind(0, app_id);
@@ -235,10 +213,10 @@ int SQLPTRepresentation::TimeoutResponse() {
utils::dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kSelectTimeoutResponse) || !query.Exec()) {
LOG4CXX_INFO(logger_, "Can not select timeout response for retry sequence");
- const int defaultTimeout = 30 * date_time::DateTime::MILLISECONDS_IN_SECOND;
+ const int defaultTimeout = 30 * date_time::MILLISECONDS_IN_SECOND;
return defaultTimeout;
}
- return query.GetInteger(0) * date_time::DateTime::MILLISECONDS_IN_SECOND;
+ return query.GetInteger(0) * date_time::MILLISECONDS_IN_SECOND;
}
bool SQLPTRepresentation::SecondsBetweenRetries(std::vector<int>* seconds) {
@@ -408,9 +386,9 @@ InitResult SQLPTRepresentation::Init(const PolicySettings* settings) {
utils::dbms::SQLQuery check_first_run(db());
if (check_first_run.Prepare(sql_pt::kIsFirstRun) &&
check_first_run.Next()) {
- LOG4CXX_INFO(logger_,
- "Selecting is first run "
- << check_first_run.GetBoolean(0));
+ LOG4CXX_INFO(
+ logger_,
+ "Selecting is first run " << check_first_run.GetBoolean(0));
if (check_first_run.GetBoolean(0)) {
utils::dbms::SQLQuery set_not_first_run(db());
set_not_first_run.Exec(sql_pt::kSetNotFirstRun);
@@ -451,16 +429,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)) {
@@ -513,10 +481,10 @@ bool SQLPTRepresentation::RefreshDB() {
return true;
}
-utils::SharedPtr<policy_table::Table> SQLPTRepresentation::GenerateSnapshot()
+std::shared_ptr<policy_table::Table> SQLPTRepresentation::GenerateSnapshot()
const {
LOG4CXX_AUTO_TRACE(logger_);
- utils::SharedPtr<policy_table::Table> table = new policy_table::Table();
+ auto table = std::make_shared<policy_table::Table>();
GatherModuleMeta(&*table->policy_table.module_meta);
GatherModuleConfig(&table->policy_table.module_config);
GatherUsageAndErrorCounts(&*table->policy_table.usage_and_error_counts);
@@ -525,6 +493,11 @@ utils::SharedPtr<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;
}
@@ -552,6 +525,9 @@ void SQLPTRepresentation::GatherModuleConfig(
*config->vehicle_year = query.GetString(7);
*config->preloaded_date = query.GetString(8);
*config->certificate = query.GetString(9);
+ if (!query.IsNull(10)) {
+ *config->lock_screen_dismissal_enabled = query.GetBoolean(10);
+ }
}
utils::dbms::SQLQuery endpoints(db());
@@ -566,6 +542,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");
@@ -645,6 +633,10 @@ bool SQLPTRepresentation::GatherFunctionalGroupings(
*rpcs_tbl.user_consent_prompt = func_group.GetString(2);
}
+ if (!func_group.IsNull(3)) {
+ *rpcs_tbl.encryption_required = func_group.GetBoolean(3);
+ }
+
const int group_id = func_group.GetInteger(0);
rpcs.Bind(0, group_id);
@@ -657,16 +649,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));
}
}
@@ -712,10 +703,33 @@ bool SQLPTRepresentation::GatherConsumerFriendlyMessages(
if (query.Prepare(sql_pt::kCollectFriendlyMsg)) {
while (query.Next()) {
UserFriendlyMessage msg;
+
+ msg.tts = query.GetString(1);
+ msg.label = query.GetString(2);
+ msg.line1 = query.GetString(3);
+ msg.line2 = query.GetString(4);
+ msg.text_body = query.GetString(5);
msg.message_code = query.GetString(7);
- std::string language = query.GetString(6);
- (*messages->messages)[msg.message_code].languages[language];
+ std::string language = query.GetString(6);
+ policy_table::Languages& languages =
+ (*messages->messages)[msg.message_code].languages;
+ policy_table::MessageString& specific_message = languages[language];
+ if (!msg.tts.empty()) {
+ *(specific_message).tts = msg.tts;
+ }
+ if (!msg.label.empty()) {
+ *(specific_message).label = msg.label;
+ }
+ if (!msg.line1.empty()) {
+ *(specific_message).line1 = msg.line1;
+ }
+ if (!msg.line2.empty()) {
+ *(specific_message).line2 = msg.line2;
+ }
+ if (!msg.text_body.empty()) {
+ *(specific_message).textBody = msg.text_body;
+ }
}
} else {
LOG4CXX_WARN(logger_, "Incorrect statement for select friendly messages.");
@@ -761,30 +775,62 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection(
*params.memory_kb = query.GetInteger(2);
*params.heart_beat_timeout_ms = query.GetUInteger(3);
- if (!GatherAppGroup(app_id, &params.groups)) {
+ if (!query.IsNull(4)) {
+ *params.certificate = query.GetString(4);
+ }
+
+ // Read cloud app properties
+ policy_table::HybridAppPreference hap;
+ bool valid = policy_table::EnumFromJsonString(query.GetString(5), &hap);
+ if (valid) {
+ *params.hybrid_app_preference = hap;
+ }
+ *params.endpoint = query.GetString(6);
+ if (!query.IsNull(7)) {
+ *params.enabled = query.GetBoolean(7);
+ }
+ *params.auth_token = query.GetString(8);
+ *params.cloud_transport_type = query.GetString(9);
+ *params.icon_url = query.GetString(10);
+ *params.allow_unknown_rpc_passthrough = query.GetBoolean(11);
+ const auto& gather_app_id = ((*policies).apps[app_id].is_string())
+ ? (*policies).apps[app_id].get_string()
+ : app_id;
+
+ if (!query.IsNull(12)) {
+ *params.encryption_required = query.GetBoolean(12);
+ }
+ // Data should be gathered from db by "default" key if application has
+ // default policies
+
+ if (!GatherAppGroup(gather_app_id, &params.groups)) {
return false;
}
bool denied = false;
- if (!GatherRemoteControlDenied(app_id, &denied)) {
+ if (!GatherRemoteControlDenied(gather_app_id, &denied)) {
return false;
}
if (!denied) {
- if (!GatherModuleType(app_id, &*params.moduleType)) {
+ if (!GatherModuleType(gather_app_id, &*params.moduleType)) {
return false;
}
}
- if (!GatherNickName(app_id, &*params.nicknames)) {
+ if (!GatherNickName(gather_app_id, &*params.nicknames)) {
return false;
}
- if (!GatherAppType(app_id, &*params.AppHMIType)) {
+ if (!GatherAppType(gather_app_id, &*params.AppHMIType)) {
return false;
}
- if (!GatherRequestType(app_id, &*params.RequestType)) {
+ if (!GatherRequestType(gather_app_id, &*params.RequestType)) {
return false;
}
- if (!GatherRequestSubType(app_id, &*params.RequestSubType)) {
+ if (!GatherRequestSubType(gather_app_id, &*params.RequestSubType)) {
+ return false;
+ }
+ if (!GatherAppServiceParameters(gather_app_id,
+ &*params.app_service_parameters)) {
return false;
}
@@ -793,6 +839,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();
@@ -827,6 +910,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;
}
@@ -872,7 +959,9 @@ bool SQLPTRepresentation::SaveFunctionalGroupings(
groups_it->second.user_consent_prompt.is_initialized()
? query.Bind(2, *(groups_it->second.user_consent_prompt))
: query.Bind(2);
-
+ groups_it->second.encryption_required.is_initialized()
+ ? query.Bind(3, *(groups_it->second.encryption_required))
+ : query.Bind(3);
if (!query.Exec() || !query.Reset()) {
LOG4CXX_WARN(logger_, "Incorrect insert into functional groups");
return false;
@@ -925,8 +1014,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");
@@ -978,6 +1066,21 @@ bool SQLPTRepresentation::SaveApplicationPoliciesSection(
return false;
}
+ if (!query_delete.Exec(sql_pt::kDeleteAppServiceHandledRpcs)) {
+ LOG4CXX_WARN(logger_, "Incorrect delete from handled rpcs.");
+ return false;
+ }
+
+ if (!query_delete.Exec(sql_pt::kDeleteAppServiceNames)) {
+ LOG4CXX_WARN(logger_, "Incorrect delete from service names.");
+ return false;
+ }
+
+ if (!query_delete.Exec(sql_pt::kDeleteAppServiceTypes)) {
+ LOG4CXX_WARN(logger_, "Incorrect delete from handled service types.");
+ return false;
+ }
+
// All predefined apps (e.g. default, pre_DataConsent) should be saved first,
// otherwise another app with the predefined permissions can get incorrect
// permissions
@@ -1029,6 +1132,34 @@ bool SQLPTRepresentation::SaveSpecificAppPolicy(
app_query.Bind(2, app.second.is_null());
app_query.Bind(3, *app.second.memory_kb);
app_query.Bind(4, static_cast<int64_t>(*app.second.heart_beat_timeout_ms));
+ app.second.certificate.is_initialized()
+ ? app_query.Bind(5, *app.second.certificate)
+ : app_query.Bind(5);
+ app.second.hybrid_app_preference.is_initialized()
+ ? app_query.Bind(6,
+ std::string(policy_table::EnumToJsonString(
+ *app.second.hybrid_app_preference)))
+ : app_query.Bind(6);
+ app.second.endpoint.is_initialized() ? app_query.Bind(7, *app.second.endpoint)
+ : app_query.Bind(7);
+ app.second.enabled.is_initialized() ? app_query.Bind(8, *app.second.enabled)
+ : app_query.Bind(8);
+ app.second.auth_token.is_initialized()
+ ? app_query.Bind(9, *app.second.auth_token)
+ : app_query.Bind(9);
+ app.second.cloud_transport_type.is_initialized()
+ ? app_query.Bind(10, *app.second.cloud_transport_type)
+ : app_query.Bind(10);
+ app.second.icon_url.is_initialized()
+ ? app_query.Bind(11, *app.second.icon_url)
+ : app_query.Bind(11);
+ app.second.allow_unknown_rpc_passthrough.is_initialized()
+ ? app_query.Bind(12, *app.second.allow_unknown_rpc_passthrough)
+ : app_query.Bind(12);
+
+ app.second.encryption_required.is_initialized()
+ ? app_query.Bind(13, *app.second.encryption_required)
+ : app_query.Bind(13);
if (!app_query.Exec() || !app_query.Reset()) {
LOG4CXX_WARN(logger_, "Incorrect insert into application.");
@@ -1065,6 +1196,10 @@ bool SQLPTRepresentation::SaveSpecificAppPolicy(
if (!SaveRequestType(app.first, *app.second.RequestType)) {
return false;
}
+ if (!SaveAppServiceParameters(app.first,
+ *app.second.app_service_parameters)) {
+ return false;
+ }
return true;
}
@@ -1097,6 +1232,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());
@@ -1112,9 +1285,9 @@ bool SQLPTRepresentation::SaveAppGroup(
query.Bind(0, app_id);
query.Bind(1, *it);
if (!query.Exec() || !query.Reset()) {
- LOG4CXX_WARN(logger_,
- "Incorrect insert into app group."
- << query.LastError().text());
+ LOG4CXX_WARN(
+ logger_,
+ "Incorrect insert into app group." << query.LastError().text());
return false;
}
}
@@ -1193,18 +1366,6 @@ bool SQLPTRepresentation::SaveRequestType(
LOG4CXX_WARN(logger_, "Incorrect insert into request types.");
return false;
}
- } else {
- utils::dbms::SQLQuery query_omitted(db());
- if (!query_omitted.Prepare(sql_pt::kInsertOmittedRequestType)) {
- LOG4CXX_WARN(logger_, "Incorrect insert statement for request types.");
- return false;
- }
- LOG4CXX_WARN(logger_, "Request types omitted.");
- query_omitted.Bind(0, app_id);
- if (!query_omitted.Exec() || !query_omitted.Reset()) {
- LOG4CXX_WARN(logger_, "Incorrect insert into request types.");
- return false;
- }
}
return true;
}
@@ -1232,23 +1393,92 @@ 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;
}
- } else {
- utils::dbms::SQLQuery query_omitted(db());
- if (!query_omitted.Prepare(sql_pt::kInsertOmittedRequestSubType)) {
- LOG4CXX_WARN(logger_, "Incorrect insert statement for request subtypes.");
+ }
+ return true;
+}
+
+bool SQLPTRepresentation::SaveAppServiceParameters(
+ const std::string& app_id,
+ const policy_table::AppServiceParameters& app_service_parameters) {
+ LOG4CXX_INFO(logger_, "Save app service parameters");
+ utils::dbms::SQLQuery query(db());
+
+ if (!query.Prepare(sql_pt::kInsertAppServiceTypes)) {
+ LOG4CXX_WARN(logger_, "Incorrect insert statement for app service types");
+ return false;
+ }
+ policy_table::AppServiceParameters::const_iterator it;
+ for (it = app_service_parameters.begin(); it != app_service_parameters.end();
+ ++it) {
+ // Create service type id from hashing app_id and service_type
+ std::string str_to_hash = std::string(app_id + it->first);
+ const long int id = abs(CacheManager::GenerateHash(str_to_hash));
+ query.Bind(0, static_cast<int64_t>(id));
+ query.Bind(1, it->first);
+ query.Bind(2, app_id);
+ if (!query.Exec() || !query.Reset()) {
+ LOG4CXX_WARN(logger_, "Insert execute failed for into app service types");
return false;
}
- LOG4CXX_WARN(logger_, "Request subtypes omitted.");
- query_omitted.Bind(0, app_id);
- if (!query_omitted.Exec() || !query_omitted.Reset()) {
- LOG4CXX_WARN(logger_, "Incorrect insert into request subtypes.");
+
+ // Insert app names array into db
+ utils::dbms::SQLQuery service_name_query(db());
+ if (!service_name_query.Prepare(sql_pt::kInsertAppServiceNames)) {
+ LOG4CXX_WARN(logger_, "Incorrect insert statement for app service names");
return false;
}
+
+ auto app_service_names = it->second.service_names;
+
+ if (app_service_names.is_initialized() && app_service_names->empty()) {
+ // App service names is an empty array
+ LOG4CXX_DEBUG(logger_, "App Service Names is Empty Array");
+ service_name_query.Bind(0, static_cast<int64_t>(id));
+ service_name_query.Bind(1);
+ if (!service_name_query.Exec() || !service_name_query.Reset()) {
+ LOG4CXX_WARN(logger_, "Incorrect insert into empty app service names");
+ return false;
+ }
+ } else {
+ policy_table::AppServiceNames::const_iterator names_it;
+ for (names_it = app_service_names->begin();
+ names_it != app_service_names->end();
+ ++names_it) {
+ service_name_query.Bind(0, static_cast<int64_t>(id));
+ service_name_query.Bind(1, *names_it);
+ if (!service_name_query.Exec() || !service_name_query.Reset()) {
+ LOG4CXX_WARN(logger_, "Incorrect insert into app service names");
+ return false;
+ }
+ }
+ }
+
+ // Insert handled rpcs array into db
+ utils::dbms::SQLQuery handled_rpcs_query(db());
+ if (!handled_rpcs_query.Prepare(sql_pt::kInsertAppServiceHandledRpcs)) {
+ LOG4CXX_WARN(logger_,
+ "Incorrect insert statement for app service handled rpcs");
+ return false;
+ }
+
+ auto handled_rpcs = it->second.handled_rpcs;
+ policy_table::AppServiceHandledRpcs::const_iterator rpc_it;
+ for (rpc_it = handled_rpcs.begin(); rpc_it != handled_rpcs.end();
+ ++rpc_it) {
+ handled_rpcs_query.Bind(0, static_cast<int64_t>(id));
+ handled_rpcs_query.Bind(1, static_cast<int32_t>(rpc_it->function_id));
+ if (!handled_rpcs_query.Exec() || !handled_rpcs_query.Reset()) {
+ LOG4CXX_WARN(logger_, "Incorrect insert into app service handled rpcs");
+ return false;
+ }
+ }
}
return true;
}
@@ -1286,6 +1516,10 @@ bool SQLPTRepresentation::SaveModuleConfig(
config.certificate.is_initialized() ? query.Bind(9, *(config.certificate))
: query.Bind(9);
+ config.lock_screen_dismissal_enabled.is_initialized()
+ ? query.Bind(10, *(config.lock_screen_dismissal_enabled))
+ : query.Bind(10);
+
if (!query.Exec()) {
LOG4CXX_WARN(logger_, "Incorrect update module config");
return false;
@@ -1304,6 +1538,10 @@ bool SQLPTRepresentation::SaveModuleConfig(
return false;
}
+ if (!SaveServiceEndpointProperties(*config.endpoint_properties)) {
+ return false;
+ }
+
return true;
}
@@ -1342,6 +1580,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_);
@@ -1428,6 +1691,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,
@@ -1670,7 +2047,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;
}
@@ -1679,6 +2057,63 @@ bool SQLPTRepresentation::GatherRequestSubType(
return true;
}
+bool SQLPTRepresentation::GatherAppServiceParameters(
+ const std::string& app_id,
+ policy_table::AppServiceParameters* app_service_parameters) const {
+ LOG4CXX_INFO(logger_, "Gather app service info");
+ utils::dbms::SQLQuery service_type_query(db());
+ if (!service_type_query.Prepare(sql_pt::kSelectAppServiceTypes)) {
+ LOG4CXX_WARN(logger_, "Incorrect select from service_types");
+ return false;
+ }
+
+ utils::dbms::SQLQuery service_name_query(db());
+ if (!service_name_query.Prepare(sql_pt::kSelectAppServiceNames)) {
+ LOG4CXX_WARN(logger_, "Incorrect select all from app_service_names");
+ return false;
+ }
+
+ utils::dbms::SQLQuery handled_rpcs_query(db());
+ if (!handled_rpcs_query.Prepare(sql_pt::kSelectAppServiceHandledRpcs)) {
+ LOG4CXX_WARN(logger_, "Incorrect select all from app_service_handled_rpcs");
+ return false;
+ }
+
+ service_type_query.Bind(0, app_id);
+ while (service_type_query.Next()) {
+ const int service_type_id = service_type_query.GetInteger(0);
+ std::string service_type = service_type_query.GetString(1);
+ (*app_service_parameters)[service_type] = policy_table::AppServiceInfo();
+
+ service_name_query.Bind(0, service_type_id);
+ while (service_name_query.Next()) {
+ LOG4CXX_DEBUG(logger_, "Loading service name");
+ (*app_service_parameters)[service_type].service_names->push_back(
+ service_name_query.GetString(0));
+ (*app_service_parameters)[service_type].service_names->mark_initialized();
+ }
+
+ handled_rpcs_query.Bind(0, service_type_id);
+ while (handled_rpcs_query.Next()) {
+ policy_table::AppServiceHandledRpc handled_rpc;
+ handled_rpc.function_id = handled_rpcs_query.GetInteger(0);
+ (*app_service_parameters)[service_type].handled_rpcs.push_back(
+ handled_rpc);
+ }
+
+ if (!service_name_query.Reset()) {
+ LOG4CXX_ERROR(logger_, "Could not reset service_name query");
+ return false;
+ }
+ if (!handled_rpcs_query.Reset()) {
+ LOG4CXX_ERROR(logger_, "Could not reset handled_rpcs query");
+ return false;
+ }
+ }
+
+ return true;
+}
+
bool SQLPTRepresentation::GatherNickName(
const std::string& app_id, policy_table::Strings* nicknames) const {
utils::dbms::SQLQuery query(db());
@@ -1740,6 +2175,10 @@ bool SQLPTRepresentation::GatherModuleType(
if (!policy_table::EnumFromJsonString(query.GetString(0), &type)) {
return false;
}
+ if (policy_table::ModuleType::MT_EMPTY == type) {
+ app_types->mark_initialized();
+ continue;
+ }
app_types->push_back(type);
}
return true;
@@ -1772,18 +2211,30 @@ bool SQLPTRepresentation::SaveModuleType(
}
policy_table::ModuleTypes::const_iterator it;
- for (it = types.begin(); it != types.end(); ++it) {
+ if (!types.empty()) {
+ for (it = types.begin(); it != types.end(); ++it) {
+ query.Bind(0, app_id);
+ std::string module(policy_table::EnumToJsonString(*it));
+ query.Bind(1, module);
+ LOG4CXX_DEBUG(logger_,
+ "Module(app: " << app_id << ", type: " << module << ")");
+ if (!query.Exec() || !query.Reset()) {
+ LOG4CXX_WARN(logger_, "Incorrect insert into module type.");
+ return false;
+ }
+ }
+ } else if (types.is_initialized()) {
query.Bind(0, app_id);
- std::string module(policy_table::EnumToJsonString(*it));
- query.Bind(1, module);
- LOG4CXX_DEBUG(logger_,
- "Module(app: " << app_id << ", type: " << module << ")");
+ query.Bind(1,
+ std::string(policy_table::EnumToJsonString(
+ policy_table::ModuleType::MT_EMPTY)));
if (!query.Exec() || !query.Reset()) {
- LOG4CXX_WARN(logger_, "Incorrect insert into module type.");
+ LOG4CXX_WARN(logger_, "Incorrect insert into module types.");
return false;
}
+ } else {
+ LOG4CXX_WARN(logger_, "Module Type omitted.");
}
-
return true;
}
@@ -2008,6 +2459,12 @@ bool SQLPTRepresentation::SetDefaultPolicy(const std::string& app_id) {
return false;
}
+ policy_table::AppServiceParameters app_service_parameters;
+ if (!GatherAppServiceParameters(kDefaultId, &app_service_parameters) ||
+ !SaveAppServiceParameters(app_id, app_service_parameters)) {
+ return false;
+ }
+
policy_table::Strings default_groups;
bool ret = (GatherAppGroup(kDefaultId, &default_groups) &&
SaveAppGroup(app_id, default_groups));
@@ -2080,6 +2537,198 @@ 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()) {
+ std::map<std::string, std::string> stored_vehicle_data_item_params;
+ for (const auto& param : *(vehicle_data_item.params)) {
+ if (!InsertVehicleDataItem(param)) {
+ return false;
+ }
+
+ if (stored_vehicle_data_item_params.end() !=
+ stored_vehicle_data_item_params.find(param.name)) {
+ LOG4CXX_DEBUG(logger_, "Parameter already stored.");
+ continue;
+ }
+
+ 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;
+ }
+ stored_vehicle_data_item_params[param.name] = param.key;
+ }
+ }
+
+ 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);
}
@@ -2109,7 +2758,7 @@ bool SQLPTRepresentation::CopyApplication(const std::string& source,
utils::dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kInsertApplicationFull)) {
- LOG4CXX_WARN(logger_, "Incorrect insert statement into application.");
+ LOG4CXX_WARN(logger_, "Incorrect insert statement into application full.");
return false;
}
query.Bind(0, destination);
@@ -2127,6 +2776,24 @@ bool SQLPTRepresentation::CopyApplication(const std::string& source,
: query.Bind(7, source_app.GetBoolean(6));
query.Bind(8, source_app.GetInteger(7));
query.Bind(9, source_app.GetInteger(8));
+ source_app.IsNull(9) ? query.Bind(10)
+ : query.Bind(10, source_app.GetString(9));
+ source_app.IsNull(10) ? query.Bind(11)
+ : query.Bind(11, source_app.GetString(10));
+ source_app.IsNull(11) ? query.Bind(12)
+ : query.Bind(12, source_app.GetString(11));
+ source_app.IsNull(12) ? query.Bind(13)
+ : query.Bind(13, source_app.GetBoolean(12));
+ source_app.IsNull(13) ? query.Bind(14)
+ : query.Bind(14, source_app.GetString(13));
+ source_app.IsNull(14) ? query.Bind(15)
+ : query.Bind(15, source_app.GetString(14));
+ source_app.IsNull(15) ? query.Bind(16)
+ : query.Bind(16, source_app.GetString(15));
+ source_app.IsNull(16) ? query.Bind(17)
+ : query.Bind(17, source_app.GetBoolean(16));
+ source_app.IsNull(17) ? query.Bind(18)
+ : query.Bind(18, source_app.GetBoolean(17));
if (!query.Exec()) {
LOG4CXX_WARN(logger_, "Failed inserting into application.");
diff --git a/src/components/policy/policy_external/src/status.cc b/src/components/policy/policy_external/src/status.cc
index 31fc7f110b..826cca5a2e 100644
--- a/src/components/policy/policy_external/src/status.cc
+++ b/src/components/policy/policy_external/src/status.cc
@@ -32,7 +32,6 @@
#include "policy/status.h"
#include "policy/update_status_manager.h"
-#include "utils/make_shared.h"
policy::UpToDateStatus::UpToDateStatus()
: Status(kUpToDate, policy::PolicyTableStatus::StatusUpToDate) {}
@@ -45,7 +44,7 @@ void policy::UpToDateStatus::ProcessEvent(UpdateStatusManager* manager,
case kScheduleUpdate:
case kScheduleManualUpdate:
case kOnResetRetrySequence:
- manager->SetNextStatus(utils::MakeShared<UpdateNeededStatus>());
+ manager->SetNextStatus(std::make_shared<UpdateNeededStatus>());
break;
default:
break;
@@ -59,14 +58,17 @@ void policy::UpdateNeededStatus::ProcessEvent(
policy::UpdateStatusManager* manager, policy::UpdateEvent event) {
switch (event) {
case kOnUpdateSentOut:
- manager->SetNextStatus(utils::MakeShared<UpdatingStatus>());
+ manager->SetNextStatus(std::make_shared<UpdatingStatus>());
break;
case kOnResetPolicyTableRequireUpdate:
- manager->SetNextStatus(utils::MakeShared<UpToDateStatus>());
- manager->SetPostponedStatus(utils::MakeShared<UpdateNeededStatus>());
+ manager->SetNextStatus(std::make_shared<UpToDateStatus>());
+ manager->SetPostponedStatus(std::make_shared<UpdateNeededStatus>());
break;
case kOnResetPolicyTableNoUpdate:
- manager->SetNextStatus(utils::MakeShared<UpToDateStatus>());
+ manager->SetNextStatus(std::make_shared<UpToDateStatus>());
+ break;
+ case kPendingUpdate:
+ manager->SetNextStatus(std::make_shared<UpdatePendingStatus>());
break;
default:
break;
@@ -77,6 +79,36 @@ bool policy::UpdateNeededStatus::IsUpdateRequired() const {
return true;
}
+policy::UpdatePendingStatus::UpdatePendingStatus()
+ : Status(kUpdateNeeded,
+ policy::PolicyTableStatus::StatusProcessingSnapshot) {}
+
+void policy::UpdatePendingStatus::ProcessEvent(
+ policy::UpdateStatusManager* manager, policy::UpdateEvent event) {
+ switch (event) {
+ case kOnUpdateSentOut:
+ manager->SetNextStatus(std::make_shared<UpdatingStatus>());
+ break;
+ case kOnResetPolicyTableRequireUpdate:
+ manager->SetNextStatus(std::make_shared<UpToDateStatus>());
+ manager->SetPostponedStatus(std::make_shared<UpdateNeededStatus>());
+ break;
+ case kOnResetPolicyTableNoUpdate:
+ manager->SetNextStatus(std::make_shared<UpToDateStatus>());
+ break;
+ default:
+ break;
+ }
+}
+
+bool policy::UpdatePendingStatus::IsUpdatePending() const {
+ return true;
+}
+
+bool policy::UpdatePendingStatus::IsUpdateRequired() const {
+ return true;
+}
+
policy::UpdatingStatus::UpdatingStatus()
: Status(kUpdating, policy::PolicyTableStatus::StatusUpdatePending) {}
@@ -85,23 +117,22 @@ void policy::UpdatingStatus::ProcessEvent(policy::UpdateStatusManager* manager,
switch (event) {
case kOnValidUpdateReceived:
case kOnResetPolicyTableNoUpdate:
- manager->SetNextStatus(utils::MakeShared<UpToDateStatus>());
- break;
- case kOnNewAppRegistered:
- manager->SetPostponedStatus(utils::MakeShared<UpdateNeededStatus>());
+ manager->SetNextStatus(std::make_shared<UpToDateStatus>());
break;
case kOnWrongUpdateReceived:
case kOnUpdateTimeout:
- manager->SetNextStatus(utils::MakeShared<UpdateNeededStatus>());
+ manager->SetNextStatus(std::make_shared<UpdateNeededStatus>());
break;
case kOnResetPolicyTableRequireUpdate:
- manager->SetNextStatus(utils::MakeShared<UpToDateStatus>());
- manager->SetPostponedStatus(utils::MakeShared<UpdateNeededStatus>());
+ manager->SetNextStatus(std::make_shared<UpToDateStatus>());
+ manager->SetPostponedStatus(std::make_shared<UpdateNeededStatus>());
break;
case kScheduleUpdate:
case kScheduleManualUpdate:
+ manager->SetPostponedStatus(std::make_shared<UpdateNeededStatus>());
+ break;
case kOnResetRetrySequence:
- manager->SetPostponedStatus(utils::MakeShared<UpdateNeededStatus>());
+ manager->SetNextStatus(std::make_shared<UpdateNeededStatus>());
break;
default:
break;
diff --git a/src/components/policy/policy_external/src/update_status_manager.cc b/src/components/policy/policy_external/src/update_status_manager.cc
index 087db1149b..d34d1b7817 100644
--- a/src/components/policy/policy_external/src/update_status_manager.cc
+++ b/src/components/policy/policy_external/src/update_status_manager.cc
@@ -32,8 +32,8 @@
#include "policy/update_status_manager.h"
#include "policy/policy_listener.h"
+#include "policy/ptu_retry_handler.h"
#include "utils/logger.h"
-#include "utils/make_shared.h"
namespace policy {
@@ -41,7 +41,7 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "Policy")
UpdateStatusManager::UpdateStatusManager()
: listener_(NULL)
- , current_status_(utils::MakeShared<UpToDateStatus>())
+ , current_status_(std::make_shared<UpToDateStatus>())
, last_processed_event_(kNoEvent)
, apps_search_in_progress_(false)
, app_registered_from_non_consented_device_(true) {
@@ -61,17 +61,18 @@ UpdateStatusManager::~UpdateStatusManager() {
}
void UpdateStatusManager::ProcessEvent(UpdateEvent event) {
+ LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock lock(status_lock_);
current_status_->ProcessEvent(this, event);
last_processed_event_ = event;
DoTransition();
}
-void UpdateStatusManager::SetNextStatus(utils::SharedPtr<Status> status) {
+void UpdateStatusManager::SetNextStatus(std::shared_ptr<Status> status) {
next_status_ = status;
}
-void UpdateStatusManager::SetPostponedStatus(utils::SharedPtr<Status> status) {
+void UpdateStatusManager::SetPostponedStatus(std::shared_ptr<Status> status) {
postponed_status_ = status;
}
@@ -88,6 +89,14 @@ void UpdateStatusManager::OnUpdateSentOut(uint32_t update_timeout) {
void UpdateStatusManager::OnUpdateTimeoutOccurs() {
LOG4CXX_AUTO_TRACE(logger_);
+
+ auto& ptu_retry_handler = listener_->ptu_retry_handler();
+
+ if (ptu_retry_handler.IsAllowedRetryCountExceeded()) {
+ ptu_retry_handler.RetrySequenceFailed();
+ return;
+ }
+
ProcessEvent(kOnUpdateTimeout);
DCHECK(update_status_thread_delegate_);
update_status_thread_delegate_->updateTimeOut(0); // Stop Timer
@@ -99,6 +108,12 @@ void UpdateStatusManager::OnValidUpdateReceived() {
ProcessEvent(kOnValidUpdateReceived);
}
+void UpdateStatusManager::ResetTimeout(uint32_t update_timeout) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ update_status_thread_delegate_->updateTimeOut(
+ update_timeout); // Restart Timer
+}
+
void UpdateStatusManager::OnWrongUpdateReceived() {
LOG4CXX_AUTO_TRACE(logger_);
update_status_thread_delegate_->updateTimeOut(0); // Stop Timer
@@ -119,21 +134,29 @@ void UpdateStatusManager::OnResetRetrySequence() {
ProcessEvent(kOnResetRetrySequence);
}
+void UpdateStatusManager::OnExistedApplicationAdded(
+ const bool is_update_required) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (is_update_required) {
+ current_status_.reset(new UpToDateStatus());
+ ProcessEvent(kScheduleUpdate);
+ }
+}
+
void UpdateStatusManager::OnNewApplicationAdded(const DeviceConsent consent) {
LOG4CXX_AUTO_TRACE(logger_);
if (kDeviceAllowed != consent) {
+ LOG4CXX_DEBUG(logger_, "Application registered from non-consented device");
app_registered_from_non_consented_device_ = true;
return;
}
+ LOG4CXX_DEBUG(logger_, "Application registered from consented device");
app_registered_from_non_consented_device_ = false;
- ProcessEvent(kOnNewAppRegistered);
-}
-
-void UpdateStatusManager::OnPolicyInit(bool is_update_required) {
- LOG4CXX_AUTO_TRACE(logger_);
- if (is_update_required) {
+ if (kOnResetRetrySequence == last_processed_event_) {
current_status_.reset(new UpToDateStatus());
ProcessEvent(kScheduleUpdate);
+ } else {
+ ProcessEvent(kOnNewAppRegistered);
}
}
@@ -153,10 +176,17 @@ bool UpdateStatusManager::IsUpdatePending() const {
}
void UpdateStatusManager::ScheduleUpdate() {
+ LOG4CXX_AUTO_TRACE(logger_);
ProcessEvent(kScheduleUpdate);
}
+void UpdateStatusManager::PendingUpdate() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ ProcessEvent(kPendingUpdate);
+}
+
void UpdateStatusManager::ScheduleManualUpdate() {
+ LOG4CXX_AUTO_TRACE(logger_);
ProcessEvent(kScheduleManualUpdate);
}
@@ -191,7 +221,10 @@ void UpdateStatusManager::DoTransition() {
current_status_ = next_status_;
next_status_.reset();
- if (last_processed_event_ != kScheduleManualUpdate) {
+ const bool is_update_pending =
+ policy::StatusProcessingSnapshot == current_status_->get_status();
+
+ if (last_processed_event_ != kScheduleManualUpdate && !is_update_pending) {
listener_->OnUpdateStatusChanged(current_status_->get_status_string());
}
@@ -210,7 +243,6 @@ UpdateStatusManager::UpdateThreadDelegate::UpdateThreadDelegate(
UpdateStatusManager* update_status_manager)
: timeout_(0)
, stop_flag_(false)
- , state_lock_(true)
, update_status_manager_(update_status_manager) {
LOG4CXX_AUTO_TRACE(logger_);
LOG4CXX_DEBUG(logger_, "Create UpdateThreadDelegate");
diff --git a/src/components/policy/policy_external/src/usage_statistics/counter.cc b/src/components/policy/policy_external/src/usage_statistics/counter.cc
index 661ea29704..5165c46edb 100644
--- a/src/components/policy/policy_external/src/usage_statistics/counter.cc
+++ b/src/components/policy/policy_external/src/usage_statistics/counter.cc
@@ -33,16 +33,16 @@
#ifndef SRC_COMPONENTS_POLICY_INCLUDE_POLICY_STATISTICS_MANAGER_H_
#define SRC_COMPONENTS_POLICY_INCLUDE_POLICY_STATISTICS_MANAGER_H_
-#include <cassert>
#include "policy/usage_statistics/counter.h"
+#include <cassert>
#include "utils/date_time.h"
-#include "utils/make_shared.h"
+
#include "utils/timer_task_impl.h"
namespace usage_statistics {
GlobalCounter::GlobalCounter(
- utils::SharedPtr<usage_statistics::StatisticsManager> statistics_manager,
+ std::shared_ptr<usage_statistics::StatisticsManager> statistics_manager,
GlobalCounterId counter_type)
: counter_type_(counter_type), statistics_manager_(statistics_manager) {}
@@ -53,7 +53,7 @@ void GlobalCounter::operator++() const {
}
AppCounter::AppCounter(
- utils::SharedPtr<usage_statistics::StatisticsManager> statistics_manager,
+ std::shared_ptr<usage_statistics::StatisticsManager> statistics_manager,
const std::string& app_id,
AppCounterId counter_type)
: app_id_(app_id)
@@ -67,7 +67,7 @@ void AppCounter::operator++() const {
}
AppInfo::AppInfo(
- utils::SharedPtr<usage_statistics::StatisticsManager> statistics_manager,
+ std::shared_ptr<usage_statistics::StatisticsManager> statistics_manager,
const std::string& app_id,
AppInfoId info_type)
: app_id_(app_id)
@@ -81,7 +81,7 @@ void AppInfo::Update(const std::string& new_info) const {
}
AppStopwatchImpl::AppStopwatchImpl(
- utils::SharedPtr<usage_statistics::StatisticsManager> statistics_manager,
+ std::shared_ptr<usage_statistics::StatisticsManager> statistics_manager,
const std::string& app_id)
: app_id_(app_id)
, stopwatch_type_(SECONDS_HMI_NONE)
@@ -92,7 +92,7 @@ AppStopwatchImpl::AppStopwatchImpl(
, time_out_(60) {}
AppStopwatchImpl::AppStopwatchImpl(
- utils::SharedPtr<StatisticsManager> statistics_manager,
+ std::shared_ptr<StatisticsManager> statistics_manager,
const std::string& app_id,
uint32_t timeout)
: app_id_(app_id)
@@ -107,8 +107,7 @@ AppStopwatchImpl::~AppStopwatchImpl() {}
void AppStopwatchImpl::Start(AppStopwatchId stopwatch_type) {
stopwatch_type_ = stopwatch_type;
- timer_.Start(time_out_ * date_time::DateTime::MILLISECONDS_IN_SECOND,
- timer::kPeriodic);
+ timer_.Start(time_out_ * date_time::MILLISECONDS_IN_SECOND, timer::kPeriodic);
}
void AppStopwatchImpl::Switch(AppStopwatchId stopwatch_type) {
diff --git a/src/components/policy/policy_external/test/CMakeLists.txt b/src/components/policy/policy_external/test/CMakeLists.txt
index 8b77c90dd2..77b1b35973 100644
--- a/src/components/policy/policy_external/test/CMakeLists.txt
+++ b/src/components/policy/policy_external/test/CMakeLists.txt
@@ -42,7 +42,7 @@ include_directories(
set(testLibraries
gmock
Utils
- Policy
+ PolicyStatic
UsageStatistics
ConfigProfile
)
diff --git a/src/components/policy/policy_external/test/counter_test.cc b/src/components/policy/policy_external/test/counter_test.cc
index 90f247de31..af166f96ad 100644
--- a/src/components/policy/policy_external/test/counter_test.cc
+++ b/src/components/policy/policy_external/test/counter_test.cc
@@ -28,12 +28,13 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
+
+#include "policy/usage_statistics/counter.h"
#include "gtest/gtest.h"
#include "policy/usage_statistics/mock_statistics_manager.h"
-#include "policy/usage_statistics/counter.h"
-using ::testing::StrictMock;
using ::testing::InSequence;
+using ::testing::StrictMock;
namespace test {
namespace components {
@@ -45,7 +46,7 @@ TEST(
StatisticsManagerIncrementMethod1Arg,
GlobalCounterOverloadedIncrement_CallONCE_StatisticsManagerIncrementCalledONCE) {
// Arrange
- MockStatisticsManager* msm = new StrictMock<MockStatisticsManager>();
+ auto msm = std::make_shared<StrictMock<MockStatisticsManager> >();
GlobalCounter reboots_counter(msm, SYNC_REBOOTS);
// Assert
@@ -59,7 +60,7 @@ TEST(
StatisticsManagerIncrementMethod1Arg,
GlobalCounterOverloadedIncrement_CallTWICE_StatisticsManagerIncrementCalledTWICE) {
// Arrange
- MockStatisticsManager* msm = new StrictMock<MockStatisticsManager>();
+ auto msm = std::make_shared<StrictMock<MockStatisticsManager> >();
GlobalCounter reboots_counter(msm, SYNC_REBOOTS);
// Assert
@@ -74,7 +75,7 @@ TEST(
StatisticsManagerIncrementMethod2Args,
AppCounterOverloadedIncrement_CallONCE_StatisticsManagerIncrementCalledONCE) {
// Arrange
- MockStatisticsManager* msm = new StrictMock<MockStatisticsManager>();
+ auto msm = std::make_shared<StrictMock<MockStatisticsManager> >();
AppCounter user_selections_counter(msm, "HelloApp", USER_SELECTIONS);
// Assert
@@ -88,7 +89,7 @@ TEST(
StatisticsManagerIncrementMethod2Args,
AppCounterOverloadedIncrement_CallTWICE_StatisticsManagerIncrementCalledTWICE) {
// Arrange
- MockStatisticsManager* msm = new StrictMock<MockStatisticsManager>();
+ auto msm = std::make_shared<StrictMock<MockStatisticsManager> >();
AppCounter user_selections_counter(msm, "HelloApp", USER_SELECTIONS);
// Assert
@@ -102,7 +103,7 @@ TEST(
TEST(StatisticsManagerSetMethod,
AppInfoUpdateMethod_CallONCE_StatisticsManagerSetMethodCalledONCE) {
// Arrange
- MockStatisticsManager* msm = new StrictMock<MockStatisticsManager>();
+ auto msm = std::make_shared<StrictMock<MockStatisticsManager> >();
AppInfo gui_language_info(msm, "HelloApp", LANGUAGE_GUI);
// Assert
@@ -115,7 +116,7 @@ TEST(StatisticsManagerSetMethod,
TEST(StatisticsManagerSetMethod,
AppInfoUpdateMethod_CallTWICE_StatisticsManagerSetMethodCalledTWICE) {
// Arrange
- MockStatisticsManager* msm = new StrictMock<MockStatisticsManager>();
+ auto msm = std::make_shared<StrictMock<MockStatisticsManager> >();
AppInfo gui_language_info(msm, "HelloApp", LANGUAGE_GUI);
// Assert
@@ -130,7 +131,7 @@ TEST(StatisticsManagerSetMethod,
TEST(StatisticsManagerAddMethod,
AppStopwatchStartMethod_CallONCE_StatisticsManagerAddMethodCalledONCE) {
// Arrange
- MockStatisticsManager* msm = new StrictMock<MockStatisticsManager>();
+ auto msm = std::make_shared<StrictMock<MockStatisticsManager> >();
const std::uint32_t time_out = 1;
AppStopwatchImpl hmi_full_stopwatch(msm, "HelloApp", time_out);
@@ -145,7 +146,7 @@ TEST(StatisticsManagerAddMethod,
TEST(StatisticsManagerAddMethod,
AppStopwatchSwitchMethod_Call_StatisticsManagerAddMethodCalled) {
// Arrange
- MockStatisticsManager* msm = new StrictMock<MockStatisticsManager>();
+ auto msm = std::make_shared<StrictMock<MockStatisticsManager> >();
AppStopwatchImpl hmi_full_stopwatch(msm, "HelloApp");
hmi_full_stopwatch.Start(SECONDS_HMI_FULL);
@@ -161,7 +162,7 @@ TEST(
StatisticsManagerAddMethod,
AppStopwatchSwitchMethod_CallAnd1SecSleepAfter_StatisticsManagerAddMethodCalledWith1SecTimespan) {
// Arrange
- MockStatisticsManager* msm = new StrictMock<MockStatisticsManager>();
+ auto msm = std::make_shared<StrictMock<MockStatisticsManager> >();
const std::uint32_t time_out = 1;
AppStopwatchImpl hmi_full_stopwatch(msm, "HelloApp", time_out);
@@ -178,6 +179,6 @@ TEST(
// Act
hmi_full_stopwatch.WriteTime();
}
-} // namespace usage_statistics
-} // components
+} // namespace usage_statistics_test
+} // namespace components
} // namespace test
diff --git a/src/components/policy/policy_external/test/generated_code_test.cc b/src/components/policy/policy_external/test/generated_code_test.cc
index 15d14e3e3b..03cfae511b 100644
--- a/src/components/policy/policy_external/test/generated_code_test.cc
+++ b/src/components/policy/policy_external/test/generated_code_test.cc
@@ -51,8 +51,9 @@ TEST(PolicyGeneratedCodeTest, TestValidPTPreloadJsonIsValid) {
std::ifstream json_file("json/sdl_preloaded_pt.json");
ASSERT_TRUE(json_file.is_open());
Json::Value valid_table;
- Json::Reader reader;
- ASSERT_TRUE(reader.parse(json_file, valid_table));
+ Json::CharReaderBuilder reader_builder;
+ ASSERT_TRUE(
+ Json::parseFromStream(reader_builder, json_file, &valid_table, nullptr));
Table table(&valid_table);
table.SetPolicyTableType(rpc::policy_table_interface_base::PT_PRELOADED);
ASSERT_RPCTYPE_VALID(table);
@@ -62,8 +63,9 @@ TEST(PolicyGeneratedCodeTest, TestValidPTUpdateJsonIsValid) {
std::ifstream json_file("json/valid_sdl_pt_update.json");
ASSERT_TRUE(json_file.is_open());
Json::Value valid_table;
- Json::Reader reader;
- ASSERT_TRUE(reader.parse(json_file, valid_table));
+ Json::CharReaderBuilder reader_builder;
+ ASSERT_TRUE(
+ Json::parseFromStream(reader_builder, json_file, &valid_table, nullptr));
Table table(&valid_table);
table.SetPolicyTableType(rpc::policy_table_interface_base::PT_UPDATE);
ASSERT_RPCTYPE_VALID(table);
diff --git a/src/components/policy/policy_external/test/include/policy/mock_pt_ext_representation.h b/src/components/policy/policy_external/test/include/policy/mock_pt_ext_representation.h
index 3225e79e01..b307270b10 100644
--- a/src/components/policy/policy_external/test/include/policy/mock_pt_ext_representation.h
+++ b/src/components/policy/policy_external/test/include/policy/mock_pt_ext_representation.h
@@ -37,10 +37,10 @@
#include "gmock/gmock.h"
+#include "mock_pt_representation.h"
+#include "policy/policy_table/types.h"
#include "policy/pt_ext_representation.h"
#include "rpc_base/rpc_base.h"
-#include "policy/policy_table/types.h"
-#include "mock_pt_representation.h"
namespace policy_table = ::rpc::policy_table_interface_base;
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 995c63ed20..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
@@ -37,9 +37,9 @@
#include "gmock/gmock.h"
+#include "policy/policy_table/types.h"
#include "policy/pt_representation.h"
#include "rpc_base/rpc_base.h"
-#include "policy/policy_table/types.h"
namespace policy_table = ::rpc::policy_table_interface_base;
@@ -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>(
@@ -78,7 +77,7 @@ class MockPTRepresentation : virtual public ::policy::PTRepresentation {
MOCK_METHOD0(Close, bool());
MOCK_METHOD0(Clear, bool());
MOCK_METHOD0(Drop, bool());
- MOCK_CONST_METHOD0(GenerateSnapshot, utils::SharedPtr<policy_table::Table>());
+ MOCK_CONST_METHOD0(GenerateSnapshot, std::shared_ptr<policy_table::Table>());
MOCK_METHOD1(Save, bool(const policy_table::Table& table));
MOCK_CONST_METHOD0(UpdateRequired, bool());
MOCK_METHOD1(SaveUpdateRequired, void(bool value));
diff --git a/src/components/policy/policy_external/test/include/policy/mock_update_status_manager.h b/src/components/policy/policy_external/test/include/policy/mock_update_status_manager.h
index a1c808d23a..662632fc59 100644
--- a/src/components/policy/policy_external/test/include/policy/mock_update_status_manager.h
+++ b/src/components/policy/policy_external/test/include/policy/mock_update_status_manager.h
@@ -33,7 +33,6 @@
#define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_TEST_INCLUDE_POLICY_MOCK_UPDATE_STATUS_MANAGER_H_
#include "gmock/gmock.h"
-
#include "policy/update_status_manager.h"
namespace test {
@@ -49,8 +48,8 @@ class MockUpdateStatusManager : public ::policy::UpdateStatusManager {
MOCK_METHOD0(OnWrongUpdateReceived, void());
MOCK_METHOD1(OnResetDefaultPT, void(bool is_update_required));
MOCK_METHOD0(OnResetRetrySequence, void());
+ MOCK_METHOD1(OnExistedApplicationAdded, void(const bool is_update_required));
MOCK_METHOD1(OnNewApplicationAdded, void(const DeviceConsent));
- MOCK_METHOD1(OnPolicyInit, void(bool is_update_required));
MOCK_METHOD0(GetUpdateStatus, PolicyTableStatus());
};
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 e753751308..40b57f9ed3 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
@@ -40,21 +40,22 @@
#include "policy/policy_manager_impl.h"
#include "policy/mock_cache_manager.h"
-#include "policy/mock_update_status_manager.h"
#include "policy/mock_policy_listener.h"
#include "policy/mock_policy_settings.h"
+#include "policy/mock_ptu_retry_handler.h"
+#include "policy/mock_update_status_manager.h"
namespace test {
namespace components {
namespace policy_test {
-using ::testing::NiceMock;
using ::policy::PolicyManagerImpl;
+using ::testing::NiceMock;
typedef std::multimap<std::string, policy_table::Rpcs&>
UserConsentPromptToRpcsConnections;
-typedef utils::SharedPtr<policy_table::Table> PolicyTableSPtr;
+typedef std::shared_ptr<policy_table::Table> PolicyTableSPtr;
namespace {
const std::string kSdlPreloadedPtJson = "json/sdl_preloaded_pt.json";
@@ -112,9 +113,11 @@ 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_;
+ PolicyTableSPtr default_pt_snapshot_;
void SetUp() OVERRIDE;
@@ -140,6 +143,7 @@ class PolicyManagerImplTest2 : public ::testing::Test {
PolicyManagerImpl* policy_manager_;
NiceMock<MockPolicyListener> listener_;
+ NiceMock<MockPTURetryHandler> ptu_retry_handler_;
::policy::StringArray hmi_level_;
::policy::StringArray pt_request_types_;
size_t ptu_request_types_size_;
@@ -203,7 +207,7 @@ class PolicyManagerImplTest2 : public ::testing::Test {
void EmulatePTAppRevoked(const std::string& ptu_name);
- utils::SharedPtr<policy_table::Table> PreconditionForBasicValidateSnapshot();
+ std::shared_ptr<policy_table::Table> PreconditionForBasicValidateSnapshot();
template <typename ParentType, typename Value>
bool IsKeyExisted(const ParentType& parent, const Value& value) const {
@@ -236,7 +240,7 @@ class PolicyManagerImplTest_RequestTypes : public ::testing::Test {
const std::string app_storage_folder_;
const std::string preloaded_pt_filename_;
- utils::SharedPtr<PolicyManagerImpl> policy_manager_impl_sptr_;
+ std::shared_ptr<PolicyManagerImpl> policy_manager_impl_sptr_;
NiceMock<MockPolicyListener> listener_;
NiceMock<policy_handler_test::MockPolicySettings> policy_settings_;
diff --git a/src/components/policy/policy_external/test/json/PTU.json b/src/components/policy/policy_external/test/json/PTU.json
index 5209030eec..c5f4b90120 100644
--- a/src/components/policy/policy_external/test/json/PTU.json
+++ b/src/components/policy/policy_external/test/json/PTU.json
@@ -403,6 +403,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -419,6 +420,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -435,6 +437,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -451,6 +454,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -481,6 +485,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -505,6 +510,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -529,6 +535,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
@@ -552,6 +559,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
diff --git a/src/components/policy/policy_external/test/json/PTU2.json b/src/components/policy/policy_external/test/json/PTU2.json
index 30746123d4..01cca4a6fd 100644
--- a/src/components/policy/policy_external/test/json/PTU2.json
+++ b/src/components/policy/policy_external/test/json/PTU2.json
@@ -403,6 +403,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -419,6 +420,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -435,6 +437,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -451,6 +454,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -481,6 +485,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -505,6 +510,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -529,6 +535,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
@@ -552,6 +559,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
diff --git a/src/components/policy/policy_external/test/json/PTU3.json b/src/components/policy/policy_external/test/json/PTU3.json
index f3bd615c73..f48f246114 100644
--- a/src/components/policy/policy_external/test/json/PTU3.json
+++ b/src/components/policy/policy_external/test/json/PTU3.json
@@ -403,6 +403,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -419,6 +420,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -435,6 +437,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -451,6 +454,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -481,6 +485,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -505,6 +510,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -529,6 +535,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
@@ -552,6 +559,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
diff --git a/src/components/policy/policy_external/test/json/PTU_with_empty_requestType_array.json b/src/components/policy/policy_external/test/json/PTU_with_empty_requestType_array.json
index 6db3836e4a..1e99e7442c 100644
--- a/src/components/policy/policy_external/test/json/PTU_with_empty_requestType_array.json
+++ b/src/components/policy/policy_external/test/json/PTU_with_empty_requestType_array.json
@@ -1438,6 +1438,7 @@
"parameters" : [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -1450,6 +1451,7 @@
"parameters" : [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -1462,6 +1464,7 @@
"parameters" : [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -1474,6 +1477,7 @@
"parameters" : [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -1601,6 +1605,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -1619,6 +1624,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -1637,6 +1643,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
@@ -1654,6 +1661,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
diff --git a/src/components/policy/policy_external/test/json/PTU_with_invalid_requestType_between_correct.json b/src/components/policy/policy_external/test/json/PTU_with_invalid_requestType_between_correct.json
index 22f7bd2930..dc40c3a182 100644
--- a/src/components/policy/policy_external/test/json/PTU_with_invalid_requestType_between_correct.json
+++ b/src/components/policy/policy_external/test/json/PTU_with_invalid_requestType_between_correct.json
@@ -1441,6 +1441,7 @@
"parameters" : [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -1453,6 +1454,7 @@
"parameters" : [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -1465,6 +1467,7 @@
"parameters" : [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -1477,6 +1480,7 @@
"parameters" : [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -1604,6 +1608,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -1622,6 +1627,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -1640,6 +1646,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
@@ -1657,6 +1664,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
diff --git a/src/components/policy/policy_external/test/json/PTU_with_one_invalid_requestType.json b/src/components/policy/policy_external/test/json/PTU_with_one_invalid_requestType.json
index 83a2b308bb..3fcc71ca72 100644
--- a/src/components/policy/policy_external/test/json/PTU_with_one_invalid_requestType.json
+++ b/src/components/policy/policy_external/test/json/PTU_with_one_invalid_requestType.json
@@ -1438,6 +1438,7 @@
"parameters" : [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -1450,6 +1451,7 @@
"parameters" : [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -1462,6 +1464,7 @@
"parameters" : [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -1474,6 +1477,7 @@
"parameters" : [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -1601,6 +1605,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -1619,6 +1624,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -1637,6 +1643,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
@@ -1654,6 +1661,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
diff --git a/src/components/policy/policy_external/test/json/PTU_without_requestType_field.json b/src/components/policy/policy_external/test/json/PTU_without_requestType_field.json
index 8509935752..03a5e8d203 100644
--- a/src/components/policy/policy_external/test/json/PTU_without_requestType_field.json
+++ b/src/components/policy/policy_external/test/json/PTU_without_requestType_field.json
@@ -1437,6 +1437,7 @@
"parameters" : [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -1449,6 +1450,7 @@
"parameters" : [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -1461,6 +1463,7 @@
"parameters" : [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -1473,6 +1476,7 @@
"parameters" : [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -1600,6 +1604,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -1618,6 +1623,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -1636,6 +1642,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
@@ -1653,6 +1660,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
diff --git a/src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_reqestType_between_valid.json b/src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_reqestType_between_valid.json
index 4d99dfbc35..b5dd0bfff5 100644
--- a/src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_reqestType_between_valid.json
+++ b/src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_reqestType_between_valid.json
@@ -296,6 +296,7 @@
"LIMITED"],
"parameters": ["accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -308,6 +309,7 @@
"LIMITED"],
"parameters": ["accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -320,6 +322,7 @@
"LIMITED"],
"parameters": ["accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -332,6 +335,7 @@
"LIMITED"],
"parameters": ["accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -358,6 +362,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -378,6 +383,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -398,6 +404,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"]
@@ -417,6 +424,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"]
diff --git a/src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_requestType.json b/src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_requestType.json
index aeed9655e1..8fa8e6f3d0 100644
--- a/src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_requestType.json
+++ b/src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_requestType.json
@@ -296,6 +296,7 @@
"LIMITED"],
"parameters": ["accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -308,6 +309,7 @@
"LIMITED"],
"parameters": ["accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -320,6 +322,7 @@
"LIMITED"],
"parameters": ["accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -332,6 +335,7 @@
"LIMITED"],
"parameters": ["accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -358,6 +362,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -378,6 +383,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -398,6 +404,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"]
@@ -417,6 +424,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"]
diff --git a/src/components/policy/policy_external/test/json/preloadedPT_with_several_invalid_default_requestTypes.json b/src/components/policy/policy_external/test/json/preloadedPT_with_several_invalid_default_requestTypes.json
index 2e99c6c8ee..589cdc7a81 100644
--- a/src/components/policy/policy_external/test/json/preloadedPT_with_several_invalid_default_requestTypes.json
+++ b/src/components/policy/policy_external/test/json/preloadedPT_with_several_invalid_default_requestTypes.json
@@ -296,6 +296,7 @@
"LIMITED"],
"parameters": ["accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -308,6 +309,7 @@
"LIMITED"],
"parameters": ["accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -320,6 +322,7 @@
"LIMITED"],
"parameters": ["accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -332,6 +335,7 @@
"LIMITED"],
"parameters": ["accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -358,6 +362,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -378,6 +383,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -398,6 +404,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"]
@@ -417,6 +424,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"]
diff --git a/src/components/policy/policy_external/test/json/ptu2_requestType.json b/src/components/policy/policy_external/test/json/ptu2_requestType.json
index 9a6ad3720d..9b580b2a08 100644
--- a/src/components/policy/policy_external/test/json/ptu2_requestType.json
+++ b/src/components/policy/policy_external/test/json/ptu2_requestType.json
@@ -415,6 +415,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -431,6 +432,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -447,6 +449,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -463,6 +466,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -493,6 +497,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -517,6 +522,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -541,6 +547,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
@@ -564,6 +571,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
diff --git a/src/components/policy/policy_external/test/json/ptu_requestType.json b/src/components/policy/policy_external/test/json/ptu_requestType.json
index 87fcf17aee..8d18a9e336 100644
--- a/src/components/policy/policy_external/test/json/ptu_requestType.json
+++ b/src/components/policy/policy_external/test/json/ptu_requestType.json
@@ -414,6 +414,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -430,6 +431,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -446,6 +448,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -462,6 +465,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -492,6 +496,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -516,6 +521,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -540,6 +546,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
@@ -563,6 +570,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
diff --git a/src/components/policy/policy_external/test/json/sdl_preloaded_pt.json b/src/components/policy/policy_external/test/json/sdl_preloaded_pt.json
index 7f5436b5b6..ad264c8518 100644
--- a/src/components/policy/policy_external/test/json/sdl_preloaded_pt.json
+++ b/src/components/policy/policy_external/test/json/sdl_preloaded_pt.json
@@ -297,6 +297,7 @@
"LIMITED"],
"parameters": ["accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -309,6 +310,7 @@
"LIMITED"],
"parameters": ["accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -321,6 +323,7 @@
"LIMITED"],
"parameters": ["accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -333,6 +336,7 @@
"LIMITED"],
"parameters": ["accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -359,6 +363,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -379,6 +384,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -399,6 +405,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"]
@@ -418,6 +425,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"]
diff --git a/src/components/policy/policy_external/test/json/sdl_preloaded_pt1.json b/src/components/policy/policy_external/test/json/sdl_preloaded_pt1.json
index 37e0476683..909fd2cb2f 100644
--- a/src/components/policy/policy_external/test/json/sdl_preloaded_pt1.json
+++ b/src/components/policy/policy_external/test/json/sdl_preloaded_pt1.json
@@ -2051,6 +2051,7 @@
[
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -2065,6 +2066,7 @@
[
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -2079,6 +2081,7 @@
[
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -2093,6 +2096,7 @@
[
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -2317,6 +2321,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -2339,6 +2344,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -2361,6 +2367,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
@@ -2382,6 +2389,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
diff --git a/src/components/policy/policy_external/test/json/sdl_preloaded_pt_send_location.json b/src/components/policy/policy_external/test/json/sdl_preloaded_pt_send_location.json
index 2a503ab4a1..87fac7c76c 100644
--- a/src/components/policy/policy_external/test/json/sdl_preloaded_pt_send_location.json
+++ b/src/components/policy/policy_external/test/json/sdl_preloaded_pt_send_location.json
@@ -415,6 +415,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -431,6 +432,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -447,6 +449,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -463,6 +466,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -493,6 +497,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -517,6 +522,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -541,6 +547,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
@@ -564,6 +571,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
diff --git a/src/components/policy/policy_external/test/json/sdl_pt_first_update.json b/src/components/policy/policy_external/test/json/sdl_pt_first_update.json
index d28f70379c..440963ba48 100644
--- a/src/components/policy/policy_external/test/json/sdl_pt_first_update.json
+++ b/src/components/policy/policy_external/test/json/sdl_pt_first_update.json
@@ -1431,6 +1431,7 @@
"parameters" : [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -1443,6 +1444,7 @@
"parameters" : [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -1455,6 +1457,7 @@
"parameters" : [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -1467,6 +1470,7 @@
"parameters" : [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -1618,6 +1622,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -1636,6 +1641,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -1654,6 +1660,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
@@ -1671,6 +1678,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
diff --git a/src/components/policy/policy_external/test/json/sdl_pt_second_update.json b/src/components/policy/policy_external/test/json/sdl_pt_second_update.json
index 7bf287671e..5900acbcfb 100644
--- a/src/components/policy/policy_external/test/json/sdl_pt_second_update.json
+++ b/src/components/policy/policy_external/test/json/sdl_pt_second_update.json
@@ -1431,6 +1431,7 @@
"parameters" : [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -1443,6 +1444,7 @@
"parameters" : [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -1455,6 +1457,7 @@
"parameters" : [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -1467,6 +1470,7 @@
"parameters" : [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -1618,6 +1622,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -1636,6 +1641,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -1654,6 +1660,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
@@ -1671,6 +1678,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
diff --git a/src/components/policy/policy_external/test/json/sdl_pt_update.json b/src/components/policy/policy_external/test/json/sdl_pt_update.json
index 6b130c8f60..b3affeb91d 100644
--- a/src/components/policy/policy_external/test/json/sdl_pt_update.json
+++ b/src/components/policy/policy_external/test/json/sdl_pt_update.json
@@ -1431,6 +1431,7 @@
"parameters" : [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -1443,6 +1444,7 @@
"parameters" : [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -1455,6 +1457,7 @@
"parameters" : [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -1467,6 +1470,7 @@
"parameters" : [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -1602,6 +1606,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -1620,6 +1625,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -1638,6 +1644,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
@@ -1655,6 +1662,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
diff --git a/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_have_params.json b/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_have_params.json
index be177335fe..639d0143c8 100644
--- a/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_have_params.json
+++ b/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_have_params.json
@@ -414,6 +414,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -430,6 +431,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -446,6 +448,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -462,6 +465,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -492,6 +496,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -516,6 +521,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -540,6 +546,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
@@ -563,6 +570,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
diff --git a/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1.json b/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1.json
index 58e3f2fad3..53216cab3d 100644
--- a/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1.json
+++ b/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1.json
@@ -414,6 +414,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -430,6 +431,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -446,6 +448,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -462,6 +465,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -492,6 +496,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -516,6 +521,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -540,6 +546,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
@@ -563,6 +570,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
diff --git a/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1_omitted_in2.json b/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1_omitted_in2.json
index 4b10f8c80b..a529dc9a3b 100644
--- a/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1_omitted_in2.json
+++ b/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1_omitted_in2.json
@@ -414,6 +414,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -430,6 +431,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -446,6 +448,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -462,6 +465,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -492,6 +496,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -516,6 +521,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -540,6 +546,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
@@ -563,6 +570,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
diff --git a/src/components/policy/policy_external/test/json/sdl_update_pt_send_location.json b/src/components/policy/policy_external/test/json/sdl_update_pt_send_location.json
index 7728b69a0b..a57791e248 100644
--- a/src/components/policy/policy_external/test/json/sdl_update_pt_send_location.json
+++ b/src/components/policy/policy_external/test/json/sdl_update_pt_send_location.json
@@ -414,6 +414,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -430,6 +431,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -446,6 +448,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -462,6 +465,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -492,6 +496,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -516,6 +521,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -540,6 +546,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
@@ -563,6 +570,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
diff --git a/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_all_params.json b/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_all_params.json
index aaa7664d06..5a633e7c95 100644
--- a/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_all_params.json
+++ b/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_all_params.json
@@ -414,6 +414,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -430,6 +431,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -446,6 +448,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -462,6 +465,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -492,6 +496,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -516,6 +521,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -540,6 +546,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
@@ -563,6 +570,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
diff --git a/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_no_params.json b/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_no_params.json
index 079892677d..86c121491b 100644
--- a/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_no_params.json
+++ b/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_no_params.json
@@ -414,6 +414,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -430,6 +431,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -446,6 +448,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -462,6 +465,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -492,6 +496,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -516,6 +521,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -540,6 +546,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
@@ -563,6 +570,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
diff --git a/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_some_params.json b/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_some_params.json
index 82048d21e6..2b57912016 100644
--- a/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_some_params.json
+++ b/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_some_params.json
@@ -414,6 +414,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -430,6 +431,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -446,6 +448,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -462,6 +465,7 @@
"parameters": [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -492,6 +496,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -516,6 +521,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -540,6 +546,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
@@ -563,6 +570,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
diff --git a/src/components/policy/policy_external/test/json/valid_sdl_pt_update.json b/src/components/policy/policy_external/test/json/valid_sdl_pt_update.json
index 81521a2e0b..acf18c5706 100644
--- a/src/components/policy/policy_external/test/json/valid_sdl_pt_update.json
+++ b/src/components/policy/policy_external/test/json/valid_sdl_pt_update.json
@@ -20,7 +20,13 @@
"nicknames" : [ "SyncProxyTester" ],
"priority" : "EMERGENCY",
"steal_focus" : true,
- "heart_beat_timeout_ms": 5000
+ "heart_beat_timeout_ms": 5000,
+ "app_services": {
+ "MEDIA": {
+ "service_names" : ["SDL App", "SDL Music"],
+ "handled_rpcs" : [{"function_id": 41}]
+ }
+ }
},
"default" : {
"default_hmi" : "NONE",
@@ -1431,6 +1437,7 @@
"parameters" : [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -1443,6 +1450,7 @@
"parameters" : [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -1455,6 +1463,7 @@
"parameters" : [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -1467,6 +1476,7 @@
"parameters" : [
"accPedalPosition",
"beltStatus",
+ "electronicParkBrakeStatus",
"driverBraking",
"myKey",
"prndl",
@@ -1594,6 +1604,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -1612,6 +1623,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -1630,6 +1642,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
@@ -1647,6 +1660,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
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 947bb5d3ad..d5be757139 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
@@ -30,19 +30,19 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <stdint.h>
#include <fstream>
#include <string>
#include <vector>
-#include <stdint.h>
#include "gtest/gtest.h"
#include "policy/policy_manager_impl_test_base.h"
#include "policy/policy_table/types.h"
+#include "json/reader.h"
#include "utils/date_time.h"
#include "utils/gen_hash.h"
-#include "json/reader.h"
namespace test {
namespace components {
@@ -92,7 +92,8 @@ TEST_F(PolicyManagerImplTest,
EXPECT_CALL(*cache_manager_, IsApplicationRepresented(_))
.WillOnce(Return(true));
EXPECT_EQ(policy_manager_->GetPolicyTableStatus(), "UP_TO_DATE");
- policy_manager_->AddApplication(kDefaultId,
+ policy_manager_->AddApplication(kDefaultDeviceMacAddress,
+ kDefaultId,
HmiTypes(policy_table::AHT_DEFAULT));
EXPECT_EQ(policy_manager_->GetPolicyTableStatus(), "UP_TO_DATE");
}
@@ -109,31 +110,34 @@ TEST_F(PolicyManagerImplTest2, GetNotificationsNumberAfterPTUpdate) {
// Act
std::string json = table.toStyledString();
::policy::BinaryMessage msg(json.begin(), json.end());
- EXPECT_CALL(listener_, OnUpdateStatusChanged(_));
- EXPECT_TRUE(policy_manager_->LoadPT(kFilePtUpdateJson, msg));
+ ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess,
+ policy_manager_->LoadPT(kFilePtUpdateJson, msg));
EXPECT_FALSE(policy_manager_->GetCache()->IsPTPreloaded());
- std::string priority = "emergency";
+ EXPECT_CALL(listener_, OnUpdateStatusChanged(_));
+ policy_manager_->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess);
+
+ std::string priority = "EMERGENCY";
uint32_t notif_number = policy_manager_->GetNotificationsNumber(priority);
EXPECT_EQ(1u, notif_number);
- priority = "navigation";
+ priority = "NAVIGATION";
notif_number = policy_manager_->GetNotificationsNumber(priority);
EXPECT_EQ(2u, notif_number);
- priority = "emergency";
+ priority = "EMERGENCY";
notif_number = policy_manager_->GetNotificationsNumber(priority);
EXPECT_EQ(1u, notif_number);
- priority = "VOICECOMM";
+ priority = "VOICECOM";
notif_number = policy_manager_->GetNotificationsNumber(priority);
EXPECT_EQ(3u, notif_number);
- priority = "normal";
+ priority = "NORMAL";
notif_number = policy_manager_->GetNotificationsNumber(priority);
EXPECT_EQ(5u, notif_number);
- priority = "none";
+ priority = "NONE";
notif_number = policy_manager_->GetNotificationsNumber(priority);
EXPECT_EQ(6u, notif_number);
}
@@ -142,15 +146,15 @@ TEST_F(PolicyManagerImplTest2, IsAppRevoked_SetRevokedAppID_ExpectAppRevoked) {
// Arrange
CreateLocalPT(preloaded_pt_filename_);
- policy_manager_->AddApplication(app_id_1_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_1_, app_id_1_, HmiTypes(policy_table::AHT_DEFAULT));
std::ifstream ifile(kValidSdlPtUpdateJson);
- Json::Reader reader;
+ Json::CharReaderBuilder reader_builder;
std::string json;
Json::Value root(Json::objectValue);
if (ifile.is_open()) {
- if (reader.parse(ifile, root, true)) {
+ if (Json::parseFromStream(reader_builder, ifile, &root, nullptr)) {
root["policy_table"]["app_policies"][app_id_1_] = Json::nullValue;
json = root.toStyledString();
}
@@ -158,7 +162,10 @@ TEST_F(PolicyManagerImplTest2, IsAppRevoked_SetRevokedAppID_ExpectAppRevoked) {
ifile.close();
::policy::BinaryMessage msg(json.begin(), json.end());
- ASSERT_TRUE(policy_manager_->LoadPT(kFilePtUpdateJson, msg));
+ ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess,
+ policy_manager_->LoadPT(kFilePtUpdateJson, msg));
+ policy_manager_->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess);
+
EXPECT_FALSE(policy_manager_->GetCache()->IsPTPreloaded());
CheckRpcPermissions(
app_id_1_, "UnregisterAppInterface", ::policy::kRpcDisallowed);
@@ -174,8 +181,8 @@ TEST_F(PolicyManagerImplTest2, AppRevokedOne_AppRegistered) {
EXPECT_FALSE(policy_manager_->GetCache()->IsPTPreloaded());
ASSERT_TRUE(
(policy_manager_->GetCache())->AddDevice(device_id_2_, "Bluetooth"));
- policy_manager_->AddApplication(application_id_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_2_, application_id_, HmiTypes(policy_table::AHT_DEFAULT));
// Registration is allowed
CheckRpcPermissions("RegisterAppInterface", ::policy::kRpcAllowed);
}
@@ -187,12 +194,13 @@ TEST_F(PolicyManagerImplTest2, AppRevokedOne_AppRegistered_HMIDefault) {
EmulatePTAppRevoked(kPtu2Json);
EXPECT_FALSE(policy_manager_->GetCache()->IsPTPreloaded());
- policy_manager_->AddApplication(application_id_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_1_, application_id_, HmiTypes(policy_table::AHT_DEFAULT));
std::string default_hmi;
// Default HMI level is NONE
- EXPECT_TRUE(policy_manager_->GetDefaultHmi(application_id_, &default_hmi));
+ EXPECT_TRUE(policy_manager_->GetDefaultHmi(
+ device_id_1_, application_id_, &default_hmi));
EXPECT_EQ("NONE", default_hmi);
}
@@ -210,12 +218,18 @@ TEST_F(PolicyManagerImplTest2,
"Life",
2,
"Bluetooth");
- EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_1_))
- .WillRepeatedly(Return(device_id_1_));
+
+ EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(_, app_id_1_))
+ .Times(0);
+ ON_CALL(listener_, GetDevicesIds(_))
+ .WillByDefault(Return(transport_manager::DeviceList()));
+ ON_CALL(listener_, GetDevicesIds(app_id_1_))
+ .WillByDefault(Return(transport_manager::DeviceList(1, device_id_1_)));
+
policy_manager_->SetUserConsentForDevice(device_id_1_, true);
// Add app from consented device. App will be assigned with default policies
- policy_manager_->AddApplication(app_id_1_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_1_, app_id_1_, HmiTypes(policy_table::AHT_DEFAULT));
// Check before action
policy_table::RpcParameters rpc_parameters;
rpc_parameters.hmi_levels.push_back(policy_table::HL_FULL);
@@ -227,28 +241,31 @@ TEST_F(PolicyManagerImplTest2,
::policy::CheckPermissionResult output;
policy_manager_->CheckPermissions(
- app_id_1_, kHmiLevelFull, "Alert", input_params, output);
+ device_id_1_, app_id_1_, kHmiLevelFull, "Alert", input_params, output);
// Check RPC is allowed
EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted);
ASSERT_TRUE(output.list_of_allowed_params.empty());
// Act
std::ifstream ifile(kValidSdlPtUpdateJson);
- Json::Reader reader;
+ Json::CharReaderBuilder reader_builder;
std::string json;
Json::Value root(Json::objectValue);
EXPECT_TRUE(ifile.is_open());
- EXPECT_TRUE(reader.parse(ifile, root, true));
+ EXPECT_TRUE(Json::parseFromStream(reader_builder, ifile, &root, nullptr));
root["policy_table"]["app_policies"][app_id_1_] = Json::nullValue;
json = root.toStyledString();
ifile.close();
::policy::BinaryMessage msg(json.begin(), json.end());
- ASSERT_TRUE(policy_manager_->LoadPT(kFilePtUpdateJson, msg));
+ ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess,
+ policy_manager_->LoadPT(kFilePtUpdateJson, msg));
+ policy_manager_->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess);
+
EXPECT_FALSE(cache->IsPTPreloaded());
policy_manager_->CheckPermissions(
- app_id_1_, kHmiLevelFull, "Alert", input_params, output);
+ device_id_1_, app_id_1_, kHmiLevelFull, "Alert", input_params, output);
// Check RPC is disallowed
EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted);
ASSERT_TRUE(output.list_of_allowed_params.empty());
@@ -269,18 +286,25 @@ TEST_F(PolicyManagerImplTest2,
"Life",
2,
"Bluetooth"));
- EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(application_id_))
- .WillRepeatedly(Return(device_id_1_));
+ EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(_, application_id_))
+ .Times(0);
+
+ ON_CALL(listener_, GetDevicesIds(_))
+ .WillByDefault(Return(transport_manager::DeviceList()));
+ ON_CALL(listener_, GetDevicesIds(app_id_1_))
+ .WillByDefault(Return(transport_manager::DeviceList(1, device_id_1_)));
+
policy_manager_->SetUserConsentForDevice(device_id_1_, true);
// Add app from consented device. App will be assigned with default policies
- policy_manager_->AddApplication(application_id_,
- HmiTypes(policy_table::AHT_MEDIA));
+ policy_manager_->AddApplication(
+ device_id_1_, application_id_, HmiTypes(policy_table::AHT_MEDIA));
// Emulate PTU with new policies for app added above
std::ifstream ifile(kValidSdlPtUpdateJson);
- Json::Reader reader;
+ Json::CharReaderBuilder reader_builder;
std::string json;
Json::Value root(Json::objectValue);
- if (ifile.is_open() && reader.parse(ifile, root, true)) {
+ if (ifile.is_open() &&
+ Json::parseFromStream(reader_builder, ifile, &root, nullptr)) {
// Add AppID with policies
root["policy_table"]["app_policies"][application_id_] =
Json::Value(Json::objectValue);
@@ -312,7 +336,10 @@ TEST_F(PolicyManagerImplTest2,
::policy::BinaryMessage msg(json.begin(), json.end());
// Load Json to cache
- EXPECT_TRUE(policy_manager_->LoadPT(kFilePtUpdateJson, msg));
+ ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess,
+ policy_manager_->LoadPT(kFilePtUpdateJson, msg));
+ policy_manager_->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess);
+
EXPECT_FALSE(cache->IsPTPreloaded());
policy_table::RpcParameters rpc_parameters;
@@ -323,8 +350,6 @@ TEST_F(PolicyManagerImplTest2,
::policy::RPCParams input_params;
::policy::CheckPermissionResult output;
- EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(application_id_))
- .WillOnce(Return(device_id_1_));
cache->AddDevice(device_id_1_, "Bluetooth");
cache->SetDeviceData(device_id_1_,
"hardware IPX",
@@ -334,8 +359,12 @@ TEST_F(PolicyManagerImplTest2,
"Life",
2,
"Bluetooth");
- policy_manager_->CheckPermissions(
- application_id_, kHmiLevelFull, "Alert", input_params, output);
+ policy_manager_->CheckPermissions(device_id_1_,
+ application_id_,
+ kHmiLevelFull,
+ "Alert",
+ input_params,
+ output);
// Check RPC is allowed
EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted);
// Check list of parameters empty
@@ -344,21 +373,22 @@ TEST_F(PolicyManagerImplTest2,
TEST_F(PolicyManagerImplTest2,
CheckPermissions_NoParametersInPT_CheckRpcsInDifferentLevels) {
+ EXPECT_CALL(listener_, GetDevicesIds(application_id_))
+ .WillRepeatedly(Return(transport_manager::DeviceList()));
// Arrange
AddSetDeviceData();
LoadPTUFromJsonFile("json/sdl_update_pt_send_location.json");
- // Will be called each time permissions are checked
- EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(application_id_))
- .Times(4)
- .WillRepeatedly(Return(device_id_1_));
-
// Check RPC in each level
::policy::RPCParams input_params;
::policy::CheckPermissionResult output;
// Rpc in FULL level
- policy_manager_->CheckPermissions(
- application_id_, kHmiLevelFull, "SendLocation", input_params, output);
+ policy_manager_->CheckPermissions(device_id_1_,
+ application_id_,
+ kHmiLevelFull,
+ "SendLocation",
+ input_params,
+ output);
// Check RPC is allowed
EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted);
ASSERT_TRUE(output.list_of_allowed_params.empty());
@@ -367,8 +397,12 @@ TEST_F(PolicyManagerImplTest2,
ResetOutputList(output);
// Rpc in LIMITED level
- policy_manager_->CheckPermissions(
- application_id_, kHmiLevelLimited, "SendLocation", input_params, output);
+ policy_manager_->CheckPermissions(device_id_1_,
+ application_id_,
+ kHmiLevelLimited,
+ "SendLocation",
+ input_params,
+ output);
// Check RPC is allowed
EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted);
ASSERT_TRUE(output.list_of_allowed_params.empty());
@@ -376,7 +410,8 @@ TEST_F(PolicyManagerImplTest2,
ResetOutputList(output);
// Rpc in BACKGROUND level
- policy_manager_->CheckPermissions(application_id_,
+ policy_manager_->CheckPermissions(device_id_1_,
+ application_id_,
kHmiLevelBackground,
"SendLocation",
input_params,
@@ -388,8 +423,12 @@ TEST_F(PolicyManagerImplTest2,
ResetOutputList(output);
// Rpc in NONE level
- policy_manager_->CheckPermissions(
- application_id_, kHmiLevelNone, "SendLocation", input_params, output);
+ policy_manager_->CheckPermissions(device_id_1_,
+ application_id_,
+ kHmiLevelNone,
+ "SendLocation",
+ input_params,
+ output);
// Check RPC is disallowed
EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted);
// Check list of parameters is empty
@@ -399,24 +438,25 @@ TEST_F(PolicyManagerImplTest2,
TEST_F(
PolicyManagerImplTest2,
CheckPermissions_ParamsNotAllowedInPT_AddAppWithAllParams_CheckRpcsInDiffLvls) {
+ EXPECT_CALL(listener_, GetDevicesIds(application_id_))
+ .WillRepeatedly(Return(transport_manager::DeviceList()));
// Arrange
AddSetDeviceData();
// File have empty parameters, so they are forbidden
LoadPTUFromJsonFile("json/sdl_update_pt_send_location_no_params.json");
- // Will be called each time permissions are checked
- EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(application_id_))
- .Times(4)
- .WillRepeatedly(Return(device_id_1_));
-
// Check RPC in each level
::policy::RPCParams input_params;
InsertRpcParametersInList(input_params);
::policy::CheckPermissionResult output;
// Rpc in FULL level
- policy_manager_->CheckPermissions(
- application_id_, kHmiLevelFull, "SendLocation", input_params, output);
+ policy_manager_->CheckPermissions(device_id_1_,
+ application_id_,
+ kHmiLevelFull,
+ "SendLocation",
+ input_params,
+ output);
// Group which has RPC does not require user consent, so its auto-allowed for
// user. Since RPC 'parameters' section is present, but empty, that means
@@ -431,8 +471,12 @@ TEST_F(
ResetOutputList(output);
// Rpc in LIMITED level
- policy_manager_->CheckPermissions(
- application_id_, kHmiLevelLimited, "SendLocation", input_params, output);
+ policy_manager_->CheckPermissions(device_id_1_,
+ application_id_,
+ kHmiLevelLimited,
+ "SendLocation",
+ input_params,
+ output);
EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted);
@@ -443,7 +487,8 @@ TEST_F(
ResetOutputList(output);
// Rpc in BACKGROUND level
- policy_manager_->CheckPermissions(application_id_,
+ policy_manager_->CheckPermissions(device_id_1_,
+ application_id_,
kHmiLevelBackground,
"SendLocation",
input_params,
@@ -459,8 +504,12 @@ TEST_F(
ResetOutputList(output);
// Rpc in NONE level
- policy_manager_->CheckPermissions(
- application_id_, kHmiLevelNone, "SendLocation", input_params, output);
+ policy_manager_->CheckPermissions(device_id_1_,
+ application_id_,
+ kHmiLevelNone,
+ "SendLocation",
+ input_params,
+ output);
EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted);
@@ -472,6 +521,8 @@ TEST_F(
TEST_F(PolicyManagerImplTest2,
CheckPermissions_SomeParamsAllowedInPT_CheckRpcsInDiffLvls) {
+ EXPECT_CALL(listener_, GetDevicesIds(application_id_))
+ .WillRepeatedly(Return(transport_manager::DeviceList()));
// Arrange
AddSetDeviceData();
@@ -479,19 +530,18 @@ TEST_F(PolicyManagerImplTest2,
//"locationDescription", "phoneNumber" are allowed
LoadPTUFromJsonFile("json/sdl_update_pt_send_location_some_params.json");
- // Will be called each time permissions are checked
- EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(application_id_))
- .Times(4)
- .WillRepeatedly(Return(device_id_1_));
-
// Check RPC in each level
::policy::RPCParams input_params;
InsertRpcParametersInList(input_params);
::policy::CheckPermissionResult output;
// Rpc in FULL level
- policy_manager_->CheckPermissions(
- application_id_, kHmiLevelFull, "SendLocation", input_params, output);
+ policy_manager_->CheckPermissions(device_id_1_,
+ application_id_,
+ kHmiLevelFull,
+ "SendLocation",
+ input_params,
+ output);
// Check RPC is allowed
EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted);
@@ -520,8 +570,12 @@ TEST_F(PolicyManagerImplTest2,
output.list_of_undefined_params.clear();
// Rpc in LIMITED level
- policy_manager_->CheckPermissions(
- application_id_, kHmiLevelLimited, "SendLocation", input_params, output);
+ policy_manager_->CheckPermissions(device_id_1_,
+ application_id_,
+ kHmiLevelLimited,
+ "SendLocation",
+ input_params,
+ output);
// Check RPC is allowed
EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted);
@@ -539,7 +593,8 @@ TEST_F(PolicyManagerImplTest2,
ResetOutputList(output);
// Rpc in BACKGROUND level
- policy_manager_->CheckPermissions(application_id_,
+ policy_manager_->CheckPermissions(device_id_1_,
+ application_id_,
kHmiLevelBackground,
"SendLocation",
input_params,
@@ -559,8 +614,12 @@ TEST_F(PolicyManagerImplTest2,
ResetOutputList(output);
// Rpc in NONE level
- policy_manager_->CheckPermissions(
- application_id_, kHmiLevelNone, "SendLocation", input_params, output);
+ policy_manager_->CheckPermissions(device_id_1_,
+ application_id_,
+ kHmiLevelNone,
+ "SendLocation",
+ input_params,
+ output);
// Check RPC is disallowed
EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted);
// Check lists of parameters are empty
@@ -585,10 +644,12 @@ TEST_F(PolicyManagerImplTest2, GetCorrectStatus_PTUSuccessful) {
CreateLocalPT(preloaded_pt_filename_);
// Check
EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus());
+ EXPECT_CALL(listener_, GetDevicesIds(application_id_))
+ .WillRepeatedly(Return(transport_manager::DeviceList()));
// Adding changes PT status
- policy_manager_->AddApplication(application_id_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_1_, application_id_, HmiTypes(policy_table::AHT_DEFAULT));
EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus());
// Before load PT we should send notification about start updating
policy_manager_->OnUpdateStarted();
@@ -613,6 +674,8 @@ TEST_F(PolicyManagerImplTest2,
TEST_F(PolicyManagerImplTest2,
CheckPermissions_DiffParamsAllowedInGroups_CheckRpcsInDiffLvls) {
+ EXPECT_CALL(listener_, GetDevicesIds(application_id_))
+ .WillRepeatedly(Return(transport_manager::DeviceList()));
// Arrange
AddSetDeviceData();
// Load Json to cache
@@ -621,19 +684,18 @@ TEST_F(PolicyManagerImplTest2,
// Allowed both groups of parameters
LoadPTUFromJsonFile("json/sdl_update_pt_2_groups_have_params.json");
- // Will be called each time permissions are checked
- EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(application_id_))
- .Times(4)
- .WillRepeatedly(Return(device_id_1_));
-
// Check RPC in each level
::policy::RPCParams input_params;
InsertRpcParametersInList(input_params);
::policy::CheckPermissionResult output;
// Rpc in FULL level
- policy_manager_->CheckPermissions(
- application_id_, kHmiLevelFull, "SendLocation", input_params, output);
+ policy_manager_->CheckPermissions(device_id_1_,
+ application_id_,
+ kHmiLevelFull,
+ "SendLocation",
+ input_params,
+ output);
// Check RPC is allowed
EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted);
// Check list of allowed parameters is not empty
@@ -652,8 +714,12 @@ TEST_F(PolicyManagerImplTest2,
ResetOutputList(output);
// Rpc in LIMITED level
- policy_manager_->CheckPermissions(
- application_id_, kHmiLevelLimited, "SendLocation", input_params, output);
+ policy_manager_->CheckPermissions(device_id_1_,
+ application_id_,
+ kHmiLevelLimited,
+ "SendLocation",
+ input_params,
+ output);
// Check RPC is allowed
EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted);
// Check list of allowed parameters is not empty
@@ -672,7 +738,8 @@ TEST_F(PolicyManagerImplTest2,
ResetOutputList(output);
// Rpc in BACKGROUND level
- policy_manager_->CheckPermissions(application_id_,
+ policy_manager_->CheckPermissions(device_id_1_,
+ application_id_,
kHmiLevelBackground,
"SendLocation",
input_params,
@@ -696,8 +763,12 @@ TEST_F(PolicyManagerImplTest2,
ResetOutputList(output);
// Rpc in NONE level
- policy_manager_->CheckPermissions(
- application_id_, kHmiLevelNone, "SendLocation", input_params, output);
+ policy_manager_->CheckPermissions(device_id_1_,
+ application_id_,
+ kHmiLevelNone,
+ "SendLocation",
+ input_params,
+ output);
// Check RPC is disallowed
EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted);
// Check lists of parameters are empty
@@ -726,27 +797,28 @@ TEST_F(PolicyManagerImplTest2,
2,
"Bluetooth"));
+ EXPECT_CALL(listener_, GetDevicesIds(application_id_))
+ .WillRepeatedly(Return(transport_manager::DeviceList()));
// Add app from consented device. App will be assigned with default policies
- policy_manager_->AddApplication(application_id_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->SetUserConsentForDevice(device_id_1_, true);
+ policy_manager_->AddApplication(
+ device_id_1_, application_id_, HmiTypes(policy_table::AHT_DEFAULT));
std::ifstream ifile("json/sdl_update_pt_2_groups_no_params_in1.json");
- Json::Reader reader;
+ Json::CharReaderBuilder reader_builder;
std::string json;
Json::Value root(Json::objectValue);
if (ifile.is_open()) {
- reader.parse(ifile, root, true);
+ Json::parseFromStream(reader_builder, ifile, &root, nullptr);
}
json = root.toStyledString();
ifile.close();
::policy::BinaryMessage msg(json.begin(), json.end());
- EXPECT_TRUE(policy_manager_->LoadPT(kFilePtUpdateJson, msg));
- EXPECT_FALSE(cache->IsPTPreloaded());
+ ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess,
+ policy_manager_->LoadPT(kFilePtUpdateJson, msg));
+ policy_manager_->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess);
- // Will be called each time permissions are checked
- EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(application_id_))
- .Times(4)
- .WillRepeatedly(Return(device_id_1_));
+ EXPECT_FALSE(cache->IsPTPreloaded());
// Check RPC in each level
::policy::RPCParams input_params;
@@ -754,39 +826,52 @@ TEST_F(PolicyManagerImplTest2,
::policy::CheckPermissionResult output;
// Rpc in FULL level
- policy_manager_->CheckPermissions(
- application_id_, kHmiLevelFull, "SendLocation", input_params, output);
+ policy_manager_->CheckPermissions(device_id_1_,
+ application_id_,
+ kHmiLevelFull,
+ "SendLocation",
+ input_params,
+ output);
- EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted);
- EXPECT_TRUE(output.list_of_allowed_params.empty());
- EXPECT_EQ(10u, output.list_of_undefined_params.size());
+ EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted);
+ EXPECT_TRUE(output.list_of_undefined_params.empty());
+ EXPECT_EQ(10u, output.list_of_allowed_params.size());
ResetOutputList(output);
// Rpc in LIMITED level
- policy_manager_->CheckPermissions(
- application_id_, kHmiLevelLimited, "SendLocation", input_params, output);
+ policy_manager_->CheckPermissions(device_id_1_,
+ application_id_,
+ kHmiLevelLimited,
+ "SendLocation",
+ input_params,
+ output);
- EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted);
- EXPECT_TRUE(output.list_of_allowed_params.empty());
- EXPECT_EQ(10u, output.list_of_undefined_params.size());
+ EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted);
+ EXPECT_TRUE(output.list_of_undefined_params.empty());
+ EXPECT_EQ(10u, output.list_of_allowed_params.size());
ResetOutputList(output);
// Rpc in BACKGROUND level
- policy_manager_->CheckPermissions(application_id_,
+ policy_manager_->CheckPermissions(device_id_1_,
+ application_id_,
kHmiLevelBackground,
"SendLocation",
input_params,
output);
- EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted);
- EXPECT_TRUE(output.list_of_allowed_params.empty());
- EXPECT_EQ(10u, output.list_of_undefined_params.size());
+ EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted);
+ EXPECT_TRUE(output.list_of_undefined_params.empty());
+ EXPECT_EQ(10u, output.list_of_allowed_params.size());
// Reset output
ResetOutputList(output);
// Rpc in NONE level
- policy_manager_->CheckPermissions(
- application_id_, kHmiLevelNone, "SendLocation", input_params, output);
+ policy_manager_->CheckPermissions(device_id_1_,
+ application_id_,
+ kHmiLevelNone,
+ "SendLocation",
+ input_params,
+ output);
EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted);
EXPECT_TRUE(output.list_of_allowed_params.empty());
@@ -813,28 +898,29 @@ TEST_F(PolicyManagerImplTest2,
2,
"Bluetooth"));
+ EXPECT_CALL(listener_, GetDevicesIds(application_id_))
+ .WillRepeatedly(Return(transport_manager::DeviceList()));
// Add app from consented device. App will be assigned with default policies
- policy_manager_->AddApplication(application_id_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->SetUserConsentForDevice(device_id_1_, true);
+ policy_manager_->AddApplication(
+ device_id_1_, application_id_, HmiTypes(policy_table::AHT_DEFAULT));
std::ifstream ifile(
"json/sdl_update_pt_2_groups_no_params_in1_omitted_in2.json");
- Json::Reader reader;
+ Json::CharReaderBuilder reader_builder;
std::string json;
Json::Value root(Json::objectValue);
if (ifile.is_open()) {
- reader.parse(ifile, root, true);
+ Json::parseFromStream(reader_builder, ifile, &root, nullptr);
}
json = root.toStyledString();
ifile.close();
::policy::BinaryMessage msg(json.begin(), json.end());
- EXPECT_TRUE(policy_manager_->LoadPT(kFilePtUpdateJson, msg));
- EXPECT_FALSE(cache->IsPTPreloaded());
+ ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess,
+ policy_manager_->LoadPT(kFilePtUpdateJson, msg));
+ policy_manager_->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess);
- // Will be called each time permissions are checked
- EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(application_id_))
- .Times(4)
- .WillRepeatedly(Return(device_id_1_));
+ EXPECT_FALSE(cache->IsPTPreloaded());
// Check RPC in each level
::policy::RPCParams input_params;
@@ -842,37 +928,50 @@ TEST_F(PolicyManagerImplTest2,
::policy::CheckPermissionResult output;
// Rpc in FULL level
- policy_manager_->CheckPermissions(
- application_id_, kHmiLevelFull, "SendLocation", input_params, output);
+ policy_manager_->CheckPermissions(device_id_1_,
+ application_id_,
+ kHmiLevelFull,
+ "SendLocation",
+ input_params,
+ output);
- EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted);
- EXPECT_TRUE(output.list_of_allowed_params.empty());
- EXPECT_EQ(10u, output.list_of_undefined_params.size());
+ EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted);
+ EXPECT_TRUE(output.list_of_undefined_params.empty());
+ EXPECT_EQ(10u, output.list_of_allowed_params.size());
ResetOutputList(output);
// Rpc in LIMITED level
- policy_manager_->CheckPermissions(
- application_id_, kHmiLevelLimited, "SendLocation", input_params, output);
- EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted);
- EXPECT_TRUE(output.list_of_allowed_params.empty());
- EXPECT_EQ(10u, output.list_of_undefined_params.size());
+ policy_manager_->CheckPermissions(device_id_1_,
+ application_id_,
+ kHmiLevelLimited,
+ "SendLocation",
+ input_params,
+ output);
+ EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted);
+ EXPECT_TRUE(output.list_of_undefined_params.empty());
+ EXPECT_EQ(10u, output.list_of_allowed_params.size());
ResetOutputList(output);
// Rpc in BACKGROUND level
- policy_manager_->CheckPermissions(application_id_,
+ policy_manager_->CheckPermissions(device_id_1_,
+ application_id_,
kHmiLevelBackground,
"SendLocation",
input_params,
output);
- EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted);
- EXPECT_TRUE(output.list_of_allowed_params.empty());
- EXPECT_EQ(10u, output.list_of_undefined_params.size());
+ EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted);
+ EXPECT_TRUE(output.list_of_undefined_params.empty());
+ EXPECT_EQ(10u, output.list_of_allowed_params.size());
// Reset output
ResetOutputList(output);
// Rpc in NONE level
- policy_manager_->CheckPermissions(
- application_id_, kHmiLevelNone, "SendLocation", input_params, output);
+ policy_manager_->CheckPermissions(device_id_1_,
+ application_id_,
+ kHmiLevelNone,
+ "SendLocation",
+ input_params,
+ output);
EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted);
EXPECT_TRUE(output.list_of_allowed_params.empty());
EXPECT_TRUE(output.list_of_disallowed_params.empty());
@@ -881,6 +980,8 @@ TEST_F(PolicyManagerImplTest2,
TEST_F(PolicyManagerImplTest, LoadPT_SetInvalidUpdatePT_PTIsNotLoaded) {
// Arrange
+ EXPECT_CALL(*cache_manager_, GenerateSnapshot())
+ .WillOnce(Return(default_pt_snapshot_));
policy_manager_->ForcePTExchange();
policy_manager_->OnUpdateStarted();
Json::Value table(Json::objectValue);
@@ -895,17 +996,26 @@ 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_FALSE(policy_manager_->LoadPT(kFilePtUpdateJson, msg));
+ EXPECT_CALL(*cache_manager_, GetVehicleDataItems())
+ .WillOnce(Return(std::vector<policy_table::VehicleDataItem>()));
+ ASSERT_EQ(PolicyManager::PtProcessingResult::kWrongPtReceived,
+ policy_manager_->LoadPT(kFilePtUpdateJson, msg));
+
EXPECT_CALL(*cache_manager_, IsPTPreloaded());
EXPECT_FALSE(policy_manager_->GetCache()->IsPTPreloaded());
+
+ EXPECT_CALL(listener_, OnUpdateStatusChanged(_)).Times(1);
+ policy_manager_->OnPTUFinished(
+ PolicyManager::PtProcessingResult::kWrongPtReceived);
}
TEST_F(
@@ -917,16 +1027,16 @@ TEST_F(
GetPTU(kValidSdlPtUpdateJson);
EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus());
// Try to add existing app
- policy_manager_->AddApplication(app_id_2_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_1_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT));
// Check no update required
EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus());
}
uint32_t GetCurrentDaysCount() {
- TimevalStruct current_time = date_time::DateTime::getCurrentTime();
+ date_time::TimeDuration current_time = date_time::getCurrentTime();
const uint32_t kSecondsInDay = 60 * 60 * 24;
- return current_time.tv_sec / kSecondsInDay;
+ return date_time::getSecs(current_time) / kSecondsInDay;
}
TEST_F(PolicyManagerImplTest2,
@@ -939,14 +1049,14 @@ TEST_F(PolicyManagerImplTest2,
GetPTU(kValidSdlPtUpdateJson);
EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus());
- policy_manager_->AddApplication(app_id_2_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_2_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT));
EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus());
::policy::Counters counter = ::policy::Counters::DAYS_AFTER_EPOCH;
// Set PT was updated 10 days ago (limit is 30 days for now)
// So no limit exceeded
policy_manager_->PTUpdatedAt(counter, days - 10);
- policy_manager_->OnAppRegisteredOnMobile(app_id_2_);
+ policy_manager_->OnAppRegisteredOnMobile(device_id_2_, app_id_2_);
EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus());
}
@@ -959,13 +1069,13 @@ TEST_F(PolicyManagerImplTest2,
GetPTU(kValidSdlPtUpdateJson);
EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus());
- policy_manager_->AddApplication(app_id_2_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_2_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT));
EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus());
::policy::Counters counter = ::policy::Counters::DAYS_AFTER_EPOCH;
// Set PT was updated 50 days ago (limit is 30 days for now)
policy_manager_->PTUpdatedAt(counter, days - 50);
- policy_manager_->OnAppRegisteredOnMobile(app_id_2_);
+ policy_manager_->OnAppRegisteredOnMobile(device_id_2_, app_id_2_);
EXPECT_EQ("UPDATE_NEEDED", policy_manager_->GetPolicyTableStatus());
}
@@ -979,8 +1089,8 @@ TEST_F(
GetPTU(kValidSdlPtUpdateJson);
EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus());
// Try to add existing app
- policy_manager_->AddApplication(app_id_2_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_2_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT));
EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus());
::policy::Counters counter = ::policy::Counters::DAYS_AFTER_EPOCH;
// Set PT was updated 10 days ago (limit is 30 days for now)
@@ -993,7 +1103,7 @@ TEST_F(
for (int i = 0; i < ign_cycles; ++i) {
policy_manager_->IncrementIgnitionCycles();
}
- policy_manager_->OnAppRegisteredOnMobile(app_id_2_);
+ policy_manager_->OnAppRegisteredOnMobile(device_id_2_, app_id_2_);
// Check update required
EXPECT_EQ("UPDATE_NEEDED", policy_manager_->GetPolicyTableStatus());
}
@@ -1022,10 +1132,10 @@ TEST_F(PolicyManagerImplTest2,
->SetUserPermissionsForDevice(
device_id_2_, consented_groups, disallowed_groups);
policy_manager_->SetUserConsentForDevice(device_id_2_, true);
- EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_))
- .WillRepeatedly(Return(device_id_2_));
- policy_manager_->AddApplication(app_id_2_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ EXPECT_CALL(listener_, GetDevicesIds(app_id_2_))
+ .WillRepeatedly(Return(transport_manager::DeviceList()));
+ policy_manager_->AddApplication(
+ device_id_2_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT));
GetPTU(kValidSdlPtUpdateJson);
::policy::PermissionConsent perm_consent;
@@ -1045,7 +1155,8 @@ TEST_F(PolicyManagerImplTest2,
policy_manager_->SetUserConsentForApp(perm_consent,
policy::PolicyManager::kSilentMode);
- policy_manager_->SendNotificationOnPermissionsUpdated(app_id_2_);
+ policy_manager_->SendNotificationOnPermissionsUpdated(device_id_2_,
+ app_id_2_);
std::vector< ::policy::FunctionalGroupPermission> actual_groups_permissions;
std::vector< ::policy::FunctionalGroupPermission>::iterator it;
policy_manager_->GetUserConsentForApp(
@@ -1069,8 +1180,10 @@ TEST_F(PolicyManagerImplTest2,
CanAppKeepContext_SetPoliciesForAppUpdated_ExpectAppCanKeepContext) {
// Arrange
CreateLocalPT(preloaded_pt_filename_);
- policy_manager_->AddApplication(app_id_2_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ EXPECT_CALL(listener_, GetDevicesIds(app_id_2_))
+ .WillRepeatedly(Return(transport_manager::DeviceList()));
+ policy_manager_->AddApplication(
+ device_id_2_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT));
GetPTU(kValidSdlPtUpdateJson);
// Check keep context in updated policies for app
EXPECT_TRUE(policy_manager_->CanAppKeepContext(app_id_2_));
@@ -1080,31 +1193,15 @@ TEST_F(PolicyManagerImplTest2,
CanAppStealFocus_SetPoliciesForAppUpdated_ExpectAppCanStealFocus) {
// Arrange
CreateLocalPT(preloaded_pt_filename_);
- policy_manager_->AddApplication(app_id_2_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ EXPECT_CALL(listener_, GetDevicesIds(app_id_2_))
+ .WillRepeatedly(Return(transport_manager::DeviceList()));
+ policy_manager_->AddApplication(
+ device_id_2_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT));
GetPTU(kValidSdlPtUpdateJson);
// Check keep context in updated policies for app
EXPECT_TRUE(policy_manager_->CanAppKeepContext(app_id_2_));
}
-TEST_F(PolicyManagerImplTest2,
- GetVehicleInfo_SetVehicleInfo_ExpectReceivedInfoCorrect) {
- // Arrange
- CreateLocalPT(preloaded_pt_filename_);
- GetPTU(kValidSdlPtUpdateJson);
- utils::SharedPtr<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) {
@@ -1130,10 +1227,10 @@ TEST_F(
->SetUserPermissionsForDevice(
device_id_2_, consented_groups, disallowed_groups);
policy_manager_->SetUserConsentForDevice(device_id_2_, true);
- EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_))
- .WillRepeatedly(Return(device_id_2_));
- policy_manager_->AddApplication(app_id_2_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ EXPECT_CALL(listener_, GetDevicesIds(app_id_2_))
+ .WillRepeatedly(Return(transport_manager::DeviceList(1, device_id_2_)));
+ policy_manager_->AddApplication(
+ device_id_2_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT));
GetPTU(kValidSdlPtUpdateJson);
::policy::PermissionConsent perm_consent;
@@ -1153,7 +1250,8 @@ TEST_F(
policy_manager_->SetUserConsentForApp(perm_consent,
policy::PolicyManager::kSilentMode);
- policy_manager_->SendNotificationOnPermissionsUpdated(app_id_2_);
+ policy_manager_->SendNotificationOnPermissionsUpdated(device_id_2_,
+ app_id_2_);
std::vector< ::policy::FunctionalGroupPermission> actual_groups_permissions;
std::vector< ::policy::FunctionalGroupPermission>::iterator it;
policy_manager_->GetPermissionsForApp(
@@ -1177,19 +1275,23 @@ TEST_F(
PolicyManagerImplTest2,
GetAppRequestTypes_AddApp_UpdateAppPolicies_ExpectReceivedRequestTypesCorrect) {
// Arrange
+ const transport_manager::DeviceHandle handle = 1;
CreateLocalPT(preloaded_pt_filename_);
-
- policy_manager_->AddApplication(app_id_3_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ EXPECT_CALL(listener_, GetDevicesIds(app_id_3_))
+ .WillRepeatedly(Return(transport_manager::DeviceList(1, device_id_1_)));
+ EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(handle, app_id_3_))
+ .WillRepeatedly(Return(device_id_1_));
+ policy_manager_->AddApplication(
+ device_id_1_, app_id_3_, HmiTypes(policy_table::AHT_DEFAULT));
::policy::StringArray app_requests =
- policy_manager_->GetAppRequestTypes(app_id_3_);
+ policy_manager_->GetAppRequestTypes(handle, app_id_3_);
EXPECT_EQ(1u, app_requests.size());
Json::Value root = GetPTU(kPtuRequestTypeJson);
Json::Value request_Types = Json::Value(Json::arrayValue);
request_Types =
root["policy_table"]["app_policies"][app_id_3_]["RequestType"];
- app_requests = policy_manager_->GetAppRequestTypes(app_id_3_);
+ app_requests = policy_manager_->GetAppRequestTypes(handle, app_id_3_);
EXPECT_EQ(request_Types.size(), app_requests.size());
// Check nicknames match
for (uint32_t i = 0; i < request_Types.size(); ++i) {
@@ -1202,7 +1304,7 @@ TEST_F(
HertBeatTimeout_AddApp_UpdateAppPolicies_ExpectReceivedHertBeatTimeoutCorrect) {
// Arrange
CreateLocalPT(preloaded_pt_filename_);
- utils::SharedPtr<policy_table::Table> pt =
+ std::shared_ptr<policy_table::Table> pt =
(policy_manager_->GetCache())->GetPT();
::policy_table::PolicyTableType type1 =
::policy_table::PolicyTableType::PT_PRELOADED;
@@ -1213,9 +1315,11 @@ TEST_F(
rpc::ValidationReport report("policy_table");
pt->ReportErrors(&report);
}
+ EXPECT_CALL(listener_, GetDevicesIds(app_id_2_))
+ .WillRepeatedly(Return(transport_manager::DeviceList()));
// Add new app
- policy_manager_->AddApplication(app_id_2_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_2_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT));
uint32_t result = policy_manager_->HeartBeatTimeout(app_id_2_);
// By default hertbeat timeout is 0
EXPECT_EQ(0u, result);
@@ -1261,10 +1365,10 @@ TEST_F(PolicyManagerImplTest2,
->SetUserPermissionsForDevice(
device_id_2_, consented_groups, disallowed_groups);
policy_manager_->SetUserConsentForDevice(device_id_2_, true);
- EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_))
- .WillRepeatedly(Return(device_id_2_));
- policy_manager_->AddApplication(app_id_2_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ EXPECT_CALL(listener_, GetDevicesIds(app_id_2_))
+ .WillRepeatedly(Return(transport_manager::DeviceList(1, device_id_2_)));
+ policy_manager_->AddApplication(
+ device_id_2_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT));
GetPTU(kValidSdlPtUpdateJson);
::policy::PermissionConsent perm_consent;
@@ -1284,7 +1388,8 @@ TEST_F(PolicyManagerImplTest2,
policy_manager_->SetUserConsentForApp(perm_consent,
policy::PolicyManager::kSilentMode);
- policy_manager_->SendNotificationOnPermissionsUpdated(app_id_2_);
+ policy_manager_->SendNotificationOnPermissionsUpdated(device_id_2_,
+ app_id_2_);
std::vector< ::policy::FunctionalGroupPermission> actual_groups_permissions;
std::vector< ::policy::FunctionalGroupPermission>::iterator it;
policy_manager_->GetPermissionsForApp(
@@ -1302,7 +1407,7 @@ TEST_F(PolicyManagerImplTest2,
actual_groups_permissions[index].group_name);
EXPECT_EQ(group1_perm.group_id, actual_groups_permissions[index].group_id);
EXPECT_EQ(group1_perm.state, actual_groups_permissions[index].state);
- utils::SharedPtr<policy_table::Table> pt =
+ std::shared_ptr<policy_table::Table> pt =
(policy_manager_->GetCache())->GetPT();
uint32_t ucr_size = 0;
::policy_table::DeviceData& device_data = *pt->policy_table.device_data;
@@ -1330,20 +1435,22 @@ TEST_F(PolicyManagerImplTest2,
SingleInvalidRequestTypeInPTU_ExpectReplaceWithDefaultValues) {
// Arrange
const std::string section_name = app_id_2_;
+ const transport_manager::DeviceHandle handle = 1;
// Arrange
CreateLocalPT(preloaded_pt_filename_);
// Setting device consent to 'true' in order to have defult application
// permissions, request type etc.
- EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_))
+ EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(handle, app_id_2_))
.WillRepeatedly(Return(device_id_1_));
policy_manager_->SetUserConsentForDevice(device_id_1_, true);
-
+ EXPECT_CALL(listener_, GetDevicesIds(section_name))
+ .WillRepeatedly(Return(transport_manager::DeviceList(1, device_id_1_)));
// Add app
- policy_manager_->AddApplication(section_name,
- HmiTypes(policy_table::AHT_DEFAULT));
- EXPECT_CALL(listener_, OnPendingPermissionChange(section_name));
+ policy_manager_->AddApplication(
+ device_id_1_, section_name, HmiTypes(policy_table::AHT_DEFAULT));
+ EXPECT_CALL(listener_, OnPendingPermissionChange(device_id_1_, section_name));
// PTU has single invalid RequestTypes, which must be dropped and replaced
// with default RT
@@ -1351,18 +1458,18 @@ TEST_F(PolicyManagerImplTest2,
// Get RequestTypes from <app_id> section of app policies after PT update
::policy::StringArray app_request_types_after =
- policy_manager_->GetAppRequestTypes(section_name);
+ policy_manager_->GetAppRequestTypes(handle, section_name);
- EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(kDefaultId))
+ EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(handle, kDefaultId))
.WillOnce(Return(device_id_1_));
::policy::StringArray default_request_types_after =
- policy_manager_->GetAppRequestTypes(kDefaultId);
+ policy_manager_->GetAppRequestTypes(handle, kDefaultId);
// Check sizes of Request types of PT and PTU
EXPECT_EQ(4u, app_request_types_after.size());
::policy::AppPermissions permissions =
- policy_manager_->GetAppPermissionsChanges(section_name);
+ policy_manager_->GetAppPermissionsChanges(device_id_1_, section_name);
EXPECT_TRUE(permissions.requestTypeChanged);
policy_table::RequestType temp_res1;
@@ -1713,6 +1820,6 @@ TEST_F(
CompareRequestTypesContainers(correct_types, received_types);
}
-} // namespace policy
+} // namespace policy_test
} // namespace components
} // namespace test
diff --git a/src/components/policy/policy_external/test/policy_manager_impl_snapshot_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_snapshot_test.cc
index e666ac82de..f89a2ce0c7 100644
--- a/src/components/policy/policy_external/test/policy_manager_impl_snapshot_test.cc
+++ b/src/components/policy/policy_external/test/policy_manager_impl_snapshot_test.cc
@@ -53,27 +53,26 @@ TEST_F(PolicyManagerImplTest2, UpdatedPreloadedPT_ExpectLPT_IsUpdated) {
CreateLocalPT(preloaded_pt_filename_);
// Update preloadedPT
std::ifstream ifile(preloaded_pt_filename_);
- Json::Reader reader;
+ Json::CharReaderBuilder reader_builder;
Json::Value root(Json::objectValue);
- if (ifile.is_open() && reader.parse(ifile, root, true)) {
+ if (ifile.is_open() &&
+ Json::parseFromStream(reader_builder, ifile, &root, nullptr)) {
root["policy_table"]["module_config"]["preloaded_date"] =
new_data.new_date_;
Json::Value val(Json::objectValue);
Json::Value val2(Json::arrayValue);
val2[0] = hmi_level_[index_];
val[new_data.new_field_value_]["hmi_levels"] = val2;
- root["policy_table"]["functional_groupings"][new_data
- .new_field_name_]["rpcs"] =
- val;
+ root["policy_table"]["functional_groupings"][new_data.new_field_name_]
+ ["rpcs"] = val;
root["policy_table"]["functional_groupings"][new_data.new_field_name_]
["user_consent_prompt"] = new_data.new_field_name_;
}
ifile.close();
- Json::StyledStreamWriter writer;
std::ofstream ofile(preloaded_pt_filename_);
- writer.write(ofile, root);
+ ofile << root;
ofile.flush();
ofile.close();
@@ -84,7 +83,7 @@ TEST_F(PolicyManagerImplTest2, UpdatedPreloadedPT_ExpectLPT_IsUpdated) {
EXPECT_TRUE(cache->IsPTPreloaded());
// Arrange
- utils::SharedPtr<policy_table::Table> table = cache->GenerateSnapshot();
+ std::shared_ptr<policy_table::Table> table = cache->GenerateSnapshot();
// Get FunctionalGroupings
policy_table::FunctionalGroupings& fc =
table->policy_table.functional_groupings;
@@ -119,7 +118,7 @@ TEST_F(PolicyManagerImplTest2,
// Arrange
CreateLocalPT(preloaded_pt_filename_);
policy_manager_->SetSystemLanguage("it-it");
- utils::SharedPtr<policy_table::Table> pt =
+ std::shared_ptr<policy_table::Table> pt =
(policy_manager_->GetCache())->GetPT();
::policy_table::ModuleMeta& ModuleMeta = *(pt->policy_table.module_meta);
EXPECT_EQ("it-it", static_cast<std::string>(*(ModuleMeta.language)));
@@ -130,7 +129,7 @@ TEST_F(PolicyManagerImplTest2, SetVINValue_ExpectVINSetSuccessfully) {
CreateLocalPT(preloaded_pt_filename_);
std::string vin_code("1FAPP6242VH100001");
policy_manager_->SetVINValue(vin_code);
- utils::SharedPtr<policy_table::Table> pt =
+ std::shared_ptr<policy_table::Table> pt =
(policy_manager_->GetCache())->GetPT();
::policy_table::ModuleMeta& ModuleMeta = *(pt->policy_table.module_meta);
EXPECT_EQ(vin_code, static_cast<std::string>(*(ModuleMeta.vin)));
@@ -141,7 +140,7 @@ TEST_F(PolicyManagerImplTest2, SetSystemInfo_ExpectSystemInfoSetSuccessfully) {
CreateLocalPT(preloaded_pt_filename_);
policy_manager_->SetSystemInfo("4.1.3.B_EB355B", "WAEGB", "ru-ru");
policy::CacheManagerInterfaceSPtr cache = policy_manager_->GetCache();
- utils::SharedPtr<policy_table::Table> pt = cache->GetPT();
+ std::shared_ptr<policy_table::Table> pt = cache->GetPT();
::policy_table::ModuleMeta& ModuleMeta = *(pt->policy_table.module_meta);
EXPECT_EQ("ru-ru", static_cast<std::string>(*(ModuleMeta.language)));
EXPECT_EQ("4.1.3.B_EB355B",
@@ -189,7 +188,7 @@ TEST_F(PolicyManagerImplTest2, CleanUnpairedDevice_ExpectDevicesDeleted) {
policy_manager_->AddDevice("AAA123456789RRR", "Bluetooth");
policy_manager_->SetDeviceInfo("AAA123456789RRR", dev_info3);
- utils::SharedPtr<policy_table::Table> pt =
+ std::shared_ptr<policy_table::Table> pt =
(policy_manager_->GetCache())->GetPT();
// Try to find first device in PT
policy_table::DeviceData::const_iterator iter =
@@ -260,25 +259,30 @@ TEST_F(
PolicyManagerImplTest2,
AddValidRequestTypeToPT_GetNewAppWithSpecificPoliciesViaPTU_ExpectRTAdded) {
const std::string& app_id = application_id_;
+ const transport_manager::DeviceHandle handle = 1;
// Arrange
CreateLocalPT(preloaded_pt_filename_);
+ EXPECT_CALL(listener_, GetDevicesIds(app_id))
+ .WillRepeatedly(Return(transport_manager::DeviceList(1, device_id_1_)));
// Add app
- policy_manager_->AddApplication(app_id, HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_1_, app_id, HmiTypes(policy_table::AHT_DEFAULT));
// Check app gets RequestTypes from pre_DataConsent of app_policies
// section
- pt_request_types_ = policy_manager_->GetAppRequestTypes(app_id);
+ pt_request_types_ = policy_manager_->GetAppRequestTypes(handle, app_id);
// Only single item as in pre_DataConsent in preloaded PT
EXPECT_EQ(1u, pt_request_types_.size());
- EXPECT_CALL(listener_, OnPendingPermissionChange(app_id)).Times(1);
+ EXPECT_CALL(listener_, OnPendingPermissionChange(device_id_1_, app_id))
+ .Times(1);
// PTU has RequestTypes as [] - means 'all allowed'
Json::Value root = GetPTU("json/PTU2.json");
// Setting device consent to 'true' in order to have appropriate application
// permissions, request type etc.
- EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(application_id_))
+ EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(handle, app_id))
.WillRepeatedly(Return(device_id_1_));
policy_manager_->SetUserConsentForDevice(device_id_1_, true);
@@ -289,13 +293,13 @@ TEST_F(
pt_request_types_.clear();
// Get RequestTypes from <app_id> section of app policies after PT update
- pt_request_types_ = policy_manager_->GetAppRequestTypes(app_id);
+ pt_request_types_ = policy_manager_->GetAppRequestTypes(handle, app_id);
// Check sizes of Request types of PT and PTU
ASSERT_EQ(ptu_request_types_size_, pt_request_types_.size());
::policy::AppPermissions permissions =
- policy_manager_->GetAppPermissionsChanges(app_id);
+ policy_manager_->GetAppPermissionsChanges(device_id_1_, app_id);
EXPECT_TRUE(permissions.requestTypeChanged);
::policy::StringArray result;
@@ -316,7 +320,7 @@ TEST_F(PolicyManagerImplTest2, AddDevice_RegisterDevice_TRUE) {
const bool result =
(policy_manager_->GetCache())->AddDevice(device_id_1_, connection_type);
// Get Policy table
- const utils::SharedPtr<policy_table::Table> policy_table =
+ const std::shared_ptr<policy_table::Table> policy_table =
policy_manager_->GetCache()->GetPT();
// Get preloaded_pt flag from Policy table
const bool is_preloaded_pt =
@@ -333,6 +337,6 @@ TEST_F(PolicyManagerImplTest2, AddDevice_RegisterDevice_TRUE) {
EXPECT_TRUE(result);
}
-} // namespace policy
+} // namespace policy_test
} // namespace components
} // namespace test
diff --git a/src/components/policy/policy_external/test/policy_manager_impl_stress_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_stress_test.cc
index 2f1cc5a9d3..f886108463 100644
--- a/src/components/policy/policy_external/test/policy_manager_impl_stress_test.cc
+++ b/src/components/policy/policy_external/test/policy_manager_impl_stress_test.cc
@@ -29,15 +29,15 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "gtest/gtest.h"
#include <fstream>
+#include "gtest/gtest.h"
#include "mock_policy_listener.h"
#include "policy/policy_manager_impl.h"
-using ::testing::_;
-using ::policy::PolicyManagerImpl;
using ::policy::BinaryMessage;
using ::policy::MockPolicyListener;
+using ::policy::PolicyManagerImpl;
+using ::testing::_;
namespace test {
namespace components {
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 f4e922e647..9e0b61c2dd 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
@@ -32,47 +32,22 @@
#include <fstream>
-#include "json/reader.h"
-#include "gtest/gtest.h"
#include <utility>
+#include "gtest/gtest.h"
+#include "json/reader.h"
#include "policy/policy_manager_impl_test_base.h"
-#include "utils/make_shared.h"
-#include "utils/shared_ptr.h"
+#include "utils/date_time.h"
using ::testing::_;
+using ::testing::AtLeast;
using ::testing::Return;
using ::testing::SetArgReferee;
-using ::testing::AtLeast;
namespace test {
namespace components {
namespace policy_test {
-TEST_F(
- PolicyManagerImplTest,
- RefreshRetrySequence_SetSecondsBetweenRetries_ExpectRetryTimeoutSequenceWithSameSeconds) {
- // Arrange
- std::vector<int> seconds;
- seconds.push_back(50);
- seconds.push_back(100);
- seconds.push_back(200);
-
- // Assert
- EXPECT_CALL(*cache_manager_, TimeoutResponse()).WillOnce(Return(60));
- EXPECT_CALL(*cache_manager_, SecondsBetweenRetries(_))
- .WillOnce(DoAll(SetArgReferee<0>(seconds), Return(true)));
-
- // Act
- policy_manager_->RefreshRetrySequence();
-
- // Assert
- EXPECT_EQ(50, policy_manager_->NextRetryTimeout());
- EXPECT_EQ(100, policy_manager_->NextRetryTimeout());
- EXPECT_EQ(200, policy_manager_->NextRetryTimeout());
- EXPECT_EQ(0, policy_manager_->NextRetryTimeout());
-}
-
TEST_F(PolicyManagerImplTest, GetNotificationsNumber) {
std::string priority = "EMERGENCY";
uint32_t notif_number = 100;
@@ -131,8 +106,10 @@ TEST_F(PolicyManagerImplTest, LoadPT_SetPT_PTIsLoaded) {
// Arrange
EXPECT_CALL(*cache_manager_, DaysBeforeExchange(_))
.WillOnce(Return(kNonZero));
+ ON_CALL(*cache_manager_, GenerateSnapshot())
+ .WillByDefault(Return(default_pt_snapshot_));
policy_manager_->ForcePTExchange();
- policy_manager_->SetSendOnUpdateFlags(true, false);
+ policy_manager_->SetSendOnUpdateFlags(true);
policy_manager_->OnUpdateStarted();
Json::Value table = createPTforLoad();
@@ -148,21 +125,28 @@ TEST_F(PolicyManagerImplTest, LoadPT_SetPT_PTIsLoaded) {
std::string json = table.toStyledString();
::policy::BinaryMessage msg(json.begin(), json.end());
- utils::SharedPtr<policy_table::Table> snapshot =
- new policy_table::Table(update.policy_table);
+ 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_, 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(policy_manager_->LoadPT(kFilePtUpdateJson, msg));
+ EXPECT_CALL(*cache_manager_, GetVehicleDataItems())
+ .WillOnce(Return(std::vector<policy_table::VehicleDataItem>()));
+ ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess,
+ policy_manager_->LoadPT(kFilePtUpdateJson, msg));
+
EXPECT_CALL(*cache_manager_, IsPTPreloaded());
EXPECT_FALSE(policy_manager_->GetCache()->IsPTPreloaded());
+
+ EXPECT_CALL(*cache_manager_, TimeoutResponse());
+ EXPECT_CALL(*cache_manager_, SecondsBetweenRetries(_));
+ EXPECT_CALL(listener_, OnUpdateStatusChanged(_));
+ policy_manager_->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess);
}
TEST_F(PolicyManagerImplTest2,
@@ -190,42 +174,17 @@ TEST_F(PolicyManagerImplTest2, ForcePTExchange_ExpectUpdateNeeded) {
EXPECT_EQ("UPDATE_NEEDED", policy_manager_->GetPolicyTableStatus());
}
-TEST_F(PolicyManagerImplTest2, OnSystemReady) {
- // Arrange
- CreateLocalPT(preloaded_pt_filename_);
- // Check
- EXPECT_CALL(listener_, OnSystemInfoUpdateRequired());
- policy_manager_->OnSystemReady();
-}
-
TEST_F(PolicyManagerImplTest2, ResetRetrySequence) {
// Arrange
CreateLocalPT(preloaded_pt_filename_);
- policy_manager_->ResetRetrySequence();
+ policy_manager_->ResetRetrySequence(
+ policy::ResetRetryCountType::kResetWithStatusUpdate);
EXPECT_EQ("UPDATE_NEEDED", policy_manager_->GetPolicyTableStatus());
- policy_manager_->SetSendOnUpdateFlags(false, false);
+ policy_manager_->SetSendOnUpdateFlags(false);
policy_manager_->OnUpdateStarted();
EXPECT_EQ("UPDATING", policy_manager_->GetPolicyTableStatus());
}
-TEST_F(PolicyManagerImplTest2, NextRetryTimeout_ExpectTimeoutsFromPT) {
- // Arrange
- std::ifstream ifile(preloaded_pt_filename_);
- Json::Reader reader;
- Json::Value root(Json::objectValue);
- if (ifile.is_open() && reader.parse(ifile, root, true)) {
- Json::Value seconds_between_retries = Json::Value(Json::arrayValue);
- seconds_between_retries =
- root["policy_table"]["module_config"]["seconds_between_retries"];
- uint32_t size = seconds_between_retries.size();
- CreateLocalPT(preloaded_pt_filename_);
- for (uint32_t i = 0; i < size; ++i) {
- EXPECT_EQ(seconds_between_retries[i],
- policy_manager_->NextRetryTimeout());
- }
- }
-}
-
TEST_F(PolicyManagerImplTest2, TimeOutExchange) {
// Arrange
CreateLocalPT(preloaded_pt_filename_);
@@ -236,9 +195,9 @@ TEST_F(PolicyManagerImplTest2, TimeOutExchange) {
TEST_F(PolicyManagerImplTest,
RequestPTUpdate_SetPT_GeneratedSnapshotAndPTUpdate) {
Json::Value table = createPTforLoad();
- utils::SharedPtr<policy_table::Table> p_table =
- utils::MakeShared<policy_table::Table>(&table);
- ASSERT_TRUE(p_table);
+ std::shared_ptr<policy_table::Table> p_table =
+ std::make_shared<policy_table::Table>(&table);
+ ASSERT_TRUE(p_table.get());
p_table->SetPolicyTableType(rpc::policy_table_interface_base::PT_UPDATE);
EXPECT_TRUE(IsValid(*p_table));
@@ -249,9 +208,9 @@ TEST_F(PolicyManagerImplTest,
}
TEST_F(PolicyManagerImplTest, RequestPTUpdate_InvalidPT_PTUpdateFail) {
- utils::SharedPtr<policy_table::Table> p_table =
- utils::MakeShared<policy_table::Table>();
- ASSERT_TRUE(p_table);
+ std::shared_ptr<policy_table::Table> p_table =
+ std::make_shared<policy_table::Table>();
+ ASSERT_TRUE(p_table.get());
EXPECT_FALSE(IsValid(*p_table));
EXPECT_CALL(listener_, OnSnapshotCreated(_, _, _)).Times(0);
@@ -261,7 +220,7 @@ TEST_F(PolicyManagerImplTest, RequestPTUpdate_InvalidPT_PTUpdateFail) {
}
TEST_F(PolicyManagerImplTest, RequestPTUpdate_InvalidSnapshot_PTUpdateFail) {
- utils::SharedPtr<policy_table::Table> p_table;
+ std::shared_ptr<policy_table::Table> p_table;
EXPECT_FALSE(p_table);
EXPECT_CALL(listener_, OnSnapshotCreated(_, _, _)).Times(0);
@@ -289,6 +248,8 @@ TEST_F(PolicyManagerImplTest2, GetPolicyTableStatus_ExpectUpToDate) {
TEST_F(PolicyManagerImplTest,
SetUpdateStarted_GetPolicyTableStatus_Expect_Updating) {
// Arrange
+ EXPECT_CALL(*cache_manager_, GenerateSnapshot())
+ .WillOnce(Return(default_pt_snapshot_));
policy_manager_->ForcePTExchange();
EXPECT_CALL(*cache_manager_, SaveUpdateRequired(true));
policy_manager_->OnUpdateStarted();
@@ -300,9 +261,10 @@ TEST_F(PolicyManagerImplTest2,
RetrySequenceDelaysSeconds_Expect_CorrectValues) {
// Arrange
std::ifstream ifile(preloaded_pt_filename_);
- Json::Reader reader;
+ Json::CharReaderBuilder reader_builder;
Json::Value root(Json::objectValue);
- if (ifile.is_open() && reader.parse(ifile, root, true)) {
+ if (ifile.is_open() &&
+ Json::parseFromStream(reader_builder, ifile, &root, nullptr)) {
Json::Value seconds_between_retries = Json::Value(Json::arrayValue);
seconds_between_retries =
root["policy_table"]["module_config"]["seconds_between_retries"];
@@ -321,6 +283,8 @@ TEST_F(PolicyManagerImplTest2,
OnExceededTimeout_GetPolicyTableStatus_ExpectUpdateNeeded) {
// Arrange
CreateLocalPT(preloaded_pt_filename_);
+ ON_CALL(ptu_retry_handler_, IsAllowedRetryCountExceeded())
+ .WillByDefault(Return(false));
policy_manager_->ForcePTExchange();
policy_manager_->OnExceededTimeout();
// Check
@@ -338,13 +302,48 @@ TEST_F(PolicyManagerImplTest, MarkUnpairedDevice) {
EXPECT_CALL(*cache_manager_, IgnitionCyclesBeforeExchange());
EXPECT_CALL(*cache_manager_, DaysBeforeExchange(_));
// Act
+ EXPECT_CALL(*cache_manager_, GenerateSnapshot())
+ .WillOnce(Return(default_pt_snapshot_));
policy_manager_->MarkUnpairedDevice(unpaired_device_id_);
}
TEST_F(PolicyManagerImplTest2, GetCurrentDeviceId) {
// Arrange
- EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_)).Times(1);
- EXPECT_EQ("", policy_manager_->GetCurrentDeviceId(app_id_2_));
+ const transport_manager::DeviceHandle handle = 1;
+ EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(handle, app_id_2_))
+ .Times(1);
+ EXPECT_EQ("", policy_manager_->GetCurrentDeviceId(handle, app_id_2_));
+}
+
+TEST_F(PolicyManagerImplTest2, UpdateApplication_AppServices) {
+ // Arrange
+ std::string kServiceType = "MEDIA";
+ CreateLocalPT(preloaded_pt_filename_);
+ EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus());
+ GetPTU("json/valid_sdl_pt_update.json");
+ EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus());
+ // Try to add existing app
+ policy_table::AppServiceParameters app_service_parameters =
+ policy_table::AppServiceParameters();
+ policy_manager_->GetAppServiceParameters(app_id_2_, &app_service_parameters);
+
+ ASSERT_FALSE(app_service_parameters.find(kServiceType) ==
+ app_service_parameters.end());
+
+ auto service_names = *(app_service_parameters[kServiceType].service_names);
+
+ ASSERT_TRUE(service_names.is_initialized());
+ ASSERT_EQ(service_names.size(), 2u);
+ EXPECT_EQ(static_cast<std::string>(service_names[0]), "SDL App");
+ EXPECT_EQ(static_cast<std::string>(service_names[1]), "SDL Music");
+
+ auto handled_rpcs = app_service_parameters[kServiceType].handled_rpcs;
+
+ ASSERT_TRUE(handled_rpcs.is_initialized());
+ EXPECT_EQ(handled_rpcs[0].function_id, 41);
+
+ // Check no update required
+ EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus());
}
TEST_F(
@@ -355,7 +354,7 @@ TEST_F(
PreconditionExternalConsentPreparePTWithAppGroupsAndConsents();
- utils::SharedPtr<policy_table::Table> pt =
+ std::shared_ptr<policy_table::Table> pt =
policy_manager_->GetCache()->GetPT();
// Checking groups consents before setting ExternalConsent status
@@ -395,7 +394,7 @@ TEST_F(
status.insert(ExternalConsentStatusItem(type_2_, id_2_, kStatusOn));
status.insert(ExternalConsentStatusItem(type_3_, id_3_, kStatusOn));
- EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_1_, _));
+ EXPECT_CALL(listener_, OnPermissionsUpdated(device_id_1_, app_id_1_, _));
EXPECT_TRUE(policy_manager_->SetExternalConsentStatus(status));
@@ -420,7 +419,7 @@ TEST_F(
PreconditionExternalConsentPreparePTWithAppGroupsAndConsents();
// Act
- utils::SharedPtr<policy_table::Table> pt =
+ std::shared_ptr<policy_table::Table> pt =
policy_manager_->GetCache()->GetPT();
// Checking ExternalConsent consents before setting new ExternalConsent status
@@ -444,7 +443,7 @@ TEST_F(
status.insert(ExternalConsentStatusItem(type_2_, id_2_, kStatusOn));
status.insert(ExternalConsentStatusItem(type_3_, id_3_, kStatusOn));
- EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_1_, _));
+ EXPECT_CALL(listener_, OnPermissionsUpdated(device_id_1_, app_id_1_, _));
EXPECT_TRUE(policy_manager_->SetExternalConsentStatus(status));
@@ -484,7 +483,7 @@ TEST_F(
PreconditionExternalConsentPreparePTWithAppPolicy();
// Act
- utils::SharedPtr<policy_table::Table> pt =
+ std::shared_ptr<policy_table::Table> pt =
policy_manager_->GetCache()->GetPT();
ExternalConsentStatus status;
@@ -500,12 +499,12 @@ TEST_F(
EXPECT_FALSE(pt->policy_table.device_data->end() != updated_device_data);
- EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_1_, _));
- EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_1_))
+ EXPECT_CALL(listener_, OnPermissionsUpdated(device_id_1_, app_id_1_, _));
+ EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(_, app_id_1_))
.WillRepeatedly(Return(device_id_1_));
- policy_manager_->AddApplication(app_id_1_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_1_, app_id_1_, HmiTypes(policy_table::AHT_DEFAULT));
// Check ExternalConsent consents for application
updated_device_data = pt->policy_table.device_data->find(device_id_1_);
@@ -552,7 +551,7 @@ TEST_F(
PreconditionExternalConsentPreparePTWithAppPolicy();
// Act
- utils::SharedPtr<policy_table::Table> pt =
+ std::shared_ptr<policy_table::Table> pt =
policy_manager_->GetCache()->GetPT();
ExternalConsentStatus status;
@@ -568,12 +567,12 @@ TEST_F(
EXPECT_FALSE(pt->policy_table.device_data->end() != updated_device_data);
- EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_1_, _));
- EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_1_))
+ EXPECT_CALL(listener_, OnPermissionsUpdated(device_id_1_, app_id_1_, _));
+ EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(_, app_id_1_))
.WillRepeatedly(Return(device_id_1_));
- policy_manager_->AddApplication(app_id_1_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_1_, app_id_1_, HmiTypes(policy_table::AHT_DEFAULT));
// Checking ExternalConsent consents after setting new ExternalConsent status
ApplicationPolicies::const_iterator app_parameters =
@@ -623,18 +622,15 @@ TEST_F(
EXPECT_TRUE(policy_manager_->GetCache()->ApplyUpdate(t));
- EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_1_, _));
- EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_1_))
- .WillOnce(Return(device_id_1_)) // registered
- .WillOnce(Return("")) // not registered
- .WillRepeatedly(Return(device_id_1_)); // again registered
-
+ EXPECT_CALL(listener_, OnPermissionsUpdated(device_id_1_, app_id_1_, _));
+ EXPECT_CALL(listener_, GetDevicesIds(app_id_1_))
+ .WillRepeatedly(Return(transport_manager::DeviceList()));
// First register w/o app having groups to consent
- policy_manager_->AddApplication(app_id_1_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_1_, app_id_1_, HmiTypes(policy_table::AHT_DEFAULT));
// Act
- utils::SharedPtr<policy_table::Table> pt =
+ std::shared_ptr<policy_table::Table> pt =
policy_manager_->GetCache()->GetPT();
ExternalConsentStatus status;
@@ -662,8 +658,8 @@ TEST_F(
EXPECT_TRUE(policy_manager_->GetCache()->ApplyUpdate(t));
// Second time register w/ app having groups to consent
- policy_manager_->AddApplication(app_id_1_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_1_, app_id_1_, HmiTypes(policy_table::AHT_DEFAULT));
// Checking ExternalConsent consents after setting new ExternalConsent status
ApplicationPolicies::const_iterator app_parameters =
@@ -713,18 +709,14 @@ TEST_F(
EXPECT_TRUE(policy_manager_->GetCache()->ApplyUpdate(t));
- EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_1_, _));
- EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_1_))
- .WillOnce(Return(device_id_1_)) // registered
- .WillOnce(Return("")) // not registered
- .WillRepeatedly(Return(device_id_1_)); // registered again
+ EXPECT_CALL(listener_, OnPermissionsUpdated(device_id_1_, app_id_1_, _));
// First register w/o app having groups to consent
- policy_manager_->AddApplication(app_id_1_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_1_, app_id_1_, HmiTypes(policy_table::AHT_DEFAULT));
// Act
- utils::SharedPtr<policy_table::Table> pt =
+ std::shared_ptr<policy_table::Table> pt =
policy_manager_->GetCache()->GetPT();
ExternalConsentStatus status;
@@ -752,8 +744,8 @@ TEST_F(
EXPECT_TRUE(policy_manager_->GetCache()->ApplyUpdate(t));
// Second time register w/ app having groups to consent
- policy_manager_->AddApplication(app_id_1_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_1_, app_id_1_, HmiTypes(policy_table::AHT_DEFAULT));
// Check ExternalConsent consents for application
updated_device_data = pt->policy_table.device_data->find(device_id_1_);
@@ -811,14 +803,13 @@ TEST_F(PolicyManagerImplTest_ExternalConsent,
EXPECT_TRUE(policy_manager_->SetExternalConsentStatus(status));
- EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_1_, _));
- EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_1_))
- .WillRepeatedly(Return(device_id_1_));
+ EXPECT_CALL(listener_, OnPermissionsUpdated(device_id_1_, app_id_1_, _));
+ EXPECT_CALL(listener_, GetDevicesIds(app_id_1_))
+ .WillRepeatedly(Return(transport_manager::DeviceList()));
+ policy_manager_->AddApplication(
+ device_id_1_, app_id_1_, HmiTypes(policy_table::AHT_DEFAULT));
- policy_manager_->AddApplication(app_id_1_,
- HmiTypes(policy_table::AHT_DEFAULT));
-
- utils::SharedPtr<policy_table::Table> pt =
+ std::shared_ptr<policy_table::Table> pt =
policy_manager_->GetCache()->GetPT();
// Check ExternalConsent consents for application
@@ -875,7 +866,9 @@ TEST_F(PolicyManagerImplTest_ExternalConsent,
EXPECT_CALL(listener_, OnCertificateUpdated(_));
- EXPECT_TRUE(policy_manager_->LoadPT("DummyFileName", msg));
+ ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess,
+ policy_manager_->LoadPT("DummyFileName", msg));
+ policy_manager_->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess);
pt = policy_manager_->GetCache()->GetPT();
@@ -936,14 +929,13 @@ TEST_F(PolicyManagerImplTest_ExternalConsent,
EXPECT_TRUE(policy_manager_->SetExternalConsentStatus(status));
- EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_1_, _));
- EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_1_))
- .WillRepeatedly(Return(device_id_1_));
-
- policy_manager_->AddApplication(app_id_1_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ EXPECT_CALL(listener_, OnPermissionsUpdated(device_id_1_, app_id_1_, _));
+ EXPECT_CALL(listener_, GetDevicesIds(app_id_1_))
+ .WillRepeatedly(Return(transport_manager::DeviceList()));
+ policy_manager_->AddApplication(
+ device_id_1_, app_id_1_, HmiTypes(policy_table::AHT_DEFAULT));
- utils::SharedPtr<policy_table::Table> pt =
+ std::shared_ptr<policy_table::Table> pt =
policy_manager_->GetCache()->GetPT();
// Check ExternalConsent consents for application
@@ -995,7 +987,9 @@ TEST_F(PolicyManagerImplTest_ExternalConsent,
EXPECT_CALL(listener_, OnCertificateUpdated(_));
- EXPECT_TRUE(policy_manager_->LoadPT("DummyFileName", msg));
+ ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess,
+ policy_manager_->LoadPT("DummyFileName", msg));
+ policy_manager_->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess);
pt = policy_manager_->GetCache()->GetPT();
@@ -1046,7 +1040,7 @@ TEST_F(
PreconditionExternalConsentPreparePTWithAppGroupsAndConsents();
// Act
- utils::SharedPtr<policy_table::Table> pt =
+ std::shared_ptr<policy_table::Table> pt =
policy_manager_->GetCache()->GetPT();
// Checking ExternalConsent consents before setting new ExternalConsent status
@@ -1070,7 +1064,7 @@ TEST_F(
status_on.insert(ExternalConsentStatusItem(type_2_, id_2_, kStatusOn));
status_on.insert(ExternalConsentStatusItem(type_3_, id_3_, kStatusOn));
- EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_1_, _));
+ EXPECT_CALL(listener_, OnPermissionsUpdated(device_id_1_, app_id_1_, _));
EXPECT_TRUE(policy_manager_->SetExternalConsentStatus(status_on));
@@ -1106,7 +1100,8 @@ TEST_F(
status_off.insert(ExternalConsentStatusItem(type_2_, id_2_, kStatusOff));
status_off.insert(ExternalConsentStatusItem(type_3_, id_3_, kStatusOff));
- EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_1_, _)).Times(1);
+ EXPECT_CALL(listener_, OnPermissionsUpdated(device_id_1_, app_id_1_, _))
+ .Times(1);
EXPECT_TRUE(policy_manager_->SetExternalConsentStatus(status_off));
@@ -1122,6 +1117,6 @@ TEST_F(
EXPECT_EQ(Boolean(false), updated_group_2->second);
}
-} // namespace policy
+} // namespace policy_test
} // namespace components
} // namespace test
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 48e86d24b7..7c2d231708 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
@@ -30,17 +30,17 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <string>
-#include <fstream>
#include <stdint.h>
+#include <fstream>
+#include <string>
#include <vector>
#include "policy/policy_manager_impl_test_base.h"
#include "utils/file_system.h"
-#include "utils/make_shared.h"
+
#include "utils/gen_hash.h"
-#include "json/reader.h"
+#include "utils/jsoncpp_reader_wrapper.h"
#include "policy/mock_pt_ext_representation.h"
@@ -48,10 +48,10 @@ namespace test {
namespace components {
namespace policy_test {
+using ::testing::_;
+using ::testing::ContainerEq;
using ::testing::Return;
using ::testing::ReturnRef;
-using ::testing::ContainerEq;
-using ::testing::_;
// Help functions
char GenRandomChar(char range_from, char range_to) {
@@ -105,12 +105,12 @@ Json::Value createPTforLoad() {
"}"
"},"
"\"notifications_per_minute_by_priority\": {"
- "\"emergency\": 1,"
- "\"navigation\": 2,"
- "\"VOICECOMM\": 3,"
- "\"communication\": 4,"
- "\"normal\": 5,"
- "\"none\": 6"
+ "\"EMERGENCY\": 1,"
+ "\"NAVIGATION\": 2,"
+ "\"VOICECOM\": 3,"
+ "\"COMMUNICATION\": 4,"
+ "\"NORMAL\": 5,"
+ "\"NONE\": 6"
"},"
"\"vehicle_make\" : \"MakeT\","
"\"vehicle_model\" : \"ModelT\","
@@ -175,8 +175,8 @@ Json::Value createPTforLoad() {
"}");
Json::Value table(Json::objectValue);
- Json::Reader reader;
- EXPECT_TRUE(reader.parse(load_table, table));
+ utils::JsonReader reader;
+ EXPECT_TRUE(reader.parse(load_table, &table));
return table;
}
@@ -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_);
@@ -218,6 +218,10 @@ void PolicyManagerImplTest::SetUp() {
ON_CALL(*cache_manager_, GetKnownLinksFromPT())
.WillByDefault(Return(std::map<std::string, std::string>()));
ON_CALL(listener_, GetRegisteredLinks(_)).WillByDefault(Return());
+ ON_CALL(listener_, ptu_retry_handler())
+ .WillByDefault(ReturnRef(ptu_retry_handler_));
+ Json::Value table = createPTforLoad();
+ default_pt_snapshot_ = std::make_shared<policy_table::Table>(&table);
}
void PolicyManagerImplTest::TearDown() {
@@ -253,6 +257,10 @@ PolicyManagerImplTest2::PolicyManagerImplTest2()
void PolicyManagerImplTest2::SetUp() {
ON_CALL(listener_, GetRegisteredLinks(_)).WillByDefault(Return());
+ ON_CALL(listener_, ptu_retry_handler())
+ .WillByDefault(ReturnRef(ptu_retry_handler_));
+ ON_CALL(listener_, GetDevicesIds(_))
+ .WillByDefault(Return(transport_manager::DeviceList()));
file_system::CreateDirectory(app_storage_folder_);
@@ -260,7 +268,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;
@@ -278,16 +286,19 @@ void PolicyManagerImplTest2::SetUp() {
const Json::Value PolicyManagerImplTest2::GetPTU(const std::string& file_name) {
// Get PTU
std::ifstream ifile(file_name);
- Json::Reader reader;
+ Json::CharReaderBuilder reader_builder;
std::string json;
Json::Value root(Json::objectValue);
- if (ifile.is_open() && reader.parse(ifile, root, true)) {
+ if (ifile.is_open() &&
+ Json::parseFromStream(reader_builder, ifile, &root, nullptr)) {
json = root.toStyledString();
}
ifile.close();
::policy::BinaryMessage msg(json.begin(), json.end());
// Load Json to cache
- EXPECT_TRUE(policy_manager_->LoadPT(kFilePtUpdateJson, msg));
+ EXPECT_EQ(PolicyManager::PtProcessingResult::kSuccess,
+ policy_manager_->LoadPT(kFilePtUpdateJson, msg));
+ policy_manager_->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess);
EXPECT_FALSE(policy_manager_->GetCache()->IsPTPreloaded());
return root;
}
@@ -307,7 +318,10 @@ void PolicyManagerImplTest2::AddRTtoPT(const std::string& update_file_name,
// Arrange
CreateLocalPT(preloaded_pt_filename_);
// Get RequestTypes from section of preloaded_pt app_policies
- pt_request_types_ = policy_manager_->GetAppRequestTypes(section_name);
+ const transport_manager::DeviceHandle handle = 1;
+ EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(handle, section_name))
+ .WillRepeatedly(Return(device_id_1_));
+ pt_request_types_ = policy_manager_->GetAppRequestTypes(handle, section_name);
EXPECT_EQ(rt_number, pt_request_types_.size());
Json::Value root = GetPTU(update_file_name);
// Get Request Types from JSON (PTU)
@@ -316,7 +330,7 @@ void PolicyManagerImplTest2::AddRTtoPT(const std::string& update_file_name,
ptu_request_types_size_ = ptu_request_types_.size();
pt_request_types_.clear();
// Get RequestTypes from section of PT app policies after update
- pt_request_types_ = policy_manager_->GetAppRequestTypes(section_name);
+ pt_request_types_ = policy_manager_->GetAppRequestTypes(handle, section_name);
// Check number of RT in PTU and PT now are equal
ASSERT_EQ(ptu_request_types_size_ - invalid_rt_number,
pt_request_types_.size());
@@ -329,14 +343,17 @@ void PolicyManagerImplTest2::AddRTtoAppSectionPT(
const uint32_t invalid_rt_number) {
// Arrange
CreateLocalPT(preloaded_pt_filename_);
+ const transport_manager::DeviceHandle handle = 1;
+ EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(handle, section_name))
+ .WillRepeatedly(Return(device_id_1_));
// Add app
- policy_manager_->AddApplication(section_name,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_1_, section_name, HmiTypes(policy_table::AHT_DEFAULT));
// Check app gets RequestTypes from pre_DataConsent of app_policies
// section
- pt_request_types_ = policy_manager_->GetAppRequestTypes(section_name);
+ pt_request_types_ = policy_manager_->GetAppRequestTypes(handle, section_name);
EXPECT_EQ(rt_number, pt_request_types_.size());
- EXPECT_CALL(listener_, OnPendingPermissionChange(section_name)).Times(1);
+ EXPECT_CALL(listener_, OnPendingPermissionChange(_, section_name)).Times(1);
Json::Value root = GetPTU(update_file_name);
// Get App Request Types from PTU
@@ -346,13 +363,13 @@ void PolicyManagerImplTest2::AddRTtoAppSectionPT(
pt_request_types_.clear();
// Get RequestTypes from <app_id> section of app policies after PT update
- pt_request_types_ = policy_manager_->GetAppRequestTypes(section_name);
+ pt_request_types_ = policy_manager_->GetAppRequestTypes(handle, section_name);
// Check sizes of Request types of PT and PTU
ASSERT_EQ(ptu_request_types_size_ - invalid_rt_number,
pt_request_types_.size());
::policy::AppPermissions permissions =
- policy_manager_->GetAppPermissionsChanges(section_name);
+ policy_manager_->GetAppPermissionsChanges(device_id_1_, section_name);
EXPECT_TRUE(permissions.requestTypeChanged);
}
@@ -414,7 +431,7 @@ void PolicyManagerImplTest2::GetFunctionalGroupingsFromManager(
// Get cache
::policy::CacheManagerInterfaceSPtr cache = policy_manager_->GetCache();
// Get table_snapshot
- utils::SharedPtr<policy_table::Table> table = cache->GenerateSnapshot();
+ std::shared_ptr<policy_table::Table> table = cache->GenerateSnapshot();
// Set functional groupings from policy table
input_functional_groupings = table->policy_table.functional_groupings;
}
@@ -449,28 +466,30 @@ void PolicyManagerImplTest2::
2,
"Bluetooth"));
+ EXPECT_CALL(listener_, GetDevicesIds(application_id_))
+ .WillRepeatedly(Return(transport_manager::DeviceList()));
+
// Add app from consented device. App will be assigned with default policies
- policy_manager_->AddApplication(application_id_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->SetUserConsentForDevice(device_id_1_, true);
+ policy_manager_->AddApplication(
+ device_id_1_, application_id_, HmiTypes(policy_table::AHT_DEFAULT));
// Expect all parameters are allowed
std::ifstream ifile(update_file);
- Json::Reader reader;
+ Json::CharReaderBuilder reader_builder;
std::string json;
Json::Value root(Json::objectValue);
if (ifile.is_open()) {
- reader.parse(ifile, root, true);
+ Json::parseFromStream(reader_builder, ifile, &root, nullptr);
}
json = root.toStyledString();
ifile.close();
::policy::BinaryMessage msg(json.begin(), json.end());
- EXPECT_TRUE(policy_manager_->LoadPT(kFilePtUpdateJson, msg));
- EXPECT_FALSE(cache->IsPTPreloaded());
+ ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess,
+ policy_manager_->LoadPT(kFilePtUpdateJson, msg));
+ policy_manager_->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess);
- // Will be called each time permissions are checked
- EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(application_id_))
- .Times(4)
- .WillRepeatedly(Return(device_id_1_));
+ EXPECT_FALSE(cache->IsPTPreloaded());
// Check RPC in each level
::policy::RPCParams input_params;
@@ -478,8 +497,12 @@ void PolicyManagerImplTest2::
::policy::CheckPermissionResult output;
// Rpc in FULL level
- policy_manager_->CheckPermissions(
- application_id_, kHmiLevelFull, "SendLocation", input_params, output);
+ policy_manager_->CheckPermissions(device_id_1_,
+ application_id_,
+ kHmiLevelFull,
+ "SendLocation",
+ input_params,
+ output);
// Check RPC is allowed
EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted);
// Check list of allowed parameters is not empty
@@ -489,8 +512,12 @@ void PolicyManagerImplTest2::
ResetOutputList(output);
// Rpc in LIMITED level
- policy_manager_->CheckPermissions(
- application_id_, kHmiLevelLimited, "SendLocation", input_params, output);
+ policy_manager_->CheckPermissions(device_id_1_,
+ application_id_,
+ kHmiLevelLimited,
+ "SendLocation",
+ input_params,
+ output);
// Check RPC is allowed
EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted);
// Check list of allowed parameters is not empty
@@ -500,7 +527,8 @@ void PolicyManagerImplTest2::
ResetOutputList(output);
// Rpc in BACKGROUND level
- policy_manager_->CheckPermissions(application_id_,
+ policy_manager_->CheckPermissions(device_id_1_,
+ application_id_,
kHmiLevelBackground,
"SendLocation",
input_params,
@@ -515,8 +543,12 @@ void PolicyManagerImplTest2::
ResetOutputList(output);
// Rpc in NONE level
- policy_manager_->CheckPermissions(
- application_id_, kHmiLevelNone, "SendLocation", input_params, output);
+ policy_manager_->CheckPermissions(device_id_1_,
+ application_id_,
+ kHmiLevelNone,
+ "SendLocation",
+ input_params,
+ output);
// Check RPC is disallowed
EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted);
// Check lists of parameters are empty
@@ -529,8 +561,12 @@ void PolicyManagerImplTest2::CheckRpcPermissions(
const std::string& rpc_name, const PermitResult& expected_permission) {
::policy::RPCParams input_params;
::policy::CheckPermissionResult output;
- policy_manager_->CheckPermissions(
- application_id_, kHmiLevelFull, rpc_name, input_params, output);
+ policy_manager_->CheckPermissions(device_id_1_,
+ application_id_,
+ kHmiLevelFull,
+ rpc_name,
+ input_params,
+ output);
EXPECT_EQ(expected_permission, output.hmi_level_permitted);
}
@@ -541,16 +577,17 @@ void PolicyManagerImplTest2::CheckRpcPermissions(
::policy::RPCParams input_params;
::policy::CheckPermissionResult output;
policy_manager_->CheckPermissions(
- app_id, kHmiLevelFull, rpc_name, input_params, output);
+ device_id_1_, app_id, kHmiLevelFull, rpc_name, input_params, output);
EXPECT_EQ(out_expected_permission, output.hmi_level_permitted);
}
void PolicyManagerImplTest2::EmulatePTAppRevoked(const std::string& ptu_name) {
std::ifstream ifile(ptu_name);
- Json::Reader reader;
+ Json::CharReaderBuilder reader_builder;
std::string json;
Json::Value root(Json::objectValue);
- if (ifile.is_open() && reader.parse(ifile, root, true)) {
+ if (ifile.is_open() &&
+ Json::parseFromStream(reader_builder, ifile, &root, nullptr)) {
// Emulate application is revoked
root["policy_table"]["app_policies"]["1234"]["is_revoked"] = 1;
json = root.toStyledString();
@@ -558,7 +595,9 @@ void PolicyManagerImplTest2::EmulatePTAppRevoked(const std::string& ptu_name) {
ifile.close();
::policy::BinaryMessage msg(json.begin(), json.end());
- ASSERT_TRUE(policy_manager_->LoadPT(kDummyUpdateFileName, msg));
+ ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess,
+ policy_manager_->LoadPT(kDummyUpdateFileName, msg));
+ policy_manager_->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess);
}
// To avoid duplicate arrange of test
@@ -576,8 +615,9 @@ void PolicyManagerImplTest2::AddSetDeviceData() {
"Bluetooth"));
// Add app from consented device. App will be assigned with default policies
- policy_manager_->AddApplication(application_id_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->SetUserConsentForDevice(device_id_1_, true);
+ policy_manager_->AddApplication(
+ device_id_1_, application_id_, HmiTypes(policy_table::AHT_DEFAULT));
(policy_manager_->GetCache())->AddDevice(device_id_1_, "Bluetooth");
}
@@ -586,16 +626,19 @@ void PolicyManagerImplTest2::LoadPTUFromJsonFile(
const std::string& update_file) {
// Load Json to cache
std::ifstream ifile(update_file);
- Json::Reader reader;
+ Json::CharReaderBuilder reader_builder;
std::string json;
Json::Value root(Json::objectValue);
if (ifile.is_open()) {
- reader.parse(ifile, root, true);
+ Json::parseFromStream(reader_builder, ifile, &root, nullptr);
}
json = root.toStyledString();
ifile.close();
::policy::BinaryMessage msg(json.begin(), json.end());
- EXPECT_TRUE(policy_manager_->LoadPT(kFilePtUpdateJson, msg));
+ ASSERT_EQ(PolicyManager::PtProcessingResult::kSuccess,
+ policy_manager_->LoadPT(kFilePtUpdateJson, msg));
+ policy_manager_->OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess);
+
EXPECT_FALSE(policy_manager_->GetCache()->IsPTPreloaded());
}
@@ -636,10 +679,12 @@ PolicyManagerImplTest_RequestTypes::PolicyManagerImplTest_RequestTypes()
void PolicyManagerImplTest_RequestTypes::SetUp() {
ON_CALL(listener_, GetRegisteredLinks(_)).WillByDefault(Return());
+ ON_CALL(listener_, GetDevicesIds(_))
+ .WillByDefault(Return(transport_manager::DeviceList()));
file_system::CreateDirectory(app_storage_folder_);
const bool in_memory = true;
- policy_manager_impl_sptr_ = utils::MakeShared<PolicyManagerImpl>(in_memory);
+ policy_manager_impl_sptr_ = std::make_shared<PolicyManagerImpl>(in_memory);
policy_manager_impl_sptr_->set_listener(&listener_);
}
@@ -647,16 +692,21 @@ const Json::Value PolicyManagerImplTest_RequestTypes::GetPTU(
const std::string& file_name) {
// Get PTU
std::ifstream ifile(file_name);
- Json::Reader reader;
+ Json::CharReaderBuilder reader_builder;
std::string json;
Json::Value root(Json::objectValue);
- if (ifile.is_open() && reader.parse(ifile, root, true)) {
+ if (ifile.is_open() &&
+ Json::parseFromStream(reader_builder, ifile, &root, nullptr)) {
json = root.toStyledString();
}
ifile.close();
::policy::BinaryMessage msg(json.begin(), json.end());
// Load Json to cache
- EXPECT_TRUE(policy_manager_impl_sptr_->LoadPT(kFilePtUpdateJson, msg));
+ EXPECT_EQ(PolicyManager::PtProcessingResult::kSuccess,
+ policy_manager_impl_sptr_->LoadPT(kFilePtUpdateJson, msg));
+ policy_manager_impl_sptr_->OnPTUFinished(
+ PolicyManager::PtProcessingResult::kSuccess);
+
EXPECT_FALSE(policy_manager_impl_sptr_->GetCache()->IsPTPreloaded());
return root;
}
@@ -864,10 +914,11 @@ std::string PolicyManagerImplTest_ExternalConsent::PreparePTUWithNewGroup(
using namespace rpc;
std::ifstream ifile(preloaded_pt_filename_);
- Json::Reader reader;
+ Json::CharReaderBuilder reader_builder;
std::string json;
Json::Value root(Json::objectValue);
- if (ifile.is_open() && reader.parse(ifile, root, true)) {
+ if (ifile.is_open() &&
+ Json::parseFromStream(reader_builder, ifile, &root, nullptr)) {
Table t = PreparePTWithGroupsHavingExternalConsent();
ExternalConsentEntity entity_4(type, id);
diff --git a/src/components/policy/policy_external/test/policy_manager_impl_user_consent_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_user_consent_test.cc
index 2f2162494f..1db23260a8 100644
--- a/src/components/policy/policy_external/test/policy_manager_impl_user_consent_test.cc
+++ b/src/components/policy/policy_external/test/policy_manager_impl_user_consent_test.cc
@@ -34,6 +34,7 @@
#include "policy/policy_manager_impl_test_base.h"
#include "utils/date_time.h"
+#include "utils/macro.h"
namespace test {
namespace components {
@@ -49,13 +50,15 @@ TEST_F(
// Arrange
CreateLocalPT(preloaded_pt_filename_);
- EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_1_))
+ EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(_, app_id_1_))
.WillRepeatedly(Return(device_id_1_));
+ EXPECT_CALL(listener_, CanUpdate()).WillRepeatedly(Return(true));
+
policy_manager_->SetUserConsentForDevice(device_id_1_, true);
- policy_manager_->AddApplication(app_id_1_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_1_, app_id_1_, HmiTypes(policy_table::AHT_DEFAULT));
EXPECT_EQ("UPDATE_NEEDED", policy_manager_->GetPolicyTableStatus());
}
@@ -69,20 +72,21 @@ TEST_F(
// To set UP_TO_DATE before registration
GetPTU(kValidSdlPtUpdateJson);
- const TimevalStruct current_time = date_time::DateTime::getCurrentTime();
+ const date_time::TimeDuration current_time = date_time::getCurrentTime();
const int kSecondsInDay = 60 * 60 * 24;
- const int days_after_epoch = current_time.tv_sec / kSecondsInDay;
+ const int days_after_epoch = date_time::getSecs(current_time) / kSecondsInDay;
policy_manager_->PTUpdatedAt(DAYS_AFTER_EPOCH, days_after_epoch);
policy_manager_->PTUpdatedAt(KILOMETERS, 1000);
- EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_1_))
+ const transport_manager::DeviceHandle handle = 1;
+ EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(handle, app_id_1_))
.WillRepeatedly(Return(device_id_1_));
policy_manager_->SetUserConsentForDevice(device_id_1_, false);
- policy_manager_->AddApplication(app_id_1_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_1_, app_id_1_, HmiTypes(policy_table::AHT_DEFAULT));
EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus());
}
@@ -92,10 +96,13 @@ TEST_F(
ReactOnUserDevConsentForApp_AddNewApplicationFromDeviceWithoutConsent_ExpectPreDataConsent) {
// Arrange
CreateLocalPT(preloaded_pt_filename_);
- policy_manager_->AddApplication(app_id_1_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ const transport_manager::DeviceHandle handle = 1;
+ EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(handle, app_id_1_))
+ .WillRepeatedly(Return(device_id_1_));
+ policy_manager_->AddApplication(
+ device_id_1_, app_id_1_, HmiTypes(policy_table::AHT_DEFAULT));
ASSERT_TRUE(policy_manager_->IsPredataPolicy(app_id_1_));
- policy_manager_->ReactOnUserDevConsentForApp(app_id_1_, false);
+ policy_manager_->ReactOnUserDevConsentForApp(handle, app_id_1_, false);
EXPECT_TRUE(policy_manager_->IsPredataPolicy(app_id_1_));
}
@@ -106,8 +113,8 @@ TEST_F(PolicyManagerImplTest2,
CreateLocalPT(kSdlPreloadedPtJson2);
ASSERT_TRUE(
(policy_manager_->GetCache())->AddDevice(device_id_2_, "Bluetooth"));
- policy_manager_->AddApplication(application_id_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_2_, application_id_, HmiTypes(policy_table::AHT_DEFAULT));
// Expect RPCs from pre_dataConsent group are allowed
// Next checks are equal to BaseBeforeDataConsent_APIs.xml checks from task
@@ -155,11 +162,11 @@ TEST_F(PolicyManagerImplTest2,
TEST_F(PolicyManagerImplTest2, CheckPreDataConsent_GetDefaultHmiLevel_NONE) {
// Arrange
CreateLocalPT(preloaded_pt_filename_);
- policy_manager_->AddApplication(app_id_2_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_1_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT));
std::string default_hmi;
// Default HMI level is NONE
- policy_manager_->GetDefaultHmi(app_id_2_, &default_hmi);
+ policy_manager_->GetDefaultHmi(device_id_1_, app_id_2_, &default_hmi);
EXPECT_EQ("NONE", default_hmi);
// Default priority level is NONE
@@ -173,11 +180,11 @@ TEST_F(PolicyManagerImplTest2,
CheckPreDataConsent_GetDefaultHmiLevel_BACKGROUNG) {
// Arrange
CreateLocalPT(kSdlPreloadedPtJson2);
- policy_manager_->AddApplication(app_id_2_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_1_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT));
std::string default_hmi;
// Default HMI level is BACKGROUND
- policy_manager_->GetDefaultHmi(app_id_2_, &default_hmi);
+ policy_manager_->GetDefaultHmi(device_id_1_, app_id_2_, &default_hmi);
EXPECT_EQ("BACKGROUND", default_hmi);
// Default priority level is EMERGENCY
std::string priority1;
@@ -191,10 +198,13 @@ TEST_F(
// Arrange
// RequestTypes for default & preDataConsent are different
CreateLocalPT("json/ptu_requestType.json");
- policy_manager_->AddApplication(app_id_1_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ const transport_manager::DeviceHandle handle = 1;
+ EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(handle, app_id_1_))
+ .WillRepeatedly(Return(device_id_1_));
+ policy_manager_->AddApplication(
+ device_id_1_, app_id_1_, HmiTypes(policy_table::AHT_DEFAULT));
ASSERT_TRUE(policy_manager_->IsPredataPolicy(app_id_1_));
- policy_manager_->ReactOnUserDevConsentForApp(app_id_1_, true);
+ policy_manager_->ReactOnUserDevConsentForApp(handle, app_id_1_, true);
EXPECT_FALSE(policy_manager_->IsPredataPolicy(app_id_1_));
// Expect app_id_1_ has default policy
EXPECT_TRUE((policy_manager_->GetCache())->IsDefaultPolicy(app_id_1_));
@@ -206,11 +216,14 @@ TEST_F(
// Arrange
// RequestTypes for default & preDataConsent are the same
CreateLocalPT(kPtu2RequestTypeJson);
- policy_manager_->AddApplication(app_id_1_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ const transport_manager::DeviceHandle handle = 1;
+ EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(handle, app_id_1_))
+ .WillRepeatedly(Return(device_id_1_));
+ policy_manager_->AddApplication(
+ device_id_1_, app_id_1_, HmiTypes(policy_table::AHT_DEFAULT));
ASSERT_TRUE(policy_manager_->IsPredataPolicy(app_id_1_));
- EXPECT_CALL(listener_, OnPendingPermissionChange(app_id_1_)).Times(0);
- policy_manager_->ReactOnUserDevConsentForApp(app_id_1_, true);
+ EXPECT_CALL(listener_, OnPendingPermissionChange(_, app_id_1_)).Times(0);
+ policy_manager_->ReactOnUserDevConsentForApp(handle, app_id_1_, true);
EXPECT_FALSE(policy_manager_->IsPredataPolicy(app_id_1_));
EXPECT_TRUE((policy_manager_->GetCache())->IsDefaultPolicy(app_id_1_));
}
@@ -297,12 +310,12 @@ TEST_F(PolicyManagerImplTest2,
policy_manager_->GetUserConsentForDevice(device_id_2_);
// Check
EXPECT_EQ(::policy::DeviceConsent::kDeviceDisallowed, consent);
- EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_))
+ EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(_, app_id_2_))
.WillRepeatedly(Return(device_id_2_));
- policy_manager_->AddApplication(app_id_2_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_2_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT));
std::string default_hmi;
- policy_manager_->GetDefaultHmi(app_id_2_, &default_hmi);
+ policy_manager_->GetDefaultHmi(device_id_2_, app_id_2_, &default_hmi);
EXPECT_EQ("NONE", default_hmi);
}
@@ -310,12 +323,12 @@ TEST_F(PolicyManagerImplTest2,
GetDefaultHmi_SetDeviceAllowed_ExpectReceivedHmiCorrect) {
// Arrange
CreateLocalPT(kPtu2RequestTypeJson);
- policy_manager_->AddApplication(app_id_2_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_1_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT));
// Check if app has preData policy
EXPECT_TRUE(policy_manager_->IsPredataPolicy(app_id_2_));
std::string default_hmi1;
- policy_manager_->GetDefaultHmi(app_id_2_, &default_hmi1);
+ policy_manager_->GetDefaultHmi(device_id_1_, app_id_2_, &default_hmi1);
EXPECT_EQ("NONE", default_hmi1);
ASSERT_TRUE(
(policy_manager_->GetCache())->AddDevice(device_id_2_, "Bluetooth"));
@@ -333,13 +346,13 @@ TEST_F(PolicyManagerImplTest2,
policy_manager_->GetUserConsentForDevice(device_id_2_);
// Check
EXPECT_EQ(::policy::DeviceConsent::kDeviceAllowed, consent);
- EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_))
+ EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(_, app_id_2_))
.WillRepeatedly(Return(device_id_2_));
- policy_manager_->AddApplication(app_id_2_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_2_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT));
EXPECT_TRUE((policy_manager_->GetCache())->IsDefaultPolicy(app_id_2_));
std::string default_hmi2;
- policy_manager_->GetDefaultHmi(app_id_2_, &default_hmi2);
+ policy_manager_->GetDefaultHmi(device_id_2_, app_id_2_, &default_hmi2);
EXPECT_EQ("LIMITED", default_hmi2);
}
@@ -347,8 +360,8 @@ TEST_F(PolicyManagerImplTest2,
GetDefaultPriority_SetDeviceAllowed_ExpectReceivedPriorityCorrect) {
// Arrange
CreateLocalPT(kPtu2RequestTypeJson);
- policy_manager_->AddApplication(app_id_2_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_1_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT));
// Check if app has preData policy
EXPECT_TRUE(policy_manager_->IsPredataPolicy(app_id_2_));
std::string priority1;
@@ -370,10 +383,10 @@ TEST_F(PolicyManagerImplTest2,
policy_manager_->GetUserConsentForDevice(device_id_2_);
// Check
EXPECT_EQ(::policy::DeviceConsent::kDeviceAllowed, consent);
- EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_))
+ EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(_, app_id_2_))
.WillRepeatedly(Return(device_id_2_));
- policy_manager_->AddApplication(app_id_2_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_2_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT));
EXPECT_TRUE((policy_manager_->GetCache())->IsDefaultPolicy(app_id_2_));
std::string priority2;
EXPECT_TRUE(policy_manager_->GetPriority(app_id_2_, &priority2));
@@ -395,7 +408,7 @@ TEST_F(PolicyManagerImplTest2,
uint32_t size = result.size();
EXPECT_GT(size, 0u);
std::vector< ::policy::UserFriendlyMessage>::iterator result_iter;
- utils::SharedPtr<policy_table::Table> pt =
+ std::shared_ptr<policy_table::Table> pt =
(policy_manager_->GetCache())->GetPT();
policy_table::ConsumerFriendlyMessages& consumer_friendly_messages =
@@ -456,7 +469,7 @@ TEST_F(PolicyManagerImplTest2,
TEST_F(PolicyManagerImplTest2, SetDeviceInfo_ExpectDevInfoAddedToPT) {
// Arrange
::policy::DeviceInfo dev_info;
- utils::SharedPtr<policy_table::Table> pt =
+ std::shared_ptr<policy_table::Table> pt =
(policy_manager_->GetCache())->GetPT();
dev_info.hardware = "hardware IPX";
dev_info.firmware_rev = "v.8.0.1";
@@ -490,8 +503,10 @@ TEST_F(PolicyManagerImplTest2, SetDeviceInfo_ExpectDevInfoAddedToPT) {
TEST_F(PolicyManagerImplTest2, GetInitialAppData_ExpectReceivedConsentCorrect) {
// Arrange
CreateLocalPT(preloaded_pt_filename_);
- policy_manager_->AddApplication(app_id_2_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ EXPECT_CALL(listener_, GetDevicesIds(app_id_2_))
+ .WillRepeatedly(Return(transport_manager::DeviceList()));
+ policy_manager_->AddApplication(
+ device_id_1_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT));
::policy::StringArray app_nicknames;
::policy::StringArray app_hmi_types;
policy_manager_->GetInitialAppData(app_id_2_, &app_nicknames, &app_hmi_types);
@@ -534,8 +549,8 @@ TEST_F(
CanAppKeepContext_AddAppFromUnconsentedDevice_ExpectAppCannotKeepContext) {
// Arrange
CreateLocalPT(preloaded_pt_filename_);
- policy_manager_->AddApplication(app_id_2_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_1_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT));
// Check if app has preData policy
EXPECT_TRUE(policy_manager_->IsPredataPolicy(app_id_2_));
// Check keep context in preData policy
@@ -548,8 +563,8 @@ TEST_F(PolicyManagerImplTest2,
CreateLocalPT(preloaded_pt_filename_);
ASSERT_TRUE(
(policy_manager_->GetCache())->AddDevice(device_id_2_, "Bluetooth"));
- policy_manager_->AddApplication(app_id_2_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_1_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT));
ASSERT_TRUE((policy_manager_->GetCache())
->SetDeviceData(device_id_2_,
"hardware IPX",
@@ -563,10 +578,10 @@ TEST_F(PolicyManagerImplTest2,
::policy::DeviceConsent consent =
policy_manager_->GetUserConsentForDevice(device_id_2_);
EXPECT_EQ(::policy::DeviceConsent::kDeviceAllowed, consent);
- EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_))
+ EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(_, app_id_2_))
.WillRepeatedly(Return(device_id_2_));
- policy_manager_->AddApplication(app_id_2_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_2_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT));
EXPECT_TRUE((policy_manager_->GetCache())->IsDefaultPolicy(app_id_2_));
// Check keep context in default policy
EXPECT_FALSE(policy_manager_->CanAppKeepContext(app_id_2_));
@@ -576,8 +591,8 @@ TEST_F(PolicyManagerImplTest2,
CanAppStealFocus_AddAppFromUnconsentedDevice_ExpectAppCannotStealFocus) {
// Arrange
CreateLocalPT(preloaded_pt_filename_);
- policy_manager_->AddApplication(app_id_2_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_1_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT));
// Check if app has preData policy
EXPECT_TRUE(policy_manager_->IsPredataPolicy(app_id_2_));
// Check keep context in preData policy
@@ -590,8 +605,8 @@ TEST_F(PolicyManagerImplTest2,
CreateLocalPT(preloaded_pt_filename_);
ASSERT_TRUE(
(policy_manager_->GetCache())->AddDevice(device_id_2_, "Bluetooth"));
- policy_manager_->AddApplication(app_id_2_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_1_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT));
ASSERT_TRUE((policy_manager_->GetCache())
->SetDeviceData(device_id_2_,
"hardware IPX",
@@ -605,10 +620,10 @@ TEST_F(PolicyManagerImplTest2,
::policy::DeviceConsent consent =
policy_manager_->GetUserConsentForDevice(device_id_2_);
EXPECT_EQ(::policy::DeviceConsent::kDeviceAllowed, consent);
- EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_))
+ EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(_, app_id_2_))
.WillRepeatedly(Return(device_id_2_));
- policy_manager_->AddApplication(app_id_2_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_2_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT));
EXPECT_TRUE((policy_manager_->GetCache())->IsDefaultPolicy(app_id_2_));
// Check keep context in default policy
EXPECT_FALSE(policy_manager_->CanAppStealFocus(app_id_2_));
@@ -618,8 +633,8 @@ TEST_F(PolicyManagerImplTest2,
IsPredataPolicy_SetAppWIthPredataPolicy_ExpectPredataPolicy) {
// Arrange
CreateLocalPT(preloaded_pt_filename_);
- policy_manager_->AddApplication(app_id_2_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ policy_manager_->AddApplication(
+ device_id_1_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT));
// Check if app has preData policy
EXPECT_TRUE(policy_manager_->IsPredataPolicy(app_id_2_));
}
@@ -629,18 +644,18 @@ TEST_F(
SendNotificationOnPermissionsUpdated_SetDeviceAllowed_ExpectNotificationSent) {
// Arrange
CreateLocalPT(kPtu2RequestTypeJson);
- policy_manager_->AddApplication(app_id_2_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ EXPECT_CALL(listener_, GetDevicesIds(app_id_2_)).Times(0);
+ policy_manager_->AddApplication(
+ device_id_1_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT));
// Check if app has preData policy
EXPECT_TRUE(policy_manager_->IsPredataPolicy(app_id_2_));
std::string default_hmi1;
- policy_manager_->GetDefaultHmi(app_id_2_, &default_hmi1);
+ policy_manager_->GetDefaultHmi(device_id_1_, app_id_2_, &default_hmi1);
EXPECT_EQ("NONE", default_hmi1);
- EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_))
- .WillOnce(Return(""));
- EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_2_, _, default_hmi1))
+ EXPECT_CALL(listener_, OnPermissionsUpdated(device_id_1_, app_id_2_, _))
.Times(0);
- policy_manager_->SendNotificationOnPermissionsUpdated(app_id_2_);
+ policy_manager_->SendNotificationOnPermissionsUpdated(device_id_1_,
+ app_id_2_);
ASSERT_TRUE(
(policy_manager_->GetCache())->AddDevice(device_id_2_, "Bluetooth"));
@@ -658,18 +673,19 @@ TEST_F(
policy_manager_->GetUserConsentForDevice(device_id_2_);
// Check
EXPECT_EQ(::policy::DeviceConsent::kDeviceAllowed, consent);
- EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_))
- .WillRepeatedly(Return(device_id_2_));
- policy_manager_->AddApplication(app_id_2_,
- HmiTypes(policy_table::AHT_DEFAULT));
+ EXPECT_CALL(listener_, GetDevicesIds(app_id_2_)).Times(0);
+ policy_manager_->AddApplication(
+ device_id_2_, app_id_2_, HmiTypes(policy_table::AHT_DEFAULT));
EXPECT_TRUE((policy_manager_->GetCache())->IsDefaultPolicy(app_id_2_));
std::string default_hmi2;
- policy_manager_->GetDefaultHmi(app_id_2_, &default_hmi2);
+ policy_manager_->GetDefaultHmi(device_id_2_, app_id_2_, &default_hmi2);
EXPECT_EQ("LIMITED", default_hmi2);
- EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_2_, _, default_hmi2));
- policy_manager_->SendNotificationOnPermissionsUpdated(app_id_2_);
+ EXPECT_CALL(listener_,
+ OnPermissionsUpdated(device_id_2_, app_id_2_, _, default_hmi2));
+ policy_manager_->SendNotificationOnPermissionsUpdated(device_id_2_,
+ app_id_2_);
}
-} // namespace policy
+} // namespace policy_test
} // namespace components
} // namespace test
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 92525c646d..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
@@ -29,29 +29,27 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <vector>
-#include <map>
+#include "policy/sql_pt_ext_representation.h"
#include <algorithm>
-#include <utility>
-#include <string>
-#include <iterator>
#include <iostream>
+#include <iterator>
+#include <map>
+#include <string>
+#include <utility>
+#include <vector>
#include "gtest/gtest.h"
-#include "policy/sql_pt_ext_representation.h"
-#include "utils/gen_hash.h"
-#include "utils/file_system.h"
-#include "sqlite_wrapper/sql_query.h"
-#include "rpc_base/rpc_base.h"
-#include "policy/policy_table/types.h"
#include "policy/mock_policy_settings.h"
-#include "utils/shared_ptr.h"
-#include "utils/make_shared.h"
+#include "policy/policy_table/types.h"
+#include "rpc_base/rpc_base.h"
+#include "sqlite_wrapper/sql_query.h"
+#include "utils/file_system.h"
+#include "utils/gen_hash.h"
using namespace ::policy;
namespace policy_table = rpc::policy_table_interface_base;
-using std::string;
using std::map;
using std::pair;
+using std::string;
using std::vector;
using testing::ReturnRef;
@@ -393,7 +391,7 @@ TEST_F(SQLPTExtRepresentationTest,
ASSERT_TRUE(reps_->Save(update));
// Act
- utils::SharedPtr<policy_table::Table> snapshot = reps_->GenerateSnapshot();
+ std::shared_ptr<policy_table::Table> snapshot = reps_->GenerateSnapshot();
snapshot->SetPolicyTableType(rpc::policy_table_interface_base::PT_SNAPSHOT);
policy_table["module_meta"] = Json::Value(Json::objectValue);
@@ -1506,7 +1504,7 @@ TEST_F(SQLPTExtRepresentationTest, SaveUserConsentRecords_ExpectedSaved) {
// Act
EXPECT_TRUE(reps_->Save(original_table));
- utils::SharedPtr<Table> loaded_table = reps_->GenerateSnapshot();
+ std::shared_ptr<Table> loaded_table = reps_->GenerateSnapshot();
// GetData/GetKeyData methods do internal existence check - no need to do it
// separately. In case of data is missing expectations will be violated.
@@ -1543,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;
@@ -1580,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);
@@ -1591,7 +1589,7 @@ TEST_F(SQLPTExtRepresentationTest, SaveFunctionalGroupings_ExpectedSaved) {
// Act
EXPECT_TRUE(reps_->Save(original_table));
- utils::SharedPtr<Table> loaded_table = reps_->GenerateSnapshot();
+ std::shared_ptr<Table> loaded_table = reps_->GenerateSnapshot();
FunctionalGroupings loaded_groupings =
GetData<Table, FunctionalGroupings>(*loaded_table);
@@ -1617,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);
@@ -1639,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 0b0831eaad..2f85f8dc0a 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
@@ -29,39 +29,38 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <vector>
-#include <string>
-#include <algorithm>
-#include <fstream>
#include <stdio.h>
#include <sys/stat.h>
+#include <algorithm>
+#include <fstream>
#include <memory>
+#include <string>
+#include <vector>
#include "gtest/gtest.h"
-#include "policy/sql_pt_representation.h"
-#include "utils/file_system.h"
-#include "utils/system.h"
-#include "policy/sql_wrapper.h"
-#include "policy/policy_types.h"
-#include "json/writer.h"
#include "json/reader.h"
-#include "policy/policy_table/types.h"
+#include "json/writer.h"
+#include "policy/mock_policy_settings.h"
#include "policy/policy_table/enums.h"
+#include "policy/policy_table/types.h"
+#include "policy/policy_types.h"
+#include "policy/sql_pt_representation.h"
+#include "policy/sql_wrapper.h"
#include "rpc_base/rpc_base.h"
-#include "policy/mock_policy_settings.h"
-#include "utils/shared_ptr.h"
+#include "utils/file_system.h"
+#include "utils/system.h"
namespace policy_table = rpc::policy_table_interface_base;
-using policy::SQLPTRepresentation;
using policy::CheckPermissionResult;
-using policy::UserFriendlyMessage;
using policy::EndpointUrls;
+using policy::SQLPTRepresentation;
+using policy::UserFriendlyMessage;
using policy::VehicleInfo;
-using testing::ReturnRef;
-using testing::Return;
-using testing::NiceMock;
using testing::Mock;
+using testing::NiceMock;
+using testing::Return;
+using testing::ReturnRef;
namespace test {
namespace components {
@@ -81,14 +80,14 @@ class SQLPTRepresentationTest : public SQLPTRepresentation,
static const std::string kDatabaseName;
static utils::dbms::SQLQuery* query_wrapper_;
// Gtest can show message that this object doesn't destroyed
- static std::auto_ptr<policy_handler_test::MockPolicySettings>
+ static std::unique_ptr<policy_handler_test::MockPolicySettings>
policy_settings_;
static void SetUpTestCase() {
const std::string kAppStorageFolder = "storage_SQLPTRepresentationTest";
reps = new SQLPTRepresentation(in_memory_);
ASSERT_TRUE(reps != NULL);
- policy_settings_ = std::auto_ptr<policy_handler_test::MockPolicySettings>(
+ policy_settings_ = std::unique_ptr<policy_handler_test::MockPolicySettings>(
new policy_handler_test::MockPolicySettings());
ON_CALL(*policy_settings_, app_storage_folder())
.WillByDefault(ReturnRef(kAppStorageFolder));
@@ -177,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,
@@ -348,7 +347,7 @@ SQLPTRepresentation* SQLPTRepresentationTest::reps = 0;
utils::dbms::SQLQuery* SQLPTRepresentationTest::query_wrapper_ = 0;
const std::string SQLPTRepresentationTest::kDatabaseName = ":memory:";
const bool SQLPTRepresentationTest::in_memory_ = true;
-std::auto_ptr<policy_handler_test::MockPolicySettings>
+std::unique_ptr<policy_handler_test::MockPolicySettings>
SQLPTRepresentationTest::policy_settings_;
class SQLPTRepresentationTest2 : public ::testing::Test {
@@ -377,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_));
@@ -407,8 +499,8 @@ TEST_F(SQLPTRepresentationTest,
query.Prepare(query_select);
query.Next();
- // 33 - is current total tables number created by schema
- const int policy_tables_number = 33;
+ // 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 =
@@ -966,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
@@ -1585,7 +1658,7 @@ TEST_F(SQLPTRepresentationTest,
ASSERT_TRUE(reps->Save(update));
// Act
- utils::SharedPtr<policy_table::Table> snapshot = reps->GenerateSnapshot();
+ std::shared_ptr<policy_table::Table> snapshot = reps->GenerateSnapshot();
snapshot->SetPolicyTableType(rpc::policy_table_interface_base::PT_SNAPSHOT);
// Remove fields which must be absent in snapshot
table["policy_table"]["consumer_friendly_messages"].removeMember("messages");
@@ -1609,13 +1682,15 @@ TEST_F(SQLPTRepresentationTest,
table["policy_table"]["module_meta"] = Json::Value(Json::objectValue);
table["policy_table"]["module_config"]["preloaded_pt"] = Json::Value(false);
policy_table::Table expected(&table);
- Json::StyledWriter writer;
+ Json::StreamWriterBuilder writer_builder;
// Checks
- EXPECT_EQ(writer.write(expected.ToJsonValue()),
- writer.write(snapshot->ToJsonValue()));
- std::cout << writer.write(snapshot->ToJsonValue()) << std::endl;
+ Json::Value snapshot_json_value = snapshot->ToJsonValue();
+ EXPECT_EQ(Json::writeString(writer_builder, expected.ToJsonValue()),
+ Json::writeString(writer_builder, snapshot_json_value));
+ std::cout << Json::writeString(writer_builder, snapshot_json_value)
+ << std::endl;
EXPECT_EQ(expected.ToJsonValue().toStyledString(),
- snapshot->ToJsonValue().toStyledString());
+ snapshot_json_value.toStyledString());
}
TEST_F(SQLPTRepresentationTest,
@@ -1696,9 +1771,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_external/test/update_status_manager_test.cc b/src/components/policy/policy_external/test/update_status_manager_test.cc
index 5546984ff4..29952bd18e 100644
--- a/src/components/policy/policy_external/test/update_status_manager_test.cc
+++ b/src/components/policy/policy_external/test/update_status_manager_test.cc
@@ -30,11 +30,12 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include "policy/update_status_manager.h"
#include "gtest/gtest.h"
#include "policy/mock_policy_listener.h"
+#include "policy/mock_ptu_retry_handler.h"
#include "policy/policy_manager_impl.h"
-#include "policy/update_status_manager.h"
-#include "utils/make_shared.h"
+
#include "utils/conditional_variable.h"
namespace test {
@@ -43,24 +44,26 @@ namespace policy_test {
using namespace ::policy;
using ::testing::_;
-using ::testing::Return;
using testing::NiceMock;
+using ::testing::Return;
class UpdateStatusManagerTest : public ::testing::Test {
protected:
- utils::SharedPtr<UpdateStatusManager> manager_;
+ std::shared_ptr<UpdateStatusManager> manager_;
PolicyTableStatus status_;
const uint32_t k_timeout_;
NiceMock<MockPolicyListener> listener_;
+ NiceMock<MockPTURetryHandler> mock_ptu_retry_handler_;
const std::string up_to_date_status_;
const std::string update_needed_status_;
const std::string updating_status_;
public:
UpdateStatusManagerTest()
- : manager_(utils::MakeShared<UpdateStatusManager>())
+ : manager_(std::make_shared<UpdateStatusManager>())
, k_timeout_(1000)
, listener_()
+ , mock_ptu_retry_handler_()
, up_to_date_status_("UP_TO_DATE")
, update_needed_status_("UPDATE_NEEDED")
, updating_status_("UPDATING") {}
@@ -68,6 +71,8 @@ class UpdateStatusManagerTest : public ::testing::Test {
void SetUp() OVERRIDE {
manager_->set_listener(&listener_);
ON_CALL(listener_, OnUpdateStatusChanged(_)).WillByDefault(Return());
+ ON_CALL(listener_, ptu_retry_handler())
+ .WillByDefault(ReturnRef(mock_ptu_retry_handler_));
}
void TearDown() OVERRIDE {}
@@ -105,12 +110,17 @@ class WaitAsync {
const uint32_t timeout_;
sync_primitives::ConditionalVariable cond_var_;
};
-}
+} // namespace
ACTION_P(NotifyAsync, waiter) {
waiter->Notify();
}
+ACTION_P2(RetryFailed, manager, listener) {
+ manager->OnResetRetrySequence();
+ listener->OnPTUFinished(false);
+}
+
TEST_F(UpdateStatusManagerTest,
OnUpdateSentOut_WaitForTimeoutExpired_ExpectStatusUpdateNeeded) {
// Arrange
@@ -131,6 +141,38 @@ TEST_F(UpdateStatusManagerTest,
EXPECT_EQ(StatusUpdateRequired, status_);
}
+TEST_F(
+ UpdateStatusManagerTest,
+ OnUpdateSentOut_WaitForTimeoutExpired_ExpectStatusUpdateNeeded_RetryExceeded) {
+ sync_primitives::Lock lock;
+ sync_primitives::AutoLock auto_lock(lock);
+ const uint32_t count = 3u;
+ const uint32_t timeout = 2u * k_timeout_;
+ WaitAsync waiter(count, timeout);
+ EXPECT_CALL(listener_, OnUpdateStatusChanged(_))
+ .WillRepeatedly(NotifyAsync(&waiter));
+ EXPECT_CALL(mock_ptu_retry_handler_, RetrySequenceFailed())
+ .WillOnce(RetryFailed(manager_, &listener_));
+ manager_->ScheduleUpdate();
+ manager_->OnUpdateSentOut(k_timeout_);
+ status_ = manager_->GetLastUpdateStatus();
+ {
+ ::testing::InSequence s;
+ EXPECT_CALL(mock_ptu_retry_handler_, IsAllowedRetryCountExceeded())
+ .WillRepeatedly(Return(false));
+ EXPECT_CALL(mock_ptu_retry_handler_, IsAllowedRetryCountExceeded())
+ .WillRepeatedly(Return(false));
+ EXPECT_CALL(mock_ptu_retry_handler_, IsAllowedRetryCountExceeded())
+ .WillRepeatedly(Return(true));
+ EXPECT_CALL(listener_, OnPTUFinished(false));
+ }
+ EXPECT_EQ(StatusUpdatePending, status_);
+ EXPECT_TRUE(waiter.Wait(auto_lock));
+ status_ = manager_->GetLastUpdateStatus();
+ // Check
+ EXPECT_EQ(StatusUpdateRequired, status_);
+}
+
TEST_F(UpdateStatusManagerTest,
OnUpdateTimeOutOccurs_ExpectStatusUpdateNeeded) {
// Arrange
@@ -245,7 +287,7 @@ TEST_F(UpdateStatusManagerTest, OnResetRetrySequence_ExpectStatusUpToDate) {
manager_->OnResetRetrySequence();
status_ = manager_->GetLastUpdateStatus();
// Check
- EXPECT_EQ(StatusUpdatePending, status_);
+ EXPECT_EQ(StatusUpdateRequired, status_);
}
TEST_F(UpdateStatusManagerTest,
@@ -287,42 +329,6 @@ TEST_F(UpdateStatusManagerTest, ScheduleUpdate_ExpectStatusUpdateNeeded) {
}
TEST_F(UpdateStatusManagerTest,
- OnPolicyInit_SetUpdateRequired_ExpectStatusUpdateNeeded) {
- // Arrange
- manager_->OnPolicyInit(true);
- status_ = manager_->GetLastUpdateStatus();
- // Checks
- EXPECT_EQ(StatusUpdateRequired, status_);
- EXPECT_FALSE(manager_->IsUpdatePending());
- EXPECT_TRUE(manager_->IsUpdateRequired());
-}
-
-TEST_F(UpdateStatusManagerTest,
- OnPolicyInit_SetUpdateNotRequired_ExpectStatusUpToDate) {
- // Arrange
- manager_->OnPolicyInit(false);
- status_ = manager_->GetLastUpdateStatus();
- // Checks
- EXPECT_EQ(StatusUpToDate, status_);
- EXPECT_FALSE(manager_->IsUpdatePending());
- EXPECT_FALSE(manager_->IsUpdateRequired());
-}
-
-TEST_F(UpdateStatusManagerTest,
- StringifiedUpdateStatus_SetStatuses_ExpectCorrectStringifiedStatuses) {
- // Arrange
- manager_->OnPolicyInit(false);
- // Check
- EXPECT_EQ("UP_TO_DATE", manager_->StringifiedUpdateStatus());
- manager_->OnPolicyInit(true);
- // Check
- EXPECT_EQ("UPDATE_NEEDED", manager_->StringifiedUpdateStatus());
- manager_->OnUpdateSentOut(k_timeout_);
- // Check
- EXPECT_EQ("UPDATING", manager_->StringifiedUpdateStatus());
-}
-
-TEST_F(UpdateStatusManagerTest,
OnAppSearchStartedCompleted_ExpectAppSearchCorrectStatus) {
// Arrange
manager_->OnAppsSearchStarted();
@@ -334,6 +340,12 @@ TEST_F(UpdateStatusManagerTest,
EXPECT_FALSE(manager_->IsAppsSearchInProgress());
}
-} // namespace policy
+TEST_F(UpdateStatusManagerTest, OnAppRegistered) {
+ manager_->ScheduleUpdate();
+ ASSERT_EQ(policy::kUpdateNeeded, manager_->StringifiedUpdateStatus());
+ manager_->ProcessEvent(policy::UpdateEvent::kOnNewAppRegistered);
+ EXPECT_EQ(policy::kUpdateNeeded, manager_->StringifiedUpdateStatus());
+}
+} // namespace policy_test
} // namespace components
} // namespace test