summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYana Chernysheva (GitHub) <59469418+ychernysheva@users.noreply.github.com>2020-06-25 17:57:22 +0300
committerGitHub <noreply@github.com>2020-06-25 10:57:22 -0400
commit9f18265c848f778ca580b02b9abebd96c09eaba9 (patch)
tree8ce883f0083d973238177e0295f2f8ad266e877f
parent73840c947b176476a7a68642d4a78cd270e270c1 (diff)
downloadsdl_core-9f18265c848f778ca580b02b9abebd96c09eaba9.tar.gz
Add check for already existed subscriptions during resumption in VehicleInfoPlugin (#3355)
* Add check for already existed subscriptions
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_plugin.cc40
1 files changed, 31 insertions, 9 deletions
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 3e8ef6b29d..1c553fb84d 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
@@ -154,28 +154,50 @@ void VehicleInfoPlugin::UnsubscribeFromRemovedVDItems() {
application_manager_->GetRPCService().ManageHMICommand(message);
}
+bool IsOtherAppAlreadySubscribedFor(
+ const std::string& ivi_name,
+ const application_manager::ApplicationManager& app_mngr,
+ const uint32_t current_app_id) {
+ auto applications = app_mngr.applications();
+
+ for (auto& app : applications.GetData()) {
+ auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app);
+ if (ext.isSubscribedToVehicleInfo(ivi_name) &&
+ (app->app_id() != current_app_id)) {
+ return true;
+ }
+ }
+ return false;
+}
+
void VehicleInfoPlugin::ProcessResumptionSubscription(
application_manager::Application& app, VehicleInfoAppExtension& ext) {
LOG4CXX_AUTO_TRACE(logger_);
smart_objects::SmartObject msg_params =
smart_objects::SmartObject(smart_objects::SmartType_Map);
- msg_params[strings::app_id] = app.app_id();
+
const auto& subscriptions = ext.Subscriptions();
+
if (subscriptions.empty()) {
LOG4CXX_DEBUG(logger_, "No vehicle data to subscribe. Exiting");
return;
}
- for (const auto& item : subscriptions) {
- msg_params[item] = true;
+ for (auto& ivi : subscriptions) {
+ if (!IsOtherAppAlreadySubscribedFor(
+ ivi, *application_manager_, app.app_id())) {
+ msg_params[ivi] = true;
+ }
}
- smart_objects::SmartObjectSPtr request =
- application_manager::MessageHelper::CreateModuleInfoSO(
- hmi_apis::FunctionID::VehicleInfo_SubscribeVehicleData,
- *application_manager_);
- (*request)[strings::msg_params] = msg_params;
- application_manager_->GetRPCService().ManageHMICommand(request);
+ if (!msg_params.empty()) {
+ auto request = application_manager::MessageHelper::CreateModuleInfoSO(
+ hmi_apis::FunctionID::VehicleInfo_SubscribeVehicleData,
+ *application_manager_);
+ msg_params[strings::app_id] = app.app_id();
+ (*request)[strings::msg_params] = msg_params;
+ application_manager_->GetRPCService().ManageHMICommand(request);
+ }
}
application_manager::ApplicationSharedPtr FindAppSubscribedToIVI(