diff options
author | Alexander <akutsan@luxoft.com> | 2018-06-16 19:45:29 +0300 |
---|---|---|
committer | Ira Lytvynenko (GitHub) <ILytvynenko@luxoft.com> | 2018-06-27 18:20:30 +0300 |
commit | 116a93c7012a8251bbc232abf23949fb8683c139 (patch) | |
tree | 8892462b23897ddb3854a2c169566878d330b9c7 | |
parent | 0adfe23ef489c2a5ee38d0ce48a8b8eec2ea0da9 (diff) | |
download | sdl_core-116a93c7012a8251bbc232abf23949fb8683c139.tar.gz |
Replace all of application SubscribeToIVI to app extension subscribeToVehicleInfo
8 files changed, 28 insertions, 27 deletions
diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index fd0503581c..8ffab07ee8 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -625,7 +625,6 @@ class Application : public virtual InitialApplicationData, virtual bool UnsubscribeFromButton( mobile_apis::ButtonName::eType btn_name) = 0; - virtual bool SubscribeToIVI(uint32_t vehicle_info_type) = 0; virtual bool IsSubscribedToIVI(uint32_t vehicle_info_type) const = 0; virtual bool UnsubscribeFromIVI(uint32_t vehicle_info_type) = 0; diff --git a/src/components/application_manager/include/application_manager/application_impl.h b/src/components/application_manager/include/application_manager/application_impl.h index 99723ee2cb..2c9abf3bc6 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -213,7 +213,6 @@ class ApplicationImpl : public virtual Application, bool IsSubscribedToButton(mobile_apis::ButtonName::eType btn_name); bool UnsubscribeFromButton(mobile_apis::ButtonName::eType btn_name); - bool SubscribeToIVI(uint32_t vehicle_info_type) OVERRIDE; bool IsSubscribedToIVI(uint32_t vehicle_info_type) const OVERRIDE; bool UnsubscribeFromIVI(uint32_t vehicle_info_type) OVERRIDE; DataAccessor<VehicleInfoSubscriptions> SubscribedIVI() const OVERRIDE; diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc index 766e720217..51c5fab6fe 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc @@ -39,6 +39,7 @@ #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" #include "utils/helpers.h" +#include "vehicle_info_plugin/vehicle_info_app_extension.h" namespace vehicle_info_plugin { using namespace application_manager; @@ -269,7 +270,8 @@ void SubscribeVehicleDataRequest::on_event(const event_engine::Event& event) { app_mngr::VehicleInfoSubscriptions::const_iterator key = vi_waiting_for_subscribe_.begin(); for (; key != vi_waiting_for_subscribe_.end(); ++key) { - app->SubscribeToIVI(*key); + auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app); + ext.subscribeToVehicleInfo(*key); } } } @@ -436,7 +438,9 @@ void SubscribeVehicleDataRequest::CheckVISubscriptions( "There are apps subscribed already for " "VehicleDataType: " << key_type); - if (!app->SubscribeToIVI(static_cast<uint32_t>(key_type))) { + auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app); + + if (!ext.subscribeToVehicleInfo(key_type)) { LOG4CXX_ERROR( logger_, "Unable to subscribe for VehicleDataType: " << key_type); diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_app_extension.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_app_extension.cc index f5e944a38d..e7937eadb8 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_app_extension.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_app_extension.cc @@ -31,14 +31,17 @@ */ #include "vehicle_info_plugin/vehicle_info_app_extension.h" +#include "vehicle_info_plugin/vehicle_info_plugin.h" CREATE_LOGGERPTR_GLOBAL(logger_, "VehicleInfoPlugin") namespace vehicle_info_plugin { -VehicleInfoAppExtension::VehicleInfoAppExtension( - application_manager::AppExtensionUID uid) - : app_mngr::AppExtension(uid) { +unsigned VehicleInfoAppExtension::VehicleInfoAppExtensionUID = 146; + +VehicleInfoAppExtension::VehicleInfoAppExtension() + : app_mngr::AppExtension( + VehicleInfoAppExtension::VehicleInfoAppExtensionUID) { LOG4CXX_AUTO_TRACE(logger_); } @@ -46,10 +49,10 @@ VehicleInfoAppExtension::~VehicleInfoAppExtension() { LOG4CXX_AUTO_TRACE(logger_); } -void VehicleInfoAppExtension::subscribeToVehicleInfo( +bool VehicleInfoAppExtension::subscribeToVehicleInfo( const VehicleDataType vehicle_data) { LOG4CXX_DEBUG(logger_, vehicle_data); - subscribed_data_.insert(vehicle_data); + return subscribed_data_.insert(vehicle_data).second; } void VehicleInfoAppExtension::unsubscribeFromVehicleInfo( @@ -103,4 +106,17 @@ void VehicleInfoAppExtension::ProcessResumption( // application, application_manager_)); } } + +VehicleInfoAppExtension& VehicleInfoAppExtension::ExtractVIExtension( + application_manager::Application& app) { + auto ext_ptr = + app.QueryInterface(VehicleInfoAppExtension::VehicleInfoAppExtensionUID); + DCHECK(ext_ptr); + DCHECK(dynamic_cast<VehicleInfoAppExtension*>(ext_ptr.get())); + auto vi_app_extension = + application_manager::AppExtensionPtr::static_pointer_cast< + VehicleInfoAppExtension>(ext_ptr); + DCHECK(vi_app_extension); + return *vi_app_extension; +} } diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index a53fe52675..f1c785ccf3 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -760,14 +760,6 @@ bool ApplicationImpl::UnsubscribeFromButton( return subscribed_buttons_.erase(btn_name); } -bool ApplicationImpl::SubscribeToIVI(uint32_t vehicle_info_type) { - sync_primitives::AutoLock lock(vi_lock_ptr_); - return subscribed_vehicle_info_ - .insert( - static_cast<mobile_apis::VehicleDataType::eType>(vehicle_info_type)) - .second; -} - bool ApplicationImpl::IsSubscribedToIVI(uint32_t vehicle_info_type) const { sync_primitives::AutoLock lock(vi_lock_ptr_); VehicleInfoSubscriptions::const_iterator it = subscribed_vehicle_info_.find( diff --git a/src/components/application_manager/test/application_helper_test.cc b/src/components/application_manager/test/application_helper_test.cc index a0b6fd6aa2..620aad0f0b 100644 --- a/src/components/application_manager/test/application_helper_test.cc +++ b/src/components/application_manager/test/application_helper_test.cc @@ -147,7 +147,7 @@ TEST_F(ApplicationHelperTest, RecallApplicationData_ExpectAppDataReset) { app_impl_->AddCommand(cmd_id, cmd[strings::msg_params]); app_impl_->AddSubMenu(menu_id, cmd[strings::menu_params]); app_impl_->AddChoiceSet(choice_set_id, cmd[strings::msg_params]); - EXPECT_TRUE(app_impl_->SubscribeToIVI(static_cast<uint32_t>(vi))); + EXPECT_TRUE(app_impl_->SubscribeToButton(button)); const std::string some_string = "some_string"; @@ -230,8 +230,6 @@ TEST_F(ApplicationHelperTest, RecallApplicationData_ExpectHMICleanupRequests) { app_impl_->AddCommand(cmd_id, cmd[strings::msg_params]); app_impl_->AddSubMenu(menu_id, cmd[strings::menu_params]); app_impl_->AddChoiceSet(choice_set_id, cmd[strings::msg_params]); - app_impl_->SubscribeToIVI(static_cast<uint32_t>( - mobile_apis::VehicleDataType::VEHICLEDATA_ACCPEDAL)); app_impl_->SubscribeToButton(mobile_apis::ButtonName::AC); EXPECT_CALL(*mock_message_helper_, SendUnsubscribedWayPoints(_)); diff --git a/src/components/application_manager/test/include/application_manager/mock_application.h b/src/components/application_manager/test/include/application_manager/mock_application.h index ef1cd46cce..d531371c0c 100644 --- a/src/components/application_manager/test/include/application_manager/mock_application.h +++ b/src/components/application_manager/test/include/application_manager/mock_application.h @@ -150,7 +150,6 @@ class MockApplication : public ::application_manager::Application { bool(mobile_apis::ButtonName::eType btn_name)); MOCK_METHOD1(UnsubscribeFromButton, bool(mobile_apis::ButtonName::eType btn_name)); - MOCK_METHOD1(SubscribeToIVI, bool(uint32_t vehicle_info_type)); MOCK_CONST_METHOD1(IsSubscribedToIVI, bool(uint32_t vehicle_info_type)); MOCK_METHOD1(UnsubscribeFromIVI, bool(uint32_t vehicle_info_type)); MOCK_METHOD0(ResetDataInNone, void()); diff --git a/src/components/application_manager/test/resumption/resume_ctrl_test.cc b/src/components/application_manager/test/resumption/resume_ctrl_test.cc index a6ab69e182..79a7ac95cb 100644 --- a/src/components/application_manager/test/resumption/resume_ctrl_test.cc +++ b/src/components/application_manager/test/resumption/resume_ctrl_test.cc @@ -480,12 +480,6 @@ TEST_F(ResumeCtrlTest, StartResumption_AppWithSubscriptionToIVI) { EXPECT_CALL(*app_mock_, set_grammar_id(kTestGrammarId_)); - for (size_t i = 0; i < app_vi.length(); ++i) { - EXPECT_CALL( - *app_mock_, - SubscribeToIVI(static_cast<mobile_apis::VehicleDataType::eType>(i))); - } - smart_objects::SmartObjectList requests; EXPECT_CALL(*application_manager::MockMessageHelper::message_helper_mock(), GetIVISubscriptionRequests(_)).WillRepeatedly(Return(requests)); |