From e912f736d4dd9d158e97275a923ba453f284ca15 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 5 Nov 2021 17:09:14 +0900 Subject: [PATCH 1/4] Update sdl0315_add_rpc_conflict_management --- src/appMain/sdl_preloaded_pt.json | 29 ++ src/appMain/smartDeviceLink.ini | 1 + .../application_manager_impl.h | 9 + .../application_manager/commands/command.h | 2 + .../commands/command_impl.h | 2 + .../commands/command_request_impl.h | 2 + .../application_manager/interrupt_manager.h | 86 +++++ .../policies/policy_handler.h | 4 + .../commands/mobile/alert_request.h | 2 + .../commands/mobile/dial_number_request.h | 2 + .../mobile/perform_audio_pass_thru_request.h | 2 + .../mobile/perform_interaction_request.h | 2 + .../mobile/scrollable_message_request.h | 2 + .../commands/mobile/slider_request.h | 2 + .../commands/mobile/speak_request.h | 2 + .../src/commands/mobile/alert_request.cc | 6 + .../commands/mobile/dial_number_request.cc | 6 + .../mobile/perform_audio_pass_thru_request.cc | 6 + .../mobile/perform_interaction_request.cc | 6 + .../mobile/scrollable_message_request.cc | 6 + .../src/commands/mobile/slider_request.cc | 6 + .../src/commands/mobile/speak_request.cc | 6 + .../src/application_manager_impl.cc | 7 +- .../src/commands/command_impl.cc | 2 + .../src/interrupt_manager.cc | 292 +++++++++++++++++ .../src/policies/policy_handler.cc | 22 ++ .../src/rpc_handler_impl.cc | 3 + .../src/rpc_service_impl.cc | 7 + .../application_manager/test/CMakeLists.txt | 1 + .../application_manager/mock_request.h | 2 + .../test/interrupt_manager_test.cc | 296 ++++++++++++++++++ .../test/sdl_pt_update.json | 25 ++ .../include/config_profile/profile.h | 5 + src/components/config_profile/src/profile.cc | 15 +- .../include/policy/cache_manager.h | 7 + .../include/policy/cache_manager_interface.h | 5 + .../include/policy/policy_manager_impl.h | 4 + .../include/policy/policy_table/types.h | 38 ++- .../include/policy/sql_pt_queries.h | 9 + .../include/policy/sql_pt_representation.h | 6 + .../policy_external/src/cache_manager.cc | 31 ++ .../src/policy_manager_impl.cc | 11 + .../policy_external/src/policy_table/types.cc | 114 ++++++- .../src/policy_table/validation.cc | 3 + .../policy_external/src/sql_pt_queries.cc | 49 +++ .../src/sql_pt_representation.cc | 135 ++++++++ .../sdl_preloaded_pt_for_merge_initial.json | 25 ++ .../sdl_preloaded_pt_for_merge_latest.json | 25 ++ .../include/policy/cache_manager.h | 7 + .../include/policy/cache_manager_interface.h | 4 + .../include/policy/policy_manager_impl.h | 4 + .../include/policy/policy_table/types.h | 37 ++- .../include/policy/sql_pt_queries.h | 9 + .../include/policy/sql_pt_representation.h | 7 + .../policy_regular/src/cache_manager.cc | 32 ++ .../policy_regular/src/policy_manager_impl.cc | 11 + .../policy_regular/src/policy_table/types.cc | 115 ++++++- .../src/policy_table/validation.cc | 4 + .../policy_regular/src/sql_pt_queries.cc | 85 +++++ .../src/sql_pt_representation.cc | 130 ++++++++ .../sdl_preloaded_pt_for_merge_initial.json | 25 ++ .../sdl_preloaded_pt_for_merge_latest.json | 25 ++ .../test/sql_pt_representation_test.cc | 4 +- 63 files changed, 1817 insertions(+), 12 deletions(-) create mode 100644 src/components/application_manager/include/application_manager/interrupt_manager.h create mode 100644 src/components/application_manager/src/interrupt_manager.cc create mode 100644 src/components/application_manager/test/interrupt_manager_test.cc diff --git a/src/appMain/sdl_preloaded_pt.json b/src/appMain/sdl_preloaded_pt.json index 4887405909e..3429e31b242 100644 --- a/src/appMain/sdl_preloaded_pt.json +++ b/src/appMain/sdl_preloaded_pt.json @@ -4613,6 +4613,35 @@ "since": "7.1" } ] + }, + "interrupt_manager_config": + { + "rpc_priority": + { + "DialNumber": 1, + "Alert": 2, + "PerformAudioPassThru": 2, + "PerformInteraction": 3, + "ScrollableMessage": 3, + "Slider": 3, + "Speak": 3 + }, + "app_priority": + { + "EMERGENCY": 0, + "NAVIGATION": 1, + "VOICE_COMMUNICATION": 2, + "COMMUNICATION": 3, + "NORMAL": 4, + "NONE": 5 + }, + "hmi_status_priority": + { + "FULL": 1, + "LIMITED": 2, + "BACKGROUND": 3, + "NONE": 4 + } } } } diff --git a/src/appMain/smartDeviceLink.ini b/src/appMain/smartDeviceLink.ini index 56822db0ef2..c921f3d2a0c 100644 --- a/src/appMain/smartDeviceLink.ini +++ b/src/appMain/smartDeviceLink.ini @@ -201,6 +201,7 @@ AttemptsToOpenPolicyDB = 5 OpenAttemptTimeoutMs = 500 ; Whether to use the fullAppID over the short-form appID in policy lookups UseFullAppID = true +EnableRPCConflictManager = false [TransportManager] ; Listening port form incoming TCP mobile connection diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index c59456a0225..2355e9d5e55 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -80,6 +80,8 @@ #include "interfaces/v4_protocol_v1_2_no_extra.h" #include "interfaces/v4_protocol_v1_2_no_extra_schema.h" +#include "application_manager/interrupt_manager.h" + #ifdef ENABLE_SECURITY #include "security_manager/security_manager_listener.h" #include "security_manager/ssl_context.h" @@ -1017,6 +1019,11 @@ class ApplicationManagerImpl return *request_ctrl_; } + interrupt_manager::InterruptManager& GetInterruptManager() const OVERRIDE{ + return *interrupt_manager_; + } + + void SetRPCService(std::unique_ptr& rpc_service) { rpc_service_ = std::move(rpc_service); } @@ -1748,6 +1755,8 @@ class ApplicationManagerImpl mutable sync_primitives::Lock expired_button_requests_lock_; mutable ExpiredButtonRequestsMap expired_button_requests_; + + std::unique_ptrinterrupt_manager_; #ifdef BUILD_TESTS public: diff --git a/src/components/application_manager/include/application_manager/commands/command.h b/src/components/application_manager/include/application_manager/commands/command.h index f8bc66df2a3..473ee2b68a2 100644 --- a/src/components/application_manager/include/application_manager/commands/command.h +++ b/src/components/application_manager/include/application_manager/commands/command.h @@ -137,6 +137,8 @@ class Command { */ virtual void SetAllowedToTerminate(const bool allowed) = 0; + virtual void Reject() = 0; + enum CommandSource { SOURCE_SDL, SOURCE_MOBILE, diff --git a/src/components/application_manager/include/application_manager/commands/command_impl.h b/src/components/application_manager/include/application_manager/commands/command_impl.h index 534f07aa37a..c1e37e25ab7 100644 --- a/src/components/application_manager/include/application_manager/commands/command_impl.h +++ b/src/components/application_manager/include/application_manager/commands/command_impl.h @@ -212,6 +212,8 @@ class CommandImpl : public Command { bool IsHMIResultSuccess(hmi_apis::Common_Result::eType result_code, HmiInterfaces::InterfaceID interface) const; + void Reject() OVERRIDE; + // members static const int32_t hmi_protocol_type_; static const int32_t mobile_protocol_type_; diff --git a/src/components/application_manager/include/application_manager/commands/command_request_impl.h b/src/components/application_manager/include/application_manager/commands/command_request_impl.h index 97e2dce0eb3..00042e9bd5a 100644 --- a/src/components/application_manager/include/application_manager/commands/command_request_impl.h +++ b/src/components/application_manager/include/application_manager/commands/command_request_impl.h @@ -132,6 +132,8 @@ class CommandRequestImpl : public CommandImpl, bool DecrementReferenceCount() const OVERRIDE; + void Reject() OVERRIDE; + protected: /** * @brief Checks message permissions and parameters according to policy table diff --git a/src/components/application_manager/include/application_manager/interrupt_manager.h b/src/components/application_manager/include/application_manager/interrupt_manager.h new file mode 100644 index 00000000000..9644ecb968a --- /dev/null +++ b/src/components/application_manager/include/application_manager/interrupt_manager.h @@ -0,0 +1,86 @@ +/* +InterruptManager header file (under construction) + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_INTERRUPT_MANAGER_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_INTERRUPT_MANAGER_H + +#include "application_manager/rpc_handler_impl.h" +#include "config_profile/profile.h" +#include "application_manager/application_manager.h" +#include "utils/logger.h" + +namespace application_manager { + +namespace interrupt_manager { + +enum IMStatus +{ + IM_DEACTIVATE = 0, + IM_ACTIVATE, + IM_ACTIVATE_DEFAULT +}; + +enum InterruptCheckResult +{ + NO_INTERRUPT = 0, + REJECT_ONS_IN_QUEUE, + REJECT_RECEIVED_ONS, + INTERRUPT_ERROR, +}; + +class InterruptManager +{ +public: + InterruptManager(); + InterruptManager(ApplicationManager& app_manager, const policy::PolicySettings& policy_settings); + ~InterruptManager(); + + void Init(); + + InterruptCheckResult CheckRpcInterrupt(const std::shared_ptr outgoing_message); + bool DoRpcReject(mobile_apis::FunctionID::eType function_id); + IMStatus GetRunningStatus(); + bool ReadInterruptSetting(); + bool IsSubjectMessageToPrioritized(std::shared_ptr outgoing_message); + std::shared_ptr highest_priority_ons_rpc_; + std::list reject_rpc_list_; + std::string appPriority; + std::string firstAppPriority; + std::string app_hmi_level; + std::string first_app_hmi_level; + ns_smart_device_link::ns_smart_objects::SmartObject message_; + ns_smart_device_link::ns_smart_objects::SmartObject first_message_; + int32_t app_id; + int32_t first_app_id; + ApplicationSharedPtr app; + ApplicationSharedPtr first_app; + int32_t function_id; + int32_t first_function_id; + + std::string function_name; + std::string first_function_name; + + // Priority Table + rpc::policy_table_interface_base::rpc_priority_type rpc_priority_table_; + rpc::policy_table_interface_base::app_priority_type apptype_priority_table_; + rpc::policy_table_interface_base::hmi_status_priority_type hmists_priority_table_; + +private: + InterruptCheckResult CheckRpcPriority(const std::shared_ptr outgoing_message); + InterruptCheckResult CheckAppTypePriority(const std::shared_ptr outgoing_message); + InterruptCheckResult CheckHmiStatusPriority(const std::shared_ptr outgoing_message); + bool ReadRpcPriorityTable(); + bool ReadAppTypePriorityTable(); + bool ReadHmiStatusPriorityTable(); + +private: + IMStatus im_status_; + ApplicationManager& app_manager_; + const policy::PolicySettings& policy_settings_; +}; + +} // namespace interrupt_manager +} // namespace application_manager +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_INTERRUPT_MANAGER_H + diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h index 662e2558718..8e65798e6e5 100644 --- a/src/components/application_manager/include/application_manager/policies/policy_handler.h +++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h @@ -684,6 +684,10 @@ class PolicyHandler : public PolicyHandlerInterface, const std::vector GetAppRequestSubTypes( const std::string& policy_app_id) const OVERRIDE; + virtual rpc::policy_table_interface_base::rpc_priority_type GetRpcPriority() const OVERRIDE; + virtual rpc::policy_table_interface_base::app_priority_type GetAppPriority() const OVERRIDE; + virtual rpc::policy_table_interface_base::hmi_status_priority_type GetHmiStatusPriority() const OVERRIDE; + #ifdef EXTERNAL_PROPRIETARY_MODE /** * @brief Gets meta information diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_request.h index 5352148289d..dfbf693a144 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_request.h @@ -80,6 +80,8 @@ class AlertRequest : public app_mngr::commands::RequestFromMobileImpl { void OnTimeOut() FINAL; + void Reject(); + protected: private: /* diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/dial_number_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/dial_number_request.h index b7865122aad..833f820ba5b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/dial_number_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/dial_number_request.h @@ -77,6 +77,8 @@ class DialNumberRequest : public app_mngr::commands::RequestFromMobileImpl { */ void on_event(const app_mngr::event_engine::Event& event); + void Reject(); + private: /** * @brief Removes from number param all characters diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_request.h index da8f13c5d7a..bcf4d0c36e1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_request.h @@ -85,6 +85,8 @@ class PerformAudioPassThruRequest */ void OnTimeOut() FINAL; + void Reject(); + private: /** * @brief Prepare result code, result and info for sending to mobile diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h index 8652464fbaf..dbadd7d58a7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h @@ -84,6 +84,8 @@ class PerformInteractionRequest void OnTimeOut() FINAL; + void Reject(); + protected: /** * @brief Prepare result code for sending to mobile application diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/scrollable_message_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/scrollable_message_request.h index fc7b8e0207e..2677a0964a1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/scrollable_message_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/scrollable_message_request.h @@ -80,6 +80,8 @@ class ScrollableMessageRequest */ void on_event(const app_mngr::event_engine::Event& event) OVERRIDE; + void Reject(); + private: DISALLOW_COPY_AND_ASSIGN(ScrollableMessageRequest); }; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/slider_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/slider_request.h index f9cf401c7ca..b9473315009 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/slider_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/slider_request.h @@ -78,6 +78,8 @@ class SliderRequest : public app_mngr::commands::RequestFromMobileImpl { */ void on_event(const app_mngr::event_engine::Event& event) OVERRIDE; + void Reject(); + private: /** * @brief Checks slider params(sliderHeader, sliderFooter, ...). diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/speak_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/speak_request.h index f753c029900..ee84574c2e3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/speak_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/speak_request.h @@ -73,6 +73,8 @@ class SpeakRequest : public app_mngr::commands::RequestFromMobileImpl { */ void on_event(const app_mngr::event_engine::Event& event) OVERRIDE; + void Reject(); + private: /* * @brief Sends Speak response to mobile side diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_request.cc index aab2c8c486c..824e5097276 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_request.cc @@ -461,6 +461,12 @@ bool AlertRequest::IsPendingResponseExist() { awaiting_tts_stop_speaking_response_; } +void AlertRequest::Reject(){ + SDL_LOG_INFO("Interrupt Rejected"); + SendResponse(false, mobile_apis::Result::REJECTED); + return; +} + } // namespace commands } // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/dial_number_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/dial_number_request.cc index c14eb02daeb..bc177b4f4ff 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/dial_number_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/dial_number_request.cc @@ -152,6 +152,12 @@ void DialNumberRequest::StripNumberParam(std::string& number) { (*message_)[strings::msg_params][strings::number] = number; } +void DialNumberRequest::Reject(){ + SDL_LOG_INFO("Interrupt Rejected"); + SendResponse(false, mobile_apis::Result::REJECTED); + return; +} + } // namespace commands } // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_request.cc index a690c0bc9b4..d8ccc2dc061 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_request.cc @@ -441,6 +441,12 @@ bool PerformAudioPassThruRequest::IsWaitingHMIResponse() { IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_UI); } +void PerformAudioPassThruRequest::Reject(){ + SDL_LOG_INFO("Interrupt Rejected"); + SendResponse(false, mobile_apis::Result::REJECTED); + return; +} + } // namespace commands } // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc index bf0f05ba323..247cdc21444 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc @@ -1121,5 +1121,11 @@ bool PerformInteractionRequest::SetChoiceIdToResponseMsgParams( return true; } +void PerformInteractionRequest::Reject(){ + SDL_LOG_ERROR("Interrupt Rejected"); + SendResponse(false, mobile_apis::Result::REJECTED); + return; +} + } // namespace commands } // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/scrollable_message_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/scrollable_message_request.cc index 573c3402012..04da9d554cd 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/scrollable_message_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/scrollable_message_request.cc @@ -155,5 +155,11 @@ void ScrollableMessageRequest::on_event(const event_engine::Event& event) { } } +void ScrollableMessageRequest::Reject(){ + SDL_LOG_INFO("Interrupt Rejected"); + SendResponse(false, mobile_apis::Result::REJECTED); + return; +} + } // namespace commands } // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_request.cc index fb332970abf..b37a9614394 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_request.cc @@ -183,5 +183,11 @@ bool SliderRequest::IsWhiteSpaceExist() { return false; } +void SliderRequest::Reject() { + SDL_LOG_INFO("Interrupt Rejected"); + SendResponse(false, mobile_apis::Result::REJECTED); + return; +} + } // namespace commands } // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/speak_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/speak_request.cc index 593faf795ee..62a33962fc3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/speak_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/speak_request.cc @@ -173,6 +173,12 @@ bool SpeakRequest::IsWhiteSpaceExist() { return false; } +void SpeakRequest::Reject(){ + SDL_LOG_INFO("Interrupt Rejected"); + SendResponse(false, mobile_apis::Result::REJECTED); + return; +} + } // namespace commands } // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 7a5d5fc0dc8..9e37ffb43f7 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -79,6 +79,8 @@ #include "utils/threads/thread.h" #include "utils/timer_task_impl.h" +#include "application_manager/interrupt_manager.h" + namespace { int get_rand_from_range(uint32_t from = 0, int to = RAND_MAX) { return std::rand() % to + from; @@ -227,6 +229,7 @@ ApplicationManagerImpl::ApplicationManagerImpl( rpc_protection_manager, hmi_so_factory(), mobile_so_factory())); + interrupt_manager_.reset(new interrupt_manager::InterruptManager(*this, policy_settings)); } ApplicationManagerImpl::~ApplicationManagerImpl() { @@ -240,7 +243,7 @@ ApplicationManagerImpl::~ApplicationManagerImpl() { protocol_handler_ = NULL; SDL_LOG_DEBUG("Destroying Policy Handler"); RemovePolicyObserver(this); - + interrupt_manager_ = NULL; { sync_primitives::AutoLock lock(navi_app_to_stop_lock_); navi_app_to_stop_.clear(); @@ -2644,6 +2647,8 @@ bool ApplicationManagerImpl::Init( plugin_manager_->ForEachPlugin(on_app_policy_updated); + interrupt_manager_->Init(); + return true; } diff --git a/src/components/application_manager/src/commands/command_impl.cc b/src/components/application_manager/src/commands/command_impl.cc index 8eb7171274c..7064ffdfc30 100644 --- a/src/components/application_manager/src/commands/command_impl.cc +++ b/src/components/application_manager/src/commands/command_impl.cc @@ -128,6 +128,8 @@ void CommandImpl::Run() {} void CommandImpl::OnUpdateTimeOut() {} +void CommandImpl::Reject() {} + uint32_t CommandImpl::default_timeout() const { return default_timeout_; } diff --git a/src/components/application_manager/src/interrupt_manager.cc b/src/components/application_manager/src/interrupt_manager.cc new file mode 100644 index 00000000000..ac2a1baa430 --- /dev/null +++ b/src/components/application_manager/src/interrupt_manager.cc @@ -0,0 +1,292 @@ +#include "application_manager/interrupt_manager.h" + +#include "application_manager/rpc_handler_impl.h" +#include "config_profile/profile.h" +#include "utils/logger.h" + +SDL_CREATE_LOG_VARIABLE("InterruptManager") +namespace application_manager { +namespace interrupt_manager { +InterruptManager::InterruptManager( + ApplicationManager& app_manager, + const policy::PolicySettings& policy_settings) + : app_manager_(app_manager), policy_settings_(policy_settings) { + SDL_LOG_AUTO_TRACE(); + highest_priority_ons_rpc_ = 0; + reject_rpc_list_.clear(); +} + +InterruptManager::~InterruptManager() { + SDL_LOG_AUTO_TRACE(); +} + +void InterruptManager::Init() { + ReadRpcPriorityTable(); + ReadAppTypePriorityTable(); + ReadHmiStatusPriorityTable(); + ReadInterruptSetting(); +} + +IMStatus InterruptManager::GetRunningStatus() { + SDL_LOG_AUTO_TRACE(); + return im_status_; +} + +InterruptCheckResult InterruptManager::CheckRpcInterrupt( + const std::shared_ptr outgoing_message) { + SDL_LOG_AUTO_TRACE(); + InterruptCheckResult check_result = NO_INTERRUPT; + if (IsSubjectMessageToPrioritized(outgoing_message)) { + if (highest_priority_ons_rpc_) { + SDL_LOG_INFO("check start"); + SDL_LOG_INFO("highest_priority_ons_rpc_" << highest_priority_ons_rpc_->function_id()); + namespace formatters = ns_smart_device_link::ns_json_handler::formatters; + formatters::FormatterJsonRpc::FromString(outgoing_message->json_message(), message_); + + int32_t connection_key = outgoing_message->connection_key(); + SDL_LOG_INFO("connection_key " << connection_key); + + app_id = (message_)[strings::msg_params][strings::app_id].asInt(); + SDL_LOG_INFO("app_id " << app_id); + app = app_manager_.application(connection_key); + + std::string policy_app_id = app->policy_app_id(); + SDL_LOG_INFO("policy_app_id " << policy_app_id); + + policy::PolicyHandlerInterface& policy_handler_ = app_manager_.GetPolicyHandler(); + SDL_LOG_INFO("get policy_handler_"); + + policy_handler_.GetPriority(policy_app_id, &appPriority); + SDL_LOG_INFO("get appPriority " << appPriority); + + formatters::FormatterJsonRpc::FromString(highest_priority_ons_rpc_->json_message(), first_message_); + first_app_id = (first_message_)[strings::params][strings::connection_key].asInt(); + + int32_t first_connection_key = highest_priority_ons_rpc_->connection_key(); + SDL_LOG_INFO("first_connection_key " << first_connection_key); + first_app = app_manager_.application(first_connection_key); + app_manager_.GetPolicyHandler().GetPriority(first_app->policy_app_id(), &firstAppPriority); + SDL_LOG_INFO("get firstAppPriority " << firstAppPriority); + + if ((appPriority == "EMERGENCY" && firstAppPriority == "EMERGENCY") || + (appPriority != "EMERGENCY" && firstAppPriority != "EMERGENCY")) { + check_result = CheckRpcPriority(outgoing_message); + } else if (firstAppPriority == "EMERGENCY") { + SDL_LOG_INFO("reject receved ons"); + reject_rpc_list_.push_front(outgoing_message->function_id()); + check_result = REJECT_RECEIVED_ONS; + } else { + SDL_LOG_INFO("reject in queue"); + reject_rpc_list_.push_front(outgoing_message->function_id()); + check_result = REJECT_ONS_IN_QUEUE; + } + } else { + SDL_LOG_INFO("no thread message"); + highest_priority_ons_rpc_ = outgoing_message; + check_result = NO_INTERRUPT; + } + } else { + SDL_LOG_INFO("not subjectMessage"); + check_result = NO_INTERRUPT; + } + SDL_LOG_INFO("check_result" << check_result); + return check_result; +} + +bool InterruptManager::DoRpcReject(mobile_apis::FunctionID::eType function_id) { + SDL_LOG_AUTO_TRACE(); + SDL_LOG_INFO("function_id" << function_id); + SDL_LOG_INFO("reject_rpc_list_" << reject_rpc_list_.front()); + auto reject_itr = + find(reject_rpc_list_.begin(), reject_rpc_list_.end(), function_id); + if (reject_itr != reject_rpc_list_.end()) { + SDL_LOG_INFO("reject start"); + reject_rpc_list_.erase(reject_itr); + SDL_LOG_INFO("reject_rpc_list_" << reject_rpc_list_.front()); + + highest_priority_ons_rpc_ = 0; + return true; + } + SDL_LOG_INFO("no rejecte message"); + return false; +} + +bool InterruptManager::IsSubjectMessageToPrioritized( + const std::shared_ptr outgoing_message) { + SDL_LOG_AUTO_TRACE(); + function_id = outgoing_message->function_id(); + SDL_LOG_INFO("outgoing_message function_id " << function_id); + + function_name = MessageHelper::StringifiedFunctionID( + static_cast(function_id)); + SDL_LOG_INFO("outgoing_message function_name " << function_name); + + if (rpc_priority_table_.find(function_name) != rpc_priority_table_.end() || + function_id == mobile_apis::FunctionID::SubtleAlertID) { + if (outgoing_message->type() == kRequest) { + SDL_LOG_INFO("subjectMessage"); + return true; + } else { + SDL_LOG_INFO("Message is not request"); + return false; + } + } else { + return false; + } +} + +InterruptCheckResult InterruptManager::CheckRpcPriority( + const std::shared_ptr outgoing_message) { + SDL_LOG_AUTO_TRACE(); + InterruptCheckResult check_result = NO_INTERRUPT; + + function_id = outgoing_message->function_id(); + function_name = MessageHelper::StringifiedFunctionID( + static_cast(function_id)); + + first_function_id = highest_priority_ons_rpc_->function_id(); + first_function_name = MessageHelper::StringifiedFunctionID( + static_cast(first_function_id)); + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + if (function_name == "SubtleAlert") { + if ((message_)[strings::msg_params].keyExists(strings::alert_text1) || + (message_)[strings::msg_params].keyExists(strings::alert_text1)) { + function_name = "Alert"; + } else { + function_name = "Speak"; + } + } + + if (first_function_name == "SubtleAlert") { + if ((first_message_)[strings::msg_params].keyExists(strings::alert_text1) || + (first_message_)[strings::msg_params].keyExists(strings::alert_text1)) { + first_function_name = "Alert"; + } else { + first_function_name = "Speak"; + } + } + + SDL_LOG_INFO("rpc check start"); + SDL_LOG_INFO("check" << function_name << first_function_name); + if (rpc_priority_table_[function_name] > + rpc_priority_table_[first_function_name]) { + reject_rpc_list_.push_front(outgoing_message->function_id()); + check_result = REJECT_RECEIVED_ONS; + SDL_LOG_INFO("reject received message"); + SDL_LOG_INFO("reject message" << outgoing_message->function_id()); + SDL_LOG_INFO("reject list" << reject_rpc_list_.front()); + + } else if (rpc_priority_table_[function_name] < + rpc_priority_table_[first_function_name]) { + SDL_LOG_INFO("reject queue message"); + SDL_LOG_INFO("reject message" << highest_priority_ons_rpc_->function_id()); + reject_rpc_list_.push_front(highest_priority_ons_rpc_->function_id()); + check_result = REJECT_ONS_IN_QUEUE; + SDL_LOG_INFO("reject list" << reject_rpc_list_.front()); + } else if (rpc_priority_table_[function_name] == + rpc_priority_table_[first_function_name]) { + check_result = CheckAppTypePriority(outgoing_message); + } else { + check_result = INTERRUPT_ERROR; + } + return check_result; +} + +InterruptCheckResult InterruptManager::CheckAppTypePriority( + const std::shared_ptr outgoing_message) { + SDL_LOG_AUTO_TRACE(); + InterruptCheckResult check_result = NO_INTERRUPT; + if (apptype_priority_table_[appPriority] > + apptype_priority_table_[firstAppPriority]) { + reject_rpc_list_.push_front(outgoing_message->function_id()); + check_result = REJECT_RECEIVED_ONS; + } else if (apptype_priority_table_[appPriority] < + apptype_priority_table_[firstAppPriority]) { + reject_rpc_list_.push_front(highest_priority_ons_rpc_->function_id()); + check_result = REJECT_ONS_IN_QUEUE; + } else if (apptype_priority_table_[appPriority] == + apptype_priority_table_[firstAppPriority]) { + check_result = CheckHmiStatusPriority(outgoing_message); + } else { + check_result = INTERRUPT_ERROR; + } + return check_result; +} + +InterruptCheckResult InterruptManager::CheckHmiStatusPriority( + const std::shared_ptr outgoing_message) { + SDL_LOG_AUTO_TRACE(); + InterruptCheckResult check_result = NO_INTERRUPT; + + app_hmi_level = + app->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW); + first_app_hmi_level = + first_app->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW); + + if (hmists_priority_table_[app_hmi_level] > + hmists_priority_table_[first_app_hmi_level]) { + reject_rpc_list_.push_front(outgoing_message->function_id()); + check_result = REJECT_RECEIVED_ONS; + } else if ((hmists_priority_table_[app_hmi_level] < + hmists_priority_table_[first_app_hmi_level]) || + (hmists_priority_table_[app_hmi_level] == + hmists_priority_table_[first_app_hmi_level])) { + + reject_rpc_list_.push_front(highest_priority_ons_rpc_->function_id()); + check_result = REJECT_ONS_IN_QUEUE; + } else { + check_result = INTERRUPT_ERROR; + } + return check_result; +} + +bool InterruptManager::ReadRpcPriorityTable() { + SDL_LOG_AUTO_TRACE(); + rpc_priority_table_ = app_manager_.GetPolicyHandler().GetRpcPriority(); + if (rpc_priority_table_.size() == 0) { + SDL_LOG_ERROR("Table read failed"); + return false; + } + return true; +} + +bool InterruptManager::ReadAppTypePriorityTable() { + SDL_LOG_AUTO_TRACE(); + apptype_priority_table_ = app_manager_.GetPolicyHandler().GetAppPriority(); + if (apptype_priority_table_.size() == 0) { + SDL_LOG_ERROR("Table read failed"); + return false; + } + return true; +} + +bool InterruptManager::ReadHmiStatusPriorityTable() { + SDL_LOG_AUTO_TRACE(); + hmists_priority_table_ = + app_manager_.GetPolicyHandler().GetHmiStatusPriority(); + if (hmists_priority_table_.size() == 0) { + SDL_LOG_ERROR("Table read failed"); + return false; + } + return true; +} + +bool InterruptManager::ReadInterruptSetting() { + SDL_LOG_AUTO_TRACE(); + if (policy_settings_.enable_rpc_conflict_manager()) { + SDL_LOG_INFO("IM_ACTIVATE"); + im_status_ = IM_ACTIVATE; + return true; + } + SDL_LOG_INFO("IM_DEACTIVATE"); + im_status_ = IM_DEACTIVATE; + return false; +} + +} // namespace interrupt_manager +} // namespace application_manager diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 500981a5a81..a7fcfbea1ba 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -2984,4 +2984,26 @@ void PolicyHandler::OnUpdateHMILevel(const std::string& device_id, } UpdateHMILevel(app, level); } + +rpc::policy_table_interface_base::rpc_priority_type PolicyHandler::GetRpcPriority() const { + SDL_LOG_AUTO_TRACE(); + const auto policy_manager = LoadPolicyManager(); + POLICY_LIB_CHECK_OR_RETURN(policy_manager, rpc::policy_table_interface_base::rpc_priority_type()); + return policy_manager->GetRpcPriority(); +} + +rpc::policy_table_interface_base::app_priority_type PolicyHandler::GetAppPriority() const { + SDL_LOG_AUTO_TRACE(); + const auto policy_manager = LoadPolicyManager(); + POLICY_LIB_CHECK_OR_RETURN(policy_manager, rpc::policy_table_interface_base::app_priority_type()); + return policy_manager->GetAppPriority(); +} + +rpc::policy_table_interface_base::hmi_status_priority_type PolicyHandler::GetHmiStatusPriority() const { + SDL_LOG_AUTO_TRACE(); + const auto policy_manager = LoadPolicyManager(); + POLICY_LIB_CHECK_OR_RETURN(policy_manager, rpc::policy_table_interface_base::hmi_status_priority_type()); + return policy_manager->GetHmiStatusPriority(); +} + } // namespace policy diff --git a/src/components/application_manager/src/rpc_handler_impl.cc b/src/components/application_manager/src/rpc_handler_impl.cc index b6b9f2e16b9..2d40977433d 100644 --- a/src/components/application_manager/src/rpc_handler_impl.cc +++ b/src/components/application_manager/src/rpc_handler_impl.cc @@ -257,6 +257,9 @@ void RPCHandlerImpl::OnMessageReceived( std::shared_ptr outgoing_message = ConvertRawMsgToMessage(message); if (outgoing_message) { + if(app_manager_.GetInterruptManager().GetRunningStatus() == application_manager::interrupt_manager::IM_ACTIVATE){ + app_manager_.GetInterruptManager().CheckRpcInterrupt(outgoing_message); + } SDL_LOG_DEBUG("Posting new Message"); messages_from_mobile_.PostMessage( impl::MessageFromMobile(outgoing_message)); diff --git a/src/components/application_manager/src/rpc_service_impl.cc b/src/components/application_manager/src/rpc_service_impl.cc index 36dcb335c1a..634e4ad413c 100644 --- a/src/components/application_manager/src/rpc_service_impl.cc +++ b/src/components/application_manager/src/rpc_service_impl.cc @@ -220,6 +220,13 @@ bool RPCServiceImpl::ManageMobileCommand( return false; } + if (app_manager_.GetInterruptManager().DoRpcReject(function_id)) { + SDL_LOG_INFO("Rejected_by_InterruptManager"); + command->Reject(); + command->CleanUp(); + return false; + } + if (message_type == mobile_apis::messageType::response) { if (command->Init() && command->CheckPermissions()) { command->Run(); diff --git a/src/components/application_manager/test/CMakeLists.txt b/src/components/application_manager/test/CMakeLists.txt index 596d11cfa98..bee5646cf3c 100755 --- a/src/components/application_manager/test/CMakeLists.txt +++ b/src/components/application_manager/test/CMakeLists.txt @@ -73,6 +73,7 @@ set(testSources ${AM_TEST_DIR}/rpc_service_impl_test.cc ${AM_TEST_DIR}/command_holder_test.cc ${AM_TEST_DIR}/request_timeout_handler_test.cc + ${AM_TEST_DIR}/interrupt_manager_test.cc ) set(testSourcesMockHmi diff --git a/src/components/application_manager/test/include/application_manager/mock_request.h b/src/components/application_manager/test/include/application_manager/mock_request.h index 4348e39020c..b8a5adeddfe 100644 --- a/src/components/application_manager/test/include/application_manager/mock_request.h +++ b/src/components/application_manager/test/include/application_manager/mock_request.h @@ -65,6 +65,8 @@ class MockRequest : public application_manager::commands::Command { MOCK_CONST_METHOD0(connection_key, uint32_t()); MOCK_CONST_METHOD0(correlation_id, uint32_t()); + + MOCK_METHOD0(Reject, void()); }; } // namespace application_manager_test diff --git a/src/components/application_manager/test/interrupt_manager_test.cc b/src/components/application_manager/test/interrupt_manager_test.cc new file mode 100644 index 00000000000..eac6087c881 --- /dev/null +++ b/src/components/application_manager/test/interrupt_manager_test.cc @@ -0,0 +1,296 @@ +/* + * 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. + *Ubuntu 20.04.3 LTS + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "application_manager/interrupt_manager.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "policy/mock_policy_settings.h" +#include "application_manager/mock_rpc_service.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_message_helper.h" + + +namespace test { +namespace components { +namespace application_manager_test { + +using ::test::components::application_manager_test::MockApplicationManager; +using test::components::policy_test::MockPolicyHandlerInterface; +using ::testing::_; +using ::testing::Mock; +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::ReturnRef; +using ::testing::SetArgPointee; +using namespace application_manager; +using namespace application_manager::interrupt_manager; +using namespace policy_handler_test; +typedef smart_objects::SmartObjectSPtr MessageSharedPtr; + +class InterruptManagerTest : public ::testing::Test { + public: + typedef NiceMock MockRPCService; + + InterruptManagerTest() + : interrupt_manager_(new InterruptManager(mock_app_mngr_, mock_policy_settings_)) + , kPolicyAppId_("fake_app_id") + , priority_1("fake_priority") + , mock_app_ptr_(std::make_shared >()) + , mock_message_helper_(*application_manager::MockMessageHelper::message_helper_mock()){ + } + application_manager::MobileMessage CreateMessage() { + return std::make_shared( + protocol_handler::MessagePriority::FromServiceType(protocol_handler::ServiceType::kRpc)); + } + + protected: + void SetUp() OVERRIDE { + + DefaultRpcPriority = {}; + std::string rpcPriority[] = {"DialNumber","Alert","PerformAudioPassThru","PerformInteraction","ScrollableMessage","Slider","Speak"}; + DefaultRpcPriority[rpcPriority[0]] = 1; + DefaultRpcPriority[rpcPriority[1]] = 2; + DefaultRpcPriority[rpcPriority[2]] = 2; + DefaultRpcPriority[rpcPriority[3]] = 3; + DefaultRpcPriority[rpcPriority[4]] = 3; + DefaultRpcPriority[rpcPriority[5]] = 3; + DefaultRpcPriority[rpcPriority[6]] = 3; + + DefaultAppPriority = {}; + std::string appPriority[] = {"EMERGENCY","NAVIGATION","VOICE_COMMUNICATION","COMMUNICATION","NORMAL","NONE"}; + DefaultAppPriority[appPriority[0]] = 0; + DefaultAppPriority[appPriority[1]] = 1; + DefaultAppPriority[appPriority[2]] = 2; + DefaultAppPriority[appPriority[3]] = 3; + DefaultAppPriority[appPriority[4]] = 4; + DefaultAppPriority[appPriority[5]] = 5; + + DefaultHmiStatusPriority = {}; + std::string hmiStatusPriority[] = {"FULL", "LIMITED", "BACKGROUND", "NONE"}; + DefaultHmiStatusPriority[hmiStatusPriority[0]] = 1; + DefaultHmiStatusPriority[hmiStatusPriority[1]] = 2; + DefaultHmiStatusPriority[hmiStatusPriority[2]] = 3; + DefaultHmiStatusPriority[hmiStatusPriority[3]] = 4; + + ON_CALL(mock_app_mngr_, GetPolicyHandler()) + .WillByDefault(ReturnRef(mock_policy_handler_)); + ON_CALL(mock_policy_handler_, GetRpcPriority()) + .WillByDefault(Return(DefaultRpcPriority)); + ON_CALL(mock_policy_handler_, GetAppPriority()) + .WillByDefault(Return(DefaultAppPriority)); + ON_CALL(mock_policy_handler_, GetHmiStatusPriority()) + .WillByDefault(Return(DefaultHmiStatusPriority)); + + ON_CALL(mock_app_mngr_, application(_)) + .WillByDefault(Return(mock_app_ptr_)); + + ON_CALL(*mock_app_ptr_, hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) + .WillByDefault(Return(mobile_apis::HMILevel::HMI_NONE)); + + ON_CALL(mock_message_helper_, StringifiedFunctionID(mobile_apis::FunctionID::DialNumberID)) + .WillByDefault(Return("DialNumber")); + + ON_CALL(mock_message_helper_, StringifiedFunctionID(mobile_apis::FunctionID::SubtleAlertID)) + .WillByDefault(Return("SubtleAlert")); + + ON_CALL(mock_message_helper_, StringifiedFunctionID(mobile_apis::FunctionID::AlertID)) + .WillByDefault(Return("Alert")); + + interrupt_manager_->rpc_priority_table_ = DefaultRpcPriority; + interrupt_manager_->apptype_priority_table_ = DefaultAppPriority; + interrupt_manager_->hmists_priority_table_ = DefaultHmiStatusPriority; + + } + MockRPCService mock_rpc_service_; + std::unique_ptr interrupt_manager_; + profile::Profile profile_; + NiceMock mock_policy_settings_; + NiceMock mock_app_mngr_; + NiceMock mock_policy_handler_; + const std::string kPolicyAppId_; + std::string priority_1; + std::string priority_2; + rpc::policy_table_interface_base::rpc_priority_type DefaultRpcPriority; + rpc::policy_table_interface_base::app_priority_type DefaultAppPriority; + rpc::policy_table_interface_base::hmi_status_priority_type DefaultHmiStatusPriority; + std::shared_ptr > mock_app_ptr_; + MockMessageHelper& mock_message_helper_; +}; + +TEST_F(InterruptManagerTest, ReadInterruptSetting_TRUE) { + EXPECT_CALL(mock_policy_settings_, enable_rpc_conflict_manager()) + .WillRepeatedly(Return(true)); + + EXPECT_TRUE(interrupt_manager_->ReadInterruptSetting()); +} + +TEST_F(InterruptManagerTest, ReadInterruptSetting_FALSE) { + EXPECT_CALL(mock_policy_settings_, enable_rpc_conflict_manager()) + .WillRepeatedly(Return(false)); + + EXPECT_FALSE(interrupt_manager_->ReadInterruptSetting()); +} + +TEST_F(InterruptManagerTest, IsSubjectMessageToPrioritized_TRUE) { + std::shared_ptr message = CreateMessage(); + message->set_function_id(mobile_apis::FunctionID::SubtleAlertID); + message->set_message_type(application_manager::kRequest); + + EXPECT_TRUE(interrupt_manager_->IsSubjectMessageToPrioritized(message)); +} + +TEST_F(InterruptManagerTest, CheckRpcInterrupt_NO_INTERRUPT) { + + std::shared_ptr no_interrupt_message = CreateMessage(); + interrupt_manager_->rpc_priority_table_ = DefaultRpcPriority; + + no_interrupt_message->set_function_id(999); + no_interrupt_message->set_message_type(application_manager::kRequest); + + EXPECT_FALSE(interrupt_manager_->IsSubjectMessageToPrioritized(no_interrupt_message)); + EXPECT_EQ(interrupt_manager_->CheckRpcInterrupt(no_interrupt_message), InterruptCheckResult::NO_INTERRUPT); + + no_interrupt_message->set_function_id(mobile_apis::FunctionID::DialNumberID); + no_interrupt_message->set_message_type(application_manager::kNotification); + + EXPECT_FALSE(interrupt_manager_->IsSubjectMessageToPrioritized(no_interrupt_message)); + EXPECT_EQ(interrupt_manager_->CheckRpcInterrupt(no_interrupt_message), InterruptCheckResult::NO_INTERRUPT); + + no_interrupt_message->set_function_id(mobile_apis::FunctionID::SubtleAlertID); + no_interrupt_message->set_message_type(application_manager::kNotification); + + EXPECT_FALSE(interrupt_manager_->IsSubjectMessageToPrioritized(no_interrupt_message)); + EXPECT_EQ(interrupt_manager_->CheckRpcInterrupt(no_interrupt_message), InterruptCheckResult::NO_INTERRUPT); + + interrupt_manager_->highest_priority_ons_rpc_ = 0; + no_interrupt_message->set_function_id(mobile_apis::FunctionID::DialNumberID); + no_interrupt_message->set_message_type(application_manager::kRequest); + + EXPECT_TRUE(interrupt_manager_->IsSubjectMessageToPrioritized(no_interrupt_message)); + EXPECT_EQ(interrupt_manager_->CheckRpcInterrupt(no_interrupt_message), InterruptCheckResult::NO_INTERRUPT); + +} + +TEST_F(InterruptManagerTest, CheckRpcInterrupt_REJECT_ONS_IN_QUEUE) { + std::shared_ptr in_queue_message = CreateMessage(); + in_queue_message->set_function_id(mobile_apis::FunctionID::DialNumberID); + in_queue_message->set_message_type(application_manager::kRequest); + interrupt_manager_->highest_priority_ons_rpc_ = in_queue_message; + std::shared_ptr reject_ons_in_queue_message = CreateMessage(); + reject_ons_in_queue_message->set_function_id(mobile_apis::FunctionID::DialNumberID); + reject_ons_in_queue_message->set_message_type(application_manager::kRequest); + + interrupt_manager_->appPriority = "EMERGENCY"; + interrupt_manager_->firstAppPriority = "NONE"; + + EXPECT_TRUE(interrupt_manager_->IsSubjectMessageToPrioritized(reject_ons_in_queue_message)); + EXPECT_EQ(interrupt_manager_->CheckRpcInterrupt(reject_ons_in_queue_message), InterruptCheckResult::REJECT_ONS_IN_QUEUE); + + interrupt_manager_->appPriority = "NONE"; + + reject_ons_in_queue_message->set_function_id(mobile_apis::FunctionID::DialNumberID); + in_queue_message->set_function_id(mobile_apis::FunctionID::AlertID); + + EXPECT_EQ(interrupt_manager_->CheckRpcInterrupt(reject_ons_in_queue_message), InterruptCheckResult::REJECT_ONS_IN_QUEUE); + in_queue_message->set_function_id(mobile_apis::FunctionID::DialNumberID); + + interrupt_manager_->appPriority = "NAVIGATION"; + interrupt_manager_->firstAppPriority = "NONE"; + + EXPECT_EQ(interrupt_manager_->CheckRpcInterrupt(reject_ons_in_queue_message), InterruptCheckResult::REJECT_ONS_IN_QUEUE); + + interrupt_manager_->appPriority = "NONE"; + + EXPECT_EQ(interrupt_manager_->CheckRpcInterrupt(reject_ons_in_queue_message), InterruptCheckResult::REJECT_ONS_IN_QUEUE); +} + +TEST_F(InterruptManagerTest, CheckRpcInterrupt_REJECT_RECEIVED_ONS) { + std::shared_ptr reject_received_ons_message = CreateMessage(); + + reject_received_ons_message->set_function_id(mobile_apis::FunctionID::DialNumberID); + reject_received_ons_message->set_message_type(application_manager::kRequest); + + std::shared_ptr in_queue_message = CreateMessage(); + + in_queue_message->set_function_id(mobile_apis::FunctionID::DialNumberID); + in_queue_message->set_message_type(application_manager::kRequest); + + interrupt_manager_->appPriority = "NONE"; + interrupt_manager_->firstAppPriority = "EMERGENCY"; + + interrupt_manager_->highest_priority_ons_rpc_ = in_queue_message; + + EXPECT_EQ(interrupt_manager_->CheckRpcInterrupt(reject_received_ons_message), InterruptCheckResult::REJECT_RECEIVED_ONS); + + interrupt_manager_->firstAppPriority = "NONE"; + reject_received_ons_message->set_function_id(mobile_apis::FunctionID::AlertID); + + EXPECT_EQ(interrupt_manager_->CheckRpcInterrupt(reject_received_ons_message), InterruptCheckResult::REJECT_RECEIVED_ONS); + + reject_received_ons_message->set_function_id(mobile_apis::FunctionID::DialNumberID); + interrupt_manager_->firstAppPriority = "NAVIGATION"; + + EXPECT_EQ(interrupt_manager_->CheckRpcInterrupt(reject_received_ons_message), InterruptCheckResult::REJECT_RECEIVED_ONS); + + interrupt_manager_->app_hmi_level = "NONE"; + interrupt_manager_->first_app_hmi_level = "FULL"; + + EXPECT_EQ(interrupt_manager_->CheckRpcInterrupt(reject_received_ons_message), InterruptCheckResult::REJECT_RECEIVED_ONS); +} + +TEST_F(InterruptManagerTest, DoRpcReject_SUCCESS) { + mobile_apis::FunctionID::eType function_id = mobile_apis::FunctionID::eType::DialNumberID; + + std::list test_reject_rpc_list_{function_id}; + interrupt_manager_->reject_rpc_list_ = test_reject_rpc_list_; + + std::shared_ptr message = CreateMessage(); + interrupt_manager_->highest_priority_ons_rpc_ = message; + + EXPECT_TRUE(interrupt_manager_->DoRpcReject(mobile_apis::FunctionID::eType::DialNumberID)); +} + +TEST_F(InterruptManagerTest, DoRpcReject_UNSUCCESS) { + mobile_apis::FunctionID::eType function_id = mobile_apis::FunctionID::eType::DialNumberID; + std::list test_reject_rpc_list_{function_id}; + std::shared_ptr message = CreateMessage(); + interrupt_manager_->highest_priority_ons_rpc_ = message; + + interrupt_manager_->reject_rpc_list_.push_front(message->function_id()); + + EXPECT_FALSE(interrupt_manager_->DoRpcReject(mobile_apis::FunctionID::eType::AlertID)); +} + +} // namespace application_manager_test +} // namespace components +} // namespace test + diff --git a/src/components/application_manager/test/sdl_pt_update.json b/src/components/application_manager/test/sdl_pt_update.json index e3c9c158610..91f6234d7fe 100644 --- a/src/components/application_manager/test/sdl_pt_update.json +++ b/src/components/application_manager/test/sdl_pt_update.json @@ -1634,6 +1634,31 @@ "vehicle_make" : "Stark Industries", "vehicle_model" : "E-Tron", "vehicle_year" : "1992" + }, + "interrupt_manager_config": { + "rpc_priority":{ + "DialNumber": 1, + "Alert": 2, + "PerformAudioPassThru": 2, + "PerformInteraction": 3, + "ScrollableMessage": 3, + "Slider": 3, + "Speak": 3 + }, + "app_priority":{ + "EMERGENCY": 0, + "NAVIGATION": 1, + "VOICE_COMMUNICATION": 2, + "COMMUNICATION": 3, + "NORMAL": 4, + "NONE": 5 + }, + "hmi_status_priority":{ + "FULL": 1, + "LIMITED": 2, + "BACKGROUND": 3, + "NONE": 4 + } } } } diff --git a/src/components/config_profile/include/config_profile/profile.h b/src/components/config_profile/include/config_profile/profile.h index bb7762721fc..f1311626155 100644 --- a/src/components/config_profile/include/config_profile/profile.h +++ b/src/components/config_profile/include/config_profile/profile.h @@ -868,6 +868,8 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, */ const std::string ErrorDescription() const; + bool enable_rpc_conflict_manager() const; + private: /** * @brief Checks that filename consists of portable symbols @@ -1177,6 +1179,9 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, std::string hmi_origin_id_; DISALLOW_COPY_AND_ASSIGN(Profile); + + bool enable_rpc_conflict_manager_; + }; } // namespace profile diff --git a/src/components/config_profile/src/profile.cc b/src/components/config_profile/src/profile.cc index f318ec98f59..03a7664b76d 100644 --- a/src/components/config_profile/src/profile.cc +++ b/src/components/config_profile/src/profile.cc @@ -309,6 +309,8 @@ const char* kMediaLowBandwidthResumptionLevelKey = const char* kHMIOriginIDKey = "HMIOriginID"; const char* kEmbeddedServicesKey = "EmbeddedServices"; +const char* kEnableRPCConflictManagerKey = "EnableRPCConflictManager"; + #ifdef WEB_HMI const char* kDefaultLinkToWebHMI = "HMI/index.html"; #endif // WEB_HMI @@ -444,6 +446,7 @@ const char* kDefaultAOAFilterDescription = "SmartDeviceLink Core Component USB"; const char* kDefaultAOAFilterVersion = "1.0"; const char* kDefaultAOAFilterURI = "http://www.smartdevicelink.org"; const char* kDefaultAOAFilterSerialNumber = "N000000"; +const bool kDefaultEnableRPCConflictManager = false; } // namespace namespace profile { @@ -574,7 +577,8 @@ Profile::Profile() , wake_up_signal_offset_(kDefaultWakeUpSignalOffset) , ignition_off_signal_offset_(kDefaultIgnitionOffSignalOffset) , rpc_pass_through_timeout_(kDefaultRpcPassThroughTimeout) - , period_for_consent_expiration_(kDefaultPeriodForConsentExpiration) { + , period_for_consent_expiration_(kDefaultPeriodForConsentExpiration) + , enable_rpc_conflict_manager_(kDefaultEnableRPCConflictManager){ } Profile::~Profile() {} @@ -1297,6 +1301,11 @@ void Profile::ParseConfiguration() { } } +bool Profile::enable_rpc_conflict_manager() const { + SDL_LOG_AUTO_TRACE(); + return enable_rpc_conflict_manager_; +} + void Profile::UpdateValues() { SDL_LOG_AUTO_TRACE(); @@ -2724,6 +2733,10 @@ void Profile::UpdateValues() { ++entry; } } + ReadBoolValue(&enable_rpc_conflict_manager_, + kDefaultEnableRPCConflictManager, + kPolicySection, + kEnableRPCConflictManagerKey); } bool Profile::ReadValue(bool* value, 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 8384f56f776..1e273cb66a4 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager.h +++ b/src/components/policy/policy_external/include/policy/cache_manager.h @@ -864,6 +864,10 @@ class CacheManager : public CacheManagerInterface { static policy_table::VehicleDataItems CollectCustomVDItems( const policy_table::VehicleDataItems& vd_items); + virtual rpc::policy_table_interface_base::rpc_priority_type GetRpcPriority() const OVERRIDE; + virtual rpc::policy_table_interface_base::app_priority_type GetAppPriority() const OVERRIDE; + virtual rpc::policy_table_interface_base::hmi_status_priority_type GetHmiStatusPriority() const OVERRIDE; + private: std::string currentDateTime(); struct AppHMITypeToString { @@ -1085,6 +1089,9 @@ class CacheManager : public CacheManagerInterface { void MergeVD(const policy_table::PolicyTable& new_pt, policy_table::PolicyTable& pt); + void MergeIMC(const policy_table::PolicyTable& new_pt, + policy_table::PolicyTable& pt); + void InitBackupThread(); /** diff --git a/src/components/policy/policy_external/include/policy/cache_manager_interface.h b/src/components/policy/policy_external/include/policy/cache_manager_interface.h index f33dabd0258..de48f78787e 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 @@ -1024,6 +1024,11 @@ class CacheManagerInterface { */ virtual std::shared_ptr GetPT() const = 0; #endif + + virtual rpc::policy_table_interface_base::rpc_priority_type GetRpcPriority() const = 0; + virtual rpc::policy_table_interface_base::app_priority_type GetAppPriority() const = 0; + virtual rpc::policy_table_interface_base::hmi_status_priority_type GetHmiStatusPriority() const = 0; + }; typedef std::shared_ptr CacheManagerInterfaceSPtr; 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 2be8183bfa5..aa221c99a21 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 @@ -1125,6 +1125,10 @@ class PolicyManagerImpl : public PolicyManager { bool GetModuleTypes(const std::string& policy_app_id, std::vector* modules) const OVERRIDE; + rpc::policy_table_interface_base::rpc_priority_type GetRpcPriority() const OVERRIDE; + rpc::policy_table_interface_base::app_priority_type GetAppPriority() const OVERRIDE; + rpc::policy_table_interface_base::hmi_status_priority_type GetHmiStatusPriority() const OVERRIDE; + void ResetTimeout() OVERRIDE; /** 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 98f86d6ea1c..a6698377889 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 @@ -124,6 +124,10 @@ typedef Array, 0, 255> ModuleTypes; typedef AppHMIType AppHmiType; typedef std::vector AppHmiTypes; +typedef Map, 0, 7> rpc_priority_type; +typedef Map, 0, 6> app_priority_type; +typedef Map, 0, 4> hmi_status_priority_type; + struct AppServiceHandledRpc : CompositeType { public: FunctionIDInt function_id; @@ -719,6 +723,36 @@ struct VehicleData : CompositeType { bool Validate() const; }; + +struct InterruptManagerConfig : CompositeType { + public: + rpc_priority_type rpc_priority; + app_priority_type app_priority; + hmi_status_priority_type hmi_status_priority; + + public: + InterruptManagerConfig(); + InterruptManagerConfig(const rpc_priority_type& rpc_priority, + const app_priority_type& app_priority, + const hmi_status_priority_type& hmi_status_priority); + ~InterruptManagerConfig(); + explicit InterruptManagerConfig(const Json::Value* value__); + + void SafeCopyFrom(const InterruptManagerConfig& from); + + 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; @@ -729,13 +763,15 @@ struct PolicyTable : CompositeType { Optional usage_and_error_counts; Optional device_data; Optional vehicle_data; + InterruptManagerConfig interrupt_manager_config; public: PolicyTable(); PolicyTable(const ApplicationPoliciesSection& app_policies_section, const FunctionalGroupings& functional_groupings, const ConsumerFriendlyMessages& consumer_friendly_messages, - const ModuleConfig& module_config); + const ModuleConfig& module_config, + const InterruptManagerConfig& interrupt_manager_config); ~PolicyTable(); explicit PolicyTable(const Json::Value* value__); Json::Value ToJsonValue() const; 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 aba08dcca13..76a7084e8f9 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 @@ -157,6 +157,15 @@ extern const std::string kSelectVehicleDataSchemaVersion; extern const std::string kInsertVehicleDataSchemaVersion; extern const std::string kSelectEndpointProperties; extern const std::string kInsertEndpointVersion; +extern const std::string kSelectInterruptManagerConfig; +extern const std::string kUpdateInterruptManagerConfig; +extern const std::string kInsertInterruptManagerConfig; +extern const std::string kSelectRpcPriority; +extern const std::string kSelectAppPriority; +extern const std::string kSelectHmiStatusPriority; +extern const std::string kInsertRpcPriority; +extern const std::string kInsertAppPriority; +extern const std::string kInsertHmiStatusPriority; } // 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 473022c6c3c..56f09adf5ec 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 @@ -142,6 +142,8 @@ class SQLPTRepresentation : public virtual PTRepresentation { bool GatherNickName(const std::string& app_id, policy_table::Strings* nicknames) const; + virtual void GatherInterruptManagerConfig(policy_table::InterruptManagerConfig* config) const; + virtual bool SaveApplicationCustomData(const std::string& app_id, bool is_revoked, bool is_default, @@ -168,6 +170,7 @@ class SQLPTRepresentation : public virtual PTRepresentation { virtual bool SaveMessageString(const std::string& type, const std::string& lang, const policy_table::MessageString& strings); + virtual bool SaveInterruptManagerConfig(const policy_table::InterruptManagerConfig& config); bool SaveAppGroup(const std::string& app_id, const policy_table::Strings& app_groups); @@ -256,6 +259,9 @@ class SQLPTRepresentation : public virtual PTRepresentation { bool SaveLanguage(const std::string& code); policy_table::VehicleDataItem PopulateVDIFromQuery( const utils::dbms::SQLQuery& query) const; + bool SaveRpcPriority(const policy_table::rpc_priority_type& priority); + bool SaveAppPriority(const policy_table::app_priority_type& priority); + bool SaveHmiStatusPriority(const policy_table::hmi_status_priority_type& priority); bool DeleteVehicleDataItems() const; bool is_in_memory; diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc index 07f2df19918..3e1b108057d 100644 --- a/src/components/policy/policy_external/src/cache_manager.cc +++ b/src/components/policy/policy_external/src/cache_manager.cc @@ -768,6 +768,9 @@ bool CacheManager::ApplyUpdate(const policy_table::Table& update_pt) { pt_->policy_table.module_config.endpoint_properties = update_pt.policy_table.module_config.endpoint_properties; + pt_->policy_table.interrupt_manager_config.SafeCopyFrom( + update_pt.policy_table.interrupt_manager_config); + // Apply update for vehicle data if (update_pt.policy_table.vehicle_data.is_initialized()) { policy_table::VehicleDataItems custom_items_before_apply; @@ -2136,6 +2139,8 @@ std::shared_ptr CacheManager::GenerateSnapshot() { snapshot_->SetPolicyTableType(policy_table::PT_SNAPSHOT); + snapshot_->policy_table.interrupt_manager_config = pt_->policy_table.interrupt_manager_config; + CheckSnapshotInitialization(); return snapshot_; } @@ -3082,6 +3087,7 @@ bool CacheManager::MergePreloadPT(const std::string& file_name) { MergeAP(new_table, current); MergeCFM(new_table, current); MergeVD(new_table, current); + MergeIMC(new_table, current); Backup(); } return true; @@ -3155,6 +3161,12 @@ void CacheManager::MergeVD(const policy_table::PolicyTable& new_pt, pt.vehicle_data.assign_if_valid(new_pt.vehicle_data); } +void CacheManager::MergeIMC(const policy_table::PolicyTable& new_pt, + policy_table::PolicyTable& pt) { + SDL_LOG_AUTO_TRACE(); + pt.interrupt_manager_config = new_pt.interrupt_manager_config; +} + void CacheManager::InitBackupThread() { SDL_LOG_AUTO_TRACE(); backuper_ = new BackgroundBackuper(this); @@ -3305,4 +3317,23 @@ void CacheManager::GetApplicationParams( application_params = (*it).second; } +rpc::policy_table_interface_base::rpc_priority_type +CacheManager::GetRpcPriority() const { + SDL_LOG_AUTO_TRACE(); + sync_primitives::AutoLock auto_lock(cache_lock_); + return pt_->policy_table.interrupt_manager_config.rpc_priority; +} + +rpc::policy_table_interface_base::app_priority_type +CacheManager::GetAppPriority() const { + sync_primitives::AutoLock auto_lock(cache_lock_); + return pt_->policy_table.interrupt_manager_config.app_priority; +} + +rpc::policy_table_interface_base::hmi_status_priority_type +CacheManager::GetHmiStatusPriority() const { + sync_primitives::AutoLock auto_lock(cache_lock_); + return pt_->policy_table.interrupt_manager_config.hmi_status_priority; +} + } // namespace policy 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 75920be58c0..d5bebd2491e 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -2573,6 +2573,17 @@ const std::vector PolicyManagerImpl::GetRPCsForFunctionGroup( return rpcs_for_group; } +rpc::policy_table_interface_base::rpc_priority_type PolicyManagerImpl::GetRpcPriority() const { + SDL_LOG_AUTO_TRACE(); + return cache_->GetRpcPriority(); +} +rpc::policy_table_interface_base::app_priority_type PolicyManagerImpl::GetAppPriority() const { + return cache_->GetAppPriority(); +} +rpc::policy_table_interface_base::hmi_status_priority_type PolicyManagerImpl::GetHmiStatusPriority() const { + return cache_->GetHmiStatusPriority(); +} + } // namespace policy __attribute__((visibility("default"))) policy::PolicyManager* CreateManager( 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 fffa6a78480..10d7c87d561 100644 --- a/src/components/policy/policy_external/src/policy_table/types.cc +++ b/src/components/policy/policy_external/src/policy_table/types.cc @@ -2683,6 +2683,100 @@ void VehicleData::SetPolicyTableType(PolicyTableType pt_type) { schema_items.SetPolicyTableType(pt_type); } +//InterruptManagerConfig methods +InterruptManagerConfig::InterruptManagerConfig() : CompositeType(kUninitialized) {} + +InterruptManagerConfig::InterruptManagerConfig( + const rpc_priority_type& rpc_priority, + const app_priority_type& app_priority, + const hmi_status_priority_type& hmi_status_priority) + : CompositeType(kUninitialized) + , rpc_priority(rpc_priority) + , app_priority(app_priority) + , hmi_status_priority(hmi_status_priority){} + +InterruptManagerConfig::~InterruptManagerConfig() {} + + +InterruptManagerConfig::InterruptManagerConfig(const Json::Value* value__) + : CompositeType(InitHelper(value__, &Json::Value::isObject)) + , rpc_priority(impl::ValueMember(value__, "rpc_priority")) + , app_priority(impl::ValueMember(value__, "app_priority")) + , hmi_status_priority(impl::ValueMember(value__, "hmi_status_priority")){} + + +void InterruptManagerConfig::SafeCopyFrom(const InterruptManagerConfig& from) { + rpc_priority = from.rpc_priority; + app_priority = from.app_priority; + hmi_status_priority = from.hmi_status_priority; +} + +Json::Value InterruptManagerConfig::ToJsonValue() const { + Json::Value result__(Json::objectValue); + impl::WriteJsonField("rpc_priority", rpc_priority, &result__); + impl::WriteJsonField("app_priority", app_priority, &result__); + impl::WriteJsonField("hmi_status_priority", hmi_status_priority, &result__); + return result__; +} + + +bool InterruptManagerConfig::is_valid() const { + if (!rpc_priority.is_valid()) { + return false; + } + if (!app_priority.is_valid()) { + return false; + } + if (!hmi_status_priority.is_valid()) { + return false; + } + return Validate(); +} + + +bool InterruptManagerConfig::is_initialized() const { + return (initialization_state__ != kUninitialized) || (!struct_empty()); +} + + +bool InterruptManagerConfig::struct_empty() const { + if (!rpc_priority.is_initialized()) { + return false; + } + if (!app_priority.is_initialized()) { + return false; + } + if (!hmi_status_priority.is_initialized()) { + return false; + } + return true; +} + +void InterruptManagerConfig::ReportErrors(rpc::ValidationReport* report__) const { + if (struct_empty()) { + rpc::CompositeType::ReportErrors(report__); + } + if (!rpc_priority.is_valid()) { + rpc_priority.ReportErrors( + &report__->ReportSubobject("rpc_priority")); + } + if (!app_priority.is_valid()) { + app_priority.ReportErrors( + &report__->ReportSubobject("app_priority")); + } + if (!hmi_status_priority.is_valid()) { + hmi_status_priority.ReportErrors( + &report__->ReportSubobject("hmi_status_priority")); + } +} + +void InterruptManagerConfig::SetPolicyTableType(PolicyTableType pt_type) { + CompositeType::SetPolicyTableType(pt_type); + rpc_priority.SetPolicyTableType(pt_type); + app_priority.SetPolicyTableType(pt_type); + hmi_status_priority.SetPolicyTableType(pt_type); +} + // PolicyTable methods PolicyTable::PolicyTable() : CompositeType(kUninitialized) {} @@ -2690,12 +2784,14 @@ PolicyTable::PolicyTable( const ApplicationPoliciesSection& app_policies_section, const FunctionalGroupings& functional_groupings, const ConsumerFriendlyMessages& consumer_friendly_messages, - const ModuleConfig& module_config) + const ModuleConfig& module_config, + const InterruptManagerConfig& interrupt_manager_config) : CompositeType(kUninitialized) , app_policies_section(app_policies_section) , functional_groupings(functional_groupings) , consumer_friendly_messages(consumer_friendly_messages) - , module_config(module_config) {} + , module_config(module_config) + , interrupt_manager_config(interrupt_manager_config) {} PolicyTable::~PolicyTable() {} @@ -2710,7 +2806,8 @@ PolicyTable::PolicyTable(const Json::Value* value__) , usage_and_error_counts( impl::ValueMember(value__, "usage_and_error_counts")) , device_data(impl::ValueMember(value__, "device_data")) - , vehicle_data(impl::ValueMember(value__, "vehicle_data")) {} + , vehicle_data(impl::ValueMember(value__, "vehicle_data")) + , interrupt_manager_config(impl::ValueMember(value__, "interrupt_manager_config")){} Json::Value PolicyTable::ToJsonValue() const { Json::Value result__(Json::objectValue); @@ -2724,6 +2821,7 @@ Json::Value PolicyTable::ToJsonValue() const { "usage_and_error_counts", usage_and_error_counts, &result__); impl::WriteJsonField("device_data", device_data, &result__); impl::WriteJsonField("vehicle_data", vehicle_data, &result__); + impl::WriteJsonField("interrupt_manager_config", interrupt_manager_config, &result__); return result__; } @@ -2752,6 +2850,9 @@ bool PolicyTable::is_valid() const { if (!vehicle_data.is_valid()) { return false; } + if (!interrupt_manager_config.is_valid()) { + return false; + } return Validate(); } @@ -2788,6 +2889,9 @@ bool PolicyTable::struct_empty() const { if (vehicle_data.is_initialized()) { return false; } + if (interrupt_manager_config.is_initialized()) { + return false; + } return true; } @@ -2833,6 +2937,9 @@ void PolicyTable::ReportErrors(rpc::ValidationReport* report__) const { if (!vehicle_data.is_valid()) { vehicle_data.ReportErrors(&report__->ReportSubobject("vehicle_data")); } + if (!interrupt_manager_config.is_valid()) { + interrupt_manager_config.ReportErrors(&report__->ReportSubobject("interrupt_manager_config")); + } } void PolicyTable::SetPolicyTableType(PolicyTableType pt_type) { @@ -2845,6 +2952,7 @@ void PolicyTable::SetPolicyTableType(PolicyTableType pt_type) { usage_and_error_counts.SetPolicyTableType(pt_type); device_data.SetPolicyTableType(pt_type); vehicle_data.SetPolicyTableType(pt_type); + interrupt_manager_config.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 825fd20b848..947de337f47 100644 --- a/src/components/policy/policy_external/src/policy_table/validation.cc +++ b/src/components/policy/policy_external/src/policy_table/validation.cc @@ -270,6 +270,9 @@ bool ModuleConfig::Validate() const { return true; } +bool InterruptManagerConfig::Validate() const { + return true; +} bool MessageString::Validate() const { 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 91dd6fb7136..05754f417e2 100644 --- a/src/components/policy/policy_external/src/sql_pt_queries.cc +++ b/src/components/policy/policy_external/src/sql_pt_queries.cc @@ -500,6 +500,39 @@ const std::string kCreateSchema = " FOREIGN KEY(`param_name`, `param_key`) " " REFERENCES `vehicle_data_item_definition`(`name`, `key`) " "); " + "CREATE TABLE IF NOT EXISTS `rpc_priority`( " + " `priority_value` VARCHAR(45) PRIMARY KEY NOT NULL, " + " `value` INTEGER NOT NULL, " + " CONSTRAINT `fk_rpc_priority_priority1` " + " FOREIGN KEY(`priority_value`) " + " REFERENCES `priority`(`value`) " + "); " + "CREATE INDEX IF NOT EXISTS " + "`rpc_priority.fk_rpc_priority_" + "priority1_idx` " + " ON `rpc_priority`(`priority_value`); " + "CREATE TABLE IF NOT EXISTS `app_priority`( " + " `priority_value` VARCHAR(45) PRIMARY KEY NOT NULL, " + " `value` INTEGER NOT NULL, " + " CONSTRAINT `fk_app_priority_priority1` " + " FOREIGN KEY(`priority_value`) " + " REFERENCES `priority`(`value`) " + "); " + "CREATE INDEX IF NOT EXISTS " + "`app_priority.fk_app_priority_" + "priority1_idx` " + " ON `app_priority`(`priority_value`); " + "CREATE TABLE IF NOT EXISTS `hmi_status_priority`( " + " `priority_value` VARCHAR(45) PRIMARY KEY NOT NULL, " + " `value` INTEGER NOT NULL, " + " CONSTRAINT `fk_hmi_status_priority_priority1` " + " FOREIGN KEY(`priority_value`) " + " REFERENCES `priority`(`value`) " + "); " + "CREATE INDEX IF NOT EXISTS " + "`hmi_status_priority.fk_hmi_status_priority_" + "priority1_idx` " + " ON `hmi_status_priority`(`priority_value`); " "COMMIT;"; const std::string kInsertInitData = @@ -654,6 +687,19 @@ const std::string kDropSchema = "DROP TABLE IF EXISTS `vehicle_data`; " "DROP TABLE IF EXISTS `vehicle_data_item_definition`; " "DROP TABLE IF EXISTS `vehicle_data_item_parameters`; " + "DROP INDEX IF EXISTS " + "`rpc_priority.fk_rpc_priority_" + "priority1_idx`; " + "DROP TABLE IF EXISTS `rpc_priority`; " + "DROP INDEX IF EXISTS " + "`app_priority.fk_app_priority_" + "priority1_idx`; " + "DROP TABLE IF EXISTS `app_priority`; " + "DROP INDEX IF EXISTS " + "`hmi_status_priority.fk_hmi_status_priority_" + "priority1_idx`; " + "DROP TABLE IF EXISTS `hmi_status_priority`; " + "DROP TABLE IF EXISTS `interrupt_manager_config`; " "COMMIT; " "VACUUM;"; @@ -693,6 +739,9 @@ const std::string kDeleteData = "DELETE FROM `vehicle_data`; " "DELETE FROM `vehicle_data_item_definition`; " "DELETE FROM `vehicle_data_item_parameters`; " + "DELETE FROM `rpc_priority`; " + "DELETE FROM `app_priority`; " + "DELETE FROM `hmi_status_priority`; " "COMMIT; " "VACUUM;"; 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 1570675cf90..e254d744f14 100644 --- a/src/components/policy/policy_external/src/sql_pt_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_representation.cc @@ -480,6 +480,7 @@ std::shared_ptr SQLPTRepresentation::GenerateSnapshot() rpc::Optional > null_version; table->policy_table.vehicle_data->schema_version = null_version; } + GatherInterruptManagerConfig(&table->policy_table.interrupt_manager_config); return table; } @@ -868,6 +869,48 @@ bool SQLPTRepresentation::GatherVehicleDataItems( return true; } +void SQLPTRepresentation::GatherInterruptManagerConfig( + policy_table::InterruptManagerConfig* config) const { + SDL_LOG_INFO("Gather Configuration Info"); + + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kSelectInterruptManagerConfig) || !query.Next()) { + SDL_LOG_WARN("Incorrect select statement for interrupt manager config"); + } + + utils::dbms::SQLQuery rpc_priority(db()); + if (!rpc_priority.Prepare(sql_pt::kSelectRpcPriority)) { + SDL_LOG_WARN("Incorrect select statement for priority"); + } else { + while (rpc_priority.Next()) { + config->rpc_priority[rpc_priority.GetString(0)] = + rpc_priority.GetInteger(1); + } + } + SDL_LOG_INFO("rpc_priority.GetString(0) :" << rpc_priority.GetString(0)); + SDL_LOG_INFO("rpc_priority.GetInteger(1) :" << rpc_priority.GetInteger(1)); + + utils::dbms::SQLQuery app_priority(db()); + if (!app_priority.Prepare(sql_pt::kSelectAppPriority)) { + SDL_LOG_WARN("Incorrect select statement for priority"); + } else { + while (app_priority.Next()) { + config->app_priority[app_priority.GetString(0)] = + app_priority.GetInteger(1); + } + } + + utils::dbms::SQLQuery hmi_status_priority(db()); + if (!hmi_status_priority.Prepare(sql_pt::kSelectRpcPriority)) { + SDL_LOG_WARN("Incorrect select statement for priority"); + } else { + while (hmi_status_priority.Next()) { + config->hmi_status_priority[hmi_status_priority.GetString(0)] = + hmi_status_priority.GetInteger(1); + } + } +} + bool SQLPTRepresentation::Save(const policy_table::Table& table) { SDL_LOG_AUTO_TRACE(); db_->BeginTransaction(); @@ -906,6 +949,11 @@ bool SQLPTRepresentation::Save(const policy_table::Table& table) { db_->RollbackTransaction(); return false; } + if (!SaveInterruptManagerConfig( + table.policy_table.interrupt_manager_config)) { + db_->RollbackTransaction(); + return false; + } db_->CommitTransaction(); return true; } @@ -2847,4 +2895,91 @@ bool SQLPTRepresentation::SaveExternalConsentEntities( return true; } +bool SQLPTRepresentation::SaveInterruptManagerConfig( + const policy_table::InterruptManagerConfig& config) { + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kInsertInterruptManagerConfig)) { + SDL_LOG_WARN("Incorrect update statement for InterruptManager config"); + return false; + } + + if (!query.Exec()) { + SDL_LOG_WARN("Incorrect update InterruptManager config"); + return false; + } + + if (!SaveRpcPriority(config.rpc_priority)) { + return false; + } + + if (!SaveAppPriority(config.app_priority)) { + return false; + } + + if (!SaveHmiStatusPriority(config.hmi_status_priority)) { + return false; + } + return true; +} + +bool SQLPTRepresentation::SaveRpcPriority( + const policy_table::rpc_priority_type& priority) { + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kInsertRpcPriority)) { + SDL_LOG_WARN("Incorrect insert statement for rpc priority."); + return false; + } + + policy_table::rpc_priority_type::const_iterator it; + for (it = priority.begin(); it != priority.end(); ++it) { + query.Bind(0, it->first); + query.Bind(1, it->second); + if (!query.Exec() || !query.Reset()) { + SDL_LOG_WARN("Incorrect insert into rpc priority."); + return false; + } + } + return true; +} + +bool SQLPTRepresentation::SaveAppPriority( + const policy_table::app_priority_type& priority) { + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kInsertAppPriority)) { + SDL_LOG_WARN("Incorrect insert statement for rpc priority."); + return false; + } + + policy_table::app_priority_type::const_iterator it; + for (it = priority.begin(); it != priority.end(); ++it) { + query.Bind(0, it->first); + query.Bind(1, it->second); + if (!query.Exec() || !query.Reset()) { + SDL_LOG_WARN("Incorrect insert into rpc priority."); + return false; + } + } + return true; +} + +bool SQLPTRepresentation::SaveHmiStatusPriority( + const policy_table::hmi_status_priority_type& priority) { + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kInsertRpcPriority)) { + SDL_LOG_WARN("Incorrect insert statement for rpc priority."); + return false; + } + + policy_table::hmi_status_priority_type::const_iterator it; + for (it = priority.begin(); it != priority.end(); ++it) { + query.Bind(0, it->first); + query.Bind(1, it->second); + if (!query.Exec() || !query.Reset()) { + SDL_LOG_WARN("Incorrect insert into rpc priority."); + return false; + } + } + return true; +} + } // namespace policy diff --git a/src/components/policy/policy_external/test/json/sdl_preloaded_pt_for_merge_initial.json b/src/components/policy/policy_external/test/json/sdl_preloaded_pt_for_merge_initial.json index 087da1e93b4..10c15966a58 100644 --- a/src/components/policy/policy_external/test/json/sdl_preloaded_pt_for_merge_initial.json +++ b/src/components/policy/policy_external/test/json/sdl_preloaded_pt_for_merge_initial.json @@ -2286,6 +2286,31 @@ "preloaded_pt" : true, "seconds_between_retries" : [ 1, 5, 25, 125, 625 ], "timeout_after_x_seconds" : 60 + }, + "interrupt_manager_config": { + "rpc_priority":{ + "DialNumber": 1, + "Alert": 2, + "PerformAudioPassThru": 2, + "PerformInteraction": 3, + "ScrollableMessage": 3, + "Slider": 3, + "Speak": 3 + }, + "app_priority":{ + "EMERGENCY": 0, + "NAVIGATION": 1, + "VOICE_COMMUNICATION": 2, + "COMMUNICATION": 3, + "NORMAL": 4, + "NONE": 5 + }, + "hmi_status_priority":{ + "FULL": 1, + "LIMITED": 2, + "BACKGROUND": 3, + "NONE": 4 + } } } } diff --git a/src/components/policy/policy_external/test/json/sdl_preloaded_pt_for_merge_latest.json b/src/components/policy/policy_external/test/json/sdl_preloaded_pt_for_merge_latest.json index 43c16f18b8e..ecbdd289ba9 100644 --- a/src/components/policy/policy_external/test/json/sdl_preloaded_pt_for_merge_latest.json +++ b/src/components/policy/policy_external/test/json/sdl_preloaded_pt_for_merge_latest.json @@ -2282,6 +2282,31 @@ "preloaded_pt" : true, "seconds_between_retries" : [ 1, 5, 25, 125, 625 ], "timeout_after_x_seconds" : 60 + }, + "interrupt_manager_config": { + "rpc_priority":{ + "DialNumber": 1, + "Alert": 2, + "PerformAudioPassThru": 2, + "PerformInteraction": 3, + "ScrollableMessage": 3, + "Slider": 3, + "Speak": 3 + }, + "app_priority":{ + "EMERGENCY": 0, + "NAVIGATION": 1, + "VOICE_COMMUNICATION": 2, + "COMMUNICATION": 3, + "NORMAL": 4, + "NONE": 5 + }, + "hmi_status_priority":{ + "FULL": 1, + "LIMITED": 2, + "BACKGROUND": 3, + "NONE": 4 + } } } } diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h index 473caef1450..9305068abf3 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager.h @@ -857,6 +857,9 @@ class CacheManager : public CacheManagerInterface { void MergeVD(const policy_table::PolicyTable& new_pt, policy_table::PolicyTable& pt); + void MergeIMC(const policy_table::PolicyTable& new_pt, + policy_table::PolicyTable& pt); + const PolicySettings& get_settings() const; std::shared_ptr pt() const { @@ -890,6 +893,10 @@ class CacheManager : public CacheManagerInterface { static policy_table::VehicleDataItems CollectCustomVDItems( const policy_table::VehicleDataItems& vd_items); + virtual rpc::policy_table_interface_base::rpc_priority_type GetRpcPriority() const OVERRIDE; + virtual rpc::policy_table_interface_base::app_priority_type GetAppPriority() const OVERRIDE; + virtual rpc::policy_table_interface_base::hmi_status_priority_type GetHmiStatusPriority() const OVERRIDE; + private: std::string currentDateTime(); struct AppHMITypeToString { diff --git a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h index 5e536ef3156..c68c1d2ee17 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h @@ -875,6 +875,10 @@ class CacheManagerInterface { virtual void GetApplicationParams( const std::string& application_name, policy_table::ApplicationParams& application_params) const = 0; + + virtual rpc::policy_table_interface_base::rpc_priority_type GetRpcPriority() const = 0; + virtual rpc::policy_table_interface_base::app_priority_type GetAppPriority() const = 0; + virtual rpc::policy_table_interface_base::hmi_status_priority_type GetHmiStatusPriority() const = 0; }; typedef std::shared_ptr CacheManagerInterfaceSPtr; diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h index 0d1a61ec89d..13fa090aa70 100644 --- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h @@ -1077,6 +1077,10 @@ class PolicyManagerImpl : public PolicyManager { bool GetModuleTypes(const std::string& policy_app_id, std::vector* modules) const OVERRIDE; + rpc::policy_table_interface_base::rpc_priority_type GetRpcPriority() const OVERRIDE; + rpc::policy_table_interface_base::app_priority_type GetAppPriority() const OVERRIDE; + rpc::policy_table_interface_base::hmi_status_priority_type GetHmiStatusPriority() const OVERRIDE; + /** * @brief pointer to policy table listener for callbacks */ diff --git a/src/components/policy/policy_regular/include/policy/policy_table/types.h b/src/components/policy/policy_regular/include/policy/policy_table/types.h index 664987b70fa..1914bdfaf0d 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/types.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/types.h @@ -119,6 +119,10 @@ typedef Array, 0, 255> ModuleTypes; typedef AppHMIType AppHmiType; typedef std::vector AppHmiTypes; +typedef Map, 0, 7> rpc_priority_type; +typedef Map, 0, 6> app_priority_type; +typedef Map, 0, 4> hmi_status_priority_type; + struct AppServiceHandledRpc : CompositeType { public: FunctionIDInt function_id; @@ -615,6 +619,35 @@ struct VehicleData : CompositeType { bool Validate() const; }; +struct InterruptManagerConfig : CompositeType { + public: + rpc_priority_type rpc_priority; + app_priority_type app_priority; + hmi_status_priority_type hmi_status_priority; + + public: + InterruptManagerConfig(); + InterruptManagerConfig(const rpc_priority_type& rpc_priority, + const app_priority_type& app_priority, + const hmi_status_priority_type& hmi_status_priority); + ~InterruptManagerConfig(); + explicit InterruptManagerConfig(const Json::Value* value__); + + void SafeCopyFrom(const InterruptManagerConfig& from); + + 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; @@ -625,13 +658,15 @@ struct PolicyTable : CompositeType { Optional usage_and_error_counts; Optional device_data; Optional vehicle_data; + InterruptManagerConfig interrupt_manager_config; public: PolicyTable(); PolicyTable(const ApplicationPoliciesSection& app_policies_section, const FunctionalGroupings& functional_groupings, const ConsumerFriendlyMessages& consumer_friendly_messages, - const ModuleConfig& module_config); + const ModuleConfig& module_config, + const InterruptManagerConfig& interrupt_manager_config); ~PolicyTable(); explicit PolicyTable(const Json::Value* value__); Json::Value ToJsonValue() const; diff --git a/src/components/policy/policy_regular/include/policy/sql_pt_queries.h b/src/components/policy/policy_regular/include/policy/sql_pt_queries.h index fd7f879abf4..a375d33139d 100644 --- a/src/components/policy/policy_regular/include/policy/sql_pt_queries.h +++ b/src/components/policy/policy_regular/include/policy/sql_pt_queries.h @@ -159,6 +159,15 @@ extern const std::string kSelectVehicleDataSchemaVersion; extern const std::string kInsertVehicleDataSchemaVersion; extern const std::string kSelectEndpointProperties; extern const std::string kInsertEndpointVersion; +extern const std::string kSelectInterruptManagerConfig; +extern const std::string kUpdateInterruptManagerConfig; +extern const std::string kInsertInterruptManagerConfig; +extern const std::string kSelectRpcPriority; +extern const std::string kSelectAppPriority; +extern const std::string kSelectHmiStatusPriority; +extern const std::string kInsertRpcPriority; +extern const std::string kInsertAppPriority; +extern const std::string kInsertHmiStatusPriority; } // namespace sql_pt } // namespace policy diff --git a/src/components/policy/policy_regular/include/policy/sql_pt_representation.h b/src/components/policy/policy_regular/include/policy/sql_pt_representation.h index 18147c43f0d..1ddbaf1d42a 100644 --- a/src/components/policy/policy_regular/include/policy/sql_pt_representation.h +++ b/src/components/policy/policy_regular/include/policy/sql_pt_representation.h @@ -144,6 +144,8 @@ class SQLPTRepresentation : public virtual PTRepresentation { bool GatherNickName(const std::string& app_id, policy_table::Strings* nicknames) const; + virtual void GatherInterruptManagerConfig(policy_table::InterruptManagerConfig* config) const; + virtual bool SaveApplicationCustomData(const std::string& app_id, bool is_revoked, bool is_default, @@ -171,6 +173,8 @@ class SQLPTRepresentation : public virtual PTRepresentation { const std::string& lang, const policy_table::MessageString& strings); + virtual bool SaveInterruptManagerConfig(const policy_table::InterruptManagerConfig& config); + bool SaveAppGroup(const std::string& app_id, const policy_table::Strings& app_groups); bool SaveNickname(const std::string& app_id, @@ -256,6 +260,9 @@ class SQLPTRepresentation : public virtual PTRepresentation { bool SaveLanguage(const std::string& code); policy_table::VehicleDataItem PopulateVDIFromQuery( const utils::dbms::SQLQuery& query) const; + bool SaveRpcPriority(const policy_table::rpc_priority_type& priority); + bool SaveAppPriority(const policy_table::app_priority_type& priority); + bool SaveHmiStatusPriority(const policy_table::hmi_status_priority_type& priority); bool DeleteVehicleDataItems() const; bool is_in_memory; diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index cf4164d1338..6ab0a2f62f1 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -306,6 +306,9 @@ bool CacheManager::ApplyUpdate(const policy_table::Table& update_pt) { pt_->policy_table.module_config.endpoint_properties = update_pt.policy_table.module_config.endpoint_properties; + pt_->policy_table.interrupt_manager_config.SafeCopyFrom( + update_pt.policy_table.interrupt_manager_config); + // Apply update for vehicle data if (update_pt.policy_table.vehicle_data.is_initialized()) { policy_table::VehicleDataItems custom_items_before_apply; @@ -1418,6 +1421,8 @@ std::shared_ptr CacheManager::GenerateSnapshot() { pt_->policy_table.vehicle_data->schema_version; } + snapshot_->policy_table.interrupt_manager_config = pt_->policy_table.interrupt_manager_config; + // Set policy table type to Snapshot snapshot_->SetPolicyTableType( rpc::policy_table_interface_base::PolicyTableType::PT_SNAPSHOT); @@ -2080,6 +2085,7 @@ bool CacheManager::MergePreloadPT(const std::string& file_name) { MergeAP(new_table, current); MergeCFM(new_table, current); MergeVD(new_table, current); + MergeIMC(new_table, current); Backup(); } return true; @@ -2153,6 +2159,12 @@ void CacheManager::MergeVD(const policy_table::PolicyTable& new_pt, pt.vehicle_data.assign_if_valid(new_pt.vehicle_data); } +void CacheManager::MergeIMC(const policy_table::PolicyTable& new_pt, + policy_table::PolicyTable& pt) { + SDL_LOG_AUTO_TRACE(); + pt.interrupt_manager_config = new_pt.interrupt_manager_config; +} + const PolicySettings& CacheManager::get_settings() const { DCHECK(settings_); @@ -2259,4 +2271,24 @@ void CacheManager::GetApplicationParams( application_params = (*it).second; } +rpc::policy_table_interface_base::rpc_priority_type +CacheManager::GetRpcPriority() const { + SDL_LOG_AUTO_TRACE(); + sync_primitives::AutoLock auto_lock(cache_lock_); + return pt_->policy_table.interrupt_manager_config.rpc_priority; +} + +rpc::policy_table_interface_base::app_priority_type +CacheManager::GetAppPriority() const { + sync_primitives::AutoLock auto_lock(cache_lock_); + return pt_->policy_table.interrupt_manager_config.app_priority; +} + +rpc::policy_table_interface_base::hmi_status_priority_type +CacheManager::GetHmiStatusPriority() const { + sync_primitives::AutoLock auto_lock(cache_lock_); + return pt_->policy_table.interrupt_manager_config.hmi_status_priority; +} + + } // namespace policy diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc index 3a41cfa08bd..c8434b62ccb 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -1886,6 +1886,17 @@ const std::vector PolicyManagerImpl::GetRPCsForFunctionGroup( return rpcs_for_group; } +rpc::policy_table_interface_base::rpc_priority_type PolicyManagerImpl::GetRpcPriority() const { + SDL_LOG_AUTO_TRACE(); + return cache_->GetRpcPriority(); +} +rpc::policy_table_interface_base::app_priority_type PolicyManagerImpl::GetAppPriority() const { + return cache_->GetAppPriority(); +} +rpc::policy_table_interface_base::hmi_status_priority_type PolicyManagerImpl::GetHmiStatusPriority() const { + return cache_->GetHmiStatusPriority(); +} + } // namespace policy __attribute__((visibility("default"))) policy::PolicyManager* CreateManager( diff --git a/src/components/policy/policy_regular/src/policy_table/types.cc b/src/components/policy/policy_regular/src/policy_table/types.cc index 6b1ba15cfd7..f9f6404c715 100644 --- a/src/components/policy/policy_regular/src/policy_table/types.cc +++ b/src/components/policy/policy_regular/src/policy_table/types.cc @@ -2162,6 +2162,101 @@ void VehicleData::SetPolicyTableType(PolicyTableType pt_type) { schema_items.SetPolicyTableType(pt_type); } +//InterruptManagerConfig methods +InterruptManagerConfig::InterruptManagerConfig() : CompositeType(kUninitialized) {} + +InterruptManagerConfig::InterruptManagerConfig( + const rpc_priority_type& rpc_priority, + const app_priority_type& app_priority, + const hmi_status_priority_type& hmi_status_priority) + : CompositeType(kUninitialized) + , rpc_priority(rpc_priority) + , app_priority(app_priority) + , hmi_status_priority(hmi_status_priority){} + +InterruptManagerConfig::~InterruptManagerConfig() {} + + +InterruptManagerConfig::InterruptManagerConfig(const Json::Value* value__) + : CompositeType(InitHelper(value__, &Json::Value::isObject)) + , rpc_priority(impl::ValueMember(value__, "rpc_priority")) + , app_priority(impl::ValueMember(value__, "app_priority")) + , hmi_status_priority(impl::ValueMember(value__, "hmi_status_priority")){} + + +void InterruptManagerConfig::SafeCopyFrom(const InterruptManagerConfig& from) { + rpc_priority = from.rpc_priority; + app_priority = from.app_priority; + hmi_status_priority = from.hmi_status_priority; +} + +Json::Value InterruptManagerConfig::ToJsonValue() const { + Json::Value result__(Json::objectValue); + impl::WriteJsonField("rpc_priority", rpc_priority, &result__); + impl::WriteJsonField("app_priority", app_priority, &result__); + impl::WriteJsonField("hmi_status_priority", hmi_status_priority, &result__); + return result__; +} + + +bool InterruptManagerConfig::is_valid() const { + if (!rpc_priority.is_valid()) { + return false; + } + if (!app_priority.is_valid()) { + return false; + } + if (!hmi_status_priority.is_valid()) { + return false; + } + return Validate(); +} + + +bool InterruptManagerConfig::is_initialized() const { + return (initialization_state__ != kUninitialized) || (!struct_empty()); +} + + +bool InterruptManagerConfig::struct_empty() const { + if (!rpc_priority.is_initialized()) { + return false; + } + if (!app_priority.is_initialized()) { + return false; + } + if (!hmi_status_priority.is_initialized()) { + return false; + } + return true; +} + + +void InterruptManagerConfig::ReportErrors(rpc::ValidationReport* report__) const { + if (struct_empty()) { + rpc::CompositeType::ReportErrors(report__); + } + if (!rpc_priority.is_valid()) { + rpc_priority.ReportErrors( + &report__->ReportSubobject("rpc_priority")); + } + if (!app_priority.is_valid()) { + app_priority.ReportErrors( + &report__->ReportSubobject("app_priority")); + } + if (!hmi_status_priority.is_valid()) { + hmi_status_priority.ReportErrors( + &report__->ReportSubobject("hmi_status_priority")); + } +} + +void InterruptManagerConfig::SetPolicyTableType(PolicyTableType pt_type) { + CompositeType::SetPolicyTableType(pt_type); + rpc_priority.SetPolicyTableType(pt_type); + app_priority.SetPolicyTableType(pt_type); + hmi_status_priority.SetPolicyTableType(pt_type); +} + // PolicyTable methods PolicyTable::PolicyTable() : CompositeType(kUninitialized) {} @@ -2169,12 +2264,14 @@ PolicyTable::PolicyTable( const ApplicationPoliciesSection& app_policies_section, const FunctionalGroupings& functional_groupings, const ConsumerFriendlyMessages& consumer_friendly_messages, - const ModuleConfig& module_config) + const ModuleConfig& module_config, + const InterruptManagerConfig& interrupt_manager_config) : CompositeType(kUninitialized) , app_policies_section(app_policies_section) , functional_groupings(functional_groupings) , consumer_friendly_messages(consumer_friendly_messages) - , module_config(module_config) {} + , module_config(module_config) + , interrupt_manager_config(interrupt_manager_config) {} PolicyTable::~PolicyTable() {} @@ -2189,7 +2286,8 @@ PolicyTable::PolicyTable(const Json::Value* value__) , usage_and_error_counts( impl::ValueMember(value__, "usage_and_error_counts")) , device_data(impl::ValueMember(value__, "device_data")) - , vehicle_data(impl::ValueMember(value__, "vehicle_data")) {} + , vehicle_data(impl::ValueMember(value__, "vehicle_data")) + , interrupt_manager_config(impl::ValueMember(value__, "interrupt_manager_config")){} Json::Value PolicyTable::ToJsonValue() const { Json::Value result__(Json::objectValue); @@ -2203,6 +2301,7 @@ Json::Value PolicyTable::ToJsonValue() const { "usage_and_error_counts", usage_and_error_counts, &result__); impl::WriteJsonField("device_data", device_data, &result__); impl::WriteJsonField("vehicle_data", vehicle_data, &result__); + impl::WriteJsonField("interrupt_manager_config", interrupt_manager_config, &result__); return result__; } @@ -2231,6 +2330,9 @@ bool PolicyTable::is_valid() const { if (!vehicle_data.is_valid()) { return false; } + if (!interrupt_manager_config.is_valid()) { + return false; + } return Validate(); } @@ -2266,6 +2368,9 @@ bool PolicyTable::struct_empty() const { if (vehicle_data.is_initialized()) { return false; } + if (interrupt_manager_config.is_initialized()) { + return false; + } return true; } @@ -2311,6 +2416,9 @@ void PolicyTable::ReportErrors(rpc::ValidationReport* report__) const { if (!vehicle_data.is_valid()) { vehicle_data.ReportErrors(&report__->ReportSubobject("vehicle_data")); } + if (!interrupt_manager_config.is_valid()) { + interrupt_manager_config.ReportErrors(&report__->ReportSubobject("interrupt_manager_config")); + } } void PolicyTable::SetPolicyTableType(PolicyTableType pt_type) { @@ -2323,6 +2431,7 @@ void PolicyTable::SetPolicyTableType(PolicyTableType pt_type) { usage_and_error_counts.SetPolicyTableType(pt_type); device_data.SetPolicyTableType(pt_type); vehicle_data.SetPolicyTableType(pt_type); + interrupt_manager_config.SetPolicyTableType(pt_type); } // Table methods diff --git a/src/components/policy/policy_regular/src/policy_table/validation.cc b/src/components/policy/policy_regular/src/policy_table/validation.cc index dbc44f01ab6..17d6b5c2284 100644 --- a/src/components/policy/policy_regular/src/policy_table/validation.cc +++ b/src/components/policy/policy_regular/src/policy_table/validation.cc @@ -234,6 +234,10 @@ bool ModuleConfig::Validate() const { return true; } +bool InterruptManagerConfig::Validate() const { + return true; +} + bool MessageString::Validate() const { return true; } diff --git a/src/components/policy/policy_regular/src/sql_pt_queries.cc b/src/components/policy/policy_regular/src/sql_pt_queries.cc index 6e0bfd8c897..e3f0df15c57 100644 --- a/src/components/policy/policy_regular/src/sql_pt_queries.cc +++ b/src/components/policy/policy_regular/src/sql_pt_queries.cc @@ -468,6 +468,39 @@ const std::string kCreateSchema = " FOREIGN KEY(`param_name`, `param_key`) " " REFERENCES `vehicle_data_item_definition`(`name`, `key`) " "); " + "CREATE TABLE IF NOT EXISTS `rpc_priority`( " + " `priority_value` VARCHAR(45) PRIMARY KEY NOT NULL, " + " `value` INTEGER NOT NULL, " + " CONSTRAINT `fk_rpc_priority_priority1` " + " FOREIGN KEY(`priority_value`) " + " REFERENCES `priority`(`value`) " + "); " + "CREATE INDEX IF NOT EXISTS " + "`rpc_priority.fk_rpc_priority_" + "priority1_idx` " + " ON `rpc_priority`(`priority_value`); " + "CREATE TABLE IF NOT EXISTS `app_priority`( " + " `priority_value` VARCHAR(45) PRIMARY KEY NOT NULL, " + " `value` INTEGER NOT NULL, " + " CONSTRAINT `fk_app_priority_priority1` " + " FOREIGN KEY(`priority_value`) " + " REFERENCES `priority`(`value`) " + "); " + "CREATE INDEX IF NOT EXISTS " + "`app_priority.fk_app_priority_" + "priority1_idx` " + " ON `app_priority`(`priority_value`); " + "CREATE TABLE IF NOT EXISTS `hmi_status_priority`( " + " `priority_value` VARCHAR(45) PRIMARY KEY NOT NULL, " + " `value` INTEGER NOT NULL, " + " CONSTRAINT `fk_hmi_status_priority_priority1` " + " FOREIGN KEY(`priority_value`) " + " REFERENCES `priority`(`value`) " + "); " + "CREATE INDEX IF NOT EXISTS " + "`hmi_status_priority.fk_hmi_status_priority_" + "priority1_idx` " + " ON `hmi_status_priority`(`priority_value`); " "COMMIT;"; const std::string kInsertInitData = @@ -619,6 +652,19 @@ const std::string kDropSchema = "DROP TABLE IF EXISTS `vehicle_data`; " "DROP TABLE IF EXISTS `vehicle_data_item_definition`; " "DROP TABLE IF EXISTS `vehicle_data_item_parameters`; " + "DROP INDEX IF EXISTS " + "`rpc_priority.fk_rpc_priority_" + "priority1_idx`; " + "DROP TABLE IF EXISTS `rpc_priority`; " + "DROP INDEX IF EXISTS " + "`app_priority.fk_app_priority_" + "priority1_idx`; " + "DROP TABLE IF EXISTS `app_priority`; " + "DROP INDEX IF EXISTS " + "`hmi_status_priority.fk_hmi_status_priority_" + "priority1_idx`; " + "DROP TABLE IF EXISTS `hmi_status_priority`; " + "DROP TABLE IF EXISTS `interrupt_manager_config`; " "COMMIT; " "VACUUM;"; @@ -655,6 +701,9 @@ const std::string kDeleteData = "DELETE FROM `vehicle_data`; " "DELETE FROM `vehicle_data_item_definition`; " "DELETE FROM `vehicle_data_item_parameters`; " + "DELETE FROM `rpc_priority`; " + "DELETE FROM `app_priority`; " + "DELETE FROM `hmi_status_priority`; " "COMMIT; " "VACUUM;"; @@ -1087,5 +1136,41 @@ const std::string kUpdateMetaParams = const std::string kUpdateMetaHardwareVersion = "UPDATE `module_meta` SET `hardware_version` = ? "; + +const std::string kSelectInterruptManagerConfig = + "SELECT `rpc_priority`, `app_priority`, " + " `hmi_status_priority`, " + " FROM `interrupt_manager_config`"; + +const std::string kUpdateInterruptManagerConfig = + "UPDATE `interrupt_manager_config` SET `rpc_priority` = ?, " + " `app_priority` = ?," + " `hmi_status_priority` = ? "; + +const std::string kInsertInterruptManagerConfig = + "INSERT INTO `interrupt_manager_config` (`rpc_priority`, `app_priority`, " + "`hmi_status_priority`) " + " VALUES (?, ?, ?)"; + +const std::string kSelectRpcPriority = + "SELECT `priority_value`, `value` FROM rpc_priority"; + +const std::string kSelectAppPriority = + "SELECT `priority_value`, `value` FROM app_priority"; + +const std::string kSelectHmiStatusPriority = + "SELECT `priority_value`, `value` FROM hmi_status_priority"; + +const std::string kInsertRpcPriority = + "INSERT OR REPLACE INTO `rpc_priority` (`priority_value`, `value`) " + " VALUES (?, ?)"; + +const std::string kInsertAppPriority = + "INSERT OR REPLACE INTO `app_priority` (`priority_value`, `value`) " + " VALUES (?, ?)"; +const std::string kInsertHmiStatusPriority = + "INSERT OR REPLACE INTO `hmi_status_priority` (`priority_value`, `value`) " + " VALUES (?, ?)"; + } // namespace sql_pt } // namespace policy diff --git a/src/components/policy/policy_regular/src/sql_pt_representation.cc b/src/components/policy/policy_regular/src/sql_pt_representation.cc index 0496896b605..d46e944b763 100644 --- a/src/components/policy/policy_regular/src/sql_pt_representation.cc +++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc @@ -464,6 +464,7 @@ std::shared_ptr SQLPTRepresentation::GenerateSnapshot() rpc::Optional > null_version; table->policy_table.vehicle_data->schema_version = null_version; } + GatherInterruptManagerConfig(&table->policy_table.interrupt_manager_config); return table; } @@ -875,6 +876,48 @@ bool SQLPTRepresentation::GatherVehicleDataItems( return true; } +void SQLPTRepresentation::GatherInterruptManagerConfig( + policy_table::InterruptManagerConfig* config) const { + SDL_LOG_INFO("Gather Configuration Info"); + + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kSelectInterruptManagerConfig) || !query.Next()) { + SDL_LOG_WARN("Incorrect select statement for interrupt manager config"); + } + + utils::dbms::SQLQuery rpc_priority(db()); + if (!rpc_priority.Prepare(sql_pt::kSelectRpcPriority)) { + SDL_LOG_WARN("Incorrect select statement for priority"); + } else { + while (rpc_priority.Next()) { + config->rpc_priority[rpc_priority.GetString(0)] = + rpc_priority.GetInteger(1); + } + } + SDL_LOG_INFO("rpc_priority.GetString(0) :" << rpc_priority.GetString(0)); + SDL_LOG_INFO("rpc_priority.GetInteger(1) :" << rpc_priority.GetInteger(1)); + + utils::dbms::SQLQuery app_priority(db()); + if (!app_priority.Prepare(sql_pt::kSelectAppPriority)) { + SDL_LOG_WARN("Incorrect select statement for priority"); + } else { + while (app_priority.Next()) { + config->app_priority[app_priority.GetString(0)] = + app_priority.GetInteger(1); + } + } + + utils::dbms::SQLQuery hmi_status_priority(db()); + if (!hmi_status_priority.Prepare(sql_pt::kSelectRpcPriority)) { + SDL_LOG_WARN("Incorrect select statement for priority"); + } else { + while (hmi_status_priority.Next()) { + config->hmi_status_priority[hmi_status_priority.GetString(0)] = + hmi_status_priority.GetInteger(1); + } + } +} + bool SQLPTRepresentation::Save(const policy_table::Table& table) { SDL_LOG_AUTO_TRACE(); db_->BeginTransaction(); @@ -2834,4 +2877,91 @@ bool SQLPTRepresentation::DeleteVehicleDataItems() const { return true; } +bool SQLPTRepresentation::SaveInterruptManagerConfig( + const policy_table::InterruptManagerConfig& config) { + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kInsertInterruptManagerConfig)) { + SDL_LOG_WARN("Incorrect update statement for InterruptManager config"); + return false; + } + + if (!query.Exec()) { + SDL_LOG_WARN("Incorrect update InterruptManager config"); + return false; + } + + if (!SaveRpcPriority(config.rpc_priority)) { + return false; + } + + if (!SaveAppPriority(config.app_priority)) { + return false; + } + + if (!SaveHmiStatusPriority(config.hmi_status_priority)) { + return false; + } + return true; +} + +bool SQLPTRepresentation::SaveRpcPriority( + const policy_table::rpc_priority_type& priority) { + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kInsertRpcPriority)) { + SDL_LOG_WARN("Incorrect insert statement for rpc priority."); + return false; + } + + policy_table::rpc_priority_type::const_iterator it; + for (it = priority.begin(); it != priority.end(); ++it) { + query.Bind(0, it->first); + query.Bind(1, it->second); + if (!query.Exec() || !query.Reset()) { + SDL_LOG_WARN("Incorrect insert into rpc priority."); + return false; + } + } + return true; +} + +bool SQLPTRepresentation::SaveAppPriority( + const policy_table::app_priority_type& priority) { + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kInsertAppPriority)) { + SDL_LOG_WARN("Incorrect insert statement for rpc priority."); + return false; + } + + policy_table::app_priority_type::const_iterator it; + for (it = priority.begin(); it != priority.end(); ++it) { + query.Bind(0, it->first); + query.Bind(1, it->second); + if (!query.Exec() || !query.Reset()) { + SDL_LOG_WARN("Incorrect insert into rpc priority."); + return false; + } + } + return true; +} + +bool SQLPTRepresentation::SaveHmiStatusPriority( + const policy_table::hmi_status_priority_type& priority) { + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kInsertRpcPriority)) { + SDL_LOG_WARN("Incorrect insert statement for rpc priority."); + return false; + } + + policy_table::hmi_status_priority_type::const_iterator it; + for (it = priority.begin(); it != priority.end(); ++it) { + query.Bind(0, it->first); + query.Bind(1, it->second); + if (!query.Exec() || !query.Reset()) { + SDL_LOG_WARN("Incorrect insert into rpc priority."); + return false; + } + } + return true; +} + } // namespace policy diff --git a/src/components/policy/policy_regular/test/json/sdl_preloaded_pt_for_merge_initial.json b/src/components/policy/policy_regular/test/json/sdl_preloaded_pt_for_merge_initial.json index 066ed867271..9c71de360ce 100644 --- a/src/components/policy/policy_regular/test/json/sdl_preloaded_pt_for_merge_initial.json +++ b/src/components/policy/policy_regular/test/json/sdl_preloaded_pt_for_merge_initial.json @@ -2282,6 +2282,31 @@ "preloaded_pt" : true, "seconds_between_retries" : [ 1, 5, 25, 125, 625 ], "timeout_after_x_seconds" : 60 + }, + "interrupt_manager_config": { + "rpc_priority":{ + "DialNumber": 1, + "Alert": 2, + "PerformAudioPassThru": 2, + "PerformInteraction": 3, + "ScrollableMessage": 3, + "Slider": 3, + "Speak": 3 + }, + "app_priority":{ + "EMERGENCY": 0, + "NAVIGATION": 1, + "VOICE_COMMUNICATION": 2, + "COMMUNICATION": 3, + "NORMAL": 4, + "NONE": 5 + }, + "hmi_status_priority":{ + "FULL": 1, + "LIMITED": 2, + "BACKGROUND": 3, + "NONE": 4 + } } } } diff --git a/src/components/policy/policy_regular/test/json/sdl_preloaded_pt_for_merge_latest.json b/src/components/policy/policy_regular/test/json/sdl_preloaded_pt_for_merge_latest.json index 43c16f18b8e..ecbdd289ba9 100644 --- a/src/components/policy/policy_regular/test/json/sdl_preloaded_pt_for_merge_latest.json +++ b/src/components/policy/policy_regular/test/json/sdl_preloaded_pt_for_merge_latest.json @@ -2282,6 +2282,31 @@ "preloaded_pt" : true, "seconds_between_retries" : [ 1, 5, 25, 125, 625 ], "timeout_after_x_seconds" : 60 + }, + "interrupt_manager_config": { + "rpc_priority":{ + "DialNumber": 1, + "Alert": 2, + "PerformAudioPassThru": 2, + "PerformInteraction": 3, + "ScrollableMessage": 3, + "Slider": 3, + "Speak": 3 + }, + "app_priority":{ + "EMERGENCY": 0, + "NAVIGATION": 1, + "VOICE_COMMUNICATION": 2, + "COMMUNICATION": 3, + "NORMAL": 4, + "NONE": 5 + }, + "hmi_status_priority":{ + "FULL": 1, + "LIMITED": 2, + "BACKGROUND": 3, + "NONE": 4 + } } } } diff --git a/src/components/policy/policy_regular/test/sql_pt_representation_test.cc b/src/components/policy/policy_regular/test/sql_pt_representation_test.cc index d0044c7b757..60089bbf76d 100644 --- a/src/components/policy/policy_regular/test/sql_pt_representation_test.cc +++ b/src/components/policy/policy_regular/test/sql_pt_representation_test.cc @@ -457,8 +457,8 @@ TEST_F(SQLPTRepresentationTest, ASSERT_TRUE(reps->RefreshDB()); // Check PT structure destroyed and tables number is 0 - // There are 38 tables in the database, now. - const int32_t total_tables_number = 38; + // There are 41 tables in the database, now. + const int32_t total_tables_number = 41; ASSERT_EQ(total_tables_number, FetchOneInt(query_select)); const std::string query_select_count_of_iap_buffer_full = From 2f926f235ff139740b5eb16f7661b952a9723d32 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 10 Nov 2021 14:41:09 +0900 Subject: [PATCH 2/4] Add modified files. --- .../src/commands/command_request_impl.cc | 2 ++ .../include/application_manager/application_manager.h | 7 +++++++ .../policies/policy_handler_interface.h | 4 ++++ .../include/policy/policy_external/policy/policy_manager.h | 4 ++++ .../policy/policy_external/policy/policy_settings.h | 2 ++ .../include/policy/policy_regular/policy/policy_manager.h | 4 ++++ .../include/policy/policy_regular/policy/policy_settings.h | 2 ++ .../test/application_manager/mock_application_manager.h | 3 +++ .../policies/mock_policy_handler_interface.h | 4 ++++ .../policy/policy_external/policy/mock_cache_manager.h | 5 +++++ .../policy/policy_external/policy/mock_policy_manager.h | 5 +++++ .../policy/policy_external/policy/mock_policy_settings.h | 1 + .../test/policy/policy_regular/policy/mock_cache_manager.h | 5 +++++ .../policy/policy_regular/policy/mock_policy_manager.h | 5 +++++ .../policy/policy_regular/policy/mock_policy_settings.h | 1 + 15 files changed, 54 insertions(+) diff --git a/src/components/application_manager/src/commands/command_request_impl.cc b/src/components/application_manager/src/commands/command_request_impl.cc index 2929144883d..9de3c3b65ac 100644 --- a/src/components/application_manager/src/commands/command_request_impl.cc +++ b/src/components/application_manager/src/commands/command_request_impl.cc @@ -216,5 +216,7 @@ void CommandRequestImpl::set_current_state( current_state_ = state; } +void CommandRequestImpl::Reject() {} + } // namespace commands } // namespace application_manager diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h index 5fd9be2a66e..7047663b025 100644 --- a/src/components/include/application_manager/application_manager.h +++ b/src/components/include/application_manager/application_manager.h @@ -53,6 +53,8 @@ #include "application_manager/state_controller.h" #include "policy/policy_types.h" +#include "application_manager/interrupt_manager.h" + namespace app_launch { class AppLaunchCtrl; } // namespace app_launch @@ -89,6 +91,9 @@ class RPCService; namespace rpc_handler { class RPCHandler; } +namespace interrupt_manager { +class InterruptManager; +} namespace request_controller { class RequestTimeoutHandler; class RequestController; @@ -1019,6 +1024,8 @@ class ApplicationManager { * @param corr_id Correlation id */ virtual void DeleteExpiredButtonRequest(const int32_t corr_id) = 0; + + virtual interrupt_manager::InterruptManager& GetInterruptManager() const = 0; }; } // namespace application_manager diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h index d79c059b342..8d4aab45bcd 100644 --- a/src/components/include/application_manager/policies/policy_handler_interface.h +++ b/src/components/include/application_manager/policies/policy_handler_interface.h @@ -806,6 +806,10 @@ class PolicyHandlerInterface : public VehicleDataItemProvider { */ virtual void TriggerPTUOnStartupIfRequired() = 0; + virtual rpc::policy_table_interface_base::rpc_priority_type GetRpcPriority() const = 0; + virtual rpc::policy_table_interface_base::app_priority_type GetAppPriority() const = 0; + virtual rpc::policy_table_interface_base::hmi_status_priority_type GetHmiStatusPriority() const = 0; + private: /** * @brief Processes data received via OnAppPermissionChanged notification diff --git a/src/components/include/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h index 5d57d5ca45c..a9619788cff 100644 --- a/src/components/include/policy/policy_external/policy/policy_manager.h +++ b/src/components/include/policy/policy_external/policy/policy_manager.h @@ -867,6 +867,10 @@ class PolicyManager : public usage_statistics::StatisticsManager, */ virtual void TriggerPTUOnStartupIfRequired() = 0; + virtual rpc::policy_table_interface_base::rpc_priority_type GetRpcPriority() const = 0; + virtual rpc::policy_table_interface_base::app_priority_type GetAppPriority() const = 0; + virtual rpc::policy_table_interface_base::hmi_status_priority_type GetHmiStatusPriority() const = 0; + protected: /** * @brief Checks is PT exceeded IgnitionCycles diff --git a/src/components/include/policy/policy_external/policy/policy_settings.h b/src/components/include/policy/policy_external/policy/policy_settings.h index d9d2493d101..8c230870c33 100644 --- a/src/components/include/policy/policy_external/policy/policy_settings.h +++ b/src/components/include/policy/policy_external/policy/policy_settings.h @@ -38,6 +38,8 @@ class PolicySettings { */ virtual const std::string& system_files_path() const = 0; + virtual bool enable_rpc_conflict_manager() const = 0; + virtual ~PolicySettings() {} }; } // namespace policy diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h index b4043067ab7..542ee20be2d 100644 --- a/src/components/include/policy/policy_regular/policy/policy_manager.h +++ b/src/components/include/policy/policy_regular/policy/policy_manager.h @@ -832,6 +832,10 @@ class PolicyManager : public usage_statistics::StatisticsManager, */ virtual void TriggerPTUOnStartupIfRequired() = 0; + virtual rpc::policy_table_interface_base::rpc_priority_type GetRpcPriority() const = 0; + virtual rpc::policy_table_interface_base::app_priority_type GetAppPriority() const = 0; + virtual rpc::policy_table_interface_base::hmi_status_priority_type GetHmiStatusPriority() const = 0; + protected: /** * @brief Checks is PT exceeded IgnitionCycles diff --git a/src/components/include/policy/policy_regular/policy/policy_settings.h b/src/components/include/policy/policy_regular/policy/policy_settings.h index 3529a32717d..206d7ac6a61 100644 --- a/src/components/include/policy/policy_regular/policy/policy_settings.h +++ b/src/components/include/policy/policy_regular/policy/policy_settings.h @@ -38,6 +38,8 @@ class PolicySettings { virtual bool use_full_app_id() const = 0; + virtual bool enable_rpc_conflict_manager() const = 0; + virtual ~PolicySettings() {} }; } // namespace policy diff --git a/src/components/include/test/application_manager/mock_application_manager.h b/src/components/include/test/application_manager/mock_application_manager.h index ef0f20ac65b..c1726793bbe 100644 --- a/src/components/include/test/application_manager/mock_application_manager.h +++ b/src/components/include/test/application_manager/mock_application_manager.h @@ -417,6 +417,9 @@ class MockApplicationManager : public application_manager::ApplicationManager { utils::Optional( const int32_t corr_id)); MOCK_METHOD1(DeleteExpiredButtonRequest, void(const int32_t corr_id)); + + MOCK_CONST_METHOD0(GetInterruptManager, + application_manager::interrupt_manager::InterruptManager&()); }; } // namespace application_manager_test diff --git a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h index ca5d25ed4c3..e403fad71f3 100644 --- a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h +++ b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h @@ -354,6 +354,10 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { MOCK_CONST_METHOD0(OnSystemRequestReceived, void()); + MOCK_CONST_METHOD0(GetRpcPriority, rpc::policy_table_interface_base::rpc_priority_type()); + MOCK_CONST_METHOD0(GetAppPriority, rpc::policy_table_interface_base::app_priority_type()); + MOCK_CONST_METHOD0(GetHmiStatusPriority, rpc::policy_table_interface_base::hmi_status_priority_type()); + private: #ifdef EXTERNAL_PROPRIETARY_MODE MOCK_METHOD3(OnAppPermissionConsentInternal, diff --git a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h index a79918cc395..4645cbf9e9f 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h @@ -314,6 +314,11 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface { void(const std::string& application_name, policy_table::ApplicationParams& application_params)); MOCK_CONST_METHOD0(GetPolicyAppIDs, const policy_table::Strings()); + + MOCK_CONST_METHOD0(GetRpcPriority, rpc::policy_table_interface_base::rpc_priority_type()); + MOCK_CONST_METHOD0(GetAppPriority, rpc::policy_table_interface_base::app_priority_type()); + MOCK_CONST_METHOD0(GetHmiStatusPriority, rpc::policy_table_interface_base::hmi_status_priority_type()); + }; } // namespace policy_test diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h index 22ab31307a4..54d68a87503 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h @@ -311,6 +311,11 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD0(ResetTimeout, void()); MOCK_CONST_METHOD0(GetCCPUVersionFromPT, std::string()); MOCK_CONST_METHOD0(GetHardwareVersionFromPT, std::string()); + + MOCK_CONST_METHOD0(GetRpcPriority, rpc::policy_table_interface_base::rpc_priority_type()); + MOCK_CONST_METHOD0(GetAppPriority, rpc::policy_table_interface_base::app_priority_type()); + MOCK_CONST_METHOD0(GetHmiStatusPriority, rpc::policy_table_interface_base::hmi_status_priority_type()); + }; } // namespace policy_manager_test } // namespace components diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_settings.h b/src/components/include/test/policy/policy_external/policy/mock_policy_settings.h index 16239bfb76a..f5b7ea42000 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_policy_settings.h +++ b/src/components/include/test/policy/policy_external/policy/mock_policy_settings.h @@ -50,6 +50,7 @@ class MockPolicySettings : public ::policy::PolicySettings { MOCK_CONST_METHOD0(policies_snapshot_file_name, const std::string&()); MOCK_CONST_METHOD0(system_files_path, const std::string&()); MOCK_CONST_METHOD0(use_full_app_id, bool()); + MOCK_CONST_METHOD0(enable_rpc_conflict_manager, bool()); }; } // namespace policy_handler_test diff --git a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h index 716f66f994c..be3ee98e04b 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h @@ -275,6 +275,11 @@ class MockCacheManagerInterface : public CacheManagerInterface { void(const std::string& application_name, policy_table::ApplicationParams& application_params)); MOCK_CONST_METHOD0(GetPolicyAppIDs, const policy_table::Strings()); + + MOCK_CONST_METHOD0(GetRpcPriority, rpc::policy_table_interface_base::rpc_priority_type()); + MOCK_CONST_METHOD0(GetAppPriority, rpc::policy_table_interface_base::app_priority_type()); + MOCK_CONST_METHOD0(GetHmiStatusPriority, rpc::policy_table_interface_base::hmi_status_priority_type()); + }; } // namespace policy_test diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h index 076f0423ef0..99649ac68d0 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h @@ -313,6 +313,11 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD0(ResetTimeout, void()); MOCK_CONST_METHOD0(GetCCPUVersionFromPT, std::string()); MOCK_CONST_METHOD0(GetHardwareVersionFromPT, std::string()); + + MOCK_CONST_METHOD0(GetRpcPriority, rpc::policy_table_interface_base::rpc_priority_type()); + MOCK_CONST_METHOD0(GetAppPriority, rpc::policy_table_interface_base::app_priority_type()); + MOCK_CONST_METHOD0(GetHmiStatusPriority, rpc::policy_table_interface_base::hmi_status_priority_type()); + }; } // namespace policy_manager_test diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_settings.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_settings.h index 26c5572d990..b66ba3ada48 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_policy_settings.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_settings.h @@ -50,6 +50,7 @@ class MockPolicySettings : public ::policy::PolicySettings { MOCK_CONST_METHOD0(policies_snapshot_file_name, const std::string&()); MOCK_CONST_METHOD0(system_files_path, const std::string&()); MOCK_CONST_METHOD0(use_full_app_id, bool()); + MOCK_CONST_METHOD0(enable_rpc_conflict_manager, bool()); }; } // namespace policy_handler_test From 7cc93e18869c4cfbeb8a6b6e67ffa40122360c58 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 3 Dec 2021 17:11:04 +0900 Subject: [PATCH 3/4] Modify files --- .../include/policy/sql_pt_queries.h | 3 --- .../policy_external/src/sql_pt_queries.cc | 1 - .../src/sql_pt_representation.cc | 16 +------------- .../test/sql_pt_representation_test.cc | 4 ++-- .../include/policy/sql_pt_queries.h | 3 --- .../policy_regular/src/sql_pt_queries.cc | 16 -------------- .../src/sql_pt_representation.cc | 22 ++++++------------- 7 files changed, 10 insertions(+), 55 deletions(-) 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 76a7084e8f9..a613fd77856 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 @@ -157,9 +157,6 @@ extern const std::string kSelectVehicleDataSchemaVersion; extern const std::string kInsertVehicleDataSchemaVersion; extern const std::string kSelectEndpointProperties; extern const std::string kInsertEndpointVersion; -extern const std::string kSelectInterruptManagerConfig; -extern const std::string kUpdateInterruptManagerConfig; -extern const std::string kInsertInterruptManagerConfig; extern const std::string kSelectRpcPriority; extern const std::string kSelectAppPriority; extern const std::string kSelectHmiStatusPriority; 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 05754f417e2..61081636943 100644 --- a/src/components/policy/policy_external/src/sql_pt_queries.cc +++ b/src/components/policy/policy_external/src/sql_pt_queries.cc @@ -699,7 +699,6 @@ const std::string kDropSchema = "`hmi_status_priority.fk_hmi_status_priority_" "priority1_idx`; " "DROP TABLE IF EXISTS `hmi_status_priority`; " - "DROP TABLE IF EXISTS `interrupt_manager_config`; " "COMMIT; " "VACUUM;"; 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 e254d744f14..13b4f1689dd 100644 --- a/src/components/policy/policy_external/src/sql_pt_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_representation.cc @@ -873,11 +873,6 @@ void SQLPTRepresentation::GatherInterruptManagerConfig( policy_table::InterruptManagerConfig* config) const { SDL_LOG_INFO("Gather Configuration Info"); - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt::kSelectInterruptManagerConfig) || !query.Next()) { - SDL_LOG_WARN("Incorrect select statement for interrupt manager config"); - } - utils::dbms::SQLQuery rpc_priority(db()); if (!rpc_priority.Prepare(sql_pt::kSelectRpcPriority)) { SDL_LOG_WARN("Incorrect select statement for priority"); @@ -2897,16 +2892,7 @@ bool SQLPTRepresentation::SaveExternalConsentEntities( bool SQLPTRepresentation::SaveInterruptManagerConfig( const policy_table::InterruptManagerConfig& config) { - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt::kInsertInterruptManagerConfig)) { - SDL_LOG_WARN("Incorrect update statement for InterruptManager config"); - return false; - } - - if (!query.Exec()) { - SDL_LOG_WARN("Incorrect update InterruptManager config"); - return false; - } + SDL_LOG_AUTO_TRACE(); if (!SaveRpcPriority(config.rpc_priority)) { return false; 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 90479498603..d0201acbd81 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 @@ -353,8 +353,8 @@ TEST_F(SQLPTRepresentationTest, query.Prepare(query_select); query.Next(); - // 42 - is current total tables number created by schema - const int policy_tables_number = 42; + // 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 = diff --git a/src/components/policy/policy_regular/include/policy/sql_pt_queries.h b/src/components/policy/policy_regular/include/policy/sql_pt_queries.h index a375d33139d..42855f33d21 100644 --- a/src/components/policy/policy_regular/include/policy/sql_pt_queries.h +++ b/src/components/policy/policy_regular/include/policy/sql_pt_queries.h @@ -159,9 +159,6 @@ extern const std::string kSelectVehicleDataSchemaVersion; extern const std::string kInsertVehicleDataSchemaVersion; extern const std::string kSelectEndpointProperties; extern const std::string kInsertEndpointVersion; -extern const std::string kSelectInterruptManagerConfig; -extern const std::string kUpdateInterruptManagerConfig; -extern const std::string kInsertInterruptManagerConfig; extern const std::string kSelectRpcPriority; extern const std::string kSelectAppPriority; extern const std::string kSelectHmiStatusPriority; diff --git a/src/components/policy/policy_regular/src/sql_pt_queries.cc b/src/components/policy/policy_regular/src/sql_pt_queries.cc index e3f0df15c57..afcd8dc7fa3 100644 --- a/src/components/policy/policy_regular/src/sql_pt_queries.cc +++ b/src/components/policy/policy_regular/src/sql_pt_queries.cc @@ -664,7 +664,6 @@ const std::string kDropSchema = "`hmi_status_priority.fk_hmi_status_priority_" "priority1_idx`; " "DROP TABLE IF EXISTS `hmi_status_priority`; " - "DROP TABLE IF EXISTS `interrupt_manager_config`; " "COMMIT; " "VACUUM;"; @@ -1137,21 +1136,6 @@ const std::string kUpdateMetaParams = const std::string kUpdateMetaHardwareVersion = "UPDATE `module_meta` SET `hardware_version` = ? "; -const std::string kSelectInterruptManagerConfig = - "SELECT `rpc_priority`, `app_priority`, " - " `hmi_status_priority`, " - " FROM `interrupt_manager_config`"; - -const std::string kUpdateInterruptManagerConfig = - "UPDATE `interrupt_manager_config` SET `rpc_priority` = ?, " - " `app_priority` = ?," - " `hmi_status_priority` = ? "; - -const std::string kInsertInterruptManagerConfig = - "INSERT INTO `interrupt_manager_config` (`rpc_priority`, `app_priority`, " - "`hmi_status_priority`) " - " VALUES (?, ?, ?)"; - const std::string kSelectRpcPriority = "SELECT `priority_value`, `value` FROM rpc_priority"; diff --git a/src/components/policy/policy_regular/src/sql_pt_representation.cc b/src/components/policy/policy_regular/src/sql_pt_representation.cc index d46e944b763..abcc489adf3 100644 --- a/src/components/policy/policy_regular/src/sql_pt_representation.cc +++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc @@ -879,11 +879,6 @@ bool SQLPTRepresentation::GatherVehicleDataItems( void SQLPTRepresentation::GatherInterruptManagerConfig( policy_table::InterruptManagerConfig* config) const { SDL_LOG_INFO("Gather Configuration Info"); - - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt::kSelectInterruptManagerConfig) || !query.Next()) { - SDL_LOG_WARN("Incorrect select statement for interrupt manager config"); - } utils::dbms::SQLQuery rpc_priority(db()); if (!rpc_priority.Prepare(sql_pt::kSelectRpcPriority)) { @@ -956,6 +951,11 @@ bool SQLPTRepresentation::Save(const policy_table::Table& table) { db_->RollbackTransaction(); return false; } + if (!SaveInterruptManagerConfig( + table.policy_table.interrupt_manager_config)) { + db_->RollbackTransaction(); + return false; + } db_->CommitTransaction(); return true; } @@ -2879,16 +2879,7 @@ bool SQLPTRepresentation::DeleteVehicleDataItems() const { bool SQLPTRepresentation::SaveInterruptManagerConfig( const policy_table::InterruptManagerConfig& config) { - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt::kInsertInterruptManagerConfig)) { - SDL_LOG_WARN("Incorrect update statement for InterruptManager config"); - return false; - } - - if (!query.Exec()) { - SDL_LOG_WARN("Incorrect update InterruptManager config"); - return false; - } + SDL_LOG_AUTO_TRACE(); if (!SaveRpcPriority(config.rpc_priority)) { return false; @@ -2907,6 +2898,7 @@ bool SQLPTRepresentation::SaveInterruptManagerConfig( bool SQLPTRepresentation::SaveRpcPriority( const policy_table::rpc_priority_type& priority) { utils::dbms::SQLQuery query(db()); + SDL_LOG_AUTO_TRACE(); if (!query.Prepare(sql_pt::kInsertRpcPriority)) { SDL_LOG_WARN("Incorrect insert statement for rpc priority."); return false; From 25bc88ff45bf18519616c14384f5a9b103c49f8b Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 31 Jan 2022 11:12:54 +0900 Subject: [PATCH 4/4] Modify policy table read process. --- src/appMain/sdl_preloaded_pt.json | 2 - .../application_manager/interrupt_manager.h | 2 +- .../src/policies/policy_handler.cc | 26 +- .../test/sdl_pt_update.json | 6 +- .../include/policy/cache_manager.h | 6 +- .../include/policy/policy_table/types.h | 138 +++-- .../include/policy/sql_pt_queries.h | 6 +- .../include/policy/sql_pt_representation.h | 9 +- .../policy_external/src/cache_manager.cc | 89 +++- .../policy_external/src/policy_table/types.cc | 479 ++++++++++++++--- .../src/policy_table/validation.cc | 8 +- .../policy_external/src/sql_pt_queries.cc | 122 +++-- .../src/sql_pt_representation.cc | 174 ++++--- .../sdl_preloaded_pt_for_merge_initial.json | 2 - .../sdl_preloaded_pt_for_merge_latest.json | 4 +- .../include/policy/cache_manager.h | 6 +- .../include/policy/policy_table/types.h | 137 +++-- .../include/policy/sql_pt_queries.h | 6 +- .../include/policy/sql_pt_representation.h | 9 +- .../policy_regular/src/cache_manager.cc | 88 +++- .../policy_regular/src/policy_table/types.cc | 480 +++++++++++++++--- .../src/policy_table/validation.cc | 8 +- .../policy_regular/src/sql_pt_queries.cc | 131 +++-- .../src/sql_pt_representation.cc | 171 ++++--- .../sdl_preloaded_pt_for_merge_initial.json | 4 +- .../sdl_preloaded_pt_for_merge_latest.json | 4 +- 26 files changed, 1626 insertions(+), 491 deletions(-) diff --git a/src/appMain/sdl_preloaded_pt.json b/src/appMain/sdl_preloaded_pt.json index 3429e31b242..517f6f95f10 100644 --- a/src/appMain/sdl_preloaded_pt.json +++ b/src/appMain/sdl_preloaded_pt.json @@ -4614,8 +4614,6 @@ } ] }, - "interrupt_manager_config": - { "rpc_priority": { "DialNumber": 1, diff --git a/src/components/application_manager/include/application_manager/interrupt_manager.h b/src/components/application_manager/include/application_manager/interrupt_manager.h index 9644ecb968a..cbade9fbf36 100644 --- a/src/components/application_manager/include/application_manager/interrupt_manager.h +++ b/src/components/application_manager/include/application_manager/interrupt_manager.h @@ -39,7 +39,7 @@ class InterruptManager void Init(); InterruptCheckResult CheckRpcInterrupt(const std::shared_ptr outgoing_message); - bool DoRpcReject(mobile_apis::FunctionID::eType function_id); + bool DoRpcReject(int32_t function_id); IMStatus GetRunningStatus(); bool ReadInterruptSetting(); bool IsSubjectMessageToPrioritized(std::shared_ptr outgoing_message); diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index a7fcfbea1ba..7f8372f21ab 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -2985,24 +2985,30 @@ void PolicyHandler::OnUpdateHMILevel(const std::string& device_id, UpdateHMILevel(app, level); } -rpc::policy_table_interface_base::rpc_priority_type PolicyHandler::GetRpcPriority() const { +rpc::policy_table_interface_base::rpc_priority_type +PolicyHandler::GetRpcPriority() const { SDL_LOG_AUTO_TRACE(); const auto policy_manager = LoadPolicyManager(); - POLICY_LIB_CHECK_OR_RETURN(policy_manager, rpc::policy_table_interface_base::rpc_priority_type()); + POLICY_LIB_CHECK_OR_RETURN( + policy_manager, rpc::policy_table_interface_base::rpc_priority_type()); return policy_manager->GetRpcPriority(); } -rpc::policy_table_interface_base::app_priority_type PolicyHandler::GetAppPriority() const { - SDL_LOG_AUTO_TRACE(); - const auto policy_manager = LoadPolicyManager(); - POLICY_LIB_CHECK_OR_RETURN(policy_manager, rpc::policy_table_interface_base::app_priority_type()); +rpc::policy_table_interface_base::app_priority_type +PolicyHandler::GetAppPriority() const { + SDL_LOG_AUTO_TRACE(); + const auto policy_manager = LoadPolicyManager(); + POLICY_LIB_CHECK_OR_RETURN( + policy_manager, rpc::policy_table_interface_base::app_priority_type()); return policy_manager->GetAppPriority(); } -rpc::policy_table_interface_base::hmi_status_priority_type PolicyHandler::GetHmiStatusPriority() const { - SDL_LOG_AUTO_TRACE(); - const auto policy_manager = LoadPolicyManager(); - POLICY_LIB_CHECK_OR_RETURN(policy_manager, rpc::policy_table_interface_base::hmi_status_priority_type()); +rpc::policy_table_interface_base::hmi_status_priority_type +PolicyHandler::GetHmiStatusPriority() const { + SDL_LOG_AUTO_TRACE(); + const auto policy_manager = LoadPolicyManager(); + POLICY_LIB_CHECK_OR_RETURN( + policy_manager, rpc::policy_table_interface_base::hmi_status_priority_type()); return policy_manager->GetHmiStatusPriority(); } diff --git a/src/components/application_manager/test/sdl_pt_update.json b/src/components/application_manager/test/sdl_pt_update.json index 91f6234d7fe..a069153a9fa 100644 --- a/src/components/application_manager/test/sdl_pt_update.json +++ b/src/components/application_manager/test/sdl_pt_update.json @@ -1635,7 +1635,7 @@ "vehicle_model" : "E-Tron", "vehicle_year" : "1992" }, - "interrupt_manager_config": { + "rpc_priority":{ "DialNumber": 1, "Alert": 2, @@ -1658,7 +1658,7 @@ "LIMITED": 2, "BACKGROUND": 3, "NONE": 4 - } - } + }, + } } 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 1e273cb66a4..872be3ea532 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager.h +++ b/src/components/policy/policy_external/include/policy/cache_manager.h @@ -1089,7 +1089,11 @@ class CacheManager : public CacheManagerInterface { void MergeVD(const policy_table::PolicyTable& new_pt, policy_table::PolicyTable& pt); - void MergeIMC(const policy_table::PolicyTable& new_pt, + void MergeRPCP(const policy_table::PolicyTable& new_pt, + policy_table::PolicyTable& pt); + void MergeAPPP(const policy_table::PolicyTable& new_pt, + policy_table::PolicyTable& pt); + void MergeHMISP(const policy_table::PolicyTable& new_pt, policy_table::PolicyTable& pt); void InitBackupThread(); 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 a6698377889..2fc06ed20fa 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 @@ -124,9 +124,9 @@ typedef Array, 0, 255> ModuleTypes; typedef AppHMIType AppHmiType; typedef std::vector AppHmiTypes; -typedef Map, 0, 7> rpc_priority_type; -typedef Map, 0, 6> app_priority_type; -typedef Map, 0, 4> hmi_status_priority_type; +typedef std::map rpc_priority_type; +typedef std::map app_priority_type; +typedef std::map hmi_status_priority_type; struct AppServiceHandledRpc : CompositeType { public: @@ -375,6 +375,100 @@ struct EndpointProperty : CompositeType { bool Validate() const; }; +struct RpcPriority : CompositeType { + public: + Integer DialNumber; + Integer Alert; + Integer PerformAudioPassThru; + Integer PerformInteraction; + Integer ScrollableMessage; + Integer Slider; + Integer Speak; + + public: + RpcPriority(); + RpcPriority(uint8_t DialNumber, + uint8_t Alert, + uint8_t PerformAudioPassThru, + uint8_t PerformInteraction, + uint8_t ScrollableMessage, + uint8_t Slider, + uint8_t Speak); + ~RpcPriority(); + + explicit RpcPriority(const Json::Value* value__); + void SafeCopyFrom(const RpcPriority& from); + 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 AppPriority : CompositeType { + public: + Integer EMERGENCY; + Integer NAVIGATION; + Integer VOICE_COMMUNICATION; + Integer COMMUNICATION; + Integer NORMAL; + Integer NONE; + + public: + AppPriority(); + AppPriority(uint8_t EMERGENCY, + uint8_t NAVIGATION, + uint8_t VOICE_COMMUNICATION, + uint8_t COMMUNICATION, + uint8_t NORMAL, + uint8_t NONE); + ~AppPriority(); + + explicit AppPriority(const Json::Value* value__); + void SafeCopyFrom(const AppPriority& from); + 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 HmiStatusPriority : CompositeType { + public: + Integer FULL; + Integer LIMITED; + Integer BACKGROUND; + Integer NONE; + + public: + HmiStatusPriority(); + HmiStatusPriority(uint8_t FULL, + uint8_t LIMITED, + uint8_t BACKGROUND, + uint8_t NONE); + ~HmiStatusPriority(); + + explicit HmiStatusPriority(const Json::Value* value__); + void SafeCopyFrom(const HmiStatusPriority& from); + 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 ModuleConfig : CompositeType { public: Integer exchange_after_x_ignition_cycles; @@ -723,36 +817,6 @@ struct VehicleData : CompositeType { bool Validate() const; }; - -struct InterruptManagerConfig : CompositeType { - public: - rpc_priority_type rpc_priority; - app_priority_type app_priority; - hmi_status_priority_type hmi_status_priority; - - public: - InterruptManagerConfig(); - InterruptManagerConfig(const rpc_priority_type& rpc_priority, - const app_priority_type& app_priority, - const hmi_status_priority_type& hmi_status_priority); - ~InterruptManagerConfig(); - explicit InterruptManagerConfig(const Json::Value* value__); - - void SafeCopyFrom(const InterruptManagerConfig& from); - - 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; @@ -763,7 +827,9 @@ struct PolicyTable : CompositeType { Optional usage_and_error_counts; Optional device_data; Optional vehicle_data; - InterruptManagerConfig interrupt_manager_config; + RpcPriority rpc_priority; + AppPriority app_priority; + HmiStatusPriority hmi_status_priority; public: PolicyTable(); @@ -771,7 +837,9 @@ struct PolicyTable : CompositeType { const FunctionalGroupings& functional_groupings, const ConsumerFriendlyMessages& consumer_friendly_messages, const ModuleConfig& module_config, - const InterruptManagerConfig& interrupt_manager_config); + const RpcPriority& rpc_priority, + const AppPriority& app_priority, + const HmiStatusPriority& hmi_status_priority); ~PolicyTable(); explicit PolicyTable(const Json::Value* value__); Json::Value ToJsonValue() const; 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 a613fd77856..c6515ff3825 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 @@ -157,12 +157,12 @@ extern const std::string kSelectVehicleDataSchemaVersion; extern const std::string kInsertVehicleDataSchemaVersion; extern const std::string kSelectEndpointProperties; extern const std::string kInsertEndpointVersion; +extern const std::string kUpdateRpcPriority; +extern const std::string kUpdateAppPriority; +extern const std::string kUpdateHmiStatusPriority; extern const std::string kSelectRpcPriority; extern const std::string kSelectAppPriority; extern const std::string kSelectHmiStatusPriority; -extern const std::string kInsertRpcPriority; -extern const std::string kInsertAppPriority; -extern const std::string kInsertHmiStatusPriority; } // 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 56f09adf5ec..77bfed324c2 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 @@ -142,7 +142,9 @@ class SQLPTRepresentation : public virtual PTRepresentation { bool GatherNickName(const std::string& app_id, policy_table::Strings* nicknames) const; - virtual void GatherInterruptManagerConfig(policy_table::InterruptManagerConfig* config) const; + virtual void GatherRpcPriority(policy_table::RpcPriority* priority) const; + virtual void GatherAppPriority(policy_table::AppPriority* priority) const; + virtual void GatherHmiStatusPriority(policy_table::HmiStatusPriority* priority) const; virtual bool SaveApplicationCustomData(const std::string& app_id, bool is_revoked, @@ -170,7 +172,10 @@ class SQLPTRepresentation : public virtual PTRepresentation { virtual bool SaveMessageString(const std::string& type, const std::string& lang, const policy_table::MessageString& strings); - virtual bool SaveInterruptManagerConfig(const policy_table::InterruptManagerConfig& config); + + virtual bool SaveRpcPriority(const policy_table::RpcPriority& priority); + virtual bool SaveAppPriority(const policy_table::AppPriority& priority); + virtual bool SaveHmiStatusPriority(const policy_table::HmiStatusPriority& priority); bool SaveAppGroup(const std::string& app_id, const policy_table::Strings& app_groups); diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc index 3e1b108057d..01869f6753a 100644 --- a/src/components/policy/policy_external/src/cache_manager.cc +++ b/src/components/policy/policy_external/src/cache_manager.cc @@ -768,8 +768,14 @@ bool CacheManager::ApplyUpdate(const policy_table::Table& update_pt) { pt_->policy_table.module_config.endpoint_properties = update_pt.policy_table.module_config.endpoint_properties; - pt_->policy_table.interrupt_manager_config.SafeCopyFrom( - update_pt.policy_table.interrupt_manager_config); + pt_->policy_table.rpc_priority.SafeCopyFrom( + update_pt.policy_table.rpc_priority); + + pt_->policy_table.app_priority.SafeCopyFrom( + update_pt.policy_table.app_priority); + + pt_->policy_table.hmi_status_priority.SafeCopyFrom( + update_pt.policy_table.hmi_status_priority); // Apply update for vehicle data if (update_pt.policy_table.vehicle_data.is_initialized()) { @@ -2136,11 +2142,12 @@ std::shared_ptr CacheManager::GenerateSnapshot() { snapshot_->policy_table.vehicle_data->schema_version = pt_->policy_table.vehicle_data->schema_version; } + snapshot_->policy_table.rpc_priority = pt_->policy_table.rpc_priority; + snapshot_->policy_table.app_priority = pt_->policy_table.app_priority; + snapshot_->policy_table.hmi_status_priority = pt_->policy_table.hmi_status_priority; snapshot_->SetPolicyTableType(policy_table::PT_SNAPSHOT); - snapshot_->policy_table.interrupt_manager_config = pt_->policy_table.interrupt_manager_config; - CheckSnapshotInitialization(); return snapshot_; } @@ -3087,7 +3094,9 @@ bool CacheManager::MergePreloadPT(const std::string& file_name) { MergeAP(new_table, current); MergeCFM(new_table, current); MergeVD(new_table, current); - MergeIMC(new_table, current); + MergeRPCP(new_table, current); + MergeAPPP(new_table, current); + MergeHMISP(new_table, current); Backup(); } return true; @@ -3161,10 +3170,25 @@ void CacheManager::MergeVD(const policy_table::PolicyTable& new_pt, pt.vehicle_data.assign_if_valid(new_pt.vehicle_data); } -void CacheManager::MergeIMC(const policy_table::PolicyTable& new_pt, - policy_table::PolicyTable& pt) { +void CacheManager::MergeRPCP(const policy_table::PolicyTable& new_pt, + policy_table::PolicyTable& pt) { + SDL_LOG_AUTO_TRACE(); + policy_table::RpcPriority copy(pt.rpc_priority); + pt.rpc_priority = new_pt.rpc_priority; +} + +void CacheManager::MergeAPPP(const policy_table::PolicyTable& new_pt, + policy_table::PolicyTable& pt) { + SDL_LOG_AUTO_TRACE(); + policy_table::AppPriority copy(pt.app_priority); + pt.app_priority = new_pt.app_priority; +} + +void CacheManager::MergeHMISP(const policy_table::PolicyTable& new_pt, + policy_table::PolicyTable& pt) { SDL_LOG_AUTO_TRACE(); - pt.interrupt_manager_config = new_pt.interrupt_manager_config; + policy_table::HmiStatusPriority copy(pt.hmi_status_priority); + pt.hmi_status_priority = new_pt.hmi_status_priority; } void CacheManager::InitBackupThread() { @@ -3320,20 +3344,57 @@ void CacheManager::GetApplicationParams( rpc::policy_table_interface_base::rpc_priority_type CacheManager::GetRpcPriority() const { SDL_LOG_AUTO_TRACE(); - sync_primitives::AutoLock auto_lock(cache_lock_); - return pt_->policy_table.interrupt_manager_config.rpc_priority; + sync_primitives::AutoLock auto_lock(cache_lock_); + + rpc::policy_table_interface_base::rpc_priority_type rpc_priority_table = {}; + std::string rpcPriority[] = {"DialNumber", + "Alert", + "PerformAudioPassThru", + "PerformInteraction", + "ScrollableMessage", + "Slider", + "Speak"}; + rpc_priority_table[rpcPriority[0]] = pt_->policy_table.rpc_priority.DialNumber; + rpc_priority_table[rpcPriority[1]] = pt_->policy_table.rpc_priority.Alert; + rpc_priority_table[rpcPriority[2]] = pt_->policy_table.rpc_priority.PerformAudioPassThru; + rpc_priority_table[rpcPriority[3]] = pt_->policy_table.rpc_priority.PerformInteraction; + rpc_priority_table[rpcPriority[4]] = pt_->policy_table.rpc_priority.ScrollableMessage; + rpc_priority_table[rpcPriority[5]] = pt_->policy_table.rpc_priority.Slider; + rpc_priority_table[rpcPriority[6]] = pt_->policy_table.rpc_priority.Speak; + + return rpc_priority_table; } rpc::policy_table_interface_base::app_priority_type CacheManager::GetAppPriority() const { - sync_primitives::AutoLock auto_lock(cache_lock_); - return pt_->policy_table.interrupt_manager_config.app_priority; + SDL_LOG_AUTO_TRACE(); + sync_primitives::AutoLock auto_lock(cache_lock_); + + rpc::policy_table_interface_base::app_priority_type app_priority_table = {}; + std::string appPriority[] = {"EMERGENCY","NAVIGATION","VOICE_COMMUNICATION","COMMUNICATION","NORMAL","NONE"}; + app_priority_table[appPriority[0]] = pt_->policy_table.app_priority.EMERGENCY; + app_priority_table[appPriority[1]] = pt_->policy_table.app_priority.NAVIGATION; + app_priority_table[appPriority[2]] = pt_->policy_table.app_priority.VOICE_COMMUNICATION; + app_priority_table[appPriority[3]] = pt_->policy_table.app_priority.COMMUNICATION; + app_priority_table[appPriority[4]] = pt_->policy_table.app_priority.NORMAL; + app_priority_table[appPriority[5]] = pt_->policy_table.app_priority.NONE; + + return app_priority_table; } rpc::policy_table_interface_base::hmi_status_priority_type CacheManager::GetHmiStatusPriority() const { - sync_primitives::AutoLock auto_lock(cache_lock_); - return pt_->policy_table.interrupt_manager_config.hmi_status_priority; + SDL_LOG_AUTO_TRACE(); + sync_primitives::AutoLock auto_lock(cache_lock_); + + rpc::policy_table_interface_base::app_priority_type hmi_status_priority_table = {}; + std::string hmiStatusPriority[] = {"FULL", "LIMITED", "BACKGROUND", "NONE"}; + hmi_status_priority_table[hmiStatusPriority[0]] = pt_->policy_table.hmi_status_priority.FULL; + hmi_status_priority_table[hmiStatusPriority[1]] = pt_->policy_table.hmi_status_priority.LIMITED; + hmi_status_priority_table[hmiStatusPriority[2]] = pt_->policy_table.hmi_status_priority.BACKGROUND; + hmi_status_priority_table[hmiStatusPriority[3]] = pt_->policy_table.hmi_status_priority.NONE; + + return hmi_status_priority_table; } } // namespace policy 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 10d7c87d561..ee283b11f2e 100644 --- a/src/components/policy/policy_external/src/policy_table/types.cc +++ b/src/components/policy/policy_external/src/policy_table/types.cc @@ -2683,98 +2683,431 @@ void VehicleData::SetPolicyTableType(PolicyTableType pt_type) { schema_items.SetPolicyTableType(pt_type); } -//InterruptManagerConfig methods -InterruptManagerConfig::InterruptManagerConfig() : CompositeType(kUninitialized) {} +//RpcPriority methods + +RpcPriority::RpcPriority() : CompositeType(kUninitialized) {} + + Integer DialNumber; + Integer Alert; + Integer PerformAudioPassThru; + Integer PerformInteraction; + Integer ScrollableMessage; + Integer Slider; + Integer Speak; + +RpcPriority::RpcPriority( + uint8_t DialNumber, + uint8_t Alert, + uint8_t PerformAudioPassThru, + uint8_t PerformInteraction, + uint8_t ScrollableMessage, + uint8_t Slider, + uint8_t Speak) + : CompositeType(kUninitialized) + ,DialNumber(DialNumber) + ,Alert(Alert) + ,PerformAudioPassThru(PerformAudioPassThru) + ,PerformInteraction(PerformInteraction) + ,ScrollableMessage(ScrollableMessage) + ,Slider(Slider) + ,Speak(Speak) + {} + +RpcPriority::~RpcPriority() {} + +RpcPriority::RpcPriority(const Json::Value* value__) + : CompositeType(InitHelper(value__, &Json::Value::isObject)) + , DialNumber(impl::ValueMember(value__, "DialNumber")) + , Alert(impl::ValueMember(value__, "Alert")) + , PerformAudioPassThru(impl::ValueMember(value__, "PerformAudioPassThru")) + , PerformInteraction(impl::ValueMember(value__, "PerformInteraction")) + , ScrollableMessage(impl::ValueMember(value__, "ScrollableMessage")) + , Slider(impl::ValueMember(value__, "Slider")) + , Speak(impl::ValueMember(value__, "Speak")) + {} + +void RpcPriority::SafeCopyFrom(const RpcPriority& from) { + DialNumber = from.DialNumber; + Alert = from.Alert; + PerformAudioPassThru = from.PerformAudioPassThru; + PerformInteraction = from.PerformInteraction; + ScrollableMessage = from.ScrollableMessage; + Slider = from.Slider; + Speak = from.Speak; +} + +Json::Value RpcPriority::ToJsonValue() const { + Json::Value result__(Json::objectValue); + impl::WriteJsonField("DialNumber", DialNumber, &result__); + impl::WriteJsonField("Alert", Alert, &result__); + impl::WriteJsonField("PerformAudioPassThru", PerformAudioPassThru, &result__); + impl::WriteJsonField("PerformInteraction", PerformInteraction, &result__); + impl::WriteJsonField("ScrollableMessage", ScrollableMessage, &result__); + impl::WriteJsonField("Slider", Slider, &result__); + impl::WriteJsonField("Speak", Speak, &result__); + return result__; +} -InterruptManagerConfig::InterruptManagerConfig( - const rpc_priority_type& rpc_priority, - const app_priority_type& app_priority, - const hmi_status_priority_type& hmi_status_priority) - : CompositeType(kUninitialized) - , rpc_priority(rpc_priority) - , app_priority(app_priority) - , hmi_status_priority(hmi_status_priority){} +bool RpcPriority::is_valid() const { + if (!DialNumber.is_valid()) { + return false; + } + if (!Alert.is_valid()) { + return false; + } + if (!PerformAudioPassThru.is_valid()) { + return false; + } + if (!PerformInteraction.is_valid()) { + return false; + } + if (!ScrollableMessage.is_valid()) { + return false; + } + if (!Slider.is_valid()) { + return false; + } + if (!Speak.is_valid()) { + return false; + } + return Validate(); +} -InterruptManagerConfig::~InterruptManagerConfig() {} +bool RpcPriority::is_initialized() const { + return (initialization_state__ != kUninitialized) || (!struct_empty()); +} +bool RpcPriority::struct_empty() const { + if (DialNumber.is_initialized()) { + return false; + } + if (Alert.is_initialized()) { + return false; + } + if (PerformAudioPassThru.is_initialized()) { + return false; + } + if (PerformInteraction.is_initialized()) { + return false; + } + if (ScrollableMessage.is_initialized()) { + return false; + } + if (Slider.is_initialized()) { + return false; + } + if (Speak.is_initialized()) { + return false; + } + return true; +} + +void RpcPriority::ReportErrors(rpc::ValidationReport* report__) const { + if (struct_empty()) { + rpc::CompositeType::ReportErrors(report__); + } + + if (!DialNumber.is_valid()) { + DialNumber.ReportErrors( + &report__->ReportSubobject("DialNumber")); + } + if (!Alert.is_valid()) { + Alert.ReportErrors( + &report__->ReportSubobject("Alert")); + } + if (!PerformAudioPassThru.is_valid()) { + PerformAudioPassThru.ReportErrors( + &report__->ReportSubobject("PerformAudioPassThru")); + } + if (!PerformInteraction.is_valid()) { + PerformInteraction.ReportErrors( + &report__->ReportSubobject("PerformInteraction")); + } + if (!ScrollableMessage.is_valid()) { + ScrollableMessage.ReportErrors( + &report__->ReportSubobject("ScrollableMessage")); + } + if (!Slider.is_valid()) { + Slider.ReportErrors( + &report__->ReportSubobject("Slider")); + } + if (!Speak.is_valid()) { + Speak.ReportErrors( + &report__->ReportSubobject("Speak")); + } +} -InterruptManagerConfig::InterruptManagerConfig(const Json::Value* value__) +void RpcPriority::SetPolicyTableType(PolicyTableType pt_type) { + CompositeType::SetPolicyTableType(pt_type); + DialNumber.SetPolicyTableType(pt_type); + Alert.SetPolicyTableType(pt_type); + PerformAudioPassThru.SetPolicyTableType(pt_type); + PerformInteraction.SetPolicyTableType(pt_type); + ScrollableMessage.SetPolicyTableType(pt_type); + Slider.SetPolicyTableType(pt_type); + Speak.SetPolicyTableType(pt_type); +} + +//AppPriority methods + +AppPriority::AppPriority() : CompositeType(kUninitialized) {} + + Integer EMERGENCY; + Integer NAVIGATION; + Integer VOICE_COMMUNICATION; + Integer COMMUNICATION; + Integer NORMAL; + Integer NONE; + +AppPriority::AppPriority( + uint8_t EMERGENCY, + uint8_t NAVIGATION, + uint8_t VOICE_COMMUNICATION, + uint8_t COMMUNICATION, + uint8_t NORMAL, + uint8_t NONE) + : CompositeType(kUninitialized) + ,EMERGENCY(EMERGENCY) + ,NAVIGATION(NAVIGATION) + ,VOICE_COMMUNICATION(VOICE_COMMUNICATION) + ,COMMUNICATION(COMMUNICATION) + ,NORMAL(NORMAL) + ,NONE(NONE) + {} + +AppPriority::~AppPriority() {} + +AppPriority::AppPriority(const Json::Value* value__) : CompositeType(InitHelper(value__, &Json::Value::isObject)) - , rpc_priority(impl::ValueMember(value__, "rpc_priority")) - , app_priority(impl::ValueMember(value__, "app_priority")) - , hmi_status_priority(impl::ValueMember(value__, "hmi_status_priority")){} + , EMERGENCY(impl::ValueMember(value__, "EMERGENCY")) + , NAVIGATION(impl::ValueMember(value__, "NAVIGATION")) + , VOICE_COMMUNICATION(impl::ValueMember(value__, "VOICE_COMMUNICATION")) + , COMMUNICATION(impl::ValueMember(value__, "COMMUNICATION")) + , NORMAL(impl::ValueMember(value__, "NORMAL")) + , NONE(impl::ValueMember(value__, "NONE")) + {} + +void AppPriority::SafeCopyFrom(const AppPriority& from) { + EMERGENCY = from.EMERGENCY; + NAVIGATION = from.NAVIGATION; + VOICE_COMMUNICATION = from.VOICE_COMMUNICATION; + COMMUNICATION = from.COMMUNICATION; + NORMAL = from.NORMAL; + NONE = from.NONE; +} + +Json::Value AppPriority::ToJsonValue() const { + Json::Value result__(Json::objectValue); + impl::WriteJsonField("EMERGENCY", EMERGENCY, &result__); + impl::WriteJsonField("NAVIGATION", NAVIGATION, &result__); + impl::WriteJsonField("VOICE_COMMUNICATION", VOICE_COMMUNICATION, &result__); + impl::WriteJsonField("COMMUNICATION", COMMUNICATION, &result__); + impl::WriteJsonField("NORMAL", NORMAL, &result__); + impl::WriteJsonField("NONE", NONE, &result__); + return result__; +} +bool AppPriority::is_valid() const { + if (!EMERGENCY.is_valid()) { + return false; + } + if (!NAVIGATION.is_valid()) { + return false; + } + if (!VOICE_COMMUNICATION.is_valid()) { + return false; + } + if (!COMMUNICATION.is_valid()) { + return false; + } + if (!NORMAL.is_valid()) { + return false; + } + if (!NONE.is_valid()) { + return false; + } + return Validate(); +} -void InterruptManagerConfig::SafeCopyFrom(const InterruptManagerConfig& from) { - rpc_priority = from.rpc_priority; - app_priority = from.app_priority; - hmi_status_priority = from.hmi_status_priority; +bool AppPriority::is_initialized() const { + return (initialization_state__ != kUninitialized) || (!struct_empty()); } -Json::Value InterruptManagerConfig::ToJsonValue() const { +bool AppPriority::struct_empty() const { + if (EMERGENCY.is_initialized()) { + return false; + } + if (NAVIGATION.is_initialized()) { + return false; + } + if (VOICE_COMMUNICATION.is_initialized()) { + return false; + } + if (COMMUNICATION.is_initialized()) { + return false; + } + if (NORMAL.is_initialized()) { + return false; + } + if (NONE.is_initialized()) { + return false; + } + return true; +} + +void AppPriority::ReportErrors(rpc::ValidationReport* report__) const { + if (struct_empty()) { + rpc::CompositeType::ReportErrors(report__); + } + + if (!EMERGENCY.is_valid()) { + EMERGENCY.ReportErrors( + &report__->ReportSubobject("EMERGENCY")); + } + if (!NAVIGATION.is_valid()) { + NAVIGATION.ReportErrors( + &report__->ReportSubobject("NAVIGATION")); + } + if (!VOICE_COMMUNICATION.is_valid()) { + VOICE_COMMUNICATION.ReportErrors( + &report__->ReportSubobject("VOICE_COMMUNICATION")); + } + if (!COMMUNICATION.is_valid()) { + COMMUNICATION.ReportErrors( + &report__->ReportSubobject("COMMUNICATION")); + } + if (!NORMAL.is_valid()) { + NORMAL.ReportErrors( + &report__->ReportSubobject("NORMAL")); + } + if (!NONE.is_valid()) { + NONE.ReportErrors( + &report__->ReportSubobject("NONE")); + } +} + +void AppPriority::SetPolicyTableType(PolicyTableType pt_type) { + CompositeType::SetPolicyTableType(pt_type); + EMERGENCY.SetPolicyTableType(pt_type); + NAVIGATION.SetPolicyTableType(pt_type); + VOICE_COMMUNICATION.SetPolicyTableType(pt_type); + COMMUNICATION.SetPolicyTableType(pt_type); + NORMAL.SetPolicyTableType(pt_type); + NONE.SetPolicyTableType(pt_type); +} + +//HmiStatusPriority methods + +HmiStatusPriority::HmiStatusPriority() : CompositeType(kUninitialized) {} + + Integer FULL; + Integer LIMITED; + Integer BACKGROUND; + //Integer NONE; + +HmiStatusPriority::HmiStatusPriority( + uint8_t FULL, + uint8_t LIMITED, + uint8_t BACKGROUND, + uint8_t NONE) + : CompositeType(kUninitialized) + ,FULL(FULL) + ,LIMITED(LIMITED) + ,BACKGROUND(BACKGROUND) + ,NONE(NONE) + {} + +HmiStatusPriority::~HmiStatusPriority() {} + +HmiStatusPriority::HmiStatusPriority(const Json::Value* value__) + : CompositeType(InitHelper(value__, &Json::Value::isObject)) + , FULL(impl::ValueMember(value__, "FULL")) + , LIMITED(impl::ValueMember(value__, "LIMITED")) + , BACKGROUND(impl::ValueMember(value__, "BACKGROUND")) + , NONE(impl::ValueMember(value__, "NONE")) + {} + +void HmiStatusPriority::SafeCopyFrom(const HmiStatusPriority& from) { + FULL = from.FULL; + LIMITED = from.LIMITED; + BACKGROUND = from.BACKGROUND; + NONE = from.NONE; +} + +Json::Value HmiStatusPriority::ToJsonValue() const { Json::Value result__(Json::objectValue); - impl::WriteJsonField("rpc_priority", rpc_priority, &result__); - impl::WriteJsonField("app_priority", app_priority, &result__); - impl::WriteJsonField("hmi_status_priority", hmi_status_priority, &result__); + impl::WriteJsonField("FULL", FULL, &result__); + impl::WriteJsonField("LIMITED", LIMITED, &result__); + impl::WriteJsonField("BACKGROUND", BACKGROUND, &result__); + impl::WriteJsonField("NONE", NONE, &result__); return result__; } - -bool InterruptManagerConfig::is_valid() const { - if (!rpc_priority.is_valid()) { +bool HmiStatusPriority::is_valid() const { + if (!FULL.is_valid()) { return false; } - if (!app_priority.is_valid()) { + if (!LIMITED.is_valid()) { return false; } - if (!hmi_status_priority.is_valid()) { + if (!BACKGROUND.is_valid()) { + return false; + } + if (!NONE.is_valid()) { return false; } return Validate(); } - -bool InterruptManagerConfig::is_initialized() const { +bool HmiStatusPriority::is_initialized() const { return (initialization_state__ != kUninitialized) || (!struct_empty()); } - -bool InterruptManagerConfig::struct_empty() const { - if (!rpc_priority.is_initialized()) { +bool HmiStatusPriority::struct_empty() const { + if (FULL.is_initialized()) { + return false; + } + if (LIMITED.is_initialized()) { return false; } - if (!app_priority.is_initialized()) { + if (BACKGROUND.is_initialized()) { return false; } - if (!hmi_status_priority.is_initialized()) { + if (NONE.is_initialized()) { return false; } return true; } -void InterruptManagerConfig::ReportErrors(rpc::ValidationReport* report__) const { +void HmiStatusPriority::ReportErrors(rpc::ValidationReport* report__) const { if (struct_empty()) { rpc::CompositeType::ReportErrors(report__); } - if (!rpc_priority.is_valid()) { - rpc_priority.ReportErrors( - &report__->ReportSubobject("rpc_priority")); + + if (!FULL.is_valid()) { + FULL.ReportErrors( + &report__->ReportSubobject("FULL")); } - if (!app_priority.is_valid()) { - app_priority.ReportErrors( - &report__->ReportSubobject("app_priority")); + if (!LIMITED.is_valid()) { + LIMITED.ReportErrors( + &report__->ReportSubobject("LIMITED")); } - if (!hmi_status_priority.is_valid()) { - hmi_status_priority.ReportErrors( - &report__->ReportSubobject("hmi_status_priority")); + if (!BACKGROUND.is_valid()) { + BACKGROUND.ReportErrors( + &report__->ReportSubobject("BACKGROUND")); + } + if (!NONE.is_valid()) { + NONE.ReportErrors( + &report__->ReportSubobject("NONE")); } } -void InterruptManagerConfig::SetPolicyTableType(PolicyTableType pt_type) { +void HmiStatusPriority::SetPolicyTableType(PolicyTableType pt_type) { CompositeType::SetPolicyTableType(pt_type); - rpc_priority.SetPolicyTableType(pt_type); - app_priority.SetPolicyTableType(pt_type); - hmi_status_priority.SetPolicyTableType(pt_type); + FULL.SetPolicyTableType(pt_type); + LIMITED.SetPolicyTableType(pt_type); + BACKGROUND.SetPolicyTableType(pt_type); + NONE.SetPolicyTableType(pt_type); } // PolicyTable methods @@ -2785,13 +3118,17 @@ PolicyTable::PolicyTable( const FunctionalGroupings& functional_groupings, const ConsumerFriendlyMessages& consumer_friendly_messages, const ModuleConfig& module_config, - const InterruptManagerConfig& interrupt_manager_config) + const RpcPriority& rpc_priority, + const AppPriority& app_priority, + const HmiStatusPriority& hmi_status_priority) : CompositeType(kUninitialized) , app_policies_section(app_policies_section) , functional_groupings(functional_groupings) , consumer_friendly_messages(consumer_friendly_messages) , module_config(module_config) - , interrupt_manager_config(interrupt_manager_config) {} + , rpc_priority(rpc_priority) + , app_priority(app_priority) + , hmi_status_priority(hmi_status_priority) {} PolicyTable::~PolicyTable() {} @@ -2807,7 +3144,9 @@ PolicyTable::PolicyTable(const Json::Value* value__) impl::ValueMember(value__, "usage_and_error_counts")) , device_data(impl::ValueMember(value__, "device_data")) , vehicle_data(impl::ValueMember(value__, "vehicle_data")) - , interrupt_manager_config(impl::ValueMember(value__, "interrupt_manager_config")){} + , rpc_priority(impl::ValueMember(value__, "rpc_priority")) + , app_priority(impl::ValueMember(value__, "app_priority")) + , hmi_status_priority(impl::ValueMember(value__, "hmi_status_priority")) {} Json::Value PolicyTable::ToJsonValue() const { Json::Value result__(Json::objectValue); @@ -2821,7 +3160,11 @@ Json::Value PolicyTable::ToJsonValue() const { "usage_and_error_counts", usage_and_error_counts, &result__); impl::WriteJsonField("device_data", device_data, &result__); impl::WriteJsonField("vehicle_data", vehicle_data, &result__); - impl::WriteJsonField("interrupt_manager_config", interrupt_manager_config, &result__); + + impl::WriteJsonField("rpc_priority", rpc_priority, &result__); + impl::WriteJsonField("app_priority", app_priority, &result__); + impl::WriteJsonField("hmi_status_priority", hmi_status_priority, &result__); + return result__; } @@ -2850,7 +3193,13 @@ bool PolicyTable::is_valid() const { if (!vehicle_data.is_valid()) { return false; } - if (!interrupt_manager_config.is_valid()) { + if (!rpc_priority.is_valid()) { + return false; + } + if (!app_priority.is_valid()) { + return false; + } + if (!hmi_status_priority.is_valid()) { return false; } return Validate(); @@ -2889,7 +3238,13 @@ bool PolicyTable::struct_empty() const { if (vehicle_data.is_initialized()) { return false; } - if (interrupt_manager_config.is_initialized()) { + if (rpc_priority.is_initialized()) { + return false; + } + if (app_priority.is_initialized()) { + return false; + } + if (hmi_status_priority.is_initialized()) { return false; } return true; @@ -2937,8 +3292,14 @@ void PolicyTable::ReportErrors(rpc::ValidationReport* report__) const { if (!vehicle_data.is_valid()) { vehicle_data.ReportErrors(&report__->ReportSubobject("vehicle_data")); } - if (!interrupt_manager_config.is_valid()) { - interrupt_manager_config.ReportErrors(&report__->ReportSubobject("interrupt_manager_config")); + if (!rpc_priority.is_valid()) { + rpc_priority.ReportErrors(&report__->ReportSubobject("rpc_priority")); + } + if (!app_priority.is_valid()) { + app_priority.ReportErrors(&report__->ReportSubobject("app_priority")); + } + if (!hmi_status_priority.is_valid()) { + hmi_status_priority.ReportErrors(&report__->ReportSubobject("hmi_status_priority")); } } @@ -2952,7 +3313,9 @@ void PolicyTable::SetPolicyTableType(PolicyTableType pt_type) { usage_and_error_counts.SetPolicyTableType(pt_type); device_data.SetPolicyTableType(pt_type); vehicle_data.SetPolicyTableType(pt_type); - interrupt_manager_config.SetPolicyTableType(pt_type); + rpc_priority.SetPolicyTableType(pt_type); + app_priority.SetPolicyTableType(pt_type); + hmi_status_priority.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 947de337f47..e91061edbea 100644 --- a/src/components/policy/policy_external/src/policy_table/validation.cc +++ b/src/components/policy/policy_external/src/policy_table/validation.cc @@ -270,7 +270,13 @@ bool ModuleConfig::Validate() const { return true; } -bool InterruptManagerConfig::Validate() const { +bool RpcPriority::Validate() const { + return true; +} +bool AppPriority::Validate() const { + return true; +} +bool HmiStatusPriority::Validate() const { 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 61081636943..5a5c7e66c1b 100644 --- a/src/components/policy/policy_external/src/sql_pt_queries.cc +++ b/src/components/policy/policy_external/src/sql_pt_queries.cc @@ -501,38 +501,28 @@ const std::string kCreateSchema = " REFERENCES `vehicle_data_item_definition`(`name`, `key`) " "); " "CREATE TABLE IF NOT EXISTS `rpc_priority`( " - " `priority_value` VARCHAR(45) PRIMARY KEY NOT NULL, " - " `value` INTEGER NOT NULL, " - " CONSTRAINT `fk_rpc_priority_priority1` " - " FOREIGN KEY(`priority_value`) " - " REFERENCES `priority`(`value`) " + " `DialNumber` INTEGER NOT NULL, " + " `Alert` INTEGER NOT NULL, " + " `PerformAudioPassThru` INTEGER NOT NULL, " + " `PerformInteraction` INTEGER NOT NULL, " + " `ScrollableMessage` INTEGER NOT NULL, " + " `Slider` INTEGER NOT NULL, " + " `Speak` INTEGER NOT NULL " "); " - "CREATE INDEX IF NOT EXISTS " - "`rpc_priority.fk_rpc_priority_" - "priority1_idx` " - " ON `rpc_priority`(`priority_value`); " "CREATE TABLE IF NOT EXISTS `app_priority`( " - " `priority_value` VARCHAR(45) PRIMARY KEY NOT NULL, " - " `value` INTEGER NOT NULL, " - " CONSTRAINT `fk_app_priority_priority1` " - " FOREIGN KEY(`priority_value`) " - " REFERENCES `priority`(`value`) " + " `EMERGENCY` INTEGER NOT NULL, " + " `NAVIGATION` INTEGER NOT NULL, " + " `VOICE_COMMUNICATION` INTEGER NOT NULL, " + " `COMMUNICATION` INTEGER NOT NULL, " + " `NORMAL` INTEGER NOT NULL, " + " `NONE` INTEGER NOT NULL " "); " - "CREATE INDEX IF NOT EXISTS " - "`app_priority.fk_app_priority_" - "priority1_idx` " - " ON `app_priority`(`priority_value`); " "CREATE TABLE IF NOT EXISTS `hmi_status_priority`( " - " `priority_value` VARCHAR(45) PRIMARY KEY NOT NULL, " - " `value` INTEGER NOT NULL, " - " CONSTRAINT `fk_hmi_status_priority_priority1` " - " FOREIGN KEY(`priority_value`) " - " REFERENCES `priority`(`value`) " + " `FULL` INTEGER NOT NULL, " + " `LIMITED` INTEGER NOT NULL, " + " `BACKGROUND` INTEGER NOT NULL, " + " `NONE` INTEGER NOT NULL " "); " - "CREATE INDEX IF NOT EXISTS " - "`hmi_status_priority.fk_hmi_status_priority_" - "priority1_idx` " - " ON `hmi_status_priority`(`priority_value`); " "COMMIT;"; const std::string kInsertInitData = @@ -550,6 +540,26 @@ const std::string kInsertInitData = " VALUES(1, 0, 0, 0, 0, 0); " "INSERT OR IGNORE INTO `vehicle_data` (" " `schema_version`) VALUES('0'); " + "INSERT OR IGNORE INTO `rpc_priority` (`DialNumber`," + " `Alert`," + " `PerformAudioPassThru`," + " `PerformInteraction`," + " `ScrollableMessage`," + " `Slider`," + " `Speak`)" + " VALUES(0, 0, 0, 0, 0, 0, 0); " + "INSERT OR IGNORE INTO `app_priority` (`EMERGENCY`," + " `NAVIGATION`," + " `VOICE_COMMUNICATION`," + " `COMMUNICATION`," + " `NORMAL`," + " `NONE`)" + " VALUES(0, 0, 0, 0, 0, 0); " + "INSERT OR IGNORE INTO `hmi_Status_priority` (`FULL`," + " `LIMITED`," + " `BACKGROUND`," + " `NONE`)" + " VALUES(0, 0, 0, 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'); " @@ -687,17 +697,8 @@ const std::string kDropSchema = "DROP TABLE IF EXISTS `vehicle_data`; " "DROP TABLE IF EXISTS `vehicle_data_item_definition`; " "DROP TABLE IF EXISTS `vehicle_data_item_parameters`; " - "DROP INDEX IF EXISTS " - "`rpc_priority.fk_rpc_priority_" - "priority1_idx`; " "DROP TABLE IF EXISTS `rpc_priority`; " - "DROP INDEX IF EXISTS " - "`app_priority.fk_app_priority_" - "priority1_idx`; " "DROP TABLE IF EXISTS `app_priority`; " - "DROP INDEX IF EXISTS " - "`hmi_status_priority.fk_hmi_status_priority_" - "priority1_idx`; " "DROP TABLE IF EXISTS `hmi_status_priority`; " "COMMIT; " "VACUUM;"; @@ -1172,5 +1173,54 @@ const std::string kSelectDBVersion = const std::string kUpdateDBVersion = "UPDATE `_internal_data` SET `db_version_hash` = ? "; +const std::string kUpdateRpcPriority = + "UPDATE `rpc_priority` SET `DialNumber` = ?," + " `Alert` = ?," + " `PerformAudioPassThru` = ?," + " `PerformInteraction` = ?," + " `ScrollableMessage` = ?," + " `Slider` = ?," + " `Speak` = ?"; + +const std::string kUpdateAppPriority = + "UPDATE `app_priority` SET `EMERGENCY` = ?," + " `NAVIGATION` = ?," + " `VOICE_COMMUNICATION` = ?," + " `COMMUNICATION` = ?," + " `NORMAL` = ?," + " `NONE` = ?"; + +const std::string kUpdateHmiStatusPriority = + "UPDATE `hmi_status_priority` SET `FULL` = ?," + " `LIMITED` = ?," + " `BACKGROUND` = ?," + " `NONE` = ?"; + +const std::string kSelectRpcPriority = + "SELECT `DialNumber`, " + "`Alert`," + "`PerformAudioPassThru`," + "`PerformInteraction`," + "`ScrollableMessage`," + "`Slider`," + "`Speak`" + "FROM `rpc_priority`"; + +const std::string kSelectAppPriority = + "SELECT `EMERGENCY`, " + "`NAVIGATION`," + "`VOICE_COMMUNICATION`," + "`COMMUNICATION`," + "`NORMAL`," + "`NONE`" + "FROM `app_priority`"; + +const std::string kSelectHmiStatusPriority = + "SELECT `FULL`, " + "`LIMITED`," + "`BACKGROUND`," + "`NONE`" + "FROM `hmi_status_priority`"; + } // namespace sql_pt } // namespace policy 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 13b4f1689dd..7f38438c166 100644 --- a/src/components/policy/policy_external/src/sql_pt_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_representation.cc @@ -480,7 +480,9 @@ std::shared_ptr SQLPTRepresentation::GenerateSnapshot() rpc::Optional > null_version; table->policy_table.vehicle_data->schema_version = null_version; } - GatherInterruptManagerConfig(&table->policy_table.interrupt_manager_config); + GatherRpcPriority(&table->policy_table.rpc_priority); + GatherAppPriority(&table->policy_table.app_priority); + GatherHmiStatusPriority(&table->policy_table.hmi_status_priority); return table; } @@ -869,40 +871,53 @@ bool SQLPTRepresentation::GatherVehicleDataItems( return true; } -void SQLPTRepresentation::GatherInterruptManagerConfig( - policy_table::InterruptManagerConfig* config) const { +void SQLPTRepresentation::GatherRpcPriority( + policy_table::RpcPriority* priority) const { SDL_LOG_INFO("Gather Configuration Info"); - - utils::dbms::SQLQuery rpc_priority(db()); - if (!rpc_priority.Prepare(sql_pt::kSelectRpcPriority)) { - SDL_LOG_WARN("Incorrect select statement for priority"); + + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kSelectRpcPriority) || !query.Next()) { + SDL_LOG_WARN("Incorrect select statement for rpc priority"); } else { - while (rpc_priority.Next()) { - config->rpc_priority[rpc_priority.GetString(0)] = - rpc_priority.GetInteger(1); - } + priority->DialNumber = query.GetInteger(0); + priority->Alert = query.GetInteger(1); + priority->PerformAudioPassThru = query.GetInteger(2); + priority->PerformInteraction = query.GetInteger(3); + priority->ScrollableMessage = query.GetInteger(4); + priority->Slider = query.GetInteger(5); + priority->Speak = query.GetInteger(6); } - SDL_LOG_INFO("rpc_priority.GetString(0) :" << rpc_priority.GetString(0)); - SDL_LOG_INFO("rpc_priority.GetInteger(1) :" << rpc_priority.GetInteger(1)); +} - utils::dbms::SQLQuery app_priority(db()); - if (!app_priority.Prepare(sql_pt::kSelectAppPriority)) { - SDL_LOG_WARN("Incorrect select statement for priority"); +void SQLPTRepresentation::GatherAppPriority( + policy_table::AppPriority* priority) const { + SDL_LOG_INFO("Gather Configuration Info"); + + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kSelectAppPriority) || !query.Next()) { + SDL_LOG_WARN("Incorrect select statement for app priority"); } else { - while (app_priority.Next()) { - config->app_priority[app_priority.GetString(0)] = - app_priority.GetInteger(1); - } + priority->EMERGENCY = query.GetInteger(0); + priority->NAVIGATION = query.GetInteger(1); + priority->VOICE_COMMUNICATION = query.GetInteger(2); + priority->COMMUNICATION = query.GetInteger(3); + priority->NORMAL = query.GetInteger(4); + priority->NONE = query.GetInteger(5); } +} + +void SQLPTRepresentation::GatherHmiStatusPriority( + policy_table::HmiStatusPriority* priority) const { + SDL_LOG_INFO("Gather Configuration Info"); - utils::dbms::SQLQuery hmi_status_priority(db()); - if (!hmi_status_priority.Prepare(sql_pt::kSelectRpcPriority)) { - SDL_LOG_WARN("Incorrect select statement for priority"); + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kSelectHmiStatusPriority) || !query.Next()) { + SDL_LOG_WARN("Incorrect select statement for hmi status priority"); } else { - while (hmi_status_priority.Next()) { - config->hmi_status_priority[hmi_status_priority.GetString(0)] = - hmi_status_priority.GetInteger(1); - } + priority->FULL = query.GetInteger(0); + priority->LIMITED = query.GetInteger(1); + priority->BACKGROUND = query.GetInteger(2); + priority->NONE = query.GetInteger(3); } } @@ -944,8 +959,18 @@ bool SQLPTRepresentation::Save(const policy_table::Table& table) { db_->RollbackTransaction(); return false; } - if (!SaveInterruptManagerConfig( - table.policy_table.interrupt_manager_config)) { + if (!SaveRpcPriority( + table.policy_table.rpc_priority)) { + db_->RollbackTransaction(); + return false; + } + if (!SaveAppPriority( + table.policy_table.app_priority)) { + db_->RollbackTransaction(); + return false; + } + if (!SaveHmiStatusPriority( + table.policy_table.hmi_status_priority)) { db_->RollbackTransaction(); return false; } @@ -2890,81 +2915,76 @@ bool SQLPTRepresentation::SaveExternalConsentEntities( return true; } -bool SQLPTRepresentation::SaveInterruptManagerConfig( - const policy_table::InterruptManagerConfig& config) { +bool SQLPTRepresentation::SaveRpcPriority( + const policy_table::RpcPriority& priority) { + utils::dbms::SQLQuery query(db()); SDL_LOG_AUTO_TRACE(); - if (!SaveRpcPriority(config.rpc_priority)) { - return false; - } - - if (!SaveAppPriority(config.app_priority)) { + if (!query.Prepare(sql_pt::kUpdateRpcPriority)) { + SDL_LOG_WARN("Incorrect update statement for rpc priority."); return false; } - if (!SaveHmiStatusPriority(config.hmi_status_priority)) { - return false; - } - return true; -} + query.Bind(0, priority.DialNumber); + query.Bind(1, priority.Alert); + query.Bind(2, priority.PerformAudioPassThru); + query.Bind(3, priority.PerformInteraction); + query.Bind(4, priority.ScrollableMessage); + query.Bind(5, priority.Slider); + query.Bind(6, priority.Speak); -bool SQLPTRepresentation::SaveRpcPriority( - const policy_table::rpc_priority_type& priority) { - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt::kInsertRpcPriority)) { - SDL_LOG_WARN("Incorrect insert statement for rpc priority."); + if (!query.Exec()) { + SDL_LOG_WARN("Incorrect update rpc priority"); return false; } - policy_table::rpc_priority_type::const_iterator it; - for (it = priority.begin(); it != priority.end(); ++it) { - query.Bind(0, it->first); - query.Bind(1, it->second); - if (!query.Exec() || !query.Reset()) { - SDL_LOG_WARN("Incorrect insert into rpc priority."); - return false; - } - } return true; } bool SQLPTRepresentation::SaveAppPriority( - const policy_table::app_priority_type& priority) { + const policy_table::AppPriority& priority) { utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt::kInsertAppPriority)) { - SDL_LOG_WARN("Incorrect insert statement for rpc priority."); + SDL_LOG_AUTO_TRACE(); + + if (!query.Prepare(sql_pt::kUpdateAppPriority)) { + SDL_LOG_WARN("Incorrect update statement for app priority."); return false; } + query.Bind(0, priority.EMERGENCY); + query.Bind(1, priority.NAVIGATION); + query.Bind(2, priority.VOICE_COMMUNICATION); + query.Bind(3, priority.COMMUNICATION); + query.Bind(4, priority.NORMAL); + query.Bind(5, priority.NONE); - policy_table::app_priority_type::const_iterator it; - for (it = priority.begin(); it != priority.end(); ++it) { - query.Bind(0, it->first); - query.Bind(1, it->second); - if (!query.Exec() || !query.Reset()) { - SDL_LOG_WARN("Incorrect insert into rpc priority."); - return false; - } + if (!query.Exec()) { + SDL_LOG_WARN("Incorrect update app priority"); + return false; } + return true; } bool SQLPTRepresentation::SaveHmiStatusPriority( - const policy_table::hmi_status_priority_type& priority) { + const policy_table::HmiStatusPriority& priority) { utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt::kInsertRpcPriority)) { - SDL_LOG_WARN("Incorrect insert statement for rpc priority."); + SDL_LOG_AUTO_TRACE(); + + if (!query.Prepare(sql_pt::kUpdateHmiStatusPriority)) { + SDL_LOG_WARN("Incorrect update statement for hmi status priority."); return false; } - policy_table::hmi_status_priority_type::const_iterator it; - for (it = priority.begin(); it != priority.end(); ++it) { - query.Bind(0, it->first); - query.Bind(1, it->second); - if (!query.Exec() || !query.Reset()) { - SDL_LOG_WARN("Incorrect insert into rpc priority."); - return false; - } + query.Bind(0, priority.FULL); + query.Bind(1, priority.LIMITED); + query.Bind(2, priority.BACKGROUND); + query.Bind(3, priority.NONE); + + if (!query.Exec()) { + SDL_LOG_WARN("Incorrect update hmi status priority"); + return false; } + return true; } diff --git a/src/components/policy/policy_external/test/json/sdl_preloaded_pt_for_merge_initial.json b/src/components/policy/policy_external/test/json/sdl_preloaded_pt_for_merge_initial.json index 10c15966a58..1b1430135b3 100644 --- a/src/components/policy/policy_external/test/json/sdl_preloaded_pt_for_merge_initial.json +++ b/src/components/policy/policy_external/test/json/sdl_preloaded_pt_for_merge_initial.json @@ -2287,7 +2287,6 @@ "seconds_between_retries" : [ 1, 5, 25, 125, 625 ], "timeout_after_x_seconds" : 60 }, - "interrupt_manager_config": { "rpc_priority":{ "DialNumber": 1, "Alert": 2, @@ -2311,6 +2310,5 @@ "BACKGROUND": 3, "NONE": 4 } - } } } diff --git a/src/components/policy/policy_external/test/json/sdl_preloaded_pt_for_merge_latest.json b/src/components/policy/policy_external/test/json/sdl_preloaded_pt_for_merge_latest.json index ecbdd289ba9..fd57d71a92f 100644 --- a/src/components/policy/policy_external/test/json/sdl_preloaded_pt_for_merge_latest.json +++ b/src/components/policy/policy_external/test/json/sdl_preloaded_pt_for_merge_latest.json @@ -2283,7 +2283,7 @@ "seconds_between_retries" : [ 1, 5, 25, 125, 625 ], "timeout_after_x_seconds" : 60 }, - "interrupt_manager_config": { + "rpc_priority":{ "DialNumber": 1, "Alert": 2, @@ -2307,6 +2307,6 @@ "BACKGROUND": 3, "NONE": 4 } - } + } } diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h index 9305068abf3..ee245074bbf 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager.h @@ -857,7 +857,11 @@ class CacheManager : public CacheManagerInterface { void MergeVD(const policy_table::PolicyTable& new_pt, policy_table::PolicyTable& pt); - void MergeIMC(const policy_table::PolicyTable& new_pt, + void MergeRPCP(const policy_table::PolicyTable& new_pt, + policy_table::PolicyTable& pt); + void MergeAPPP(const policy_table::PolicyTable& new_pt, + policy_table::PolicyTable& pt); + void MergeHMISP(const policy_table::PolicyTable& new_pt, policy_table::PolicyTable& pt); const PolicySettings& get_settings() const; diff --git a/src/components/policy/policy_regular/include/policy/policy_table/types.h b/src/components/policy/policy_regular/include/policy/policy_table/types.h index 1914bdfaf0d..d96d52283c2 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/types.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/types.h @@ -119,9 +119,9 @@ typedef Array, 0, 255> ModuleTypes; typedef AppHMIType AppHmiType; typedef std::vector AppHmiTypes; -typedef Map, 0, 7> rpc_priority_type; -typedef Map, 0, 6> app_priority_type; -typedef Map, 0, 4> hmi_status_priority_type; +typedef std::map rpc_priority_type; +typedef std::map app_priority_type; +typedef std::map hmi_status_priority_type; struct AppServiceHandledRpc : CompositeType { public: @@ -313,6 +313,100 @@ struct EndpointProperty : CompositeType { bool Validate() const; }; +struct RpcPriority : CompositeType { + public: + Integer DialNumber; + Integer Alert; + Integer PerformAudioPassThru; + Integer PerformInteraction; + Integer ScrollableMessage; + Integer Slider; + Integer Speak; + + public: + RpcPriority(); + RpcPriority(uint8_t DialNumber, + uint8_t Alert, + uint8_t PerformAudioPassThru, + uint8_t PerformInteraction, + uint8_t ScrollableMessage, + uint8_t Slider, + uint8_t Speak); + ~RpcPriority(); + + explicit RpcPriority(const Json::Value* value__); + void SafeCopyFrom(const RpcPriority& from); + 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 AppPriority : CompositeType { + public: + Integer EMERGENCY; + Integer NAVIGATION; + Integer VOICE_COMMUNICATION; + Integer COMMUNICATION; + Integer NORMAL; + Integer NONE; + + public: + AppPriority(); + AppPriority(uint8_t EMERGENCY, + uint8_t NAVIGATION, + uint8_t VOICE_COMMUNICATION, + uint8_t COMMUNICATION, + uint8_t NORMAL, + uint8_t NONE); + ~AppPriority(); + + explicit AppPriority(const Json::Value* value__); + void SafeCopyFrom(const AppPriority& from); + 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 HmiStatusPriority : CompositeType { + public: + Integer FULL; + Integer LIMITED; + Integer BACKGROUND; + Integer NONE; + + public: + HmiStatusPriority(); + HmiStatusPriority(uint8_t FULL, + uint8_t LIMITED, + uint8_t BACKGROUND, + uint8_t NONE); + ~HmiStatusPriority(); + + explicit HmiStatusPriority(const Json::Value* value__); + void SafeCopyFrom(const HmiStatusPriority& from); + 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 ModuleConfig : CompositeType { public: Optional preloaded_pt; @@ -619,35 +713,6 @@ struct VehicleData : CompositeType { bool Validate() const; }; -struct InterruptManagerConfig : CompositeType { - public: - rpc_priority_type rpc_priority; - app_priority_type app_priority; - hmi_status_priority_type hmi_status_priority; - - public: - InterruptManagerConfig(); - InterruptManagerConfig(const rpc_priority_type& rpc_priority, - const app_priority_type& app_priority, - const hmi_status_priority_type& hmi_status_priority); - ~InterruptManagerConfig(); - explicit InterruptManagerConfig(const Json::Value* value__); - - void SafeCopyFrom(const InterruptManagerConfig& from); - - 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; @@ -658,7 +723,9 @@ struct PolicyTable : CompositeType { Optional usage_and_error_counts; Optional device_data; Optional vehicle_data; - InterruptManagerConfig interrupt_manager_config; + RpcPriority rpc_priority; + AppPriority app_priority; + HmiStatusPriority hmi_status_priority; public: PolicyTable(); @@ -666,7 +733,9 @@ struct PolicyTable : CompositeType { const FunctionalGroupings& functional_groupings, const ConsumerFriendlyMessages& consumer_friendly_messages, const ModuleConfig& module_config, - const InterruptManagerConfig& interrupt_manager_config); + const RpcPriority& rpc_priority, + const AppPriority& app_priority, + const HmiStatusPriority& hmi_status_priority); ~PolicyTable(); explicit PolicyTable(const Json::Value* value__); Json::Value ToJsonValue() const; diff --git a/src/components/policy/policy_regular/include/policy/sql_pt_queries.h b/src/components/policy/policy_regular/include/policy/sql_pt_queries.h index 42855f33d21..026fd883170 100644 --- a/src/components/policy/policy_regular/include/policy/sql_pt_queries.h +++ b/src/components/policy/policy_regular/include/policy/sql_pt_queries.h @@ -159,12 +159,12 @@ extern const std::string kSelectVehicleDataSchemaVersion; extern const std::string kInsertVehicleDataSchemaVersion; extern const std::string kSelectEndpointProperties; extern const std::string kInsertEndpointVersion; +extern const std::string kUpdateRpcPriority; +extern const std::string kUpdateAppPriority; +extern const std::string kUpdateHmiStatusPriority; extern const std::string kSelectRpcPriority; extern const std::string kSelectAppPriority; extern const std::string kSelectHmiStatusPriority; -extern const std::string kInsertRpcPriority; -extern const std::string kInsertAppPriority; -extern const std::string kInsertHmiStatusPriority; } // namespace sql_pt } // namespace policy diff --git a/src/components/policy/policy_regular/include/policy/sql_pt_representation.h b/src/components/policy/policy_regular/include/policy/sql_pt_representation.h index 1ddbaf1d42a..77e1ea6da3e 100644 --- a/src/components/policy/policy_regular/include/policy/sql_pt_representation.h +++ b/src/components/policy/policy_regular/include/policy/sql_pt_representation.h @@ -144,7 +144,10 @@ class SQLPTRepresentation : public virtual PTRepresentation { bool GatherNickName(const std::string& app_id, policy_table::Strings* nicknames) const; - virtual void GatherInterruptManagerConfig(policy_table::InterruptManagerConfig* config) const; + virtual void GatherRpcPriority(policy_table::RpcPriority* priority) const; + virtual void GatherAppPriority(policy_table::AppPriority* priority) const; + virtual void GatherHmiStatusPriority(policy_table::HmiStatusPriority* priority) const; + virtual bool SaveApplicationCustomData(const std::string& app_id, bool is_revoked, @@ -173,7 +176,9 @@ class SQLPTRepresentation : public virtual PTRepresentation { const std::string& lang, const policy_table::MessageString& strings); - virtual bool SaveInterruptManagerConfig(const policy_table::InterruptManagerConfig& config); + virtual bool SaveRpcPriority(const policy_table::RpcPriority& priority); + virtual bool SaveAppPriority(const policy_table::AppPriority& priority); + virtual bool SaveHmiStatusPriority(const policy_table::HmiStatusPriority& priority); bool SaveAppGroup(const std::string& app_id, const policy_table::Strings& app_groups); diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index 6ab0a2f62f1..37cf0baa217 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -305,9 +305,15 @@ bool CacheManager::ApplyUpdate(const policy_table::Table& update_pt) { pt_->policy_table.module_config.endpoint_properties = update_pt.policy_table.module_config.endpoint_properties; + + pt_->policy_table.rpc_priority.SafeCopyFrom( + update_pt.policy_table.rpc_priority); + + pt_->policy_table.app_priority.SafeCopyFrom( + update_pt.policy_table.app_priority); - pt_->policy_table.interrupt_manager_config.SafeCopyFrom( - update_pt.policy_table.interrupt_manager_config); + pt_->policy_table.hmi_status_priority.SafeCopyFrom( + update_pt.policy_table.hmi_status_priority); // Apply update for vehicle data if (update_pt.policy_table.vehicle_data.is_initialized()) { @@ -1421,7 +1427,9 @@ std::shared_ptr CacheManager::GenerateSnapshot() { pt_->policy_table.vehicle_data->schema_version; } - snapshot_->policy_table.interrupt_manager_config = pt_->policy_table.interrupt_manager_config; + snapshot_->policy_table.rpc_priority = pt_->policy_table.rpc_priority; + snapshot_->policy_table.app_priority = pt_->policy_table.app_priority; + snapshot_->policy_table.hmi_status_priority = pt_->policy_table.hmi_status_priority; // Set policy table type to Snapshot snapshot_->SetPolicyTableType( @@ -2085,7 +2093,9 @@ bool CacheManager::MergePreloadPT(const std::string& file_name) { MergeAP(new_table, current); MergeCFM(new_table, current); MergeVD(new_table, current); - MergeIMC(new_table, current); + MergeRPCP(new_table, current); + MergeAPPP(new_table, current); + MergeHMISP(new_table, current); Backup(); } return true; @@ -2159,10 +2169,25 @@ void CacheManager::MergeVD(const policy_table::PolicyTable& new_pt, pt.vehicle_data.assign_if_valid(new_pt.vehicle_data); } -void CacheManager::MergeIMC(const policy_table::PolicyTable& new_pt, - policy_table::PolicyTable& pt) { +void CacheManager::MergeRPCP(const policy_table::PolicyTable& new_pt, + policy_table::PolicyTable& pt) { + SDL_LOG_AUTO_TRACE(); + policy_table::RpcPriority copy(pt.rpc_priority); + pt.rpc_priority = new_pt.rpc_priority; +} + +void CacheManager::MergeAPPP(const policy_table::PolicyTable& new_pt, + policy_table::PolicyTable& pt) { SDL_LOG_AUTO_TRACE(); - pt.interrupt_manager_config = new_pt.interrupt_manager_config; + policy_table::AppPriority copy(pt.app_priority); + pt.app_priority = new_pt.app_priority; +} + +void CacheManager::MergeHMISP(const policy_table::PolicyTable& new_pt, + policy_table::PolicyTable& pt) { + SDL_LOG_AUTO_TRACE(); + policy_table::HmiStatusPriority copy(pt.hmi_status_priority); + pt.hmi_status_priority = new_pt.hmi_status_priority; } const PolicySettings& CacheManager::get_settings() const { @@ -2274,20 +2299,57 @@ void CacheManager::GetApplicationParams( rpc::policy_table_interface_base::rpc_priority_type CacheManager::GetRpcPriority() const { SDL_LOG_AUTO_TRACE(); - sync_primitives::AutoLock auto_lock(cache_lock_); - return pt_->policy_table.interrupt_manager_config.rpc_priority; + sync_primitives::AutoLock auto_lock(cache_lock_); + + rpc::policy_table_interface_base::rpc_priority_type rpc_priority_table = {}; + std::string rpcPriority[] = {"DialNumber", + "Alert", + "PerformAudioPassThru", + "PerformInteraction", + "ScrollableMessage", + "Slider", + "Speak"}; + rpc_priority_table[rpcPriority[0]] = pt_->policy_table.rpc_priority.DialNumber; + rpc_priority_table[rpcPriority[1]] = pt_->policy_table.rpc_priority.Alert; + rpc_priority_table[rpcPriority[2]] = pt_->policy_table.rpc_priority.PerformAudioPassThru; + rpc_priority_table[rpcPriority[3]] = pt_->policy_table.rpc_priority.PerformInteraction; + rpc_priority_table[rpcPriority[4]] = pt_->policy_table.rpc_priority.ScrollableMessage; + rpc_priority_table[rpcPriority[5]] = pt_->policy_table.rpc_priority.Slider; + rpc_priority_table[rpcPriority[6]] = pt_->policy_table.rpc_priority.Speak; + + return rpc_priority_table; } rpc::policy_table_interface_base::app_priority_type CacheManager::GetAppPriority() const { - sync_primitives::AutoLock auto_lock(cache_lock_); - return pt_->policy_table.interrupt_manager_config.app_priority; + SDL_LOG_AUTO_TRACE(); + sync_primitives::AutoLock auto_lock(cache_lock_); + + rpc::policy_table_interface_base::app_priority_type app_priority_table = {}; + std::string appPriority[] = {"EMERGENCY","NAVIGATION","VOICE_COMMUNICATION","COMMUNICATION","NORMAL","NONE"}; + app_priority_table[appPriority[0]] = pt_->policy_table.app_priority.EMERGENCY; + app_priority_table[appPriority[1]] = pt_->policy_table.app_priority.NAVIGATION; + app_priority_table[appPriority[2]] = pt_->policy_table.app_priority.VOICE_COMMUNICATION; + app_priority_table[appPriority[3]] = pt_->policy_table.app_priority.COMMUNICATION; + app_priority_table[appPriority[4]] = pt_->policy_table.app_priority.NORMAL; + app_priority_table[appPriority[5]] = pt_->policy_table.app_priority.NONE; + + return app_priority_table; } rpc::policy_table_interface_base::hmi_status_priority_type CacheManager::GetHmiStatusPriority() const { - sync_primitives::AutoLock auto_lock(cache_lock_); - return pt_->policy_table.interrupt_manager_config.hmi_status_priority; + SDL_LOG_AUTO_TRACE(); + sync_primitives::AutoLock auto_lock(cache_lock_); + + rpc::policy_table_interface_base::app_priority_type hmi_status_priority_table = {}; + std::string hmiStatusPriority[] = {"FULL", "LIMITED", "BACKGROUND", "NONE"}; + hmi_status_priority_table[hmiStatusPriority[0]] = pt_->policy_table.hmi_status_priority.FULL; + hmi_status_priority_table[hmiStatusPriority[1]] = pt_->policy_table.hmi_status_priority.LIMITED; + hmi_status_priority_table[hmiStatusPriority[2]] = pt_->policy_table.hmi_status_priority.BACKGROUND; + hmi_status_priority_table[hmiStatusPriority[3]] = pt_->policy_table.hmi_status_priority.NONE; + + return hmi_status_priority_table; } diff --git a/src/components/policy/policy_regular/src/policy_table/types.cc b/src/components/policy/policy_regular/src/policy_table/types.cc index f9f6404c715..fe2eb66a2be 100644 --- a/src/components/policy/policy_regular/src/policy_table/types.cc +++ b/src/components/policy/policy_regular/src/policy_table/types.cc @@ -2162,99 +2162,431 @@ void VehicleData::SetPolicyTableType(PolicyTableType pt_type) { schema_items.SetPolicyTableType(pt_type); } -//InterruptManagerConfig methods -InterruptManagerConfig::InterruptManagerConfig() : CompositeType(kUninitialized) {} +//RpcPriority methods + +RpcPriority::RpcPriority() : CompositeType(kUninitialized) {} + + Integer DialNumber; + Integer Alert; + Integer PerformAudioPassThru; + Integer PerformInteraction; + Integer ScrollableMessage; + Integer Slider; + Integer Speak; + +RpcPriority::RpcPriority( + uint8_t DialNumber, + uint8_t Alert, + uint8_t PerformAudioPassThru, + uint8_t PerformInteraction, + uint8_t ScrollableMessage, + uint8_t Slider, + uint8_t Speak) + : CompositeType(kUninitialized) + ,DialNumber(DialNumber) + ,Alert(Alert) + ,PerformAudioPassThru(PerformAudioPassThru) + ,PerformInteraction(PerformInteraction) + ,ScrollableMessage(ScrollableMessage) + ,Slider(Slider) + ,Speak(Speak) + {} + +RpcPriority::~RpcPriority() {} + +RpcPriority::RpcPriority(const Json::Value* value__) + : CompositeType(InitHelper(value__, &Json::Value::isObject)) + , DialNumber(impl::ValueMember(value__, "DialNumber")) + , Alert(impl::ValueMember(value__, "Alert")) + , PerformAudioPassThru(impl::ValueMember(value__, "PerformAudioPassThru")) + , PerformInteraction(impl::ValueMember(value__, "PerformInteraction")) + , ScrollableMessage(impl::ValueMember(value__, "ScrollableMessage")) + , Slider(impl::ValueMember(value__, "Slider")) + , Speak(impl::ValueMember(value__, "Speak")) + {} + +void RpcPriority::SafeCopyFrom(const RpcPriority& from) { + DialNumber = from.DialNumber; + Alert = from.Alert; + PerformAudioPassThru = from.PerformAudioPassThru; + PerformInteraction = from.PerformInteraction; + ScrollableMessage = from.ScrollableMessage; + Slider = from.Slider; + Speak = from.Speak; +} + +Json::Value RpcPriority::ToJsonValue() const { + Json::Value result__(Json::objectValue); + impl::WriteJsonField("DialNumber", DialNumber, &result__); + impl::WriteJsonField("Alert", Alert, &result__); + impl::WriteJsonField("PerformAudioPassThru", PerformAudioPassThru, &result__); + impl::WriteJsonField("PerformInteraction", PerformInteraction, &result__); + impl::WriteJsonField("ScrollableMessage", ScrollableMessage, &result__); + impl::WriteJsonField("Slider", Slider, &result__); + impl::WriteJsonField("Speak", Speak, &result__); + return result__; +} -InterruptManagerConfig::InterruptManagerConfig( - const rpc_priority_type& rpc_priority, - const app_priority_type& app_priority, - const hmi_status_priority_type& hmi_status_priority) - : CompositeType(kUninitialized) - , rpc_priority(rpc_priority) - , app_priority(app_priority) - , hmi_status_priority(hmi_status_priority){} +bool RpcPriority::is_valid() const { + if (!DialNumber.is_valid()) { + return false; + } + if (!Alert.is_valid()) { + return false; + } + if (!PerformAudioPassThru.is_valid()) { + return false; + } + if (!PerformInteraction.is_valid()) { + return false; + } + if (!ScrollableMessage.is_valid()) { + return false; + } + if (!Slider.is_valid()) { + return false; + } + if (!Speak.is_valid()) { + return false; + } + return Validate(); +} -InterruptManagerConfig::~InterruptManagerConfig() {} +bool RpcPriority::is_initialized() const { + return (initialization_state__ != kUninitialized) || (!struct_empty()); +} +bool RpcPriority::struct_empty() const { + if (DialNumber.is_initialized()) { + return false; + } + if (Alert.is_initialized()) { + return false; + } + if (PerformAudioPassThru.is_initialized()) { + return false; + } + if (PerformInteraction.is_initialized()) { + return false; + } + if (ScrollableMessage.is_initialized()) { + return false; + } + if (Slider.is_initialized()) { + return false; + } + if (Speak.is_initialized()) { + return false; + } + return true; +} + +void RpcPriority::ReportErrors(rpc::ValidationReport* report__) const { + if (struct_empty()) { + rpc::CompositeType::ReportErrors(report__); + } + + if (!DialNumber.is_valid()) { + DialNumber.ReportErrors( + &report__->ReportSubobject("DialNumber")); + } + if (!Alert.is_valid()) { + Alert.ReportErrors( + &report__->ReportSubobject("Alert")); + } + if (!PerformAudioPassThru.is_valid()) { + PerformAudioPassThru.ReportErrors( + &report__->ReportSubobject("PerformAudioPassThru")); + } + if (!PerformInteraction.is_valid()) { + PerformInteraction.ReportErrors( + &report__->ReportSubobject("PerformInteraction")); + } + if (!ScrollableMessage.is_valid()) { + ScrollableMessage.ReportErrors( + &report__->ReportSubobject("ScrollableMessage")); + } + if (!Slider.is_valid()) { + Slider.ReportErrors( + &report__->ReportSubobject("Slider")); + } + if (!Speak.is_valid()) { + Speak.ReportErrors( + &report__->ReportSubobject("Speak")); + } +} -InterruptManagerConfig::InterruptManagerConfig(const Json::Value* value__) +void RpcPriority::SetPolicyTableType(PolicyTableType pt_type) { + CompositeType::SetPolicyTableType(pt_type); + DialNumber.SetPolicyTableType(pt_type); + Alert.SetPolicyTableType(pt_type); + PerformAudioPassThru.SetPolicyTableType(pt_type); + PerformInteraction.SetPolicyTableType(pt_type); + ScrollableMessage.SetPolicyTableType(pt_type); + Slider.SetPolicyTableType(pt_type); + Speak.SetPolicyTableType(pt_type); +} + +//AppPriority methods + +AppPriority::AppPriority() : CompositeType(kUninitialized) {} + + Integer EMERGENCY; + Integer NAVIGATION; + Integer VOICE_COMMUNICATION; + Integer COMMUNICATION; + Integer NORMAL; + Integer NONE; + +AppPriority::AppPriority( + uint8_t EMERGENCY, + uint8_t NAVIGATION, + uint8_t VOICE_COMMUNICATION, + uint8_t COMMUNICATION, + uint8_t NORMAL, + uint8_t NONE) + : CompositeType(kUninitialized) + ,EMERGENCY(EMERGENCY) + ,NAVIGATION(NAVIGATION) + ,VOICE_COMMUNICATION(VOICE_COMMUNICATION) + ,COMMUNICATION(COMMUNICATION) + ,NORMAL(NORMAL) + ,NONE(NONE) + {} + +AppPriority::~AppPriority() {} + +AppPriority::AppPriority(const Json::Value* value__) : CompositeType(InitHelper(value__, &Json::Value::isObject)) - , rpc_priority(impl::ValueMember(value__, "rpc_priority")) - , app_priority(impl::ValueMember(value__, "app_priority")) - , hmi_status_priority(impl::ValueMember(value__, "hmi_status_priority")){} + , EMERGENCY(impl::ValueMember(value__, "EMERGENCY")) + , NAVIGATION(impl::ValueMember(value__, "NAVIGATION")) + , VOICE_COMMUNICATION(impl::ValueMember(value__, "VOICE_COMMUNICATION")) + , COMMUNICATION(impl::ValueMember(value__, "COMMUNICATION")) + , NORMAL(impl::ValueMember(value__, "NORMAL")) + , NONE(impl::ValueMember(value__, "NONE")) + {} + +void AppPriority::SafeCopyFrom(const AppPriority& from) { + EMERGENCY = from.EMERGENCY; + NAVIGATION = from.NAVIGATION; + VOICE_COMMUNICATION = from.VOICE_COMMUNICATION; + COMMUNICATION = from.COMMUNICATION; + NORMAL = from.NORMAL; + NONE = from.NONE; +} + +Json::Value AppPriority::ToJsonValue() const { + Json::Value result__(Json::objectValue); + impl::WriteJsonField("EMERGENCY", EMERGENCY, &result__); + impl::WriteJsonField("NAVIGATION", NAVIGATION, &result__); + impl::WriteJsonField("VOICE_COMMUNICATION", VOICE_COMMUNICATION, &result__); + impl::WriteJsonField("COMMUNICATION", COMMUNICATION, &result__); + impl::WriteJsonField("NORMAL", NORMAL, &result__); + impl::WriteJsonField("NONE", NONE, &result__); + return result__; +} + +bool AppPriority::is_valid() const { + if (!EMERGENCY.is_valid()) { + return false; + } + if (!NAVIGATION.is_valid()) { + return false; + } + if (!VOICE_COMMUNICATION.is_valid()) { + return false; + } + if (!COMMUNICATION.is_valid()) { + return false; + } + if (!NORMAL.is_valid()) { + return false; + } + if (!NONE.is_valid()) { + return false; + } + return Validate(); +} +bool AppPriority::is_initialized() const { + return (initialization_state__ != kUninitialized) || (!struct_empty()); +} + +bool AppPriority::struct_empty() const { + if (EMERGENCY.is_initialized()) { + return false; + } + if (NAVIGATION.is_initialized()) { + return false; + } + if (VOICE_COMMUNICATION.is_initialized()) { + return false; + } + if (COMMUNICATION.is_initialized()) { + return false; + } + if (NORMAL.is_initialized()) { + return false; + } + if (NONE.is_initialized()) { + return false; + } + return true; +} + +void AppPriority::ReportErrors(rpc::ValidationReport* report__) const { + if (struct_empty()) { + rpc::CompositeType::ReportErrors(report__); + } + + if (!EMERGENCY.is_valid()) { + EMERGENCY.ReportErrors( + &report__->ReportSubobject("EMERGENCY")); + } + if (!NAVIGATION.is_valid()) { + NAVIGATION.ReportErrors( + &report__->ReportSubobject("NAVIGATION")); + } + if (!VOICE_COMMUNICATION.is_valid()) { + VOICE_COMMUNICATION.ReportErrors( + &report__->ReportSubobject("VOICE_COMMUNICATION")); + } + if (!COMMUNICATION.is_valid()) { + COMMUNICATION.ReportErrors( + &report__->ReportSubobject("COMMUNICATION")); + } + if (!NORMAL.is_valid()) { + NORMAL.ReportErrors( + &report__->ReportSubobject("NORMAL")); + } + if (!NONE.is_valid()) { + NONE.ReportErrors( + &report__->ReportSubobject("NONE")); + } +} -void InterruptManagerConfig::SafeCopyFrom(const InterruptManagerConfig& from) { - rpc_priority = from.rpc_priority; - app_priority = from.app_priority; - hmi_status_priority = from.hmi_status_priority; +void AppPriority::SetPolicyTableType(PolicyTableType pt_type) { + CompositeType::SetPolicyTableType(pt_type); + EMERGENCY.SetPolicyTableType(pt_type); + NAVIGATION.SetPolicyTableType(pt_type); + VOICE_COMMUNICATION.SetPolicyTableType(pt_type); + COMMUNICATION.SetPolicyTableType(pt_type); + NORMAL.SetPolicyTableType(pt_type); + NONE.SetPolicyTableType(pt_type); +} + +//HmiStatusPriority methods + +HmiStatusPriority::HmiStatusPriority() : CompositeType(kUninitialized) {} + + Integer FULL; + Integer LIMITED; + Integer BACKGROUND; + //Integer NONE; + +HmiStatusPriority::HmiStatusPriority( + uint8_t FULL, + uint8_t LIMITED, + uint8_t BACKGROUND, + uint8_t NONE) + : CompositeType(kUninitialized) + ,FULL(FULL) + ,LIMITED(LIMITED) + ,BACKGROUND(BACKGROUND) + ,NONE(NONE) + {} + +HmiStatusPriority::~HmiStatusPriority() {} + +HmiStatusPriority::HmiStatusPriority(const Json::Value* value__) + : CompositeType(InitHelper(value__, &Json::Value::isObject)) + , FULL(impl::ValueMember(value__, "FULL")) + , LIMITED(impl::ValueMember(value__, "LIMITED")) + , BACKGROUND(impl::ValueMember(value__, "BACKGROUND")) + , NONE(impl::ValueMember(value__, "NONE")) + {} + +void HmiStatusPriority::SafeCopyFrom(const HmiStatusPriority& from) { + FULL = from.FULL; + LIMITED = from.LIMITED; + BACKGROUND = from.BACKGROUND; + NONE = from.NONE; } -Json::Value InterruptManagerConfig::ToJsonValue() const { +Json::Value HmiStatusPriority::ToJsonValue() const { Json::Value result__(Json::objectValue); - impl::WriteJsonField("rpc_priority", rpc_priority, &result__); - impl::WriteJsonField("app_priority", app_priority, &result__); - impl::WriteJsonField("hmi_status_priority", hmi_status_priority, &result__); + impl::WriteJsonField("FULL", FULL, &result__); + impl::WriteJsonField("LIMITED", LIMITED, &result__); + impl::WriteJsonField("BACKGROUND", BACKGROUND, &result__); + impl::WriteJsonField("NONE", NONE, &result__); return result__; } - -bool InterruptManagerConfig::is_valid() const { - if (!rpc_priority.is_valid()) { +bool HmiStatusPriority::is_valid() const { + if (!FULL.is_valid()) { return false; } - if (!app_priority.is_valid()) { + if (!LIMITED.is_valid()) { return false; } - if (!hmi_status_priority.is_valid()) { + if (!BACKGROUND.is_valid()) { + return false; + } + if (!NONE.is_valid()) { return false; } return Validate(); } - -bool InterruptManagerConfig::is_initialized() const { +bool HmiStatusPriority::is_initialized() const { return (initialization_state__ != kUninitialized) || (!struct_empty()); } - -bool InterruptManagerConfig::struct_empty() const { - if (!rpc_priority.is_initialized()) { +bool HmiStatusPriority::struct_empty() const { + if (FULL.is_initialized()) { + return false; + } + if (LIMITED.is_initialized()) { return false; } - if (!app_priority.is_initialized()) { + if (BACKGROUND.is_initialized()) { return false; } - if (!hmi_status_priority.is_initialized()) { + if (NONE.is_initialized()) { return false; } return true; } - -void InterruptManagerConfig::ReportErrors(rpc::ValidationReport* report__) const { +void HmiStatusPriority::ReportErrors(rpc::ValidationReport* report__) const { if (struct_empty()) { rpc::CompositeType::ReportErrors(report__); } - if (!rpc_priority.is_valid()) { - rpc_priority.ReportErrors( - &report__->ReportSubobject("rpc_priority")); + + if (!FULL.is_valid()) { + FULL.ReportErrors( + &report__->ReportSubobject("FULL")); } - if (!app_priority.is_valid()) { - app_priority.ReportErrors( - &report__->ReportSubobject("app_priority")); + if (!LIMITED.is_valid()) { + LIMITED.ReportErrors( + &report__->ReportSubobject("LIMITED")); } - if (!hmi_status_priority.is_valid()) { - hmi_status_priority.ReportErrors( - &report__->ReportSubobject("hmi_status_priority")); + if (!BACKGROUND.is_valid()) { + BACKGROUND.ReportErrors( + &report__->ReportSubobject("BACKGROUND")); + } + if (!NONE.is_valid()) { + NONE.ReportErrors( + &report__->ReportSubobject("NONE")); } } -void InterruptManagerConfig::SetPolicyTableType(PolicyTableType pt_type) { +void HmiStatusPriority::SetPolicyTableType(PolicyTableType pt_type) { CompositeType::SetPolicyTableType(pt_type); - rpc_priority.SetPolicyTableType(pt_type); - app_priority.SetPolicyTableType(pt_type); - hmi_status_priority.SetPolicyTableType(pt_type); + FULL.SetPolicyTableType(pt_type); + LIMITED.SetPolicyTableType(pt_type); + BACKGROUND.SetPolicyTableType(pt_type); + NONE.SetPolicyTableType(pt_type); } // PolicyTable methods @@ -2265,13 +2597,17 @@ PolicyTable::PolicyTable( const FunctionalGroupings& functional_groupings, const ConsumerFriendlyMessages& consumer_friendly_messages, const ModuleConfig& module_config, - const InterruptManagerConfig& interrupt_manager_config) + const RpcPriority& rpc_priority, + const AppPriority& app_priority, + const HmiStatusPriority& hmi_status_priority) : CompositeType(kUninitialized) , app_policies_section(app_policies_section) , functional_groupings(functional_groupings) , consumer_friendly_messages(consumer_friendly_messages) , module_config(module_config) - , interrupt_manager_config(interrupt_manager_config) {} + , rpc_priority(rpc_priority) + , app_priority(app_priority) + , hmi_status_priority(hmi_status_priority) {} PolicyTable::~PolicyTable() {} @@ -2287,7 +2623,9 @@ PolicyTable::PolicyTable(const Json::Value* value__) impl::ValueMember(value__, "usage_and_error_counts")) , device_data(impl::ValueMember(value__, "device_data")) , vehicle_data(impl::ValueMember(value__, "vehicle_data")) - , interrupt_manager_config(impl::ValueMember(value__, "interrupt_manager_config")){} + , rpc_priority(impl::ValueMember(value__, "rpc_priority")) + , app_priority(impl::ValueMember(value__, "app_priority")) + , hmi_status_priority(impl::ValueMember(value__, "hmi_status_priority")) {} Json::Value PolicyTable::ToJsonValue() const { Json::Value result__(Json::objectValue); @@ -2301,7 +2639,11 @@ Json::Value PolicyTable::ToJsonValue() const { "usage_and_error_counts", usage_and_error_counts, &result__); impl::WriteJsonField("device_data", device_data, &result__); impl::WriteJsonField("vehicle_data", vehicle_data, &result__); - impl::WriteJsonField("interrupt_manager_config", interrupt_manager_config, &result__); + + impl::WriteJsonField("rpc_priority", rpc_priority, &result__); + impl::WriteJsonField("app_priority", app_priority, &result__); + impl::WriteJsonField("hmi_status_priority", hmi_status_priority, &result__); + return result__; } @@ -2330,7 +2672,13 @@ bool PolicyTable::is_valid() const { if (!vehicle_data.is_valid()) { return false; } - if (!interrupt_manager_config.is_valid()) { + if (!rpc_priority.is_valid()) { + return false; + } + if (!app_priority.is_valid()) { + return false; + } + if (!hmi_status_priority.is_valid()) { return false; } return Validate(); @@ -2368,7 +2716,13 @@ bool PolicyTable::struct_empty() const { if (vehicle_data.is_initialized()) { return false; } - if (interrupt_manager_config.is_initialized()) { + if (rpc_priority.is_initialized()) { + return false; + } + if (app_priority.is_initialized()) { + return false; + } + if (hmi_status_priority.is_initialized()) { return false; } return true; @@ -2416,8 +2770,14 @@ void PolicyTable::ReportErrors(rpc::ValidationReport* report__) const { if (!vehicle_data.is_valid()) { vehicle_data.ReportErrors(&report__->ReportSubobject("vehicle_data")); } - if (!interrupt_manager_config.is_valid()) { - interrupt_manager_config.ReportErrors(&report__->ReportSubobject("interrupt_manager_config")); + if (!rpc_priority.is_valid()) { + rpc_priority.ReportErrors(&report__->ReportSubobject("rpc_priority")); + } + if (!app_priority.is_valid()) { + app_priority.ReportErrors(&report__->ReportSubobject("app_priority")); + } + if (!hmi_status_priority.is_valid()) { + hmi_status_priority.ReportErrors(&report__->ReportSubobject("hmi_status_priority")); } } @@ -2431,7 +2791,9 @@ void PolicyTable::SetPolicyTableType(PolicyTableType pt_type) { usage_and_error_counts.SetPolicyTableType(pt_type); device_data.SetPolicyTableType(pt_type); vehicle_data.SetPolicyTableType(pt_type); - interrupt_manager_config.SetPolicyTableType(pt_type); + rpc_priority.SetPolicyTableType(pt_type); + app_priority.SetPolicyTableType(pt_type); + hmi_status_priority.SetPolicyTableType(pt_type); } // Table methods diff --git a/src/components/policy/policy_regular/src/policy_table/validation.cc b/src/components/policy/policy_regular/src/policy_table/validation.cc index 17d6b5c2284..1f06c474cc3 100644 --- a/src/components/policy/policy_regular/src/policy_table/validation.cc +++ b/src/components/policy/policy_regular/src/policy_table/validation.cc @@ -234,7 +234,13 @@ bool ModuleConfig::Validate() const { return true; } -bool InterruptManagerConfig::Validate() const { +bool RpcPriority::Validate() const { + return true; +} +bool AppPriority::Validate() const { + return true; +} +bool HmiStatusPriority::Validate() const { return true; } diff --git a/src/components/policy/policy_regular/src/sql_pt_queries.cc b/src/components/policy/policy_regular/src/sql_pt_queries.cc index afcd8dc7fa3..8ab1792121a 100644 --- a/src/components/policy/policy_regular/src/sql_pt_queries.cc +++ b/src/components/policy/policy_regular/src/sql_pt_queries.cc @@ -469,38 +469,28 @@ const std::string kCreateSchema = " REFERENCES `vehicle_data_item_definition`(`name`, `key`) " "); " "CREATE TABLE IF NOT EXISTS `rpc_priority`( " - " `priority_value` VARCHAR(45) PRIMARY KEY NOT NULL, " - " `value` INTEGER NOT NULL, " - " CONSTRAINT `fk_rpc_priority_priority1` " - " FOREIGN KEY(`priority_value`) " - " REFERENCES `priority`(`value`) " + " `DialNumber` INTEGER NOT NULL, " + " `Alert` INTEGER NOT NULL, " + " `PerformAudioPassThru` INTEGER NOT NULL, " + " `PerformInteraction` INTEGER NOT NULL, " + " `ScrollableMessage` INTEGER NOT NULL, " + " `Slider` INTEGER NOT NULL, " + " `Speak` INTEGER NOT NULL " "); " - "CREATE INDEX IF NOT EXISTS " - "`rpc_priority.fk_rpc_priority_" - "priority1_idx` " - " ON `rpc_priority`(`priority_value`); " "CREATE TABLE IF NOT EXISTS `app_priority`( " - " `priority_value` VARCHAR(45) PRIMARY KEY NOT NULL, " - " `value` INTEGER NOT NULL, " - " CONSTRAINT `fk_app_priority_priority1` " - " FOREIGN KEY(`priority_value`) " - " REFERENCES `priority`(`value`) " + " `EMERGENCY` INTEGER NOT NULL, " + " `NAVIGATION` INTEGER NOT NULL, " + " `VOICE_COMMUNICATION` INTEGER NOT NULL, " + " `COMMUNICATION` INTEGER NOT NULL, " + " `NORMAL` INTEGER NOT NULL, " + " `NONE` INTEGER NOT NULL " "); " - "CREATE INDEX IF NOT EXISTS " - "`app_priority.fk_app_priority_" - "priority1_idx` " - " ON `app_priority`(`priority_value`); " "CREATE TABLE IF NOT EXISTS `hmi_status_priority`( " - " `priority_value` VARCHAR(45) PRIMARY KEY NOT NULL, " - " `value` INTEGER NOT NULL, " - " CONSTRAINT `fk_hmi_status_priority_priority1` " - " FOREIGN KEY(`priority_value`) " - " REFERENCES `priority`(`value`) " + " `FULL` INTEGER NOT NULL, " + " `LIMITED` INTEGER NOT NULL, " + " `BACKGROUND` INTEGER NOT NULL, " + " `NONE` INTEGER NOT NULL " "); " - "CREATE INDEX IF NOT EXISTS " - "`hmi_status_priority.fk_hmi_status_priority_" - "priority1_idx` " - " ON `hmi_status_priority`(`priority_value`); " "COMMIT;"; const std::string kInsertInitData = @@ -518,6 +508,26 @@ const std::string kInsertInitData = " VALUES(1, 0, 0, 0, 0, 0); " "INSERT OR IGNORE INTO `vehicle_data` (`schema_version`) " "VALUES('0'); " + "INSERT OR IGNORE INTO `rpc_priority` (`DialNumber`," + " `Alert`," + " `PerformAudioPassThru`," + " `PerformInteraction`," + " `ScrollableMessage`," + " `Slider`," + " `Speak`)" + " VALUES(0, 0, 0, 0, 0, 0, 0); " + "INSERT OR IGNORE INTO `app_priority` (`EMERGENCY`," + " `NAVIGATION`," + " `VOICE_COMMUNICATION`," + " `COMMUNICATION`," + " `NORMAL`," + " `NONE`)" + " VALUES(0, 0, 0, 0, 0, 0); " + "INSERT OR IGNORE INTO `hmi_Status_priority` (`FULL`," + " `LIMITED`," + " `BACKGROUND`," + " `NONE`)" + " VALUES(0, 0, 0, 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'); " @@ -652,17 +662,8 @@ const std::string kDropSchema = "DROP TABLE IF EXISTS `vehicle_data`; " "DROP TABLE IF EXISTS `vehicle_data_item_definition`; " "DROP TABLE IF EXISTS `vehicle_data_item_parameters`; " - "DROP INDEX IF EXISTS " - "`rpc_priority.fk_rpc_priority_" - "priority1_idx`; " "DROP TABLE IF EXISTS `rpc_priority`; " - "DROP INDEX IF EXISTS " - "`app_priority.fk_app_priority_" - "priority1_idx`; " "DROP TABLE IF EXISTS `app_priority`; " - "DROP INDEX IF EXISTS " - "`hmi_status_priority.fk_hmi_status_priority_" - "priority1_idx`; " "DROP TABLE IF EXISTS `hmi_status_priority`; " "COMMIT; " "VACUUM;"; @@ -1136,25 +1137,53 @@ const std::string kUpdateMetaParams = const std::string kUpdateMetaHardwareVersion = "UPDATE `module_meta` SET `hardware_version` = ? "; +const std::string kUpdateRpcPriority = + "UPDATE `rpc_priority` SET `DialNumber` = ?," + " `Alert` = ?," + " `PerformAudioPassThru` = ?," + " `PerformInteraction` = ?," + " `ScrollableMessage` = ?," + " `Slider` = ?," + " `Speak` = ?"; + +const std::string kUpdateAppPriority = + "UPDATE `app_priority` SET `EMERGENCY` = ?," + " `NAVIGATION` = ?," + " `VOICE_COMMUNICATION` = ?," + " `COMMUNICATION` = ?," + " `NORMAL` = ?," + " `NONE` = ?"; + +const std::string kUpdateHmiStatusPriority = + "UPDATE `hmi_status_priority` SET `FULL` = ?," + " `LIMITED` = ?," + " `BACKGROUND` = ?," + " `NONE` = ?"; + const std::string kSelectRpcPriority = - "SELECT `priority_value`, `value` FROM rpc_priority"; + "SELECT `DialNumber`, " + "`Alert`," + "`PerformAudioPassThru`," + "`PerformInteraction`," + "`ScrollableMessage`," + "`Slider`," + "`Speak`" + "FROM `rpc_priority`"; const std::string kSelectAppPriority = - "SELECT `priority_value`, `value` FROM app_priority"; + "SELECT `EMERGENCY`, " + "`NAVIGATION`," + "`VOICE_COMMUNICATION`," + "`COMMUNICATION`," + "`NORMAL`," + "`NONE`" + "FROM `app_priority`"; const std::string kSelectHmiStatusPriority = - "SELECT `priority_value`, `value` FROM hmi_status_priority"; - -const std::string kInsertRpcPriority = - "INSERT OR REPLACE INTO `rpc_priority` (`priority_value`, `value`) " - " VALUES (?, ?)"; - -const std::string kInsertAppPriority = - "INSERT OR REPLACE INTO `app_priority` (`priority_value`, `value`) " - " VALUES (?, ?)"; -const std::string kInsertHmiStatusPriority = - "INSERT OR REPLACE INTO `hmi_status_priority` (`priority_value`, `value`) " - " VALUES (?, ?)"; - + "SELECT `FULL`, " + "`LIMITED`," + "`BACKGROUND`," + "`NONE`" + "FROM `hmi_status_priority`"; } // namespace sql_pt } // namespace policy diff --git a/src/components/policy/policy_regular/src/sql_pt_representation.cc b/src/components/policy/policy_regular/src/sql_pt_representation.cc index abcc489adf3..9fb13241366 100644 --- a/src/components/policy/policy_regular/src/sql_pt_representation.cc +++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc @@ -464,7 +464,9 @@ std::shared_ptr SQLPTRepresentation::GenerateSnapshot() rpc::Optional > null_version; table->policy_table.vehicle_data->schema_version = null_version; } - GatherInterruptManagerConfig(&table->policy_table.interrupt_manager_config); + GatherRpcPriority(&table->policy_table.rpc_priority); + GatherAppPriority(&table->policy_table.app_priority); + GatherHmiStatusPriority(&table->policy_table.hmi_status_priority); return table; } @@ -876,40 +878,53 @@ bool SQLPTRepresentation::GatherVehicleDataItems( return true; } -void SQLPTRepresentation::GatherInterruptManagerConfig( - policy_table::InterruptManagerConfig* config) const { +void SQLPTRepresentation::GatherRpcPriority( + policy_table::RpcPriority* priority) const { SDL_LOG_INFO("Gather Configuration Info"); - utils::dbms::SQLQuery rpc_priority(db()); - if (!rpc_priority.Prepare(sql_pt::kSelectRpcPriority)) { - SDL_LOG_WARN("Incorrect select statement for priority"); + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kSelectRpcPriority) || !query.Next()) { + SDL_LOG_WARN("Incorrect select statement for rpc priority"); } else { - while (rpc_priority.Next()) { - config->rpc_priority[rpc_priority.GetString(0)] = - rpc_priority.GetInteger(1); - } + priority->DialNumber = query.GetInteger(0); + priority->Alert = query.GetInteger(1); + priority->PerformAudioPassThru = query.GetInteger(2); + priority->PerformInteraction = query.GetInteger(3); + priority->ScrollableMessage = query.GetInteger(4); + priority->Slider = query.GetInteger(5); + priority->Speak = query.GetInteger(6); } - SDL_LOG_INFO("rpc_priority.GetString(0) :" << rpc_priority.GetString(0)); - SDL_LOG_INFO("rpc_priority.GetInteger(1) :" << rpc_priority.GetInteger(1)); +} - utils::dbms::SQLQuery app_priority(db()); - if (!app_priority.Prepare(sql_pt::kSelectAppPriority)) { - SDL_LOG_WARN("Incorrect select statement for priority"); +void SQLPTRepresentation::GatherAppPriority( + policy_table::AppPriority* priority) const { + SDL_LOG_INFO("Gather Configuration Info"); + + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kSelectAppPriority) || !query.Next()) { + SDL_LOG_WARN("Incorrect select statement for app priority"); } else { - while (app_priority.Next()) { - config->app_priority[app_priority.GetString(0)] = - app_priority.GetInteger(1); - } + priority->EMERGENCY = query.GetInteger(0); + priority->NAVIGATION = query.GetInteger(1); + priority->VOICE_COMMUNICATION = query.GetInteger(2); + priority->COMMUNICATION = query.GetInteger(3); + priority->NORMAL = query.GetInteger(4); + priority->NONE = query.GetInteger(5); } +} + +void SQLPTRepresentation::GatherHmiStatusPriority( + policy_table::HmiStatusPriority* priority) const { + SDL_LOG_INFO("Gather Configuration Info"); - utils::dbms::SQLQuery hmi_status_priority(db()); - if (!hmi_status_priority.Prepare(sql_pt::kSelectRpcPriority)) { - SDL_LOG_WARN("Incorrect select statement for priority"); + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kSelectHmiStatusPriority) || !query.Next()) { + SDL_LOG_WARN("Incorrect select statement for hmi status priority"); } else { - while (hmi_status_priority.Next()) { - config->hmi_status_priority[hmi_status_priority.GetString(0)] = - hmi_status_priority.GetInteger(1); - } + priority->FULL = query.GetInteger(0); + priority->LIMITED = query.GetInteger(1); + priority->BACKGROUND = query.GetInteger(2); + priority->NONE = query.GetInteger(3); } } @@ -951,8 +966,18 @@ bool SQLPTRepresentation::Save(const policy_table::Table& table) { db_->RollbackTransaction(); return false; } - if (!SaveInterruptManagerConfig( - table.policy_table.interrupt_manager_config)) { + if (!SaveRpcPriority( + table.policy_table.rpc_priority)) { + db_->RollbackTransaction(); + return false; + } + if (!SaveAppPriority( + table.policy_table.app_priority)) { + db_->RollbackTransaction(); + return false; + } + if (!SaveHmiStatusPriority( + table.policy_table.hmi_status_priority)) { db_->RollbackTransaction(); return false; } @@ -2877,82 +2902,76 @@ bool SQLPTRepresentation::DeleteVehicleDataItems() const { return true; } -bool SQLPTRepresentation::SaveInterruptManagerConfig( - const policy_table::InterruptManagerConfig& config) { +bool SQLPTRepresentation::SaveRpcPriority( + const policy_table::RpcPriority& priority) { + utils::dbms::SQLQuery query(db()); SDL_LOG_AUTO_TRACE(); - if (!SaveRpcPriority(config.rpc_priority)) { + if (!query.Prepare(sql_pt::kUpdateRpcPriority)) { + SDL_LOG_WARN("Incorrect update statement for rpc priority."); return false; } - if (!SaveAppPriority(config.app_priority)) { - return false; - } + query.Bind(0, priority.DialNumber); + query.Bind(1, priority.Alert); + query.Bind(2, priority.PerformAudioPassThru); + query.Bind(3, priority.PerformInteraction); + query.Bind(4, priority.ScrollableMessage); + query.Bind(5, priority.Slider); + query.Bind(6, priority.Speak); - if (!SaveHmiStatusPriority(config.hmi_status_priority)) { + if (!query.Exec()) { + SDL_LOG_WARN("Incorrect update rpc priority"); return false; } + return true; } -bool SQLPTRepresentation::SaveRpcPriority( - const policy_table::rpc_priority_type& priority) { +bool SQLPTRepresentation::SaveAppPriority( + const policy_table::AppPriority& priority) { utils::dbms::SQLQuery query(db()); SDL_LOG_AUTO_TRACE(); - if (!query.Prepare(sql_pt::kInsertRpcPriority)) { - SDL_LOG_WARN("Incorrect insert statement for rpc priority."); - return false; - } - policy_table::rpc_priority_type::const_iterator it; - for (it = priority.begin(); it != priority.end(); ++it) { - query.Bind(0, it->first); - query.Bind(1, it->second); - if (!query.Exec() || !query.Reset()) { - SDL_LOG_WARN("Incorrect insert into rpc priority."); - return false; - } + if (!query.Prepare(sql_pt::kUpdateAppPriority)) { + SDL_LOG_WARN("Incorrect update statement for app priority."); + return false; } - return true; -} + query.Bind(0, priority.EMERGENCY); + query.Bind(1, priority.NAVIGATION); + query.Bind(2, priority.VOICE_COMMUNICATION); + query.Bind(3, priority.COMMUNICATION); + query.Bind(4, priority.NORMAL); + query.Bind(5, priority.NONE); -bool SQLPTRepresentation::SaveAppPriority( - const policy_table::app_priority_type& priority) { - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt::kInsertAppPriority)) { - SDL_LOG_WARN("Incorrect insert statement for rpc priority."); + if (!query.Exec()) { + SDL_LOG_WARN("Incorrect update app priority"); return false; } - policy_table::app_priority_type::const_iterator it; - for (it = priority.begin(); it != priority.end(); ++it) { - query.Bind(0, it->first); - query.Bind(1, it->second); - if (!query.Exec() || !query.Reset()) { - SDL_LOG_WARN("Incorrect insert into rpc priority."); - return false; - } - } return true; } bool SQLPTRepresentation::SaveHmiStatusPriority( - const policy_table::hmi_status_priority_type& priority) { + const policy_table::HmiStatusPriority& priority) { utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt::kInsertRpcPriority)) { - SDL_LOG_WARN("Incorrect insert statement for rpc priority."); + SDL_LOG_AUTO_TRACE(); + + if (!query.Prepare(sql_pt::kUpdateHmiStatusPriority)) { + SDL_LOG_WARN("Incorrect update statement for hmi status priority."); return false; } - policy_table::hmi_status_priority_type::const_iterator it; - for (it = priority.begin(); it != priority.end(); ++it) { - query.Bind(0, it->first); - query.Bind(1, it->second); - if (!query.Exec() || !query.Reset()) { - SDL_LOG_WARN("Incorrect insert into rpc priority."); - return false; - } + query.Bind(0, priority.FULL); + query.Bind(1, priority.LIMITED); + query.Bind(2, priority.BACKGROUND); + query.Bind(3, priority.NONE); + + if (!query.Exec()) { + SDL_LOG_WARN("Incorrect update hmi status priority"); + return false; } + return true; } diff --git a/src/components/policy/policy_regular/test/json/sdl_preloaded_pt_for_merge_initial.json b/src/components/policy/policy_regular/test/json/sdl_preloaded_pt_for_merge_initial.json index 9c71de360ce..d308c54fc77 100644 --- a/src/components/policy/policy_regular/test/json/sdl_preloaded_pt_for_merge_initial.json +++ b/src/components/policy/policy_regular/test/json/sdl_preloaded_pt_for_merge_initial.json @@ -2283,7 +2283,7 @@ "seconds_between_retries" : [ 1, 5, 25, 125, 625 ], "timeout_after_x_seconds" : 60 }, - "interrupt_manager_config": { + "rpc_priority":{ "DialNumber": 1, "Alert": 2, @@ -2307,6 +2307,6 @@ "BACKGROUND": 3, "NONE": 4 } - } + } } diff --git a/src/components/policy/policy_regular/test/json/sdl_preloaded_pt_for_merge_latest.json b/src/components/policy/policy_regular/test/json/sdl_preloaded_pt_for_merge_latest.json index ecbdd289ba9..53464af801e 100644 --- a/src/components/policy/policy_regular/test/json/sdl_preloaded_pt_for_merge_latest.json +++ b/src/components/policy/policy_regular/test/json/sdl_preloaded_pt_for_merge_latest.json @@ -2283,7 +2283,7 @@ "seconds_between_retries" : [ 1, 5, 25, 125, 625 ], "timeout_after_x_seconds" : 60 }, - "interrupt_manager_config": { + "rpc_priority":{ "DialNumber": 1, "Alert": 2, @@ -2307,6 +2307,6 @@ "BACKGROUND": 3, "NONE": 4 } - } + } }