From 178a3b43c78afdf5b227779bbe2c416ac349240e Mon Sep 17 00:00:00 2001 From: Andrii Kalinich Date: Tue, 15 Oct 2019 22:24:28 -0400 Subject: Fix revoked VD items subscription after PTU There was found an issue that SDL is still keeping subscriptions for a custom vehicle data items even for case when they was revoked by PTU. By that reason, SDL was crashing with DCHECK on attempt to unsubscribe from not existing custom data. Was added missing logic of internal unsubscribe in case if some custom vehicle data was revoked by policies. --- .../vehicle_info_plugin/vehicle_info_plugin.h | 1 + .../vehicle_info_plugin/src/vehicle_info_plugin.cc | 24 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_plugin.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_plugin.h index 3f6c078522..8d51b40a0d 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_plugin.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_plugin.h @@ -72,6 +72,7 @@ class VehicleInfoPlugin : public plugins::RPCPlugin { VehicleInfoAppExtension& ext); private: + void UnsubscribeFromRevokedVDItems(); smart_objects::SmartObjectSPtr GetUnsubscribeIVIRequest( const std::vector& ivi_names); void DeleteSubscriptions(app_mngr::ApplicationSharedPtr app); 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 d6d1c69461..53b39ab6e1 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 @@ -82,6 +82,7 @@ app_mngr::CommandFactory& VehicleInfoPlugin::GetCommandFactory() { void VehicleInfoPlugin::OnPolicyEvent(plugins::PolicyEvent event) { custom_vehicle_data_manager_->OnPolicyEvent(event); + UnsubscribeFromRevokedVDItems(); } void VehicleInfoPlugin::OnApplicationEvent( @@ -96,6 +97,29 @@ void VehicleInfoPlugin::OnApplicationEvent( } } +void VehicleInfoPlugin::UnsubscribeFromRevokedVDItems() { + auto applications = application_manager_->applications(); + auto& std_vehicle_data = application_manager::MessageHelper::vehicle_data(); + + for (auto& app : applications.GetData()) { + auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app); + auto subscription_names = ext.Subscriptions(); + for (auto& subscription_name : subscription_names) { + const bool is_std_vd_name = + std_vehicle_data.end() != std_vehicle_data.find(subscription_name); + const bool is_valid_custom_vd_name = + custom_vehicle_data_manager_->IsValidCustomVehicleDataName( + subscription_name); + if (!is_std_vd_name && !is_valid_custom_vd_name) { + LOG4CXX_DEBUG(logger_, + "Vehicle data item " << subscription_name + << " has been revoked by policy"); + ext.unsubscribeFromVehicleInfo(subscription_name); + } + } + } +} + void VehicleInfoPlugin::ProcessResumptionSubscription( application_manager::Application& app, VehicleInfoAppExtension& ext) { LOG4CXX_AUTO_TRACE(logger_); -- cgit v1.2.1