summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIra Lytvynenko <ILytvynenko@luxoft.com>2018-03-04 15:18:07 +0200
committerIra Lytvynenko (GitHub) <ILytvynenko@luxoft.com>2018-07-12 13:31:03 +0300
commite97601acd9013c237a252c523590ef5fcfb83ca3 (patch)
tree6e0355b0984840eb5513592a326b27c775416403
parent82a8a55773954698803e93633f8800f71871b7dc (diff)
downloadsdl_core-e97601acd9013c237a252c523590ef5fcfb83ca3.tar.gz
Fix OnRCStatus sending after app registration
Fix OnRCStatusNotification
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h6
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h7
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc30
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_resource_allocation_manager.h1
5 files changed, 29 insertions, 16 deletions
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 0dc8b59f8f..71ee5fddff 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
@@ -144,6 +144,12 @@ class ResourceAllocationManager {
virtual RCAppExtensionPtr GetApplicationExtention(
application_manager::ApplicationSharedPtr application) = 0;
+ /**
+ * @brief Create and send OnRCStatusNotification to mobile and HMI
+ * @param application
+ */
+ virtual void SendOnRCStatusNotification() = 0;
+
virtual ~ResourceAllocationManager() {}
};
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 0bbea236e3..434bde2a82 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
@@ -118,6 +118,8 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager {
RCAppExtensionPtr GetApplicationExtention(
application_manager::ApplicationSharedPtr application) FINAL;
+ void SendOnRCStatusNotification() FINAL;
+
private:
typedef std::vector<application_manager::ApplicationSharedPtr> Apps;
@@ -127,10 +129,11 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager {
* @param app_id application to send OnRCStatusNotification
* @return smart object with mobile OnRCStatusNotification
*/
- smart_objects::SmartObjectSPtr CreateOnRCStatusNotification(
+ smart_objects::SmartObjectSPtr CreateOnRCStatusNotificationToMobile(
const uint32_t app_id);
- smart_objects::SmartObjectSPtr CreateOnRCStatusNotification();
+ smart_objects::SmartObjectSPtr CreateOnRCStatusNotificationToHmi(
+ const uint32_t app_id);
/**
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 bb32f1d7fd..f423a66fc6 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
@@ -91,6 +91,7 @@ void RCRPCPlugin::OnApplicationEvent(
switch (event) {
case plugins::kApplicationRegistered: {
application->AddExtension(new RCAppExtension(kRCPluginID));
+ resource_allocation_manager_->SendOnRCStatusNotification();
break;
}
case plugins::kApplicationExit: {
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 cd08313572..4b70830de7 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
@@ -249,6 +249,7 @@ void ConstructOnRCStatusNotificationParams(
auto module_type =
StringToEnum<mobile_apis::ModuleType::eType>(module_name);
module_data[message_params::kModuleType] = module_type;
+ result_modules.asArray()->push_back(module_data);
};
};
SmartObject allocated_modules = SmartObject(SmartType_Array);
@@ -266,7 +267,7 @@ void ConstructOnRCStatusNotificationParams(
}
smart_objects::SmartObjectSPtr
-ResourceAllocationManagerImpl::CreateOnRCStatusNotification(
+ResourceAllocationManagerImpl::CreateOnRCStatusNotificationToMobile(
const uint32_t app_id) {
LOG4CXX_AUTO_TRACE(logger_);
using application_manager::MessageHelper;
@@ -279,7 +280,8 @@ ResourceAllocationManagerImpl::CreateOnRCStatusNotification(
}
smart_objects::SmartObjectSPtr
-ResourceAllocationManagerImpl::CreateOnRCStatusNotification() {
+ResourceAllocationManagerImpl::CreateOnRCStatusNotificationToHmi(
+ const uint32_t app_id) {
LOG4CXX_AUTO_TRACE(logger_);
using application_manager::MessageHelper;
auto to_hmi_msg =
@@ -287,20 +289,26 @@ ResourceAllocationManagerImpl::CreateOnRCStatusNotification() {
auto& msg_params = (*to_hmi_msg)[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;
}
void ResourceAllocationManagerImpl::SetResourceAquired(
const std::string& module_type, const uint32_t app_id) {
LOG4CXX_AUTO_TRACE(logger_);
+ allocated_resources_[module_type] = app_id;
+ SendOnRCStatusNotification();
+}
+
+void ResourceAllocationManagerImpl::SendOnRCStatusNotification() {
+ LOG4CXX_AUTO_TRACE(logger_);
auto rc_apps = RCRPCPlugin::GetRCApplications(app_mngr_);
for (auto& rc_app : rc_apps) {
- auto notification = CreateOnRCStatusNotification(rc_app->app_id());
- rpc_service_.SendMessageToMobile(notification);
+ 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);
}
- auto notification = CreateOnRCStatusNotification();
- rpc_service_.SendMessageToHMI(notification);
- allocated_resources_[module_type] = app_id;
}
void ResourceAllocationManagerImpl::SetResourceFree(
@@ -319,13 +327,7 @@ void ResourceAllocationManagerImpl::SetResourceFree(
}
allocated_resources_.erase(allocation);
LOG4CXX_DEBUG(logger_, "Resource " << module_type << " is released.");
- auto rc_apps = RCRPCPlugin::GetRCApplications(app_mngr_);
- for (auto& rc_app : rc_apps) {
- auto notification = CreateOnRCStatusNotification(rc_app->app_id());
- rpc_service_.SendMessageToMobile(notification);
- }
- auto notification = CreateOnRCStatusNotification();
- rpc_service_.SendMessageToHMI(notification);
+ SendOnRCStatusNotification();
}
std::vector<std::string>
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 fb9326209c..ba61620d1d 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
@@ -65,6 +65,7 @@ class MockResourceAllocationManager
rc_rpc_plugin::RCAppExtensionPtr(
application_manager::ApplicationSharedPtr application));
MOCK_METHOD0(ResetAllAllocations, void());
+ MOCK_METHOD0(SendOnRCStatusNotification, void());
};
} // namespace rc_rpc_plugin_test