diff options
author | Ira Lytvynenko (GitHub) <ILytvynenko@luxoft.com> | 2018-04-05 14:25:45 +0300 |
---|---|---|
committer | Ira Lytvynenko (GitHub) <ILytvynenko@luxoft.com> | 2018-07-12 13:31:03 +0300 |
commit | 0bd0303698e2545b62e9890f134d39dd87143deb (patch) | |
tree | 3253e7a9df6a88d47b8717b1b9cef6948542d753 /src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc | |
parent | 1072b44f8fb7df2c934927d90077ea1bd92b2de4 (diff) | |
download | sdl_core-0bd0303698e2545b62e9890f134d39dd87143deb.tar.gz |
Fix SDL sends multiple OnRCStatus notification in case of app unregistration
Fix disabling RC-functionality
Diffstat (limited to 'src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc')
-rw-r--r-- | src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc | 60 |
1 files changed, 37 insertions, 23 deletions
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 4b70830de7..e9a56007df 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 @@ -52,7 +52,8 @@ ResourceAllocationManagerImpl::ResourceAllocationManagerImpl( application_manager::rpc_service::RPCService& rpc_service) : current_access_mode_(hmi_apis::Common_RCAccessMode::AUTO_ALLOW) , app_mngr_(app_mngr) - , rpc_service_(rpc_service) {} + , rpc_service_(rpc_service) + , is_rc_enabled_(true) {} ResourceAllocationManagerImpl::~ResourceAllocationManagerImpl() {} @@ -173,6 +174,7 @@ void ResourceAllocationManagerImpl::ProcessApplicationPolicyUpdate() { if (rc_extention) { rc_extention->UnsubscribeFromInteriorVehicleData(*module); } + SendOnRCStatusNotification(); } } } @@ -234,7 +236,8 @@ EnumType StringToEnum(const std::string& str) { void ConstructOnRCStatusNotificationParams( smart_objects::SmartObject& msg_params, const std::map<std::string, uint32_t>& allocated_resources, - const std::vector<std::string>& supported_resources) { + const std::vector<std::string>& supported_resources, + const u_int32_t app_id) { namespace strings = application_manager::strings; namespace message_params = rc_rpc_plugin::message_params; using smart_objects::SmartObject; @@ -253,8 +256,10 @@ void ConstructOnRCStatusNotificationParams( }; }; SmartObject allocated_modules = SmartObject(SmartType_Array); - for (auto& module : allocated_resources) { - modules_inserter(allocated_modules)(module.first); + for (const auto& module : allocated_resources) { + if (module.second == app_id) { + modules_inserter(allocated_modules)(module.first); + } } SmartObject free_modules = SmartObject(SmartType_Array); for (auto& module : supported_resources) { @@ -268,29 +273,29 @@ void ConstructOnRCStatusNotificationParams( smart_objects::SmartObjectSPtr ResourceAllocationManagerImpl::CreateOnRCStatusNotificationToMobile( - const uint32_t app_id) { + const application_manager::ApplicationSharedPtr app) { LOG4CXX_AUTO_TRACE(logger_); using application_manager::MessageHelper; - auto to_mobile_msg = MessageHelper::CreateNotification( - mobile_apis::FunctionID::OnRCStatusID, app_id); - auto& msg_params = (*to_mobile_msg)[application_manager::strings::msg_params]; + auto msg_to_mobile = MessageHelper::CreateNotification( + mobile_apis::FunctionID::OnRCStatusID, app->app_id()); + auto& msg_params = (*msg_to_mobile)[application_manager::strings::msg_params]; ConstructOnRCStatusNotificationParams( - msg_params, allocated_resources_, all_supported_modules()); - return to_mobile_msg; + msg_params, allocated_resources_, all_supported_modules(), app->app_id()); + return msg_to_mobile; } smart_objects::SmartObjectSPtr ResourceAllocationManagerImpl::CreateOnRCStatusNotificationToHmi( - const uint32_t app_id) { + const application_manager::ApplicationSharedPtr app) { LOG4CXX_AUTO_TRACE(logger_); using application_manager::MessageHelper; - auto to_hmi_msg = + auto msg_to_hmi = MessageHelper::CreateHMINotification(hmi_apis::FunctionID::RC_OnRCStatus); - auto& msg_params = (*to_hmi_msg)[application_manager::strings::msg_params]; + auto& msg_params = (*msg_to_hmi)[application_manager::strings::msg_params]; ConstructOnRCStatusNotificationParams( - msg_params, allocated_resources_, all_supported_modules()); - msg_params[application_manager::strings::app_id] = app_id; - return to_hmi_msg; + msg_params, allocated_resources_, all_supported_modules(), app->app_id()); + msg_params[application_manager::strings::app_id] = app->hmi_app_id(); + return msg_to_hmi; } void ResourceAllocationManagerImpl::SetResourceAquired( @@ -303,14 +308,22 @@ void ResourceAllocationManagerImpl::SetResourceAquired( void ResourceAllocationManagerImpl::SendOnRCStatusNotification() { LOG4CXX_AUTO_TRACE(logger_); auto rc_apps = RCRPCPlugin::GetRCApplications(app_mngr_); - for (auto& rc_app : rc_apps) { - auto to_mobile = CreateOnRCStatusNotificationToMobile(rc_app->app_id()); - rpc_service_.SendMessageToMobile(to_mobile); - auto to_HMI = CreateOnRCStatusNotificationToHmi(rc_app->hmi_app_id()); - rpc_service_.SendMessageToHMI(to_HMI); + for (const auto& rc_app : rc_apps) { + auto msg_to_mobile = CreateOnRCStatusNotificationToMobile(rc_app); + rpc_service_.SendMessageToMobile(msg_to_mobile); + auto msg_to_hmi = CreateOnRCStatusNotificationToHmi(rc_app); + rpc_service_.SendMessageToHMI(msg_to_hmi); } } +bool ResourceAllocationManagerImpl::is_rc_enabled() const { + return is_rc_enabled_; +} + +void ResourceAllocationManagerImpl::set_rc_enabled(const bool value) { + is_rc_enabled_ = value; +} + void ResourceAllocationManagerImpl::SetResourceFree( const std::string& module_type, const uint32_t app_id) { AllocatedResources::const_iterator allocation = @@ -327,7 +340,6 @@ void ResourceAllocationManagerImpl::SetResourceFree( } allocated_resources_.erase(allocation); LOG4CXX_DEBUG(logger_, "Resource " << module_type << " is released."); - SendOnRCStatusNotification(); } std::vector<std::string> @@ -473,7 +485,9 @@ void ResourceAllocationManagerImpl::OnApplicationEvent( for (; acquired_modules.end() != module; ++module) { ReleaseResource(*module, application->app_id()); } - + if (!acquired_modules.empty()) { + SendOnRCStatusNotification(); + } Apps app_list; app_list.push_back(application); RemoveAppsSubscriptions(app_list); |