From ee79e141698c15d552507b72f4bca28450ae62d4 Mon Sep 17 00:00:00 2001 From: Ira Lytvynenko Date: Fri, 26 May 2017 16:52:15 +0300 Subject: Make Size() function thread safe to avoid core dump --- src/components/application_manager/src/request_info.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/application_manager/src/request_info.cc b/src/components/application_manager/src/request_info.cc index 9a5828d939..6327315a24 100644 --- a/src/components/application_manager/src/request_info.cc +++ b/src/components/application_manager/src/request_info.cc @@ -257,6 +257,7 @@ uint32_t RequestInfoSet::RemoveMobileRequests() { } const size_t RequestInfoSet::Size() { + sync_primitives::AutoLock lock(this_lock_); CheckSetSizes(); return time_sorted_pending_requests_.size(); } -- cgit v1.2.1 From ab2b23a553acc63427f9c39e31b4cdc16317982f Mon Sep 17 00:00:00 2001 From: Ira Lytvynenko Date: Wed, 31 May 2017 13:12:58 +0300 Subject: Rename 'this_lock_' to 'pending_requests_lock_' --- .../include/application_manager/request_info.h | 3 +-- src/components/application_manager/src/request_info.cc | 14 +++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/components/application_manager/include/application_manager/request_info.h b/src/components/application_manager/include/application_manager/request_info.h index 216eb86cc5..09e9b02180 100644 --- a/src/components/application_manager/include/application_manager/request_info.h +++ b/src/components/application_manager/include/application_manager/request_info.h @@ -254,8 +254,7 @@ class RequestInfoSet { TimeSortedRequestInfoSet time_sorted_pending_requests_; HashSortedRequestInfoSet hash_sorted_pending_requests_; - // the lock caled this_lock_, since the class represent collection by itself. - sync_primitives::Lock this_lock_; + sync_primitives::Lock pending_requests_lock_; }; /** diff --git a/src/components/application_manager/src/request_info.cc b/src/components/application_manager/src/request_info.cc index 6327315a24..a485a89b01 100644 --- a/src/components/application_manager/src/request_info.cc +++ b/src/components/application_manager/src/request_info.cc @@ -123,7 +123,7 @@ bool RequestInfoSet::Add(RequestInfoPtr request_info) { logger_, "Add request app_id = " << request_info->app_id() << "; corr_id = " << request_info->requestId()); - sync_primitives::AutoLock lock(this_lock_); + sync_primitives::AutoLock lock(pending_requests_lock_); CheckSetSizes(); const std::pair& insert_resilt = hash_sorted_pending_requests_.insert(request_info); @@ -154,7 +154,7 @@ RequestInfoPtr RequestInfoSet::Find(const uint32_t connection_key, utils::SharedPtr request_info_for_search( new FakeRequestInfo(connection_key, correlation_id)); - sync_primitives::AutoLock lock(this_lock_); + sync_primitives::AutoLock lock(pending_requests_lock_); HashSortedRequestInfoSet::iterator it = hash_sorted_pending_requests_.find(request_info_for_search); if (it != hash_sorted_pending_requests_.end()) { @@ -166,7 +166,7 @@ RequestInfoPtr RequestInfoSet::Find(const uint32_t connection_key, RequestInfoPtr RequestInfoSet::Front() { RequestInfoPtr result; - sync_primitives::AutoLock lock(this_lock_); + sync_primitives::AutoLock lock(pending_requests_lock_); TimeSortedRequestInfoSet::iterator it = time_sorted_pending_requests_.begin(); if (it != time_sorted_pending_requests_.end()) { result = *it; @@ -176,7 +176,7 @@ RequestInfoPtr RequestInfoSet::Front() { RequestInfoPtr RequestInfoSet::FrontWithNotNullTimeout() { LOG4CXX_AUTO_TRACE(logger_); - sync_primitives::AutoLock lock(this_lock_); + sync_primitives::AutoLock lock(pending_requests_lock_); RequestInfoPtr result; TimeSortedRequestInfoSet::iterator it = time_sorted_pending_requests_.begin(); while (it != time_sorted_pending_requests_.end()) { @@ -220,7 +220,7 @@ bool RequestInfoSet::Erase(const RequestInfoPtr request_info) { } bool RequestInfoSet::RemoveRequest(const RequestInfoPtr request_info) { - sync_primitives::AutoLock lock(this_lock_); + sync_primitives::AutoLock lock(pending_requests_lock_); return Erase(request_info); } @@ -229,7 +229,7 @@ uint32_t RequestInfoSet::RemoveRequests( LOG4CXX_AUTO_TRACE(logger_); uint32_t erased = 0; - sync_primitives::AutoLock lock(this_lock_); + sync_primitives::AutoLock lock(pending_requests_lock_); HashSortedRequestInfoSet::iterator it = std::find_if(hash_sorted_pending_requests_.begin(), hash_sorted_pending_requests_.end(), @@ -257,7 +257,7 @@ uint32_t RequestInfoSet::RemoveMobileRequests() { } const size_t RequestInfoSet::Size() { - sync_primitives::AutoLock lock(this_lock_); + sync_primitives::AutoLock lock(pending_requests_lock_); CheckSetSizes(); return time_sorted_pending_requests_.size(); } -- cgit v1.2.1 From 5bc69aa9083145f3f5c27f50f6f7ddb79f47a3a0 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Thu, 6 Sep 2018 14:45:10 -0400 Subject: Set proper function id in removeHMIFakeParameters --- .../include/application_manager/application_manager_impl.h | 3 ++- .../commands/mobile/set_interior_vehicle_data_request.cc | 3 ++- .../test/commands/set_interior_vehicle_data_request_test.cc | 2 +- .../application_manager/src/application_manager_impl.cc | 13 ++++++++++++- .../include/application_manager/application_manager.h | 3 ++- .../test/application_manager/mock_application_manager.h | 5 +++-- 6 files changed, 22 insertions(+), 7 deletions(-) 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 d5f9f9b7f8..4f4faa15a8 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 @@ -553,7 +553,8 @@ class ApplicationManagerImpl void StartDevicesDiscovery(); void RemoveHMIFakeParameters( - application_manager::commands::MessageSharedPtr& message) OVERRIDE; + application_manager::commands::MessageSharedPtr& message, + const hmi_apis::FunctionID::eType& function_id) OVERRIDE; /** * @brief TerminateRequest forces termination of request diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc index 88df9d8382..b81008155d 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc @@ -488,7 +488,8 @@ void SetInteriorVehicleDataRequest::Execute() { CutOffReadOnlyParams(module_data); } - application_manager_.RemoveHMIFakeParameters(message_); + application_manager_.RemoveHMIFakeParameters( + message_, hmi_apis::FunctionID::RC_SetInteriorVehicleData); app_mngr::ApplicationSharedPtr app = application_manager_.application(connection_key()); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc index 47e1c9a389..b1cb8271f5 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc @@ -184,7 +184,7 @@ TEST_F( EXPECT_CALL(mock_hmi_capabilities_, rc_capability()) .WillOnce(Return(nullptr)); - EXPECT_CALL(app_mngr_, RemoveHMIFakeParameters(_)); + EXPECT_CALL(app_mngr_, RemoveHMIFakeParameters(_, _)); EXPECT_CALL( mock_rpc_service_, diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 69040997fe..02c41e0472 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -1693,10 +1693,21 @@ void ApplicationManagerImpl::TerminateRequest(const uint32_t connection_key, } void ApplicationManagerImpl::RemoveHMIFakeParameters( - application_manager::commands::MessageSharedPtr& message) { + application_manager::commands::MessageSharedPtr& message, + const hmi_apis::FunctionID::eType& function_id) { LOG4CXX_AUTO_TRACE(logger_); hmi_apis::HMI_API factory; + if (!(*message)[jhs::S_PARAMS].keyExists(jhs::S_FUNCTION_ID)) { + LOG4CXX_ERROR(logger_, + "RemoveHMIFakeParameters message missing function id"); + return; + } + mobile_apis::FunctionID::eType mobile_function_id = + static_cast( + (*message)[jhs::S_PARAMS][jhs::S_FUNCTION_ID].asInt()); + (*message)[jhs::S_PARAMS][jhs::S_FUNCTION_ID] = function_id; factory.attachSchema(*message, true); + (*message)[jhs::S_PARAMS][jhs::S_FUNCTION_ID] = mobile_function_id; } bool ApplicationManagerImpl::Init(resumption::LastState& last_state, diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h index 9b482b9e62..6df91d748c 100644 --- a/src/components/include/application_manager/application_manager.h +++ b/src/components/include/application_manager/application_manager.h @@ -316,7 +316,8 @@ class ApplicationManager { virtual const std::set GetAppsSubscribedForWayPoints() const = 0; virtual void RemoveHMIFakeParameters( - application_manager::commands::MessageSharedPtr& message) = 0; + application_manager::commands::MessageSharedPtr& message, + const hmi_apis::FunctionID::eType& function_id) = 0; virtual mobile_api::HMILevel::eType GetDefaultHmiLevel( ApplicationConstSharedPtr application) const = 0; 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 e6e39bce58..f6a0c181c2 100644 --- a/src/components/include/test/application_manager/mock_application_manager.h +++ b/src/components/include/test/application_manager/mock_application_manager.h @@ -124,8 +124,9 @@ class MockApplicationManager : public application_manager::ApplicationManager { void(const std::shared_ptr app)); MOCK_METHOD1(SendDriverDistractionState, void(application_manager::ApplicationSharedPtr app)); - MOCK_METHOD1(RemoveHMIFakeParameters, - void(application_manager::commands::MessageSharedPtr& message)); + MOCK_METHOD2(RemoveHMIFakeParameters, + void(application_manager::commands::MessageSharedPtr& message, + const hmi_apis::FunctionID::eType& function_id)); MOCK_CONST_METHOD1( GetDefaultHmiLevel, mobile_apis::HMILevel::eType( -- cgit v1.2.1 From 262ebc612693a97ddb846fd59c8b4c3efd71fd8b Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Thu, 6 Sep 2018 15:08:48 -0400 Subject: Update HMI API interface versions for 5.0.0 --- src/components/interfaces/HMI_API.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index b4d4d2c850..0b6eed072d 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -34,7 +34,7 @@ - + @@ -3426,7 +3426,7 @@ - + Request from SDL to HMI to obtain current UTC time. @@ -3920,7 +3920,7 @@ - + RPCs for communication between TTS and SDL. Method is invoked at system start-up. SDL requests the information about all supported hardware and their capabilities @@ -4046,7 +4046,7 @@ - + Request from SDL to show an alert message on the display. @@ -4792,7 +4792,7 @@ - + Method is invoked at system startup. Response should provide information about presence of any of vehicle information modules (ECU, GPS, etc) and their readiness to cooperate with SDL. @@ -5505,7 +5505,7 @@ - + @@ -5678,7 +5678,7 @@ - + Method is invoked at system startup. Response should provide information about presence of any of remote controllable module and its readiness to cooperate with SDL. -- cgit v1.2.1 From 586c049050baa10b6f2de2bf8fcb4635e732f4ad Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Fri, 7 Sep 2018 13:40:46 -0400 Subject: Fix capabilities check for siriusxmAvailable Also fix reverted refactoring change --- .../mobile/set_interior_vehicle_data_request.cc | 69 ++++++++++++---------- 1 file changed, 37 insertions(+), 32 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc index b81008155d..cfd8caae39 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc @@ -267,6 +267,32 @@ ModuleCapability GetLightNameCapabilities( capabilitiesStatus::missedLightName); } +ModuleCapability GetRadioBandByCapabilities( + const smart_objects::SmartObject& capabilities_status, + const smart_objects::SmartObject& request_parameter) { + mobile_apis::RadioBand::eType radio_band = + static_cast(request_parameter.asUInt()); + if (mobile_apis::RadioBand::XM == radio_band) { + if (!capabilities_status.keyExists(strings::kSiriusxmRadioAvailable)) { + LOG4CXX_DEBUG(logger_, + "Capability " + << strings::kSiriusxmRadioAvailable + << " is missed in RemoteControl capabilities"); + return std::make_pair(strings::kSiriusxmRadioAvailable, + capabilitiesStatus::missedParam); + } + if (!capabilities_status[strings::kSiriusxmRadioAvailable].asBool()) { + LOG4CXX_DEBUG(logger_, + "Capability " + << strings::kSiriusxmRadioAvailable + << " is switched off in RemoteControl capabilities"); + return std::make_pair(strings::kSiriusxmRadioAvailable, + capabilitiesStatus::missedParam); + } + } + return std::make_pair("", capabilitiesStatus::success); +} + /** * @brief Check whether the exists light data related to correspondent * capabilities @@ -303,40 +329,18 @@ ModuleCapability GetControlDataCapabilities( return light_capability; } - - const capabilitiesStatus status_item_capability = - GetItemCapability(capabilities[0], - mapping, - request_parameter, - mobile_apis::Result::UNSUPPORTED_RESOURCE); - - if (capabilitiesStatus::success != status_item_capability) { - return std::make_pair("", status_item_capability); + if (message_params::kBand == request_parameter) { + ModuleCapability radio_capability = GetRadioBandByCapabilities( + capabilities, control_data[request_parameter]); + if (capabilitiesStatus::success != radio_capability.second) { + return radio_capability; + } } - } - - return std::make_pair("", capabilitiesStatus::success); -} - -/** - * @brief Check whether the exists hmi data related to correspondent - * capabilities - * @param smart object of capabilities - * @param smart object of control_data - * @return pair of state and capability status - ModuleCapability - */ -ModuleCapability GetHmiControlDataCapabilities( - const smart_objects::SmartObject& capabilities, - const smart_objects::SmartObject& control_data) { - LOG4CXX_AUTO_TRACE(logger_); - std::map mapping = - GetModuleDataToCapabilitiesMapping(); - for (auto it = control_data.map_begin(); it != control_data.map_end(); ++it) { const capabilitiesStatus status_item_capability = GetItemCapability(capabilities, mapping, - it->first, + request_parameter, mobile_apis::Result::UNSUPPORTED_RESOURCE); if (capabilitiesStatus::success != status_item_capability) { @@ -376,12 +380,13 @@ ModuleCapability GetModuleDataCapabilities( const smart_objects::SmartObject& caps = rc_capabilities[capabilities_key]; - if (message_params::kHmiSettingsControlData == module_data_key) { + if (message_params::kHmiSettingsControlData == module_data_key || + message_params::kLightControlData == module_data_key) { module_data_capabilities = - GetHmiControlDataCapabilities(caps, module_data[module_data_key]); + GetControlDataCapabilities(caps, module_data[module_data_key]); } else { module_data_capabilities = - GetControlDataCapabilities(caps, module_data[module_data_key]); + GetControlDataCapabilities(caps[0], module_data[module_data_key]); } } } -- cgit v1.2.1 From af12f2ad080611f14d495e822dc39992006a8aac Mon Sep 17 00:00:00 2001 From: JackLivio Date: Fri, 7 Sep 2018 16:11:26 -0400 Subject: Update missing RPC changes: SpaceAvailable & CurrentTemperatureAvailable --- src/components/interfaces/MOBILE_API.xml | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index c36c4a4533..76d922136e 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -3204,6 +3204,12 @@ The short friendly name of the climate control module. It should not be used to identify a module by mobile application. + + + Availability of the reading of current temperature. + True: Available, False: Not Available, Not present: Not Available. + + Availability of the control of fan speed. @@ -5987,11 +5993,14 @@ - + Provides the total local space available in SDL Core for the registered app. If the transfer has systemFile enabled, then the value will be set to 0 automatically. + + + @@ -6032,8 +6041,14 @@ - - Provides the total local space available on the module for the registered app. + + + Provides the total local space available in SDL Core for the registered app. + If the transfer has systemFile enabled, then the value will be set to 0 automatically. + + + + @@ -6076,8 +6091,14 @@ - - Provides the total local space available on the module for the registered app. + + + Provides the total local space available in SDL Core for the registered app. + If the transfer has systemFile enabled, then the value will be set to 0 automatically. + + + + -- cgit v1.2.1 From 9eb0abe2fc0576fa0abbba67964bc4a516cd73e1 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Fri, 7 Sep 2018 16:16:16 -0400 Subject: Fix Spacing --- src/components/interfaces/MOBILE_API.xml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 76d922136e..670793f1c4 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -3205,11 +3205,11 @@ It should not be used to identify a module by mobile application. - - Availability of the reading of current temperature. - True: Available, False: Not Available, Not present: Not Available. - - + + Availability of the reading of current temperature. + True: Available, False: Not Available, Not present: Not Available. + + Availability of the control of fan speed. @@ -5999,8 +5999,8 @@ If the transfer has systemFile enabled, then the value will be set to 0 automatically. - - + + @@ -6047,8 +6047,8 @@ If the transfer has systemFile enabled, then the value will be set to 0 automatically. - - + + @@ -6097,8 +6097,8 @@ If the transfer has systemFile enabled, then the value will be set to 0 automatically. - - + + -- cgit v1.2.1 From 2dd7e2a810de7b15ebc5eaa947e47170bfbcef2a Mon Sep 17 00:00:00 2001 From: Alexander Kutsan Date: Tue, 6 Feb 2018 11:36:44 +0200 Subject: Add function to filter invalid parametres and RPCs --- .../policy_external/src/policy_manager_impl.cc | 47 +++++++++++++++++++++- .../policy_regular/src/policy_manager_impl.cc | 46 +++++++++++++++++++++ 2 files changed, 92 insertions(+), 1 deletion(-) 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 e2b0d6524f..9dffaf52e3 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -271,6 +271,51 @@ std::string PolicyManagerImpl::GetLockScreenIconUrl() const { return cache_->GetLockScreenIconUrl(); } +/** + * @brief FilterInvalidFunctions filter functions that are absent in schema + * @param rpcs list of functions to filter + */ +void FilterInvalidFunctions(policy_table::Rpc& rpcs) { + policy_table::Rpc valid_rpcs; + for (const auto& rpc : rpcs) { + const std::string& rpc_name = rpc.first; + policy_table::FunctionID function_id; + if (policy_table::EnumFromJsonString(rpc_name, &function_id)) { + valid_rpcs.insert(rpc); + } + } + rpcs.swap(valid_rpcs); +} + +/** + * @brief FilterInvalidParameters filter parameters that not present in schema + * @param rpc_parameters parameters to filter + */ +void FilterInvalidParameters(policy_table::RpcParameters& rpc_parameters) { + policy_table::Parameters valid_params; + for (auto& param : *(rpc_parameters.parameters)) { + if (param.is_valid()) { + valid_params.push_back(param); + } + } + rpc_parameters.parameters->swap(valid_params); +} + +/** + * @brief FilterPolicyTable filter values that not present in schema + * @param pt policy table to filter + */ +void FilterPolicyTable(policy_table::PolicyTable& pt) { + for (auto& group : pt.functional_groupings) { + policy_table::Rpc& rpcs = group.second.rpcs; + FilterInvalidFunctions(rpcs); + + for (auto& func : rpcs) { + FilterInvalidParameters(func.second); + } + } +} + bool PolicyManagerImpl::LoadPT(const std::string& file, const BinaryMessage& pt_content) { LOG4CXX_INFO(logger_, "LoadPT of size " << pt_content.size()); @@ -287,7 +332,7 @@ bool PolicyManagerImpl::LoadPT(const std::string& file, } file_system::DeleteFile(file); - + FilterPolicyTable(pt_update->policy_table); if (!IsPTValid(pt_update, policy_table::PT_UPDATE)) { wrong_ptu_update_received_ = true; update_status_manager_.OnWrongUpdateReceived(); 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 f4b6f0ae03..8c70437bfc 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -143,6 +143,51 @@ void PolicyManagerImpl::CheckTriggers() { } } +/** + * @brief FilterInvalidFunctions filter functions that are not present in schema + * @param rpcs list of functions to filter + */ +void FilterInvalidFunctions(policy_table::Rpc& rpcs) { + policy_table::Rpc valid_rpcs; + for (const auto& rpc : rpcs) { + const std::string& rpc_name = rpc.first; + policy_table::FunctionID function_id; + if (policy_table::EnumFromJsonString(rpc_name, &function_id)) { + valid_rpcs.insert(rpc); + } + } + rpcs.swap(valid_rpcs); +} + +/** + * @brief FilterInvalidParameters filter parameters that not present in schema + * @param rpc_parameters parameters to filter + */ +void FilterInvalidParameters(policy_table::RpcParameters& rpc_parameters) { + policy_table::Parameters valid_params; + for (auto& param : *(rpc_parameters.parameters)) { + if (param.is_valid()) { + valid_params.push_back(param); + } + } + rpc_parameters.parameters->swap(valid_params); +} + +/** + * @brief FilterPolicyTable filter values that not present in schema + * @param pt policy table to filter + */ +void FilterPolicyTable(policy_table::PolicyTable& pt) { + for (auto& group : pt.functional_groupings) { + policy_table::Rpc& rpcs = group.second.rpcs; + FilterInvalidFunctions(rpcs); + + for (auto& func : rpcs) { + FilterInvalidParameters(func.second); + } + } +} + bool PolicyManagerImpl::LoadPT(const std::string& file, const BinaryMessage& pt_content) { LOG4CXX_INFO(logger_, "LoadPT of size " << pt_content.size()); @@ -168,6 +213,7 @@ bool PolicyManagerImpl::LoadPT(const std::string& file, file_system::DeleteFile(file); + FilterPolicyTable(pt_update->policy_table); if (!IsPTValid(pt_update, policy_table::PT_UPDATE)) { wrong_ptu_update_received_ = true; update_status_manager_.OnWrongUpdateReceived(); -- cgit v1.2.1 From 78ac9a2cd006eed81fdbf273fea7dba531113830 Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 10 Sep 2018 13:59:48 +0300 Subject: Add FunctionID to enums --- .../include/policy/policy_table/enums.h | 366 ++++++++++++ .../policy_external/src/policy_table/enums.cc | 358 +++++++++++ .../include/policy/policy_table/enums.h | 365 ++++++++++++ .../policy_regular/src/policy_table/enums.cc | 656 +++++++++++++++++++++ 4 files changed, 1745 insertions(+) diff --git a/src/components/policy/policy_external/include/policy/policy_table/enums.h b/src/components/policy/policy_external/include/policy/policy_table/enums.h index a31e955d99..2ab6ade03b 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_external/include/policy/policy_table/enums.h @@ -180,6 +180,372 @@ bool IsValidEnum(ModuleType val); const char* EnumToJsonString(ModuleType val); bool EnumFromJsonString(const std::string& literal, ModuleType* result); +/** + * @brief Enumeration FunctionID. + * + * Enumeration linking function names with function IDs in AppLink protocol. + *Assumes enumeration starts at value 0. + */ +enum FunctionID { + /** + * @brief RESERVED. + */ + RESERVED = 0, + + /** + * @brief RegisterAppInterfaceID. + */ + RegisterAppInterfaceID = 1, + + /** + * @brief UnregisterAppInterfaceID. + */ + UnregisterAppInterfaceID = 2, + + /** + * @brief SetGlobalPropertiesID. + */ + SetGlobalPropertiesID = 3, + + /** + * @brief ResetGlobalPropertiesID. + */ + ResetGlobalPropertiesID = 4, + + /** + * @brief AddCommandID. + */ + AddCommandID = 5, + + /** + * @brief DeleteCommandID. + */ + DeleteCommandID = 6, + + /** + * @brief AddSubMenuID. + */ + AddSubMenuID = 7, + + /** + * @brief DeleteSubMenuID. + */ + DeleteSubMenuID = 8, + + /** + * @brief CreateInteractionChoiceSetID. + */ + CreateInteractionChoiceSetID = 9, + + /** + * @brief PerformInteractionID. + */ + PerformInteractionID = 10, + + /** + * @brief DeleteInteractionChoiceSetID. + */ + DeleteInteractionChoiceSetID = 11, + + /** + * @brief AlertID. + */ + AlertID = 12, + + /** + * @brief ShowID. + */ + ShowID = 13, + + /** + * @brief SpeakID. + */ + SpeakID = 14, + + /** + * @brief SetMediaClockTimerID. + */ + SetMediaClockTimerID = 15, + + /** + * @brief PerformAudioPassThruID. + */ + PerformAudioPassThruID = 16, + + /** + * @brief EndAudioPassThruID. + */ + EndAudioPassThruID = 17, + + /** + * @brief SubscribeButtonID. + */ + SubscribeButtonID = 18, + + /** + * @brief UnsubscribeButtonID. + */ + UnsubscribeButtonID = 19, + + /** + * @brief SubscribeVehicleDataID. + */ + SubscribeVehicleDataID = 20, + + /** + * @brief UnsubscribeVehicleDataID. + */ + UnsubscribeVehicleDataID = 21, + + /** + * @brief GetVehicleDataID. + */ + GetVehicleDataID = 22, + + /** + * @brief ReadDIDID. + */ + ReadDIDID = 23, + + /** + * @brief GetDTCsID. + */ + GetDTCsID = 24, + + /** + * @brief ScrollableMessageID. + */ + ScrollableMessageID = 25, + + /** + * @brief SliderID. + */ + SliderID = 26, + + /** + * @brief ShowConstantTBTID. + */ + ShowConstantTBTID = 27, + + /** + * @brief AlertManeuverID. + */ + AlertManeuverID = 28, + + /** + * @brief UpdateTurnListID. + */ + UpdateTurnListID = 29, + + /** + * @brief ChangeRegistrationID. + */ + ChangeRegistrationID = 30, + + /** + * @brief GenericResponseID. + */ + GenericResponseID = 31, + + /** + * @brief PutFileID. + */ + PutFileID = 32, + + /** + * @brief DeleteFileID. + */ + DeleteFileID = 33, + + /** + * @brief ListFilesID. + */ + ListFilesID = 34, + + /** + * @brief SetAppIconID. + */ + SetAppIconID = 35, + + /** + * @brief SetDisplayLayoutID. + */ + SetDisplayLayoutID = 36, + + /** + * @brief DiagnosticMessageID. + */ + DiagnosticMessageID = 37, + + /** + * @brief SystemRequestID. + */ + SystemRequestID = 38, + + /** + * @brief SendLocationID. + */ + SendLocationID = 39, + + /** + * @brief DialNumberID. + */ + DialNumberID = 40, + + /** + * @brief ButtonPressID. + */ + ButtonPressID = 41, + + /** + * @brief GetInteriorVehicleDataID. + */ + GetInteriorVehicleDataID = 43, + + /** + * @brief SetInteriorVehicleDataID. + */ + SetInteriorVehicleDataID = 44, + + /** + * @brief GetWayPointsID. + */ + GetWayPointsID = 45, + + /** + * @brief SubscribeWayPointsID. + */ + SubscribeWayPointsID = 46, + + /** + * @brief UnsubscribeWayPointsID. + */ + UnsubscribeWayPointsID = 47, + + /** + * @brief GetSystemCapabilityID. + */ + GetSystemCapabilityID = 48, + + /** + * @brief SendHapticDataID. + */ + SendHapticDataID = 49, + + /** + * @brief OnHMIStatusID. + */ + OnHMIStatusID = 32768, + + /** + * @brief OnAppInterfaceUnregisteredID. + */ + OnAppInterfaceUnregisteredID = 32769, + + /** + * @brief OnButtonEventID. + */ + OnButtonEventID = 32770, + + /** + * @brief OnButtonPressID. + */ + OnButtonPressID = 32771, + + /** + * @brief OnVehicleDataID. + */ + OnVehicleDataID = 32772, + + /** + * @brief OnCommandID. + */ + OnCommandID = 32773, + + /** + * @brief OnTBTClientStateID. + */ + OnTBTClientStateID = 32774, + + /** + * @brief OnDriverDistractionID. + */ + OnDriverDistractionID = 32775, + + /** + * @brief OnPermissionsChangeID. + */ + OnPermissionsChangeID = 32776, + + /** + * @brief OnAudioPassThruID. + */ + OnAudioPassThruID = 32777, + + /** + * @brief OnLanguageChangeID. + */ + OnLanguageChangeID = 32778, + + /** + * @brief OnKeyboardInputID. + */ + OnKeyboardInputID = 32779, + + /** + * @brief OnTouchEventID. + */ + OnTouchEventID = 32780, + + /** + * @brief OnSystemRequestID. + */ + OnSystemRequestID = 32781, + + /** + * @brief OnHashChangeID. + */ + OnHashChangeID = 32782, + + /** + * @brief OnInteriorVehicleDataID. + */ + OnInteriorVehicleDataID = 32783, + + /** + * @brief OnWayPointChangeID. + */ + OnWayPointChangeID = 32784, + + /** + * @brief OnRCStatusID. + */ + OnRCStatusID = 32785, + + /** + * @brief EncodedSyncPDataID. + */ + EncodedSyncPDataID = 65536, + + /** + * @brief SyncPDataID. + */ + SyncPDataID = 65537, + + /** + * @brief OnEncodedSyncPDataID. + */ + OnEncodedSyncPDataID = 98304, + + /** + * @brief OnSyncPDataID. + */ + OnSyncPDataID = 98305 +}; +bool IsValidEnum(FunctionID val); +const char* EnumToJsonString(FunctionID val); +bool EnumFromJsonString(const std::string& literal, FunctionID* result); + extern const std::string kDefaultApp; extern const std::string kPreDataConsentApp; extern const std::string kDeviceApp; diff --git a/src/components/policy/policy_external/src/policy_table/enums.cc b/src/components/policy/policy_external/src/policy_table/enums.cc index 31a6fc86e6..5152cc38ef 100644 --- a/src/components/policy/policy_external/src/policy_table/enums.cc +++ b/src/components/policy/policy_external/src/policy_table/enums.cc @@ -833,6 +833,364 @@ bool EnumFromJsonString(const std::string& literal, ModuleType* result) { } } +bool EnumFromJsonString(const std::string& literal, FunctionID* result) { + if ("RESERVE" == literal) { + *result = RESERVED; + return true; + } + + if ("RegisterAppInterface" == literal) { + *result = RegisterAppInterfaceID; + return true; + } + + if ("UnregisterAppInterface" == literal) { + *result = UnregisterAppInterfaceID; + return true; + } + + if ("SetGlobalProperties" == literal) { + *result = SetGlobalPropertiesID; + return true; + } + + if ("ResetGlobalProperties" == literal) { + *result = ResetGlobalPropertiesID; + return true; + } + + if ("AddCommand" == literal) { + *result = AddCommandID; + return true; + } + + if ("DeleteCommand" == literal) { + *result = DeleteCommandID; + return true; + } + + if ("AddSubMenu" == literal) { + *result = AddSubMenuID; + return true; + } + + if ("DeleteSubMenu" == literal) { + *result = DeleteSubMenuID; + return true; + } + + if ("CreateInteractionChoiceSet" == literal) { + *result = CreateInteractionChoiceSetID; + return true; + } + + if ("PerformInteraction" == literal) { + *result = PerformInteractionID; + return true; + } + + if ("DeleteInteractionChoiceSet" == literal) { + *result = DeleteInteractionChoiceSetID; + return true; + } + + if ("Alert" == literal) { + *result = AlertID; + return true; + } + + if ("Show" == literal) { + *result = ShowID; + return true; + } + + if ("Speak" == literal) { + *result = SpeakID; + return true; + } + + if ("SetMediaClockTimer" == literal) { + *result = SetMediaClockTimerID; + return true; + } + + if ("PerformAudioPassThru" == literal) { + *result = PerformAudioPassThruID; + return true; + } + + if ("EndAudioPassThru" == literal) { + *result = EndAudioPassThruID; + return true; + } + + if ("SubscribeButton" == literal) { + *result = SubscribeButtonID; + return true; + } + + if ("UnsubscribeButton" == literal) { + *result = UnsubscribeButtonID; + return true; + } + + if ("SubscribeVehicleData" == literal) { + *result = SubscribeVehicleDataID; + return true; + } + + if ("UnsubscribeVehicleData" == literal) { + *result = UnsubscribeVehicleDataID; + return true; + } + + if ("GetVehicleData" == literal) { + *result = GetVehicleDataID; + return true; + } + + if ("ReadD" == literal) { + *result = ReadDIDID; + return true; + } + + if ("GetDTCs" == literal) { + *result = GetDTCsID; + return true; + } + + if ("ScrollableMessage" == literal) { + *result = ScrollableMessageID; + return true; + } + + if ("Slider" == literal) { + *result = SliderID; + return true; + } + + if ("ShowConstantTBT" == literal) { + *result = ShowConstantTBTID; + return true; + } + + if ("AlertManeuver" == literal) { + *result = AlertManeuverID; + return true; + } + + if ("UpdateTurnList" == literal) { + *result = UpdateTurnListID; + return true; + } + + if ("ChangeRegistration" == literal) { + *result = ChangeRegistrationID; + return true; + } + + if ("GenericResponse" == literal) { + *result = GenericResponseID; + return true; + } + + if ("PutFile" == literal) { + *result = PutFileID; + return true; + } + + if ("DeleteFile" == literal) { + *result = DeleteFileID; + return true; + } + + if ("ListFiles" == literal) { + *result = ListFilesID; + return true; + } + + if ("SetAppIcon" == literal) { + *result = SetAppIconID; + return true; + } + + if ("SetDisplayLayout" == literal) { + *result = SetDisplayLayoutID; + return true; + } + + if ("DiagnosticMessage" == literal) { + *result = DiagnosticMessageID; + return true; + } + + if ("SystemRequest" == literal) { + *result = SystemRequestID; + return true; + } + + if ("SendLocation" == literal) { + *result = SendLocationID; + return true; + } + + if ("DialNumber" == literal) { + *result = DialNumberID; + return true; + } + + if ("ButtonPress" == literal) { + *result = ButtonPressID; + return true; + } + + if ("GetInteriorVehicleData" == literal) { + *result = GetInteriorVehicleDataID; + return true; + } + + if ("SetInteriorVehicleData" == literal) { + *result = SetInteriorVehicleDataID; + return true; + } + + if ("GetWayPoints" == literal) { + *result = GetWayPointsID; + return true; + } + + if ("SubscribeWayPoints" == literal) { + *result = SubscribeWayPointsID; + return true; + } + + if ("UnsubscribeWayPoints" == literal) { + *result = UnsubscribeWayPointsID; + return true; + } + + if ("GetSystemCapability" == literal) { + *result = GetSystemCapabilityID; + return true; + } + + if ("SendHapticData" == literal) { + *result = SendHapticDataID; + return true; + } + + if ("OnHMIStatus" == literal) { + *result = OnHMIStatusID; + return true; + } + + if ("OnAppInterfaceUnregistered" == literal) { + *result = OnAppInterfaceUnregisteredID; + return true; + } + + if ("OnButtonEvent" == literal) { + *result = OnButtonEventID; + return true; + } + + if ("OnButtonPress" == literal) { + *result = OnButtonPressID; + return true; + } + + if ("OnVehicleData" == literal) { + *result = OnVehicleDataID; + return true; + } + + if ("OnCommand" == literal) { + *result = OnCommandID; + return true; + } + + if ("OnTBTClientState" == literal) { + *result = OnTBTClientStateID; + return true; + } + + if ("OnDriverDistraction" == literal) { + *result = OnDriverDistractionID; + return true; + } + + if ("OnPermissionsChange" == literal) { + *result = OnPermissionsChangeID; + return true; + } + + if ("OnAudioPassThru" == literal) { + *result = OnAudioPassThruID; + return true; + } + + if ("OnLanguageChange" == literal) { + *result = OnLanguageChangeID; + return true; + } + + if ("OnKeyboardInput" == literal) { + *result = OnKeyboardInputID; + return true; + } + + if ("OnTouchEvent" == literal) { + *result = OnTouchEventID; + return true; + } + + if ("OnSystemRequest" == literal) { + *result = OnSystemRequestID; + return true; + } + + if ("OnHashChange" == literal) { + *result = OnHashChangeID; + return true; + } + + if ("OnInteriorVehicleData" == literal) { + *result = OnInteriorVehicleDataID; + return true; + } + + if ("OnWayPointChange" == literal) { + *result = OnWayPointChangeID; + return true; + } + + if ("OnRCStatus" == literal) { + *result = OnRCStatusID; + return true; + } + + if ("EncodedSyncPData" == literal) { + *result = EncodedSyncPDataID; + return true; + } + + if ("SyncPData" == literal) { + *result = SyncPDataID; + return true; + } + + if ("OnEncodedSyncPData" == literal) { + *result = OnEncodedSyncPDataID; + return true; + } + + if ("OnSyncPData" == literal) { + *result = OnSyncPDataID; + return true; + } + return false; +}; + const std::string kDefaultApp = "default"; const std::string kPreDataConsentApp = "pre_DataConsent"; const std::string kDeviceApp = "device"; diff --git a/src/components/policy/policy_regular/include/policy/policy_table/enums.h b/src/components/policy/policy_regular/include/policy/policy_table/enums.h index b2acf77ec1..4fda36cbe7 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/enums.h @@ -166,6 +166,371 @@ bool IsValidEnum(ModuleType val); const char* EnumToJsonString(ModuleType val); bool EnumFromJsonString(const std::string& literal, ModuleType* result); +/** + * @brief Enumeration FunctionID. + * + * Enumeration linking function names with function IDs in AppLink protocol. Assumes enumeration starts at value 0. + */ +enum FunctionID { + /** + * @brief RESERVED. + */ + RESERVED = 0, + + /** + * @brief RegisterAppInterfaceID. + */ + RegisterAppInterfaceID = 1, + + /** + * @brief UnregisterAppInterfaceID. + */ + UnregisterAppInterfaceID = 2, + + /** + * @brief SetGlobalPropertiesID. + */ + SetGlobalPropertiesID = 3, + + /** + * @brief ResetGlobalPropertiesID. + */ + ResetGlobalPropertiesID = 4, + + /** + * @brief AddCommandID. + */ + AddCommandID = 5, + + /** + * @brief DeleteCommandID. + */ + DeleteCommandID = 6, + + /** + * @brief AddSubMenuID. + */ + AddSubMenuID = 7, + + /** + * @brief DeleteSubMenuID. + */ + DeleteSubMenuID = 8, + + /** + * @brief CreateInteractionChoiceSetID. + */ + CreateInteractionChoiceSetID = 9, + + /** + * @brief PerformInteractionID. + */ + PerformInteractionID = 10, + + /** + * @brief DeleteInteractionChoiceSetID. + */ + DeleteInteractionChoiceSetID = 11, + + /** + * @brief AlertID. + */ + AlertID = 12, + + /** + * @brief ShowID. + */ + ShowID = 13, + + /** + * @brief SpeakID. + */ + SpeakID = 14, + + /** + * @brief SetMediaClockTimerID. + */ + SetMediaClockTimerID = 15, + + /** + * @brief PerformAudioPassThruID. + */ + PerformAudioPassThruID = 16, + + /** + * @brief EndAudioPassThruID. + */ + EndAudioPassThruID = 17, + + /** + * @brief SubscribeButtonID. + */ + SubscribeButtonID = 18, + + /** + * @brief UnsubscribeButtonID. + */ + UnsubscribeButtonID = 19, + + /** + * @brief SubscribeVehicleDataID. + */ + SubscribeVehicleDataID = 20, + + /** + * @brief UnsubscribeVehicleDataID. + */ + UnsubscribeVehicleDataID = 21, + + /** + * @brief GetVehicleDataID. + */ + GetVehicleDataID = 22, + + /** + * @brief ReadDIDID. + */ + ReadDIDID = 23, + + /** + * @brief GetDTCsID. + */ + GetDTCsID = 24, + + /** + * @brief ScrollableMessageID. + */ + ScrollableMessageID = 25, + + /** + * @brief SliderID. + */ + SliderID = 26, + + /** + * @brief ShowConstantTBTID. + */ + ShowConstantTBTID = 27, + + /** + * @brief AlertManeuverID. + */ + AlertManeuverID = 28, + + /** + * @brief UpdateTurnListID. + */ + UpdateTurnListID = 29, + + /** + * @brief ChangeRegistrationID. + */ + ChangeRegistrationID = 30, + + /** + * @brief GenericResponseID. + */ + GenericResponseID = 31, + + /** + * @brief PutFileID. + */ + PutFileID = 32, + + /** + * @brief DeleteFileID. + */ + DeleteFileID = 33, + + /** + * @brief ListFilesID. + */ + ListFilesID = 34, + + /** + * @brief SetAppIconID. + */ + SetAppIconID = 35, + + /** + * @brief SetDisplayLayoutID. + */ + SetDisplayLayoutID = 36, + + /** + * @brief DiagnosticMessageID. + */ + DiagnosticMessageID = 37, + + /** + * @brief SystemRequestID. + */ + SystemRequestID = 38, + + /** + * @brief SendLocationID. + */ + SendLocationID = 39, + + /** + * @brief DialNumberID. + */ + DialNumberID = 40, + + /** + * @brief ButtonPressID. + */ + ButtonPressID = 41, + + /** + * @brief GetInteriorVehicleDataID. + */ + GetInteriorVehicleDataID = 43, + + /** + * @brief SetInteriorVehicleDataID. + */ + SetInteriorVehicleDataID = 44, + + /** + * @brief GetWayPointsID. + */ + GetWayPointsID = 45, + + /** + * @brief SubscribeWayPointsID. + */ + SubscribeWayPointsID = 46, + + /** + * @brief UnsubscribeWayPointsID. + */ + UnsubscribeWayPointsID = 47, + + /** + * @brief GetSystemCapabilityID. + */ + GetSystemCapabilityID = 48, + + /** + * @brief SendHapticDataID. + */ + SendHapticDataID = 49, + + /** + * @brief OnHMIStatusID. + */ + OnHMIStatusID = 32768, + + /** + * @brief OnAppInterfaceUnregisteredID. + */ + OnAppInterfaceUnregisteredID = 32769, + + /** + * @brief OnButtonEventID. + */ + OnButtonEventID = 32770, + + /** + * @brief OnButtonPressID. + */ + OnButtonPressID = 32771, + + /** + * @brief OnVehicleDataID. + */ + OnVehicleDataID = 32772, + + /** + * @brief OnCommandID. + */ + OnCommandID = 32773, + + /** + * @brief OnTBTClientStateID. + */ + OnTBTClientStateID = 32774, + + /** + * @brief OnDriverDistractionID. + */ + OnDriverDistractionID = 32775, + + /** + * @brief OnPermissionsChangeID. + */ + OnPermissionsChangeID = 32776, + + /** + * @brief OnAudioPassThruID. + */ + OnAudioPassThruID = 32777, + + /** + * @brief OnLanguageChangeID. + */ + OnLanguageChangeID = 32778, + + /** + * @brief OnKeyboardInputID. + */ + OnKeyboardInputID = 32779, + + /** + * @brief OnTouchEventID. + */ + OnTouchEventID = 32780, + + /** + * @brief OnSystemRequestID. + */ + OnSystemRequestID = 32781, + + /** + * @brief OnHashChangeID. + */ + OnHashChangeID = 32782, + + /** + * @brief OnInteriorVehicleDataID. + */ + OnInteriorVehicleDataID = 32783, + + /** + * @brief OnWayPointChangeID. + */ + OnWayPointChangeID = 32784, + + /** + * @brief OnRCStatusID. + */ + OnRCStatusID = 32785, + + /** + * @brief EncodedSyncPDataID. + */ + EncodedSyncPDataID = 65536, + + /** + * @brief SyncPDataID. + */ + SyncPDataID = 65537, + + /** + * @brief OnEncodedSyncPDataID. + */ + OnEncodedSyncPDataID = 98304, + + /** + * @brief OnSyncPDataID. + */ + OnSyncPDataID = 98305 +}; +bool IsValidEnum(FunctionID val); +const char* EnumToJsonString(FunctionID val); +bool EnumFromJsonString(const std::string& literal, FunctionID* result); + extern const std::string kDefaultApp; extern const std::string kPreDataConsentApp; extern const std::string kDeviceApp; diff --git a/src/components/policy/policy_regular/src/policy_table/enums.cc b/src/components/policy/policy_regular/src/policy_table/enums.cc index 138d866174..6f914807c5 100644 --- a/src/components/policy/policy_regular/src/policy_table/enums.cc +++ b/src/components/policy/policy_regular/src/policy_table/enums.cc @@ -702,6 +702,662 @@ bool EnumFromJsonString(const std::string& literal, ModuleType* result) { return false; } +bool IsValidEnum(FunctionID val) { + switch (val) { + case RESERVED: + return true; + case RegisterAppInterfaceID: + return true; + case UnregisterAppInterfaceID: + return true; + case SetGlobalPropertiesID: + return true; + case ResetGlobalPropertiesID: + return true; + case AddCommandID: + return true; + case DeleteCommandID: + return true; + case AddSubMenuID: + return true; + case DeleteSubMenuID: + return true; + case CreateInteractionChoiceSetID: + return true; + case PerformInteractionID: + return true; + case DeleteInteractionChoiceSetID: + return true; + case AlertID: + return true; + case ShowID: + return true; + case SpeakID: + return true; + case SetMediaClockTimerID: + return true; + case PerformAudioPassThruID: + return true; + case EndAudioPassThruID: + return true; + case SubscribeButtonID: + return true; + case UnsubscribeButtonID: + return true; + case SubscribeVehicleDataID: + return true; + case UnsubscribeVehicleDataID: + return true; + case GetVehicleDataID: + return true; + case ReadDIDID: + return true; + case GetDTCsID: + return true; + case ScrollableMessageID: + return true; + case SliderID: + return true; + case ShowConstantTBTID: + return true; + case AlertManeuverID: + return true; + case UpdateTurnListID: + return true; + case ChangeRegistrationID: + return true; + case GenericResponseID: + return true; + case PutFileID: + return true; + case DeleteFileID: + return true; + case ListFilesID: + return true; + case SetAppIconID: + return true; + case SetDisplayLayoutID: + return true; + case DiagnosticMessageID: + return true; + case SystemRequestID: + return true; + case SendLocationID: + return true; + case DialNumberID: + return true; + case ButtonPressID: + return true; + case GetInteriorVehicleDataID: + return true; + case SetInteriorVehicleDataID: + return true; + case GetWayPointsID: + return true; + case SubscribeWayPointsID: + return true; + case UnsubscribeWayPointsID: + return true; + case GetSystemCapabilityID: + return true; + case SendHapticDataID: + return true; + case OnHMIStatusID: + return true; + case OnAppInterfaceUnregisteredID: + return true; + case OnButtonEventID: + return true; + case OnButtonPressID: + return true; + case OnVehicleDataID: + return true; + case OnCommandID: + return true; + case OnTBTClientStateID: + return true; + case OnDriverDistractionID: + return true; + case OnPermissionsChangeID: + return true; + case OnAudioPassThruID: + return true; + case OnLanguageChangeID: + return true; + case OnKeyboardInputID: + return true; + case OnTouchEventID: + return true; + case OnSystemRequestID: + return true; + case OnHashChangeID: + return true; + case OnInteriorVehicleDataID: + return true; + case OnWayPointChangeID: + return true; + case OnRCStatusID: + return true; + case EncodedSyncPDataID: + return true; + case SyncPDataID: + return true; + case OnEncodedSyncPDataID: + return true; + case OnSyncPDataID: + return true; + default: + return false; + } +}; + +const char* EnumToJsonString(FunctionID val) { + switch (val) { + case RESERVED: + return "RESERVE"; + case RegisterAppInterfaceID: + return "RegisterAppInterface"; + case UnregisterAppInterfaceID: + return "UnregisterAppInterface"; + case SetGlobalPropertiesID: + return "SetGlobalProperties"; + case ResetGlobalPropertiesID: + return "ResetGlobalProperties"; + case AddCommandID: + return "AddCommand"; + case DeleteCommandID: + return "DeleteCommand"; + case AddSubMenuID: + return "AddSubMenu"; + case DeleteSubMenuID: + return "DeleteSubMenu"; + case CreateInteractionChoiceSetID: + return "CreateInteractionChoiceSet"; + case PerformInteractionID: + return "PerformInteraction"; + case DeleteInteractionChoiceSetID: + return "DeleteInteractionChoiceSet"; + case AlertID: + return "Alert"; + case ShowID: + return "Show"; + case SpeakID: + return "Speak"; + case SetMediaClockTimerID: + return "SetMediaClockTimer"; + case PerformAudioPassThruID: + return "PerformAudioPassThru"; + case EndAudioPassThruID: + return "EndAudioPassThru"; + case SubscribeButtonID: + return "SubscribeButton"; + case UnsubscribeButtonID: + return "UnsubscribeButton"; + case SubscribeVehicleDataID: + return "SubscribeVehicleData"; + case UnsubscribeVehicleDataID: + return "UnsubscribeVehicleData"; + case GetVehicleDataID: + return "GetVehicleData"; + case ReadDIDID: + return "ReadD"; + case GetDTCsID: + return "GetDTCs"; + case ScrollableMessageID: + return "ScrollableMessage"; + case SliderID: + return "Slider"; + case ShowConstantTBTID: + return "ShowConstantTBT"; + case AlertManeuverID: + return "AlertManeuver"; + case UpdateTurnListID: + return "UpdateTurnList"; + case ChangeRegistrationID: + return "ChangeRegistration"; + case GenericResponseID: + return "GenericResponse"; + case PutFileID: + return "PutFile"; + case DeleteFileID: + return "DeleteFile"; + case ListFilesID: + return "ListFiles"; + case SetAppIconID: + return "SetAppIcon"; + case SetDisplayLayoutID: + return "SetDisplayLayout"; + case DiagnosticMessageID: + return "DiagnosticMessage"; + case SystemRequestID: + return "SystemRequest"; + case SendLocationID: + return "SendLocation"; + case DialNumberID: + return "DialNumber"; + case ButtonPressID: + return "ButtonPress"; + case GetInteriorVehicleDataID: + return "GetInteriorVehicleData"; + case SetInteriorVehicleDataID: + return "SetInteriorVehicleData"; + case GetWayPointsID: + return "GetWayPoints"; + case SubscribeWayPointsID: + return "SubscribeWayPoints"; + case UnsubscribeWayPointsID: + return "UnsubscribeWayPoints"; + case GetSystemCapabilityID: + return "GetSystemCapability"; + case SendHapticDataID: + return "SendHapticData"; + case OnHMIStatusID: + return "OnHMIStatus"; + case OnAppInterfaceUnregisteredID: + return "OnAppInterfaceUnregistered"; + case OnButtonEventID: + return "OnButtonEvent"; + case OnButtonPressID: + return "OnButtonPress"; + case OnVehicleDataID: + return "OnVehicleData"; + case OnCommandID: + return "OnCommand"; + case OnTBTClientStateID: + return "OnTBTClientState"; + case OnDriverDistractionID: + return "OnDriverDistraction"; + case OnPermissionsChangeID: + return "OnPermissionsChange"; + case OnAudioPassThruID: + return "OnAudioPassThru"; + case OnLanguageChangeID: + return "OnLanguageChange"; + case OnKeyboardInputID: + return "OnKeyboardInput"; + case OnTouchEventID: + return "OnTouchEvent"; + case OnSystemRequestID: + return "OnSystemRequest"; + case OnHashChangeID: + return "OnHashChange"; + case OnInteriorVehicleDataID: + return "OnInteriorVehicleData"; + case OnWayPointChangeID: + return "OnWayPointChange"; + case OnRCStatusID: + return "OnRCStatus"; + case EncodedSyncPDataID: + return "EncodedSyncPData"; + case SyncPDataID: + return "SyncPData"; + case OnEncodedSyncPDataID: + return "OnEncodedSyncPData"; + case OnSyncPDataID: + return "OnSyncPData"; + default: + return ""; + } +}; + +bool EnumFromJsonString(const std::string& literal, FunctionID* result) { + if ("RESERVE" == literal) { + *result = RESERVED; + return true; + } + + if ("RegisterAppInterface" == literal) { + *result = RegisterAppInterfaceID; + return true; + } + + if ("UnregisterAppInterface" == literal) { + *result = UnregisterAppInterfaceID; + return true; + } + + if ("SetGlobalProperties" == literal) { + *result = SetGlobalPropertiesID; + return true; + } + + if ("ResetGlobalProperties" == literal) { + *result = ResetGlobalPropertiesID; + return true; + } + + if ("AddCommand" == literal) { + *result = AddCommandID; + return true; + } + + if ("DeleteCommand" == literal) { + *result = DeleteCommandID; + return true; + } + + if ("AddSubMenu" == literal) { + *result = AddSubMenuID; + return true; + } + + if ("DeleteSubMenu" == literal) { + *result = DeleteSubMenuID; + return true; + } + + if ("CreateInteractionChoiceSet" == literal) { + *result = CreateInteractionChoiceSetID; + return true; + } + + if ("PerformInteraction" == literal) { + *result = PerformInteractionID; + return true; + } + + if ("DeleteInteractionChoiceSet" == literal) { + *result = DeleteInteractionChoiceSetID; + return true; + } + + if ("Alert" == literal) { + *result = AlertID; + return true; + } + + if ("Show" == literal) { + *result = ShowID; + return true; + } + + if ("Speak" == literal) { + *result = SpeakID; + return true; + } + + if ("SetMediaClockTimer" == literal) { + *result = SetMediaClockTimerID; + return true; + } + + if ("PerformAudioPassThru" == literal) { + *result = PerformAudioPassThruID; + return true; + } + + if ("EndAudioPassThru" == literal) { + *result = EndAudioPassThruID; + return true; + } + + if ("SubscribeButton" == literal) { + *result = SubscribeButtonID; + return true; + } + + if ("UnsubscribeButton" == literal) { + *result = UnsubscribeButtonID; + return true; + } + + if ("SubscribeVehicleData" == literal) { + *result = SubscribeVehicleDataID; + return true; + } + + if ("UnsubscribeVehicleData" == literal) { + *result = UnsubscribeVehicleDataID; + return true; + } + + if ("GetVehicleData" == literal) { + *result = GetVehicleDataID; + return true; + } + + if ("ReadD" == literal) { + *result = ReadDIDID; + return true; + } + + if ("GetDTCs" == literal) { + *result = GetDTCsID; + return true; + } + + if ("ScrollableMessage" == literal) { + *result = ScrollableMessageID; + return true; + } + + if ("Slider" == literal) { + *result = SliderID; + return true; + } + + if ("ShowConstantTBT" == literal) { + *result = ShowConstantTBTID; + return true; + } + + if ("AlertManeuver" == literal) { + *result = AlertManeuverID; + return true; + } + + if ("UpdateTurnList" == literal) { + *result = UpdateTurnListID; + return true; + } + + if ("ChangeRegistration" == literal) { + *result = ChangeRegistrationID; + return true; + } + + if ("GenericResponse" == literal) { + *result = GenericResponseID; + return true; + } + + if ("PutFile" == literal) { + *result = PutFileID; + return true; + } + + if ("DeleteFile" == literal) { + *result = DeleteFileID; + return true; + } + + if ("ListFiles" == literal) { + *result = ListFilesID; + return true; + } + + if ("SetAppIcon" == literal) { + *result = SetAppIconID; + return true; + } + + if ("SetDisplayLayout" == literal) { + *result = SetDisplayLayoutID; + return true; + } + + if ("DiagnosticMessage" == literal) { + *result = DiagnosticMessageID; + return true; + } + + if ("SystemRequest" == literal) { + *result = SystemRequestID; + return true; + } + + if ("SendLocation" == literal) { + *result = SendLocationID; + return true; + } + + if ("DialNumber" == literal) { + *result = DialNumberID; + return true; + } + + if ("ButtonPress" == literal) { + *result = ButtonPressID; + return true; + } + + if ("GetInteriorVehicleData" == literal) { + *result = GetInteriorVehicleDataID; + return true; + } + + if ("SetInteriorVehicleData" == literal) { + *result = SetInteriorVehicleDataID; + return true; + } + + if ("GetWayPoints" == literal) { + *result = GetWayPointsID; + return true; + } + + if ("SubscribeWayPoints" == literal) { + *result = SubscribeWayPointsID; + return true; + } + + if ("UnsubscribeWayPoints" == literal) { + *result = UnsubscribeWayPointsID; + return true; + } + + if ("GetSystemCapability" == literal) { + *result = GetSystemCapabilityID; + return true; + } + + if ("SendHapticData" == literal) { + *result = SendHapticDataID; + return true; + } + + if ("OnHMIStatus" == literal) { + *result = OnHMIStatusID; + return true; + } + + if ("OnAppInterfaceUnregistered" == literal) { + *result = OnAppInterfaceUnregisteredID; + return true; + } + + if ("OnButtonEvent" == literal) { + *result = OnButtonEventID; + return true; + } + + if ("OnButtonPress" == literal) { + *result = OnButtonPressID; + return true; + } + + if ("OnVehicleData" == literal) { + *result = OnVehicleDataID; + return true; + } + + if ("OnCommand" == literal) { + *result = OnCommandID; + return true; + } + + if ("OnTBTClientState" == literal) { + *result = OnTBTClientStateID; + return true; + } + + if ("OnDriverDistraction" == literal) { + *result = OnDriverDistractionID; + return true; + } + + if ("OnPermissionsChange" == literal) { + *result = OnPermissionsChangeID; + return true; + } + + if ("OnAudioPassThru" == literal) { + *result = OnAudioPassThruID; + return true; + } + + if ("OnLanguageChange" == literal) { + *result = OnLanguageChangeID; + return true; + } + + if ("OnKeyboardInput" == literal) { + *result = OnKeyboardInputID; + return true; + } + + if ("OnTouchEvent" == literal) { + *result = OnTouchEventID; + return true; + } + + if ("OnSystemRequest" == literal) { + *result = OnSystemRequestID; + return true; + } + + if ("OnHashChange" == literal) { + *result = OnHashChangeID; + return true; + } + + if ("OnInteriorVehicleData" == literal) { + *result = OnInteriorVehicleDataID; + return true; + } + + if ("OnWayPointChange" == literal) { + *result = OnWayPointChangeID; + return true; + } + + if ("OnRCStatus" == literal) { + *result = OnRCStatusID; + return true; + } + + if ("EncodedSyncPData" == literal) { + *result = EncodedSyncPDataID; + return true; + } + + if ("SyncPData" == literal) { + *result = SyncPDataID; + return true; + } + + if ("OnEncodedSyncPData" == literal) { + *result = OnEncodedSyncPDataID; + return true; + } + + if ("OnSyncPData" == literal) { + *result = OnSyncPDataID; + return true; + } + return false; +}; + const std::string kDefaultApp = "default"; const std::string kPreDataConsentApp = "pre_DataConsent"; const std::string kDeviceApp = "device"; -- cgit v1.2.1 From ed95b345449e132c94d6ee23625c9846d94f23af Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Wed, 12 Sep 2018 15:20:01 -0400 Subject: Fix EndService being sent to the wrong connection Also fix issue where app remained in FULL after AUDIO_SOURCE event --- .../src/application_manager_impl.cc | 2 +- .../application_manager/src/hmi_state.cc | 3 --- .../src/connection_handler_impl.cc | 22 ++++++++++++++++------ .../connection_handler/connection_handler.h | 1 + .../protocol_handler/src/protocol_handler_impl.cc | 4 ++-- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 02c41e0472..abab63aa7e 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -2698,7 +2698,7 @@ void ApplicationManagerImpl::OnAppStreaming( media_manager_->StartStreaming(app_id, service_type); } else { media_manager_->StopStreaming(app_id, service_type); - state_ctrl_.OnVideoStreamingStarted(app); + state_ctrl_.OnVideoStreamingStopped(app); } } diff --git a/src/components/application_manager/src/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc index aa4c979ae7..41850a3ef2 100644 --- a/src/components/application_manager/src/hmi_state.cc +++ b/src/components/application_manager/src/hmi_state.cc @@ -207,9 +207,6 @@ mobile_apis::HMILevel::eType AudioSource::hmi_level() const { if (mobile_apis::HMILevel::HMI_NONE == parent()->hmi_level()) { return mobile_apis::HMILevel::HMI_NONE; } - if (mobile_apis::HMILevel::HMI_FULL == parent()->hmi_level()) { - return mobile_apis::HMILevel::HMI_FULL; - } return mobile_apis::HMILevel::HMI_BACKGROUND; } diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc index 045985f650..478127c42a 100644 --- a/src/components/connection_handler/src/connection_handler_impl.cc +++ b/src/components/connection_handler/src/connection_handler_impl.cc @@ -354,8 +354,8 @@ void ConnectionHandlerImpl::OnSessionStartedCallback( // so they can send appropriate Ack or NAK messages on the correct transport. transport_manager::ConnectionUID primary_connection_handle = connection_handle; + SessionTransports st = GetSessionTransports(session_id); if (session_id != 0) { - SessionTransports st = GetSessionTransports(session_id); if (st.primary_transport == 0) { LOG4CXX_WARN(logger_, "OnSessionStartedCallback could not find Session in the " @@ -424,6 +424,11 @@ void ConnectionHandlerImpl::OnSessionStartedCallback( } context.new_session_id_ = session_id; context.hash_id_ = protocol_handler::HASH_ID_NOT_SUPPORTED; + + if (st.secondary_transport == connection_handle) { + sync_primitives::AutoLock auto_lock(session_connection_map_lock_ptr_); + st.secondary_transport_services.push_back(service_type); + } } sync_primitives::AutoReadLock read_lock(connection_handler_observer_lock_); if (connection_handler_observer_) { @@ -1444,11 +1449,16 @@ void ConnectionHandlerImpl::SendEndService(uint32_t key, uint8_t service_type) { << static_cast(st.primary_transport) << " and secondary connection " << static_cast(st.secondary_transport)); - - protocol_handler_->SendEndService(st.primary_transport, - st.secondary_transport, - session_id, - service_type); + sync_primitives::AutoLock auto_lock(session_connection_map_lock_ptr_); + auto it = std::find(st.secondary_transport_services.begin(), + st.secondary_transport_services.end(), + service_type); + if (it != st.secondary_transport_services.end()) { + connection_handle = st.secondary_transport; + st.secondary_transport_services.erase(it); + } + protocol_handler_->SendEndService( + st.primary_transport, connection_handle, session_id, service_type); } } } diff --git a/src/components/include/connection_handler/connection_handler.h b/src/components/include/connection_handler/connection_handler.h index bfaacf5fc1..a50760b547 100644 --- a/src/components/include/connection_handler/connection_handler.h +++ b/src/components/include/connection_handler/connection_handler.h @@ -57,6 +57,7 @@ class ConnectionHandlerObserver; typedef struct { transport_manager::ConnectionUID primary_transport; transport_manager::ConnectionUID secondary_transport; + std::vector secondary_transport_services; } SessionTransports; typedef std::map SessionConnectionMap; diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc index 093d89490b..28773e75d5 100644 --- a/src/components/protocol_handler/src/protocol_handler_impl.cc +++ b/src/components/protocol_handler/src/protocol_handler_impl.cc @@ -621,9 +621,9 @@ void ProtocolHandlerImpl::SendEndServicePrivate(int32_t primary_connection_id, impl::RawFordMessageToMobile(ptr, false)); LOG4CXX_DEBUG(logger_, "SendEndServicePrivate() for connection " - << primary_connection_id << " for service_type " + << connection_id << " for service_type " << static_cast(service_type) - << " service connection " << connection_id + << " primary connection " << primary_connection_id << " session_id " << static_cast(session_id)); } else { LOG4CXX_WARN( -- cgit v1.2.1 From c934f656df2e1c6993500973ca5e29c23b592355 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Thu, 13 Sep 2018 14:49:15 -0400 Subject: Fix incorrectly saved RequestType and RequestSubType, which caused silent errors while loading application policies on startup --- .../include/policy/sql_pt_queries.h | 2 -- .../policy/policy_external/src/sql_pt_queries.cc | 8 -------- .../policy_external/src/sql_pt_representation.cc | 24 ---------------------- .../policy_regular/include/policy/sql_pt_queries.h | 2 -- .../policy/policy_regular/src/sql_pt_queries.cc | 8 -------- .../policy_regular/src/sql_pt_representation.cc | 24 ---------------------- 6 files changed, 68 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 646cc7663b..dd9e0204e7 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 @@ -79,8 +79,6 @@ extern const std::string kInsertAppGroup; extern const std::string kInsertNickname; extern const std::string kInsertAppType; extern const std::string kInsertRequestType; -extern const std::string kInsertOmittedRequestType; -extern const std::string kInsertOmittedRequestSubType; extern const std::string kInsertRequestSubType; extern const std::string kInsertMessageType; extern const std::string kInsertLanguage; diff --git a/src/components/policy/policy_external/src/sql_pt_queries.cc b/src/components/policy/policy_external/src/sql_pt_queries.cc index ee53eb1487..97d75731ea 100644 --- a/src/components/policy/policy_external/src/sql_pt_queries.cc +++ b/src/components/policy/policy_external/src/sql_pt_queries.cc @@ -645,19 +645,11 @@ const std::string kInsertRequestType = "INSERT OR IGNORE INTO `request_type` (`application_id`, `request_type`) " "VALUES (?, ?)"; -const std::string kInsertOmittedRequestType = - "INSERT INTO `request_type` (`application_id`) " - "VALUES (?)"; - const std::string kInsertRequestSubType = "INSERT INTO `request_subtype` (`application_id`, " "`request_subtype`) " "VALUES (?, ?)"; -const std::string kInsertOmittedRequestSubType = - "INSERT INTO `request_subtype` (`application_id`) " - "VALUES (?)"; - const std::string kUpdateVersion = "UPDATE `version` SET `number`= ?"; const std::string kInsertMessageType = 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 34c5b90903..31c69e3725 100644 --- a/src/components/policy/policy_external/src/sql_pt_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_representation.cc @@ -1193,18 +1193,6 @@ bool SQLPTRepresentation::SaveRequestType( LOG4CXX_WARN(logger_, "Incorrect insert into request types."); return false; } - } else { - utils::dbms::SQLQuery query_omitted(db()); - if (!query_omitted.Prepare(sql_pt::kInsertOmittedRequestType)) { - LOG4CXX_WARN(logger_, "Incorrect insert statement for request types."); - return false; - } - LOG4CXX_WARN(logger_, "Request types omitted."); - query_omitted.Bind(0, app_id); - if (!query_omitted.Exec() || !query_omitted.Reset()) { - LOG4CXX_WARN(logger_, "Incorrect insert into request types."); - return false; - } } return true; } @@ -1237,18 +1225,6 @@ bool SQLPTRepresentation::SaveRequestSubType( LOG4CXX_WARN(logger_, "Incorrect insert into request subtypes."); return false; } - } else { - utils::dbms::SQLQuery query_omitted(db()); - if (!query_omitted.Prepare(sql_pt::kInsertOmittedRequestSubType)) { - LOG4CXX_WARN(logger_, "Incorrect insert statement for request subtypes."); - return false; - } - LOG4CXX_WARN(logger_, "Request subtypes omitted."); - query_omitted.Bind(0, app_id); - if (!query_omitted.Exec() || !query_omitted.Reset()) { - LOG4CXX_WARN(logger_, "Incorrect insert into request subtypes."); - return false; - } } return true; } 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 5259ffa7e9..191873efe0 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 @@ -79,8 +79,6 @@ extern const std::string kInsertAppGroup; extern const std::string kInsertNickname; extern const std::string kInsertAppType; extern const std::string kInsertRequestType; -extern const std::string kInsertOmittedRequestType; -extern const std::string kInsertOmittedRequestSubType; extern const std::string kInsertRequestSubType; extern const std::string kInsertMessageType; extern const std::string kInsertLanguage; 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 91a5573a04..f5ccffce3b 100644 --- a/src/components/policy/policy_regular/src/sql_pt_queries.cc +++ b/src/components/policy/policy_regular/src/sql_pt_queries.cc @@ -595,19 +595,11 @@ const std::string kInsertRequestType = "INSERT INTO `request_type` (`application_id`, `request_type`) " "VALUES (?, ?)"; -const std::string kInsertOmittedRequestType = - "INSERT INTO `request_type` (`application_id`) " - "VALUES (?)"; - const std::string kInsertRequestSubType = "INSERT INTO `request_subtype` (`application_id`, " "`request_subtype`) " "VALUES (?, ?)"; -const std::string kInsertOmittedRequestSubType = - "INSERT INTO `request_subtype` (`application_id`) " - "VALUES (?)"; - const std::string kUpdateVersion = "UPDATE `version` SET `number`= ?"; const std::string kInsertMessageType = 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 d32ee7133d..4f5dbc4c3b 100644 --- a/src/components/policy/policy_regular/src/sql_pt_representation.cc +++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc @@ -1137,18 +1137,6 @@ bool SQLPTRepresentation::SaveRequestType( LOG4CXX_WARN(logger_, "Incorrect insert into request types."); return false; } - } else { - utils::dbms::SQLQuery query_omitted(db()); - if (!query_omitted.Prepare(sql_pt::kInsertOmittedRequestType)) { - LOG4CXX_WARN(logger_, "Incorrect insert statement for request types."); - return false; - } - LOG4CXX_WARN(logger_, "Request types omitted."); - query_omitted.Bind(0, app_id); - if (!query_omitted.Exec() || !query_omitted.Reset()) { - LOG4CXX_WARN(logger_, "Incorrect insert into request types."); - return false; - } } return true; } @@ -1181,18 +1169,6 @@ bool SQLPTRepresentation::SaveRequestSubType( LOG4CXX_WARN(logger_, "Incorrect insert into request subtypes."); return false; } - } else { - utils::dbms::SQLQuery query_omitted(db()); - if (!query_omitted.Prepare(sql_pt::kInsertOmittedRequestSubType)) { - LOG4CXX_WARN(logger_, "Incorrect insert statement for request subtypes."); - return false; - } - LOG4CXX_WARN(logger_, "Request subtypes omitted."); - query_omitted.Bind(0, app_id); - if (!query_omitted.Exec() || !query_omitted.Reset()) { - LOG4CXX_WARN(logger_, "Incorrect insert into request subtypes."); - return false; - } } return true; } -- cgit v1.2.1 From 5c11affab7175ce4969641a047ffde19432e3aec Mon Sep 17 00:00:00 2001 From: theresalech Date: Thu, 13 Sep 2018 15:44:21 -0400 Subject: add third_party.md Resolves issue #2610 --- third_party.md | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 third_party.md diff --git a/third_party.md b/third_party.md new file mode 100644 index 0000000000..249d58fade --- /dev/null +++ b/third_party.md @@ -0,0 +1,104 @@ +### SDL CORE + +Copyright (C) 2018 SmartDeviceLink Consortium, Inc. + +#### License +Copyright (c) 2017 - 2018, SmartDeviceLink Consortium, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +* Neither the name of SmartDeviceLink Consortium, Inc. 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. + +#### Third Party Licenses + +Both the source and binary distributions of this software contain +some third party software. All the third party software included +or linked is redistributed under the terms and conditions of their +original licenses. + +The third party software included and used by this project is: + +**googlemock 1.7.0** + +* Copyright 2008, Google Inc +* Licensed under BSD 3-clause +* The library is included in Google C++ Mocking Framework +* See [https://github.com/google/googletest/tree/master/googlemock](https://github.com/google/googletest/tree/master/googlemock) + +**googlemock 1.7.0** + +* Copyright [2007] Neal Norwitz +* Portions Copyright [2007] Google Inc +* Licensed under the Apache License, Version 2.0 +* The library is included in the Google Mock class generator +* See [https://github.com/google/googletest/tree/master/googlemock](https://github.com/google/googletest/tree/master/googlemock) + +**json-cpp 0.6.0 rc2** + +* Copyright (c) 2007-2010 Baptiste Lepilleur +* Licensed under MIT License +* The library is included in jsoncpp 3rd party static src folder +* See [https://github.com/open-source-parsers/jsoncpp/releases/tag/svn-release-0.6.0-rc2](https://github.com/open-source-parsers/jsoncpp/releases/tag/svn-release-0.6.0-rc2) + +**Apache log4cxx 0.10.0** + +* Copyright 2004-2007 The Apache Software Foundation +* Licensed under the Apache License, Version 2.0 +* The library is included in apache-log4cxx-0.10.0 3rd party src folder +* See [https://github.com/apache/logging-log4cxx/releases](https://github.com/apache/logging-log4cxx/releases) + +**Apache Portable Runtime 1.5** + +* Copyright (c) 2000-2013 The Apache Software Foundation. +* Licensed under the Apache License, Version 2.0. +* The library is included in apr-1.5.0 3rd party src folder. +* See [https://github.com/apache/apr/releases/tag/1.5.0](https://github.com/apache/apr/releases/tag/1.5.0) + +**Apache Portable Runtime Utility 1.5.3** + +* Copyright (c) 2000-2013 The Apache Software Foundation +* Licensed under the Apache License, Version 2.0 +* The library is included in apr-util-1.5.3 3rd party src folder +* See [https://github.com/apache/apr-util/releases/tag/1.5.3](https://github.com/apache/apr-util/releases/tag/1.5.3) + +**Apache Portable Runtime 1.5** + +* Copyright (c) 1987, 1992, 1993, 1994, The Regents of the University of California +* Licensed under BSD 4-clause +* The library is included in apr-1.5.0 3rd party src folder +* See [https://github.com/apache/apr/releases/tag/1.5.0](https://github.com/apache/apr/releases/tag/1.5.0) + +**inetlib** + +* Copyright (c) 1996 by Internet Software Consortium +* Licensed under ISC License +* The library is included in the unix folder of network_io, under the apr-1.5.0 3rd party src folder + +**Expat 2.1.0** + +* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd and Clark Cooper +* Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers +* Licensed under MIT License +* The library is included in expat-2.1.0 3rd party src folder +* See [https://github.com/libexpat/libexpat/tree/defusedexpat-2.1.0/expat](https://github.com/libexpat/libexpat/tree/defusedexpat-2.1.0/expat) + +**Expat 2.1.0** + +* Licensed under GNU Free Documentation License v1.1 +* The library is included in the doc folder, under the expat-2.1.0 3rd party src folder +* See [https://github.com/libexpat/libexpat/tree/defusedexpat-2.1.0/expat/doc](https://github.com/libexpat/libexpat/tree/defusedexpat-2.1.0/expat/doc) + +**Pugixml 1.2** + +* Copyright (C) 2006-2012, by Arseny Kapoulkine +* Licensed under MIT License +* The library is used as an XML processing library, located in the tools folder +* See [https://github.com/zeux/pugixml/releases/tag/v1.2](https://github.com/zeux/pugixml/releases/tag/v1.2) \ No newline at end of file -- cgit v1.2.1 From c84cd99e962af6730791df69f1796783ca106e40 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Mon, 17 Sep 2018 14:27:40 -0400 Subject: Add override for IAP emulated transport --- .../iap2_emulation/iap2_transport_adapter.h | 18 ++++++++++++++++++ .../src/iap2_emulation/iap2_transport_adapter.cc | 10 ++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/components/transport_manager/include/transport_manager/iap2_emulation/iap2_transport_adapter.h b/src/components/transport_manager/include/transport_manager/iap2_emulation/iap2_transport_adapter.h index 36a2b374dd..e53a472bcb 100644 --- a/src/components/transport_manager/include/transport_manager/iap2_emulation/iap2_transport_adapter.h +++ b/src/components/transport_manager/include/transport_manager/iap2_emulation/iap2_transport_adapter.h @@ -74,6 +74,15 @@ class IAP2BluetoothEmulationTransportAdapter : public TcpTransportAdapter { */ void DeviceSwitched(const DeviceUID& device_handle) OVERRIDE; + /** + * @brief Notification that transport's configuration is updated. This + * override is needed so that a OnTransportConfigUpdated is not sent to the + * mobile device for the emulated transport. + * + * @param new_config The new configuration of the transport + */ + void TransportConfigUpdated(const TransportConfig& new_config) OVERRIDE; + protected: /** * @brief GetDeviceType Provides SDL device type for transport adapter @@ -110,6 +119,15 @@ class IAP2USBEmulationTransportAdapter : public TcpTransportAdapter { */ void DeviceSwitched(const DeviceUID& device_handle) OVERRIDE; + /** + * @brief Notification that transport's configuration is updated. This + * override is needed so that a OnTransportConfigUpdated is not sent to the + * mobile device for the emulated transport. + * + * @param new_config The new configuration of the transport + */ + void TransportConfigUpdated(const TransportConfig& new_config) OVERRIDE; + protected: /** * @brief GetDeviceType Provides SDL device type for transport adapter diff --git a/src/components/transport_manager/src/iap2_emulation/iap2_transport_adapter.cc b/src/components/transport_manager/src/iap2_emulation/iap2_transport_adapter.cc index e2e5b98190..31e997f3ba 100644 --- a/src/components/transport_manager/src/iap2_emulation/iap2_transport_adapter.cc +++ b/src/components/transport_manager/src/iap2_emulation/iap2_transport_adapter.cc @@ -69,6 +69,11 @@ DeviceType IAP2BluetoothEmulationTransportAdapter::GetDeviceType() const { return IOS_BT; } +void IAP2BluetoothEmulationTransportAdapter::TransportConfigUpdated( + const TransportConfig& new_config) { + return; +} + IAP2USBEmulationTransportAdapter::IAP2USBEmulationTransportAdapter( const uint16_t port, resumption::LastState& last_state, @@ -120,6 +125,11 @@ DeviceType IAP2USBEmulationTransportAdapter::GetDeviceType() const { return IOS_USB; } +void IAP2USBEmulationTransportAdapter::TransportConfigUpdated( + const TransportConfig& new_config) { + return; +} + IAP2USBEmulationTransportAdapter::IAPSignalHandlerDelegate:: IAPSignalHandlerDelegate(IAP2USBEmulationTransportAdapter& adapter) : adapter_(adapter), run_flag_(true), in_(0) { -- cgit v1.2.1 From 8fe9d54458b162fb9eb895a45a02af5656b655b0 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 18 Sep 2018 16:19:33 -0400 Subject: Add keepContext logic to AudioSource HMI State --- .../include/application_manager/application.h | 12 ++++++ .../include/application_manager/application_impl.h | 3 ++ .../include/application_manager/hmi_state.h | 3 ++ .../mobile/set_interior_vehicle_data_request.cc | 48 ++++++++++------------ .../application_manager/src/application_impl.cc | 9 ++++ .../application_manager/src/hmi_state.cc | 10 +++-- .../include/application_manager/mock_application.h | 2 + .../test/state_controller/state_controller_test.cc | 6 ++- 8 files changed, 62 insertions(+), 31 deletions(-) diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index c3a4ecbb30..ad7570955e 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -589,6 +589,18 @@ class Application : public virtual InitialApplicationData, * @return flag tts_properties_in_full */ virtual bool tts_properties_in_full() = 0; + /** + * @brief sets true if application should keep it's HMI Level after an audio + * source change + * @param value of keep context + */ + virtual void set_keep_context(bool keep_context) = 0; + /** + * @brief returns true if application should keep keep it's HMI Level after + * an audio source change, otherwise return false + * @return value of keep_context flag + */ + virtual bool keep_context() = 0; virtual void set_version(const Version& version) = 0; virtual void set_name(const custom_str::CustomString& name) = 0; virtual void set_is_media_application(bool is_media) = 0; diff --git a/src/components/application_manager/include/application_manager/application_impl.h b/src/components/application_manager/include/application_manager/application_impl.h index f937ebebe1..8dc3b2da20 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -177,6 +177,8 @@ class ApplicationImpl : public virtual Application, bool tts_properties_in_none(); void set_tts_properties_in_full(bool active); bool tts_properties_in_full(); + void set_keep_context(bool keep_context); + bool keep_context(); void set_version(const Version& ver); void set_name(const custom_str::CustomString& name); void set_is_media_application(bool is_media); @@ -481,6 +483,7 @@ class ApplicationImpl : public virtual Application, bool has_been_activated_; bool tts_properties_in_none_; bool tts_properties_in_full_; + bool keep_context_; bool is_foreground_; bool is_application_data_changed_; uint32_t put_file_in_none_count_; diff --git a/src/components/application_manager/include/application_manager/hmi_state.h b/src/components/application_manager/include/application_manager/hmi_state.h index 4b7779e08c..07d9c8dc23 100644 --- a/src/components/application_manager/include/application_manager/hmi_state.h +++ b/src/components/application_manager/include/application_manager/hmi_state.h @@ -368,6 +368,9 @@ class AudioSource : public HmiState { const OVERRIDE { return mobile_apis::VideoStreamingState::NOT_STREAMABLE; } + + private: + bool keep_context_; }; /** diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc index cfd8caae39..0473dd1791 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc @@ -506,13 +506,20 @@ void SetInteriorVehicleDataRequest::Execute() { module_data[message_params::kAudioControlData].keyExists( message_params::kSource); - if (app_wants_to_set_audio_src && !app->IsAllowedToChangeAudioSource()) { - LOG4CXX_WARN(logger_, "App is not allowed to change audio source"); - SetResourceState(ModuleType(), ResourceState::FREE); - SendResponse(false, - mobile_apis::Result::REJECTED, - "App is not allowed to change audio source"); - return; + if (app_wants_to_set_audio_src) { + if (!app->IsAllowedToChangeAudioSource()) { + LOG4CXX_WARN(logger_, "App is not allowed to change audio source"); + SetResourceState(ModuleType(), ResourceState::FREE); + SendResponse(false, + mobile_apis::Result::REJECTED, + "App is not allowed to change audio source"); + return; + } else if (module_data[message_params::kAudioControlData].keyExists( + message_params::kKeepContext)) { + app->set_keep_context( + module_data[message_params::kAudioControlData] + [message_params::kKeepContext].asBool()); + } } SendHMIRequest(hmi_apis::FunctionID::RC_SetInteriorVehicleData, @@ -555,6 +562,10 @@ void SetInteriorVehicleDataRequest::on_event( *message_)[app_mngr::strings::msg_params][message_params::kModuleData] [message_params::kAudioControlData]); } + } else { + app_mngr::ApplicationSharedPtr app = + application_manager_.application(connection_key()); + app->set_keep_context(false); } std::string info; GetInfo(hmi_response, info); @@ -580,27 +591,10 @@ const smart_objects::SmartObject& SetInteriorVehicleDataRequest::ControlData( void SetInteriorVehicleDataRequest::CheckAudioSource( const smart_objects::SmartObject& audio_data) { LOG4CXX_AUTO_TRACE(logger_); - const bool should_keep_context = - audio_data.keyExists(message_params::kKeepContext) && - audio_data[message_params::kKeepContext].asBool(); - const bool switch_source_from_app = - mobile_apis::PrimaryAudioSource::MOBILE_APP == - application_manager_.get_current_audio_source() && - mobile_apis::PrimaryAudioSource::MOBILE_APP != - audio_data[message_params::kSource].asInt(); - if (!should_keep_context && switch_source_from_app) { - app_mngr::ApplicationSharedPtr app = - application_manager_.application(connection_key()); - if (app->mobile_projection_enabled()) { - application_manager_.ChangeAppsHMILevel( - app->app_id(), mobile_apis::HMILevel::eType::HMI_LIMITED); - } else { - application_manager_.ChangeAppsHMILevel( - app->app_id(), mobile_apis::HMILevel::eType::HMI_BACKGROUND); - } + if (audio_data.keyExists(message_params::kSource)) { + application_manager_.set_current_audio_source( + audio_data[message_params::kSource].asUInt()); } - application_manager_.set_current_audio_source( - audio_data[message_params::kSource].asUInt()); } bool SetInteriorVehicleDataRequest::AreAllParamsReadOnly( diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 1168d94245..8a611195c7 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -116,6 +116,7 @@ ApplicationImpl::ApplicationImpl( , has_been_activated_(false) , tts_properties_in_none_(false) , tts_properties_in_full_(false) + , keep_context_(false) , is_foreground_(false) , is_application_data_changed_(false) , put_file_in_none_count_(0) @@ -438,6 +439,14 @@ bool ApplicationImpl::tts_properties_in_full() { return tts_properties_in_full_; } +void ApplicationImpl::set_keep_context(bool keep_context) { + keep_context_ = keep_context; +} + +bool ApplicationImpl::keep_context() { + return keep_context_; +} + void ApplicationImpl::set_video_streaming_approved(bool state) { video_streaming_approved_ = state; } diff --git a/src/components/application_manager/src/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc index 41850a3ef2..7be9668543 100644 --- a/src/components/application_manager/src/hmi_state.cc +++ b/src/components/application_manager/src/hmi_state.cc @@ -199,13 +199,17 @@ mobile_apis::HMILevel::eType DeactivateHMI::hmi_level() const { AudioSource::AudioSource(std::shared_ptr app, const ApplicationManager& app_mngr) - : HmiState(app, app_mngr, STATE_ID_AUDIO_SOURCE) {} + : HmiState(app, app_mngr, STATE_ID_AUDIO_SOURCE) + , keep_context_(app->keep_context()) { + app_->set_keep_context(false); +} mobile_apis::HMILevel::eType AudioSource::hmi_level() const { // Checking for NONE is necessary to avoid issue during // calculation of HMI level during setting default HMI level - if (mobile_apis::HMILevel::HMI_NONE == parent()->hmi_level()) { - return mobile_apis::HMILevel::HMI_NONE; + if (keep_context_ || + mobile_apis::HMILevel::HMI_NONE == parent()->hmi_level()) { + return parent()->hmi_level(); } return mobile_apis::HMILevel::HMI_BACKGROUND; diff --git a/src/components/application_manager/test/include/application_manager/mock_application.h b/src/components/application_manager/test/include/application_manager/mock_application.h index d7552060ff..fe16e8ce6e 100644 --- a/src/components/application_manager/test/include/application_manager/mock_application.h +++ b/src/components/application_manager/test/include/application_manager/mock_application.h @@ -118,6 +118,8 @@ class MockApplication : public ::application_manager::Application { MOCK_METHOD0(tts_properties_in_none, bool()); MOCK_METHOD1(set_tts_properties_in_full, void(bool active)); MOCK_METHOD0(tts_properties_in_full, bool()); + MOCK_METHOD1(set_keep_context, void(bool keep_context)); + MOCK_METHOD0(keep_context, bool()); MOCK_METHOD1(set_version, void(const ::application_manager::Version& version)); MOCK_METHOD1(set_name, void(const custom_str::CustomString& name)); diff --git a/src/components/application_manager/test/state_controller/state_controller_test.cc b/src/components/application_manager/test/state_controller/state_controller_test.cc index 3731848d89..1d4cead52b 100644 --- a/src/components/application_manager/test/state_controller/state_controller_test.cc +++ b/src/components/application_manager/test/state_controller/state_controller_test.cc @@ -2830,7 +2830,8 @@ TEST_F(StateControllerImplTest, state_ctrl_->SetRegularState(navi_app_, hmi_state, true); } -TEST_F(StateControllerImplTest, OnEventChangedAudioSourceAppRemainInFull) { +TEST_F(StateControllerImplTest, + OnEventChangedAudioSource_KeepContext_AppRemainInFull) { const uint32_t app_id = simple_app_->app_id(); InsertApplication(simple_app_); smart_objects::SmartObject msg; @@ -2849,11 +2850,14 @@ TEST_F(StateControllerImplTest, OnEventChangedAudioSourceAppRemainInFull) { mobile_apis::AudioStreamingState::AUDIBLE, mobile_apis::VideoStreamingState::NOT_STREAMABLE, mobile_apis::SystemContext::SYSCTXT_MAIN); + + EXPECT_CALL(*simple_app_ptr_, keep_context()).WillOnce(Return(true)); EXPECT_CALL(*simple_app_ptr_, RegularHmiState()).WillOnce(Return(state)); EXPECT_CALL(*simple_app_ptr_, IsAudioApplication()) .WillRepeatedly(Return(true)); EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()) .WillOnce(Return(FullAudibleState())); + EXPECT_CALL(*simple_app_ptr_, set_keep_context(false)); HmiStatePtr new_state; EXPECT_CALL(*simple_app_ptr_, AddHMIState(_)) -- cgit v1.2.1 From 0ece6ac12019dd99b6d04a364619b5972bfaa93d Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Wed, 19 Sep 2018 15:05:00 -0400 Subject: Reject StartService for audio or video based on settings --- .../protocol_handler/src/protocol_handler_impl.cc | 40 ++- .../test/protocol_handler_tm_test.cc | 284 +++++++++++++++++++++ 2 files changed, 317 insertions(+), 7 deletions(-) diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc index 093d89490b..138a18df3f 100644 --- a/src/components/protocol_handler/src/protocol_handler_impl.cc +++ b/src/components/protocol_handler/src/protocol_handler_impl.cc @@ -1556,15 +1556,9 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessageStartSession( logger_, "Protocol version:" << static_cast(packet->protocol_version())); const ServiceType service_type = ServiceTypeFromByte(packet->service_type()); - BsonObject bson_obj; - if (packet->data() != NULL) { - bson_obj = bson_object_from_bytes(packet->data()); - } else { - bson_object_initialize_default(&bson_obj); - } -#ifdef ENABLE_SECURITY const uint8_t protocol_version = packet->protocol_version(); +#ifdef ENABLE_SECURITY const bool protection = // Protocol version 1 does not support protection (protocol_version > PROTOCOL_VERSION_1) ? packet->protection_flag() @@ -1575,6 +1569,31 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessageStartSession( const ConnectionID connection_id = packet->connection_id(); const uint8_t session_id = packet->session_id(); + const std::string& transport = + session_observer_.TransportTypeProfileStringFromConnHandle(connection_id); + + const auto video_transports = settings_.video_service_transports(); + const bool is_video_allowed = + video_transports.empty() || + std::find(video_transports.begin(), video_transports.end(), transport) != + video_transports.end(); + + const auto audio_transports = settings_.audio_service_transports(); + const bool is_audio_allowed = + audio_transports.empty() || + std::find(audio_transports.begin(), audio_transports.end(), transport) != + audio_transports.end(); + + if ((ServiceType::kMobileNav == service_type && !is_video_allowed) || + (ServiceType::kAudio == service_type && !is_audio_allowed)) { + LOG4CXX_DEBUG(logger_, + "Rejecting StartService for service:" + << service_type << ", over transport: " << transport + << ", disallowed by settings."); + SendStartSessionNAck( + connection_id, session_id, protocol_version, service_type); + return RESULT_OK; + } LOG4CXX_INFO(logger_, "StartSession ID " << static_cast(session_id) @@ -1587,6 +1606,13 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessageStartSession( packet; } + BsonObject bson_obj; + if (packet->data() != NULL) { + bson_obj = bson_object_from_bytes(packet->data()); + } else { + bson_object_initialize_default(&bson_obj); + } + session_observer_.OnSessionStartedCallback( connection_id, packet->session_id(), service_type, protection, &bson_obj); bson_object_deinitialize(&bson_obj); diff --git a/src/components/protocol_handler/test/protocol_handler_tm_test.cc b/src/components/protocol_handler/test/protocol_handler_tm_test.cc index 615900c7fa..51284dfcda 100644 --- a/src/components/protocol_handler/test/protocol_handler_tm_test.cc +++ b/src/components/protocol_handler/test/protocol_handler_tm_test.cc @@ -269,6 +269,21 @@ class ProtocolHandlerImplTest : public ::testing::Test { HASH_ID_WRONG, callback_protection_flag); + // Expect verification of allowed transport + EXPECT_CALL(session_observer_mock, + TransportTypeProfileStringFromConnHandle(connection_id)) + .WillOnce(Return("TCP_WIFI")); + + std::vector audio_service_transports; + audio_service_transports.push_back("TCP_WIFI"); + std::vector video_service_transports; + video_service_transports.push_back("TCP_WIFI"); + + EXPECT_CALL(protocol_handler_settings_mock, audio_service_transports()) + .WillOnce(ReturnRef(audio_service_transports)); + EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) + .WillOnce(ReturnRef(video_service_transports)); + // Expect ConnectionHandler check EXPECT_CALL(session_observer_mock, OnSessionStartedCallback(connection_id, @@ -452,6 +467,24 @@ TEST_F(ProtocolHandlerImplTest, TestAsyncWaiter waiter; uint32_t times = 0; ServiceType service_type; + // Expect verification of allowed transport + EXPECT_CALL(session_observer_mock, + TransportTypeProfileStringFromConnHandle(connection_id)) + .Times(call_times) + .WillRepeatedly(Return("TCP_WIFI")); + + std::vector audio_service_transports; + audio_service_transports.push_back("TCP_WIFI"); + std::vector video_service_transports; + video_service_transports.push_back("TCP_WIFI"); + + EXPECT_CALL(protocol_handler_settings_mock, audio_service_transports()) + .Times(call_times) + .WillRepeatedly(ReturnRef(audio_service_transports)); + EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) + .Times(call_times) + .WillRepeatedly(ReturnRef(video_service_transports)); + // Expect ConnectionHandler check EXPECT_CALL( session_observer_mock, @@ -520,6 +553,24 @@ TEST_F(ProtocolHandlerImplTest, StartSession_Protected_SessionObserverReject) { TestAsyncWaiter waiter; uint32_t times = 0; ServiceType service_type; + // Expect verification of allowed transport + EXPECT_CALL(session_observer_mock, + TransportTypeProfileStringFromConnHandle(connection_id)) + .Times(call_times) + .WillRepeatedly(Return("TCP_WIFI")); + + std::vector audio_service_transports; + audio_service_transports.push_back("TCP_WIFI"); + std::vector video_service_transports; + video_service_transports.push_back("TCP_WIFI"); + + EXPECT_CALL(protocol_handler_settings_mock, audio_service_transports()) + .Times(call_times) + .WillRepeatedly(ReturnRef(audio_service_transports)); + EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) + .Times(call_times) + .WillRepeatedly(ReturnRef(video_service_transports)); + // Expect ConnectionHandler check EXPECT_CALL( session_observer_mock, @@ -578,6 +629,21 @@ TEST_F(ProtocolHandlerImplTest, TestAsyncWaiter waiter; uint32_t times = 0; + // Expect verification of allowed transport + EXPECT_CALL(session_observer_mock, + TransportTypeProfileStringFromConnHandle(connection_id)) + .WillOnce(Return("TCP_WIFI")); + + std::vector audio_service_transports; + audio_service_transports.push_back("TCP_WIFI"); + std::vector video_service_transports; + video_service_transports.push_back("TCP_WIFI"); + + EXPECT_CALL(protocol_handler_settings_mock, audio_service_transports()) + .WillOnce(ReturnRef(audio_service_transports)); + EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) + .WillOnce(ReturnRef(video_service_transports)); + // Expect ConnectionHandler check EXPECT_CALL(session_observer_mock, OnSessionStartedCallback(connection_id, @@ -694,6 +760,26 @@ TEST_F(ProtocolHandlerImplTest, TestAsyncWaiter waiter; uint32_t times = 0; + // Expect verification of allowed transport + EXPECT_CALL(session_observer_mock, + TransportTypeProfileStringFromConnHandle(connection_id1)) + .WillOnce(Return("TCP_WIFI")); + EXPECT_CALL(session_observer_mock, + TransportTypeProfileStringFromConnHandle(connection_id2)) + .WillOnce(Return("TCP_WIFI")); + + std::vector audio_service_transports; + audio_service_transports.push_back("TCP_WIFI"); + std::vector video_service_transports; + video_service_transports.push_back("TCP_WIFI"); + + EXPECT_CALL(protocol_handler_settings_mock, audio_service_transports()) + .Times(2) + .WillRepeatedly(ReturnRef(audio_service_transports)); + EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) + .Times(2) + .WillRepeatedly(ReturnRef(video_service_transports)); + BsonObject bson_params1; bson_object_initialize_default(&bson_params1); bson_object_put_string(&bson_params1, @@ -830,6 +916,84 @@ TEST_F(ProtocolHandlerImplTest, bson_object_deinitialize(&bson_params2); } +/* + * ProtocolHandler shall send NAck on session_observer rejection + * Check protection flag OFF for all services from kControl to kBulk + */ +TEST_F(ProtocolHandlerImplTest, StartSession_Audio_RejectByTransportType) { + using namespace protocol_handler; + AddConnection(); + const ServiceType start_service = kAudio; + + TestAsyncWaiter waiter; + uint32_t times = 0; + // Expect verification of allowed transport + EXPECT_CALL(session_observer_mock, + TransportTypeProfileStringFromConnHandle(connection_id)) + .WillOnce(Return("TCP_WIFI")); + + std::vector audio_service_transports; + audio_service_transports.push_back("AOA_USB"); + std::vector video_service_transports; + video_service_transports.push_back("TCP_WIFI"); + + EXPECT_CALL(protocol_handler_settings_mock, audio_service_transports()) + .WillOnce(ReturnRef(audio_service_transports)); + EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) + .WillOnce(ReturnRef(video_service_transports)); + + // Expect send Ack + EXPECT_CALL(transport_manager_mock, + SendMessageToDevice(ControlMessage(FRAME_DATA_START_SERVICE_NACK, + PROTECTION_OFF))) + .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS))); + times++; + + SendControlMessage( + PROTECTION_OFF, start_service, NEW_SESSION_ID, FRAME_DATA_START_SERVICE); + + EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); +} + +/* + * ProtocolHandler shall send NAck on session_observer rejection + * Check protection flag OFF for all services from kControl to kBulk + */ +TEST_F(ProtocolHandlerImplTest, StartSession_Video_RejectByTransportType) { + using namespace protocol_handler; + AddConnection(); + const ServiceType start_service = kMobileNav; + + TestAsyncWaiter waiter; + uint32_t times = 0; + // Expect verification of allowed transport + EXPECT_CALL(session_observer_mock, + TransportTypeProfileStringFromConnHandle(connection_id)) + .WillOnce(Return("TCP_WIFI")); + + std::vector audio_service_transports; + audio_service_transports.push_back("TCP_WIFI"); + std::vector video_service_transports; + video_service_transports.push_back("AOA_USB"); + + EXPECT_CALL(protocol_handler_settings_mock, audio_service_transports()) + .WillOnce(ReturnRef(audio_service_transports)); + EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) + .WillOnce(ReturnRef(video_service_transports)); + + // Expect send Ack + EXPECT_CALL(transport_manager_mock, + SendMessageToDevice(ControlMessage(FRAME_DATA_START_SERVICE_NACK, + PROTECTION_OFF))) + .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS))); + times++; + + SendControlMessage( + PROTECTION_OFF, start_service, NEW_SESSION_ID, FRAME_DATA_START_SERVICE); + + EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); +} + // TODO(EZamakhov): add test for get_hash_id/set_hash_id from // protocol_handler_impl.cc /* @@ -910,6 +1074,21 @@ TEST_F(ProtocolHandlerImplTest, SecurityEnable_StartSessionProtocoloV1) { // Add security manager AddSecurityManager(); const ServiceType start_service = kRpc; + // Expect verification of allowed transport + EXPECT_CALL(session_observer_mock, + TransportTypeProfileStringFromConnHandle(connection_id)) + .WillOnce(Return("TCP_WIFI")); + + std::vector audio_service_transports; + audio_service_transports.push_back("TCP_WIFI"); + std::vector video_service_transports; + video_service_transports.push_back("TCP_WIFI"); + + EXPECT_CALL(protocol_handler_settings_mock, audio_service_transports()) + .WillOnce(ReturnRef(audio_service_transports)); + EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) + .WillOnce(ReturnRef(video_service_transports)); + // Expect ConnectionHandler check EXPECT_CALL(session_observer_mock, OnSessionStartedCallback(connection_id, @@ -966,6 +1145,21 @@ TEST_F(ProtocolHandlerImplTest, SecurityEnable_StartSessionUnprotected) { TestAsyncWaiter waiter; uint32_t times = 0; + // Expect verification of allowed transport + EXPECT_CALL(session_observer_mock, + TransportTypeProfileStringFromConnHandle(connection_id)) + .WillOnce(Return("TCP_WIFI")); + + std::vector audio_service_transports; + audio_service_transports.push_back("TCP_WIFI"); + std::vector video_service_transports; + video_service_transports.push_back("TCP_WIFI"); + + EXPECT_CALL(protocol_handler_settings_mock, audio_service_transports()) + .WillOnce(ReturnRef(audio_service_transports)); + EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) + .WillOnce(ReturnRef(video_service_transports)); + // Expect ConnectionHandler check EXPECT_CALL(session_observer_mock, OnSessionStartedCallback(connection_id, @@ -1021,6 +1215,21 @@ TEST_F(ProtocolHandlerImplTest, SecurityEnable_StartSessionProtected_Fail) { PROTECTION_ON); context.is_new_service_ = true; + // Expect verification of allowed transport + EXPECT_CALL(session_observer_mock, + TransportTypeProfileStringFromConnHandle(connection_id)) + .WillOnce(Return("TCP_WIFI")); + + std::vector audio_service_transports; + audio_service_transports.push_back("TCP_WIFI"); + std::vector video_service_transports; + video_service_transports.push_back("TCP_WIFI"); + + EXPECT_CALL(protocol_handler_settings_mock, audio_service_transports()) + .WillOnce(ReturnRef(audio_service_transports)); + EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) + .WillOnce(ReturnRef(video_service_transports)); + // Expect ConnectionHandler check EXPECT_CALL(session_observer_mock, OnSessionStartedCallback(connection_id, @@ -1074,6 +1283,21 @@ TEST_F(ProtocolHandlerImplTest, TestAsyncWaiter waiter; uint32_t times = 0; + // Expect verification of allowed transport + EXPECT_CALL(session_observer_mock, + TransportTypeProfileStringFromConnHandle(connection_id)) + .WillOnce(Return("TCP_WIFI")); + + std::vector audio_service_transports; + audio_service_transports.push_back("TCP_WIFI"); + std::vector video_service_transports; + video_service_transports.push_back("TCP_WIFI"); + + EXPECT_CALL(protocol_handler_settings_mock, audio_service_transports()) + .WillOnce(ReturnRef(audio_service_transports)); + EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) + .WillOnce(ReturnRef(video_service_transports)); + // Expect ConnectionHandler check EXPECT_CALL(session_observer_mock, OnSessionStartedCallback(connection_id, @@ -1150,6 +1374,21 @@ TEST_F(ProtocolHandlerImplTest, PROTECTION_ON); context.is_new_service_ = true; + // Expect verification of allowed transport + EXPECT_CALL(session_observer_mock, + TransportTypeProfileStringFromConnHandle(connection_id)) + .WillOnce(Return("TCP_WIFI")); + + std::vector audio_service_transports; + audio_service_transports.push_back("TCP_WIFI"); + std::vector video_service_transports; + video_service_transports.push_back("TCP_WIFI"); + + EXPECT_CALL(protocol_handler_settings_mock, audio_service_transports()) + .WillOnce(ReturnRef(audio_service_transports)); + EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) + .WillOnce(ReturnRef(video_service_transports)); + // Expect ConnectionHandler check EXPECT_CALL(session_observer_mock, OnSessionStartedCallback(connection_id, @@ -1231,6 +1470,21 @@ TEST_F(ProtocolHandlerImplTest, TestAsyncWaiter waiter; uint32_t times = 0; + // Expect verification of allowed transport + EXPECT_CALL(session_observer_mock, + TransportTypeProfileStringFromConnHandle(connection_id)) + .WillOnce(Return("TCP_WIFI")); + + std::vector audio_service_transports; + audio_service_transports.push_back("TCP_WIFI"); + std::vector video_service_transports; + video_service_transports.push_back("TCP_WIFI"); + + EXPECT_CALL(protocol_handler_settings_mock, audio_service_transports()) + .WillOnce(ReturnRef(audio_service_transports)); + EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) + .WillOnce(ReturnRef(video_service_transports)); + // Expect ConnectionHandler check EXPECT_CALL(session_observer_mock, OnSessionStartedCallback(connection_id, @@ -1329,6 +1583,21 @@ TEST_F( TestAsyncWaiter waiter; uint32_t times = 0; + // Expect verification of allowed transport + EXPECT_CALL(session_observer_mock, + TransportTypeProfileStringFromConnHandle(connection_id)) + .WillOnce(Return("TCP_WIFI")); + + std::vector audio_service_transports; + audio_service_transports.push_back("TCP_WIFI"); + std::vector video_service_transports; + video_service_transports.push_back("TCP_WIFI"); + + EXPECT_CALL(protocol_handler_settings_mock, audio_service_transports()) + .WillOnce(ReturnRef(audio_service_transports)); + EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) + .WillOnce(ReturnRef(video_service_transports)); + // Expect ConnectionHandler check EXPECT_CALL(session_observer_mock, OnSessionStartedCallback(connection_id, @@ -1425,6 +1694,21 @@ TEST_F(ProtocolHandlerImplTest, TestAsyncWaiter waiter; uint32_t times = 0; + // Expect verification of allowed transport + EXPECT_CALL(session_observer_mock, + TransportTypeProfileStringFromConnHandle(connection_id)) + .WillOnce(Return("TCP_WIFI")); + + std::vector audio_service_transports; + audio_service_transports.push_back("TCP_WIFI"); + std::vector video_service_transports; + video_service_transports.push_back("TCP_WIFI"); + + EXPECT_CALL(protocol_handler_settings_mock, audio_service_transports()) + .WillOnce(ReturnRef(audio_service_transports)); + EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) + .WillOnce(ReturnRef(video_service_transports)); + // Expect ConnectionHandler check EXPECT_CALL(session_observer_mock, OnSessionStartedCallback(connection_id, -- cgit v1.2.1 From 55a73f739d9d92d975b9c7d95c3b3001a007c8d1 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Wed, 19 Sep 2018 17:24:57 -0400 Subject: Add filtering for policy table parameters --- .../include/policy/policy_table/enums.h | 1 + .../policy_external/src/policy_manager_impl.cc | 119 ++++++++++++++++++++- .../policy_external/src/policy_table/enums.cc | 7 ++ .../test/policy_manager_impl_ptu_test.cc | 12 +-- .../test/policy_manager_impl_test_base.cc | 12 +-- .../include/policy/policy_table/enums.h | 4 +- .../policy_regular/src/policy_manager_impl.cc | 119 ++++++++++++++++++++- .../policy_regular/src/policy_table/enums.cc | 7 ++ .../test/policy_manager_impl_test.cc | 24 ++--- 9 files changed, 274 insertions(+), 31 deletions(-) diff --git a/src/components/policy/policy_external/include/policy/policy_table/enums.h b/src/components/policy/policy_external/include/policy/policy_table/enums.h index 2ab6ade03b..82322d442d 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_external/include/policy/policy_table/enums.h @@ -44,6 +44,7 @@ enum Priority { P_VOICECOM, P_COMMUNICATION, P_NORMAL, + P_PROJECTION, P_NONE, }; 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 9dffaf52e3..649bcb8ea6 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -288,10 +288,19 @@ void FilterInvalidFunctions(policy_table::Rpc& rpcs) { } /** - * @brief FilterInvalidParameters filter parameters that not present in schema + * @brief FilterInvalidRPCParameters filter parameters that not present in + * schema * @param rpc_parameters parameters to filter */ -void FilterInvalidParameters(policy_table::RpcParameters& rpc_parameters) { +void FilterInvalidRPCParameters(policy_table::RpcParameters& rpc_parameters) { + policy_table::HmiLevels valid_hmi_levels; + for (auto& hmi_level : rpc_parameters.hmi_levels) { + if (hmi_level.is_valid()) { + valid_hmi_levels.push_back(hmi_level); + } + } + rpc_parameters.hmi_levels.swap(valid_hmi_levels); + policy_table::Parameters valid_params; for (auto& param : *(rpc_parameters.parameters)) { if (param.is_valid()) { @@ -301,17 +310,121 @@ void FilterInvalidParameters(policy_table::RpcParameters& rpc_parameters) { rpc_parameters.parameters->swap(valid_params); } +/** + * @brief FilterInvalidNotifications filter notification priorities that are not + * present in schema + * @param notification priorities to filter + */ +void FilterInvalidNotifications( + policy_table::NumberOfNotificationsPerMinute& notifications) { + policy_table::NumberOfNotificationsPerMinute valid_notifications; + for (const auto& notification : notifications) { + policy_table::Priority priority; + if (policy_table::EnumFromJsonString(notification.first, &priority)) { + valid_notifications.insert(notification); + } + } + notifications.swap(valid_notifications); +} + +/** + * @brief FilterInvalidApplicationParameters filter app params that are not + * present in schema + * @param object of app policy params to filter + */ +void FilterInvalidApplicationParameters( + policy_table::ApplicationParams& app_params) { + // Filter AppHMIType array + policy_table::AppHMITypes valid_app_hmi_types; + policy_table::AppHMITypes app_hmi_types = *(app_params.AppHMIType); + for (const auto& app_hmi_type : app_hmi_types) { + if (app_hmi_type.is_valid()) { + valid_app_hmi_types.push_back(app_hmi_type); + } + } + app_params.AppHMIType->swap(valid_app_hmi_types); + + // Filter RquestTypes array + policy_table::RequestTypes valid_request_types; + policy_table::RequestTypes request_types = *(app_params.RequestType); + for (const auto& request_type : request_types) { + if (request_type.is_valid()) { + valid_request_types.push_back(request_type); + } + } + if (valid_request_types.empty() && !request_types.empty()) { + // An empty RequestType array will allow all request types. No valid + // parameters are in the filtered array, so assign an uninitizlied value to + // for array to be "omitted" + policy_table::RequestTypes omitted_request_types; + *(app_params.RequestType) = omitted_request_types; + } else { + app_params.RequestType->swap(valid_request_types); + } + + // Filter RquestSubTypes array + policy_table::RequestSubTypes valid_request_sub_types; + policy_table::RequestSubTypes request_sub_types = + *(app_params.RequestSubType); + for (const auto& request_sub_type : request_sub_types) { + if (request_sub_type.is_valid()) { + valid_request_sub_types.push_back(request_sub_type); + } + } + if (valid_request_types.empty() && !request_types.empty()) { + // An empty RequestSubType array will allow all request types. No valid + // parameters are in the filtered array, so assign an uninitizlied value to + // for array to be "omitted" + policy_table::RequestTypes omitted_request_types; + *(app_params.RequestType) = omitted_request_types; + } else { + app_params.RequestType->swap(valid_request_types); + } + + // Filter moduleType array + policy_table::ModuleTypes valid_module_types; + policy_table::ModuleTypes module_types = *(app_params.moduleType); + for (const auto& module_type : module_types) { + if (module_type.is_valid()) { + valid_module_types.push_back(module_type); + } + } + if (valid_module_types.empty() && !module_types.empty()) { + // An empty moduleType array will allow all request types. No valid + // parameters are in the filtered array, so assign an uninitizlied value to + // for array to be "omitted" + policy_table::ModuleTypes omitted_module_types; + *(app_params.moduleType) = omitted_module_types; + } else { + app_params.moduleType->swap(valid_module_types); + } +} + /** * @brief FilterPolicyTable filter values that not present in schema * @param pt policy table to filter */ void FilterPolicyTable(policy_table::PolicyTable& pt) { + policy_table::ModuleConfig& module_config = pt.module_config; + if (module_config.is_initialized() && + module_config.notifications_per_minute_by_priority.is_initialized()) { + FilterInvalidNotifications( + module_config.notifications_per_minute_by_priority); + } + + if (pt.app_policies_section.is_initialized()) { + policy_table::ApplicationPolicies& apps = pt.app_policies_section.apps; + for (auto& app_policy : apps) { + FilterInvalidApplicationParameters(app_policy.second); + } + } + for (auto& group : pt.functional_groupings) { policy_table::Rpc& rpcs = group.second.rpcs; FilterInvalidFunctions(rpcs); for (auto& func : rpcs) { - FilterInvalidParameters(func.second); + FilterInvalidRPCParameters(func.second); } } } diff --git a/src/components/policy/policy_external/src/policy_table/enums.cc b/src/components/policy/policy_external/src/policy_table/enums.cc index 5152cc38ef..6410cb79de 100644 --- a/src/components/policy/policy_external/src/policy_table/enums.cc +++ b/src/components/policy/policy_external/src/policy_table/enums.cc @@ -14,6 +14,8 @@ bool IsValidEnum(Priority val) { return true; case P_NORMAL: return true; + case P_PROJECTION: + return true; case P_NONE: return true; default: @@ -32,6 +34,8 @@ const char* EnumToJsonString(Priority val) { return "COMMUNICATION"; case P_NORMAL: return "NORMAL"; + case P_PROJECTION: + return "PROJECTION"; case P_NONE: return "NONE"; default: @@ -54,6 +58,9 @@ bool EnumFromJsonString(const std::string& literal, Priority* result) { } else if ("NORMAL" == literal) { *result = P_NORMAL; return true; + } else if ("PROJECTION" == literal) { + *result = P_PROJECTION; + return true; } else if ("NONE" == literal) { *result = P_NONE; return true; diff --git a/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc index dd9b43d53c..93d4e19751 100644 --- a/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc +++ b/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc @@ -113,27 +113,27 @@ TEST_F(PolicyManagerImplTest2, GetNotificationsNumberAfterPTUpdate) { EXPECT_TRUE(policy_manager_->LoadPT(kFilePtUpdateJson, msg)); EXPECT_FALSE(policy_manager_->GetCache()->IsPTPreloaded()); - std::string priority = "emergency"; + std::string priority = "EMERGENCY"; uint32_t notif_number = policy_manager_->GetNotificationsNumber(priority); EXPECT_EQ(1u, notif_number); - priority = "navigation"; + priority = "NAVIGATION"; notif_number = policy_manager_->GetNotificationsNumber(priority); EXPECT_EQ(2u, notif_number); - priority = "emergency"; + priority = "EMERGENCY"; notif_number = policy_manager_->GetNotificationsNumber(priority); EXPECT_EQ(1u, notif_number); - priority = "VOICECOMM"; + priority = "VOICECOM"; notif_number = policy_manager_->GetNotificationsNumber(priority); EXPECT_EQ(3u, notif_number); - priority = "normal"; + priority = "NORMAL"; notif_number = policy_manager_->GetNotificationsNumber(priority); EXPECT_EQ(5u, notif_number); - priority = "none"; + priority = "NONE"; notif_number = policy_manager_->GetNotificationsNumber(priority); EXPECT_EQ(6u, notif_number); } diff --git a/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc b/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc index 86b7cdc9ef..13efa39805 100644 --- a/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc +++ b/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc @@ -105,12 +105,12 @@ Json::Value createPTforLoad() { "}" "}," "\"notifications_per_minute_by_priority\": {" - "\"emergency\": 1," - "\"navigation\": 2," - "\"VOICECOMM\": 3," - "\"communication\": 4," - "\"normal\": 5," - "\"none\": 6" + "\"EMERGENCY\": 1," + "\"NAVIGATION\": 2," + "\"VOICECOM\": 3," + "\"COMMUNICATION\": 4," + "\"NORMAL\": 5," + "\"NONE\": 6" "}," "\"vehicle_make\" : \"MakeT\"," "\"vehicle_model\" : \"ModelT\"," diff --git a/src/components/policy/policy_regular/include/policy/policy_table/enums.h b/src/components/policy/policy_regular/include/policy/policy_table/enums.h index 4fda36cbe7..693d547cb9 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/enums.h @@ -44,6 +44,7 @@ enum Priority { P_VOICECOM, P_COMMUNICATION, P_NORMAL, + P_PROJECTION, P_NONE, }; @@ -169,7 +170,8 @@ bool EnumFromJsonString(const std::string& literal, ModuleType* result); /** * @brief Enumeration FunctionID. * - * Enumeration linking function names with function IDs in AppLink protocol. Assumes enumeration starts at value 0. + * Enumeration linking function names with function IDs in AppLink protocol. + *Assumes enumeration starts at value 0. */ enum FunctionID { /** 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 8c70437bfc..17f0fdebd9 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -160,10 +160,19 @@ void FilterInvalidFunctions(policy_table::Rpc& rpcs) { } /** - * @brief FilterInvalidParameters filter parameters that not present in schema + * @brief FilterInvalidRPCParameters filter parameters that not present in + * schema * @param rpc_parameters parameters to filter */ -void FilterInvalidParameters(policy_table::RpcParameters& rpc_parameters) { +void FilterInvalidRPCParameters(policy_table::RpcParameters& rpc_parameters) { + policy_table::HmiLevels valid_hmi_levels; + for (auto& hmi_level : rpc_parameters.hmi_levels) { + if (hmi_level.is_valid()) { + valid_hmi_levels.push_back(hmi_level); + } + } + rpc_parameters.hmi_levels.swap(valid_hmi_levels); + policy_table::Parameters valid_params; for (auto& param : *(rpc_parameters.parameters)) { if (param.is_valid()) { @@ -173,17 +182,121 @@ void FilterInvalidParameters(policy_table::RpcParameters& rpc_parameters) { rpc_parameters.parameters->swap(valid_params); } +/** + * @brief FilterInvalidNotifications filter notification priorities that are not + * present in schema + * @param notification priorities to filter + */ +void FilterInvalidNotifications( + policy_table::NumberOfNotificationsPerMinute& notifications) { + policy_table::NumberOfNotificationsPerMinute valid_notifications; + for (const auto& notification : notifications) { + policy_table::Priority priority; + if (policy_table::EnumFromJsonString(notification.first, &priority)) { + valid_notifications.insert(notification); + } + } + notifications.swap(valid_notifications); +} + +/** + * @brief FilterInvalidApplicationParameters filter app params that are not + * present in schema + * @param object of app policy params to filter + */ +void FilterInvalidApplicationParameters( + policy_table::ApplicationParams& app_params) { + // Filter AppHMIType array + policy_table::AppHMITypes valid_app_hmi_types; + policy_table::AppHMITypes app_hmi_types = *(app_params.AppHMIType); + for (const auto& app_hmi_type : app_hmi_types) { + if (app_hmi_type.is_valid()) { + valid_app_hmi_types.push_back(app_hmi_type); + } + } + app_params.AppHMIType->swap(valid_app_hmi_types); + + // Filter RquestTypes array + policy_table::RequestTypes valid_request_types; + policy_table::RequestTypes request_types = *(app_params.RequestType); + for (const auto& request_type : request_types) { + if (request_type.is_valid()) { + valid_request_types.push_back(request_type); + } + } + if (valid_request_types.empty() && !request_types.empty()) { + // An empty RequestType array will allow all request types. No valid + // parameters are in the filtered array, so assign an uninitizlied value to + // for array to be "omitted" + policy_table::RequestTypes omitted_request_types; + *(app_params.RequestType) = omitted_request_types; + } else { + app_params.RequestType->swap(valid_request_types); + } + + // Filter RquestSubTypes array + policy_table::RequestSubTypes valid_request_sub_types; + policy_table::RequestSubTypes request_sub_types = + *(app_params.RequestSubType); + for (const auto& request_sub_type : request_sub_types) { + if (request_sub_type.is_valid()) { + valid_request_sub_types.push_back(request_sub_type); + } + } + if (valid_request_types.empty() && !request_types.empty()) { + // An empty RequestSubType array will allow all request types. No valid + // parameters are in the filtered array, so assign an uninitizlied value to + // for array to be "omitted" + policy_table::RequestTypes omitted_request_types; + *(app_params.RequestType) = omitted_request_types; + } else { + app_params.RequestType->swap(valid_request_types); + } + + // Filter moduleType array + policy_table::ModuleTypes valid_module_types; + policy_table::ModuleTypes module_types = *(app_params.moduleType); + for (const auto& module_type : module_types) { + if (module_type.is_valid()) { + valid_module_types.push_back(module_type); + } + } + if (valid_module_types.empty() && !module_types.empty()) { + // An empty moduleType array will allow all request types. No valid + // parameters are in the filtered array, so assign an uninitizlied value to + // for array to be "omitted" + policy_table::ModuleTypes omitted_module_types; + *(app_params.moduleType) = omitted_module_types; + } else { + app_params.moduleType->swap(valid_module_types); + } +} + /** * @brief FilterPolicyTable filter values that not present in schema * @param pt policy table to filter */ void FilterPolicyTable(policy_table::PolicyTable& pt) { + policy_table::ModuleConfig& module_config = pt.module_config; + if (module_config.is_initialized() && + module_config.notifications_per_minute_by_priority.is_initialized()) { + FilterInvalidNotifications( + module_config.notifications_per_minute_by_priority); + } + + if (pt.app_policies_section.is_initialized()) { + policy_table::ApplicationPolicies& apps = pt.app_policies_section.apps; + for (auto& app_policy : apps) { + FilterInvalidApplicationParameters(app_policy.second); + } + } + for (auto& group : pt.functional_groupings) { policy_table::Rpc& rpcs = group.second.rpcs; FilterInvalidFunctions(rpcs); for (auto& func : rpcs) { - FilterInvalidParameters(func.second); + FilterInvalidRPCParameters(func.second); } } } diff --git a/src/components/policy/policy_regular/src/policy_table/enums.cc b/src/components/policy/policy_regular/src/policy_table/enums.cc index 6f914807c5..ec92d064da 100644 --- a/src/components/policy/policy_regular/src/policy_table/enums.cc +++ b/src/components/policy/policy_regular/src/policy_table/enums.cc @@ -15,6 +15,8 @@ bool IsValidEnum(Priority val) { return true; case P_NORMAL: return true; + case P_PROJECTION: + return true; case P_NONE: return true; default: @@ -33,6 +35,8 @@ const char* EnumToJsonString(Priority val) { return "COMMUNICATION"; case P_NORMAL: return "NORMAL"; + case P_PROJECTION: + return "PROJECTION"; case P_NONE: return "NONE"; default: @@ -55,6 +59,9 @@ bool EnumFromJsonString(const std::string& literal, Priority* result) { } else if ("NORMAL" == literal) { *result = P_NORMAL; return true; + } else if ("PROJECTION" == literal) { + *result = P_PROJECTION; + return true; } else if ("NONE" == literal) { *result = P_NONE; return true; diff --git a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc index 9f73f60d28..ff054b3cc4 100644 --- a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc +++ b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc @@ -383,12 +383,12 @@ Json::Value CreatePTforLoad() { "}" "}," "\"notifications_per_minute_by_priority\": {" - "\"emergency\": 1," - "\"navigation\": 2," - "\"VOICECOMM\": 3," - "\"communication\": 4," - "\"normal\": 5," - "\"none\": 6" + "\"EMERGENCY\": 1," + "\"NAVIGATION\": 2," + "\"VOICECOM\": 3," + "\"COMMUNICATION\": 4," + "\"NORMAL\": 5," + "\"NONE\": 6" "}," "\"vehicle_make\" : \"MakeT\"," "\"vehicle_model\" : \"ModelT\"," @@ -481,27 +481,27 @@ TEST_F(PolicyManagerImplTest2, GetNotificationsNumberAfterPTUpdate) { EXPECT_CALL(listener, OnUpdateStatusChanged(_)); EXPECT_TRUE(manager->LoadPT("file_pt_update.json", msg)); - std::string priority = "emergency"; + std::string priority = "EMERGENCY"; uint32_t notif_number = manager->GetNotificationsNumber(priority); EXPECT_EQ(1u, notif_number); - priority = "navigation"; + priority = "NAVIGATION"; notif_number = manager->GetNotificationsNumber(priority); EXPECT_EQ(2u, notif_number); - priority = "emergency"; + priority = "EMERGENCY"; notif_number = manager->GetNotificationsNumber(priority); EXPECT_EQ(1u, notif_number); - priority = "VOICECOMM"; + priority = "VOICECOM"; notif_number = manager->GetNotificationsNumber(priority); EXPECT_EQ(3u, notif_number); - priority = "normal"; + priority = "NORMAL"; notif_number = manager->GetNotificationsNumber(priority); EXPECT_EQ(5u, notif_number); - priority = "none"; + priority = "NONE"; notif_number = manager->GetNotificationsNumber(priority); EXPECT_EQ(6u, notif_number); } -- cgit v1.2.1 From 67fdb552dc89c9e0c911937a8ac8a825f11dfb49 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Thu, 20 Sep 2018 15:58:36 -0400 Subject: Update based on comments --- .../policy_external/src/policy_manager_impl.cc | 60 +++++++++------------ .../policy_regular/src/policy_manager_impl.cc | 62 +++++++++------------- 2 files changed, 51 insertions(+), 71 deletions(-) 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 649bcb8ea6..ce0e8d0588 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -294,7 +294,7 @@ void FilterInvalidFunctions(policy_table::Rpc& rpcs) { */ void FilterInvalidRPCParameters(policy_table::RpcParameters& rpc_parameters) { policy_table::HmiLevels valid_hmi_levels; - for (auto& hmi_level : rpc_parameters.hmi_levels) { + for (const auto& hmi_level : rpc_parameters.hmi_levels) { if (hmi_level.is_valid()) { valid_hmi_levels.push_back(hmi_level); } @@ -302,7 +302,7 @@ void FilterInvalidRPCParameters(policy_table::RpcParameters& rpc_parameters) { rpc_parameters.hmi_levels.swap(valid_hmi_levels); policy_table::Parameters valid_params; - for (auto& param : *(rpc_parameters.parameters)) { + for (const auto& param : *(rpc_parameters.parameters)) { if (param.is_valid()) { valid_params.push_back(param); } @@ -311,11 +311,12 @@ void FilterInvalidRPCParameters(policy_table::RpcParameters& rpc_parameters) { } /** - * @brief FilterInvalidNotifications filter notification priorities that are not + * @brief FilterInvalidPriorityValues filter notification priorities that are + * not * present in schema - * @param notification priorities to filter + * @param notifications priorities to filter */ -void FilterInvalidNotifications( +void FilterInvalidPriorityValues( policy_table::NumberOfNotificationsPerMinute& notifications) { policy_table::NumberOfNotificationsPerMinute valid_notifications; for (const auto& notification : notifications) { @@ -330,13 +331,13 @@ void FilterInvalidNotifications( /** * @brief FilterInvalidApplicationParameters filter app params that are not * present in schema - * @param object of app policy params to filter + * @param app_params object of app policy params to filter */ void FilterInvalidApplicationParameters( policy_table::ApplicationParams& app_params) { // Filter AppHMIType array policy_table::AppHMITypes valid_app_hmi_types; - policy_table::AppHMITypes app_hmi_types = *(app_params.AppHMIType); + const policy_table::AppHMITypes& app_hmi_types = *(app_params.AppHMIType); for (const auto& app_hmi_type : app_hmi_types) { if (app_hmi_type.is_valid()) { valid_app_hmi_types.push_back(app_hmi_type); @@ -346,7 +347,7 @@ void FilterInvalidApplicationParameters( // Filter RquestTypes array policy_table::RequestTypes valid_request_types; - policy_table::RequestTypes request_types = *(app_params.RequestType); + const policy_table::RequestTypes& request_types = *(app_params.RequestType); for (const auto& request_type : request_types) { if (request_type.is_valid()) { valid_request_types.push_back(request_type); @@ -354,36 +355,16 @@ void FilterInvalidApplicationParameters( } if (valid_request_types.empty() && !request_types.empty()) { // An empty RequestType array will allow all request types. No valid - // parameters are in the filtered array, so assign an uninitizlied value to + // parameters are in the filtered array, so assign an unitialized value to // for array to be "omitted" - policy_table::RequestTypes omitted_request_types; - *(app_params.RequestType) = omitted_request_types; - } else { - app_params.RequestType->swap(valid_request_types); - } - - // Filter RquestSubTypes array - policy_table::RequestSubTypes valid_request_sub_types; - policy_table::RequestSubTypes request_sub_types = - *(app_params.RequestSubType); - for (const auto& request_sub_type : request_sub_types) { - if (request_sub_type.is_valid()) { - valid_request_sub_types.push_back(request_sub_type); - } - } - if (valid_request_types.empty() && !request_types.empty()) { - // An empty RequestSubType array will allow all request types. No valid - // parameters are in the filtered array, so assign an uninitizlied value to - // for array to be "omitted" - policy_table::RequestTypes omitted_request_types; - *(app_params.RequestType) = omitted_request_types; + *(app_params.RequestType) = policy_table::RequestTypes(); } else { app_params.RequestType->swap(valid_request_types); } // Filter moduleType array policy_table::ModuleTypes valid_module_types; - policy_table::ModuleTypes module_types = *(app_params.moduleType); + const policy_table::ModuleTypes& module_types = *(app_params.moduleType); for (const auto& module_type : module_types) { if (module_type.is_valid()) { valid_module_types.push_back(module_type); @@ -391,13 +372,22 @@ void FilterInvalidApplicationParameters( } if (valid_module_types.empty() && !module_types.empty()) { // An empty moduleType array will allow all request types. No valid - // parameters are in the filtered array, so assign an uninitizlied value to + // parameters are in the filtered array, so assign an unitialized value to // for array to be "omitted" - policy_table::ModuleTypes omitted_module_types; - *(app_params.moduleType) = omitted_module_types; + *(app_params.moduleType) = policy_table::ModuleTypes(); } else { app_params.moduleType->swap(valid_module_types); } + + // Filter default_hmi + if (!app_params.default_hmi.is_valid()) { + app_params.default_hmi = policy_table::HmiLevel(); + } + + // Filter priority + if (!app_params.priority.is_valid()) { + app_params.priority = policy_table::Priority(); + } } /** @@ -408,7 +398,7 @@ void FilterPolicyTable(policy_table::PolicyTable& pt) { policy_table::ModuleConfig& module_config = pt.module_config; if (module_config.is_initialized() && module_config.notifications_per_minute_by_priority.is_initialized()) { - FilterInvalidNotifications( + FilterInvalidPriorityValues( module_config.notifications_per_minute_by_priority); } 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 17f0fdebd9..a9619f8bf6 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -144,7 +144,7 @@ void PolicyManagerImpl::CheckTriggers() { } /** - * @brief FilterInvalidFunctions filter functions that are not present in schema + * @brief FilterInvalidFunctions filter functions that are absent in schema * @param rpcs list of functions to filter */ void FilterInvalidFunctions(policy_table::Rpc& rpcs) { @@ -166,7 +166,7 @@ void FilterInvalidFunctions(policy_table::Rpc& rpcs) { */ void FilterInvalidRPCParameters(policy_table::RpcParameters& rpc_parameters) { policy_table::HmiLevels valid_hmi_levels; - for (auto& hmi_level : rpc_parameters.hmi_levels) { + for (const auto& hmi_level : rpc_parameters.hmi_levels) { if (hmi_level.is_valid()) { valid_hmi_levels.push_back(hmi_level); } @@ -174,7 +174,7 @@ void FilterInvalidRPCParameters(policy_table::RpcParameters& rpc_parameters) { rpc_parameters.hmi_levels.swap(valid_hmi_levels); policy_table::Parameters valid_params; - for (auto& param : *(rpc_parameters.parameters)) { + for (const auto& param : *(rpc_parameters.parameters)) { if (param.is_valid()) { valid_params.push_back(param); } @@ -183,11 +183,12 @@ void FilterInvalidRPCParameters(policy_table::RpcParameters& rpc_parameters) { } /** - * @brief FilterInvalidNotifications filter notification priorities that are not + * @brief FilterInvalidPriorityValues filter notification priorities that are + * not * present in schema - * @param notification priorities to filter + * @param notifications priorities to filter */ -void FilterInvalidNotifications( +void FilterInvalidPriorityValues( policy_table::NumberOfNotificationsPerMinute& notifications) { policy_table::NumberOfNotificationsPerMinute valid_notifications; for (const auto& notification : notifications) { @@ -202,13 +203,13 @@ void FilterInvalidNotifications( /** * @brief FilterInvalidApplicationParameters filter app params that are not * present in schema - * @param object of app policy params to filter + * @param app_params object of app policy params to filter */ void FilterInvalidApplicationParameters( policy_table::ApplicationParams& app_params) { // Filter AppHMIType array policy_table::AppHMITypes valid_app_hmi_types; - policy_table::AppHMITypes app_hmi_types = *(app_params.AppHMIType); + const policy_table::AppHMITypes& app_hmi_types = *(app_params.AppHMIType); for (const auto& app_hmi_type : app_hmi_types) { if (app_hmi_type.is_valid()) { valid_app_hmi_types.push_back(app_hmi_type); @@ -218,7 +219,7 @@ void FilterInvalidApplicationParameters( // Filter RquestTypes array policy_table::RequestTypes valid_request_types; - policy_table::RequestTypes request_types = *(app_params.RequestType); + const policy_table::RequestTypes& request_types = *(app_params.RequestType); for (const auto& request_type : request_types) { if (request_type.is_valid()) { valid_request_types.push_back(request_type); @@ -226,36 +227,16 @@ void FilterInvalidApplicationParameters( } if (valid_request_types.empty() && !request_types.empty()) { // An empty RequestType array will allow all request types. No valid - // parameters are in the filtered array, so assign an uninitizlied value to + // parameters are in the filtered array, so assign an unitialized value to // for array to be "omitted" - policy_table::RequestTypes omitted_request_types; - *(app_params.RequestType) = omitted_request_types; - } else { - app_params.RequestType->swap(valid_request_types); - } - - // Filter RquestSubTypes array - policy_table::RequestSubTypes valid_request_sub_types; - policy_table::RequestSubTypes request_sub_types = - *(app_params.RequestSubType); - for (const auto& request_sub_type : request_sub_types) { - if (request_sub_type.is_valid()) { - valid_request_sub_types.push_back(request_sub_type); - } - } - if (valid_request_types.empty() && !request_types.empty()) { - // An empty RequestSubType array will allow all request types. No valid - // parameters are in the filtered array, so assign an uninitizlied value to - // for array to be "omitted" - policy_table::RequestTypes omitted_request_types; - *(app_params.RequestType) = omitted_request_types; + *(app_params.RequestType) = policy_table::RequestTypes(); } else { app_params.RequestType->swap(valid_request_types); } // Filter moduleType array policy_table::ModuleTypes valid_module_types; - policy_table::ModuleTypes module_types = *(app_params.moduleType); + const policy_table::ModuleTypes& module_types = *(app_params.moduleType); for (const auto& module_type : module_types) { if (module_type.is_valid()) { valid_module_types.push_back(module_type); @@ -263,13 +244,22 @@ void FilterInvalidApplicationParameters( } if (valid_module_types.empty() && !module_types.empty()) { // An empty moduleType array will allow all request types. No valid - // parameters are in the filtered array, so assign an uninitizlied value to + // parameters are in the filtered array, so assign an unitialized value to // for array to be "omitted" - policy_table::ModuleTypes omitted_module_types; - *(app_params.moduleType) = omitted_module_types; + *(app_params.moduleType) = policy_table::ModuleTypes(); } else { app_params.moduleType->swap(valid_module_types); } + + // Filter default_hmi + if (!app_params.default_hmi.is_valid()) { + app_params.default_hmi = policy_table::HmiLevel(); + } + + // Filter priority + if (!app_params.priority.is_valid()) { + app_params.priority = policy_table::Priority(); + } } /** @@ -280,7 +270,7 @@ void FilterPolicyTable(policy_table::PolicyTable& pt) { policy_table::ModuleConfig& module_config = pt.module_config; if (module_config.is_initialized() && module_config.notifications_per_minute_by_priority.is_initialized()) { - FilterInvalidNotifications( + FilterInvalidPriorityValues( module_config.notifications_per_minute_by_priority); } -- cgit v1.2.1 From 0940a8d3412648ffeadb58b633ca8a293b4df58d Mon Sep 17 00:00:00 2001 From: JackLivio Date: Thu, 20 Sep 2018 16:03:25 -0400 Subject: Fix typo --- src/components/policy/policy_external/src/policy_manager_impl.cc | 4 ++-- src/components/policy/policy_regular/src/policy_manager_impl.cc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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 ce0e8d0588..34d58b5812 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -355,7 +355,7 @@ void FilterInvalidApplicationParameters( } if (valid_request_types.empty() && !request_types.empty()) { // An empty RequestType array will allow all request types. No valid - // parameters are in the filtered array, so assign an unitialized value to + // parameters are in the filtered array, so assign an uninitialized value to // for array to be "omitted" *(app_params.RequestType) = policy_table::RequestTypes(); } else { @@ -372,7 +372,7 @@ void FilterInvalidApplicationParameters( } if (valid_module_types.empty() && !module_types.empty()) { // An empty moduleType array will allow all request types. No valid - // parameters are in the filtered array, so assign an unitialized value to + // parameters are in the filtered array, so assign an uninitialized value to // for array to be "omitted" *(app_params.moduleType) = policy_table::ModuleTypes(); } else { 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 a9619f8bf6..6ecf8521ed 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -227,7 +227,7 @@ void FilterInvalidApplicationParameters( } if (valid_request_types.empty() && !request_types.empty()) { // An empty RequestType array will allow all request types. No valid - // parameters are in the filtered array, so assign an unitialized value to + // parameters are in the filtered array, so assign an uninitialized value to // for array to be "omitted" *(app_params.RequestType) = policy_table::RequestTypes(); } else { @@ -244,7 +244,7 @@ void FilterInvalidApplicationParameters( } if (valid_module_types.empty() && !module_types.empty()) { // An empty moduleType array will allow all request types. No valid - // parameters are in the filtered array, so assign an unitialized value to + // parameters are in the filtered array, so assign an uninitialized value to // for array to be "omitted" *(app_params.moduleType) = policy_table::ModuleTypes(); } else { -- cgit v1.2.1 From 3eb89f8a33c603f7d3bcee5592b62840fb728d34 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Thu, 20 Sep 2018 17:10:29 -0400 Subject: Address comments --- .../policy/policy_external/include/policy/policy_table/enums.h | 2 +- src/components/policy/policy_external/src/policy_manager_impl.cc | 6 +++--- .../policy/policy_regular/include/policy/policy_table/enums.h | 2 +- src/components/policy/policy_regular/src/policy_manager_impl.cc | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/policy/policy_external/include/policy/policy_table/enums.h b/src/components/policy/policy_external/include/policy/policy_table/enums.h index 82322d442d..34864c5602 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_external/include/policy/policy_table/enums.h @@ -185,7 +185,7 @@ bool EnumFromJsonString(const std::string& literal, ModuleType* result); * @brief Enumeration FunctionID. * * Enumeration linking function names with function IDs in AppLink protocol. - *Assumes enumeration starts at value 0. + * Assumes enumeration starts at value 0. */ enum FunctionID { /** 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 34d58b5812..e93eea3969 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -302,7 +302,8 @@ void FilterInvalidRPCParameters(policy_table::RpcParameters& rpc_parameters) { rpc_parameters.hmi_levels.swap(valid_hmi_levels); policy_table::Parameters valid_params; - for (const auto& param : *(rpc_parameters.parameters)) { + const policy_table::Parameters& params = *(rpc_parameters.parameters); + for (const auto& param : params) { if (param.is_valid()) { valid_params.push_back(param); } @@ -312,8 +313,7 @@ void FilterInvalidRPCParameters(policy_table::RpcParameters& rpc_parameters) { /** * @brief FilterInvalidPriorityValues filter notification priorities that are - * not - * present in schema + * not present in schema * @param notifications priorities to filter */ void FilterInvalidPriorityValues( diff --git a/src/components/policy/policy_regular/include/policy/policy_table/enums.h b/src/components/policy/policy_regular/include/policy/policy_table/enums.h index 693d547cb9..1f10db9f6f 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/enums.h @@ -171,7 +171,7 @@ bool EnumFromJsonString(const std::string& literal, ModuleType* result); * @brief Enumeration FunctionID. * * Enumeration linking function names with function IDs in AppLink protocol. - *Assumes enumeration starts at value 0. + * Assumes enumeration starts at value 0. */ enum FunctionID { /** 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 6ecf8521ed..a4e21a023c 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -174,7 +174,8 @@ void FilterInvalidRPCParameters(policy_table::RpcParameters& rpc_parameters) { rpc_parameters.hmi_levels.swap(valid_hmi_levels); policy_table::Parameters valid_params; - for (const auto& param : *(rpc_parameters.parameters)) { + const policy_table::Parameters& params = *(rpc_parameters.parameters); + for (const auto& param : params) { if (param.is_valid()) { valid_params.push_back(param); } @@ -184,8 +185,7 @@ void FilterInvalidRPCParameters(policy_table::RpcParameters& rpc_parameters) { /** * @brief FilterInvalidPriorityValues filter notification priorities that are - * not - * present in schema + * not present in schema * @param notifications priorities to filter */ void FilterInvalidPriorityValues( -- cgit v1.2.1 From 0aaa4eb5d1405ac3472b2a0fc35cb6a1cf9f88a5 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Fri, 21 Sep 2018 10:25:00 -0400 Subject: Remove default_hmi error from regular policy manager --- src/components/policy/policy_regular/src/policy_manager_impl.cc | 5 ----- 1 file changed, 5 deletions(-) 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 a4e21a023c..084ddd2701 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -251,11 +251,6 @@ void FilterInvalidApplicationParameters( app_params.moduleType->swap(valid_module_types); } - // Filter default_hmi - if (!app_params.default_hmi.is_valid()) { - app_params.default_hmi = policy_table::HmiLevel(); - } - // Filter priority if (!app_params.priority.is_valid()) { app_params.priority = policy_table::Priority(); -- cgit v1.2.1 From 461f76b129e998d4b60540491684c348dd5c27e2 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Mon, 24 Sep 2018 16:03:58 -0400 Subject: Fix ReadDID Typo (#2630) * Fix ReadDID Typo * Remove Reserved from external enums * Remove Reserved from regular enums --- .../policy/policy_external/src/policy_table/enums.cc | 7 +------ .../policy/policy_regular/src/policy_table/enums.cc | 13 ++----------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/src/components/policy/policy_external/src/policy_table/enums.cc b/src/components/policy/policy_external/src/policy_table/enums.cc index 6410cb79de..27db505e3f 100644 --- a/src/components/policy/policy_external/src/policy_table/enums.cc +++ b/src/components/policy/policy_external/src/policy_table/enums.cc @@ -841,11 +841,6 @@ bool EnumFromJsonString(const std::string& literal, ModuleType* result) { } bool EnumFromJsonString(const std::string& literal, FunctionID* result) { - if ("RESERVE" == literal) { - *result = RESERVED; - return true; - } - if ("RegisterAppInterface" == literal) { *result = RegisterAppInterfaceID; return true; @@ -956,7 +951,7 @@ bool EnumFromJsonString(const std::string& literal, FunctionID* result) { return true; } - if ("ReadD" == literal) { + if ("ReadDID" == literal) { *result = ReadDIDID; return true; } diff --git a/src/components/policy/policy_regular/src/policy_table/enums.cc b/src/components/policy/policy_regular/src/policy_table/enums.cc index ec92d064da..428e18d0bd 100644 --- a/src/components/policy/policy_regular/src/policy_table/enums.cc +++ b/src/components/policy/policy_regular/src/policy_table/enums.cc @@ -711,8 +711,6 @@ bool EnumFromJsonString(const std::string& literal, ModuleType* result) { bool IsValidEnum(FunctionID val) { switch (val) { - case RESERVED: - return true; case RegisterAppInterfaceID: return true; case UnregisterAppInterfaceID: @@ -860,8 +858,6 @@ bool IsValidEnum(FunctionID val) { const char* EnumToJsonString(FunctionID val) { switch (val) { - case RESERVED: - return "RESERVE"; case RegisterAppInterfaceID: return "RegisterAppInterface"; case UnregisterAppInterfaceID: @@ -907,7 +903,7 @@ const char* EnumToJsonString(FunctionID val) { case GetVehicleDataID: return "GetVehicleData"; case ReadDIDID: - return "ReadD"; + return "ReadDID"; case GetDTCsID: return "GetDTCs"; case ScrollableMessageID: @@ -1008,11 +1004,6 @@ const char* EnumToJsonString(FunctionID val) { }; bool EnumFromJsonString(const std::string& literal, FunctionID* result) { - if ("RESERVE" == literal) { - *result = RESERVED; - return true; - } - if ("RegisterAppInterface" == literal) { *result = RegisterAppInterfaceID; return true; @@ -1123,7 +1114,7 @@ bool EnumFromJsonString(const std::string& literal, FunctionID* result) { return true; } - if ("ReadD" == literal) { + if ("ReadDID" == literal) { *result = ReadDIDID; return true; } -- cgit v1.2.1 From ee367877d4126db27061827d1f4c8e0a9f07bc5b Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Thu, 27 Sep 2018 16:53:22 -0400 Subject: Fix uninitialized field errors CID 188297 CID 188291 Also fix request_type typo --- .../include/application_manager/request_info.h | 19 +++++++++++-------- .../application_manager/src/request_controller.cc | 4 ++-- .../application_manager/src/request_info.cc | 4 ++-- .../application_manager/test/request_info_test.cc | 8 ++++---- ...latform_specific_network_interface_listener_impl.h | 7 ++++++- 5 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/components/application_manager/include/application_manager/request_info.h b/src/components/application_manager/include/application_manager/request_info.h index 57b6986af0..da1bd0a2ee 100644 --- a/src/components/application_manager/include/application_manager/request_info.h +++ b/src/components/application_manager/include/application_manager/request_info.h @@ -60,7 +60,7 @@ struct RequestInfo { RequestInfo() : timeout_msec_(0) , app_id_(0) - , requst_type_(RequestNone) + , request_type_(RequestNone) , correlation_id_(0) { start_time_ = date_time::getCurrentTime(); updateEndTime(); @@ -68,16 +68,19 @@ struct RequestInfo { virtual ~RequestInfo() {} RequestInfo(RequestPtr request, - const RequestType requst_type, + const RequestType request_type, const uint64_t timeout_msec) - : request_(request), timeout_msec_(timeout_msec), correlation_id_(0) { + : request_(request) + , timeout_msec_(timeout_msec) + , app_id_(0) + , correlation_id_(0) { start_time_ = date_time::getCurrentTime(); updateEndTime(); - requst_type_ = requst_type; + request_type_ = request_type; } RequestInfo(RequestPtr request, - const RequestType requst_type, + const RequestType request_type, const date_time::TimeDuration& start_time, const uint64_t timeout_msec); @@ -111,8 +114,8 @@ struct RequestInfo { return app_id_; } - RequestType requst_type() const { - return requst_type_; + RequestType request_type() const { + return request_type_; } uint32_t requestId() { @@ -132,7 +135,7 @@ struct RequestInfo { uint64_t timeout_msec_; date_time::TimeDuration end_time_; uint32_t app_id_; - RequestType requst_type_; + RequestType request_type_; uint32_t correlation_id_; }; diff --git a/src/components/application_manager/src/request_controller.cc b/src/components/application_manager/src/request_controller.cc index 28c773ffcb..315cf6fdf8 100644 --- a/src/components/application_manager/src/request_controller.cc +++ b/src/components/application_manager/src/request_controller.cc @@ -401,7 +401,7 @@ void RequestController::TimeoutThread() { LOG4CXX_DEBUG(logger_, "Timeout for " << (RequestInfo::HMIRequest == - probably_expired->requst_type() + probably_expired->request_type() ? "HMI" : "Mobile") << " request id: " << probably_expired->requestId() @@ -420,7 +420,7 @@ void RequestController::TimeoutThread() { LOG4CXX_INFO(logger_, "Timeout for " << (RequestInfo::HMIRequest == - probably_expired->requst_type() + probably_expired->request_type() ? "HMI" : "Mobile") << " request id: " << probably_expired->requestId() diff --git a/src/components/application_manager/src/request_info.cc b/src/components/application_manager/src/request_info.cc index 45e56c5f9e..cd99a42508 100644 --- a/src/components/application_manager/src/request_info.cc +++ b/src/components/application_manager/src/request_info.cc @@ -74,12 +74,12 @@ MobileRequestInfo::MobileRequestInfo(RequestPtr request, } RequestInfo::RequestInfo(RequestPtr request, - const RequestInfo::RequestType requst_type, + const RequestInfo::RequestType request_type, const date_time::TimeDuration& start_time, const uint64_t timeout_msec) : request_(request), start_time_(start_time), timeout_msec_(timeout_msec) { updateEndTime(); - requst_type_ = requst_type; + request_type_ = request_type; correlation_id_ = request_->correlation_id(); app_id_ = request_->connection_key(); } diff --git a/src/components/application_manager/test/request_info_test.cc b/src/components/application_manager/test/request_info_test.cc index 0d7e6c65ac..0abef44e9a 100644 --- a/src/components/application_manager/test/request_info_test.cc +++ b/src/components/application_manager/test/request_info_test.cc @@ -46,10 +46,10 @@ namespace application_manager_test { class TestRequestInfo : public request_info::RequestInfo { public: TestRequestInfo(request_info::RequestPtr request, - const RequestType requst_type, + const RequestType request_type, const date_time::TimeDuration& start_time, const uint64_t timeout_msec) - : RequestInfo(request, requst_type, start_time, timeout_msec) {} + : RequestInfo(request, request_type, start_time, timeout_msec) {} void SetEndTime(const date_time::TimeDuration& end_time) { end_time_ = end_time; } @@ -77,14 +77,14 @@ class RequestInfoTest : public ::testing::Test { std::shared_ptr CreateTestInfo( uint32_t connection_key, uint32_t correlation_id, - request_info::RequestInfo::RequestType requst_type, + request_info::RequestInfo::RequestType request_type, const date_time::TimeDuration& start_time, uint64_t timeout_msec) { std::shared_ptr mock_request = std::make_shared(connection_key, correlation_id); std::shared_ptr request = std::make_shared( - mock_request, requst_type, start_time, timeout_msec); + mock_request, request_type, start_time, timeout_msec); return request; } }; diff --git a/src/components/transport_manager/include/transport_manager/tcp/platform_specific/linux/platform_specific_network_interface_listener_impl.h b/src/components/transport_manager/include/transport_manager/tcp/platform_specific/linux/platform_specific_network_interface_listener_impl.h index a7338b94be..fd90cb0f22 100644 --- a/src/components/transport_manager/include/transport_manager/tcp/platform_specific/linux/platform_specific_network_interface_listener_impl.h +++ b/src/components/transport_manager/include/transport_manager/tcp/platform_specific/linux/platform_specific_network_interface_listener_impl.h @@ -22,7 +22,12 @@ class TcpClientListener; */ class InterfaceStatus { public: - InterfaceStatus() : flags_(0), has_ipv4_(false), has_ipv6_(false) {} + InterfaceStatus() + : flags_(0) + , has_ipv4_(false) + , has_ipv6_(false) + , ipv4_address_() + , ipv6_address_() {} ~InterfaceStatus() {} bool IsAvailable() const; -- cgit v1.2.1 From 9c8c2487f7b24dc6c8305329b8a420cf5db99e73 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Thu, 27 Sep 2018 16:54:03 -0400 Subject: Fix missing return value CID 80021 --- tools/intergen/model/src/model/composite_type.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/intergen/model/src/model/composite_type.cc b/tools/intergen/model/src/model/composite_type.cc index 57e89cce54..d4b0687c5a 100644 --- a/tools/intergen/model/src/model/composite_type.cc +++ b/tools/intergen/model/src/model/composite_type.cc @@ -332,6 +332,7 @@ bool NullableType::operator<(const NullableType& that) const { if (type_ != that.type_) { return type_ < that.type_; } + return false; } TypeCodeGenerator* NullableType::Apply( -- cgit v1.2.1 From 35defc42777c57412cbf8b793489ab0dac502f4e Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Thu, 27 Sep 2018 16:55:13 -0400 Subject: Add missing resource close in LoadPlugin CID 188273 --- .../application_manager/src/plugin_manager/rpc_plugin_manager_impl.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/application_manager/src/plugin_manager/rpc_plugin_manager_impl.cc b/src/components/application_manager/src/plugin_manager/rpc_plugin_manager_impl.cc index bbd0011298..712b91afe7 100644 --- a/src/components/application_manager/src/plugin_manager/rpc_plugin_manager_impl.cc +++ b/src/components/application_manager/src/plugin_manager/rpc_plugin_manager_impl.cc @@ -54,6 +54,7 @@ RPCPluginPtr LoadPlugin(const std::string& full_plugin_path) { return RPCPluginPtr(); } RPCPlugin* plugin = create_plugin(); + dlclose(plugin_dll); return RPCPluginPtr(plugin); } -- cgit v1.2.1 From 0c32601453970fa16798d3d917b360c0a8ac3c02 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Fri, 28 Sep 2018 09:44:01 -0400 Subject: Fix uninitialized members CIDs 188281, 188276, 188250, 188245, 188239 --- .../rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc | 1 + .../commands/mobile/create_interaction_choice_set_request.h | 2 +- .../src/commands/mobile/create_interaction_choice_set_request.cc | 7 ++++--- .../src/system_time/system_time_handler_impl.cc | 1 + src/components/include/security_manager/ssl_context.h | 3 ++- .../linux/platform_specific_network_interface_listener_impl.h | 2 +- 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc index 40249387a7..c24529d720 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc @@ -52,6 +52,7 @@ RCCommandRequest::RCCommandRequest( params.hmi_capabilities_, params.policy_handler_) , is_subscribed(false) + , auto_allowed_(false) , resource_allocation_manager_(params.resource_allocation_manager_) , interior_data_cache_(params.interior_data_cache_) , interior_data_manager_(params.interior_data_manager_) {} diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h index 4564858845..1ad1c07b2a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h @@ -128,7 +128,7 @@ class CreateInteractionChoiceSetRequest int32_t choice_set_id_; size_t expected_chs_count_; size_t received_chs_count_; - bool should_send_warnings; + bool should_send_warnings_; /** * @brief Flag for stop sending VR commands to HMI, in case one of responses diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc index cd1f95b93c..416f4f2085 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc @@ -63,6 +63,7 @@ CreateInteractionChoiceSetRequest::CreateInteractionChoiceSetRequest( , choice_set_id_(0) , expected_chs_count_(0) , received_chs_count_(0) + , should_send_warnings_(false) , error_from_hmi_(false) , is_timed_out_(false) {} @@ -80,7 +81,7 @@ void CreateInteractionChoiceSetRequest::Run() { SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); return; } - should_send_warnings = false; + for (uint32_t i = 0; i < (*message_)[strings::msg_params][strings::choice_set].length(); ++i) { @@ -109,7 +110,7 @@ void CreateInteractionChoiceSetRequest::Run() { return; } else if (verification_result_image == Result::WARNINGS || verification_result_secondary_image == Result::WARNINGS) { - should_send_warnings = true; + should_send_warnings_ = true; break; } } @@ -465,7 +466,7 @@ void CreateInteractionChoiceSetRequest::DeleteChoices() { void CreateInteractionChoiceSetRequest::OnAllHMIResponsesReceived() { LOG4CXX_AUTO_TRACE(logger_); - if (!error_from_hmi_ && should_send_warnings) { + if (!error_from_hmi_ && should_send_warnings_) { SendResponse(true, mobile_apis::Result::WARNINGS, kInvalidImageWarningInfo); } else if (!error_from_hmi_) { SendResponse(true, mobile_apis::Result::SUCCESS); diff --git a/src/components/application_manager/src/system_time/system_time_handler_impl.cc b/src/components/application_manager/src/system_time/system_time_handler_impl.cc index 6ae6d3e901..27f0972c01 100644 --- a/src/components/application_manager/src/system_time/system_time_handler_impl.cc +++ b/src/components/application_manager/src/system_time/system_time_handler_impl.cc @@ -46,6 +46,7 @@ SystemTimeHandlerImpl::SystemTimeHandlerImpl( : event_engine::EventObserver(application_manager.event_dispatcher()) , utc_time_can_be_received_(false) , awaiting_get_system_time_(false) + , last_time_(0) , system_time_listener_(NULL) , app_manager_(application_manager) { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/include/security_manager/ssl_context.h b/src/components/include/security_manager/ssl_context.h index 9d66e1af2f..7d52c72abe 100644 --- a/src/components/include/security_manager/ssl_context.h +++ b/src/components/include/security_manager/ssl_context.h @@ -77,7 +77,8 @@ class SSLContext { }; struct HandshakeContext { - HandshakeContext() : expected_sn(""), expected_cn("") {} + HandshakeContext() + : expected_sn(""), expected_cn(""), system_time(time(NULL)) {} HandshakeContext(const custom_str::CustomString& exp_sn, const custom_str::CustomString& exp_cn) diff --git a/src/components/transport_manager/include/transport_manager/tcp/platform_specific/linux/platform_specific_network_interface_listener_impl.h b/src/components/transport_manager/include/transport_manager/tcp/platform_specific/linux/platform_specific_network_interface_listener_impl.h index fd90cb0f22..bb60b09a9d 100644 --- a/src/components/transport_manager/include/transport_manager/tcp/platform_specific/linux/platform_specific_network_interface_listener_impl.h +++ b/src/components/transport_manager/include/transport_manager/tcp/platform_specific/linux/platform_specific_network_interface_listener_impl.h @@ -137,7 +137,7 @@ class PlatformSpecificNetworkInterfaceListener struct sockaddr_storage address; EventParam(int interface_index, unsigned int interface_flags = 0) - : if_index(interface_index), flags(interface_flags) {} + : if_index(interface_index), flags(interface_flags), address() {} }; // parent class which we will notify the events to -- cgit v1.2.1 From b0f6c448a88daae21925d6f27fd9ec0708a5ca71 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Fri, 28 Sep 2018 11:51:26 -0400 Subject: Apply changes to default group on PTU to existing PT --- .../policy/policy_external/src/cache_manager.cc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc index e4a4151fa4..c2c2e91257 100644 --- a/src/components/policy/policy_external/src/cache_manager.cc +++ b/src/components/policy/policy_external/src/cache_manager.cc @@ -207,6 +207,21 @@ struct ExternalConsentConsentGroupAppender } }; +struct DefaultPolicyUpdater { + DefaultPolicyUpdater(const policy_table::ApplicationParams& default_params) + : default_params_(default_params) {} + + void operator()(policy_table::ApplicationPolicies::value_type& pt_value) { + if (policy::kDefaultId == pt_value.second.get_string()) { + pt_value.second = default_params_; + pt_value.second.set_to_string(policy::kDefaultId); + } + } + + private: + const policy_table::ApplicationParams& default_params_; +}; + } // namespace namespace policy { @@ -681,6 +696,13 @@ void CacheManager::ProcessUpdate( initial_policy_iter->second; *(pt_->policy_table.app_policies_section.apps[app_id].RequestType) = merged_pt_request_types; + + if (app_id == kDefaultId) { + std::for_each(pt_->policy_table.app_policies_section.apps.begin(), + pt_->policy_table.app_policies_section.apps.end(), + DefaultPolicyUpdater( + pt_->policy_table.app_policies_section.apps[app_id])); + } } bool CacheManager::ApplyUpdate(const policy_table::Table& update_pt) { -- cgit v1.2.1 From 6abbfaf52d3e1014bad7a7ff9233afb97452230c Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Sun, 30 Sep 2018 19:53:58 -0700 Subject: Fix 188233 Unitialized scalar field --- src/components/smart_objects/src/object_schema_item.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/smart_objects/src/object_schema_item.cc b/src/components/smart_objects/src/object_schema_item.cc index e0324d841e..6964d169ce 100644 --- a/src/components/smart_objects/src/object_schema_item.cc +++ b/src/components/smart_objects/src/object_schema_item.cc @@ -45,7 +45,8 @@ namespace ns_smart_device_link { namespace ns_smart_objects { CObjectSchemaItem::SMember::SMember() - : mSchemaItem(CAlwaysFalseSchemaItem::create()), mIsMandatory(true) {} + : mSchemaItem(CAlwaysFalseSchemaItem::create()), mIsMandatory(true), + mIsDeprecated(false), mIsRemoved(false) {} CObjectSchemaItem::SMember::SMember( const ISchemaItemPtr SchemaItem, -- cgit v1.2.1 From 1155a0eb7d725f56b153b80ff5feee0c8b44f920 Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Sun, 30 Sep 2018 20:44:30 -0700 Subject: Fix 188234 Uncaught Exception --- .../utils/src/conditional_variable_boost.cc | 53 ++++++++++++---------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/src/components/utils/src/conditional_variable_boost.cc b/src/components/utils/src/conditional_variable_boost.cc index c07b8284ea..1e5c9b6998 100644 --- a/src/components/utils/src/conditional_variable_boost.cc +++ b/src/components/utils/src/conditional_variable_boost.cc @@ -92,32 +92,37 @@ ConditionalVariable::WaitStatus ConditionalVariable::WaitFor( BaseLock& lock = auto_lock.GetLock(); WaitStatus wait_status = kNoTimeout; - lock.AssertTakenAndMarkFree(); - bool timeout = true; - - // What kind of lock are we ? - if (Lock* test_lock = dynamic_cast(&lock)) { - // Regular lock - // cond_var_.wait(test_lock->mutex_); - timeout = cond_var_.timed_wait( - test_lock->mutex_, boost::posix_time::milliseconds(milliseconds)); - } else if (RecursiveLock* test_rec_lock = - dynamic_cast(&lock)) { - // Recursive lock - // cond_var_.wait(test_rec_lock->mutex_); - timeout = cond_var_.timed_wait( - test_rec_lock->mutex_, boost::posix_time::milliseconds(milliseconds)); - } else { - // this is an unknown lock, we have an issue - LOG4CXX_ERROR(logger_, "Unknown lock type!"); - NOTREACHED(); + try{ + lock.AssertTakenAndMarkFree(); + bool timeout = true; + + // What kind of lock are we ? + if (Lock* test_lock = dynamic_cast(&lock)) { + // Regular lock + // cond_var_.wait(test_lock->mutex_); + timeout = cond_var_.timed_wait( + test_lock->mutex_, boost::posix_time::milliseconds(milliseconds)); + } else if (RecursiveLock* test_rec_lock = + dynamic_cast(&lock)) { + // Recursive lock + // cond_var_.wait(test_rec_lock->mutex_); + timeout = cond_var_.timed_wait( + test_rec_lock->mutex_, boost::posix_time::milliseconds(milliseconds)); + } else { + // this is an unknown lock, we have an issue + LOG4CXX_ERROR(logger_, "Unknown lock type!"); + NOTREACHED(); + } + + if (!timeout) { + wait_status = kTimeout; + } + lock.AssertFreeAndMarkTaken(); + } catch (const boost::exception& error) { + std::string error_string = boost::diagnostic_information(error); + LOG4CXX_FATAL(logger_, error_string); } - if (!timeout) { - wait_status = kTimeout; - } - lock.AssertFreeAndMarkTaken(); - return wait_status; } -- cgit v1.2.1 From b65342cfb789785d25bf816f3f986a8f8204195c Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Sun, 30 Sep 2018 20:50:27 -0700 Subject: Fix 148714 Structurally Dead Code --- src/components/telemetry_monitor/src/metric_wrapper.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/telemetry_monitor/src/metric_wrapper.cc b/src/components/telemetry_monitor/src/metric_wrapper.cc index 937a705ef7..10b694c5e6 100644 --- a/src/components/telemetry_monitor/src/metric_wrapper.cc +++ b/src/components/telemetry_monitor/src/metric_wrapper.cc @@ -45,7 +45,6 @@ bool MetricWrapper::grabResources() { } else { return false; } - flush(std::cout); } std::string MetricWrapper::GetStyledString() { -- cgit v1.2.1 From 5ad64f61802ab945c320713779e3d6328d92f95b Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Sun, 30 Sep 2018 21:11:51 -0700 Subject: Fix 188234 Uncaught Exception --- src/components/utils/src/conditional_variable_boost.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/utils/src/conditional_variable_boost.cc b/src/components/utils/src/conditional_variable_boost.cc index 1e5c9b6998..b5046ef83e 100644 --- a/src/components/utils/src/conditional_variable_boost.cc +++ b/src/components/utils/src/conditional_variable_boost.cc @@ -36,6 +36,7 @@ #include "utils/lock.h" #include "utils/logger.h" +#include namespace { const long kNanosecondsPerSecond = 1000000000; -- cgit v1.2.1 From 6182ca86dae52ab93fb9c4a82a4c1b1d7ef89336 Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Sun, 30 Sep 2018 21:14:22 -0700 Subject: Fix 148706 Unitialized pointer field --- src/components/policy/policy_regular/src/cache_manager.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index 9accabf59b..7532d5cd37 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -103,6 +103,7 @@ CacheManager::CacheManager() : CacheManagerInterface() , pt_(new policy_table::Table) , backup_(new SQLPTRepresentation()) + , settings_(nullptr) , update_required(false) { LOG4CXX_AUTO_TRACE(logger_); backuper_ = new BackgroundBackuper(this); -- cgit v1.2.1 From 6912633eda53949395f8825dc0abdb2d03a2dbdf Mon Sep 17 00:00:00 2001 From: JackLivio Date: Mon, 1 Oct 2018 11:34:31 -0400 Subject: Allows User Consent for Default Functional Groups --- .../policy_external/include/policy/policy_helper.h | 15 +++++++++- .../policy/policy_external/src/policy_helper.cc | 34 ++++++++++++++-------- .../policy_external/src/policy_manager_impl.cc | 11 ++----- 3 files changed, 38 insertions(+), 22 deletions(-) diff --git a/src/components/policy/policy_external/include/policy/policy_helper.h b/src/components/policy/policy_external/include/policy/policy_helper.h index 6f916b7cd0..e3cb509c15 100644 --- a/src/components/policy/policy_external/include/policy/policy_helper.h +++ b/src/components/policy/policy_external/include/policy/policy_helper.h @@ -100,7 +100,8 @@ struct CheckAppPolicy { * @param result Result of check of updated policy */ void SetPendingPermissions(const AppPoliciesValueType& app_policy, - PermissionsCheckResult result) const; + PermissionsCheckResult result, + AppPermissions& permissions_diff) const; /** * @brief Analyzes updated application policy whether any changes received. If * yes - provides appropriate result code @@ -200,6 +201,18 @@ struct CheckAppPolicy { */ bool IsRequestSubTypeChanged(const AppPoliciesValueType& app_policy) const; + /** + * @brief Helper function that inserts permissions into app_permissions_diff_ + * map. + * udpated + * @param app_policy Reference to updated application policy + * @param permissions_diff Reference to app permissions to be inserted into + * map. + * @return void + */ + void InsertPermission(const std::string& app_id, + const AppPermissions& permissions_diff); + private: PolicyManagerImpl* pm_; const std::shared_ptr update_; diff --git a/src/components/policy/policy_external/src/policy_helper.cc b/src/components/policy/policy_external/src/policy_helper.cc index 2358c54bef..3beeabce1e 100644 --- a/src/components/policy/policy_external/src/policy_helper.cc +++ b/src/components/policy/policy_external/src/policy_helper.cc @@ -299,9 +299,16 @@ void CheckAppPolicy::AddResult(const std::string& app_id, out_results_.insert(std::make_pair(app_id, result)); } +void CheckAppPolicy::InsertPermission(const std::string& app_id, + const AppPermissions& permissions_diff) { + pm_->app_permissions_diff_lock_.Acquire(); + pm_->app_permissions_diff_.insert(std::make_pair(app_id, permissions_diff)); + pm_->app_permissions_diff_lock_.Release(); +} + bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) { const std::string app_id = app_policy.first; - + AppPermissions permissions_diff(app_id); if (!IsKnownAppication(app_id)) { LOG4CXX_WARN(logger_, "Application:" << app_id << " is not present in snapshot."); @@ -309,14 +316,17 @@ bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) { } if (!IsPredefinedApp(app_policy) && IsAppRevoked(app_policy)) { - SetPendingPermissions(app_policy, RESULT_APP_REVOKED); + SetPendingPermissions(app_policy, RESULT_APP_REVOKED, permissions_diff); AddResult(app_id, RESULT_APP_REVOKED); + InsertPermission(app_id, permissions_diff); return true; } if (!IsPredefinedApp(app_policy) && !NicknamesMatch(app_policy)) { - SetPendingPermissions(app_policy, RESULT_NICKNAME_MISMATCH); + SetPendingPermissions( + app_policy, RESULT_NICKNAME_MISMATCH, permissions_diff); AddResult(app_id, RESULT_NICKNAME_MISMATCH); + InsertPermission(app_id, permissions_diff); return true; } @@ -328,13 +338,15 @@ bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) { if (is_request_type_changed) { LOG4CXX_TRACE(logger_, "Request types were changed for application: " << app_id); - SetPendingPermissions(app_policy, RESULT_REQUEST_TYPE_CHANGED); + SetPendingPermissions( + app_policy, RESULT_REQUEST_TYPE_CHANGED, permissions_diff); AddResult(app_id, RESULT_REQUEST_TYPE_CHANGED); } if (is_request_subtype_changed) { LOG4CXX_TRACE( logger_, "Request subtypes were changed for application: " << app_id); - SetPendingPermissions(app_policy, RESULT_REQUEST_SUBTYPE_CHANGED); + SetPendingPermissions( + app_policy, RESULT_REQUEST_SUBTYPE_CHANGED, permissions_diff); AddResult(app_id, RESULT_REQUEST_SUBTYPE_CHANGED); } } @@ -344,6 +356,7 @@ bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) { "Permissions for application:" << app_id << " wasn't changed."); AddResult(app_id, result); + InsertPermission(app_id, permissions_diff); return true; } @@ -352,19 +365,20 @@ bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) { << " have been changed."); if (!IsPredefinedApp(app_policy)) { - SetPendingPermissions(app_policy, result); + SetPendingPermissions(app_policy, result, permissions_diff); AddResult(app_id, result); } + InsertPermission(app_id, permissions_diff); return true; } void policy::CheckAppPolicy::SetPendingPermissions( const AppPoliciesValueType& app_policy, - PermissionsCheckResult result) const { + PermissionsCheckResult result, + AppPermissions& permissions_diff) const { using namespace rpc::policy_table_interface_base; const std::string app_id = app_policy.first; - AppPermissions permissions_diff(app_id); const std::string priority = policy_table::EnumToJsonString(app_policy.second.priority); @@ -421,10 +435,6 @@ void policy::CheckAppPolicy::SetPendingPermissions( if (need_send_priority) { permissions_diff.priority = priority; } - - pm_->app_permissions_diff_lock_.Acquire(); - pm_->app_permissions_diff_.insert(std::make_pair(app_id, permissions_diff)); - pm_->app_permissions_diff_lock_.Release(); } PermissionsCheckResult CheckAppPolicy::CheckPermissionsChanges( 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 e93eea3969..d624f7edc8 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -1261,15 +1261,8 @@ void PolicyManagerImpl::GetUserConsentForApp( FunctionalGroupIDs allowed_groups = Merge(consent_allowed_groups, preconsented_wo_disallowed_auto); - FunctionalGroupIDs merged_stage_1 = - Merge(default_groups, predataconsented_groups); - - FunctionalGroupIDs merged_stage_2 = Merge(merged_stage_1, device_groups); - - FunctionalGroupIDs merged_stage_3 = - Merge(merged_stage_2, auto_allowed_groups); - - FunctionalGroupIDs excluded_stage_1 = ExcludeSame(all_groups, merged_stage_3); + FunctionalGroupIDs excluded_stage_1 = + ExcludeSame(all_groups, auto_allowed_groups); FunctionalGroupIDs excluded_stage_2 = ExcludeSame(excluded_stage_1, consent_disallowed_groups); -- cgit v1.2.1 From 7eef7eda81975c3988a8120e0d0bb067dfef8f6f Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Mon, 1 Oct 2018 10:00:10 -0700 Subject: Style fix --- src/components/smart_objects/src/object_schema_item.cc | 6 ++++-- src/components/utils/src/conditional_variable_boost.cc | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/smart_objects/src/object_schema_item.cc b/src/components/smart_objects/src/object_schema_item.cc index 6964d169ce..742c2ec353 100644 --- a/src/components/smart_objects/src/object_schema_item.cc +++ b/src/components/smart_objects/src/object_schema_item.cc @@ -45,8 +45,10 @@ namespace ns_smart_device_link { namespace ns_smart_objects { CObjectSchemaItem::SMember::SMember() - : mSchemaItem(CAlwaysFalseSchemaItem::create()), mIsMandatory(true), - mIsDeprecated(false), mIsRemoved(false) {} + : mSchemaItem(CAlwaysFalseSchemaItem::create()) + , mIsMandatory(true) + , mIsDeprecated(false) + , mIsRemoved(false) {} CObjectSchemaItem::SMember::SMember( const ISchemaItemPtr SchemaItem, diff --git a/src/components/utils/src/conditional_variable_boost.cc b/src/components/utils/src/conditional_variable_boost.cc index b5046ef83e..91c75c6f3d 100644 --- a/src/components/utils/src/conditional_variable_boost.cc +++ b/src/components/utils/src/conditional_variable_boost.cc @@ -93,7 +93,7 @@ ConditionalVariable::WaitStatus ConditionalVariable::WaitFor( BaseLock& lock = auto_lock.GetLock(); WaitStatus wait_status = kNoTimeout; - try{ + try { lock.AssertTakenAndMarkFree(); bool timeout = true; @@ -120,8 +120,8 @@ ConditionalVariable::WaitStatus ConditionalVariable::WaitFor( } lock.AssertFreeAndMarkTaken(); } catch (const boost::exception& error) { - std::string error_string = boost::diagnostic_information(error); - LOG4CXX_FATAL(logger_, error_string); + std::string error_string = boost::diagnostic_information(error); + LOG4CXX_FATAL(logger_, error_string); } return wait_status; -- cgit v1.2.1 From 649ae981df2606db2954fd3b95ee62d998d337ca Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Mon, 1 Oct 2018 10:24:13 -0700 Subject: 148706 replaced settings_ with get_settings --- src/components/policy/policy_regular/src/cache_manager.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index 7532d5cd37..52fc810c98 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -827,7 +827,7 @@ void CacheManager::CheckSnapshotInitialization() { *(snapshot_->policy_table.module_config.preloaded_pt) = false; *(snapshot_->policy_table.module_config.full_app_id_supported) = - settings_->use_full_app_id(); + get_settings()->use_full_app_id(); // SDL must not send certificate in snapshot snapshot_->policy_table.module_config.certificate = -- cgit v1.2.1 From 060d3c4d95fe1439ce4ce57b34df964a786c0df4 Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Tue, 2 Oct 2018 06:09:44 -0700 Subject: Reordered initialization --- src/components/policy/policy_regular/src/cache_manager.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index 52fc810c98..226a2e4332 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -103,8 +103,8 @@ CacheManager::CacheManager() : CacheManagerInterface() , pt_(new policy_table::Table) , backup_(new SQLPTRepresentation()) - , settings_(nullptr) - , update_required(false) { + , update_required(false) + , settings_(nullptr) { LOG4CXX_AUTO_TRACE(logger_); backuper_ = new BackgroundBackuper(this); backup_thread_ = threads::CreateThread("Backup thread", backuper_); @@ -827,7 +827,7 @@ void CacheManager::CheckSnapshotInitialization() { *(snapshot_->policy_table.module_config.preloaded_pt) = false; *(snapshot_->policy_table.module_config.full_app_id_supported) = - get_settings()->use_full_app_id(); + get_settings().use_full_app_id(); // SDL must not send certificate in snapshot snapshot_->policy_table.module_config.certificate = -- cgit v1.2.1 From a9ef1f64d6c756706d6b6089215fe4c216f37b21 Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Tue, 2 Oct 2018 07:01:44 -0700 Subject: Handled uncaught exception in Wait function --- .../utils/src/conditional_variable_boost.cc | 35 ++++++++++++---------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/components/utils/src/conditional_variable_boost.cc b/src/components/utils/src/conditional_variable_boost.cc index 91c75c6f3d..a74aa3eaa6 100644 --- a/src/components/utils/src/conditional_variable_boost.cc +++ b/src/components/utils/src/conditional_variable_boost.cc @@ -63,23 +63,27 @@ void ConditionalVariable::Broadcast() { bool ConditionalVariable::Wait(BaseLock& lock) { // NOTE this grossness is due to boost mutex and recursive mutex not sharing a // superclass - - lock.AssertTakenAndMarkFree(); - // What kind of lock are we ? - if (Lock* test_lock = dynamic_cast(&lock)) { - // Regular lock - cond_var_.wait(test_lock->mutex_); - } else if (RecursiveLock* test_rec_lock = - dynamic_cast(&lock)) { - // Recursive lock - cond_var_.wait(test_rec_lock->mutex_); - } else { - // unknown, give up the lock - LOG4CXX_ERROR(logger_, "Unknown lock type!"); + try { + lock.AssertTakenAndMarkFree(); + // What kind of lock are we ? + if (Lock* test_lock = dynamic_cast(&lock)) { + // Regular lock + cond_var_.wait(test_lock->mutex_); + } else if (RecursiveLock* test_rec_lock = + dynamic_cast(&lock)) { + // Recursive lock + cond_var_.wait(test_rec_lock->mutex_); + } else { + // unknown, give up the lock + LOG4CXX_ERROR(logger_, "Unknown lock type!"); + NOTREACHED(); + } + lock.AssertFreeAndMarkTaken(); + } catch (const boost::exception& error) { + std::string error_string = boost::diagnostic_information(error); + LOG4CXX_FATAL(logger_, error_string); NOTREACHED(); } - lock.AssertFreeAndMarkTaken(); - return true; } @@ -122,6 +126,7 @@ ConditionalVariable::WaitStatus ConditionalVariable::WaitFor( } catch (const boost::exception& error) { std::string error_string = boost::diagnostic_information(error); LOG4CXX_FATAL(logger_, error_string); + NOTREACHED(); } return wait_status; -- cgit v1.2.1 From b77a003833a8d917cd51578d397e6965fd7e1258 Mon Sep 17 00:00:00 2001 From: "Andriy Byzhynar (GitHub)" Date: Tue, 2 Oct 2018 18:14:50 +0300 Subject: Fix/sdl_does_not_send SDL.OnStatusUpdate(UPDATE_NEEDED) (#2494) * Add missed RequestSubTypes gathering Added missed request subtypes gathering during app policies section collecting * Fix sending SDL.OnStatusUpdate if existed app registered Added logic of handling case when existed app registered but PTU was unsuccessful from previous IGN cycle NOTE: Fix for EXTERNAL_PROPRIETARY flow * Fix sending SDL.OnStatusUpdate when existed app registered Added logic of handling case when existed app registered but PTU was unsuccessful from previous IGN cycle NOTE: Fix for PROPRIETARY flow * Update update status manager mock classes Updated MockUpdateStatusManager classes for both policy flows: EXTERNAL_PROPRIETARY and PROPRIETARY --- .../application_manager/src/message_helper/message_helper.cc | 2 ++ .../policy_external/include/policy/update_status_manager.h | 6 ++++++ .../policy/policy_external/src/policy_manager_impl.cc | 9 +++++---- .../policy/policy_external/src/sql_pt_ext_representation.cc | 3 +++ .../policy/policy_external/src/update_status_manager.cc | 11 +++++++++++ .../test/include/policy/mock_update_status_manager.h | 2 +- .../policy_regular/include/policy/update_status_manager.h | 6 ++++++ .../include/policy/update_status_manager_interface.h | 6 ++++++ src/components/policy/policy_regular/src/cache_manager.cc | 5 ++++- .../policy/policy_regular/src/policy_manager_impl.cc | 8 ++++---- .../policy/policy_regular/src/update_status_manager.cc | 9 +++++++++ .../test/include/policy/mock_update_status_manager.h | 1 + 12 files changed, 58 insertions(+), 10 deletions(-) diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index a52cb52fbe..e99db3bece 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -2521,6 +2521,7 @@ void MessageHelper::SendUpdateSDLResponse(const std::string& result, void MessageHelper::SendOnStatusUpdate(const std::string& status, ApplicationManager& app_mngr) { + LOG4CXX_AUTO_TRACE(logger_); smart_objects::SmartObjectSPtr message = std::make_shared( smart_objects::SmartType_Map); @@ -2533,6 +2534,7 @@ void MessageHelper::SendOnStatusUpdate(const std::string& status, (*message)[strings::params][strings::message_type] = MessageType::kNotification; + LOG4CXX_DEBUG(logger_, "Sending new status:" << status); (*message)[strings::msg_params]["status"] = status; app_mngr.GetRPCService().ManageHMICommand(message); diff --git a/src/components/policy/policy_external/include/policy/update_status_manager.h b/src/components/policy/policy_external/include/policy/update_status_manager.h index b4a373d1cf..29adeec084 100644 --- a/src/components/policy/policy_external/include/policy/update_status_manager.h +++ b/src/components/policy/policy_external/include/policy/update_status_manager.h @@ -113,6 +113,12 @@ class UpdateStatusManager { */ void OnResetRetrySequence(); + /** + * @brief Update status handler on existed application registering + * @param is_update_required Update necessity flag + */ + void OnExistedApplicationAdded(const bool is_update_required); + /** * @brief Update status handler on new application registering */ 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 e93eea3969..95304f45a6 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -1922,13 +1922,15 @@ StatusNotifier PolicyManagerImpl::AddApplication( DeviceConsent device_consent = GetUserConsentForDevice(device_id); sync_primitives::AutoLock lock(apps_registration_lock_); if (IsNewApplication(application_id)) { + LOG4CXX_DEBUG(logger_, "Adding new application"); AddNewApplication(application_id, device_consent); return std::make_shared(update_status_manager_, device_consent); - } else { - PromoteExistedApplication(application_id, device_consent); - return std::make_shared(); } + LOG4CXX_DEBUG(logger_, "Promote existed application"); + PromoteExistedApplication(application_id, device_consent); + update_status_manager_.OnExistedApplicationAdded(cache_->UpdateRequired()); + return std::make_shared(); } void PolicyManagerImpl::RemoveAppConsentForGroup( @@ -2042,7 +2044,6 @@ bool PolicyManagerImpl::InitPT(const std::string& file_name, const bool ret = cache_->Init(file_name, settings); if (ret) { RefreshRetrySequence(); - update_status_manager_.OnPolicyInit(cache_->UpdateRequired()); } return ret; } diff --git a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc index f26264ddf9..248372beff 100644 --- a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc @@ -897,6 +897,9 @@ bool SQLPTExtRepresentation::GatherApplicationPoliciesSection( if (!GatherRequestType(app_id, &*params.RequestType)) { return false; } + if (!GatherRequestSubType(app_id, &*params.RequestSubType)) { + return false; + } GatherPreconsentedGroup(app_id, &*params.preconsented_groups); (*policies).apps[app_id] = params; } diff --git a/src/components/policy/policy_external/src/update_status_manager.cc b/src/components/policy/policy_external/src/update_status_manager.cc index e738554799..579ad8cb56 100644 --- a/src/components/policy/policy_external/src/update_status_manager.cc +++ b/src/components/policy/policy_external/src/update_status_manager.cc @@ -118,12 +118,23 @@ void UpdateStatusManager::OnResetRetrySequence() { ProcessEvent(kOnResetRetrySequence); } +void UpdateStatusManager::OnExistedApplicationAdded( + const bool is_update_required) { + LOG4CXX_AUTO_TRACE(logger_); + if (is_update_required) { + current_status_.reset(new UpToDateStatus()); + ProcessEvent(kScheduleUpdate); + } +} + void UpdateStatusManager::OnNewApplicationAdded(const DeviceConsent consent) { LOG4CXX_AUTO_TRACE(logger_); if (kDeviceAllowed != consent) { + LOG4CXX_DEBUG(logger_, "Application registered from non-consented device"); app_registered_from_non_consented_device_ = true; return; } + LOG4CXX_DEBUG(logger_, "Application registered from consented device"); app_registered_from_non_consented_device_ = false; ProcessEvent(kOnNewAppRegistered); } diff --git a/src/components/policy/policy_external/test/include/policy/mock_update_status_manager.h b/src/components/policy/policy_external/test/include/policy/mock_update_status_manager.h index a1c808d23a..104b37e379 100644 --- a/src/components/policy/policy_external/test/include/policy/mock_update_status_manager.h +++ b/src/components/policy/policy_external/test/include/policy/mock_update_status_manager.h @@ -33,7 +33,6 @@ #define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_TEST_INCLUDE_POLICY_MOCK_UPDATE_STATUS_MANAGER_H_ #include "gmock/gmock.h" - #include "policy/update_status_manager.h" namespace test { @@ -49,6 +48,7 @@ class MockUpdateStatusManager : public ::policy::UpdateStatusManager { MOCK_METHOD0(OnWrongUpdateReceived, void()); MOCK_METHOD1(OnResetDefaultPT, void(bool is_update_required)); MOCK_METHOD0(OnResetRetrySequence, void()); + MOCK_METHOD1(OnExistedApplicationAdded, void(const bool is_update_required)); MOCK_METHOD1(OnNewApplicationAdded, void(const DeviceConsent)); MOCK_METHOD1(OnPolicyInit, void(bool is_update_required)); MOCK_METHOD0(GetUpdateStatus, PolicyTableStatus()); diff --git a/src/components/policy/policy_regular/include/policy/update_status_manager.h b/src/components/policy/policy_regular/include/policy/update_status_manager.h index 52d5b92b8a..5cd20e57e3 100644 --- a/src/components/policy/policy_regular/include/policy/update_status_manager.h +++ b/src/components/policy/policy_regular/include/policy/update_status_manager.h @@ -117,6 +117,12 @@ class UpdateStatusManager : public UpdateStatusManagerInterface { */ void OnNewApplicationAdded(const DeviceConsent consent); + /** + * @brief Update status handler on existed application registering + * @param is_update_required Update necessity flag + */ + void OnExistedApplicationAdded(const bool is_update_required); + /** * @brief Update status handler for policy initialization * @param is_update_required Update necessity flag diff --git a/src/components/policy/policy_regular/include/policy/update_status_manager_interface.h b/src/components/policy/policy_regular/include/policy/update_status_manager_interface.h index b9da90f929..b4999b569c 100644 --- a/src/components/policy/policy_regular/include/policy/update_status_manager_interface.h +++ b/src/components/policy/policy_regular/include/policy/update_status_manager_interface.h @@ -104,6 +104,12 @@ class UpdateStatusManagerInterface { */ virtual void OnNewApplicationAdded(DeviceConsent device_consent) = 0; + /** + * @brief Update status handler on existed application registering + * @param is_update_required Update necessity flag + */ + virtual void OnExistedApplicationAdded(const bool is_update_required) = 0; + /** * @brief Update status handler for policy initialization * @param is_update_required Update necessity flag diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index 9accabf59b..2f47853a2d 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -1453,10 +1453,13 @@ bool CacheManager::Init(const std::string& file_name, void CacheManager::FillDeviceSpecificData() {} bool CacheManager::LoadFromBackup() { + LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock lock(cache_lock_); pt_ = backup_->GenerateSnapshot(); update_required = backup_->UpdateRequired(); - + LOG4CXX_DEBUG(logger_, + "Update required flag from backup: " << std::boolalpha + << update_required); FillDeviceSpecificData(); return true; 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 084ddd2701..4985035629 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -1211,10 +1211,10 @@ StatusNotifier PolicyManagerImpl::AddApplication( AddNewApplication(application_id, device_consent); return std::make_shared(update_status_manager_, device_consent); - } else { - PromoteExistedApplication(application_id, device_consent); - return std::make_shared(); } + PromoteExistedApplication(application_id, device_consent); + update_status_manager_.OnExistedApplicationAdded(cache_->UpdateRequired()); + return std::make_shared(); } void PolicyManagerImpl::RemoveAppConsentForGroup( @@ -1237,6 +1237,7 @@ void PolicyManagerImpl::AddNewApplication(const std::string& application_id, void PolicyManagerImpl::PromoteExistedApplication( const std::string& application_id, DeviceConsent device_consent) { + LOG4CXX_AUTO_TRACE(logger_); // If device consent changed to allowed during application being // disconnected, app permissions should be changed also if (kDeviceAllowed == device_consent && @@ -1289,7 +1290,6 @@ bool PolicyManagerImpl::InitPT(const std::string& file_name, const bool ret = cache_->Init(file_name, settings); if (ret) { RefreshRetrySequence(); - update_status_manager_.OnPolicyInit(cache_->UpdateRequired()); const std::string certificate_data = cache_->GetCertificate(); if (!certificate_data.empty()) { listener_->OnCertificateUpdated(certificate_data); diff --git a/src/components/policy/policy_regular/src/update_status_manager.cc b/src/components/policy/policy_regular/src/update_status_manager.cc index 66d21dea54..97a1573176 100644 --- a/src/components/policy/policy_regular/src/update_status_manager.cc +++ b/src/components/policy/policy_regular/src/update_status_manager.cc @@ -100,6 +100,15 @@ void UpdateStatusManager::OnResetRetrySequence() { ProcessEvent(kOnResetRetrySequence); } +void UpdateStatusManager::OnExistedApplicationAdded( + const bool is_update_required) { + LOG4CXX_AUTO_TRACE(logger_); + if (is_update_required) { + current_status_.reset(new UpToDateStatus()); + ProcessEvent(kScheduleUpdate); + } +} + void UpdateStatusManager::OnNewApplicationAdded(const DeviceConsent consent) { LOG4CXX_AUTO_TRACE(logger_); if (kDeviceAllowed != consent) { diff --git a/src/components/policy/policy_regular/test/include/policy/mock_update_status_manager.h b/src/components/policy/policy_regular/test/include/policy/mock_update_status_manager.h index 924284c8cc..8dcaabd3cb 100644 --- a/src/components/policy/policy_regular/test/include/policy/mock_update_status_manager.h +++ b/src/components/policy/policy_regular/test/include/policy/mock_update_status_manager.h @@ -47,6 +47,7 @@ class MockUpdateStatusManager : public UpdateStatusManager { MOCK_METHOD0(OnWrongUpdateReceived, void()); MOCK_METHOD1(OnResetDefaultPT, void(bool is_update_required)); MOCK_METHOD0(OnResetRetrySequence, void()); + MOCK_METHOD1(OnExistedApplicationAdded, void(const bool is_update_required)); MOCK_METHOD0(OnNewApplicationAdded, void()); MOCK_METHOD1(OnPolicyInit, void(bool is_update_required)); MOCK_METHOD0(GetUpdateStatus, PolicyTableStatus()); -- cgit v1.2.1 From df2f42ce8eb2c22671b7bd34077e95b0be62bc33 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Tue, 2 Oct 2018 14:20:14 -0400 Subject: Remove unused variables --- src/components/policy/policy_external/src/policy_manager_impl.cc | 4 ---- 1 file changed, 4 deletions(-) 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 d624f7edc8..3f4d20bb89 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -1246,10 +1246,6 @@ void PolicyManagerImpl::GetUserConsentForApp( FunctionalGroupIDs preconsented_groups = group_types[kTypePreconsented]; FunctionalGroupIDs consent_allowed_groups = group_types[kTypeAllowed]; FunctionalGroupIDs consent_disallowed_groups = group_types[kTypeDisallowed]; - FunctionalGroupIDs default_groups = group_types[kTypeDefault]; - FunctionalGroupIDs predataconsented_groups = - group_types[kTypePreDataConsented]; - FunctionalGroupIDs device_groups = group_types[kTypeDevice]; // Sorting groups by consent FunctionalGroupIDs preconsented_wo_auto = -- cgit v1.2.1 From 7ed7e819828a1957b0f4b27e4f13ff99ed81c230 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 2 Oct 2018 18:43:10 -0400 Subject: Fix issue where pending permissions were not being cleared --- .../application_manager/src/policies/policy_handler.cc | 10 +++------- src/components/policy/policy_external/src/policy_helper.cc | 5 +++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index cbc434a485..1b64c5d7b4 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -951,6 +951,7 @@ void PolicyHandler::OnVehicleDataUpdated( void PolicyHandler::OnPendingPermissionChange( const std::string& policy_app_id) { + LOG4CXX_AUTO_TRACE(logger_); LOG4CXX_DEBUG(logger_, "PolicyHandler::OnPendingPermissionChange for " << policy_app_id); @@ -989,8 +990,6 @@ void PolicyHandler::OnPendingPermissionChange( if (permissions.appPermissionsConsentNeeded) { MessageHelper::SendOnAppPermissionsChangedNotification( app->app_id(), permissions, application_manager_); - - policy_manager_->RemovePendingPermissionChanges(policy_app_id); // "Break" statement has to be here to continue processing in case of // there is another "true" flag in permissions struct break; @@ -1000,8 +999,6 @@ void PolicyHandler::OnPendingPermissionChange( if (permissions.isAppPermissionsRevoked) { MessageHelper::SendOnAppPermissionsChangedNotification( app->app_id(), permissions, application_manager_); - - policy_manager_->RemovePendingPermissionChanges(policy_app_id); } break; } @@ -1022,15 +1019,14 @@ void PolicyHandler::OnPendingPermissionChange( commands::Command::SOURCE_SDL); application_manager_.OnAppUnauthorized(app->app_id()); - - policy_manager_->RemovePendingPermissionChanges(policy_app_id); } if (permissions.requestTypeChanged || permissions.requestSubTypeChanged) { MessageHelper::SendOnAppPermissionsChangedNotification( app->app_id(), permissions, application_manager_); - policy_manager_->RemovePendingPermissionChanges(policy_app_id); } + + policy_manager_->RemovePendingPermissionChanges(policy_app_id); } bool PolicyHandler::SendMessageToSDK(const BinaryMessage& pt_string, diff --git a/src/components/policy/policy_external/src/policy_helper.cc b/src/components/policy/policy_external/src/policy_helper.cc index 3beeabce1e..4d4b62470c 100644 --- a/src/components/policy/policy_external/src/policy_helper.cc +++ b/src/components/policy/policy_external/src/policy_helper.cc @@ -302,7 +302,9 @@ void CheckAppPolicy::AddResult(const std::string& app_id, void CheckAppPolicy::InsertPermission(const std::string& app_id, const AppPermissions& permissions_diff) { pm_->app_permissions_diff_lock_.Acquire(); - pm_->app_permissions_diff_.insert(std::make_pair(app_id, permissions_diff)); + if (!pm_->app_permissions_diff_.insert(std::make_pair(app_id, permissions_diff)).second) { + LOG4CXX_ERROR(logger_, "App ID: " << app_id << " already exists in map."); + } pm_->app_permissions_diff_lock_.Release(); } @@ -356,7 +358,6 @@ bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) { "Permissions for application:" << app_id << " wasn't changed."); AddResult(app_id, result); - InsertPermission(app_id, permissions_diff); return true; } -- cgit v1.2.1 From 95db581f50f156599501a8822ac078fa75d95e62 Mon Sep 17 00:00:00 2001 From: SKobziev Date: Wed, 3 Oct 2018 17:09:55 +0300 Subject: Add_PRNDL_enum_value(UNKNOWN)_to_the_HMI_API --- src/components/interfaces/HMI_API.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index b4d4d2c850..cf2bf0e430 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -883,6 +883,8 @@ + + -- cgit v1.2.1 From 8d2f777498d744e890a2b5148c69969940ccd655 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Wed, 3 Oct 2018 10:12:53 -0400 Subject: Coverity Fixes for 5.0.0 (#2638) * Fix 188268 Non-virtual destructor * Fix 188267 Non-virtual destructor * Fix 188246 Non-virtual destructor * Fix 188236 Buffer not null terminated * Fix 188295 Uncaught exception * Fix 188234 Uncaught exception * Reverted fix 188234 * Fix Size Calculation and Style * Fix error * Fix errors * Fix typo --- .../include/application_manager/command_factory.h | 5 +++++ .../include/application_manager/plugin_manager/rpc_plugin.h | 5 +++++ .../rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache.h | 5 +++++ src/components/transport_manager/src/tcp/tcp_client_listener.cc | 7 ++++--- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/components/application_manager/include/application_manager/command_factory.h b/src/components/application_manager/include/application_manager/command_factory.h index f494fd64f8..7dc8a0cfc1 100644 --- a/src/components/application_manager/include/application_manager/command_factory.h +++ b/src/components/application_manager/include/application_manager/command_factory.h @@ -48,6 +48,11 @@ typedef std::shared_ptr CommandSharedPtr; **/ class CommandFactory { public: + /** + * @brief Class destructor + */ + virtual ~CommandFactory() {} + /** * @brief Create command object and return pointer to it * diff --git a/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin.h b/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin.h index c9a34a75d6..09a412b2ac 100644 --- a/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin.h +++ b/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin.h @@ -62,6 +62,11 @@ enum ApplicationEvent { class RPCPlugin { public: + /** + * @brief Class destructor + */ + virtual ~RPCPlugin() {} + /** * @brief Command initialization function * @param app_manager ApplicationManager diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache.h index f12566d14c..bb45247fae 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache.h @@ -42,6 +42,11 @@ namespace rc_rpc_plugin { */ class InteriorDataCache { public: + /** + * @brief Class destructor + */ + virtual ~InteriorDataCache() {} + /** * @brief Add module data to cache * @param module_type module type name diff --git a/src/components/transport_manager/src/tcp/tcp_client_listener.cc b/src/components/transport_manager/src/tcp/tcp_client_listener.cc index 82c30744e7..9f2597f0a7 100644 --- a/src/components/transport_manager/src/tcp/tcp_client_listener.cc +++ b/src/components/transport_manager/src/tcp/tcp_client_listener.cc @@ -286,9 +286,10 @@ void TcpClientListener::Loop() { } char device_name[32]; - strncpy(device_name, - inet_ntoa(client_address.sin_addr), - sizeof(device_name) / sizeof(device_name[0])); + size_t size = sizeof(device_name) / sizeof(device_name[0]); + strncpy(device_name, inet_ntoa(client_address.sin_addr), size); + + device_name[size - 1] = '\0'; LOG4CXX_INFO(logger_, "Connected client " << device_name); LOG4CXX_INFO(logger_, "Port is: " << port_); -- cgit v1.2.1 From 486610a54ae35b6cebf62b5ff4cc07f0ee9d1543 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Wed, 3 Oct 2018 10:15:40 -0400 Subject: Remove OnPolicyInit, Unused Function (#2650) --- .../include/policy/update_status_manager.h | 6 ---- .../policy_external/src/update_status_manager.cc | 8 ----- .../include/policy/mock_update_status_manager.h | 1 - .../test/update_status_manager_test.cc | 36 ---------------------- .../include/policy/update_status_manager.h | 6 ---- .../policy/update_status_manager_interface.h | 6 ---- .../policy_regular/src/update_status_manager.cc | 8 ----- .../include/policy/mock_update_status_manager.h | 1 - .../test/update_status_manager_test.cc | 14 --------- 9 files changed, 86 deletions(-) diff --git a/src/components/policy/policy_external/include/policy/update_status_manager.h b/src/components/policy/policy_external/include/policy/update_status_manager.h index 29adeec084..3a9e13b83f 100644 --- a/src/components/policy/policy_external/include/policy/update_status_manager.h +++ b/src/components/policy/policy_external/include/policy/update_status_manager.h @@ -124,12 +124,6 @@ class UpdateStatusManager { */ void OnNewApplicationAdded(const DeviceConsent consent); - /** - * @brief Update status handler for policy initialization - * @param is_update_required Update necessity flag - */ - void OnPolicyInit(bool is_update_required); - /** * @brief In case application from non-consented device has been registered * before and and no updated happened then triggers status change diff --git a/src/components/policy/policy_external/src/update_status_manager.cc b/src/components/policy/policy_external/src/update_status_manager.cc index 579ad8cb56..b352b5ea39 100644 --- a/src/components/policy/policy_external/src/update_status_manager.cc +++ b/src/components/policy/policy_external/src/update_status_manager.cc @@ -139,14 +139,6 @@ void UpdateStatusManager::OnNewApplicationAdded(const DeviceConsent consent) { ProcessEvent(kOnNewAppRegistered); } -void UpdateStatusManager::OnPolicyInit(bool is_update_required) { - LOG4CXX_AUTO_TRACE(logger_); - if (is_update_required) { - current_status_.reset(new UpToDateStatus()); - ProcessEvent(kScheduleUpdate); - } -} - void UpdateStatusManager::OnDeviceConsented() { LOG4CXX_AUTO_TRACE(logger_); if (app_registered_from_non_consented_device_) { diff --git a/src/components/policy/policy_external/test/include/policy/mock_update_status_manager.h b/src/components/policy/policy_external/test/include/policy/mock_update_status_manager.h index 104b37e379..662632fc59 100644 --- a/src/components/policy/policy_external/test/include/policy/mock_update_status_manager.h +++ b/src/components/policy/policy_external/test/include/policy/mock_update_status_manager.h @@ -50,7 +50,6 @@ class MockUpdateStatusManager : public ::policy::UpdateStatusManager { MOCK_METHOD0(OnResetRetrySequence, void()); MOCK_METHOD1(OnExistedApplicationAdded, void(const bool is_update_required)); MOCK_METHOD1(OnNewApplicationAdded, void(const DeviceConsent)); - MOCK_METHOD1(OnPolicyInit, void(bool is_update_required)); MOCK_METHOD0(GetUpdateStatus, PolicyTableStatus()); }; diff --git a/src/components/policy/policy_external/test/update_status_manager_test.cc b/src/components/policy/policy_external/test/update_status_manager_test.cc index 278c4fc43a..bf443bb201 100644 --- a/src/components/policy/policy_external/test/update_status_manager_test.cc +++ b/src/components/policy/policy_external/test/update_status_manager_test.cc @@ -286,42 +286,6 @@ TEST_F(UpdateStatusManagerTest, ScheduleUpdate_ExpectStatusUpdateNeeded) { EXPECT_TRUE(manager_->IsUpdateRequired()); } -TEST_F(UpdateStatusManagerTest, - OnPolicyInit_SetUpdateRequired_ExpectStatusUpdateNeeded) { - // Arrange - manager_->OnPolicyInit(true); - status_ = manager_->GetLastUpdateStatus(); - // Checks - EXPECT_EQ(StatusUpdateRequired, status_); - EXPECT_FALSE(manager_->IsUpdatePending()); - EXPECT_TRUE(manager_->IsUpdateRequired()); -} - -TEST_F(UpdateStatusManagerTest, - OnPolicyInit_SetUpdateNotRequired_ExpectStatusUpToDate) { - // Arrange - manager_->OnPolicyInit(false); - status_ = manager_->GetLastUpdateStatus(); - // Checks - EXPECT_EQ(StatusUpToDate, status_); - EXPECT_FALSE(manager_->IsUpdatePending()); - EXPECT_FALSE(manager_->IsUpdateRequired()); -} - -TEST_F(UpdateStatusManagerTest, - StringifiedUpdateStatus_SetStatuses_ExpectCorrectStringifiedStatuses) { - // Arrange - manager_->OnPolicyInit(false); - // Check - EXPECT_EQ("UP_TO_DATE", manager_->StringifiedUpdateStatus()); - manager_->OnPolicyInit(true); - // Check - EXPECT_EQ("UPDATE_NEEDED", manager_->StringifiedUpdateStatus()); - manager_->OnUpdateSentOut(k_timeout_); - // Check - EXPECT_EQ("UPDATING", manager_->StringifiedUpdateStatus()); -} - TEST_F(UpdateStatusManagerTest, OnAppSearchStartedCompleted_ExpectAppSearchCorrectStatus) { // Arrange diff --git a/src/components/policy/policy_regular/include/policy/update_status_manager.h b/src/components/policy/policy_regular/include/policy/update_status_manager.h index 5cd20e57e3..c90acd4957 100644 --- a/src/components/policy/policy_regular/include/policy/update_status_manager.h +++ b/src/components/policy/policy_regular/include/policy/update_status_manager.h @@ -123,12 +123,6 @@ class UpdateStatusManager : public UpdateStatusManagerInterface { */ void OnExistedApplicationAdded(const bool is_update_required); - /** - * @brief Update status handler for policy initialization - * @param is_update_required Update necessity flag - */ - void OnPolicyInit(bool is_update_required); - /** * @brief In case application from non-consented device has been registered * before and and no updated happened then triggers status change diff --git a/src/components/policy/policy_regular/include/policy/update_status_manager_interface.h b/src/components/policy/policy_regular/include/policy/update_status_manager_interface.h index b4999b569c..4763ff2eb5 100644 --- a/src/components/policy/policy_regular/include/policy/update_status_manager_interface.h +++ b/src/components/policy/policy_regular/include/policy/update_status_manager_interface.h @@ -109,12 +109,6 @@ class UpdateStatusManagerInterface { * @param is_update_required Update necessity flag */ virtual void OnExistedApplicationAdded(const bool is_update_required) = 0; - - /** - * @brief Update status handler for policy initialization - * @param is_update_required Update necessity flag - */ - virtual void OnPolicyInit(bool is_update_required) = 0; }; typedef std::shared_ptr diff --git a/src/components/policy/policy_regular/src/update_status_manager.cc b/src/components/policy/policy_regular/src/update_status_manager.cc index 97a1573176..c37f8bbadc 100644 --- a/src/components/policy/policy_regular/src/update_status_manager.cc +++ b/src/components/policy/policy_regular/src/update_status_manager.cc @@ -119,14 +119,6 @@ void UpdateStatusManager::OnNewApplicationAdded(const DeviceConsent consent) { ProcessEvent(kOnNewAppRegistered); } -void UpdateStatusManager::OnPolicyInit(bool is_update_required) { - LOG4CXX_AUTO_TRACE(logger_); - if (is_update_required) { - current_status_.reset(new UpToDateStatus()); - ProcessEvent(kScheduleUpdate); - } -} - void UpdateStatusManager::OnDeviceConsented() { LOG4CXX_AUTO_TRACE(logger_); if (app_registered_from_non_consented_device_) { diff --git a/src/components/policy/policy_regular/test/include/policy/mock_update_status_manager.h b/src/components/policy/policy_regular/test/include/policy/mock_update_status_manager.h index 8dcaabd3cb..e66d2012cb 100644 --- a/src/components/policy/policy_regular/test/include/policy/mock_update_status_manager.h +++ b/src/components/policy/policy_regular/test/include/policy/mock_update_status_manager.h @@ -49,7 +49,6 @@ class MockUpdateStatusManager : public UpdateStatusManager { MOCK_METHOD0(OnResetRetrySequence, void()); MOCK_METHOD1(OnExistedApplicationAdded, void(const bool is_update_required)); MOCK_METHOD0(OnNewApplicationAdded, void()); - MOCK_METHOD1(OnPolicyInit, void(bool is_update_required)); MOCK_METHOD0(GetUpdateStatus, PolicyTableStatus()); }; diff --git a/src/components/policy/policy_regular/test/update_status_manager_test.cc b/src/components/policy/policy_regular/test/update_status_manager_test.cc index 6f301c6720..244858554f 100644 --- a/src/components/policy/policy_regular/test/update_status_manager_test.cc +++ b/src/components/policy/policy_regular/test/update_status_manager_test.cc @@ -61,20 +61,6 @@ class UpdateStatusManagerTest : public ::testing::Test { void TearDown() OVERRIDE {} }; -TEST_F(UpdateStatusManagerTest, - StringifiedUpdateStatus_SetStatuses_ExpectCorrectStringifiedStatuses) { - // Arrange - manager_->OnPolicyInit(false); - // Check - EXPECT_EQ("UP_TO_DATE", manager_->StringifiedUpdateStatus()); - manager_->OnPolicyInit(true); - // Check - EXPECT_EQ("UPDATE_NEEDED", manager_->StringifiedUpdateStatus()); - manager_->OnUpdateSentOut(); - // Check - EXPECT_EQ("UPDATING", manager_->StringifiedUpdateStatus()); -} - TEST_F(UpdateStatusManagerTest, OnAppSearchStartedCompleted_ExpectAppSearchCorrectStatus) { // Arrange -- cgit v1.2.1 From 26a38d0af466e3d19272046485cf8a11866f5e64 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Wed, 3 Oct 2018 10:51:12 -0400 Subject: Fix unit tests --- src/components/application_manager/test/policy_handler_test.cc | 2 +- src/components/policy/policy_external/src/policy_helper.cc | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/application_manager/test/policy_handler_test.cc b/src/components/application_manager/test/policy_handler_test.cc index 15123385a0..a1471eff36 100644 --- a/src/components/application_manager/test/policy_handler_test.cc +++ b/src/components/application_manager/test/policy_handler_test.cc @@ -921,7 +921,7 @@ TEST_F(PolicyHandlerTest, EXPECT_CALL(*mock_policy_manager_, GetAppPermissionsChanges(_)) .WillOnce(Return(permissions)); EXPECT_CALL(*mock_policy_manager_, - RemovePendingPermissionChanges(kPolicyAppId_)).Times(0); + RemovePendingPermissionChanges(kPolicyAppId_)); // Act policy_handler_.OnPendingPermissionChange(kPolicyAppId_); } diff --git a/src/components/policy/policy_external/src/policy_helper.cc b/src/components/policy/policy_external/src/policy_helper.cc index bd83f24a92..c9df969bd1 100644 --- a/src/components/policy/policy_external/src/policy_helper.cc +++ b/src/components/policy/policy_external/src/policy_helper.cc @@ -345,6 +345,8 @@ bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) { SetPendingPermissions( app_policy, RESULT_REQUEST_TYPE_CHANGED, permissions_diff); AddResult(app_id, RESULT_REQUEST_TYPE_CHANGED); + result = + (RESULT_NO_CHANGES == result) ? RESULT_REQUEST_TYPE_CHANGED : result; } if (is_request_subtype_changed) { LOG4CXX_TRACE( @@ -352,6 +354,8 @@ bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) { SetPendingPermissions( app_policy, RESULT_REQUEST_SUBTYPE_CHANGED, permissions_diff); AddResult(app_id, RESULT_REQUEST_SUBTYPE_CHANGED); + result = (RESULT_NO_CHANGES == result) ? RESULT_REQUEST_SUBTYPE_CHANGED + : result; } } -- cgit v1.2.1 From efdca58327e623a4da234d41d228f48642212347 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Wed, 3 Oct 2018 16:25:15 -0400 Subject: Update MOBILE_API.xml --- src/components/interfaces/MOBILE_API.xml | 458 +++++++++++++++---------------- 1 file changed, 228 insertions(+), 230 deletions(-) diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 670793f1c4..68135ca528 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -1,7 +1,7 @@ - + The request succeeded @@ -302,21 +302,6 @@ Clears the media clock timer (previously done through Show->mediaClock) - - - - Default playback indicator. - - - Indicates that a button press of the Play/Pause button would start the playback. - - - Indicates that a button press of the Play/Pause button would pause the current playback. - - - Indicates that a button press of the Play/Pause button would stop the current playback. - - @@ -376,12 +361,6 @@ - - - Enumeration that describes possible states of video streaming. - - - Enumeration that describes system actions that can be triggered. @@ -414,6 +393,12 @@ Broadcast only to whichever app has an alert currently being displayed. + + + Enumeration that describes possible states of video streaming. + + + Contains information about the SoftButton capabilities. @@ -534,7 +519,6 @@ - @@ -554,6 +538,7 @@ + @@ -952,6 +937,27 @@ Similar to VP8, but VP9 is customized for video resolutions beyond high-definition video (UHD) and also enables lossless compression. + + + + + Default playback indicator. + By default the playback indicator should be PLAY_PAUSE when: + - the media app is newly registered on the head unit (after RegisterAppInterface) + - the media app was closed by the user (App enters HMI_NONE) + - the app sends SetMediaClockTimer with audioStreamingIndicator not set to any value + + + + Indicates that a button press of the Play/Pause button starts the audio playback. + + + Indicates that a button press of the Play/Pause button pauses the current audio playback. + + + Indicates that a button press of the Play/Pause button stops the current audio playback. + + @@ -961,7 +967,7 @@ Describes, whether it is a static or dynamic image. - Optional value to specify whether it's a template image. A template image can be (re)colored by the HMI as needed by using an image pattern + If true, the image is a template image and can be recolored by the HMI @@ -1177,35 +1183,7 @@ TPMS reports the tire is not trained. - - - - - Park brake actuators have been fully applied. - - - - - Park brake actuators are transitioning to either Apply/Closed or Release/Open state. - - - - - Park brake actuators are released. - - - - - When driver pulls the Electronic Park Brake switch while driving "at speed". - - - - - When system has a fault or is under maintenance. - - - - + @@ -1236,12 +1214,42 @@ + + + + Park brake actuators have been fully applied. + + + + + Park brake actuators are transitioning to either Apply/Closed or Release/Open state. + + + + + Park brake actuators are released. + + + + + When driver pulls the Electronic Park Brake switch while driving "at speed". + + + + + When system has a fault or is under maintenance. + + + + See ComponentVolumeStatus. - The status of TPMS according to the particular tire. + + The status of TPMS according to the particular tire. + The pressure value of the particular tire in kilo pascal. @@ -1855,7 +1863,6 @@ - Enumeration that describes the status of the turn light indicator. @@ -1871,7 +1878,7 @@ Both signals (left and right) are on. - + Struct with the GPS data. @@ -1920,20 +1927,20 @@ - - PDOP. + + PDOP. If undefined or unavailable, then value shall be set to 0. - - HDOP. + + HDOP. If value is unknown, value shall be set to 0. - - VDOP. + + VDOP. If value is unknown, value shall be set to 0. @@ -2851,130 +2858,131 @@ - List possible zones of a multi-contour massage seat. - - The back of a multi-contour massage seat. or SEAT_BACK - - - The bottom a multi-contour massage seat. or SEAT_BOTTOM - + List possible zones of a multi-contour massage seat. + + The back of a multi-contour massage seat. or SEAT_BACK + + + The bottom a multi-contour massage seat. or SEAT_BOTTOM + - List possible modes of a massage zone. - - - + List possible modes of a massage zone. + + + - Specify the mode of a massage zone. - - + Specify the mode of a massage zone. + + - List possible cushions of a multi-contour massage seat. - - - - - + List possible cushions of a multi-contour massage seat. + + + + + - The intensity or firmness of a cushion. - - + The intensity or firmness of a cushion. + + - - Save current seat postions and settings to seat memory. - - - Restore / apply the seat memory settings to the current seat. - - - No action to be performed. - + + Save current seat postions and settings to seat memory. + + + Restore / apply the seat memory settings to the current seat. + + + No action to be performed. + - - - + + + - List possible seats that is a remote controllable seat. - - + List possible seats that is a remote controllable seat. + + - Seat control data corresponds to "SEAT" ModuleType. - - - - - - - - - - - - - - - + Seat control data corresponds to "SEAT" ModuleType. + + + + + + - - - - + + + + + + + + + + + + + + - - - The short friendly name of the light control module. - It should not be used to identify a module by mobile application. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + The short friendly name of the light control module. + It should not be used to identify a module by mobile application. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Temperature Unit @@ -3050,7 +3058,7 @@ - True if the hd radio is on, false is the radio is off + True if the hd radio is on, false if the radio is off number of HD sub-channels if available @@ -3070,7 +3078,7 @@ If the signal strength falls below the set value for this parameter, the radio will tune to an alternative frequency - True if the radio is on, false is the radio is off. If set to false, no other data will be included. + True if the radio is on, false if the radio is off. If set to false, no other data will be included. @@ -3306,7 +3314,9 @@ read-only channel / frequency name (e.i. "Treble, Midrange, Bass" or "125 Hz") - + + Reflects the setting, from 0%-100%. + @@ -3317,13 +3327,13 @@ If the value is MOBILE_APP, the system shall switch to the mobile media app that issues the setter RPC. - + This parameter shall not be present in any getter responses or notifications. - This parameter is optional in a setter request. The default value is false. - If it is false, the system not only changes the audio source but also brings the default application - or system UI associated with the audio source to foreground. - If it is true, the system changes the audio source, but still keeps the current application in foreground. + This parameter is optional in a setter request. The default value is false if it is not included. + If it is false, the system not only changes the audio source but also brings the default application or + system UI associated with the audio source to foreground. + If it is true, the system only changes the audio source, but keeps the current application in foreground. @@ -3345,7 +3355,7 @@ Availability of the control of audio source. - Availability of the keepContext paramter. + Availability of the keepContext parameter. Availability of the control of audio volume. @@ -3393,7 +3403,7 @@ Include all fog lights: front_left, front_right, rear_left and rear_right. - Include all daytime running lights: front, left and right. + Include all daytime running lights: front_left and front_right. Include all parking lights: front_left and front_right. @@ -3445,7 +3455,7 @@ Include exterior lights located in front of the vehicle. For example, fog lights and low beams. - Include exterior lights located at the back of the vehicle. For example, license plate lights, reverse lights, cargo lights, bed lights an trailer assist lights. + Include exterior lights located at the back of the vehicle. For example, license plate lights, reverse lights, cargo lights, bed lights and trailer assist lights. Include exterior lights located at the left side of the vehicle. For example, left puddle lights and spot lights. @@ -3481,7 +3491,7 @@ - Indicates if the light's color can be set remotely by using the RGB color space. + Indicates if the light's color can be set remotely by using the sRGB color space. @@ -3494,7 +3504,7 @@ - An array of available light names that are controllable. + An array of available LightCapabilities that are controllable. @@ -3518,6 +3528,7 @@ + @@ -3547,7 +3558,7 @@ Availability of the control of HMI display mode. - + The moduleType indicates which type of data should be changed and identifies which data object exists in this struct. For example, if the moduleType is CLIMATE then a "climateControlData" should exist @@ -3568,27 +3579,25 @@ - If included, the platform supports RC climate controls. For this baseline version, maxsize=1. i.e. only one climate control module is supported. + If included, the platform supports RC climate controls. For this baseline version, maxsize=1. i.e. only one climate control module is supported. - If included, the platform supports RC radio controls.For this baseline version, maxsize=1. i.e. only one radio control module is supported. + If included, the platform supports RC radio controls.For this baseline version, maxsize=1. i.e. only one radio control module is supported. - - If included, the platform supports RC button controls with the included button names. - - - - If included, the platform supports seat controls. - + + If included, the platform supports RC button controls with the included button names. - If included, the platform supports audio controls. + If included, the platform supports audio controls. - If included, the platform supports hmi setting controls. + If included, the platform supports hmi setting controls. - If included, the platform supports light controls. + If included, the platform supports light controls. + + + If included, the platform supports seat controls. @@ -3794,9 +3803,7 @@ See AppInfo. - - @@ -3900,6 +3907,7 @@ The software version of the system that implements the SmartDeviceLink core. + Existence of apps icon at system. If true, apps icon @@ -4155,6 +4163,7 @@ Text to show in the menu for this sub menu. + The image field for AddSubMenu @@ -4670,8 +4679,11 @@ In case of pause, resume, or clear, the start time value is ignored and shall be left out. For resume, the time continues with the same value as it was when paused. + - Indicates that a button press of the Play/Pause button would play, pause or Stop the current playback. + + Enumeration for the indicator icon on a play/pause button. see AudioStreamingIndicator. + @@ -4925,9 +4937,8 @@ The estimated percentage of remaining oil life of the engine. - The status of the park brake as provided by Electric Park Brake (EPB) system. + The status of the park brake as provided by Electric Park Brake (EPB) system. - @@ -5041,9 +5052,8 @@ The estimated percentage of remaining oil life of the engine. - The status of the park brake as provided by Electric Park Brake (EPB) system. + The status of the park brake as provided by Electric Park Brake (EPB) system. - @@ -5135,9 +5145,8 @@ The estimated percentage of remaining oil life of the engine. - The status of the park brake as provided by Electric Park Brake (EPB) system. + The status of the park brake as provided by Electric Park Brake (EPB) system. - @@ -5249,9 +5258,8 @@ The estimated percentage of remaining oil life of the engine. - The status of the park brake as provided by Electric Park Brake (EPB) system. + The status of the park brake as provided by Electric Park Brake (EPB) system. - @@ -5346,9 +5354,8 @@ The estimated percentage of remaining oil life of the engine. - The status of the park brake as provided by Electric Park Brake (EPB) system. + The status of the park brake as provided by Electric Park Brake (EPB) system. - @@ -5464,9 +5471,8 @@ The estimated percentage of remaining oil life of the engine. - The status of the park brake as provided by Electric Park Brake (EPB) system. + The status of the park brake as provided by Electric Park Brake (EPB) system. - @@ -5969,7 +5975,7 @@ - Additional CRC32 checksum to protect data integrity up to 512 Mbits . + Additional CRC32 checksum to protect data integrity up to 512 Mbits @@ -6042,10 +6048,7 @@ - - Provides the total local space available in SDL Core for the registered app. - If the transfer has systemFile enabled, then the value will be set to 0 automatically. - + Provides the total local space available on the module for the registered app. @@ -6092,10 +6095,7 @@ - - Provides the total local space available in SDL Core for the registered app. - If the transfer has systemFile enabled, then the value will be set to 0 automatically. - + Provides the total local space available on the module for the registered app. @@ -6158,7 +6158,7 @@ Currently only predefined screen layouts are defined. - + @@ -6393,14 +6393,11 @@ In the future, this should be the Identification of a module. - + - If subscribe is true, the head unit will register onInteriorVehicleData notifications for the requested moduelType. - If subscribe is false, the head unit will unregister onInteriorVehicleData notifications for the requested moduelType. + If subscribe is true, the head unit will register onInteriorVehicleData notifications for the requested moduleType. + If subscribe is false, the head unit will unregister onInteriorVehicleData notifications for the requested moduleType. - - - @@ -6620,8 +6617,12 @@ See SystemContext + - See VideoStreamingState. If it is NOT_STREAMABLE, the app must stop streaming video to SDL. + + See VideoStreamingState. + If it is NOT_STREAMABLE, the app must stop streaming video to SDL Core(stop service). + @@ -6725,9 +6726,8 @@ The estimated percentage of remaining oil life of the engine. - The status of the park brake as provided by Electric Park Brake (EPB) system. + The status of the park brake as provided by Electric Park Brake (EPB) system. - @@ -6881,18 +6881,16 @@ - Issued by SDL to notify the application about remote control status change on SDL - - - If "true" - RC is allowed; if "false" - RC is disallowed. - - - - Contains a list (zero or more) of module types that are allocated to the application. - - - Contains a list (zero or more) of module types that are free to access for the application. - + Issued by SDL to notify the application about remote control status change on SDL + + If "true" - RC is allowed; if "false" - RC is disallowed. + + + Contains a list (zero or more) of module types that are allocated to the application. + + + Contains a list (zero or more) of module types that are free to access for the application. + -- cgit v1.2.1 From edd46b78f4ad1dad7385d5383bbd341751a15956 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Thu, 4 Oct 2018 10:09:26 -0400 Subject: Fixes mismatch between HMI and MOBILE API --- src/components/interfaces/HMI_API.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 0b6eed072d..0702993621 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -1069,7 +1069,6 @@ - @@ -1089,6 +1088,7 @@ + -- cgit v1.2.1 From 2f342d8c5689c388f087242965f545df38816fba Mon Sep 17 00:00:00 2001 From: JackLivio Date: Thu, 4 Oct 2018 15:43:44 -0400 Subject: Remove defvalue from keepContext --- src/components/interfaces/MOBILE_API.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 68135ca528..6310f8d823 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -3327,7 +3327,7 @@ If the value is MOBILE_APP, the system shall switch to the mobile media app that issues the setter RPC. - + This parameter shall not be present in any getter responses or notifications. This parameter is optional in a setter request. The default value is false if it is not included. -- cgit v1.2.1 From 026888567b3630c873a6bafac7b81480c6d7b38b Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Thu, 4 Oct 2018 16:52:53 -0400 Subject: Fix issue where Vehicle Data and WayPoints were not unsubscribed on transport switch --- .../include/application_manager/application_manager_impl.h | 4 ++-- .../src/commands/mobile/on_way_point_change_notification.cc | 4 ++-- .../commands/mobile/on_way_point_change_notification_test.cc | 2 +- .../vehicle_info_plugin/src/vehicle_info_plugin.cc | 2 ++ .../application_manager/src/application_manager_impl.cc | 11 ++++++++++- .../application_manager/test/application_manager_impl_test.cc | 5 +++-- .../include/application_manager/application_manager.h | 2 +- .../test/application_manager/mock_application_manager.h | 2 +- 8 files changed, 22 insertions(+), 10 deletions(-) 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 4f4faa15a8..6c111dbbb3 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 @@ -257,7 +257,7 @@ class ApplicationManagerImpl * @brief Get subscribed for way points * @return reference to set of subscribed apps for way points */ - const std::set GetAppsSubscribedForWayPoints() const OVERRIDE; + const std::set GetAppsSubscribedForWayPoints() const OVERRIDE; /** * @brief Notifies all components interested in Vehicle Data update @@ -1355,7 +1355,7 @@ class ApplicationManagerImpl /** * @brief Set AppIDs of subscribed apps for way points */ - std::set subscribed_way_points_apps_list_; + std::set subscribed_way_points_apps_list_; /** * @brief Map contains applications which diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification.cc index e25e4c622b..2f666ffc03 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification.cc @@ -55,10 +55,10 @@ OnWayPointChangeNotification::~OnWayPointChangeNotification() {} void OnWayPointChangeNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); - std::set subscribed_for_way_points = + std::set subscribed_for_way_points = application_manager_.GetAppsSubscribedForWayPoints(); - for (std::set::const_iterator app_id = + for (std::set::const_iterator app_id = subscribed_for_way_points.begin(); app_id != subscribed_for_way_points.end(); ++app_id) { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_way_point_change_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_way_point_change_notification_test.cc index 97a290e792..ed0a9b07d2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_way_point_change_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_way_point_change_notification_test.cc @@ -98,7 +98,7 @@ MATCHER(CheckMessageData, "") { TEST_F(OnWayPointChangeNotificationTest, Run_NotEmptyListOfAppsSubscribedForWayPoints_SUCCESS) { - std::set apps_subscribed_for_way_points; + std::set apps_subscribed_for_way_points; apps_subscribed_for_way_points.insert(kAppId); EXPECT_CALL(app_mngr_, GetAppsSubscribedForWayPoints()) diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_plugin.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_plugin.cc index bd8eb1920d..d0bcc36ab4 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_plugin.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_plugin.cc @@ -76,6 +76,8 @@ void VehicleInfoPlugin::OnApplicationEvent( if (plugins::ApplicationEvent::kApplicationRegistered == event) { application->AddExtension( std::make_shared(*this, *application)); + } else if (plugins::ApplicationEvent::kDeleteApplicationData == event) { + DeleteSubscriptions(application); } } diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 98d0309253..24f27af2e2 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -1126,7 +1126,14 @@ void ApplicationManagerImpl::SwitchApplication(ApplicationSharedPtr app, << ". Changing device id to " << device_id); + bool is_subscribed_to_way_points = IsAppSubscribedForWayPoints(app); + if (is_subscribed_to_way_points) { + UnsubscribeAppFromWayPoints(app); + } SwitchApplicationParameters(app, connection_key, device_id, mac_address); + if (is_subscribed_to_way_points) { + SubscribeAppForWayPoints(app); + } // Normally this is done during registration, however since switched apps are // not being registered again need to set protocol version on session. @@ -3482,6 +3489,7 @@ void ApplicationManagerImpl::SubscribeAppForWayPoints( ApplicationSharedPtr app) { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock lock(subscribed_way_points_apps_lock_); + LOG4CXX_DEBUG(logger_, "Subscribing " << app->app_id()); subscribed_way_points_apps_list_.insert(app->app_id()); LOG4CXX_DEBUG(logger_, "There are applications subscribed: " @@ -3492,6 +3500,7 @@ void ApplicationManagerImpl::UnsubscribeAppFromWayPoints( ApplicationSharedPtr app) { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock lock(subscribed_way_points_apps_lock_); + LOG4CXX_DEBUG(logger_, "Unsubscribing " << app->app_id()); subscribed_way_points_apps_list_.erase(app->app_id()); LOG4CXX_DEBUG(logger_, "There are applications subscribed: " @@ -3507,7 +3516,7 @@ bool ApplicationManagerImpl::IsAnyAppSubscribedForWayPoints() const { return !subscribed_way_points_apps_list_.empty(); } -const std::set ApplicationManagerImpl::GetAppsSubscribedForWayPoints() +const std::set ApplicationManagerImpl::GetAppsSubscribedForWayPoints() const { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock lock(subscribed_way_points_apps_lock_); diff --git a/src/components/application_manager/test/application_manager_impl_test.cc b/src/components/application_manager/test/application_manager_impl_test.cc index cf848ba159..7e57b51329 100644 --- a/src/components/application_manager/test/application_manager_impl_test.cc +++ b/src/components/application_manager/test/application_manager_impl_test.cc @@ -245,7 +245,7 @@ TEST_F(ApplicationManagerImplTest, EXPECT_TRUE(app_manager_impl_->IsAppSubscribedForWayPoints(app_ptr)); app_manager_impl_->UnsubscribeAppFromWayPoints(app_ptr); EXPECT_FALSE(app_manager_impl_->IsAppSubscribedForWayPoints(app_ptr)); - const std::set result = + const std::set result = app_manager_impl_->GetAppsSubscribedForWayPoints(); EXPECT_TRUE(result.empty()); } @@ -264,7 +264,8 @@ TEST_F( GetAppsSubscribedForWayPoints_SubcribeAppForWayPoints_ExpectCorrectResult) { auto app_ptr = std::static_pointer_cast(mock_app_ptr_); app_manager_impl_->SubscribeAppForWayPoints(app_ptr); - std::set result = app_manager_impl_->GetAppsSubscribedForWayPoints(); + std::set result = + app_manager_impl_->GetAppsSubscribedForWayPoints(); EXPECT_EQ(1u, result.size()); EXPECT_TRUE(result.find(app_ptr->app_id()) != result.end()); } diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h index 6df91d748c..e6e5c89f45 100644 --- a/src/components/include/application_manager/application_manager.h +++ b/src/components/include/application_manager/application_manager.h @@ -313,7 +313,7 @@ class ApplicationManager { * @brief Get subscribed for way points * @return reference to set of subscribed apps for way points */ - virtual const std::set GetAppsSubscribedForWayPoints() const = 0; + virtual const std::set GetAppsSubscribedForWayPoints() const = 0; virtual void RemoveHMIFakeParameters( application_manager::commands::MessageSharedPtr& message, 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 f6a0c181c2..7f5f17a93d 100644 --- a/src/components/include/test/application_manager/mock_application_manager.h +++ b/src/components/include/test/application_manager/mock_application_manager.h @@ -281,7 +281,7 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_METHOD1(UnsubscribeAppFromWayPoints, void(application_manager::ApplicationSharedPtr)); MOCK_CONST_METHOD0(IsAnyAppSubscribedForWayPoints, bool()); - MOCK_CONST_METHOD0(GetAppsSubscribedForWayPoints, const std::set()); + MOCK_CONST_METHOD0(GetAppsSubscribedForWayPoints, const std::set()); MOCK_CONST_METHOD1( WaitingApplicationByID, application_manager::ApplicationConstSharedPtr(const uint32_t)); -- cgit v1.2.1 From 82aeb31c413726a9f37d3af0578acc1f74689a59 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Wed, 10 Oct 2018 11:44:35 -0400 Subject: Remove subscribe defvalue tag --- src/components/interfaces/MOBILE_API.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 6310f8d823..c62a9e34d6 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -6393,7 +6393,7 @@ In the future, this should be the Identification of a module. - + If subscribe is true, the head unit will register onInteriorVehicleData notifications for the requested moduleType. If subscribe is false, the head unit will unregister onInteriorVehicleData notifications for the requested moduleType. -- cgit v1.2.1 From e60f5b7cff18cd06dc56e0227347fa5b1f4628bc Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Wed, 10 Oct 2018 14:38:09 -0400 Subject: Merge module data instead of outright replacing each element --- .../rc_rpc_plugin/src/interior_data_cache_impl.cc | 53 +++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_cache_impl.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_cache_impl.cc index 0eb175aa25..d2242469e2 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_cache_impl.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_cache_impl.cc @@ -34,6 +34,7 @@ #include #include #include "rc_rpc_plugin/interior_data_cache_impl.h" +#include "application_manager/smart_object_keys.h" #include "utils/date_time.h" #include "utils/logger.h" @@ -52,6 +53,13 @@ InteriorDataCacheImpl::~InteriorDataCacheImpl() {} * @param data2 - updated data * @return updated data1 with data2 keys and values */ +smart_objects::SmartObject MergeModuleData( + const smart_objects::SmartObject& data1, + const smart_objects::SmartObject& data2); + +smart_objects::SmartObject MergeArray(const smart_objects::SmartObject& data1, + const smart_objects::SmartObject& data2); + smart_objects::SmartObject MergeModuleData( const smart_objects::SmartObject& data1, const smart_objects::SmartObject& data2) { @@ -60,11 +68,54 @@ smart_objects::SmartObject MergeModuleData( for (; it != data2.map_end(); ++it) { const std::string& key = it->first; const smart_objects::SmartObject& value = it->second; - result[key] = value; + // Merge maps and arrays with `id` param included, replace other types + if (result.keyExists(key) && value.getType() == result[key].getType()) { + if (value.getType() == smart_objects::SmartType::SmartType_Map) { + result[key] = MergeModuleData(result[key], value); + } else if (value.getType() == smart_objects::SmartType::SmartType_Array) { + result[key] = MergeArray(result[key], value); + } else { + result[key] = value; + } + } else { + result[key] = value; + } } return result; } +smart_objects::SmartObject MergeArray(const smart_objects::SmartObject& data1, + const smart_objects::SmartObject& data2) { + // Merge data only in the case where each value in the array is an Object with + // an ID included, otherwise replace + if (!data2.empty() && + data2.getElement(0).getType() == + smart_objects::SmartType::SmartType_Map && + data2.getElement(0).keyExists(application_manager::strings::id)) { + smart_objects::SmartObject result = data1; + smart_objects::SmartArray* result_array = result.asArray(); + smart_objects::SmartArray* data_array = data2.asArray(); + auto data_it = data_array->begin(); + for (; data_it != data_array->end(); ++data_it) { + auto result_it = + std::find_if(result_array->begin(), + result_array->end(), + [data_it](smart_objects::SmartObject& obj) -> bool { + return obj[application_manager::strings::id] == + (*data_it)[application_manager::strings::id]; + }); + + if (result_it != result_array->end()) { + *result_it = MergeModuleData(*result_it, *data_it); + } else { + result_array->push_back(*data_it); + } + } + return result; + } + return data2; +} + void InteriorDataCacheImpl::Add(const std::string& module_type, const smart_objects::SmartObject& module_data) { LOG4CXX_TRACE(logger_, "module_type : " << module_type); -- cgit v1.2.1 From f21ae8ccf1d606d7d4a3b3c4d357fcc7acab631a Mon Sep 17 00:00:00 2001 From: JackLivio Date: Wed, 10 Oct 2018 16:23:46 -0400 Subject: Add history tag --- src/components/interfaces/MOBILE_API.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index c62a9e34d6..76fc6ef2d1 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -6393,11 +6393,15 @@ In the future, this should be the Identification of a module. - + If subscribe is true, the head unit will register onInteriorVehicleData notifications for the requested moduleType. If subscribe is false, the head unit will unregister onInteriorVehicleData notifications for the requested moduleType. + If subscribe is not included, the subscription status of the app for the requested moduleType will remain unchanged. + + + -- cgit v1.2.1 From 7ce7731d58ac59eb561af17881f3fba29a5f7dc8 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Wed, 10 Oct 2018 17:34:37 -0400 Subject: Address review comments --- .../rc_rpc_plugin/src/interior_data_cache_impl.cc | 92 +++++++++++++--------- 1 file changed, 56 insertions(+), 36 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_cache_impl.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_cache_impl.cc index d2242469e2..780aab537b 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_cache_impl.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_cache_impl.cc @@ -47,7 +47,7 @@ InteriorDataCacheImpl::InteriorDataCacheImpl() {} InteriorDataCacheImpl::~InteriorDataCacheImpl() {} /** - * @brief MergeModuleData key all keys and values from first parameter and + * @brief MergeModuleData all keys and values from first parameter and * update and append keys and values from the second * @param data1 - initial data * @param data2 - updated data @@ -57,6 +57,14 @@ smart_objects::SmartObject MergeModuleData( const smart_objects::SmartObject& data1, const smart_objects::SmartObject& data2); +/** + * @brief MergeArray merge two arrays if their elements contain an `id` + * parameter + * @param data1 - initial data + * @param data2 - updated data + * @return updated data1 with any values in data2 if the arrays can be merged, + * otherwise data2 + */ smart_objects::SmartObject MergeArray(const smart_objects::SmartObject& data1, const smart_objects::SmartObject& data2); @@ -67,19 +75,19 @@ smart_objects::SmartObject MergeModuleData( auto it = data2.map_begin(); for (; it != data2.map_end(); ++it) { const std::string& key = it->first; - const smart_objects::SmartObject& value = it->second; - // Merge maps and arrays with `id` param included, replace other types - if (result.keyExists(key) && value.getType() == result[key].getType()) { - if (value.getType() == smart_objects::SmartType::SmartType_Map) { - result[key] = MergeModuleData(result[key], value); - } else if (value.getType() == smart_objects::SmartType::SmartType_Array) { - result[key] = MergeArray(result[key], value); - } else { - result[key] = value; - } - } else { + smart_objects::SmartObject& value = it->second; + if (!result.keyExists(key) || value.getType() != result[key].getType()) { result[key] = value; + continue; + } + + // Merge maps and arrays with `id` param included, replace other types + if (value.getType() == smart_objects::SmartType::SmartType_Map) { + value = MergeModuleData(result[key], value); + } else if (value.getType() == smart_objects::SmartType::SmartType_Array) { + value = MergeArray(result[key], value); } + result[key] = value; } return result; } @@ -88,32 +96,44 @@ smart_objects::SmartObject MergeArray(const smart_objects::SmartObject& data1, const smart_objects::SmartObject& data2) { // Merge data only in the case where each value in the array is an Object with // an ID included, otherwise replace - if (!data2.empty() && - data2.getElement(0).getType() == - smart_objects::SmartType::SmartType_Map && - data2.getElement(0).keyExists(application_manager::strings::id)) { - smart_objects::SmartObject result = data1; - smart_objects::SmartArray* result_array = result.asArray(); - smart_objects::SmartArray* data_array = data2.asArray(); - auto data_it = data_array->begin(); - for (; data_it != data_array->end(); ++data_it) { - auto result_it = - std::find_if(result_array->begin(), - result_array->end(), - [data_it](smart_objects::SmartObject& obj) -> bool { - return obj[application_manager::strings::id] == - (*data_it)[application_manager::strings::id]; - }); - - if (result_it != result_array->end()) { - *result_it = MergeModuleData(*result_it, *data_it); - } else { - result_array->push_back(*data_it); - } + bool array_contains_objects = + !data2.empty() && + data2.getElement(0).getType() != smart_objects::SmartType::SmartType_Map; + bool can_merge_arrays = + array_contains_objects && + data2.getElement(0).keyExists(application_manager::strings::id); + if (!can_merge_arrays) { + return data2; + } + + smart_objects::SmartObject result = data1; + smart_objects::SmartArray* result_array = result.asArray(); + smart_objects::SmartArray* data_array = data2.asArray(); + auto data_it = data_array->begin(); + auto find_by_id = + [](smart_objects::SmartArray* array, const smart_objects::SmartObject& id) + -> smart_objects::SmartArray::iterator { + auto it = std::find_if( + array->begin(), + array->end(), + [&id](smart_objects::SmartObject& obj) -> bool { + return obj[application_manager::strings::id] == id; + }); + return it; + }; + + for (; data_it != data_array->end(); ++data_it) { + const smart_objects::SmartObject element_id = + (*data_it)[application_manager::strings::id]; + auto result_it = find_by_id(result_array, element_id); + + if (result_it != result_array->end()) { + *result_it = MergeModuleData(*result_it, *data_it); + } else { + result_array->push_back(*data_it); } - return result; } - return data2; + return result; } void InteriorDataCacheImpl::Add(const std::string& module_type, -- cgit v1.2.1 From 9785e1adda6f3abdf9714866dde9305b99332dd7 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Thu, 11 Oct 2018 15:10:36 -0400 Subject: Bump base negotiated rpc version to 4.5.1 --- .../src/commands/mobile/on_button_event_notification.cc | 2 +- .../src/commands/mobile/on_button_press_notification.cc | 2 +- .../src/commands/mobile/register_app_interface_response.cc | 2 +- .../sdl_rpc_plugin/src/commands/mobile/subscribe_button_request.cc | 2 +- .../src/commands/mobile/unsubscribe_button_request.cc | 2 +- .../test/commands/mobile/subscribe_button_request_test.cc | 6 +++--- .../test/commands/mobile/unsubscribe_button_request_test.cc | 6 +++--- src/components/include/utils/semantic_version.h | 2 +- src/components/utils/src/semantic_version.cc | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_event_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_event_notification.cc index aeb53a115e..911d7faaff 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_event_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_event_notification.cc @@ -166,7 +166,7 @@ void OnButtonEventNotification::SendButtonEvent(ApplicationConstSharedPtr app) { (*message_)[strings::msg_params][hmi_response::button_name].asInt()); if (btn_id == mobile_apis::ButtonName::PLAY_PAUSE && - app->msg_version() <= utils::version_4_5) { + app->msg_version() <= utils::base_rpc_version) { btn_id = mobile_apis::ButtonName::OK; } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_press_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_press_notification.cc index 56a87da305..9ca662389d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_press_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_press_notification.cc @@ -174,7 +174,7 @@ void OnButtonPressNotification::SendButtonPress(ApplicationConstSharedPtr app) { (*message_)[strings::msg_params][hmi_response::button_name].asInt()); if (btn_id == mobile_apis::ButtonName::PLAY_PAUSE && - app->msg_version() <= utils::version_4_5) { + app->msg_version() <= utils::base_rpc_version) { btn_id = mobile_apis::ButtonName::OK; } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_response.cc index 31eb738357..3972aab3a8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_response.cc @@ -63,7 +63,7 @@ void RegisterAppInterfaceResponse::Run() { application_manager::ApplicationSharedPtr app = application_manager_.application(connection_key()); - if (app && app->msg_version() <= utils::version_4_5 && + if (app && app->msg_version() <= utils::base_rpc_version && app->is_media_application() && (*message_)[strings::msg_params].keyExists( hmi_response::button_capabilities)) { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_request.cc index 85cb26321b..7ee15d9119 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_request.cc @@ -77,7 +77,7 @@ void SubscribeButtonRequest::Run() { return; } - if (app->msg_version() <= utils::version_4_5 && + if (app->msg_version() <= utils::base_rpc_version && btn_id == mobile_apis::ButtonName::OK && app->is_media_application()) { bool ok_supported = CheckHMICapabilities(mobile_apis::ButtonName::OK); bool play_pause_supported = diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_request.cc index ccfaef54cb..f914182e5b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_request.cc @@ -72,7 +72,7 @@ void UnsubscribeButtonRequest::Run() { static_cast( (*message_)[str::msg_params][str::button_name].asInt()); - if (app->msg_version() <= utils::version_4_5 && + if (app->msg_version() <= utils::base_rpc_version && btn_id == mobile_apis::ButtonName::OK && app->is_media_application()) { bool ok_supported = CheckHMICapabilities(mobile_apis::ButtonName::OK); bool play_pause_supported = diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc index 0196b59b79..9e2e83e8f8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc @@ -74,7 +74,7 @@ class SubscribeButtonRequestTest typedef SubscribeButtonRequestTest::MockHMICapabilities MockHMICapabilities; const utils::SemanticVersion mock_semantic_version(5, 0, 0); -const utils::SemanticVersion mock_semantic_version_4_5(4, 5, 0); +const utils::SemanticVersion mock_base_rpc_version(4, 5, 1); TEST_F(SubscribeButtonRequestTest, Run_AppNotRegistered_UNSUCCESS) { CommandPtr command(CreateCommand()); @@ -202,7 +202,7 @@ TEST_F(SubscribeButtonRequestTest, Run_SUCCESS) { [am::strings::result_code].asInt())); } -TEST_F(SubscribeButtonRequestTest, Run_SUCCESS_App_Version_4_5) { +TEST_F(SubscribeButtonRequestTest, Run_SUCCESS_App_Base_RPC_Version) { const mobile_apis::ButtonName::eType kButtonName = mobile_apis::ButtonName::OK; @@ -213,7 +213,7 @@ TEST_F(SubscribeButtonRequestTest, Run_SUCCESS_App_Version_4_5) { MockAppPtr app(CreateMockApp()); ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); ON_CALL(*app, msg_version()) - .WillByDefault(ReturnRef(mock_semantic_version_4_5)); + .WillByDefault(ReturnRef(mock_base_rpc_version)); ON_CALL(*app, is_media_application()).WillByDefault(Return(true)); ON_CALL(mock_hmi_capabilities_, is_ui_cooperating()) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_button_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_button_request_test.cc index d6bef42794..a848fff2b2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_button_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_button_request_test.cc @@ -29,7 +29,7 @@ namespace { const uint32_t kConnectionKey = 1u; const mobile_apis::ButtonName::eType kButtonId = mobile_apis::ButtonName::OK; const utils::SemanticVersion mock_semantic_version(5, 0, 0); -const utils::SemanticVersion mock_semantic_version_4_5(4, 5, 0); +const utils::SemanticVersion mock_base_rpc_version(4, 5, 1); } // namespace class UnsubscribeButtonRequestTest @@ -151,7 +151,7 @@ TEST_F(UnsubscribeButtonRequestTest, Run_SUCCESS) { command->Run(); } -TEST_F(UnsubscribeButtonRequestTest, Run_SUCCESS_Version_4_5) { +TEST_F(UnsubscribeButtonRequestTest, Run_SUCCESS_Base_RPC_Version) { MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); (*command_msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; @@ -176,7 +176,7 @@ TEST_F(UnsubscribeButtonRequestTest, Run_SUCCESS_Version_4_5) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillRepeatedly(Return(mock_app)); ON_CALL(*mock_app, msg_version()) - .WillByDefault(ReturnRef(mock_semantic_version_4_5)); + .WillByDefault(ReturnRef(mock_base_rpc_version)); ON_CALL(*mock_app, is_media_application()).WillByDefault(Return(true)); EXPECT_CALL(*mock_app, diff --git a/src/components/include/utils/semantic_version.h b/src/components/include/utils/semantic_version.h index 244ae82177..ecd7a98de2 100644 --- a/src/components/include/utils/semantic_version.h +++ b/src/components/include/utils/semantic_version.h @@ -118,7 +118,7 @@ struct SemanticVersion { uint16_t patch_version_ = 0; }; -extern const SemanticVersion version_4_5; +extern const SemanticVersion base_rpc_version; } #endif // SRC_COMPONENTS_INCLUDE_UTILS_CALLABLE_H \ No newline at end of file diff --git a/src/components/utils/src/semantic_version.cc b/src/components/utils/src/semantic_version.cc index 4b8d37b913..b7cf818791 100644 --- a/src/components/utils/src/semantic_version.cc +++ b/src/components/utils/src/semantic_version.cc @@ -33,6 +33,6 @@ namespace utils { -const SemanticVersion version_4_5(4, 5, 0); +const SemanticVersion base_rpc_version(4, 5, 1); } // namespace utils \ No newline at end of file -- cgit v1.2.1 From e12b97bc3bfb3aa49545ae6954208be64dc3cb6f Mon Sep 17 00:00:00 2001 From: JackLivio Date: Thu, 11 Oct 2018 15:11:52 -0400 Subject: Style --- .../test/commands/mobile/subscribe_button_request_test.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc index 9e2e83e8f8..caca56e297 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc @@ -212,8 +212,7 @@ TEST_F(SubscribeButtonRequestTest, Run_SUCCESS_App_Base_RPC_Version) { MockAppPtr app(CreateMockApp()); ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); - ON_CALL(*app, msg_version()) - .WillByDefault(ReturnRef(mock_base_rpc_version)); + ON_CALL(*app, msg_version()).WillByDefault(ReturnRef(mock_base_rpc_version)); ON_CALL(*app, is_media_application()).WillByDefault(Return(true)); ON_CALL(mock_hmi_capabilities_, is_ui_cooperating()) -- cgit v1.2.1 From 3a5d1ee222fb3a173031343f022c720b39a8c29c Mon Sep 17 00:00:00 2001 From: JackLivio Date: Thu, 11 Oct 2018 16:15:52 -0400 Subject: Fix usage of base_rpc_version --- .../src/commands/mobile/register_app_interface_request.cc | 5 ++--- src/components/application_manager/src/rpc_handler_impl.cc | 5 +++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc index 9cfd4f33b5..bc36b85db3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc @@ -332,13 +332,12 @@ void RegisterAppInterfaceRequest::Run() { } // Version negotiation - utils::SemanticVersion ver_4_5(4, 5, 0); utils::SemanticVersion module_version( major_version, minor_version, patch_version); - if (mobile_version <= ver_4_5) { + if (mobile_version <= utils::base_rpc_version) { // Mobile versioning did not exist for // versions 4.5 and prior. - application->set_msg_version(ver_4_5); + application->set_msg_version(utils::base_rpc_version); } else if (mobile_version < module_version) { // Use mobile RPC version as negotiated version application->set_msg_version(mobile_version); diff --git a/src/components/application_manager/src/rpc_handler_impl.cc b/src/components/application_manager/src/rpc_handler_impl.cc index 0ccdf8b758..a33da0708f 100644 --- a/src/components/application_manager/src/rpc_handler_impl.cc +++ b/src/components/application_manager/src/rpc_handler_impl.cc @@ -219,8 +219,9 @@ void RPCHandlerImpl::GetMessageVersion( } utils::SemanticVersion temp_version(major, minor, patch); if (temp_version.isValid()) { - utils::SemanticVersion ver_4_5(4, 5, 0); - message_version = (temp_version > ver_4_5) ? temp_version : ver_4_5; + message_version = (temp_version > utils::base_rpc_version) + ? temp_version + : utils::base_rpc_version; } } } -- cgit v1.2.1 From 1413bed7877486516ccec4d8cc5e6122849325a3 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Fri, 12 Oct 2018 10:11:45 -0400 Subject: Cut off unrelated module data parameters in SIVD --- .../mobile/set_interior_vehicle_data_request.cc | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc index 0473dd1791..edc45670ce 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc @@ -394,16 +394,25 @@ ModuleCapability GetModuleDataCapabilities( return module_data_capabilities; } -bool isModuleTypeAndDataMatch(const std::string& module_type, - const smart_objects::SmartObject& module_data) { +/** + * @brief Clears unrelated module data parameters + * @param module type in request + * @param smart object of module_data + * @return true if the correct module parameter is present, false otherwise + */ +bool ClearUnrelatedModuleData(const std::string& module_type, + smart_objects::SmartObject& module_data) { LOG4CXX_AUTO_TRACE(logger_); const auto& all_module_types = RCHelpers::GetModulesList(); const auto& data_mapping = RCHelpers::GetModuleTypeToDataMapping(); bool module_type_and_data_match = false; for (const auto& type : all_module_types) { + const std::string module_key = data_mapping(type); if (type == module_type) { - module_type_and_data_match = module_data.keyExists(data_mapping(type)); - break; + module_type_and_data_match = module_data.keyExists(module_key); + } else if (module_data.keyExists(module_key)) { + // Cutting unrelated module data + module_data.erase(module_key); } } return module_type_and_data_match; @@ -445,7 +454,7 @@ void SetInteriorVehicleDataRequest::Execute() { (*message_)[app_mngr::strings::msg_params][message_params::kModuleData]; const std::string module_type = ModuleType(); - if (isModuleTypeAndDataMatch(module_type, module_data)) { + if (ClearUnrelatedModuleData(module_type, module_data)) { const smart_objects::SmartObject* rc_capabilities = hmi_capabilities_.rc_capability(); ModuleCapability module_data_capabilities; -- cgit v1.2.1 From 3110a7696b44cec29cf31f7358a66317bfdf6d04 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Fri, 12 Oct 2018 14:14:54 -0400 Subject: Add radio param filtering if radioEnable or hdRadioEnable are false --- .../mobile/on_interior_vehicle_data_notification.h | 1 + .../include/rc_rpc_plugin/rc_module_constants.h | 1 + .../on_interior_vehicle_data_notification.cc | 28 ++++++++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h index 931e79366c..ec764d37cd 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h @@ -60,6 +60,7 @@ class OnInteriorVehicleDataNotification private: InteriorDataCache& interior_data_cache_; void AddDataToCache(const std::string& module_type); + void FilterDisabledModuleData(const std::string& module_type); }; } // namespace commands } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h index 1951af1a24..18014e6270 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h @@ -150,6 +150,7 @@ const char kFrequencyInteger[] = "frequencyInteger"; const char kFrequencyFraction[] = "frequencyFraction"; const char kBand[] = "band"; const char kRdsData[] = "rdsData"; +const char kHdRadioEnable[] = "hdRadioEnable"; const char kAvailableHDs[] = "availableHDs"; const char kHdChannel[] = "hdChannel"; const char kSignalStrength[] = "signalStrength"; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc index 37890b7979..7393c4f70e 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc @@ -63,6 +63,33 @@ void OnInteriorVehicleDataNotification::AddDataToCache( interior_data_cache_.Add(module_type, module_data); } +void OnInteriorVehicleDataNotification::FilterDisabledModuleData( + const std::string& module_type) { + const auto& data_mapping = RCHelpers::GetModuleTypeToDataMapping(); + auto& module_data = + (*message_)[app_mngr::strings::msg_params][message_params::kModuleData] + [data_mapping(module_type)]; + + // If radioEnable is false, remove all other radio parameters from the + // message. + if (module_data.keyExists(message_params::kRadioEnable) && + module_data[message_params::kRadioEnable] == false) { + for (auto data = module_data.map_begin(); data != module_data.map_end(); + ++data) { + if (data->first != message_params::kRadioEnable) { + module_data.erase(data->first); + } + } + } + + // If hdRadioEnable is false, find and remove the HDChannel if parameter is + // present. + if (module_data.keyExists(message_params::kHdRadioEnable) && + module_data[message_params::kHdRadioEnable] == false) { + module_data.erase(message_params::kHdChannel); + } +} + void OnInteriorVehicleDataNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); @@ -71,6 +98,7 @@ void OnInteriorVehicleDataNotification::Run() { RCHelpers::AppsSubscribedToModuleType(application_manager_, module_type); if (!apps_subscribed.empty()) { AddDataToCache(module_type); + FilterDisabledModuleData(module_type); } typedef std::vector AppPtrs; AppPtrs apps = RCRPCPlugin::GetRCApplications(application_manager_); -- cgit v1.2.1 From 096951609edb5ddd0b35f537f0f1c63c8af0116b Mon Sep 17 00:00:00 2001 From: JackLivio Date: Fri, 12 Oct 2018 14:46:21 -0400 Subject: Remove filtering from onInteriorVehicle data. Add to GetInteriorVehicleData. --- .../mobile/get_interior_vehicle_data_request.h | 1 + .../mobile/on_interior_vehicle_data_notification.h | 1 - .../mobile/get_interior_vehicle_data_request.cc | 22 +++++++++++++++++ .../on_interior_vehicle_data_notification.cc | 28 ---------------------- 4 files changed, 23 insertions(+), 29 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h index 4624d79b56..01588cc6b7 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h @@ -94,6 +94,7 @@ class GetInteriorVehicleDataRequest : public RCCommandRequest { bool CheckRateLimits(); bool AppShouldBeUnsubscribed(); bool TheLastAppShouldBeUnsubscribed(app_mngr::ApplicationSharedPtr app); + void FilterDisabledModuleData(smart_objects::SmartObject& module_data); }; } // namespace commands } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h index ec764d37cd..931e79366c 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h @@ -60,7 +60,6 @@ class OnInteriorVehicleDataNotification private: InteriorDataCache& interior_data_cache_; void AddDataToCache(const std::string& module_type); - void FilterDisabledModuleData(const std::string& module_type); }; } // namespace commands } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc index 93e37b95a7..3550a72e23 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc @@ -89,11 +89,33 @@ bool GetInteriorVehicleDataRequest::ProcessCapabilities() { return true; } +void GetInteriorVehicleDataRequest::FilterDisabledModuleData(smart_objects::SmartObject& module_data) { + // If radioEnable is false, remove all other radio parameters from the + // message. + if (module_data.keyExists(message_params::kRadioEnable) && + module_data[message_params::kRadioEnable] == false) { + for (auto data = module_data.map_begin(); data != module_data.map_end(); + ++data) { + if (data->first != message_params::kRadioEnable) { + module_data.erase(data->first); + } + } + } + + // If hdRadioEnable is false, find and remove the HDChannel if parameter is + // present. + if (module_data.keyExists(message_params::kHdRadioEnable) && + module_data[message_params::kHdRadioEnable] == false) { + module_data.erase(message_params::kHdChannel); + } +} + void GetInteriorVehicleDataRequest::ProcessResponseToMobileFromCache( app_mngr::ApplicationSharedPtr app) { LOG4CXX_AUTO_TRACE(logger_); const auto& data_mapping = RCHelpers::GetModuleTypeToDataMapping(); auto data = interior_data_cache_.Retrieve(ModuleType()); + FilterDisabledModuleData(data); auto response_msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); response_msg_params[message_params::kModuleData][data_mapping(ModuleType())] = diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc index 7393c4f70e..37890b7979 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc @@ -63,33 +63,6 @@ void OnInteriorVehicleDataNotification::AddDataToCache( interior_data_cache_.Add(module_type, module_data); } -void OnInteriorVehicleDataNotification::FilterDisabledModuleData( - const std::string& module_type) { - const auto& data_mapping = RCHelpers::GetModuleTypeToDataMapping(); - auto& module_data = - (*message_)[app_mngr::strings::msg_params][message_params::kModuleData] - [data_mapping(module_type)]; - - // If radioEnable is false, remove all other radio parameters from the - // message. - if (module_data.keyExists(message_params::kRadioEnable) && - module_data[message_params::kRadioEnable] == false) { - for (auto data = module_data.map_begin(); data != module_data.map_end(); - ++data) { - if (data->first != message_params::kRadioEnable) { - module_data.erase(data->first); - } - } - } - - // If hdRadioEnable is false, find and remove the HDChannel if parameter is - // present. - if (module_data.keyExists(message_params::kHdRadioEnable) && - module_data[message_params::kHdRadioEnable] == false) { - module_data.erase(message_params::kHdChannel); - } -} - void OnInteriorVehicleDataNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); @@ -98,7 +71,6 @@ void OnInteriorVehicleDataNotification::Run() { RCHelpers::AppsSubscribedToModuleType(application_manager_, module_type); if (!apps_subscribed.empty()) { AddDataToCache(module_type); - FilterDisabledModuleData(module_type); } typedef std::vector AppPtrs; AppPtrs apps = RCRPCPlugin::GetRCApplications(application_manager_); -- cgit v1.2.1 From af73f1fbe063e8afaa57edd0146166ae2b5e86d6 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Fri, 12 Oct 2018 15:09:59 -0400 Subject: Style --- .../src/commands/mobile/get_interior_vehicle_data_request.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc index 3550a72e23..81573600c2 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc @@ -89,7 +89,8 @@ bool GetInteriorVehicleDataRequest::ProcessCapabilities() { return true; } -void GetInteriorVehicleDataRequest::FilterDisabledModuleData(smart_objects::SmartObject& module_data) { +void GetInteriorVehicleDataRequest::FilterDisabledModuleData( + smart_objects::SmartObject& module_data) { // If radioEnable is false, remove all other radio parameters from the // message. if (module_data.keyExists(message_params::kRadioEnable) && @@ -101,7 +102,6 @@ void GetInteriorVehicleDataRequest::FilterDisabledModuleData(smart_objects::Smar } } } - // If hdRadioEnable is false, find and remove the HDChannel if parameter is // present. if (module_data.keyExists(message_params::kHdRadioEnable) && -- cgit v1.2.1 From 5aa5123c5b13f3acd024f720a1d3367e371911c4 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Fri, 12 Oct 2018 16:12:58 -0400 Subject: Add asBool() --- .../src/commands/mobile/get_interior_vehicle_data_request.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc index 81573600c2..f5077d4826 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc @@ -94,7 +94,7 @@ void GetInteriorVehicleDataRequest::FilterDisabledModuleData( // If radioEnable is false, remove all other radio parameters from the // message. if (module_data.keyExists(message_params::kRadioEnable) && - module_data[message_params::kRadioEnable] == false) { + module_data[message_params::kRadioEnable].asBool() == false) { for (auto data = module_data.map_begin(); data != module_data.map_end(); ++data) { if (data->first != message_params::kRadioEnable) { @@ -105,7 +105,7 @@ void GetInteriorVehicleDataRequest::FilterDisabledModuleData( // If hdRadioEnable is false, find and remove the HDChannel if parameter is // present. if (module_data.keyExists(message_params::kHdRadioEnable) && - module_data[message_params::kHdRadioEnable] == false) { + module_data[message_params::kHdRadioEnable].asBool() == false) { module_data.erase(message_params::kHdChannel); } } -- cgit v1.2.1 From de54a96dbf1d1463ce5413e070a8a73fb832b572 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Fri, 12 Oct 2018 16:22:47 -0400 Subject: Ensure erase does not invalidate iterator --- .../src/commands/mobile/get_interior_vehicle_data_request.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc index f5077d4826..3afa2f040c 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc @@ -95,10 +95,11 @@ void GetInteriorVehicleDataRequest::FilterDisabledModuleData( // message. if (module_data.keyExists(message_params::kRadioEnable) && module_data[message_params::kRadioEnable].asBool() == false) { - for (auto data = module_data.map_begin(); data != module_data.map_end(); - ++data) { - if (data->first != message_params::kRadioEnable) { - module_data.erase(data->first); + for (auto data = module_data.map_begin(); data != module_data.map_end();) { + auto key = data->first; + ++data; + if (key != message_params::kRadioEnable) { + module_data.erase(key); } } } -- cgit v1.2.1 From 386633b6f4381d036cc425e1e42aa5ed6ef320a8 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Mon, 15 Oct 2018 11:11:11 -0400 Subject: Filter AvailableHDs and SisData --- .../src/commands/mobile/get_interior_vehicle_data_request.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc index 3afa2f040c..4d12b4f375 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc @@ -108,6 +108,8 @@ void GetInteriorVehicleDataRequest::FilterDisabledModuleData( if (module_data.keyExists(message_params::kHdRadioEnable) && module_data[message_params::kHdRadioEnable].asBool() == false) { module_data.erase(message_params::kHdChannel); + module_data.erase(message_params::kAvailableHDs); + module_data.erase(message_params::kSisData); } } -- cgit v1.2.1 From c751be354395d109c2d1105d290e92ae8b29ec3d Mon Sep 17 00:00:00 2001 From: JackLivio Date: Mon, 15 Oct 2018 14:56:09 -0400 Subject: Update versioning logic to check for < version 5.0.0 --- .../src/commands/mobile/on_button_event_notification.cc | 2 +- .../src/commands/mobile/on_button_press_notification.cc | 2 +- .../src/commands/mobile/register_app_interface_request.cc | 4 ++-- .../src/commands/mobile/register_app_interface_response.cc | 2 +- .../sdl_rpc_plugin/src/commands/mobile/subscribe_button_request.cc | 2 +- .../sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_request.cc | 2 +- src/components/application_manager/src/rpc_handler_impl.cc | 2 +- src/components/include/utils/semantic_version.h | 1 + src/components/utils/src/semantic_version.cc | 1 + 9 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_event_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_event_notification.cc index 911d7faaff..79fb1f4272 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_event_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_event_notification.cc @@ -166,7 +166,7 @@ void OnButtonEventNotification::SendButtonEvent(ApplicationConstSharedPtr app) { (*message_)[strings::msg_params][hmi_response::button_name].asInt()); if (btn_id == mobile_apis::ButtonName::PLAY_PAUSE && - app->msg_version() <= utils::base_rpc_version) { + app->msg_version() < utils::rpc_version_5) { btn_id = mobile_apis::ButtonName::OK; } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_press_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_press_notification.cc index 9ca662389d..c73f2b4b98 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_press_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_press_notification.cc @@ -174,7 +174,7 @@ void OnButtonPressNotification::SendButtonPress(ApplicationConstSharedPtr app) { (*message_)[strings::msg_params][hmi_response::button_name].asInt()); if (btn_id == mobile_apis::ButtonName::PLAY_PAUSE && - app->msg_version() <= utils::base_rpc_version) { + app->msg_version() < utils::rpc_version_5) { btn_id = mobile_apis::ButtonName::OK; } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc index bc36b85db3..7957d9e055 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc @@ -334,9 +334,9 @@ void RegisterAppInterfaceRequest::Run() { // Version negotiation utils::SemanticVersion module_version( major_version, minor_version, patch_version); - if (mobile_version <= utils::base_rpc_version) { + if (mobile_version < utils::rpc_version_5) { // Mobile versioning did not exist for - // versions 4.5 and prior. + // versions before 5.0 application->set_msg_version(utils::base_rpc_version); } else if (mobile_version < module_version) { // Use mobile RPC version as negotiated version diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_response.cc index 3972aab3a8..584d7db075 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_response.cc @@ -63,7 +63,7 @@ void RegisterAppInterfaceResponse::Run() { application_manager::ApplicationSharedPtr app = application_manager_.application(connection_key()); - if (app && app->msg_version() <= utils::base_rpc_version && + if (app && app->msg_version() < utils::rpc_version_5 && app->is_media_application() && (*message_)[strings::msg_params].keyExists( hmi_response::button_capabilities)) { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_request.cc index 7ee15d9119..f76b6ab210 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_request.cc @@ -77,7 +77,7 @@ void SubscribeButtonRequest::Run() { return; } - if (app->msg_version() <= utils::base_rpc_version && + if (app->msg_version() < utils::rpc_version_5 && btn_id == mobile_apis::ButtonName::OK && app->is_media_application()) { bool ok_supported = CheckHMICapabilities(mobile_apis::ButtonName::OK); bool play_pause_supported = diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_request.cc index f914182e5b..0c30f567b4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_request.cc @@ -72,7 +72,7 @@ void UnsubscribeButtonRequest::Run() { static_cast( (*message_)[str::msg_params][str::button_name].asInt()); - if (app->msg_version() <= utils::base_rpc_version && + if (app->msg_version() < utils::rpc_version_5 && btn_id == mobile_apis::ButtonName::OK && app->is_media_application()) { bool ok_supported = CheckHMICapabilities(mobile_apis::ButtonName::OK); bool play_pause_supported = diff --git a/src/components/application_manager/src/rpc_handler_impl.cc b/src/components/application_manager/src/rpc_handler_impl.cc index a33da0708f..939b3d1ce6 100644 --- a/src/components/application_manager/src/rpc_handler_impl.cc +++ b/src/components/application_manager/src/rpc_handler_impl.cc @@ -219,7 +219,7 @@ void RPCHandlerImpl::GetMessageVersion( } utils::SemanticVersion temp_version(major, minor, patch); if (temp_version.isValid()) { - message_version = (temp_version > utils::base_rpc_version) + message_version = (temp_version >= utils::rpc_version_5) ? temp_version : utils::base_rpc_version; } diff --git a/src/components/include/utils/semantic_version.h b/src/components/include/utils/semantic_version.h index ecd7a98de2..5fe7ce1deb 100644 --- a/src/components/include/utils/semantic_version.h +++ b/src/components/include/utils/semantic_version.h @@ -119,6 +119,7 @@ struct SemanticVersion { }; extern const SemanticVersion base_rpc_version; +extern const SemanticVersion rpc_version_5; } #endif // SRC_COMPONENTS_INCLUDE_UTILS_CALLABLE_H \ No newline at end of file diff --git a/src/components/utils/src/semantic_version.cc b/src/components/utils/src/semantic_version.cc index b7cf818791..9f0991e991 100644 --- a/src/components/utils/src/semantic_version.cc +++ b/src/components/utils/src/semantic_version.cc @@ -34,5 +34,6 @@ namespace utils { const SemanticVersion base_rpc_version(4, 5, 1); +const SemanticVersion rpc_version_5(5, 0, 0); } // namespace utils \ No newline at end of file -- cgit v1.2.1 From 3f37ee5c1c1f3a97b98b6dc4bfb1a20444d3b8dd Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 12 Oct 2018 16:19:45 +0000 Subject: Load module types from referecced group for app_policies If appllication have default policies, sqldb does not store module types for this application separately. During loading db SDL should check that application have default policies and select from module_types sql table sing "default" key but not appid key. In function `GatherApplicationPoliciesSection` already exist check for default policies : ``` if (IsDefaultPolicy(app_id)) { (*policies).apps[app_id].set_to_string(kDefaultId); } ``` Its setup stringified representation of application policies : "default". This stringified reference ("default") used for select module type. Fixes : https://github.com/smartdevicelink/sdl_core/issues/2670 --- .../policy_regular/src/sql_pt_representation.cc | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) 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 4f5dbc4c3b..bb08dd185b 100644 --- a/src/components/policy/policy_regular/src/sql_pt_representation.cc +++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc @@ -692,6 +692,7 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( while (query.Next()) { rpc::Nullable params; const std::string& app_id = query.GetString(0); + if (IsApplicationRevoked(app_id)) { params.set_to_null(); (*policies).apps[app_id] = params; @@ -720,29 +721,35 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( if (!query.IsNull(3)) { *params.certificate = query.GetString(4); } - if (!GatherAppGroup(app_id, ¶ms.groups)) { + + const auto& gather_app_id = ((*policies).apps[app_id].is_string()) + ? (*policies).apps[app_id].get_string() + : app_id; + + if (!GatherAppGroup(gather_app_id, ¶ms.groups)) { return false; } bool denied = false; - if (!GatherRemoteControlDenied(app_id, &denied)) { + if (!GatherRemoteControlDenied(gather_app_id, &denied)) { return false; } if (!denied) { - if (!GatherModuleType(app_id, &*params.moduleType)) { + // Module types should be selected from db by referenced groups + if (!GatherModuleType(gather_app_id, &*params.moduleType)) { return false; } } - if (!GatherNickName(app_id, &*params.nicknames)) { + if (!GatherNickName(gather_app_id, &*params.nicknames)) { return false; } - if (!GatherAppType(app_id, &*params.AppHMIType)) { + if (!GatherAppType(gather_app_id, &*params.AppHMIType)) { return false; } - if (!GatherRequestType(app_id, &*params.RequestType)) { + if (!GatherRequestType(gather_app_id, &*params.RequestType)) { return false; } - if (!GatherRequestSubType(app_id, &*params.RequestSubType)) { + if (!GatherRequestSubType(gather_app_id, &*params.RequestSubType)) { return false; } -- cgit v1.2.1 From 9694a31e9090f6f6fc95a525e237956d7a66e33b Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 15 Oct 2018 20:04:04 +0000 Subject: Gather app_policies with right key for external fixup! Gather app_policies with right key for external --- .../src/sql_pt_ext_representation.cc | 22 ++++++++++++++-------- .../policy_external/src/sql_pt_representation.cc | 20 +++++++++++++------- .../policy_regular/src/sql_pt_representation.cc | 3 ++- 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc index 248372beff..a43b22a3b8 100644 --- a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc @@ -874,33 +874,39 @@ bool SQLPTExtRepresentation::GatherApplicationPoliciesSection( *params.memory_kb = query.GetInteger(5); *params.heart_beat_timeout_ms = query.GetUInteger(6); - if (!GatherAppGroup(app_id, ¶ms.groups)) { + const auto& gather_app_id = ((*policies).apps[app_id].is_string()) + ? (*policies).apps[app_id].get_string() + : app_id; + // Data should be gathered from db by "default" key if application has + // default policies + + if (!GatherAppGroup(gather_app_id, ¶ms.groups)) { return false; } bool denied = false; - if (!GatherRemoteControlDenied(app_id, &denied)) { + if (!GatherRemoteControlDenied(gather_app_id, &denied)) { return false; } if (!denied) { - if (!GatherModuleType(app_id, &*params.moduleType)) { + if (!GatherModuleType(gather_app_id, &*params.moduleType)) { return false; } } - if (!GatherNickName(app_id, &*params.nicknames)) { + if (!GatherNickName(gather_app_id, &*params.nicknames)) { return false; } - if (!GatherAppType(app_id, &*params.AppHMIType)) { + if (!GatherAppType(gather_app_id, &*params.AppHMIType)) { return false; } - if (!GatherRequestType(app_id, &*params.RequestType)) { + if (!GatherRequestType(gather_app_id, &*params.RequestType)) { return false; } - if (!GatherRequestSubType(app_id, &*params.RequestSubType)) { + if (!GatherRequestSubType(gather_app_id, &*params.RequestSubType)) { return false; } - GatherPreconsentedGroup(app_id, &*params.preconsented_groups); + GatherPreconsentedGroup(gather_app_id, &*params.preconsented_groups); (*policies).apps[app_id] = params; } return true; diff --git a/src/components/policy/policy_external/src/sql_pt_representation.cc b/src/components/policy/policy_external/src/sql_pt_representation.cc index 31c69e3725..c8b367c8ec 100644 --- a/src/components/policy/policy_external/src/sql_pt_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_representation.cc @@ -761,30 +761,36 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( *params.memory_kb = query.GetInteger(2); *params.heart_beat_timeout_ms = query.GetUInteger(3); - if (!GatherAppGroup(app_id, ¶ms.groups)) { + const auto& gather_app_id = ((*policies).apps[app_id].is_string()) + ? (*policies).apps[app_id].get_string() + : app_id; + // Data should be gathered from db by "default" key if application has + // default policies + + if (!GatherAppGroup(gather_app_id, ¶ms.groups)) { return false; } bool denied = false; - if (!GatherRemoteControlDenied(app_id, &denied)) { + if (!GatherRemoteControlDenied(gather_app_id, &denied)) { return false; } if (!denied) { - if (!GatherModuleType(app_id, &*params.moduleType)) { + if (!GatherModuleType(gather_app_id, &*params.moduleType)) { return false; } } - if (!GatherNickName(app_id, &*params.nicknames)) { + if (!GatherNickName(gather_app_id, &*params.nicknames)) { return false; } - if (!GatherAppType(app_id, &*params.AppHMIType)) { + if (!GatherAppType(gather_app_id, &*params.AppHMIType)) { return false; } - if (!GatherRequestType(app_id, &*params.RequestType)) { + if (!GatherRequestType(gather_app_id, &*params.RequestType)) { return false; } - if (!GatherRequestSubType(app_id, &*params.RequestSubType)) { + if (!GatherRequestSubType(gather_app_id, &*params.RequestSubType)) { return false; } 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 bb08dd185b..75f8be74eb 100644 --- a/src/components/policy/policy_regular/src/sql_pt_representation.cc +++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc @@ -725,6 +725,8 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( const auto& gather_app_id = ((*policies).apps[app_id].is_string()) ? (*policies).apps[app_id].get_string() : app_id; + // Data should be gathered from db by "default" key if application has + // default policies if (!GatherAppGroup(gather_app_id, ¶ms.groups)) { return false; @@ -734,7 +736,6 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( return false; } if (!denied) { - // Module types should be selected from db by referenced groups if (!GatherModuleType(gather_app_id, &*params.moduleType)) { return false; } -- cgit v1.2.1 From e7e56b24918da119a025bd0787150c008f000798 Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 15 Oct 2018 19:31:15 +0000 Subject: Remove redundant unused source files to avoid confusing betwen polcy regular and policy external Remove ext --- .../policy/policy_regular/CMakeLists.txt | 2 - .../policy_regular/include/policy/cache_manager.h | 1 - .../policy_regular/include/policy/policy_table.h | 1 - .../include/policy/pt_ext_representation.h | 336 ---- .../include/policy/sql_pt_ext_queries.h | 97 -- .../include/policy/sql_pt_ext_representation.h | 206 --- .../policy_regular/policy_table_interface_ext.xml | 284 --- .../policy_regular/src/sql_pt_ext_queries.cc | 268 --- .../src/sql_pt_ext_representation.cc | 1807 -------------------- .../include/policy/mock_pt_ext_representation.h | 139 -- 10 files changed, 3141 deletions(-) delete mode 100644 src/components/policy/policy_regular/include/policy/pt_ext_representation.h delete mode 100644 src/components/policy/policy_regular/include/policy/sql_pt_ext_queries.h delete mode 100644 src/components/policy/policy_regular/include/policy/sql_pt_ext_representation.h delete mode 100644 src/components/policy/policy_regular/policy_table_interface_ext.xml delete mode 100644 src/components/policy/policy_regular/src/sql_pt_ext_queries.cc delete mode 100644 src/components/policy/policy_regular/src/sql_pt_ext_representation.cc delete mode 100644 src/components/policy/policy_regular/test/include/policy/mock_pt_ext_representation.h diff --git a/src/components/policy/policy_regular/CMakeLists.txt b/src/components/policy/policy_regular/CMakeLists.txt index 225e99329a..a5533302a5 100644 --- a/src/components/policy/policy_regular/CMakeLists.txt +++ b/src/components/policy/policy_regular/CMakeLists.txt @@ -60,8 +60,6 @@ target_link_libraries(UsageStatistics Utils) set(EXCLUDE_PATHS ${POLICY_TABLE_PATHS} ${USAGE_STATISTICS_PATHS} - sql_pt_ext_queries.cc - sql_pt_ext_representation.cc ) set(PATHS 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 a28f1b3461..48e00f7049 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager.h @@ -36,7 +36,6 @@ #include #include "policy/pt_representation.h" -#include "policy/pt_ext_representation.h" #include "policy/usage_statistics/statistics_manager.h" #include "policy/cache_manager_interface.h" #include "utils/threads/thread.h" diff --git a/src/components/policy/policy_regular/include/policy/policy_table.h b/src/components/policy/policy_regular/include/policy/policy_table.h index 353cdda871..8ef3cd7fc8 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table.h +++ b/src/components/policy/policy_regular/include/policy/policy_table.h @@ -34,7 +34,6 @@ #define SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_POLICY_TABLE_H_ #include "policy/pt_representation.h" -#include "policy/pt_ext_representation.h" namespace policy { diff --git a/src/components/policy/policy_regular/include/policy/pt_ext_representation.h b/src/components/policy/policy_regular/include/policy/pt_ext_representation.h deleted file mode 100644 index f70946d1f5..0000000000 --- a/src/components/policy/policy_regular/include/policy/pt_ext_representation.h +++ /dev/null @@ -1,336 +0,0 @@ -/* - Copyright (c) 2013, Ford Motor Company - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_PT_EXT_REPRESENTATION_H_ -#define SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_PT_EXT_REPRESENTATION_H_ - -#include "policy/pt_representation.h" - -namespace policy { - -enum StatisticsType { - S_NONE = 0, - S_IAP_BUFFER_FULL, - S_SYNC_OUT_OF_MEMORY, - S_SYNC_REBOOTS, - S_MINS_HMI_FULL, - S_MINS_HMI_LIMITED, - S_MINS_HMI_BACKGROUND, - S_MINS_HMI_NONE, - S_RFCOM_LIMIT_REACHED, - S_USER_SELECTIONS, - S_REJECTIONS_SYNC_OUT_OF_MEMORY, - S_REJECTIONS_NICKNAME_MISMATCH, - S_REJECTIONS_DUPLICATE_NAME, - S_REJECTED_RPC_CALLS, - S_RPCS_IN_HMI_NONE, - S_REMOVALS_MISBEHAVED, - S_RUN_ATTEMPTS_WHILE_REVOKED -}; - -enum LanguageType { L_NONE = 0, L_GUI, L_VUI }; - -class PTExtRepresentation : public virtual PTRepresentation { - public: - virtual ~PTExtRepresentation() {} - - /** - * @brief Is application allowed to send notifications while in - * Backgound or limited mode. - * @param app_id Application id - * @return bool Allowed/disallowed. - */ - virtual bool CanAppKeepContext(const std::string& app_id) = 0; - - /** - * @brief Is application allowed to move foreground at will? - * @param app_id Application id - * @return bool Allowed/disallowed. - */ - virtual bool CanAppStealFocus(const std::string& app_id) = 0; - - /** - * @brief Get default_hmi for given application - * @param policy_app_id Unique application id - * @param default_hmi Default HMI level for application or empty, if value was - * not set - * @return true, if succedeed, otherwise - false - */ - virtual bool GetDefaultHMI(const std::string& policy_app_id, - std::string* default_hmi) = 0; - - /** - * @brief Reset user consent for device data and applications permissions - * @return - */ - virtual bool ResetUserConsent() = 0; - - /** - * @brief Reset user consent for device data - * @return - */ - virtual bool ResetDeviceConsents() = 0; - - /** - * @brief Reset user consent for applications permissions - * @return - */ - virtual bool ResetAppConsents() = 0; - - /** - * @brief Get user permissions for device data usage - * @param device_id Generated or obtained id of device - * @param consented_groups Groups consented by user - * @param disallowed_groups Groups not consented by user - * @return true, if query was successfull, otherwise - false - */ - virtual bool GetUserPermissionsForDevice( - const std::string& device_id, - StringArray* consented_groups = NULL, - StringArray* disallowed_groups = NULL) = 0; - - /** - * @brief Gets list of groups permissions from policy table - * @param device_id Unique device id, which hosts specific application - * @param policy_app_id Unique application id - * @param group_types Group list sorted by permission status - * @return true, if query was successfull, otherwise - false - */ - virtual bool GetPermissionsForApp(const std::string& device_id, - const std::string& policy_app_id, - FunctionalIdType* group_types) = 0; - - /** - * @brief Get device groups and preconsented groups from policies section - * @param groups List of groups to be consented for device usage - * @param preconsented_groups List of preconsented groups for device usage - * @return true, if query was successful, otherwise - false - */ - virtual bool GetDeviceGroupsFromPolicies( - policy_table::Strings* groups = NULL, - policy_table::Strings* preconsented_groups = NULL) = 0; - - /** - * @brief Record information about mobile device in Policy Table. - * @param device_id Generated or obtained id of device - * @return bool Success of operation - */ - virtual bool SetDeviceData(const std::string& device_id, - const std::string& hardware = "", - const std::string& firmware = "", - const std::string& os = "", - const std::string& os_version = "", - const std::string& carrier = "", - const uint32_t number_of_ports = 0, - const std::string& connection_type = "") = 0; - - /** - * @brief Sets user consent for particular mobile device, - * i.e. to use device for exchanging of Policy Table. - * @return bool Success of operation - */ - virtual bool SetUserPermissionsForDevice( - const std::string& device_id, - const StringArray& consented_groups = StringArray(), - const StringArray& disallowed_gropus = StringArray()) = 0; - - /** - * @brief Update Application Policies as reaction - * on User allowing/disallowing device this app is running on. - */ - virtual bool ReactOnUserDevConsentForApp(const std::string& app_id, - bool is_device_allowed) = 0; - - /** - * @brief Set user consent on functional groups - * @param permissions User consent on functional group - * @return true, if operation succedeed, otherwise - false - */ - virtual bool SetUserPermissionsForApp( - const PermissionConsent& permissions) = 0; - - /** - * @brief Counter for statistics information: adds 1 to existing number. - * @param type Type of statistics (errors, mins in mode etc) - * @return bool Success of operation - */ - virtual bool IncreaseStatisticsData(StatisticsType type) = 0; - - /** - * @brief Records information about what language - * application tried to register with. - * @param app_id Id of application - * @param type - language for UI/VR - * @param language Language - * @return bool Success of operation - */ - virtual bool SetAppRegistrationLanguage(const std::string& app_id, - LanguageType type, - const std::string& language) = 0; - - /** - * @brief Records information about head unit system to PT - * @return bool Success of operation - */ - virtual bool SetMetaInfo(const std::string& ccpu_version, - const std::string& wers_country_code, - const std::string& language) = 0; - - /** - * @brief Checks, if specific head unit is present in PT - * @return boot Suceess, if present, otherwise - false - */ - virtual bool IsMetaInfoPresent() = 0; - - /** - * @brief Kms pass since last successfull PT update - */ - virtual int GetKmFromSuccessfulExchange() = 0; - - /** - * @brief Days pass since last successfull PT update - */ - virtual int GetDayFromScsExchange() = 0; - - /** - * @brief Ignition cycles pass since last successfull PT update - */ - virtual int GetIgnitionsFromScsExchange() = 0; - - /** - * @brief Set current system language - * @param language System language - * @return true, if succedeed, otherwise - false - */ - virtual bool SetSystemLanguage(const std::string& language) = 0; - - /** - * Increments global counter - * @param type type of counter - */ - virtual void Increment(const std::string& type) const = 0; - - /** - * Increments counter of application - * @param app_id id application - * @param type type of counter - */ - virtual void Increment(const std::string& app_id, - const std::string& type) const = 0; - - /** - * Sets value of application information - * @param app_id id application - * @param type type of information - * @param value value of information - */ - virtual void Set(const std::string& app_id, - const std::string& type, - const std::string& value) const = 0; - - /** - * Adds value to stopwatch of application - * @param app_id id application - * @param type type of stopwatch - * @param seconds value for adding in seconds - */ - virtual void Add(const std::string& app_id, - const std::string& type, - int seconds) const = 0; - - virtual bool CountUnconsentedGroups(const std::string& policy_app_id, - const std::string& device_id, - int* result) const = 0; - - /** - * @brief Gets functional group names and user_consent_prompts, if any - * @param Array to be filled with group ids, names and functional prompts - * @return true, if succeeded, otherwise - false - */ - // TODO(AOleynik): Possibly, we can get rid of this method. Check this. - virtual bool GetFunctionalGroupNames(policy::FunctionalGroupNames& names) = 0; - - /** - * @brief Set app policy to pre_DataConsented policy - * @param app_id Policy ID of application to be changed - * @return true, if succeeded, otherwise - false - */ - virtual bool SetPredataPolicy(const std::string& app_id) = 0; - - /** - * @brief Updates application policy to either pre_DataConsented or not - * @param app_id Policy Id of application to be checked - * @param is_pre_data True of False to setting app policy to be - * pre_DataConsented - * @return true, if succeeded, otherwise - false - */ - virtual bool SetIsPredata(const std::string& app_id, bool is_pre_data) = 0; - - /** - * @brief Removes unpaired devices - * @return true if success - */ - virtual bool CleanupUnpairedDevices(const DeviceIds& device_ids) const = 0; - - /** - * Sets flag of unpaired device - * @param device_id Unique device id - * @param unpaired True, if unpaired, otherwise - false - * @return true if success - */ - virtual bool SetUnpairedDevice(const std::string& device_id, - bool unpaired) const = 0; - - /** - * Gets list of unpaired devices - * @param device_ids output list - * @return true if success - */ - virtual bool UnpairedDevicesList(DeviceIds* device_ids) const = 0; - - /** - * @brief Remove application consent for particular group - * @param policy_app_id Unique application id - * @param functional_group_name Functional group name, which consents should - * be removed - * @return true, in case of success, otherwise - false - */ - virtual bool RemoveAppConsentForGroup( - const std::string& policy_app_id, - const std::string& functional_group_name) const = 0; - virtual bool SaveExternalConsentStatus( - const ExternalConsentStatus& status) const = 0; - virtual ExternalConsentStatus GetExternalConsentStatus() const = 0; -}; -} // namespace policy - -#endif // SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_PT_EXT_REPRESENTATION_H_ diff --git a/src/components/policy/policy_regular/include/policy/sql_pt_ext_queries.h b/src/components/policy/policy_regular/include/policy/sql_pt_ext_queries.h deleted file mode 100644 index 727c0b165d..0000000000 --- a/src/components/policy/policy_regular/include/policy/sql_pt_ext_queries.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - Copyright (c) 2013, " Ford Motor Company - All rights reserved. - - Redistribution and use in source and binary forms, " with or without - modification, " are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, " this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, " - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, " INCLUDING, " BUT NOT LIMITED TO, " THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, " INDIRECT, " INCIDENTAL, " SPECIAL, " EXEMPLARY, " OR - CONSEQUENTIAL DAMAGES (INCLUDING, " BUT NOT LIMITED TO, " PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, " DATA, " OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, " WHETHER IN - CONTRACT, " STRICT LIABILITY, " OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, " EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_SQL_PT_EXT_QUERIES_H_ -#define SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_SQL_PT_EXT_QUERIES_H_ - -#include - -namespace policy { -namespace sql_pt_ext { - -extern const std::string kSelectKeepContext; -extern const std::string kSelectStealFocus; -extern const std::string kResetDeviceConsents; -extern const std::string kResetAppConsents; -extern const std::string kCountDeviceConsentGroup; -extern const std::string kCountDevice; -extern const std::string kSelectDeviceConsentedGroup; -extern const std::string kUpdateDeviceConsentedGroup; -extern const std::string kUpdateDevice; -extern const std::string kInsertDeviceConsentedGroup; -extern const std::string kInsertDevice; -extern const std::string kSelectDeviceData; -extern const std::string kSelectConsentGroup; -extern const std::string kInsertPreconsentedGroups; -extern const std::string kSelectPreconsentedGroups; -extern const std::string kDeletePreconsentedGroups; -extern const std::string kSelectUsageAndErrorCount; -extern const std::string kSelectAppLevels; -extern const std::string kUpdateGlobalCounters; -extern const std::string kInsertDeviceData; -extern const std::string kDeleteDeviceData; -extern const std::string kInsertConsentGroups; -extern const std::string kCountUnconsentedGroups; -extern const std::string kSelectModuleMeta; -extern const std::string kUpdateMetaParams; -extern const std::string kUpdateModuleMetaVinParam; -extern const std::string kSaveModuleMeta; -extern const std::string kSelectMetaParams; -extern const std::string kCountAppLevel; -extern const std::string kUpdateGroupPermissions; -extern const std::string kSelectDefaultHmi; -extern const std::string kInsertApplication; -extern const std::string kSelectFriendlyMsg; -extern const std::string kCollectFriendlyMsg; -extern const std::string kSelectAppGroupsId; -extern const std::string kSelectConsentedGroupsId; -extern const std::string kCountAppConsents; -extern const std::string kSelectPreconsentedGroupsId; -extern const std::string kSelectFunctionalGroupNames; -extern const std::string kSelectAppPolicies; -extern const std::string kUpdateMetaLanguage; -extern const std::string kDeleteDeviceConsent; -extern const std::string kDeleteAppGroupConsent; -extern const std::string kSelectGroupId; -extern const std::string kSelectApplicationIsPreData; -extern const std::string kUpdateIsPredata; -extern const std::string kHasAppPreloadedGroups; -extern const std::string kUpdateUnpairedDevice; -extern const std::string kSelectUnpairedDevices; -extern const std::string kHasMsgLanguageCode; -extern const std::string kDeletePreconsentedGroupsByApplicationId; -extern const std::string kDeleteAppConsent; -extern const std::string kSelectExternalConsentStatus; -} // namespace sql_pt_ext -} // namespace policy - -#endif // SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_SQL_PT_EXT_QUERIES_H_ diff --git a/src/components/policy/policy_regular/include/policy/sql_pt_ext_representation.h b/src/components/policy/policy_regular/include/policy/sql_pt_ext_representation.h deleted file mode 100644 index 0958bad5e1..0000000000 --- a/src/components/policy/policy_regular/include/policy/sql_pt_ext_representation.h +++ /dev/null @@ -1,206 +0,0 @@ -/* - Copyright (c) 2013, Ford Motor Company - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_SQL_PT_EXT_REPRESENTATION_H_ -#define SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_SQL_PT_EXT_REPRESENTATION_H_ - -#include -#include "policy/sql_pt_representation.h" -#include "policy/pt_ext_representation.h" - -namespace policy { - -class SQLPTExtRepresentation : public SQLPTRepresentation, - public PTExtRepresentation { - public: - bool CanAppKeepContext(const std::string& app_id); - bool CanAppStealFocus(const std::string& app_id); - bool GetDefaultHMI(const std::string& policy_app_id, - std::string* default_hmi); - bool ResetUserConsent(); - bool ResetDeviceConsents(); - bool ResetAppConsents(); - bool GetUserPermissionsForDevice(const std::string& device_id, - StringArray* consented_groups = NULL, - StringArray* disallowed_groups = NULL); - - bool GetPermissionsForApp(const std::string& device_id, - const std::string& policy_app_id, - FunctionalIdType* group_types); - - bool GetDeviceGroupsFromPolicies( - policy_table::Strings* groups = NULL, - policy_table::Strings* preconsented_groups = NULL); - bool SetDeviceData(const std::string& device_id, - const std::string& hardware = "", - const std::string& firmware = "", - const std::string& os = "", - const std::string& os_version = "", - const std::string& carrier = "", - const uint32_t number_of_ports = 0, - const std::string& connection_type = ""); - bool SetUserPermissionsForDevice( - const std::string& device_id, - const StringArray& consented_groups = StringArray(), - const StringArray& disallowed_groups = StringArray()); - - bool ReactOnUserDevConsentForApp(const std::string& app_id, - bool is_device_allowed); - - bool SetUserPermissionsForApp(const PermissionConsent& permissions); - - std::vector GetUserFriendlyMsg( - const std::vector& msg_codes, const std::string& language); - - bool IncreaseStatisticsData(StatisticsType type) { - return true; - } - bool SetAppRegistrationLanguage(const std::string& app_id, - LanguageType type, - const std::string& language) { - return true; - } - - bool SetMetaInfo(const std::string& ccpu_version, - const std::string& wers_country_code, - const std::string& language); - - bool IsMetaInfoPresent(); - - bool SetSystemLanguage(const std::string& language); - - int GetKmFromSuccessfulExchange() { - return true; - } - int GetDayFromScsExchange() { - return true; - } - int GetIgnitionsFromScsExchange() { - return true; - } - - bool GetFunctionalGroupNames(FunctionalGroupNames& names); - bool CleanupUnpairedDevices(const DeviceIds& device_ids) const; - - void Increment(const std::string& type) const; - void Increment(const std::string& app_id, const std::string& type) const; - void Set(const std::string& app_id, - const std::string& type, - const std::string& value) const; - void Add(const std::string& app_id, - const std::string& type, - int seconds) const; - bool SetDefaultPolicy(const std::string& app_id); - bool SetPredataPolicy(const std::string& app_id); - bool SetIsPredata(const std::string& app_id, bool is_pre_data); - bool IsPredataPolicy(const std::string& app_id) const; - bool SetUnpairedDevice(const std::string& device_id, bool unpaired) const; - bool UnpairedDevicesList(DeviceIds* device_ids) const; - bool RemoveAppConsentForGroup(const std::string& policy_app_id, - const std::string& functional_group_name) const; - - virtual bool SetVINValue(const std::string& value); - bool SaveExternalConsentStatus(const ExternalConsentStatus& status) const; - ExternalConsentStatus GetExternalConsentStatus() const; - - private: - void GatherModuleMeta(policy_table::ModuleMeta* meta) const; - void GatherPreconsentedGroup(const std::string& app_id, - policy_table::Strings* groups) const; - bool GatherUsageAndErrorCounts( - policy_table::UsageAndErrorCounts* counts) const; - bool GatherAppLevels(policy_table::AppLevels* apps) const; - void GatherDeviceData(policy_table::DeviceData* data) const; - void GatherConsentGroup(const std::string& device_id, - policy_table::UserConsentRecords* records) const; - bool GatherApplicationPoliciesSection( - policy_table::ApplicationPoliciesSection* policies) const; - bool SaveDeviceData(const policy_table::DeviceData& devices); - bool GatherConsumerFriendlyMessages( - policy_table::ConsumerFriendlyMessages* messages) const; - bool SaveConsentGroup(const std::string& device_id, - const policy_table::UserConsentRecords& records); - bool SaveApplicationPoliciesSection( - const policy_table::ApplicationPoliciesSection& policies); - bool SaveSpecificAppPolicy( - const policy_table::ApplicationPolicies::value_type& app); - bool SaveDevicePolicy(const policy_table::DevicePolicy& device); - bool SavePreconsentedGroup(const std::string& app_id, - const policy_table::Strings& groups); - bool SaveMessageString(const std::string& type, - const std::string& lang, - const policy_table::MessageString& strings); - - virtual bool SaveUsageAndErrorCounts( - const policy_table::UsageAndErrorCounts& counts); - - virtual bool SaveModuleMeta(const policy_table::ModuleMeta& meta); - - bool SaveAppCounters(const policy_table::AppLevels& app_levels); - - bool SaveGlobalCounters(const policy_table::UsageAndErrorCounts& counts); - - bool IsExistAppLevel(const std::string& app_id) const; - - bool GetAllAppGroups(const std::string& policy_app_id, - FunctionalGroupIDs& all_groups); - - bool GetConsentedGroups(const std::string& policy_app_id, - const std::string& device_id, - FunctionalGroupIDs& allowed_groups, - FunctionalGroupIDs& disallowed_groups); - - bool GetPreconsentedGroups(const std::string& policy_app_id, - FunctionalGroupIDs& preconsented_groups); - - void FillFunctionalGroupPermissions( - FunctionalGroupIDs& ids, - FunctionalGroupNames& names, - GroupConsent state, - std::vector& permissions); - bool CountUnconsentedGroups(const std::string& policy_app_id, - const std::string& device_id, - int* result) const; - - /** - * @brief Checks, if there is message present with requested language in PT - * @param message Message name - * @param language Required message language - * @return True, if message with requested language is present, otherwise - - * false - */ - bool IsMsgLanguagePresent(const std::string& message, - const std::string& language); - -} // namespace policy - -#endif // SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_SQL_PT_EXT_REPRESENTATION_H_ diff --git a/src/components/policy/policy_regular/policy_table_interface_ext.xml b/src/components/policy/policy_regular/policy_table_interface_ext.xml deleted file mode 100644 index 7a751c0ea9..0000000000 --- a/src/components/policy/policy_regular/policy_table_interface_ext.xml +++ /dev/null @@ -1,284 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/components/policy/policy_regular/src/sql_pt_ext_queries.cc b/src/components/policy/policy_regular/src/sql_pt_ext_queries.cc deleted file mode 100644 index 3fde462a32..0000000000 --- a/src/components/policy/policy_regular/src/sql_pt_ext_queries.cc +++ /dev/null @@ -1,268 +0,0 @@ -/* - Copyright (c) 2013, " Ford Motor Company - All rights reserved. - - Redistribution and use in source and binary forms, " with or without - modification, " are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, " this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, " - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, " INCLUDING, " BUT NOT LIMITED TO, " THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, " INDIRECT, " INCIDENTAL, " SPECIAL, " EXEMPLARY, " OR - CONSEQUENTIAL DAMAGES (INCLUDING, " BUT NOT LIMITED TO, " PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, " DATA, " OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, " WHETHER IN - CONTRACT, " STRICT LIABILITY, " OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, " EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - */ - -#include "policy/sql_pt_ext_queries.h" - -namespace policy { -namespace sql_pt_ext { - -const std::string kSelectKeepContext = - "SELECT `keep_context` FROM `application` WHERE `id` = ? LIMIT 1"; - -const std::string kSelectStealFocus = - "SELECT `steal_focus` FROM `application` WHERE `id` = ? LIMIT 1"; - -const std::string kSelectDefaultHmi = - "SELECT `default_hmi` FROM `application` WHERE `id` = ? LIMIT 1"; - -const std::string kResetDeviceConsents = "DELETE FROM `device_consent_group`"; - -const std::string kResetAppConsents = "DELETE FROM `consent_group`"; - -const std::string kCountDeviceConsentGroup = - "SELECT COUNT (`device_id`) " - "FROM `device_consent_group` WHERE `device_id` = ?"; - -const std::string kCountDevice = - "SELECT COUNT (`id`) " - "FROM `device` WHERE `id` = ?"; - -const std::string kSelectDeviceConsentedGroup = - "SELECT * FROM `device_consent_group` WHERE `device_id` = ?"; - -const std::string kUpdateDeviceConsentedGroup = - "UPDATE `device_consent_group` SET `is_consented` = ?, `input` = ? WHERE " - "(`device_id` = ? AND `functional_group_id` = ?)"; - -const std::string kUpdateDevice = - "UPDATE `device` SET `hardware` = ?, `firmware_rev` = ?, `os` = ?, " - "`os_version` = ?, `carrier` = ?, `max_number_rfcom_ports` = ?, " - " `connection_type` = ? WHERE `id` = ? "; - -const std::string kInsertDeviceConsentedGroup = - "INSERT OR REPLACE INTO `device_consent_group` " - "(`device_id`, `functional_group_id`, `is_consented`, `input`, " - "`time_stamp`) " - "VALUES (?,?,?,?,?)"; - -const std::string kInsertDevice = - "INSERT OR IGNORE INTO `device` " - "(`id`, `hardware`, `firmware_rev`, `os`, `os_version`, `carrier`," - "`max_number_rfcom_ports`, `connection_type`) " - "VALUES (?,?,?,?,?,?,?,?)"; - -const std::string kSelectDeviceData = "SELECT * FROM `device`"; - -const std::string kSelectConsentGroup = - "SELECT * FROM `consent_group` WHERE `device_id` = ? "; - -const std::string kInsertPreconsentedGroups = - "INSERT INTO `preconsented_group` (`application_id`, `functional_group_id`)" - " SELECT ?, `id` FROM `functional_group` WHERE `name` = ? LIMIT 1"; - -const std::string kSelectPreconsentedGroups = - "SELECT `f`.`name` FROM `preconsented_group` AS `p`" - " LEFT JOIN `functional_group` AS `f` " - " ON (`f`.`id` = `p`.`functional_group_id`)" - " WHERE `p`.`application_id` = ?"; - -const std::string kDeletePreconsentedGroups = - "DELETE FROM `preconsented_group`"; - -const std::string kSelectUsageAndErrorCount = - "SELECT `count_of_iap_buffer_full`, `count_sync_out_of_memory`, " - " `count_of_sync_reboots` " - "FROM `usage_and_error_count` LIMIT 1"; - -const std::string kSelectAppLevels = - "SELECT `application_id`, `minutes_in_hmi_full`, `minutes_in_hmi_limited`, " - " `minutes_in_hmi_background`, `minutes_in_hmi_none`, " - " `count_of_user_selections`, " - " `count_of_rejections_sync_out_of_memory`, " - " `count_of_rejections_nickname_mismatch`, " - " `count_of_rejections_duplicate_name`, " - " `count_of_rejected_rpcs_calls`, " - " `count_of_rpcs_sent_in_hmi_none`, " - " `count_of_removals_for_bad_behavior`, " - " `count_of_run_attempts_while_revoked`, " - " `app_registration_language_gui`, " - " `app_registration_language_vui`, " - " `count_of_tls_errors` " - "FROM `app_level`"; - -const std::string kUpdateGlobalCounters = - "UPDATE `usage_and_error_count` SET " - "`count_of_iap_buffer_full` = ?, " - "`count_sync_out_of_memory` = ?, " - "`count_of_sync_reboots` = ? "; - -const std::string kInsertDeviceData = - "INSERT OR IGNORE INTO `device` " - "(`id`, `hardware`, `firmware_rev`, `os`, `os_version`, `carrier`, " - "`max_number_rfcom_ports`,`connection_type`) VALUES (?,?,?,?,?,?,?,?) "; - -const std::string kInsertConsentGroups = - "INSERT OR REPLACE INTO `consent_group` " - "(`device_id`, `application_id`, `functional_group_id`, `is_consented`, " - "`input`, `time_stamp`) " - "VALUES (?,?,?,?,?,?)"; - -const std::string kDeleteAppGroupConsent = - "DELETE FROM `consent_group` WHERE " - "`application_id` = ? AND `functional_group_id` = ? "; - -const std::string kSelectGroupId = - "SELECT `id` FROM `functional_group` WHERE `name` = ? "; - -const std::string kCountUnconsentedGroups = - "SELECT COUNT(`a`.`functional_group_id`) FROM `app_group` AS `a` " - " WHERE `a`.`application_id` = ? AND NOT EXISTS " - " (SELECT NULL FROM `preconsented_group` AS `p` WHERE " - " (`p`.`functional_group_id` = `a`.`functional_group_id` AND " - " `p`.`application_id` = `a`.`application_id`)) " - " AND NOT EXISTS (SELECT NULL FROM `consent_group` AS `c` " - " WHERE (`c`.`application_id` = `a`.`application_id` " - " AND `c`.`functional_group_id` = `a`.`functional_group_id` " - " AND `c`.`device_id` = ?)) AND NOT EXISTS " - " (SELECT NULL FROM `app_group` AS `def` WHERE " - " (`def`.`application_id` = ? OR " - " `def`.`application_id` = ?) " - " AND `def`.`functional_group_id` = `a`.`functional_group_id`)" - " AND NOT EXISTS (SELECT NULL FROM `functional_group` AS `f` " - " WHERE (`a`.`functional_group_id` = `f`.`id`" - " AND`f`.`user_consent_prompt` IS NULL))"; - -const std::string kSelectModuleMeta = "SELECT* FROM `module_meta`"; - -const std::string kUpdateMetaParams = - "UPDATE `module_meta` SET " - "`ccpu_version` = ?, `wers_country_code` = ?, `language` = ? "; - -const std::string kUpdateModuleMetaVinParam = - "UPDATE `module_meta` SET `vin` = ? "; - -const std::string kSaveModuleMeta = - "UPDATE `module_meta` SET `ccpu_version` = ?, `language` = ?," - "`wers_country_code` = ?, `pt_exchanged_at_odometer_x` = ?," - "`pt_exchanged_x_days_after_epoch` = ?," - "`ignition_cycles_since_last_exchange` = ?, `vin` = ?"; - -const std::string kSelectMetaParams = - "SELECT `ccpu_version`, " - "`wers_country_code`, `language` from `module_meta`"; - -const std::string kUpdateMetaLanguage = - "UPDATE `module_meta` SET `language` = ? "; - -const std::string kCountAppLevel = - "SELECT COUNT(`application_id`) FROM `app_level`" - " WHERE `application_id` = ? "; - -const std::string kUpdateGroupPermissions = - "UPDATE `consent_group` " - "SET `is_consented` = ?, `input` = ? " - "WHERE(`application_id` = ? AND `functional_group_id` = ? AND `device_id` " - "= ?) "; - -const std::string kInsertApplication = - "INSERT OR IGNORE INTO `application`(`id`, `keep_context`, `steal_focus`, " - " `default_hmi`, `priority_value`, `is_revoked`, `memory_kb`, " - " `heart_beat_timeout_ms`, `certificate`) VALUES( ?, ?, ?, ?, ?, ?, ?, ?, " - "?) "; - -const std::string kCollectFriendlyMsg = "SELECT * FROM `message`"; - -const std::string kSelectFriendlyMsg = - "SELECT `tts`, `label`, `line1`, `line2`, `textBody` FROM `message` " - "WHERE `message_type_name` = ? AND `language_code` = ? LIMIT 1"; - -const std::string kSelectAppGroupsId = - "SELECT `functional_group_id` " - "FROM `app_group` WHERE `application_id` = ? "; - -const std::string kSelectConsentedGroupsId = - "SELECT `functional_group_id`, `is_consented` " - "FROM `consent_group` WHERE(`application_id` = ? AND `device_id` = ?) "; - -const std::string kCountAppConsents = - "SELECT COUNT(*) from `consent_group`" - "WHERE(`device_id` = ? AND `application_id` = ? AND " - "`functional_group_id` = ?) "; - -const std::string kSelectPreconsentedGroupsId = - "SELECT `functional_group_id` " - "FROM `preconsented_group` WHERE `application_id` = ? "; - -const std::string kSelectAppPolicies = - "SELECT `id`, `priority_value`, `default_hmi`, `keep_context`, " - "`steal_focus`, " - " `memory_kb`, `heart_beat_timeout_ms`, `certificate` FROM `application`"; - -const std::string kSelectFunctionalGroupNames = - "SELECT `id`, `user_consent_prompt`, `name`" - " FROM `functional_group`"; - -const std::string kDeleteDeviceConsent = - "DELETE FROM `device_consent_group` " - "WHERE `device_id` = ? "; - -const std::string kDeleteAppConsent = - "DELETE FROM `consent_group` " - "WHERE `device_id` = ? "; - -const std::string kSelectApplicationIsPreData = - "SELECT `is_predata` FROM `application` WHERE `id` = ? "; - -const std::string kUpdateIsPredata = - "UPDATE `application` SET `is_predata` = ? WHERE `id` = ? "; - -const std::string kHasAppPreloadedGroups = - "SELECT COUNT(`a1`.`functional_group_id`) FROM `app_group` " - " AS `a1` JOIN `app_group` AS `a2` " - " ON `a1`.`functional_group_id` = `a2`.`functional_group_id` " - " WHERE `a1`.`application_id` = ? AND `a2`.`application_id` = ? "; - -const std::string kUpdateUnpairedDevice = - "UPDATE `device` SET `unpaired` = ? WHERE `id` = ? "; - -const std::string kSelectUnpairedDevices = - "SELECT `id` FROM `device` WHERE `unpaired` = 1"; - -const std::string kHasMsgLanguageCode = - "SELECT COUNT (`id`) FROM message " - "WHERE `message_type_name` = ? AND `language_code` = ? "; - -const std::string kDeletePreconsentedGroupsByApplicationId = - "DELETE FROM `preconsented_group` WHERE `application_id` = ?"; - -} // namespace sql_pt_ext -} // namespace policy diff --git a/src/components/policy/policy_regular/src/sql_pt_ext_representation.cc b/src/components/policy/policy_regular/src/sql_pt_ext_representation.cc deleted file mode 100644 index c64efaaede..0000000000 --- a/src/components/policy/policy_regular/src/sql_pt_ext_representation.cc +++ /dev/null @@ -1,1807 +0,0 @@ -/* - Copyright (c) 2015, Ford Motor Company - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - */ -#include -#include -#include "utils/logger.h" -#include "policy/sql_pt_ext_representation.h" -#include "policy/sql_wrapper.h" -#include "policy/sql_pt_queries.h" -#include "policy/sql_pt_ext_queries.h" -#include "policy/policy_helper.h" -#include "policy/cache_manager.h" - -namespace policy { - -CREATE_LOGGERPTR_GLOBAL(logger_, "Policy") - -bool SQLPTExtRepresentation::CanAppKeepContext(const std::string& app_id) { - utils::dbms::SQLQuery query(db()); - if (query.Prepare(sql_pt_ext::kSelectKeepContext)) { - query.Bind(0, app_id); - if (query.Exec()) { - return query.GetBoolean(0); - } - } - return false; -} - -bool SQLPTExtRepresentation::CanAppStealFocus(const std::string& app_id) { - utils::dbms::SQLQuery query(db()); - if (query.Prepare(sql_pt_ext::kSelectStealFocus)) { - query.Bind(0, app_id); - if (query.Exec()) { - return query.GetBoolean(0); - } - } - return false; -} - -bool SQLPTExtRepresentation::ResetUserConsent() { - return ResetDeviceConsents() && ResetAppConsents(); -} - -bool SQLPTExtRepresentation::ResetDeviceConsents() { - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt_ext::kResetDeviceConsents)) { - LOG4CXX_WARN(logger_, "Incorrect delete statement from device_consents."); - return false; - } - return query.Exec(); -} - -bool SQLPTExtRepresentation::ResetAppConsents() { - return utils::dbms::SQLQuery(db()).Exec(sql_pt_ext::kResetAppConsents); -} - -bool SQLPTExtRepresentation::GetUserPermissionsForDevice( - const std::string& device_id, - StringArray* consented_groups, - StringArray* disallowed_groups) { - LOG4CXX_AUTO_TRACE(logger_); - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt_ext::kSelectDeviceConsentedGroup)) { - LOG4CXX_WARN(logger_, "Incorrect select from device consented groups"); - return false; - } - query.Bind(0, device_id); - while (query.Next()) { - if (query.GetBoolean(2)) { - if (!consented_groups) { - continue; - } - consented_groups->push_back(query.GetString(1)); - } else { - if (!disallowed_groups) { - continue; - } - disallowed_groups->push_back(query.GetString(1)); - } - } - - return true; -} - -bool SQLPTExtRepresentation::GetPermissionsForApp( - const std::string& device_id, - const std::string& policy_app_id, - FunctionalIdType* group_types) { - LOG4CXX_AUTO_TRACE(logger_); - if (!group_types) { - LOG4CXX_WARN(logger_, "Input parameter for group types is null."); - return false; - } - // Get all app groups for specified device and application - FunctionalGroupIDs all_groups; - if (!GetAllAppGroups(policy_app_id, all_groups)) { - return false; - } - // Get preconsented group - FunctionalGroupIDs preconsented_groups; - if (!GetPreconsentedGroups(policy_app_id, preconsented_groups)) { - return false; - } - // Get consented (allowed/disallowed) groups - FunctionalGroupIDs allowed_groups; - FunctionalGroupIDs disallowed_groups; - if (!GetConsentedGroups( - policy_app_id, device_id, allowed_groups, disallowed_groups)) { - return false; - } - // Get all default groups - FunctionalGroupIDs default_groups; - if (!GetAllAppGroups(kDefaultId, default_groups)) { - return false; - } - - // Get all pre_DataConsent groups - FunctionalGroupIDs predataconsented_groups; - if (!GetAllAppGroups(kPreDataConsentId, predataconsented_groups)) { - return false; - } - - // Get all device groups - FunctionalGroupIDs device_groups; - if (!GetAllAppGroups(kDeviceId, device_groups)) { - return false; - } - - (*group_types)[kTypeDefault] = default_groups; - (*group_types)[kTypeAllowed] = allowed_groups; - (*group_types)[kTypeDisallowed] = disallowed_groups; - (*group_types)[kTypePreconsented] = preconsented_groups; - (*group_types)[kTypeGeneral] = all_groups; - (*group_types)[kTypePreDataConsented] = predataconsented_groups; - (*group_types)[kTypeDevice] = device_groups; - - return true; -} - -bool SQLPTExtRepresentation::GetDeviceGroupsFromPolicies( - policy_table::Strings* groups, policy_table::Strings* preconsented_groups) { - LOG4CXX_AUTO_TRACE(logger_); - if (groups) { - GatherAppGroup(kDeviceId, groups); - } - if (preconsented_groups) { - GatherPreconsentedGroup(kDeviceId, preconsented_groups); - } - return true; -} - -bool SQLPTExtRepresentation::SetDeviceData(const std::string& device_id, - const std::string& hardware, - const std::string& firmware, - const std::string& os, - const std::string& os_version, - const std::string& carrier, - const uint32_t number_of_ports, - const std::string& connection_type) { - LOG4CXX_AUTO_TRACE(logger_); - utils::dbms::SQLQuery count_query(db()); - if (!count_query.Prepare(sql_pt_ext::kCountDevice)) { - LOG4CXX_WARN(logger_, "Incorrect statement for count of device."); - return false; - } - - count_query.Bind(0, device_id); - - if (!count_query.Exec()) { - LOG4CXX_WARN(logger_, "Incorrect count of device."); - return false; - } - - bool update = count_query.GetInteger(0); - - // Update old value - if (update) { - utils::dbms::SQLQuery update_query(db()); - if (!update_query.Prepare(sql_pt_ext::kUpdateDevice)) { - LOG4CXX_WARN(logger_, "Incorrect statement for udpate device."); - return false; - } - - update_query.Bind(0, hardware); - update_query.Bind(1, firmware); - update_query.Bind(2, os); - update_query.Bind(3, os_version); - update_query.Bind(4, carrier); - update_query.Bind(5, static_cast(number_of_ports)); - update_query.Bind(6, device_id); - update_query.Bind(7, connection_type); - - if (!update_query.Exec() || !update_query.Reset()) { - LOG4CXX_WARN(logger_, "Incorrect update for device."); - return false; - } - - return true; - } - - // Insert new data - utils::dbms::SQLQuery insert_query(db()); - if (!insert_query.Prepare(sql_pt_ext::kInsertDevice)) { - LOG4CXX_WARN(logger_, "Incorrect insert statement for device."); - return false; - } - - insert_query.Bind(0, device_id); - insert_query.Bind(1, hardware); - insert_query.Bind(2, firmware); - insert_query.Bind(3, os); - insert_query.Bind(4, os_version); - insert_query.Bind(5, carrier); - insert_query.Bind(6, static_cast(number_of_ports)); - insert_query.Bind(7, connection_type); - - if (!insert_query.Exec() || !insert_query.Reset()) { - LOG4CXX_WARN(logger_, "Incorrect insert to device."); - return false; - } - - SetPreloaded(false); - - return true; -} - -bool SQLPTExtRepresentation::SetUserPermissionsForDevice( - const std::string& device_id, - const StringArray& consented_groups, - const StringArray& disallowed_groups) { - LOG4CXX_AUTO_TRACE(logger_); - utils::dbms::SQLQuery count_query(db()); - if (!count_query.Prepare(sql_pt_ext::kCountDeviceConsentGroup)) { - LOG4CXX_WARN(logger_, "Incorrect count of device consented groups"); - return false; - } - - count_query.Bind(0, device_id); - - if (!count_query.Exec()) { - LOG4CXX_WARN(logger_, "Failed count of device consented groups"); - return false; - } - - bool update = count_query.GetInteger(0); - - // TODO(AOleynik): Split to several methods? - utils::dbms::SQLQuery query(db()); - // Update old values - if (update) { - if (!query.Prepare(sql_pt_ext::kUpdateDeviceConsentedGroup)) { - LOG4CXX_WARN( - logger_, - "Incorrect statement for updating consented groups on device"); - return false; - } - - StringArray::const_iterator it_consented_groups = consented_groups.begin(); - StringArray::const_iterator it_consented_groups_end = - consented_groups.end(); - for (; it_consented_groups != it_consented_groups_end; - ++it_consented_groups) { - query.Bind(0, true); - query.Bind(1, std::string("GUI")); - query.Bind(2, device_id); - query.Bind(3, *it_consented_groups); - // TODO(AOleynik): Get this info from external data - if (!query.Exec() || !query.Reset()) { - LOG4CXX_WARN(logger_, - "Failed update of device allowed consented groups."); - return false; - } - } - - StringArray::const_iterator it_disallowed_groups = - disallowed_groups.begin(); - StringArray::const_iterator it_disallowed_groups_end = - disallowed_groups.end(); - for (; it_disallowed_groups != it_disallowed_groups_end; - ++it_disallowed_groups) { - query.Bind(0, false); - query.Bind(1); - query.Bind(2, device_id); - query.Bind(3, *it_disallowed_groups); - if (!query.Exec() || !query.Reset()) { - LOG4CXX_WARN(logger_, - "Failed update of device disallowed consented groups."); - return false; - } - } - - return true; - } - - // Insert new values - if (!query.Prepare(sql_pt_ext::kInsertDeviceConsentedGroup)) { - LOG4CXX_WARN(logger_, - "Incorrect statement of inserting to device consented groups"); - return false; - } - - StringArray::const_iterator it_consented_groups = consented_groups.begin(); - StringArray::const_iterator it_consented_groups_end = consented_groups.end(); - for (; it_consented_groups != it_consented_groups_end; - ++it_consented_groups) { - query.Bind(0, device_id); - query.Bind(1, *it_consented_groups); - query.Bind(2, true); - // TODO(AOleynik): Get this info from external data - query.Bind(3, std::string("GUI")); - if (!query.Exec() || !query.Reset()) { - LOG4CXX_WARN(logger_, - "Failed insert to device allowed consented groups."); - return false; - } - } - - StringArray::const_iterator it_disallowed_groups = disallowed_groups.begin(); - StringArray::const_iterator it_disallowed_groups_end = - disallowed_groups.end(); - for (; it_disallowed_groups != it_disallowed_groups_end; - ++it_disallowed_groups) { - query.Bind(0, device_id); - query.Bind(1, *it_disallowed_groups); - query.Bind(2, false); - query.Bind(3); - if (!query.Exec() || !query.Reset()) { - LOG4CXX_WARN(logger_, - "Failed insert to device disallowed consented groups."); - return false; - } - } - - return true; -} - -bool SQLPTExtRepresentation::ReactOnUserDevConsentForApp( - const std::string& app_id, bool is_device_allowed) { - bool result = true; - if (is_device_allowed) { - // If app has pre_DataConsented groups it should be 'promoted' to default - // If app has only pre_DataConsented flag it should be only set to false and - // all groups get restored automatically - if (IsPredataPolicy(app_id)) { - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt_ext::kHasAppPreloadedGroups)) { - LOG4CXX_WARN(logger_, - "Incorrect statement for has app preloaded groups"); - return false; - } - query.Bind(0, app_id); - query.Bind(1, kPreDataConsentId); - if (!query.Exec()) { - LOG4CXX_WARN(logger_, - "Incorrect select for app has predataconsted groups"); - return false; - } - if (query.GetInteger(0) > 0) { - result = result && SetDefaultPolicy(app_id); - } else { - result = result && SetIsPredata(app_id, false); - } - } - } else { - // If app has default groups change them to pre_DataConsented - // If app has 'normal' groups leave them as is and set - // pre_DataConsented flag to true. - if (IsDefaultPolicy(app_id)) { - result = result && SetPredataPolicy(app_id); - } else { - result = result && SetIsPredata(app_id, true); - } - } - return result; -} - -bool SQLPTExtRepresentation::SetUserPermissionsForApp( - const PermissionConsent& permissions) { - LOG4CXX_AUTO_TRACE(logger_); - // TODO(AOleynik): Handle situation, when no application was specified, i.e. - // general permissions were set - std::vector::const_iterator it = - permissions.group_permissions.begin(); - std::vector::const_iterator it_end = - permissions.group_permissions.end(); - - utils::dbms::SQLQuery query(db()); - for (; it != it_end; ++it) { - utils::dbms::SQLQuery counter(db()); - if (!counter.Prepare(sql_pt_ext::kCountAppConsents)) { - LOG4CXX_WARN(logger_, "Incorrect statement for consent group count."); - return false; - } - - counter.Bind(0, permissions.device_id); - counter.Bind(1, permissions.policy_app_id); - counter.Bind(2, static_cast((*it).group_id)); - if (!counter.Exec()) { - LOG4CXX_WARN(logger_, "Incorrent count on consent groups."); - return false; - } - - bool update_required = counter.GetInteger(0); - - // Update already present consent record - if (update_required) { - if (!query.Prepare(sql_pt_ext::kUpdateGroupPermissions)) { - LOG4CXX_WARN(logger_, "Incorrect statement for update consent groups."); - return false; - } - - // Skip consent saving, if user didn't choose any state - if (policy::kGroupUndefined == (*it).state) { - continue; - } - query.Bind(0, (*it).state == kGroupAllowed ? 1 : 0); - query.Bind(1, permissions.consent_source); - query.Bind(2, permissions.policy_app_id); - query.Bind(3, static_cast((*it).group_id)); - query.Bind(4, permissions.device_id); - - if (!query.Exec() || !query.Reset()) { - LOG4CXX_WARN(logger_, - "Incorrect update on user defined permissions " - "for app groups."); - return false; - } - continue; - } - - // Insert new consent record - if (!query.Prepare(sql_pt_ext::kInsertConsentGroups)) { - LOG4CXX_WARN(logger_, - "Incorrect statement for update app group permissions."); - return false; - } - - // Skip consent saving, if user didn't choose any state - if (policy::kGroupUndefined == (*it).state) { - continue; - } - query.Bind(0, permissions.device_id); - query.Bind(1, permissions.policy_app_id); - query.Bind(2, static_cast((*it).group_id)); - query.Bind(3, (*it).state == kGroupAllowed ? 1 : 0); - query.Bind(4, permissions.consent_source); - - if (!query.Exec() || !query.Reset()) { - LOG4CXX_WARN(logger_, - "Incorrect insert to user defined permissions " - "for app groups."); - return false; - } - continue; - } - return true; -} - -std::vector SQLPTExtRepresentation::GetUserFriendlyMsg( - const std::vector& msg_codes, const std::string& language) { - utils::dbms::SQLQuery query(db()); - std::vector result; - if (!query.Prepare(sql_pt_ext::kSelectFriendlyMsg)) { - LOG4CXX_WARN(logger_, "Incorrect statement for select friendly messages."); - return result; - } - - const std::string fallback_language = "en-us"; - std::vector::const_iterator it = msg_codes.begin(); - std::vector::const_iterator it_end = msg_codes.end(); - for (; it != it_end; ++it) { - std::string msg_language = language; - // If message has no records with required language, fallback language - // should be used instead. - if (!IsMsgLanguagePresent((*it), language)) { - msg_language = fallback_language; - } - query.Bind(0, *it); - query.Bind(1, msg_language); - - if (!query.Exec() || !query.Reset()) { - LOG4CXX_WARN(logger_, "Incorrect select from friendly messages."); - return result; - } - - UserFriendlyMessage msg; - - msg.message_code = *it; - msg.tts = query.GetString(0); - msg.label = query.GetString(1); - msg.line1 = query.GetString(2); - msg.line2 = query.GetString(3); - msg.text_body = query.GetString(4); - - result.push_back(msg); - - if (!query.Reset()) { - LOG4CXX_WARN(logger_, - "Failed reset statement for selecting friendly " - "messages."); - return result; - } - } - - return result; -} - -bool SQLPTExtRepresentation::GatherConsumerFriendlyMessages( - policy_table::ConsumerFriendlyMessages* messages) const { - if (NULL == messages) { - LOG4CXX_ERROR(logger_, "NULL pointer has been passed to fill"); - return false; - } - - if (!SQLPTRepresentation::GatherConsumerFriendlyMessages(messages)) { - return false; - } - - utils::dbms::SQLQuery query(db()); - bool result = query.Prepare(sql_pt_ext::kCollectFriendlyMsg); - - if (result) { - while (query.Next()) { - UserFriendlyMessage msg; - - msg.tts = query.GetString(1); - msg.label = query.GetString(2); - msg.line1 = query.GetString(3); - msg.line2 = query.GetString(4); - msg.text_body = query.GetString(5); - msg.message_code = query.GetString(7); - - std::string language = query.GetString(6); - - *(*messages->messages)[msg.message_code].languages[language].tts = - msg.tts; - *(*messages->messages)[msg.message_code].languages[language].label = - msg.label; - *(*messages->messages)[msg.message_code].languages[language].line1 = - msg.line1; - *(*messages->messages)[msg.message_code].languages[language].line2 = - msg.line2; - *(*messages->messages)[msg.message_code].languages[language].textBody = - msg.text_body; - } - } else { - LOG4CXX_WARN(logger_, "Incorrect statement for select friendly messages."); - } - return result; -} - -bool SQLPTExtRepresentation::SetMetaInfo(const std::string& ccpu_version, - const std::string& wers_country_code, - const std::string& language) { - LOG4CXX_AUTO_TRACE(logger_); - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt_ext::kUpdateMetaParams)) { - LOG4CXX_WARN(logger_, "Incorrect statement for insert to module meta."); - return false; - } - - query.Bind(0, ccpu_version); - query.Bind(1, wers_country_code); - query.Bind(2, language); - - if (!query.Exec() || !query.Reset()) { - LOG4CXX_WARN(logger_, "Incorrect insert to module meta."); - return false; - } - return true; -} - -bool SQLPTExtRepresentation::IsMetaInfoPresent() { - LOG4CXX_AUTO_TRACE(logger_); - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt_ext::kSelectMetaParams)) { - LOG4CXX_WARN(logger_, "Incorrect statement for selecting meta info."); - return false; - } - - if (!query.Exec()) { - LOG4CXX_WARN(logger_, "Incorrect select from module meta."); - return false; - } - - return !query.IsNull(0) && !query.IsNull(1) && !query.IsNull(2); -} - -bool SQLPTExtRepresentation::SetSystemLanguage(const std::string& language) { - LOG4CXX_AUTO_TRACE(logger_); - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt_ext::kUpdateMetaLanguage)) { - LOG4CXX_WARN(logger_, "Incorrect statement for update meta language."); - return false; - } - - query.Bind(0, language); - - if (!query.Exec()) { - LOG4CXX_WARN(logger_, "Incorrect update for meta language."); - return false; - } - - return true; -} - -bool SQLPTExtRepresentation::SaveApplicationPoliciesSection( - const policy_table::ApplicationPoliciesSection& policies) { - LOG4CXX_INFO(logger_, "SaveApplicationPolicies ext"); - utils::dbms::SQLQuery query_delete(db()); - if (!query_delete.Exec(sql_pt::kDeleteAppGroup)) { - LOG4CXX_WARN(logger_, "Incorrect delete from app_group."); - return false; - } - - utils::dbms::SQLQuery query_delete_preconsented(db()); - if (!query_delete_preconsented.Exec(sql_pt_ext::kDeletePreconsentedGroups)) { - LOG4CXX_WARN(logger_, "Incorrect delete from preconsented_group."); - return false; - } - - if (!query_delete.Exec(sql_pt::kDeleteApplication)) { - LOG4CXX_WARN(logger_, "Incorrect delete from application."); - return false; - } - - if (!query_delete.Exec(sql_pt::kDeleteRequestType)) { - LOG4CXX_WARN(logger_, "Incorrect delete from request type."); - return false; - } - - // First, all predefined apps (e.g. default, pre_DataConsent) should be saved, - // otherwise another app with the predefined permissions can get incorrect - // permissions - policy_table::ApplicationPolicies::const_iterator it_default = - policies.apps.find(kDefaultId); - if (policies.apps.end() != it_default) { - if (!SaveSpecificAppPolicy(*it_default)) { - return false; - } - } - policy_table::ApplicationPolicies::const_iterator it_pre_data_consent = - policies.apps.find(kPreDataConsentId); - if (policies.apps.end() != it_pre_data_consent) { - if (!SaveSpecificAppPolicy(*it_pre_data_consent)) { - return false; - } - } - - if (!SaveDevicePolicy(policies.device)) { - return false; - } - - policy_table::ApplicationPolicies::const_iterator it; - for (it = policies.apps.begin(); it != policies.apps.end(); ++it) { - // Skip saving of predefined app, since they should be saved before - if (IsPredefinedApp(*it)) { - continue; - } - if (!SaveSpecificAppPolicy(*it)) { - return false; - } - } - - return true; -} - -bool SQLPTExtRepresentation::SaveSpecificAppPolicy( - const policy_table::ApplicationPolicies::value_type& app) { - if (app.second.is_string()) { - if (kDefaultId.compare(app.second.get_string()) == 0) { - if (!SetDefaultPolicy(app.first)) { - return false; - } - if (!SaveRequestType(app.first, *app.second.RequestType)) { - return false; - } - } else if (kPreDataConsentId.compare(app.second.get_string()) == 0) { - if (!SetPredataPolicy(app.first)) { - return false; - } - if (!SaveRequestType(app.first, *app.second.RequestType)) { - return false; - } - } - - // Stop saving other params, since predefined permissions already set - return true; - } - - SetIsDefault(app.first, false); - SetIsPredata(app.first, false); - - utils::dbms::SQLQuery app_query(db()); - if (!app_query.Prepare(sql_pt_ext::kInsertApplication)) { - LOG4CXX_WARN(logger_, "Incorrect insert statement into application."); - return false; - } - - app_query.Bind(0, app.first); - app_query.Bind(1, app.second.keep_context); - app_query.Bind(2, app.second.steal_focus); - app_query.Bind( - 3, std::string(policy_table::EnumToJsonString(app.second.default_hmi))); - app_query.Bind( - 4, std::string(policy_table::EnumToJsonString(app.second.priority))); - app_query.Bind(5, app.second.is_null()); - app_query.Bind(6, *app.second.memory_kb); - app_query.Bind(7, static_cast(*app.second.heart_beat_timeout_ms)); - app.second.certificate.is_initialized() - ? app_query.Bind(8, *app.second.certificate) - : app_query.Bind(8, std::string()); - - if (!app_query.Exec() || !app_query.Reset()) { - LOG4CXX_WARN(logger_, "Incorrect insert into application."); - return false; - } - - if (!SaveAppGroup(app.first, app.second.groups)) { - return false; - } - // TODO(IKozyrenko): Check logic if optional container is missing - if (!SaveNickname(app.first, *app.second.nicknames)) { - return false; - } - // TODO(IKozyrenko): Check logic if optional container is missing - if (!SaveAppType(app.first, *app.second.AppHMIType)) { - return false; - } - // TODO(IKozyrenko): Check logic if optional container is missing - if (!SavePreconsentedGroup(app.first, *app.second.preconsented_groups)) { - return false; - } - - return true; -} - -bool policy::SQLPTExtRepresentation::SaveDevicePolicy( - const policy_table::DevicePolicy& device) { - dbms::SQLQuery app_query(db()); - if (!app_query.Prepare(sql_pt_ext::kInsertApplication)) { - LOG4CXX_WARN(logger_, - "Incorrect insert statement into application (device)."); - return false; - } - app_query.Bind(0, kDeviceId); - app_query.Bind(1, device.keep_context); - app_query.Bind(2, device.steal_focus); - app_query.Bind( - 3, std::string(policy_table::EnumToJsonString(device.default_hmi))); - app_query.Bind(4, - std::string(policy_table::EnumToJsonString(device.priority))); - app_query.Bind(5, false); - app_query.Bind(6, 0); - app_query.Bind(7, 0); - app_query.Bind(8, std::string()); - - if (!app_query.Exec() || !app_query.Reset()) { - LOG4CXX_WARN(logger_, "Incorrect insert into application."); - return false; - } - - if (!SaveAppGroup(kDeviceId, device.groups)) { - return false; - } - if (!SavePreconsentedGroup(kDeviceId, *device.preconsented_groups)) { - return false; - } - - return true; -} - -bool SQLPTExtRepresentation::GatherApplicationPoliciesSection( - policy_table::ApplicationPoliciesSection* policies) const { - LOG4CXX_INFO(logger_, "Gather applications policies"); - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt_ext::kSelectAppPolicies)) { - LOG4CXX_WARN(logger_, "Incorrect select from app_policies"); - return false; - } - - while (query.Next()) { - rpc::Nullable params; - const std::string& app_id = query.GetString(0); - if (IsApplicationRevoked(app_id)) { - params.set_to_null(); - (*policies).apps[app_id] = params; - continue; - } - if (IsDefaultPolicy(app_id)) { - (*policies).apps[app_id].set_to_string(kDefaultId); - } - if (IsPredataPolicy(app_id)) { - (*policies).apps[app_id].set_to_string(kPreDataConsentId); - } - if (kDeviceId == app_id) { - policy_table::DevicePolicy device_policy; - policy_table::Priority priority; - policy_table::EnumFromJsonString(query.GetString(1), &priority); - device_policy.priority = priority; - policy_table::HmiLevel hmi; - policy_table::EnumFromJsonString(query.GetString(2), &hmi); - device_policy.default_hmi = hmi; - device_policy.keep_context = query.GetBoolean(3); - device_policy.steal_focus = query.GetBoolean(4); - if (!GatherAppGroup(app_id, &device_policy.groups)) { - return false; - } - GatherPreconsentedGroup(app_id, &*device_policy.preconsented_groups); - (*policies).device = device_policy; - continue; - } - policy_table::Priority priority; - policy_table::EnumFromJsonString(query.GetString(1), &priority); - params.priority = priority; - policy_table::HmiLevel hmi; - policy_table::EnumFromJsonString(query.GetString(2), &hmi); - params.default_hmi = hmi; - params.keep_context = query.GetBoolean(3); - params.steal_focus = query.GetBoolean(4); - *params.memory_kb = query.GetInteger(5); - *params.heart_beat_timeout_ms = query.GetUInteger(6); - if (!query.IsNull(7)) { - *params.certificate = query.GetString(7); - } - if (!GatherAppGroup(app_id, ¶ms.groups)) { - return false; - } - if (!GatherNickName(app_id, &*params.nicknames)) { - return false; - } - if (!GatherAppType(app_id, &*params.AppHMIType)) { - return false; - } - if (!GatherRequestType(app_id, &*params.RequestType)) { - return false; - } - GatherPreconsentedGroup(app_id, &*params.preconsented_groups); - (*policies).apps[app_id] = params; - } - return true; -} - -void SQLPTExtRepresentation::GatherPreconsentedGroup( - const std::string& app_id, policy_table::Strings* groups) const { - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt_ext::kSelectPreconsentedGroups)) { - LOG4CXX_WARN(logger_, "Incorrect select from preconsented group"); - return; - } - - query.Bind(0, app_id); - while (query.Next()) { - groups->push_back(query.GetString(0)); - } -} - -bool SQLPTExtRepresentation::GatherUsageAndErrorCounts( - policy_table::UsageAndErrorCounts* counts) const { - LOG4CXX_INFO(logger_, "Gather Usage and Error Counts."); - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt_ext::kSelectUsageAndErrorCount) || !query.Exec()) { - LOG4CXX_INFO(logger_, "Failed select from user_and_error_count"); - return false; - } - - *counts->count_of_iap_buffer_full = query.GetInteger(0); - *counts->count_sync_out_of_memory = query.GetInteger(1); - *counts->count_of_sync_reboots = query.GetInteger(2); - - return GatherAppLevels(&*counts->app_level); -} - -bool SQLPTExtRepresentation::GatherAppLevels( - policy_table::AppLevels* apps) const { - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt_ext::kSelectAppLevels)) { - LOG4CXX_INFO(logger_, - "Failed select from app_level. SQLError = " - << query.LastError().text()); - return false; - } - while (query.Next()) { - policy_table::AppLevel level; - // value of time fields database is seconds - level.minutes_in_hmi_full = query.GetInteger(1); - level.minutes_in_hmi_limited = query.GetInteger(2); - level.minutes_in_hmi_background = query.GetInteger(3); - level.minutes_in_hmi_none = query.GetInteger(4); - level.count_of_user_selections = query.GetInteger(5); - level.count_of_rejections_sync_out_of_memory = query.GetInteger(6); - level.count_of_rejections_nickname_mismatch = query.GetInteger(7); - level.count_of_rejections_duplicate_name = query.GetInteger(8); - level.count_of_rejected_rpc_calls = query.GetInteger(9); - level.count_of_rpcs_sent_in_hmi_none = query.GetInteger(10); - level.count_of_removals_for_bad_behavior = query.GetInteger(11); - level.count_of_run_attempts_while_revoked = query.GetInteger(12); - level.app_registration_language_gui = query.GetString(13); - level.app_registration_language_vui = query.GetString(14); - level.count_of_tls_errors = query.GetInteger(15); - (*apps)[query.GetString(0)] = level; - } - - return true; -} - -void SQLPTExtRepresentation::GatherDeviceData( - policy_table::DeviceData* data) const { - LOG4CXX_INFO(logger_, "Gather device data."); - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt_ext::kSelectDeviceData)) { - LOG4CXX_WARN(logger_, "Incorrect select statement for device data."); - return; - } - data->mark_initialized(); - while (query.Next()) { - policy_table::DeviceParams* specific_device = &(*data)[query.GetString(0)]; - *specific_device->hardware = query.GetString(1); - *specific_device->firmware_rev = query.GetString(2); - *specific_device->os = query.GetString(3); - *specific_device->os_version = query.GetString(4); - *specific_device->carrier = query.GetString(5); - *specific_device->max_number_rfcom_ports = query.GetInteger(6); - - // TODO(IKozyrenko): Check logic if optional container is missing - GatherConsentGroup(query.GetString(0), - &(*specific_device->user_consent_records)); - } -} - -void SQLPTExtRepresentation::GatherConsentGroup( - const std::string& device_id, - policy_table::UserConsentRecords* records) const { - LOG4CXX_INFO(logger_, "Gather consent records."); - utils::dbms::SQLQuery query(db()); - // Fill data for device - if (!query.Prepare(sql_pt_ext::kSelectDeviceConsentedGroup)) { - LOG4CXX_WARN(logger_, - "Incorrect select statement for device consented groups."); - return; - } - - query.Bind(0, device_id); - - // Fill device_data -> user_consent_records -> "device" - while (query.Next()) { - policy_table::ConsentRecords* device_consent_records = - &(*records)[kDeviceId]; - // TODO(IKozyrenko): Check logic if optional container is missing - policy_table::ConsentGroups& consent_groups = - *device_consent_records->consent_groups; - consent_groups[query.GetString(1)] = query.GetBoolean(2); - policy_table::Input input; - policy_table::EnumFromJsonString(query.GetString(3), &input); - *device_consent_records->input = input; - *device_consent_records->time_stamp = query.GetString(4); - } - - if (!query.Reset()) { - return; - } - - // Fill data for applications - if (!query.Prepare(sql_pt_ext::kSelectConsentGroup)) { - LOG4CXX_WARN(logger_, - "Incorrect select statement for app consented groups."); - return; - } - - query.Bind(0, device_id); - - // Fill device_data -> user_consent_records -> - while (query.Next()) { - policy_table::ConsentRecords* app_consent_records = - &(*records)[query.GetString(1)]; - // TODO(IKozyrenko): Check logic if optional container is missing - policy_table::ConsentGroups& consent_groups = - *app_consent_records->consent_groups; - - consent_groups[query.GetString(2)] = query.GetBoolean(3); - policy_table::Input input; - policy_table::EnumFromJsonString(query.GetString(4), &input); - *app_consent_records->input = input; - *app_consent_records->time_stamp = query.GetString(5); - } -} - -bool SQLPTExtRepresentation::SaveDeviceData( - const policy_table::DeviceData& devices) { - LOG4CXX_AUTO_TRACE(logger_); - utils::dbms::SQLQuery drop_device_query(db()); - const std::string drop_device = "DELETE FROM `device`"; - if (!drop_device_query.Exec(drop_device)) { - LOG4CXX_WARN(logger_, "Could not clear device table."); - return false; - } - - utils::dbms::SQLQuery drop_device_consents_query(db()); - const std::string drop_device_consents = "DELETE FROM `device_consent_group`"; - if (!drop_device_consents_query.Exec(drop_device_consents)) { - LOG4CXX_WARN(logger_, "Could not clear device consents."); - return false; - } - - utils::dbms::SQLQuery drop_user_consents_query(db()); - const std::string drop_user_consents = "DELETE FROM `consent_group`"; - if (!drop_user_consents_query.Exec(drop_user_consents)) { - LOG4CXX_WARN(logger_, "Could not clear user consents."); - return false; - } - - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt_ext::kInsertDeviceData)) { - LOG4CXX_WARN(logger_, "Incorrect insert statement for device data."); - return false; - } - - policy_table::DeviceData::const_iterator it = devices.begin(); - policy_table::DeviceData::const_iterator it_end = devices.end(); - for (; it != it_end; ++it) { - query.Bind(0, it->first); - query.Bind(1, *(it->second.hardware)); - query.Bind(2, *(it->second.firmware_rev)); - query.Bind(3, *(it->second.os)); - query.Bind(4, *(it->second.os_version)); - query.Bind(5, *(it->second.carrier)); - query.Bind(6, *(it->second.max_number_rfcom_ports)); - query.Bind(7, *(it->second.connection_type)); - - if (!query.Exec() || !query.Reset()) { - LOG4CXX_WARN(logger_, "Incorrect insert into device data."); - return false; - } - - // TODO(IKozyrenko): Check logic if optional container is missing - if (!SaveConsentGroup(it->first, *it->second.user_consent_records)) { - return false; - } - } - - return true; -} - -bool SQLPTExtRepresentation::SaveConsentGroup( - const std::string& device_id, - const policy_table::UserConsentRecords& records) { - LOG4CXX_AUTO_TRACE(logger_); - utils::dbms::SQLQuery query(db()); - - policy_table::UserConsentRecords::const_iterator it = records.begin(); - policy_table::UserConsentRecords::const_iterator it_end = records.end(); - for (; it != it_end; ++it) { - // TODO(IKozyrenko): Check logic if optional container is missing - policy_table::ConsentGroups::const_iterator it_groups = - it->second.consent_groups->begin(); - policy_table::ConsentGroups::const_iterator it_groups_end = - it->second.consent_groups->end(); - for (; it_groups != it_groups_end; ++it_groups) { - if (kDeviceId == it->first) { - if (!query.Prepare(sql_pt_ext::kInsertDeviceConsentedGroup)) { - LOG4CXX_WARN(logger_, - "Incorrect insert statement for device consent group."); - return false; - } - query.Bind(0, device_id); - query.Bind(1, it_groups->first); - query.Bind(2, it_groups->second); - query.Bind( - 3, - std::string(policy_table::EnumToJsonString(*(it->second.input)))); - query.Bind(4, std::string(*(it->second.time_stamp))); - LOG4CXX_INFO(logger_, - "Device:" - << "time stamp " - << std::string(*(it->second.time_stamp)) << " group " - << it_groups->first << " consent " - << it_groups->second); - } else { - if (!query.Prepare(sql_pt_ext::kInsertConsentGroups)) { - LOG4CXX_WARN(logger_, - "Incorrect insert statement for consent group."); - return false; - } - query.Bind(0, device_id); - query.Bind(1, it->first); - query.Bind(2, it_groups->first); - query.Bind(3, it_groups->second); - query.Bind( - 4, - std::string(policy_table::EnumToJsonString(*(it->second.input)))); - query.Bind(5, std::string(*(it->second.time_stamp))); - LOG4CXX_INFO(logger_, - "Device:" - << "time stamp " - << std::string(*(it->second.time_stamp)) << " group " - << it_groups->first << " consent " - << it_groups->second); - } - - if (!query.Exec() || !query.Reset()) { - LOG4CXX_WARN(logger_, "Incorrect insert into consent group."); - return false; - } - } - } - - return true; -} - -bool SQLPTExtRepresentation::SavePreconsentedGroup( - const std::string& app_id, const policy_table::Strings& groups) { - LOG4CXX_AUTO_TRACE(logger_); - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt_ext::kInsertPreconsentedGroups)) { - LOG4CXX_WARN(logger_, "Incorrect insert statement for preconsented groups"); - return false; - } - - policy_table::Strings::const_iterator it; - for (it = groups.begin(); it != groups.end(); ++it) { - query.Bind(0, app_id); - query.Bind(1, *it); - if (!query.Exec() || !query.Reset()) { - LOG4CXX_WARN(logger_, "Incorrect insert into preconsented groups."); - return false; - } - } - - return true; -} - -void SQLPTExtRepresentation::GatherModuleMeta( - policy_table::ModuleMeta* meta) const { - LOG4CXX_INFO(logger_, "Gather Module Meta Info"); - utils::dbms::SQLQuery query(db()); - if (query.Prepare(sql_pt_ext::kSelectModuleMeta) && query.Next()) { - *meta->ccpu_version = query.GetString(0); - *meta->language = query.GetString(1); - *meta->wers_country_code = query.GetString(2); - *meta->pt_exchanged_at_odometer_x = query.GetInteger(3); - *meta->pt_exchanged_x_days_after_epoch = query.GetInteger(4); - *meta->ignition_cycles_since_last_exchange = query.GetInteger(5); - *meta->vin = query.GetString(6); - } -} - -void SQLPTExtRepresentation::Increment(const std::string& type) const { - utils::dbms::SQLQuery query(db()); - std::string update_counter = - "UPDATE `usage_and_error_count` SET `" + type + "` = `" + type + "` + 1"; - if (!query.Exec(update_counter)) { - LOG4CXX_INFO(logger_, "Failed updating global counter"); - } -} - -bool SQLPTExtRepresentation::IsExistAppLevel(const std::string& app_id) const { - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt_ext::kCountAppLevel)) { - LOG4CXX_INFO(logger_, "Incorrect statement of count app_level"); - return false; - } - query.Bind(0, app_id); - if (!query.Exec()) { - LOG4CXX_INFO(logger_, "Failed count app_level"); - return false; - } - return query.GetInteger(0) > 0; -} - -bool SQLPTExtRepresentation::GetAllAppGroups(const std::string& policy_app_id, - FunctionalGroupIDs& all_groups) { - LOG4CXX_INFO(logger_, "GetAllAppGroups for '" << policy_app_id << "'"); - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt_ext::kSelectAppGroupsId)) { - LOG4CXX_WARN(logger_, "Incorrect statement for select app groups id."); - return false; - } - - query.Bind(0, policy_app_id); - - while (query.Next()) { - all_groups.push_back(query.GetInteger(0)); - } - - return true; -} - -bool SQLPTExtRepresentation::GetConsentedGroups( - const std::string& policy_app_id, - const std::string& device_id, - FunctionalGroupIDs& allowed_groups, - FunctionalGroupIDs& disallowed_groups) { - LOG4CXX_AUTO_TRACE(logger_); - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt_ext::kSelectConsentedGroupsId)) { - LOG4CXX_WARN(logger_, "Incorrect statement for select consent groups id."); - return false; - } - - query.Bind(0, policy_app_id); - query.Bind(1, device_id); - - while (query.Next()) { - if (query.GetBoolean(1)) { - allowed_groups.push_back(query.GetInteger(0)); - } else { - disallowed_groups.push_back(query.GetInteger(0)); - } - } - - return true; -} - -bool SQLPTExtRepresentation::GetPreconsentedGroups( - const std::string& policy_app_id, FunctionalGroupIDs& preconsented_groups) { - LOG4CXX_AUTO_TRACE(logger_); - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt_ext::kSelectPreconsentedGroupsId)) { - LOG4CXX_WARN(logger_, - "Incorrect statement for select preconsented groups id."); - return false; - } - - query.Bind(0, policy_app_id); - - while (query.Next()) { - preconsented_groups.push_back(query.GetInteger(0)); - } - - return true; -} - -bool SQLPTExtRepresentation::GetFunctionalGroupNames( - FunctionalGroupNames& names) { - LOG4CXX_AUTO_TRACE(logger_); - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt_ext::kSelectFunctionalGroupNames)) { - LOG4CXX_WARN(logger_, - "Incorrect statement for select functional groups names."); - return false; - } - - while (query.Next()) { - // Some of functional grous doesn't have filled user_consent_prompt - if (query.IsNull(1)) { - names[query.GetInteger(0)] = - std::make_pair("", query.GetString(2)); - } else { - names[query.GetInteger(0)] = std::make_pair( - query.GetString(1), query.GetString(2)); - } - } - - return true; -} - -void SQLPTExtRepresentation::FillFunctionalGroupPermissions( - FunctionalGroupIDs& ids, - FunctionalGroupNames& names, - GroupConsent state, - std::vector& permissions) { - FunctionalGroupIDs::const_iterator it = ids.begin(); - FunctionalGroupIDs::const_iterator it_end = ids.end(); - for (; it != it_end; ++it) { - FunctionalGroupPermission current_group; - current_group.group_id = *it; - current_group.group_alias = names[*it].first; - current_group.group_name = names[*it].second; - current_group.state = state; - permissions.push_back(current_group); - } -} - -void SQLPTExtRepresentation::Increment(const std::string& app_id, - const std::string& type) const { - utils::dbms::SQLQuery query(db()); - std::string sql_counter; - if (IsExistAppLevel(app_id)) { - // update - sql_counter = "UPDATE `app_level` SET `" + type + "` = `" + type + - "` + 1 WHERE `application_id` = ?"; - } else { - // insert - sql_counter = "INSERT INTO `app_level` (`application_id`, `" + type + - "`) " - "VALUES (?, 1)"; - } - if (!query.Prepare(sql_counter)) { - LOG4CXX_INFO(logger_, "Incorrect statement of update app counter"); - return; - } - query.Bind(0, app_id); - if (!query.Exec()) { - LOG4CXX_INFO(logger_, "Failed updating app counter"); - } -} - -void SQLPTExtRepresentation::Set(const std::string& app_id, - const std::string& type, - const std::string& value) const { - utils::dbms::SQLQuery query(db()); - std::string sql_info; - if (IsExistAppLevel(app_id)) { - // update - sql_info = "UPDATE `app_level` SET `" + type + - "` = ? " - "WHERE `application_id` = ?"; - } else { - // insert - sql_info = "INSERT INTO `app_level` (`" + type + - "`, `application_id`) " - "VALUES (?, ?)"; - } - if (!query.Prepare(sql_info)) { - LOG4CXX_INFO(logger_, "Incorrect statement of update app info"); - return; - } - query.Bind(0, value); - query.Bind(1, app_id); - if (!query.Exec()) { - LOG4CXX_INFO(logger_, "Failed updating app info"); - } -} - -void SQLPTExtRepresentation::Add(const std::string& app_id, - const std::string& type, - int seconds) const { - utils::dbms::SQLQuery query(db()); - std::string sql_stopwatch; - if (IsExistAppLevel(app_id)) { - // update - sql_stopwatch = "UPDATE `app_level` SET `" + type + "` = `" + type + - "` + ? WHERE `application_id` = ?"; - } else { - // insert - sql_stopwatch = "INSERT INTO `app_level` (`" + type + - "`, `application_id`) " - "VALUES (?, ?)"; - } - if (!query.Prepare(sql_stopwatch)) { - LOG4CXX_INFO(logger_, "Incorrect statement of update app stopwatch"); - return; - } - query.Bind(0, seconds); - query.Bind(1, app_id); - if (!query.Exec()) { - LOG4CXX_INFO(logger_, "Failed updating app stopwatch"); - } -} - -bool SQLPTExtRepresentation::GetDefaultHMI(const std::string& policy_app_id, - std::string* default_hmi) { - LOG4CXX_AUTO_TRACE(logger_); - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt_ext::kSelectDefaultHmi)) { - LOG4CXX_INFO(logger_, "Incorrect statement for default hmi."); - return false; - } - - query.Bind(0, policy_app_id); - - if (!query.Exec()) { - LOG4CXX_INFO(logger_, "Error during default hmi getting."); - return false; - } - - if (query.IsNull(0)) { - default_hmi->clear(); - return true; - } - - default_hmi->assign(query.GetString(0)); - - return true; -} - -bool SQLPTExtRepresentation::CountUnconsentedGroups( - const std::string& policy_app_id, - const std::string& device_id, - int* result) const { - LOG4CXX_AUTO_TRACE(logger_); - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt_ext::kCountUnconsentedGroups)) { - LOG4CXX_WARN(logger_, "Incorrect select for unconsented groups."); - return false; - } - - query.Bind(0, policy_app_id); - query.Bind(1, device_id); - query.Bind(2, kDefaultId); - query.Bind(3, kPreDataConsentId); - - if (!query.Exec()) { - LOG4CXX_INFO(logger_, "Error during executing unconsented groups."); - return false; - } - *result = query.GetInteger(0); - return true; -} - -bool SQLPTExtRepresentation::IsMsgLanguagePresent(const std::string& message, - const std::string& language) { - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt_ext::kHasMsgLanguageCode)) { - LOG4CXX_WARN(logger_, "Incorrect statement for message language check."); - return false; - } - - query.Bind(0, message); - query.Bind(1, language); - - if (!query.Exec()) { - LOG4CXX_WARN(logger_, "Failed to check message language code."); - return false; - } - - return query.GetInteger(0) != 0; -} - -bool SQLPTExtRepresentation::SaveMessageString( - const std::string& type, - const std::string& lang, - const policy_table::MessageString& strings) { - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt::kInsertMessageString)) { - LOG4CXX_WARN(logger_, "Incorrect insert statement for message."); - return false; - } - - query.Bind(0, *strings.tts); - query.Bind(1, *strings.label); - query.Bind(2, *strings.line1); - query.Bind(3, *strings.line2); - query.Bind(4, lang); - query.Bind(5, type); - query.Bind(6, *strings.textBody); - - if (!query.Exec() || !query.Reset()) { - LOG4CXX_WARN(logger_, "Incorrect insert into message."); - return false; - } - - return true; -} - -bool SQLPTExtRepresentation::SaveUsageAndErrorCounts( - const policy_table::UsageAndErrorCounts& counts) { - return SaveAppCounters(*counts.app_level) && SaveGlobalCounters(counts); -} - -bool SQLPTExtRepresentation::SaveModuleMeta( - const policy_table::ModuleMeta& meta) { - utils::dbms::SQLQuery query(db()); - - if (!query.Prepare(sql_pt_ext::kSaveModuleMeta)) { - LOG4CXX_WARN(logger_, "Incorrect insert statement for module_meta."); - return false; - } - const int64_t odometer = *(meta.pt_exchanged_at_odometer_x); - - query.Bind(0, *(meta.ccpu_version)); - query.Bind(1, *(meta.language)); - query.Bind(2, *(meta.wers_country_code)); - query.Bind(3, odometer); - query.Bind(4, *(meta.pt_exchanged_x_days_after_epoch)); - query.Bind(5, *(meta.ignition_cycles_since_last_exchange)); - query.Bind(6, *(meta.vin)); - - if (!query.Exec()) { - LOG4CXX_WARN(logger_, "Incorrect update for module_meta."); - return false; - } - - return true; -} - -bool SQLPTExtRepresentation::SaveAppCounters( - const rpc::policy_table_interface_base::AppLevels& app_levels) { - utils::dbms::SQLQuery query(db()); - if (!query.Exec(sql_pt::kDeleteAppLevel)) { - LOG4CXX_WARN(logger_, "Incorrect delete from app level."); - return false; - } - if (!query.Prepare(sql_pt::kInsertAppLevel)) { - LOG4CXX_WARN(logger_, "Incorrect insert statement for app level."); - return false; - } - - policy_table::AppLevels::const_iterator it; - for (it = app_levels.begin(); it != app_levels.end(); ++it) { - query.Bind(0, it->first); - query.Bind(1, it->second.minutes_in_hmi_full); - query.Bind(2, it->second.minutes_in_hmi_limited); - query.Bind(3, it->second.minutes_in_hmi_background); - query.Bind(4, it->second.minutes_in_hmi_none); - query.Bind(5, it->second.count_of_user_selections); - query.Bind(6, it->second.count_of_rejections_sync_out_of_memory); - query.Bind(7, it->second.count_of_rejections_nickname_mismatch); - query.Bind(8, it->second.count_of_rejections_duplicate_name); - query.Bind(9, it->second.count_of_rejected_rpc_calls); - query.Bind(10, it->second.count_of_rpcs_sent_in_hmi_none); - query.Bind(11, it->second.count_of_removals_for_bad_behavior); - query.Bind(12, it->second.count_of_run_attempts_while_revoked); - query.Bind(13, it->second.app_registration_language_gui); - query.Bind(14, it->second.app_registration_language_vui); - query.Bind(15, it->second.count_of_tls_errors); - - if (!query.Exec() || !query.Reset()) { - LOG4CXX_WARN(logger_, "Incorrect insert into app level."); - return false; - } - } - return true; -} - -bool SQLPTExtRepresentation::SaveGlobalCounters( - const rpc::policy_table_interface_base::UsageAndErrorCounts& counts) { - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt_ext::kUpdateGlobalCounters)) { - LOG4CXX_WARN(logger_, "Incorrect insert statement for global counters."); - return false; - } - - query.Bind(0, *counts.count_of_iap_buffer_full); - query.Bind(1, *counts.count_sync_out_of_memory); - query.Bind(2, *counts.count_of_sync_reboots); - - if (!query.Exec()) { - LOG4CXX_WARN(logger_, "Incorrect insert into global counters."); - return false; - } - - return true; -} - -bool SQLPTExtRepresentation::CleanupUnpairedDevices( - const DeviceIds& device_ids) const { - LOG4CXX_AUTO_TRACE(logger_); - utils::dbms::SQLQuery delete_device_query(db()); - if (!delete_device_query.Prepare(sql_pt::kDeleteDevice)) { - LOG4CXX_WARN(logger_, "Incorrect statement for device delete."); - return true; - } - - utils::dbms::SQLQuery delete_device_consent_query(db()); - if (!delete_device_consent_query.Prepare(sql_pt_ext::kDeleteDeviceConsent)) { - LOG4CXX_WARN(logger_, "Incorrect statement for delete device consent."); - return false; - } - - utils::dbms::SQLQuery delete_app_consent_query(db()); - if (!delete_app_consent_query.Prepare(sql_pt_ext::kDeleteAppConsent)) { - LOG4CXX_WARN(logger_, "Incorrect statement for delete app consent."); - return false; - } - - DeviceIds::const_iterator it = device_ids.begin(); - DeviceIds::const_iterator it_end = device_ids.end(); - for (; it != it_end; ++it) { - delete_device_query.Bind(0, (*it)); - if (!delete_device_query.Exec() || !delete_device_query.Reset()) { - LOG4CXX_WARN(logger_, "Failed to delete from device"); - return false; - } - - delete_device_consent_query.Bind(0, (*it)); - if (!delete_device_consent_query.Exec() || - !delete_device_consent_query.Reset()) { - LOG4CXX_WARN(logger_, "Failed to delete from device consent."); - return false; - } - - delete_app_consent_query.Bind(0, (*it)); - if (!delete_app_consent_query.Exec() || !delete_app_consent_query.Reset()) { - LOG4CXX_WARN(logger_, "Failed to delete from app consent."); - return false; - } - } - return true; -} - -bool SQLPTExtRepresentation::SetDefaultPolicy(const std::string& app_id) { - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt::kDeleteAppGroupByApplicationId)) { - LOG4CXX_ERROR(logger_, "Incorrect statement to delete from app_group."); - return false; - } - query.Bind(0, app_id); - if (!query.Exec()) { - LOG4CXX_ERROR(logger_, "Failed deleting from app_group."); - return false; - } - - if (!query.Prepare(sql_pt_ext::kDeletePreconsentedGroupsByApplicationId)) { - LOG4CXX_ERROR(logger_, "Incorrect statement to delete from app_group."); - return false; - } - query.Bind(0, app_id); - if (!query.Exec()) { - LOG4CXX_ERROR(logger_, "Failed deleting from app_group."); - return false; - } - - if (!CopyApplication(kDefaultId, app_id)) { - return false; - } - - SetPreloaded(false); - - policy_table::Strings default_groups; - policy_table::Strings default_preconsented_groups; - GatherAppGroup(kDefaultId, &default_groups); - GatherPreconsentedGroup(kDefaultId, &default_preconsented_groups); - if (SaveAppGroup(app_id, default_groups) && - SavePreconsentedGroup(app_id, default_preconsented_groups)) { - return SetIsDefault(app_id, true) && SetIsPredata(app_id, false); - } - - return false; -} - -bool SQLPTExtRepresentation::SetPredataPolicy(const std::string& app_id) { - LOG4CXX_INFO(logger_, - "SQLPTExtRepresentation::SetPredataPolicy for " << app_id); - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt::kDeleteAppGroupByApplicationId)) { - LOG4CXX_ERROR(logger_, "Incorrect statement to delete from app_group."); - return false; - } - query.Bind(0, app_id); - if (!query.Exec()) { - LOG4CXX_ERROR(logger_, "Failed deleting from app_group."); - return false; - } - - if (!query.Prepare(sql_pt_ext::kDeletePreconsentedGroupsByApplicationId)) { - LOG4CXX_ERROR(logger_, "Incorrect statement to delete from app_group."); - return false; - } - query.Bind(0, app_id); - if (!query.Exec()) { - LOG4CXX_ERROR(logger_, "Failed deleting from app_group."); - return false; - } - - if (!CopyApplication(kPreDataConsentId, app_id)) { - return false; - } - - SetPreloaded(false); - - policy_table::Strings predataconsent_groups; - policy_table::Strings predataconsent_preconsented_groups; - GatherAppGroup(kPreDataConsentId, &predataconsent_groups); - GatherPreconsentedGroup(kPreDataConsentId, &predataconsent_groups); - if (SaveAppGroup(app_id, predataconsent_groups) && - SavePreconsentedGroup(app_id, predataconsent_groups)) { - return SetIsDefault(app_id, false) && SetIsPredata(app_id, true); - } - return false; -} - -bool SQLPTExtRepresentation::IsPredataPolicy(const std::string& app_id) const { - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt_ext::kSelectApplicationIsPreData)) { - LOG4CXX_WARN(logger_, "Incorrect select application is pre_dataConsented"); - return false; - } - - query.Bind(0, app_id); - if (!query.Exec()) { - LOG4CXX_WARN(logger_, "Failed select application is pre_dataConsented"); - return false; - } - return query.IsNull(0) ? false : query.GetBoolean(0); -} - -bool SQLPTExtRepresentation::SetIsPredata(const std::string& app_id, - bool is_pre_data) { - LOG4CXX_TRACE(logger_, "Set flag is_predata of application"); - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt_ext::kUpdateIsPredata)) { - LOG4CXX_WARN(logger_, "Incorect statement for updating is_predata"); - return false; - } - - query.Bind(0, is_pre_data); - query.Bind(1, app_id); - if (!query.Exec()) { - LOG4CXX_WARN(logger_, "Failed update is_predata"); - return false; - } - return true; -} - -bool SQLPTExtRepresentation::SetUnpairedDevice(const std::string& device_id, - bool unpaired) const { - LOG4CXX_TRACE(logger_, "Set unpaired device: " << device_id); - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt_ext::kUpdateUnpairedDevice)) { - LOG4CXX_WARN(logger_, "Incorect statement for updating unpaired device"); - return false; - } - - query.Bind(0, unpaired); - query.Bind(1, device_id); - if (!query.Exec()) { - LOG4CXX_WARN(logger_, "Failed update unpaired device"); - return false; - } - return true; -} - -bool SQLPTExtRepresentation::UnpairedDevicesList(DeviceIds* device_ids) const { - LOG4CXX_TRACE(logger_, "Get list of unpaired devices"); - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt_ext::kSelectUnpairedDevices)) { - LOG4CXX_WARN(logger_, "Incorect statement for selecting unpaired devices"); - return false; - } - - while (query.Next()) { - device_ids->push_back(query.GetString(0)); - } - return true; -} - -bool SQLPTExtRepresentation::SetVINValue(const std::string& value) { - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt_ext::kUpdateModuleMetaVinParam)) { - LOG4CXX_WARN(logger_, "Incorect statement for updating module_meta params"); - return false; - } - - query.Bind(0, value); - const bool result = query.Exec(); - - if (!result) { - LOG4CXX_WARN(logger_, "Failed update module_meta"); - } - return result; -} - -bool SQLPTExtRepresentation::RemoveAppConsentForGroup( - const std::string& policy_app_id, - const std::string& functional_group_name) const { - utils::dbms::SQLQuery query_group_id(db()); - if (!query_group_id.Prepare(sql_pt_ext::kSelectGroupId)) { - LOG4CXX_WARN(logger_, "Incorect statement for select group name."); - return false; - } - - query_group_id.Bind(0, functional_group_name); - - if (!query_group_id.Exec()) { - LOG4CXX_WARN(logger_, "Failed to select group id."); - return false; - } - - const int id = query_group_id.GetInteger(0); - - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt_ext::kDeleteAppGroupConsent)) { - LOG4CXX_WARN(logger_, "Incorect statement for remove app consent."); - return false; - } - - query.Bind(0, policy_app_id); - query.Bind(1, id); - - if (!query.Exec()) { - LOG4CXX_WARN(logger_, "Failed to remove app consent."); - return false; - } - - return true; -} - -} // namespace policy diff --git a/src/components/policy/policy_regular/test/include/policy/mock_pt_ext_representation.h b/src/components/policy/policy_regular/test/include/policy/mock_pt_ext_representation.h deleted file mode 100644 index 34ad6af5a6..0000000000 --- a/src/components/policy/policy_regular/test/include/policy/mock_pt_ext_representation.h +++ /dev/null @@ -1,139 +0,0 @@ -/* Copyright (c) 2014, Ford Motor Company - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of the Ford Motor Company nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef SRC_COMPONENTS_POLICY_POLICY_REGULAR_TEST_INCLUDE_MOCK_PT_EXT_REPRESENTATION_H_ -#define SRC_COMPONENTS_POLICY_POLICY_REGULAR_TEST_INCLUDE_MOCK_PT_EXT_REPRESENTATION_H_ - -#include -#include - -#include "gmock/gmock.h" - -#include "policy/pt_ext_representation.h" -#include "rpc_base/rpc_base.h" -#include "policy/policy_table/types.h" -#include "mock_pt_representation.h" - -namespace policy_table = ::rpc::policy_table_interface_base; - -namespace policy { -class MockPTExtRepresentation : public MockPTRepresentation, - public PTExtRepresentation { - public: - MOCK_METHOD1(CanAppKeepContext, bool(const std::string& app_id)); - MOCK_METHOD1(CanAppStealFocus, bool(const std::string& app_id)); - MOCK_METHOD2(GetDefaultHMI, - bool(const std::string& app_id, std::string* default_hmi)); - MOCK_METHOD0(ResetUserConsent, bool()); - MOCK_METHOD0(ResetDeviceConsents, bool()); - MOCK_METHOD0(ResetAppConsents, bool()); - MOCK_METHOD3(GetUserPermissionsForDevice, - bool(const std::string&, StringArray*, StringArray*)); - MOCK_METHOD3(GetPermissionsForApp, - bool(const std::string&, - const std::string&, - FunctionalIdType* group_types)); - MOCK_METHOD2(GetDeviceGroupsFromPolicies, - bool(policy_table::Strings*, policy_table::Strings*)); - MOCK_METHOD2( - GetUserFriendlyMsg, - std::vector(const std::vector& msg_code, - const std::string& language)); - MOCK_METHOD8(SetDeviceData, - bool(const std::string& device_id, - const std::string& hardware, - const std::string& firmware, - const std::string& os, - const std::string& os_version, - const std::string& carrier, - const uint32_t number_of_ports, - const std::string& connection_type)); - MOCK_METHOD6(SetDeviceData, - bool(const std::string&, - const std::string&, - const std::string&, - const std::string&, - const std::string&, - const std::string&)); - MOCK_METHOD2(SetMaxNumberPorts, - bool(const std::string& device_id, - unsigned int number_of_ports)); - MOCK_METHOD3(SetUserPermissionsForDevice, - bool(const std::string&, - const StringArray&, - const StringArray&)); - MOCK_METHOD1(SetUserPermissionsForApp, bool(const PermissionConsent&)); - MOCK_METHOD1(IncreaseStatisticsData, bool(StatisticsType type)); - MOCK_METHOD3(SetAppRegistrationLanguage, - bool(const std::string& app_id, - LanguageType type, - const std::string& language)); - MOCK_METHOD3(SetMetaInfo, - bool(const std::string& ccpu_version, - const std::string& wers_country_code, - const std::string& vin)); - MOCK_METHOD0(IsMetaInfoPresent, bool()); - MOCK_METHOD1(SetSystemLanguage, bool(const std::string& language)); - MOCK_METHOD0(GetKmFromSuccessfulExchange, int()); - MOCK_METHOD0(GetDayFromScsExchange, int()); - MOCK_METHOD0(GetIgnitionsFromScsExchange, int()); - MOCK_CONST_METHOD1(Increment, void(const std::string& type)); - MOCK_CONST_METHOD2(Increment, - void(const std::string& app_id, const std::string& type)); - MOCK_CONST_METHOD3(Set, - void(const std::string& app_id, - const std::string& type, - const std::string& value)); - MOCK_CONST_METHOD3(Add, - void(const std::string& app_id, - const std::string& type, - int seconds)); - MOCK_CONST_METHOD3(CountUnconsentedGroups, - bool(const std::string& app_id, - const std::string& device_id, - int* count)); - MOCK_METHOD1(GetFunctionalGroupNames, bool(FunctionalGroupNames& names)); - MOCK_CONST_METHOD1(CleanupUnpairedDevices, bool(const DeviceIds& device_ids)); - MOCK_METHOD2(ReactOnUserDevConsentForApp, - bool(const std::string& app_id, bool is_device_allowed)); - MOCK_METHOD1(SetPredataPolicy, bool(const std::string& app_id)); - MOCK_METHOD2(SetIsPredata, bool(const std::string& app_id, bool is_predata)); - MOCK_CONST_METHOD2(SetUnpairedDevice, - bool(const std::string& device_id, bool unpaired)); - MOCK_CONST_METHOD1(UnpairedDevicesList, bool(DeviceIds* device_ids)); - MOCK_CONST_METHOD2(RemoveAppConsentForGroup, - bool(const std::string& policy_app_id, - const std::string& functional_group)); -}; - -} // namespace policy - -#endif // SRC_COMPONENTS_POLICY_POLICY_REGULAR_TEST_INCLUDE_MOCK_PT_EXT_REPRESENTATION_H_ -- cgit v1.2.1 From f37f43d6ed4d67e26cadeeab74d8c96c1ed77025 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Fri, 19 Oct 2018 13:31:46 -0400 Subject: Update Changelog 5.0.0 --- CHANGELOG.md | 237 ++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 186 insertions(+), 51 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 481f63a805..65d6e6f7c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,61 +1,196 @@ -# Release 4.5.0 +# Release 5.0..0 ## Supported Specifications -- SDL Mobile RPC Spec: [Version 4.5.0](https://github.com/smartdevicelink/rpc_spec/releases/tag/4.5.0) -- SDL Protocol Spec: [Version 5.0.0](https://github.com/smartdevicelink/protocol_spec/releases/tag/5.0.0) +- [SDL Mobile RPC Spec: Version 5.0.0](https://github.com/smartdevicelink/rpc_spec/releases/tag/5.0.0) +- [SDL Protocol Spec: Version 5.1.0](https://github.com/smartdevicelink/protocol_spec/releases/tag/5.1.0) -## Implemented Proposals +## Implemented Proposals / New Features -[Connectivity via iAP-BT and Transport Switch](https://github.com/smartdevicelink/sdl_evolution/blob/master/proposals/0053-Connectivity-via-iAP-BT-and-Transport-Switch.md) - Implementation of a mechanism to change a registered app connected over one transport to another seamlessly. +- [[SDL 0043] Move to the new C++11 standard](https://github.com/smartdevicelink/sdl_core/issues/1493) - C++11 unique_ptr, shared_ptr, atomic utils implemented -[Mark public deprecated methods](https://github.com/smartdevicelink/sdl_evolution/blob/master/proposals/0092-Deprecated-interfaces-markup.md) - Implemented a DEPRECATED macro for marking deprecated methods in the project. Using methods marked with this macro will result in a warning being generated. +- [[SDL 0044] Use Boost library in SDL](https://github.com/smartdevicelink/sdl_core/issues/1523) - Boost Locks, Date/Time, and Filesystem utils implemented -[Remove QT HMI from SDL Core (Partially Complete)](https://github.com/smartdevicelink/sdl_evolution/blob/master/proposals/0110-remove-qt-hmi-from-sdl-core.md) - The `qt_hmi` component was removed from SDL Core, the QT_HMI_API interface and dbus adapter will be removed in the next major release, due to this aspect of the proposal requiring breaking changes. +- [[SDL 0122] Handling VR help requests when application does not send VR help prompt](https://github.com/smartdevicelink/sdl_core/issues/2154) -[Use Boost Library (Partially Complete)](https://github.com/smartdevicelink/sdl_evolution/blob/master/proposals/0044-use-Boost-library.md) - The `boost` library is now installed as a 3rd party library, this library is currently only used in the refactored message broker component. +- [[SDL 0160] Remote Control Radio Parameter Update](https://github.com/smartdevicelink/sdl_core/issues/2162) -## Enhancements -- `DBus` and `libusb` are now dynamically linked, instead of being installed as 3rd-party libraries during the SDL Core build - #2004 +- [[SDL 0181] SDL shall not put RC applications to HMI level NONE when user disables RC in HMI](https://github.com/smartdevicelink/sdl_core/issues/2377) + +- [[SDL 0182] Audio Source AM/FM/XM/DAB](https://github.com/smartdevicelink/sdl_core/issues/2338) + +- [[SDL 0165] Remote Control Lights More Names and Status Values](https://github.com/smartdevicelink/sdl_core/issues/2172) + +- [[SDL 0099] New remote control modules (LIGHT, AUDIO, HMI_SETTINGS) and parameters (SIS Data)](https://github.com/smartdevicelink/sdl_core/issues/1798) + +- [[SDL 0178] Interior Vehicle Data Subscription Management and Data Caching in SDL](https://github.com/smartdevicelink/sdl_core/issues/2318) + +- [[SDL 0153] Support for Short and Full UUID App ID](https://github.com/smartdevicelink/sdl_core/issues/2159) + +- [[SDL 0170] SDL behavior in case of LOW_VOLTAGE event](https://github.com/smartdevicelink/sdl_core/issues/2233) + +- [[SDL 0064] Choice-VR optional](https://github.com/smartdevicelink/sdl_core/issues/2160) + +- [[SDL 0175] Updating DOP value range for GPS notification](https://github.com/smartdevicelink/sdl_core/issues/2317) + +- [[SDL 0089] Mobile API versioning](https://github.com/smartdevicelink/sdl_core/issues/2248) + +- [[SDL 0150] Enhancing onHMIStatus with a New Parameter for Video Streaming State](https://github.com/smartdevicelink/sdl_core/issues/2129) + +- [[SDL 0109] SetAudioStreamingIndicator RPC](https://github.com/smartdevicelink/sdl_core/issues/2059) + +- [[SDL 0041] Provide AppIcon resumption across app registration requests](https://github.com/smartdevicelink/sdl_core/issues/1456) + +- [[SDL 0139] Clarification of audio format details of AudioPassThru](https://github.com/smartdevicelink/sdl_core/issues/2014) + +- [[SDL 0105] Remote Control - Seat](https://github.com/smartdevicelink/sdl_core/issues/1860) + +- [[SDL 0172] Remote Control - Update OnRCStatus with a new allowed parameter](https://github.com/smartdevicelink/sdl_core/issues/2244) + +- [[SDL 0106] Remote Control - OnRCStatus notification](https://github.com/smartdevicelink/sdl_core/issues/1930) + +- [[SDL 0145] Driver Distraction Notification Upon Registration](https://github.com/smartdevicelink/sdl_core/issues/2054) + +- [[SDL 0102] New vehicle data - ElectronicParkBrakeStatus ](https://github.com/smartdevicelink/sdl_core/issues/1815) + +- [[SDL 0110] Remove QT HMI from SDL Core](https://github.com/smartdevicelink/sdl_core/issues/1857) - Fully removed from project + +- [[SDL 0141] Supporting simultaneous multiple transports](https://github.com/smartdevicelink/sdl_core/issues/2065) + +- [[SDL 0149] Add capability to disable resumption based on app type and transport type](https://github.com/smartdevicelink/sdl_core/issues/2130) + +- [[SDL 0107] New vehicle data - TurnSignal](https://github.com/smartdevicelink/sdl_core/issues/1859) + +- [[SDL 0085] SubMenu Icon](https://github.com/smartdevicelink/sdl_core/issues/1747) + +- [[SDL 0168] RPC design refactoring](https://github.com/smartdevicelink/sdl_core/issues/2189) + +- [[SDL 0120] GetSystemTime RPC](https://github.com/smartdevicelink/sdl_core/issues/1963) + +- [[SDL 0040] DTLS encryption](https://github.com/smartdevicelink/sdl_core/issues/1479) + +- [[SDL 0014] Adding Audio File Playback to TTSChunk](https://github.com/smartdevicelink/sdl_core/issues/1277) + +- [[SDL 0063] Display name parameter](https://github.com/smartdevicelink/sdl_core/issues/1589) + +- [[SDL 0083] Expandable Design for Proprietary Data Exchange](https://github.com/smartdevicelink/sdl_core/issues/1734) + +- [[SDL 0042] SDL must transfer RPCs with invalid image reference parameters to the HMI](https://github.com/smartdevicelink/sdl_core/issues/1428) + +- [[SDL 0097] Tire pressure additions](https://github.com/smartdevicelink/sdl_core/issues/1766) + +- [[SDL 0062] Template images](https://github.com/smartdevicelink/sdl_core/issues/1588) + +- [[SDL 0037] Expand Mobile putfile RPC](https://github.com/smartdevicelink/sdl_core/issues/1455) + +- [[SDL 0164] Modernize Ubuntu Support](https://github.com/smartdevicelink/sdl_core/issues/2170) + +- [[SDL 0162] Define Handling of Duplicate Correlation IDs](https://github.com/smartdevicelink/sdl_core/issues/2169) + +- [[SDL 0151] ImageFieldName for SecondaryImage](https://github.com/smartdevicelink/sdl_core/issues/2099) + +- [[SDL 0082] New vehicle data - EngineOilLife](https://github.com/smartdevicelink/sdl_core/issues/1733) + +- [[SDL 0147] Template Improvements: Color Scheme](https://github.com/smartdevicelink/sdl_core/issues/2082) + +- [[SDL 0096] Deliver build configuration](https://github.com/smartdevicelink/sdl_core/issues/1765) + +- [[SDL 0072] New vehicle data - FuelRange](https://github.com/smartdevicelink/sdl_core/issues/1656) + +- [Inclusion of PLAY_PAUSE as a subscribable button](https://github.com/smartdevicelink/sdl_core/pull/930) ## Bug Fixes -- [Remove OEM Specific references in SDL policy table preload file](https://github.com/smartdevicelink/sdl_core/issues/1252) -- ["resultCode" should be more descriptive than "INVALID_DATA"](https://github.com/smartdevicelink/sdl_core/issues/31) -- [SDL doesn't apply sequence SUSPEND -> OnSDLAwake -> SUSPEND -> IGN_OFF for saving resumption data](https://github.com/smartdevicelink/sdl_core/issues/1395) -- [SDL responds "resultCode: SUCCESS" while dataType:VEHICLEDATA_EXTERNTEMP is VEHICLE_DATA_NOT_AVAILABLE and not in subscribed list store](https://github.com/smartdevicelink/sdl_core/issues/982) -- [Policies SDL should be case-insensetive to "AppID" against listed in policies manager](https://github.com/smartdevicelink/sdl_core/issues/992) -- [App is disconnected due to PROTOCOL_VIOLATION when start audio streaming after rejected 2 times then accepted](https://github.com/smartdevicelink/sdl_core/issues/1004) -- [SDL doesn't set unsuccessful "message" value to "info" param in case HMI responds via single UI.RPC when Interface.IsReady missing](https://github.com/smartdevicelink/sdl_core/issues/997) -- [Navigation SDL does not respond info message in case GENERIC_ERROR watchdog timeout from HMI](https://github.com/smartdevicelink/sdl_core/issues/990) -- [SDL does not respond info message in case GENERIC_ERROR watchdog timeout from HM](https://github.com/smartdevicelink/sdl_core/issues/1012) -- [SDL doesn't send info parameter when result of ResetGlobalProperties is GENERIC_ERROR](https://github.com/smartdevicelink/sdl_core/issues/1016) -- [SDL does not send StopAudioStream() if exit app while Video service and Audio service are starting.](https://github.com/smartdevicelink/sdl_core/issues/1002) -- [APIs AlertManeuver: SDL responds GENERIC_ERROR instead of INVALID_DATA when soft button has Type is Image or Both and Text is whitespace or \t or \n or empty](https://github.com/smartdevicelink/sdl_core/issues/980) -- [IVSU SDL doesn't reject SystemRequest with filenam=IVSU but w/o binary data.](https://github.com/smartdevicelink/sdl_core/issues/976) -- [Memory leaks: SDL does not release memory after sending AddCommand limit exhausted](https://github.com/smartdevicelink/sdl_core/issues/1029) -- [Negative result code send instead of IGNORED for UnsubscribedVehicleData when VehicleInfo IsReady Missing](https://github.com/smartdevicelink/sdl_core/issues/996) -- [API SDL responds "UNSUPPORTED_RESOURCE", success= false in case only have "UNSUPPORTED_RESOURCE" to Navigation.AlertManeuver](https://github.com/smartdevicelink/sdl_core/issues/989) -- [Default app policies are never updated after a PTU](https://github.com/smartdevicelink/sdl_core/issues/1772) -- [Build fails with GCC6+](https://github.com/smartdevicelink/sdl_core/issues/1975) -- [Remote Control test suite fails](https://github.com/smartdevicelink/sdl_core/issues/1993) -- [PoliciesManager allows all requested params in case "parameters" field is empty](https://github.com/smartdevicelink/sdl_core/issues/1873) -- [OnDriverDistraction SDL does not send notification to app right after this app changes level from NONE to any other](https://github.com/smartdevicelink/sdl_core/issues/1881) -- [Protect access to Resumption data during LastState::SaveStateToFileSystem](https://github.com/smartdevicelink/sdl_core/issues/1953) -- [Need to protect cache manager "pt_" from concurrent access](https://github.com/smartdevicelink/sdl_core/issues/1961) -- [Prevent deadlock in EventDispatcherIimpl::raise_event](https://github.com/smartdevicelink/sdl_core/issues/1949) -- [Bluetooth StartService fail after Core restarted](https://github.com/smartdevicelink/sdl_core/issues/1932) -- [Silent error caused by implicit conversion of SmartPointer to integer](https://github.com/smartdevicelink/sdl_core/issues/1834) -- [AOA USB transport buffer size too small](https://github.com/smartdevicelink/sdl_core/issues/1863) -- [Lock screen icon URL should be updated](https://github.com/smartdevicelink/sdl_core/issues/1646) -- [Broken link in README.md for Software Architecture Documentation](https://github.com/smartdevicelink/sdl_core/issues/2091) -- [SDL doesn't send OnPermissionsChange in case of external user consent](https://github.com/smartdevicelink/sdl_core/issues/2072) -- [Build fails when ENABLE_SECURITY=OFF](https://github.com/smartdevicelink/sdl_core/issues/2073) - -### Security Related Fixes -- [SDL must start PTU for navi app right after app successfully registration](https://github.com/smartdevicelink/sdl_core/issues/1925) -- [SDL must start PTU for any app except navi right after app successfully request to start first secure service](https://github.com/smartdevicelink/sdl_core/issues/1924) -- [PolicyTableUpdate is failed by any reason and "ForceProtectedService"=ON at .ini file](https://github.com/smartdevicelink/sdl_core/issues/1923) -- [PolicyTableUpdate has NO "certificate" and "ForceProtectedService"=ON at .ini file](https://github.com/smartdevicelink/sdl_core/issues/1922) -- [SDL must respond NACK in case navigation app connected over protocol v2 sends StartService for audio service](https://github.com/smartdevicelink/sdl_core/issues/1912) -- [PolicyTableUpdate has NO "certificate" and "ForceProtectedService"=OFF at .ini file](https://github.com/smartdevicelink/sdl_core/issues/1894) -- [PolicyTableUpdate is failed by any reason and "ForceProtectedService"=OFF at .ini file](https://github.com/smartdevicelink/sdl_core/issues/1891) -- [PolicyTableUpdate is valid and brings "certificate"](https://github.com/smartdevicelink/sdl_core/issues/1888) + +- [SDL process RC requests with resultCode DISALLOWED after IGN_OFF and IGN_ON](https://github.com/smartdevicelink/sdl_core/issues/2670) + +- [SDL stop sending OnInteriorVehicleData notifications after the app sent a GetInteriorVehicleData without optional parameter subscribe](https://github.com/smartdevicelink/sdl_core/issues/2657) + +- [Make Size() function thread safe to avoid core dump](https://github.com/smartdevicelink/sdl_core/issues/2603) + +- [SDL does not cut parameters not related to defined module type from RC.SetInteriorVD](https://github.com/smartdevicelink/sdl_core/issues/2664) + +- [Add missing PRNDL enum value to the HMI API ](https://github.com/smartdevicelink/sdl_core/issues/2431) + +- [EXTERNAL_PROPRIETARY user consent is broken when permissions are in default object](https://github.com/smartdevicelink/sdl_core/issues/2146) + +- [Processing invalid PT after cutting off unknown_parameter or unknown_RPC](https://github.com/smartdevicelink/sdl_core/issues/1921) + +- [SDL does not check for non-mandatory parameters](https://github.com/smartdevicelink/sdl_core/issues/2443) + +- [SDL must close only session in case mobile app does not answer on Heartbeat_request](https://github.com/smartdevicelink/sdl_core/issues/1893) + +- [App does not activate when policies are disabled](https://github.com/smartdevicelink/sdl_core/issues/842) + +- [Pure virtual method called during SDL shutdown](https://github.com/smartdevicelink/sdl_core/issues/2433) + +- [SDL build is failing when ENABLE_LOG=OFF](https://github.com/smartdevicelink/sdl_core/issues/2341) + +- [Wrong policy permissions calculation in EXTERNAL_PROPRIETARY flow](https://github.com/smartdevicelink/sdl_core/issues/2405) + +- [Functional groupings parameters has max size of 24](https://github.com/smartdevicelink/sdl_core/issues/2470) + +- [AudioPassThru does not send audio data in raw PCM data](https://github.com/smartdevicelink/sdl_core/issues/1928) + +- [Deprecated GetDataOnSessionKey() cannot be overloaded in cross-compiling](https://github.com/smartdevicelink/sdl_core/issues/2137) + +- [V5 Protocol Messages do not encrypt payload of Control Frame Message Types](https://github.com/smartdevicelink/sdl_core/issues/2142) + +- [Remove TLS Handshake App Name String Compare](https://github.com/smartdevicelink/sdl_core/issues/1617) + +- [The reference of wild pointer cause to memory leak](https://github.com/smartdevicelink/sdl_core/issues/860) + +- [Build failing on Fedora 25](https://github.com/smartdevicelink/sdl_core/issues/1495) + +- [Add missing RPC changes: SpaceAvailable & CurrentTemperatureAvailable](https://github.com/smartdevicelink/sdl_core/pull/2588) + +- [Invalid memory accesses detected by valgrind](https://github.com/smartdevicelink/sdl_core/issues/2177) + +- [Memory leaks in media_manager_test unit tests](https://github.com/smartdevicelink/sdl_core/issues/2274) + +- [Empty moduleType disallows all RPC requests after ignition cycle](https://github.com/smartdevicelink/sdl_core/issues/2547) + +- [Feature/boost datetime implementation](https://github.com/smartdevicelink/sdl_core/pull/2278) + +- [Flush logger before deleting message loop thread](https://github.com/smartdevicelink/sdl_core/pull/2532) + +- [SDL Proxy crash happens when receiving SDLOnAppInterfaceUnregistered notification with reason -1 (INVALID_ENUM)](https://github.com/smartdevicelink/sdl_core/issues/2300) + +- [OnHMIStatus returns null hmiLevel if RPC has invalid/incomplete parameters](https://github.com/smartdevicelink/sdl_core/issues/2285) + +- [Invalid memory access in CacheManager::CheckPermissions()](https://github.com/smartdevicelink/sdl_core/issues/2298) + +- [Cert processing invalid, module certificate should be updated when a policy table update occurs](https://github.com/smartdevicelink/sdl_core/issues/2191) + +- [Cert processing invalid, CertificatePath and CACertificatePath keywords are nonfunctional](https://github.com/smartdevicelink/sdl_core/issues/2190) + +- [RegisterAppInterface Display Capabilities Segfault](https://github.com/smartdevicelink/sdl_core/issues/2220) + +- [Duplicate "PendingRequestsAmount" entries in smartDeviceLink.ini](https://github.com/smartdevicelink/sdl_core/issues/1790) + +## Enhancements + +- [PrintSmartObject function can not print to log file](https://github.com/smartdevicelink/sdl_core/issues/2574) + +## Best Practice + +- [AllowDeviceToConnect is never used](https://github.com/smartdevicelink/sdl_core/issues/494) + +- [Fix UnsubscribeWayPoints typo](https://github.com/smartdevicelink/sdl_core/pull/2504) + +- [Namespace capitalization](https://github.com/smartdevicelink/sdl_core/issues/33) + +- [Remove "SetIcon" Files](https://github.com/smartdevicelink/sdl_core/issues/1594) + +- [Initialization (et al) method return values](https://github.com/smartdevicelink/sdl_core/issues/34) + +- [Fix misspellings of "subscription"](https://github.com/smartdevicelink/sdl_core/issues/736) + + +## Documentation + +- [Add FAQ link to README.md](https://github.com/smartdevicelink/sdl_core/pull/1366) + +- [Broken Links in SDD Documentation](https://github.com/smartdevicelink/sdl_core/issues/2107) + +- [Alter build instructions for slight clarity improvements](https://github.com/smartdevicelink/sdl_core/pull/218) + +- [Add third_party file](https://github.com/smartdevicelink/sdl_core/issues/2610) \ No newline at end of file -- cgit v1.2.1 From 961ff1c362bbd731c6a22d320f49781933551efe Mon Sep 17 00:00:00 2001 From: JackLivio Date: Fri, 19 Oct 2018 13:34:33 -0400 Subject: Fix Typo --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 65d6e6f7c3..1c693f2b22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -# Release 5.0..0 +# Release 5.0.0 ## Supported Specifications - [SDL Mobile RPC Spec: Version 5.0.0](https://github.com/smartdevicelink/rpc_spec/releases/tag/5.0.0) @@ -193,4 +193,4 @@ - [Alter build instructions for slight clarity improvements](https://github.com/smartdevicelink/sdl_core/pull/218) -- [Add third_party file](https://github.com/smartdevicelink/sdl_core/issues/2610) \ No newline at end of file +- [Add third_party file](https://github.com/smartdevicelink/sdl_core/issues/2610) -- cgit v1.2.1