From 8add3513c37111f00708e1cc809838808c6cc6f8 Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 20 Jul 2018 13:39:34 +0300 Subject: Process policy events and application events in InteriorDataManager --- .../rc_rpc_plugin/resource_allocation_manager.h | 3 -- .../resource_allocation_manager_impl.h | 8 ---- .../rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc | 12 ++---- .../src/resource_allocation_manager_impl.cc | 48 ++-------------------- .../test/commands/button_press_request_test.cc | 4 +- .../set_interior_vehicle_data_request_test.cc | 2 +- .../mock/mock_resource_allocation_manager.h | 3 -- 7 files changed, 12 insertions(+), 68 deletions(-) (limited to 'src/components') diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h index 2f9659f0ec..67598b667b 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h @@ -154,9 +154,6 @@ class ResourceAllocationManager { */ virtual void ResetAllAllocations() = 0; - virtual RCAppExtensionPtr GetApplicationExtention( - application_manager::ApplicationSharedPtr application) = 0; - /** * @brief Create and send OnRCStatusNotification to mobile and HMI * @param event trigger for notification sending diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h index 7ba2aefcdc..d7d3a4743f 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h @@ -110,14 +110,6 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager { void ResetAllAllocations() FINAL; - /** - * @brief GetApplicationExtention Provides access to application RC extention - * @param application Application - * @return Pointer to RC extention of application or NULL if not available - */ - RCAppExtensionPtr GetApplicationExtention( - application_manager::ApplicationSharedPtr application) FINAL; - void SendOnRCStatusNotifications( NotificationTrigger::eType event, application_manager::ApplicationSharedPtr application) FINAL; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc index 1579412cac..fd6b4e86ac 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc @@ -86,14 +86,8 @@ application_manager::CommandFactory& RCRPCPlugin::GetCommandFactory() { void RCRPCPlugin::OnPolicyEvent( application_manager::plugin_manager::PolicyEvent event) { - switch (event) { - case plugins::kApplicationPolicyUpdated: { - resource_allocation_manager_->OnPolicyEvent(event); - break; - } - default: - break; - } + resource_allocation_manager_->OnPolicyEvent(event); + interior_data_manager_->OnPolicyEvent(event); } void RCRPCPlugin::OnApplicationEvent( @@ -112,10 +106,12 @@ void RCRPCPlugin::OnApplicationEvent( } case plugins::kApplicationExit: { resource_allocation_manager_->OnApplicationEvent(event, application); + interior_data_manager_->OnApplicationEvent(event, application); break; } case plugins::kApplicationUnregistered: { resource_allocation_manager_->OnApplicationEvent(event, application); + interior_data_manager_->OnApplicationEvent(event, application); break; } default: diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc index 59d1919bb5..c841566949 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc @@ -36,9 +36,10 @@ #include "interfaces/HMI_API.h" #include "interfaces/MOBILE_API.h" #include "smart_objects/enum_schema_item.h" -#include "rc_rpc_plugin/rc_rpc_plugin.h" #include "application_manager/message_helper.h" +#include "rc_rpc_plugin/rc_rpc_plugin.h" #include "rc_rpc_plugin/rc_module_constants.h" +#include "rc_rpc_plugin/rc_helpers.h" #include "json/json.h" #include "utils/helpers.h" @@ -166,13 +167,10 @@ void ResourceAllocationManagerImpl::ProcessApplicationPolicyUpdate() { allowed_modules.end(), std::back_inserter(disallowed_modules)); - RCAppExtensionPtr rc_extention = GetApplicationExtention(app_ptr); + auto rc_extention = RCHelpers::GetRCExtension(**app); Resources::const_iterator module = disallowed_modules.begin(); for (; disallowed_modules.end() != module; ++module) { ReleaseResource(*module, application_id); - if (rc_extention) { - rc_extention->UnsubscribeFromInteriorVehicleData(*module); - } } if (!disallowed_modules.empty()) { SendOnRCStatusNotifications( @@ -182,40 +180,6 @@ void ResourceAllocationManagerImpl::ProcessApplicationPolicyUpdate() { } } -RCAppExtensionPtr ResourceAllocationManagerImpl::GetApplicationExtention( - application_manager::ApplicationSharedPtr application) { - LOG4CXX_AUTO_TRACE(logger_); - RCAppExtensionPtr rc_app_extension; - if (!application) { - return rc_app_extension; - } - - application_manager::AppExtensionPtr app_extension = - application->QueryInterface(RCRPCPlugin::kRCPluginID); - if (!app_extension) { - return rc_app_extension; - } - - rc_app_extension = std::static_pointer_cast(app_extension); - - return rc_app_extension; -} - -void ResourceAllocationManagerImpl::RemoveAppsSubscriptions(const Apps& apps) { - LOG4CXX_AUTO_TRACE(logger_); - Apps::const_iterator app = apps.begin(); - for (; apps.end() != app; ++app) { - application_manager::ApplicationSharedPtr app_ptr = *app; - if (!app_ptr) { - continue; - } - RCAppExtensionPtr rc_extention = GetApplicationExtention(app_ptr); - if (rc_extention) { - rc_extention->UnsubscribeFromInteriorVehicleData(); - } - } -} - template EnumType StringToEnum(const std::string& str) { using smart_objects::EnumConversionHelper; @@ -235,6 +199,7 @@ void ConstructOnRCStatusNotificationParams( using smart_objects::SmartType_Map; using smart_objects::SmartType_Array; LOG4CXX_AUTO_TRACE(logger_); + auto modules_inserter = [](SmartObject& result_modules) { return [&result_modules](const std::string& module_name) { smart_objects::SmartObject module_data = @@ -513,9 +478,6 @@ void ResourceAllocationManagerImpl::OnApplicationEvent( NotificationTrigger::MODULE_ALLOCATION, std::shared_ptr()); } - Apps app_list; - app_list.push_back(application); - RemoveAppsSubscriptions(app_list); } } @@ -532,8 +494,6 @@ void ResourceAllocationManagerImpl::OnPolicyEvent( if (PolicyEvent::kApplicationsDisabled == event) { ResetAllAllocations(); - Apps app_list = RCRPCPlugin::GetRCApplications(app_mngr_); - RemoveAppsSubscriptions(app_list); return; } } diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc index d9b21afe20..022a3e51c9 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc @@ -37,6 +37,8 @@ #include "rc_rpc_plugin/rc_rpc_plugin.h" #include "rc_rpc_plugin/rc_module_constants.h" #include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h" +#include "rc_rpc_plugin/mock/mock_interior_data_cache.h" +#include "rc_rpc_plugin/mock/mock_interior_data_manager.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" #include "application_manager/commands/command_request_test.h" @@ -115,7 +117,7 @@ class ButtonPressRequestTest } rc_capabilities_[strings::kbuttonCapabilities] = button_caps; ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_)); - ON_CALL(mock_allocation_manager_, GetApplicationExtention(_)) + ON_CALL(*mock_app_, QueryInterface(RCRPCPlugin::kRCPluginID)) .WillByDefault(Return(rc_app_extention_)); ON_CALL(app_mngr_, GetPolicyHandler()) .WillByDefault(ReturnRef(mock_policy_handler_)); 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 deb912c49f..4144beea2a 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 @@ -78,7 +78,7 @@ class SetInteriorVehicleDataRequestTest .WillByDefault(Return(application_manager::HmiInterfaces:: InterfaceState::STATE_AVAILABLE)); ON_CALL(app_mngr_, application(kAppId)).WillByDefault(Return(mock_app_)); - ON_CALL(mock_allocation_manager_, GetApplicationExtention(_)) + ON_CALL(*mock_app_, QueryInterface(RCRPCPlugin::kRCPluginID)) .WillByDefault(Return(rc_app_extention_)); ON_CALL(*mock_app_, policy_app_id()).WillByDefault(Return(kPolicyAppId)); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_resource_allocation_manager.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_resource_allocation_manager.h index 18308f62cf..72ace1432a 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_resource_allocation_manager.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_resource_allocation_manager.h @@ -61,9 +61,6 @@ class MockResourceAllocationManager const uint32_t app_id, const rc_rpc_plugin::ResourceState::eType state)); MOCK_CONST_METHOD1(IsResourceFree, bool(const std::string& module_type)); - MOCK_METHOD1(GetApplicationExtention, - rc_rpc_plugin::RCAppExtensionPtr( - application_manager::ApplicationSharedPtr application)); MOCK_METHOD0(ResetAllAllocations, void()); MOCK_METHOD2(SendOnRCStatusNotifications, void(rc_rpc_plugin::NotificationTrigger::eType, -- cgit v1.2.1