From a68cecd3195b0ba0520ce38e6a8289483af1ba10 Mon Sep 17 00:00:00 2001 From: Alexandr Galiuzov Date: Mon, 22 Jun 2015 22:47:42 +0300 Subject: Update README.md file. Add informatioin regarding launching WEB HMI --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index e8cf625b3e..95dc6eaa58 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,12 @@ Once SDL Core is compiled and installed you can start it from the executable in %./smartDeviceLinkCore ``` +## Start WEB HMI +Web HMI is separated from SDL Core and located in another repository. So to make it workable please do next steps. + + 1. Clone http://github.com/smartdevicelink/sdl_hmi.git + 2. Follow the instruction from readme file in sdl_hmi repository. + ## A quick note about dependencies The dependencies for SDL Core vary based on the configuration. You can change SDL Core's configuration in the top level CMakeLists.txt. We have defaulted this file to a configuration which we believe is common for people who are interested in getting up and running quickly, generally on a Linux VM. -- cgit v1.2.1 From 26c3de0f7351ca3ac1189388330615e61634a25f Mon Sep 17 00:00:00 2001 From: Artem Nosach Date: Tue, 28 Apr 2015 15:43:03 +0300 Subject: Fix wrong increment. --- .../src/commands/hmi/on_tts_language_change_notification.cc | 4 ++-- .../src/commands/hmi/on_ui_language_change_notification.cc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/application_manager/src/commands/hmi/on_tts_language_change_notification.cc b/src/components/application_manager/src/commands/hmi/on_tts_language_change_notification.cc index 5dba6400b8..daa307d627 100644 --- a/src/components/application_manager/src/commands/hmi/on_tts_language_change_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_tts_language_change_notification.cc @@ -73,8 +73,8 @@ void OnTTSLanguageChangeNotification::Run() { ApplicationManagerImpl::ApplicationListAccessor accessor; ApplicationManagerImpl::ApplictionSetIt it = accessor.begin(); - for (;accessor.end() != it; ++it) { - ApplicationSharedPtr app = (*it); + for (; accessor.end() != it;) { + ApplicationSharedPtr app = *it++; (*message_)[strings::params][strings::connection_key] = app->app_id(); SendNotificationToMobile(message_); diff --git a/src/components/application_manager/src/commands/hmi/on_ui_language_change_notification.cc b/src/components/application_manager/src/commands/hmi/on_ui_language_change_notification.cc index 931a27abc4..7e54099994 100644 --- a/src/components/application_manager/src/commands/hmi/on_ui_language_change_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_ui_language_change_notification.cc @@ -70,8 +70,8 @@ void OnUILanguageChangeNotification::Run() { ApplicationManagerImpl::ApplicationListAccessor accessor; ApplicationManagerImpl::ApplictionSetIt it = accessor.begin(); - for (;accessor.end() != it; ++it) { - ApplicationSharedPtr app = *it; + for (; accessor.end() != it;) { + ApplicationSharedPtr app = *it++; (*message_)[strings::params][strings::connection_key] = app->app_id(); SendNotificationToMobile(message_); -- cgit v1.2.1 From 794783b5d3676339ca66f5ecebb5f7aff907c70c Mon Sep 17 00:00:00 2001 From: Artem Nosach Date: Wed, 29 Apr 2015 16:36:20 +0300 Subject: Make session_map lock recursive. --- src/components/connection_handler/src/connection.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/connection_handler/src/connection.cc b/src/components/connection_handler/src/connection.cc index 8cc690e7b9..de8c7edb03 100644 --- a/src/components/connection_handler/src/connection.cc +++ b/src/components/connection_handler/src/connection.cc @@ -79,7 +79,8 @@ Connection::Connection(ConnectionHandle connection_handle, int32_t heartbeat_timeout) : connection_handler_(connection_handler), connection_handle_(connection_handle), - connection_device_handle_(connection_device_handle) { + connection_device_handle_(connection_device_handle), + session_map_lock_(true) { LOG4CXX_AUTO_TRACE(logger_); DCHECK(connection_handler_); -- cgit v1.2.1 From 44cea52d68fd61615cf6d56693ffee7bcfba32dd Mon Sep 17 00:00:00 2001 From: Artem Nosach Date: Sun, 26 Apr 2015 16:28:15 +0300 Subject: Close session correctly even with kMalformed reason. --- .../src/connection_handler_impl.cc | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc index ac5b9f850a..017ac2f90a 100644 --- a/src/components/connection_handler/src/connection_handler_impl.cc +++ b/src/components/connection_handler/src/connection_handler_impl.cc @@ -770,7 +770,9 @@ void ConnectionHandlerImpl::CloseSession(ConnectionHandle connection_handle, LOG4CXX_AUTO_TRACE(logger_); LOG4CXX_DEBUG(logger_, "Closing session with id: " << session_id); - if (protocol_handler_) { + // In case of malformed message the connection should be broke up without + // any other notification to mobile. + if (close_reason != kMalformed && protocol_handler_) { protocol_handler_->SendEndSession(connection_handle, session_id); } @@ -784,9 +786,7 @@ void ConnectionHandlerImpl::CloseSession(ConnectionHandle connection_handle, ConnectionList::iterator connection_list_itr = connection_list_.find(connection_id); if (connection_list_.end() != connection_list_itr) { - if (connection_handler_observer_ && kCommon == close_reason) { - session_map = connection_list_itr->second->session_map(); - } + session_map = connection_list_itr->second->session_map(); connection_list_itr->second->RemoveSession(session_id); } else { LOG4CXX_ERROR(logger_, "Connection with id: " << connection_id @@ -795,6 +795,11 @@ void ConnectionHandlerImpl::CloseSession(ConnectionHandle connection_handle, } } + if (!connection_handler_observer_) { + LOG4CXX_ERROR(logger_, "Connection handler observer not found"); + return; + } + SessionMap::const_iterator session_map_itr = session_map.find(session_id); if (session_map_itr != session_map.end()) { const uint32_t session_key = KeyFromPair(connection_id, session_id); @@ -805,16 +810,14 @@ void ConnectionHandlerImpl::CloseSession(ConnectionHandle connection_handle, for (;service_list_itr != service_list.end(); ++service_list_itr) { const protocol_handler::ServiceType service_type = service_list_itr->service_type; - connection_handler_observer_->OnServiceEndedCallback( - session_key, service_type, close_reason); + connection_handler_observer_->OnServiceEndedCallback(session_key, + service_type); } } else { - LOG4CXX_ERROR(logger_, "Session with id: " << session_id - << " not found"); - session_map.clear(); + LOG4CXX_ERROR(logger_, "Session with id: " + << session_id << " not found"); return; } - session_map.clear(); LOG4CXX_DEBUG(logger_, "Session with id: " << session_id << " has been closed successfully"); } -- cgit v1.2.1 From f646dd88d5c3e37b170e436e7da0f9f8c2d9abbd Mon Sep 17 00:00:00 2001 From: Artem Nosach Date: Mon, 27 Apr 2015 16:05:40 +0300 Subject: Do not resume malformed messaging application. --- .../application_manager/application_manager_impl.h | 3 +- .../src/application_manager_impl.cc | 32 ++++------------------ .../application_manager/application_manager_impl.h | 4 +-- .../connection_handler_observer.h | 11 ++------ .../src/connection_handler_impl.cc | 18 +++++------- 5 files changed, 18 insertions(+), 50 deletions(-) diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index 2cae10bdba..e76761c58a 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -55,6 +55,7 @@ #include "hmi_message_handler/hmi_message_sender.h" #include "application_manager/policies/policy_handler_observer.h" #include "media_manager/media_manager_impl.h" +#include "connection_handler/connection_handler.h" #include "connection_handler/connection_handler_observer.h" #include "connection_handler/device.h" #include "formatters/CSmartFactory.hpp" @@ -611,7 +612,7 @@ class ApplicationManagerImpl : public ApplicationManager, const protocol_handler::ServiceType& type, const connection_handler::CloseSessionReason& close_reason) OVERRIDE; void OnApplicationFloodCallBack(const uint32_t& connection_key) OVERRIDE; - void OnMalformedMessageCallback(const uint32_t& connection_key) OVERRIDE; + /** * @ Add notification to collection * diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 0c00fc0a4f..149be380ad 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -1099,9 +1099,11 @@ void ApplicationManagerImpl::OnServiceEndedCallback( if (type == kRpc) { LOG4CXX_INFO(logger_, "Remove application."); - /* in case it was unexpected disconnect application will be removed - and we will notify HMI that it was unexpected disconnect, - but in case it was closed by mobile we will be unable to find it in the list + /* In case it was unexpected disconnect or some special case + (malformed message, flood) application will be removed + and we will unregister application correctly, but in case it was + closed by mobile and already unregistered we will be unable + to find it in the list */ Result::eType reason; @@ -1147,30 +1149,6 @@ void ApplicationManagerImpl::OnServiceEndedCallback( } } -void ApplicationManagerImpl::OnApplicationFloodCallBack(const uint32_t &connection_key) { - LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG(logger_, "Unregister flooding application " << connection_key); - - MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile( - connection_key, - mobile_apis::AppInterfaceUnregisteredReason::TOO_MANY_REQUESTS); - - const bool resuming = true; - const bool unexpected_disconnect = false; - UnregisterApplication(connection_key, mobile_apis::Result::TOO_MANY_PENDING_REQUESTS, - resuming, unexpected_disconnect); - // TODO(EZamakhov): increment "removals_for_bad_behaviour" field in policy table -} - -void ApplicationManagerImpl::OnMalformedMessageCallback(const uint32_t &connection_key) { - LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG(logger_, "Unregister malformed messaging application " << connection_key); - - MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile( - connection_key, - mobile_apis::AppInterfaceUnregisteredReason::PROTOCOL_VIOLATION); -} - void ApplicationManagerImpl::set_hmi_message_handler( hmi_message_handler::HMIMessageHandler* handler) { hmi_handler_ = handler; diff --git a/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h b/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h index 594067a9fe..605fad103e 100644 --- a/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h @@ -175,9 +175,9 @@ class ApplicationManagerImpl : public ApplicationManager, const int32_t&, const protocol_handler::ServiceType&)); MOCK_METHOD2(OnServiceEndedCallback, void (const int32_t&, - const protocol_handler::ServiceType&)); + const protocol_handler::ServiceType&, + const connection_handler::CloseSessionReason&)); MOCK_METHOD1(OnApplicationFloodCallBack, void(const uint32_t&)); - MOCK_METHOD1(OnMalformedMessageCallback, void(const uint32_t&)); MOCK_METHOD1(Handle, void (const impl::MessageFromMobile)); MOCK_METHOD1(Handle, void (const impl::MessageToMobile)); MOCK_METHOD1(Handle, void (const impl::MessageFromHmi)); diff --git a/src/components/connection_handler/include/connection_handler/connection_handler_observer.h b/src/components/connection_handler/include/connection_handler/connection_handler_observer.h index 250eb5748a..13af3ec6cb 100644 --- a/src/components/connection_handler/include/connection_handler/connection_handler_observer.h +++ b/src/components/connection_handler/include/connection_handler/connection_handler_observer.h @@ -96,8 +96,8 @@ class ConnectionHandlerObserver { * \param close_reson Service close reason */ virtual void OnServiceEndedCallback( - const int32_t &session_key, - const protocol_handler::ServiceType &type, + const int32_t& session_key, + const protocol_handler::ServiceType& type, const connection_handler::CloseSessionReason& close_reason) = 0; /** @@ -107,13 +107,6 @@ class ConnectionHandlerObserver { */ virtual void OnApplicationFloodCallBack(const uint32_t &connection_key) = 0; - /** - * \brief Callback function used by ConnectionHandler - * when Mobile Application sends malformed message - * \param connection_key used by other components as application identifier - */ - virtual void OnMalformedMessageCallback(const uint32_t &connection_key) = 0; - protected: /** * \brief Destructor diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc index 017ac2f90a..b6dd6af012 100644 --- a/src/components/connection_handler/src/connection_handler_impl.cc +++ b/src/components/connection_handler/src/connection_handler_impl.cc @@ -384,14 +384,10 @@ void ConnectionHandlerImpl::OnApplicationFloodCallBack(const uint32_t &connectio } } -void ConnectionHandlerImpl::OnMalformedMessageCallback(const uint32_t &connection_key) { +void ConnectionHandlerImpl::OnMalformedMessageCallback( + const uint32_t &connection_key) { LOG4CXX_AUTO_TRACE(logger_); - { - sync_primitives::AutoLock lock(connection_handler_observer_lock_); - if(connection_handler_observer_) { - connection_handler_observer_->OnMalformedMessageCallback(connection_key); - } - } + transport_manager::ConnectionUID connection_handle = 0; uint8_t session_id = 0; PairFromKey(connection_key, &connection_handle, &session_id); @@ -449,7 +445,7 @@ uint32_t ConnectionHandlerImpl::OnSessionEndedCallback( sync_primitives::AutoLock lock2(connection_handler_observer_lock_); if (connection_handler_observer_) { connection_handler_observer_->OnServiceEndedCallback( - session_key, service_type, CloseSessionReason::kCommon); + session_key, service_type, CloseSessionReason::kCommon); } return session_key; } @@ -810,8 +806,8 @@ void ConnectionHandlerImpl::CloseSession(ConnectionHandle connection_handle, for (;service_list_itr != service_list.end(); ++service_list_itr) { const protocol_handler::ServiceType service_type = service_list_itr->service_type; - connection_handler_observer_->OnServiceEndedCallback(session_key, - service_type); + connection_handler_observer_->OnServiceEndedCallback( + session_key, service_type, close_reason); } } else { LOG4CXX_ERROR(logger_, "Session with id: " @@ -942,7 +938,7 @@ void ConnectionHandlerImpl::OnConnectionEnded( for (ServiceList::const_iterator service_it = service_list.begin(), end = service_list.end(); service_it != end; ++service_it) { connection_handler_observer_->OnServiceEndedCallback( - session_key, service_it->service_type, CloseSessionReason::kCommon); + session_key, service_it->service_type, CloseSessionReason::kCommon); } } } -- cgit v1.2.1 From 763c724e756d2fa9b0120d1b98614230493dfdf1 Mon Sep 17 00:00:00 2001 From: Artem Nosach Date: Tue, 28 Apr 2015 15:07:57 +0300 Subject: Remove notification sending from UnregisterApplication(). --- .../application_manager/application_manager_impl.h | 1 - .../src/application_manager_impl.cc | 20 ++++++++++++++------ .../mobile/unregister_app_interface_request.cc | 3 +++ .../application_manager/application_manager_impl.h | 1 - .../connection_handler/connection_handler_observer.h | 7 ------- .../src/connection_handler_impl.cc | 10 +++------- 6 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index e76761c58a..90d26ac88d 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -611,7 +611,6 @@ class ApplicationManagerImpl : public ApplicationManager, const int32_t& session_key, const protocol_handler::ServiceType& type, const connection_handler::CloseSessionReason& close_reason) OVERRIDE; - void OnApplicationFloodCallBack(const uint32_t& connection_key) OVERRIDE; /** * @ Add notification to collection diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 149be380ad..d861832c99 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -1092,6 +1092,7 @@ void ApplicationManagerImpl::OnServiceEndedCallback( using namespace protocol_handler; using namespace mobile_apis; using namespace connection_handler; + using namespace mobile_apis; LOG4CXX_DEBUG(logger_, "OnServiceEndedCallback for service " << type << " with reason " << close_reason @@ -2213,6 +2214,15 @@ void ApplicationManagerImpl::UnregisterAllApplications() { while (it != accessor.end()) { ApplicationSharedPtr app_to_remove = *it; +#ifdef CUSTOMER_PASA + if (!is_ignition_off) { +#endif // CUSTOMER_PASA + MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile( + app_to_remove->app_id(), unregister_reason_); +#ifdef CUSTOMER_PASA + } +#endif // CUSTOMER_PASA + UnregisterApplication(app_to_remove->app_id(), mobile_apis::Result::INVALID_ENUM, is_ignition_off, is_unexpected_disconnect); @@ -2261,9 +2271,6 @@ void ApplicationManagerImpl::UnregisterApplication( } //remove appID from tts_global_properties_app_list_ - MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile( - app_id, unregister_reason_); - RemoveAppFromTTSGlobalPropertiesList(app_id); switch (reason) { @@ -2333,7 +2340,6 @@ void ApplicationManagerImpl::UnregisterApplication( return; } - void ApplicationManagerImpl::OnAppUnauthorized(const uint32_t& app_id) { connection_handler_->CloseSession(app_id, connection_handler::kUnauthorizedApp); } @@ -2585,7 +2591,8 @@ void ApplicationManagerImpl::ForbidStreaming(uint32_t app_id) { navi_service_status_.find(app_id); if (navi_service_status_.end() == it || (!it->second.first && !it->second.second)) { - SetUnregisterAllApplicationsReason(PROTOCOL_VIOLATION); + MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile( + app_id, PROTOCOL_VIOLATION); UnregisterApplication(app_id, ABORTED); return; } @@ -2713,7 +2720,8 @@ void ApplicationManagerImpl::CloseNaviApp() { navi_service_status_.find(app_id); if (navi_service_status_.end() != it) { if (it->second.first || it->second.second) { - SetUnregisterAllApplicationsReason(PROTOCOL_VIOLATION); + MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile( + app_id, PROTOCOL_VIOLATION); UnregisterApplication(app_id, ABORTED); } } diff --git a/src/components/application_manager/src/commands/mobile/unregister_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/unregister_app_interface_request.cc index 6199818dbe..dc63a11941 100644 --- a/src/components/application_manager/src/commands/mobile/unregister_app_interface_request.cc +++ b/src/components/application_manager/src/commands/mobile/unregister_app_interface_request.cc @@ -50,6 +50,9 @@ void UnregisterAppInterfaceRequest::Run() { return; } + MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile( + connection_key(), + mobile_api::AppInterfaceUnregisteredReason::INVALID_ENUM); app_manager->UnregisterApplication(connection_key(), mobile_apis::Result::SUCCESS); SendResponse(true, mobile_apis::Result::SUCCESS); diff --git a/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h b/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h index 605fad103e..15d194089b 100644 --- a/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h @@ -177,7 +177,6 @@ class ApplicationManagerImpl : public ApplicationManager, MOCK_METHOD2(OnServiceEndedCallback, void (const int32_t&, const protocol_handler::ServiceType&, const connection_handler::CloseSessionReason&)); - MOCK_METHOD1(OnApplicationFloodCallBack, void(const uint32_t&)); MOCK_METHOD1(Handle, void (const impl::MessageFromMobile)); MOCK_METHOD1(Handle, void (const impl::MessageToMobile)); MOCK_METHOD1(Handle, void (const impl::MessageFromHmi)); diff --git a/src/components/connection_handler/include/connection_handler/connection_handler_observer.h b/src/components/connection_handler/include/connection_handler/connection_handler_observer.h index 13af3ec6cb..556a2dc4e2 100644 --- a/src/components/connection_handler/include/connection_handler/connection_handler_observer.h +++ b/src/components/connection_handler/include/connection_handler/connection_handler_observer.h @@ -100,13 +100,6 @@ class ConnectionHandlerObserver { const protocol_handler::ServiceType& type, const connection_handler::CloseSessionReason& close_reason) = 0; - /** - * \brief Callback function used by ConnectionHandler - * when Mobile Application start message flood - * \param connection_key used by other components as application identifier - */ - virtual void OnApplicationFloodCallBack(const uint32_t &connection_key) = 0; - protected: /** * \brief Destructor diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc index b6dd6af012..70a50c5890 100644 --- a/src/components/connection_handler/src/connection_handler_impl.cc +++ b/src/components/connection_handler/src/connection_handler_impl.cc @@ -363,14 +363,10 @@ uint32_t ConnectionHandlerImpl::OnSessionStartedCallback( return new_session_id; } -void ConnectionHandlerImpl::OnApplicationFloodCallBack(const uint32_t &connection_key) { +void ConnectionHandlerImpl::OnApplicationFloodCallBack( + const uint32_t &connection_key) { LOG4CXX_AUTO_TRACE(logger_); - { - sync_primitives::AutoLock lock(connection_handler_observer_lock_); - if(connection_handler_observer_) { - connection_handler_observer_->OnApplicationFloodCallBack(connection_key); - } - } + transport_manager::ConnectionUID connection_handle = 0; uint8_t session_id = 0; PairFromKey(connection_key, &connection_handle, &session_id); -- cgit v1.2.1 From 8ef1a21ceab0a9520edce3f446643fb293cee326 Mon Sep 17 00:00:00 2001 From: Artem Nosach Date: Wed, 29 Apr 2015 17:00:24 +0300 Subject: Post review changes. --- .../application_manager/application_manager_impl.h | 2 +- .../test/connection_handler_impl_test.cc | 301 +++++++++++++++++++++ .../test/include/protocol_observer_mock.h | 17 +- 3 files changed, 315 insertions(+), 5 deletions(-) diff --git a/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h b/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h index 15d194089b..cbccdfd85b 100644 --- a/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h @@ -174,7 +174,7 @@ class ApplicationManagerImpl : public ApplicationManager, MOCK_METHOD3(OnServiceStartedCallback, bool (const connection_handler::DeviceHandle&, const int32_t&, const protocol_handler::ServiceType&)); - MOCK_METHOD2(OnServiceEndedCallback, void (const int32_t&, + MOCK_METHOD3(OnServiceEndedCallback, void (const int32_t&, const protocol_handler::ServiceType&, const connection_handler::CloseSessionReason&)); MOCK_METHOD1(Handle, void (const impl::MessageFromMobile)); diff --git a/src/components/connection_handler/test/connection_handler_impl_test.cc b/src/components/connection_handler/test/connection_handler_impl_test.cc index dae33528eb..8d2e9b6a07 100644 --- a/src/components/connection_handler/test/connection_handler_impl_test.cc +++ b/src/components/connection_handler/test/connection_handler_impl_test.cc @@ -223,6 +223,307 @@ TEST_F(ConnectionHandlerTest, StartSession) { AddTestSession(); } +TEST_F(ConnectionHandlerTest, GetConnectionSessionsCount) { + AddTestDeviceConnection(); + EXPECT_EQ(0u, connection_handler_->GetConnectionSessionsCount(connection_key_)); + + AddTestSession(); + EXPECT_EQ(1u, connection_handler_->GetConnectionSessionsCount(connection_key_)); +} + +TEST_F(ConnectionHandlerTest, GetAppIdOnSessionKey) { + AddTestDeviceConnection(); + AddTestSession(); + + uint32_t app_id = 0; + const uint32_t testid = SessionHash(uid_, start_session_id_); + + EXPECT_EQ(0, connection_handler_->GetDataOnSessionKey(connection_key_, &app_id)); + EXPECT_EQ(testid, app_id); +} + +TEST_F(ConnectionHandlerTest,GetDeviceID) { + AddTestDeviceConnection(); + AddTestSession(); + + DeviceHandle test_handle; + const DeviceMap & devmap = connection_handler_->getDeviceList(); + DeviceMap::const_iterator pos = devmap.find(device_handle_); + ASSERT_NE(pos, devmap.end()); + const Device & devres = pos->second; + std::string test_mac_address = devres.mac_address(); + + EXPECT_TRUE(connection_handler_->GetDeviceID(test_mac_address, &test_handle)); + EXPECT_EQ(device_handle_, test_handle); +} + +TEST_F(ConnectionHandlerTest,GetDeviceName) { + AddTestDeviceConnection(); + AddTestSession(); + + std::string test_device_name; + DeviceHandle handle = 0; + EXPECT_EQ(0, connection_handler_->GetDataOnDeviceID(handle, &test_device_name)); + EXPECT_EQ(device_name_, test_device_name); +} + +TEST_F(ConnectionHandlerTest,GetConnectionType) { + AddTestDeviceConnection(); + AddTestSession(); + + const DeviceHandle handle = 0; + std::string test_connection_type; + EXPECT_EQ(0, connection_handler_->GetDataOnDeviceID(handle, NULL, NULL, NULL, &test_connection_type)); + EXPECT_EQ(connection_type_, test_connection_type); +} + +TEST_F(ConnectionHandlerTest, GetDefaultProtocolVersion) { + AddTestDeviceConnection(); + AddTestSession(); + + uint8_t protocol_version = 0; + EXPECT_TRUE(connection_handler_->ProtocolVersionUsed(uid_, start_session_id_, protocol_version)); + + EXPECT_EQ(PROTOCOL_VERSION_2, protocol_version); +} + +TEST_F(ConnectionHandlerTest, GetProtocolVersion) { + AddTestDeviceConnection(); + AddTestSession(); + ChangeProtocol(uid_, start_session_id_, PROTOCOL_VERSION_3); + + uint8_t protocol_version = 0; + EXPECT_TRUE(connection_handler_->ProtocolVersionUsed(uid_, start_session_id_, protocol_version)); + + EXPECT_EQ(PROTOCOL_VERSION_3, protocol_version); +} + +TEST_F(ConnectionHandlerTest, GetProtocolVersionAfterBinding) { + AddTestDeviceConnection(); + AddTestSession(); + uint8_t protocol_version = 0; + EXPECT_TRUE(connection_handler_->ProtocolVersionUsed(uid_, start_session_id_, protocol_version)); + EXPECT_EQ(PROTOCOL_VERSION_2, protocol_version); + + connection_handler_->BindProtocolVersionWithSession(connection_key_, PROTOCOL_VERSION_3); + + EXPECT_TRUE(connection_handler_->ProtocolVersionUsed(uid_, start_session_id_, protocol_version)); + EXPECT_EQ(PROTOCOL_VERSION_3, protocol_version); +} + +TEST_F(ConnectionHandlerTest, GetPairFromKey) { + AddTestDeviceConnection(); + AddTestSession(); + + uint8_t session_id = 0; + uint32_t test_uid = 0; + connection_handler_->PairFromKey(connection_key_, &test_uid, &session_id); + EXPECT_EQ(uid_, test_uid); + EXPECT_EQ(start_session_id_, session_id); +} + +TEST_F(ConnectionHandlerTest, IsHeartBeatSupported) { + AddTestDeviceConnection(); + AddTestSession(); + + ChangeProtocol(uid_, start_session_id_, PROTOCOL_VERSION_3); + EXPECT_TRUE(connection_handler_->IsHeartBeatSupported(uid_, start_session_id_)); +} + +TEST_F(ConnectionHandlerTest,SendEndServiceWithoutSetProtocolHandler) { + AddTestDeviceConnection(); + AddTestSession(); + protocol_handler_test::ProtocolHandlerMock mock_protocol_handler; + + EXPECT_CALL(mock_protocol_handler, SendEndService(_,_,kRpc)).Times(0); + connection_handler_->SendEndService(connection_key_, kRpc); +} + +TEST_F(ConnectionHandlerTest,SendEndService) { + AddTestDeviceConnection(); + AddTestSession(); + protocol_handler_test::ProtocolHandlerMock mock_protocol_handler; + + connection_handler_->set_protocol_handler(&mock_protocol_handler); + EXPECT_CALL(mock_protocol_handler, SendEndService(_,_,kRpc)); + connection_handler_->SendEndService(connection_key_, kRpc); +} + +TEST_F(ConnectionHandlerTest,OnFindNewApplicationsRequest) { + AddTestDeviceConnection(); + AddTestSession(); + connection_handler_test::ConnectionHandlerObserverMock mock_connection_handler_observer; + connection_handler_->set_connection_handler_observer(&mock_connection_handler_observer); + + EXPECT_CALL(mock_connection_handler_observer, OnFindNewApplicationsRequest()); + connection_handler_->OnFindNewApplicationsRequest(); +} + +TEST_F(ConnectionHandlerTest,OnFindNewApplicationsRequestWithoutObserver) { + connection_handler_test::ConnectionHandlerObserverMock mock_connection_handler_observer; + EXPECT_CALL(mock_connection_handler_observer, OnFindNewApplicationsRequest()).Times(0); + connection_handler_->OnFindNewApplicationsRequest(); +} + +TEST_F(ConnectionHandlerTest,OnFindNewApplicationsRequestWithoutSession) { + connection_handler_test::ConnectionHandlerObserverMock mock_connection_handler_observer; + connection_handler_->set_connection_handler_observer(&mock_connection_handler_observer); + + EXPECT_CALL(mock_connection_handler_observer, OnFindNewApplicationsRequest()); + connection_handler_->OnFindNewApplicationsRequest(); +} + +TEST_F(ConnectionHandlerTest, OnMalformedMessageCallback) { + AddTestDeviceConnection(); + AddTestSession(); + connection_handler_test::ConnectionHandlerObserverMock mock_connection_handler_observer; + connection_handler_->set_connection_handler_observer(&mock_connection_handler_observer); + + EXPECT_CALL(mock_connection_handler_observer, + OnServiceEndedCallback(connection_key_,_, kMalformed)).Times(2); + connection_handler_->OnMalformedMessageCallback(uid_); +} + +TEST_F(ConnectionHandlerTest, OnApplicationFloodCallBack) { + AddTestDeviceConnection(); + AddTestSession(); + connection_handler_test::ConnectionHandlerObserverMock mock_connection_handler_observer; + connection_handler_->set_connection_handler_observer(&mock_connection_handler_observer); + + protocol_handler_test::ProtocolHandlerMock mock_protocol_handler; + connection_handler_->set_protocol_handler(&mock_protocol_handler); + + EXPECT_CALL(mock_protocol_handler, SendEndSession(uid_,start_session_id_)); + EXPECT_CALL(mock_connection_handler_observer, + OnServiceEndedCallback(connection_key_,_, kCommon)).Times(2); + connection_handler_->OnApplicationFloodCallBack(uid_); +} + +TEST_F(ConnectionHandlerTest, StartDevicesDiscovery) { + AddTestDeviceConnection(); + AddTestSession(); + transport_manager_test::TransportManagerMock mock_transport_manager; + connection_handler_->set_transport_manager(&mock_transport_manager); + connection_handler_test::ConnectionHandlerObserverMock mock_connection_handler_observer; + connection_handler_->set_connection_handler_observer(&mock_connection_handler_observer); + + EXPECT_CALL(mock_transport_manager, SearchDevices()); + EXPECT_CALL(mock_connection_handler_observer, OnDeviceListUpdated(_)); + connection_handler_->StartDevicesDiscovery(); +} + +TEST_F(ConnectionHandlerTest, StartTransportManager) { + AddTestDeviceConnection(); + AddTestSession(); + transport_manager_test::TransportManagerMock mock_transport_manager; + connection_handler_->set_transport_manager(&mock_transport_manager); + EXPECT_CALL(mock_transport_manager, Visibility(true)); + connection_handler_->StartTransportManager(); +} + +TEST_F(ConnectionHandlerTest, CloseConnection) { + AddTestDeviceConnection(); + AddTestSession(); + transport_manager_test::TransportManagerMock mock_transport_manager; + connection_handler_->set_transport_manager(&mock_transport_manager); + EXPECT_CALL(mock_transport_manager, DisconnectForce(uid_)); + connection_handler_->CloseConnection(uid_); +} + +TEST_F(ConnectionHandlerTest, CloseRevokedConnection) { + AddTestDeviceConnection(); + AddTestSession(); + transport_manager_test::TransportManagerMock mock_transport_manager; + connection_handler_->set_transport_manager(&mock_transport_manager); + EXPECT_CALL(mock_transport_manager, DisconnectForce(uid_)); + connection_handler_->CloseRevokedConnection(connection_key_); +} + +TEST_F(ConnectionHandlerTest, CloseSessionWithCommonReason) { + AddTestDeviceConnection(); + AddTestSession(); + + connection_handler_test::ConnectionHandlerObserverMock mock_connection_handler_observer; + connection_handler_->set_connection_handler_observer(&mock_connection_handler_observer); + + protocol_handler_test::ProtocolHandlerMock mock_protocol_handler; + connection_handler_->set_protocol_handler(&mock_protocol_handler); + + EXPECT_CALL(mock_protocol_handler, SendEndSession(uid_,start_session_id_)); + EXPECT_CALL(mock_connection_handler_observer, + OnServiceEndedCallback(connection_key_,_, kCommon)).Times(2); + + connection_handler_->CloseSession(connection_key_, kCommon); +} + +TEST_F(ConnectionHandlerTest, CloseSessionWithFloodReason) { + AddTestDeviceConnection(); + AddTestSession(); + + connection_handler_test::ConnectionHandlerObserverMock mock_connection_handler_observer; + connection_handler_->set_connection_handler_observer(&mock_connection_handler_observer); + + protocol_handler_test::ProtocolHandlerMock mock_protocol_handler; + connection_handler_->set_protocol_handler(&mock_protocol_handler); + + EXPECT_CALL(mock_protocol_handler, SendEndSession(uid_,start_session_id_)); + EXPECT_CALL(mock_connection_handler_observer, + OnServiceEndedCallback(connection_key_,_, kFlood)).Times(2); + + connection_handler_->CloseSession(connection_key_, kFlood); +} + +TEST_F(ConnectionHandlerTest, CloseSessionWithMalformedMessage) { + AddTestDeviceConnection(); + AddTestSession(); + + connection_handler_test::ConnectionHandlerObserverMock mock_connection_handler_observer; + connection_handler_->set_connection_handler_observer(&mock_connection_handler_observer); + + protocol_handler_test::ProtocolHandlerMock mock_protocol_handler; + connection_handler_->set_protocol_handler(&mock_protocol_handler); + + EXPECT_CALL(mock_protocol_handler, SendEndSession(uid_,start_session_id_)).Times(0); + EXPECT_CALL(mock_connection_handler_observer, + OnServiceEndedCallback(connection_key_,_, kMalformed)).Times(2); + + connection_handler_->CloseSession(connection_key_, kMalformed); +} + +TEST_F(ConnectionHandlerTest, CloseConnectionSessionsWithMalformedMessage) { + AddTestDeviceConnection(); + AddTestSession(); + + connection_handler_test::ConnectionHandlerObserverMock mock_connection_handler_observer; + connection_handler_->set_connection_handler_observer(&mock_connection_handler_observer); + + protocol_handler_test::ProtocolHandlerMock mock_protocol_handler; + connection_handler_->set_protocol_handler(&mock_protocol_handler); + + EXPECT_CALL(mock_protocol_handler, SendEndSession(uid_,start_session_id_)).Times(0); + EXPECT_CALL(mock_connection_handler_observer, + OnServiceEndedCallback(connection_key_,_, kMalformed)).Times(2); + + connection_handler_->CloseConnectionSessions(uid_, kMalformed); +} + +TEST_F(ConnectionHandlerTest, CloseConnectionSessionsWithCommonReason) { + AddTestDeviceConnection(); + AddTestSession(); + + connection_handler_test::ConnectionHandlerObserverMock mock_connection_handler_observer; + connection_handler_->set_connection_handler_observer(&mock_connection_handler_observer); + + protocol_handler_test::ProtocolHandlerMock mock_protocol_handler; + connection_handler_->set_protocol_handler(&mock_protocol_handler); + + EXPECT_CALL(mock_protocol_handler, SendEndSession(uid_,start_session_id_)); + EXPECT_CALL(mock_connection_handler_observer, + OnServiceEndedCallback(connection_key_,_, kCommon)).Times(2); + + connection_handler_->CloseConnectionSessions(uid_, kCommon); +} + TEST_F(ConnectionHandlerTest, StartService_withServices) { // Add virtual device and connection AddTestDeviceConnection(); diff --git a/src/components/protocol_handler/test/include/protocol_observer_mock.h b/src/components/protocol_handler/test/include/protocol_observer_mock.h index c415e66e40..1350319b2d 100644 --- a/src/components/protocol_handler/test/include/protocol_observer_mock.h +++ b/src/components/protocol_handler/test/include/protocol_observer_mock.h @@ -46,10 +46,19 @@ namespace protocol_handler_test { */ class ProtocolObserverMock : public ::protocol_handler::ProtocolObserver { public: - MOCK_METHOD1(OnMessageReceived, - void(const ::protocol_handler::RawMessagePtr)); - MOCK_METHOD1(OnMobileMessageSent, - void(const ::protocol_handler::RawMessagePtr)); + MOCK_METHOD1(OnDeviceListUpdated, + void(const connection_handler::DeviceMap &device_list)); + MOCK_METHOD0(OnFindNewApplicationsRequest,void()); + MOCK_METHOD1(RemoveDevice, + void(const connection_handler::DeviceHandle &device_handle)); + MOCK_METHOD3(OnServiceStartedCallback, + bool(const connection_handler::DeviceHandle &device_handle, + const int32_t &session_key, + const protocol_handler::ServiceType &type)); + MOCK_METHOD3(OnServiceEndedCallback, + void(const int32_t &session_key, + const protocol_handler::ServiceType &type, + const connection_handler::CloseSessionReason& close_reason)); }; } // namespace protocol_handler_test } // namespace components -- cgit v1.2.1 From e03769c950d8cd9071855cee7c7505eac0f43e2f Mon Sep 17 00:00:00 2001 From: Artem Nosach Date: Tue, 19 May 2015 19:07:26 +0300 Subject: Update CreateInteractionRequest timeout after each VRAddCommandResponse. --- .../mobile/create_interaction_choice_set_request.h | 17 +++- .../create_interaction_choice_set_request.cc | 110 +++++++++++++-------- 2 files changed, 83 insertions(+), 44 deletions(-) diff --git a/src/components/application_manager/include/application_manager/commands/mobile/create_interaction_choice_set_request.h b/src/components/application_manager/include/application_manager/commands/mobile/create_interaction_choice_set_request.h index 53cbe5fdc1..615416fac5 100644 --- a/src/components/application_manager/include/application_manager/commands/mobile/create_interaction_choice_set_request.h +++ b/src/components/application_manager/include/application_manager/commands/mobile/create_interaction_choice_set_request.h @@ -91,9 +91,9 @@ class CreateInteractionChoiceSetRequest : public CommandRequestImpl { void DeleteChoices(); /** - * @brief OnAllHMIResponsesReceived If HMI returnes some errors, delete - * choices. - * Delete self from request controller + * @brief Calls after all responses from HMI were received. + * Terminates request and sends successful response to mobile + * if all responses were SUCCESS or calls DeleteChoices in other case. */ void OnAllHMIResponsesReceived(); @@ -116,14 +116,21 @@ class CreateInteractionChoiceSetRequest : public CommandRequestImpl { int32_t choice_set_id_; size_t expected_chs_count_; - size_t recived_chs_count_; - + size_t received_chs_count_; /** * @brief Flag for stop sending VR commands to HMI, in case one of responses * failed */ volatile bool error_from_hmi_; + sync_primitives::Lock error_from_hmi_lock_; + + /** + * @brief Flag shows if request already was expired by timeout + */ + volatile bool is_timed_out_; + sync_primitives::Lock is_timed_out_lock_; + sync_primitives::Lock vr_commands_lock_; /* * @brief Sends VR AddCommand request to HMI diff --git a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc index f8064c65f7..ff793ee293 100644 --- a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc +++ b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc @@ -48,7 +48,7 @@ CreateInteractionChoiceSetRequest::CreateInteractionChoiceSetRequest( const MessageSharedPtr& message) : CommandRequestImpl(message), expected_chs_count_(0), - recived_chs_count_(0), + received_chs_count_(0), error_from_hmi_(false) { } @@ -308,6 +308,7 @@ bool CreateInteractionChoiceSetRequest::IsWhiteSpaceExist( void CreateInteractionChoiceSetRequest::SendVRAddCommandRequests( application_manager::ApplicationSharedPtr const app) { LOG4CXX_AUTO_TRACE(logger_); + smart_objects::SmartObject& choice_set = (*message_)[strings::msg_params]; smart_objects::SmartObject msg_params = smart_objects::SmartObject( smart_objects::SmartType_Map); @@ -319,11 +320,15 @@ void CreateInteractionChoiceSetRequest::SendVRAddCommandRequests( expected_chs_count_ = choice_count; size_t chs_num = 0; - for ( ;chs_num < choice_count; ++chs_num) { - if (error_from_hmi_) { - LOG4CXX_WARN(logger_, "Error from HMI received. Stop sending VRCommands"); - break; + for (; chs_num < choice_count; ++chs_num) { + { + sync_primitives::AutoLock error_lock(error_from_hmi_lock_); + if (error_from_hmi_) { + LOG4CXX_WARN(logger_, "Error from HMI received. Stop sending VRCommands"); + break; + } } + msg_params[strings::cmd_id] = choice_set[strings::choice_set][chs_num][strings::choice_id]; msg_params[strings::vr_commands] = smart_objects::SmartObject( @@ -331,46 +336,66 @@ void CreateInteractionChoiceSetRequest::SendVRAddCommandRequests( msg_params[strings::vr_commands] = choice_set[strings::choice_set][chs_num][strings::vr_commands]; + sync_primitives::AutoLock commands_lock(vr_commands_lock_); const uint32_t vr_cmd_id = msg_params[strings::cmd_id].asUInt(); - sync_primitives::AutoLock lock(vr_commands_lock_); const uint32_t vr_corr_id = - SendHMIRequest(hmi_apis::FunctionID::VR_AddCommand, &msg_params, true); + SendHMIRequest(hmi_apis::FunctionID::VR_AddCommand, &msg_params, true); + VRCommandInfo vr_command(vr_cmd_id); sent_commands_map_[vr_corr_id] = vr_command; - LOG4CXX_DEBUG(logger_, "VR_command sent corr_id " << vr_corr_id << " cmd_id " << vr_corr_id); + LOG4CXX_DEBUG(logger_, "VR_command sent corr_id " + << vr_corr_id << " cmd_id " << vr_corr_id); } expected_chs_count_ = chs_num; LOG4CXX_DEBUG(logger_, "expected_chs_count_ = " << expected_chs_count_); - // All Responses from HMI can came after TimeOut - } -void -CreateInteractionChoiceSetRequest::on_event(const event_engine::Event& event) { +void CreateInteractionChoiceSetRequest::on_event( + const event_engine::Event& event) { using namespace hmi_apis; LOG4CXX_AUTO_TRACE(logger_); + const smart_objects::SmartObject& message = event.smart_object(); if (event.id() == hmi_apis::FunctionID::VR_AddCommand) { - Common_Result::eType vr_result_ = static_cast( - message[strings::params][hmi_response::code].asInt()); - recived_chs_count_++; + received_chs_count_++; LOG4CXX_DEBUG(logger_, "Got VR.AddCommand response, there are " - << expected_chs_count_ << " more to wait."); - if (Common_Result::SUCCESS == vr_result_) { - uint32_t corr_id = static_cast(message[strings::params] - [strings::correlation_id].asUInt()); - VRCommandInfo& vr_command = sent_commands_map_[corr_id]; + << expected_chs_count_ - received_chs_count_ + << " more to wait."); + + uint32_t corr_id = static_cast(message[strings::params] + [strings::correlation_id].asUInt()); + SentCommandsMap::iterator it = sent_commands_map_.find(corr_id); + if (sent_commands_map_.end() == it) { + LOG4CXX_DEBUG(logger_, "HMI response for unknown VR command received"); + return; + } + + Common_Result::eType vr_result_ = static_cast( + message[strings::params][hmi_response::code].asInt()); + if (Common_Result::SUCCESS == vr_result_) { + VRCommandInfo& vr_command = it->second; vr_command.succesful_response_received_ = true; } else { LOG4CXX_DEBUG(logger_, "Hmi response is not Success: " << vr_result_ << ". Stop sending VRAAdcommands"); + sync_primitives::AutoLock error_lock(error_from_hmi_lock_); if (!error_from_hmi_) { error_from_hmi_ = true; SendResponse(false, GetMobileResultCode(vr_result_)); } } - LOG4CXX_DEBUG(logger_, "expected_chs_count_ = " << expected_chs_count_); - if (recived_chs_count_ >= expected_chs_count_) { + + // update request timeout for case we send many VR add command requests + // and HMI has no time to send responses for all of them + LOG4CXX_DEBUG(logger_, "expected_chs_count_ = " << expected_chs_count_ + << "received_chs_count_ = " << received_chs_count_); + if (received_chs_count_ < expected_chs_count_) { + sync_primitives::AutoLock timeout_lock_(is_timed_out_lock_); + if (!is_timed_out_) { + ApplicationManagerImpl::instance()->updateRequestTimeout( + connection_key(), correlation_id(), default_timeout()); + } + } else { OnAllHMIResponsesReceived(); } } @@ -378,39 +403,44 @@ CreateInteractionChoiceSetRequest::on_event(const event_engine::Event& event) { void CreateInteractionChoiceSetRequest::onTimeOut() { LOG4CXX_AUTO_TRACE(logger_); + + sync_primitives::AutoLock error_lock(error_from_hmi_lock_); if (!error_from_hmi_) { - error_from_hmi_ = true; SendResponse(false, mobile_apis::Result::GENERIC_ERROR); } - OnAllHMIResponsesReceived(); - // If timeout occured, and request is alive is should not be managed by - // request controller timer any_more - ApplicationManagerImpl::instance()->updateRequestTimeout(connection_key(), - correlation_id(), 0); + + // We have to keep request alive until receive all responses from HMI + sync_primitives::AutoLock timeout_lock_(is_timed_out_lock_); + is_timed_out_ = true; + ApplicationManagerImpl::instance()->updateRequestTimeout( + connection_key(), correlation_id(), 0); } void CreateInteractionChoiceSetRequest::DeleteChoices() { LOG4CXX_AUTO_TRACE(logger_); - sync_primitives::AutoLock lock(vr_commands_lock_); + DCHECK_OR_RETURN_VOID(ApplicationManagerImpl::instance()); ApplicationSharedPtr application = ApplicationManagerImpl::instance()->application(connection_key()); if (!application) { return; } application->RemoveChoiceSet(choice_set_id_); - smart_objects::SmartObject msg_param(smart_objects::SmartType_Map); + smart_objects::SmartObject msg_param(smart_objects::SmartType_Map); msg_param[strings::app_id] = application->app_id(); - SentCommandsMap::const_iterator it = sent_commands_map_.begin(); + sync_primitives::AutoLock commands_lock(vr_commands_lock_); + SentCommandsMap::const_iterator it = sent_commands_map_.begin(); for (; it != sent_commands_map_.end(); ++it) { const VRCommandInfo& vr_command_info = it->second; if (vr_command_info.succesful_response_received_) { msg_param[strings::cmd_id] = vr_command_info.cmd_id_; SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_param); } else { - LOG4CXX_WARN(logger_, "succesfull response did no received cmd_id = " << vr_command_info.cmd_id_); + LOG4CXX_WARN( + logger_, "Succesfull response has not been received for cmd_id = " + << vr_command_info.cmd_id_); } } sent_commands_map_.clear(); @@ -418,16 +448,18 @@ void CreateInteractionChoiceSetRequest::DeleteChoices() { void CreateInteractionChoiceSetRequest::OnAllHMIResponsesReceived() { LOG4CXX_AUTO_TRACE(logger_); - if (error_from_hmi_) { - DeleteChoices(); - } else { + + DCHECK_OR_RETURN_VOID(ApplicationManagerImpl::instance()); + if (!error_from_hmi_) { SendResponse(true, mobile_apis::Result::SUCCESS); + ApplicationSharedPtr application = - ApplicationManagerImpl::instance()->application(connection_key()); - if (!application) { - return; + ApplicationManagerImpl::instance()->application(connection_key()); + if (application) { + application->UpdateHash(); } - application->UpdateHash(); + } else { + DeleteChoices(); } ApplicationManagerImpl::instance()->TerminateRequest(connection_key(), correlation_id()); -- cgit v1.2.1 From cc702c4db9e95b092faf8fa54b3edbee17091d2a Mon Sep 17 00:00:00 2001 From: Artem Nosach Date: Fri, 22 May 2015 10:45:55 +0300 Subject: Post review changes. --- .../src/commands/mobile/create_interaction_choice_set_request.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc index ff793ee293..9908756cfc 100644 --- a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc +++ b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc @@ -366,7 +366,7 @@ void CreateInteractionChoiceSetRequest::on_event( [strings::correlation_id].asUInt()); SentCommandsMap::iterator it = sent_commands_map_.find(corr_id); if (sent_commands_map_.end() == it) { - LOG4CXX_DEBUG(logger_, "HMI response for unknown VR command received"); + LOG4CXX_WARN(logger_, "HMI response for unknown VR command received"); return; } @@ -377,7 +377,7 @@ void CreateInteractionChoiceSetRequest::on_event( vr_command.succesful_response_received_ = true; } else { LOG4CXX_DEBUG(logger_, "Hmi response is not Success: " << vr_result_ - << ". Stop sending VRAAdcommands"); + << ". Stop sending VRAddCommand requests"); sync_primitives::AutoLock error_lock(error_from_hmi_lock_); if (!error_from_hmi_) { error_from_hmi_ = true; @@ -410,6 +410,7 @@ void CreateInteractionChoiceSetRequest::onTimeOut() { } // We have to keep request alive until receive all responses from HMI + // according to SDLAQ-CRS-2976 sync_primitives::AutoLock timeout_lock_(is_timed_out_lock_); is_timed_out_ = true; ApplicationManagerImpl::instance()->updateRequestTimeout( @@ -419,7 +420,6 @@ void CreateInteractionChoiceSetRequest::onTimeOut() { void CreateInteractionChoiceSetRequest::DeleteChoices() { LOG4CXX_AUTO_TRACE(logger_); - DCHECK_OR_RETURN_VOID(ApplicationManagerImpl::instance()); ApplicationSharedPtr application = ApplicationManagerImpl::instance()->application(connection_key()); if (!application) { @@ -449,7 +449,6 @@ void CreateInteractionChoiceSetRequest::DeleteChoices() { void CreateInteractionChoiceSetRequest::OnAllHMIResponsesReceived() { LOG4CXX_AUTO_TRACE(logger_); - DCHECK_OR_RETURN_VOID(ApplicationManagerImpl::instance()); if (!error_from_hmi_) { SendResponse(true, mobile_apis::Result::SUCCESS); -- cgit v1.2.1 From fc3496057bb401d081d83eaae3de7170c33fa749 Mon Sep 17 00:00:00 2001 From: Artem Nosach Date: Thu, 21 May 2015 16:56:29 +0300 Subject: Apply active states for app on activate. --- src/components/application_manager/src/application_manager_impl.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index d861832c99..6f01b3595e 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -509,6 +509,7 @@ bool ApplicationManagerImpl::ActivateApplication(ApplicationSharedPtr app) { AudioStreamingState::eType audio_state; app->IsAudioApplication() ? audio_state = AudioStreamingState::AUDIBLE : audio_state = AudioStreamingState::NOT_AUDIBLE; + state_ctrl_.ApplyStatesForApp(app); state_ctrl_.SetRegularState(app, hmi_level, audio_state); return true; } -- cgit v1.2.1 From d9fa3162a140924dcb5127b507b706a19f092abf Mon Sep 17 00:00:00 2001 From: Artem Nosach Date: Thu, 21 May 2015 18:35:21 +0300 Subject: Set ATTENUATED not only for FULL apps. --- src/components/application_manager/src/hmi_state.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/application_manager/src/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc index f787946b5e..2b165c1062 100644 --- a/src/components/application_manager/src/hmi_state.cc +++ b/src/components/application_manager/src/hmi_state.cc @@ -67,8 +67,7 @@ NaviStreamingHmiState::audio_streaming_state() const { using namespace mobile_apis; AudioStreamingState::eType expected_state = parent()->audio_streaming_state(); - if (Compare (hmi_level(), HMILevel::HMI_FULL) && - !state_context_.is_navi_app(app_id_) && + if (!state_context_.is_navi_app(app_id_) && AudioStreamingState::AUDIBLE == expected_state) { if (state_context_.is_attenuated_supported()) { expected_state = AudioStreamingState::ATTENUATED; -- cgit v1.2.1 From e91ee286a7fc22acfb823091aa70a591510005b0 Mon Sep 17 00:00:00 2001 From: Artem Nosach Date: Fri, 22 May 2015 17:44:37 +0300 Subject: Update application hash after DeleteCommand. --- .../application_manager/src/commands/mobile/delete_command_request.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/application_manager/src/commands/mobile/delete_command_request.cc b/src/components/application_manager/src/commands/mobile/delete_command_request.cc index e76422d50e..99dd53d177 100644 --- a/src/components/application_manager/src/commands/mobile/delete_command_request.cc +++ b/src/components/application_manager/src/commands/mobile/delete_command_request.cc @@ -170,6 +170,9 @@ void DeleteCommandRequest::on_event(const event_engine::Event& event) { } SendResponse(result, result_code, NULL, &(message[strings::msg_params])); + if (result) { + application->UpdateHash(); + } } } } -- cgit v1.2.1 From 82e05285c00467ea45295eef90b0303270a047e0 Mon Sep 17 00:00:00 2001 From: Artem Nosach Date: Fri, 22 May 2015 17:47:54 +0300 Subject: Update application hash after UnsubscribeButton. --- .../src/commands/mobile/unsubscribe_button_request.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc index 8ca67d3638..af1faa9e6c 100644 --- a/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc +++ b/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc @@ -74,6 +74,7 @@ void UnsubscribeButtonRequest::Run() { SendUnsubscribeButtonNotification(); SendResponse(true, mobile_apis::Result::SUCCESS); + app->UpdateHash(); } void UnsubscribeButtonRequest::SendUnsubscribeButtonNotification() { -- cgit v1.2.1 From 53b62e06ef5197df58d13d838d3b42e2cea1b108 Mon Sep 17 00:00:00 2001 From: Artem Nosach Date: Mon, 25 May 2015 14:03:40 +0300 Subject: Check for app existing correctly. --- .../commands/hmi/navi_audio_start_stream_request.cc | 13 +++++++++---- .../src/commands/hmi/navi_start_stream_request.cc | 18 ++++++++++++++---- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc b/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc index da5bc57aca..1d6aad49b4 100644 --- a/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc +++ b/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc @@ -50,8 +50,6 @@ AudioStartStreamRequest::AudioStartStreamRequest( retry_number_ = stream_retry.first; LOG4CXX_DEBUG(logger_, "default_timeout_ = " << default_timeout_ <<"; retry_number_ = " << retry_number_); - //stream_retry.first times after stream_retry.second timeout - //SDL should resend AudioStartStreamRequest } AudioStartStreamRequest::~AudioStartStreamRequest() { @@ -59,10 +57,17 @@ AudioStartStreamRequest::~AudioStartStreamRequest() { void AudioStartStreamRequest::RetryStartSession() { LOG4CXX_AUTO_TRACE(logger_); + ApplicationManagerImpl* app_mgr = ApplicationManagerImpl::instance(); DCHECK_OR_RETURN_VOID(app_mgr); + ApplicationSharedPtr app = app_mgr->application_by_hmi_app(application_id()); - DCHECK_OR_RETURN_VOID(app); + if (!app) { + LOG4CXX_ERROR_EXT(logger_, + "StartAudioStreamRequest aborted. Application not found"); + return; + } + uint32_t curr_retry_number = app->audio_stream_retry_number(); if (curr_retry_number < retry_number_ - 1) { LOG4CXX_INFO(logger_, "Send AudioStartStream retry. retry_number = " @@ -70,7 +75,7 @@ void AudioStartStreamRequest::RetryStartSession() { MessageHelper::SendAudioStartStream(app->app_id()); app->set_audio_stream_retry_number(++curr_retry_number); } else { - LOG4CXX_INFO(logger_, "Audio start stream retry squence stopped"); + LOG4CXX_INFO(logger_, "Audio start stream retry sequence stopped"); app_mgr->EndNaviServices(app->app_id()); app->set_audio_stream_retry_number(0); } diff --git a/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc b/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc index 66a7e14fad..c8329c124d 100644 --- a/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc +++ b/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc @@ -67,7 +67,7 @@ void NaviStartStreamRequest::Run() { app->set_video_streaming_allowed(true); SendRequest(); } else { - LOG4CXX_ERROR(logger_, "Applcation with hhi_app_id " + LOG4CXX_ERROR(logger_, "Applcation with hmi_app_id " << application_id() << "does not exist"); } } @@ -103,6 +103,9 @@ void NaviStartStreamRequest::on_event(const event_engine::Event& event) { LOG4CXX_DEBUG(logger_, "NaviStartStreamRequest aborted. Application can not stream"); } + } else { + LOG4CXX_DEBUG(logger_,"Error received from HMI : " << code); + RetryStartSession(); } break; } @@ -119,18 +122,25 @@ void NaviStartStreamRequest::onTimeOut() { void NaviStartStreamRequest::RetryStartSession() { LOG4CXX_AUTO_TRACE(logger_); + ApplicationManagerImpl* app_mgr = ApplicationManagerImpl::instance(); DCHECK_OR_RETURN_VOID(app_mgr); + ApplicationSharedPtr app = app_mgr->application_by_hmi_app(application_id()); - DCHECK_OR_RETURN_VOID(app); - uint32_t curr_retry_number = app->video_stream_retry_number(); + if (!app) { + LOG4CXX_ERROR_EXT(logger_, + "NaviStartStreamRequest aborted. Application not found"); + return; + } + + uint32_t curr_retry_number = app->video_stream_retry_number(); if (curr_retry_number < retry_number_ - 1) { LOG4CXX_INFO(logger_, "Send NaviStartStream retry. retry_number = " << curr_retry_number); MessageHelper::SendNaviStartStream(app->app_id()); app->set_video_stream_retry_number(++curr_retry_number); } else { - LOG4CXX_INFO(logger_, "NaviStartStream retry squence stopped"); + LOG4CXX_INFO(logger_, "NaviStartStream retry sequence stopped"); app_mgr->EndNaviServices(app->app_id()); app->set_video_stream_retry_number(0); } -- cgit v1.2.1 From 0e4f5df94ad3696ef23c8977a6fb05e4663d5dd4 Mon Sep 17 00:00:00 2001 From: Artem Nosach Date: Mon, 25 May 2015 15:20:27 +0300 Subject: Rework StartStreamRequest. --- .../commands/hmi/navi_audio_start_stream_request.cc | 19 ++++++++++++++----- .../src/commands/hmi/navi_start_stream_request.cc | 19 ++++++++++++++----- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc b/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc index 1d6aad49b4..ef49b3992f 100644 --- a/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc +++ b/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc @@ -67,6 +67,12 @@ void AudioStartStreamRequest::RetryStartSession() { "StartAudioStreamRequest aborted. Application not found"); return; } + if (app->audio_streaming_approved()) { + LOG4CXX_INFO(logger_, "AudioStartStream retry sequence stopped. " + << "SUCCESS received"); + app->set_audio_stream_retry_number(0); + return; + } uint32_t curr_retry_number = app->audio_stream_retry_number(); if (curr_retry_number < retry_number_ - 1) { @@ -75,19 +81,25 @@ void AudioStartStreamRequest::RetryStartSession() { MessageHelper::SendAudioStartStream(app->app_id()); app->set_audio_stream_retry_number(++curr_retry_number); } else { - LOG4CXX_INFO(logger_, "Audio start stream retry sequence stopped"); - app_mgr->EndNaviServices(app->app_id()); + LOG4CXX_INFO(logger_, "Audio start stream retry sequence stopped. " + << "Attempts expired."); app->set_audio_stream_retry_number(0); + app_mgr->EndNaviServices(app->app_id()); } } void AudioStartStreamRequest::onTimeOut() { RetryStartSession(); + + ApplicationManagerImpl* app_mgr = ApplicationManagerImpl::instance(); + DCHECK_OR_RETURN_VOID(app_mgr); + app_mgr->TerminateRequest(connection_key(), correlation_id()); } void AudioStartStreamRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); + SetAllowedToTerminate(false); subscribe_on_event(hmi_apis::FunctionID::Navigation_StartAudioStream, correlation_id()); ApplicationManagerImpl* app_mgr = ApplicationManagerImpl::instance(); @@ -133,9 +145,6 @@ void AudioStartStreamRequest::on_event(const event_engine::Event& event) { LOG4CXX_DEBUG(logger_, "StartAudioStreamRequest aborted. Application can not stream"); } - } else { - LOG4CXX_DEBUG(logger_,"Error received from HMI : " << code); - RetryStartSession(); } break; } diff --git a/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc b/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc index c8329c124d..a90400aa4f 100644 --- a/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc +++ b/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc @@ -58,6 +58,7 @@ NaviStartStreamRequest::~NaviStartStreamRequest() { void NaviStartStreamRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); + SetAllowedToTerminate(false); subscribe_on_event(hmi_apis::FunctionID::Navigation_StartStream, correlation_id()); ApplicationManagerImpl* app_mgr = ApplicationManagerImpl::instance(); @@ -103,9 +104,6 @@ void NaviStartStreamRequest::on_event(const event_engine::Event& event) { LOG4CXX_DEBUG(logger_, "NaviStartStreamRequest aborted. Application can not stream"); } - } else { - LOG4CXX_DEBUG(logger_,"Error received from HMI : " << code); - RetryStartSession(); } break; } @@ -118,6 +116,10 @@ void NaviStartStreamRequest::on_event(const event_engine::Event& event) { void NaviStartStreamRequest::onTimeOut() { RetryStartSession(); + + ApplicationManagerImpl* app_mgr = ApplicationManagerImpl::instance(); + DCHECK_OR_RETURN_VOID(app_mgr); + app_mgr->TerminateRequest(connection_key(), correlation_id()); } void NaviStartStreamRequest::RetryStartSession() { @@ -132,6 +134,12 @@ void NaviStartStreamRequest::RetryStartSession() { "NaviStartStreamRequest aborted. Application not found"); return; } + if (app->video_streaming_approved()) { + LOG4CXX_INFO(logger_, "NaviStartStream retry sequence stopped. " + << "SUCCESS received"); + app->set_video_stream_retry_number(0); + return; + } uint32_t curr_retry_number = app->video_stream_retry_number(); if (curr_retry_number < retry_number_ - 1) { @@ -140,9 +148,10 @@ void NaviStartStreamRequest::RetryStartSession() { MessageHelper::SendNaviStartStream(app->app_id()); app->set_video_stream_retry_number(++curr_retry_number); } else { - LOG4CXX_INFO(logger_, "NaviStartStream retry sequence stopped"); - app_mgr->EndNaviServices(app->app_id()); + LOG4CXX_INFO(logger_, "NaviStartStream retry sequence stopped. " + << "Attempts expired"); app->set_video_stream_retry_number(0); + app_mgr->EndNaviServices(app->app_id()); } } -- cgit v1.2.1 From 7e105c6670dd27f942db6b735400ed3cc391195d Mon Sep 17 00:00:00 2001 From: Artem Nosach Date: Mon, 25 May 2015 15:24:58 +0300 Subject: Change timeout from seconds to milliseconds. --- customer-specific/pasa/src/appMain/smartDeviceLink.ini | 2 ++ src/appMain/smartDeviceLink.ini | 4 ++-- .../src/commands/hmi/navi_audio_start_stream_request.cc | 2 +- .../application_manager/src/commands/hmi/navi_start_stream_request.cc | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/customer-specific/pasa/src/appMain/smartDeviceLink.ini b/customer-specific/pasa/src/appMain/smartDeviceLink.ini index d292c042d2..ea81e57227 100644 --- a/customer-specific/pasa/src/appMain/smartDeviceLink.ini +++ b/customer-specific/pasa/src/appMain/smartDeviceLink.ini @@ -62,6 +62,8 @@ LogFileMaxSize = 0K [MEDIA MANAGER] +; where 3 is a number of retries and 1000 is a timeout in milliseconds for request frequency +StartStreamRetry = 3, 1000 EnableRedecoding = false ;VideoStreamConsumer = socket ;AudioStreamConsumer = socket diff --git a/src/appMain/smartDeviceLink.ini b/src/appMain/smartDeviceLink.ini index 1520aec371..bdca54e80e 100644 --- a/src/appMain/smartDeviceLink.ini +++ b/src/appMain/smartDeviceLink.ini @@ -60,8 +60,8 @@ ReadDIDRequest = 5, 1 GetVehicleDataRequest = 5, 1 [MEDIA MANAGER] -; where 3 is a number of retries and 1 is a timeout in seconds for request frequency -StartStreamRetry = 3, 1 +; where 3 is a number of retries and 1000 is a timeout in milliseconds for request frequency +StartStreamRetry = 3, 1000 EnableRedecoding = false VideoStreamConsumer = socket AudioStreamConsumer = socket diff --git a/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc b/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc index ef49b3992f..354b070df6 100644 --- a/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc +++ b/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc @@ -46,7 +46,7 @@ AudioStartStreamRequest::AudioStartStreamRequest( LOG4CXX_AUTO_TRACE(logger_); std::pair stream_retry = profile::Profile::instance()->start_stream_retry_amount(); - default_timeout_ = stream_retry.second * date_time::DateTime::MILLISECONDS_IN_SECOND; + default_timeout_ = stream_retry.second; retry_number_ = stream_retry.first; LOG4CXX_DEBUG(logger_, "default_timeout_ = " << default_timeout_ <<"; retry_number_ = " << retry_number_); diff --git a/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc b/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc index a90400aa4f..e95ebf2b66 100644 --- a/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc +++ b/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc @@ -46,7 +46,7 @@ NaviStartStreamRequest::NaviStartStreamRequest( LOG4CXX_AUTO_TRACE(logger_); std::pair stream_retry = profile::Profile::instance()->start_stream_retry_amount(); - default_timeout_ = stream_retry.second * date_time::DateTime::MILLISECONDS_IN_SECOND; + default_timeout_ = stream_retry.second; retry_number_ = stream_retry.first; LOG4CXX_DEBUG(logger_, "default_timeout_ = " << default_timeout_ <<"; retry_number_ = " << retry_number_); -- cgit v1.2.1 From b78bfbde8036bb0a1259b13ac7c9cb3d0987ab0a Mon Sep 17 00:00:00 2001 From: Artem Nosach Date: Tue, 26 May 2015 10:08:03 +0300 Subject: Post review changes. --- .../hmi/navi_audio_start_stream_request.cc | 40 ++++++++++------------ .../src/commands/hmi/navi_start_stream_request.cc | 38 +++++++++----------- 2 files changed, 35 insertions(+), 43 deletions(-) diff --git a/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc b/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc index 354b070df6..4a637341c1 100644 --- a/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc +++ b/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc @@ -58,17 +58,15 @@ AudioStartStreamRequest::~AudioStartStreamRequest() { void AudioStartStreamRequest::RetryStartSession() { LOG4CXX_AUTO_TRACE(logger_); - ApplicationManagerImpl* app_mgr = ApplicationManagerImpl::instance(); - DCHECK_OR_RETURN_VOID(app_mgr); - - ApplicationSharedPtr app = app_mgr->application_by_hmi_app(application_id()); + ApplicationSharedPtr app = ApplicationManagerImpl::instance()-> + application_by_hmi_app(application_id()); if (!app) { - LOG4CXX_ERROR_EXT(logger_, + LOG4CXX_ERROR(logger_, "StartAudioStreamRequest aborted. Application not found"); return; } if (app->audio_streaming_approved()) { - LOG4CXX_INFO(logger_, "AudioStartStream retry sequence stopped. " + LOG4CXX_DEBUG(logger_, "AudioStartStream retry sequence stopped. " << "SUCCESS received"); app->set_audio_stream_retry_number(0); return; @@ -76,24 +74,23 @@ void AudioStartStreamRequest::RetryStartSession() { uint32_t curr_retry_number = app->audio_stream_retry_number(); if (curr_retry_number < retry_number_ - 1) { - LOG4CXX_INFO(logger_, "Send AudioStartStream retry. retry_number = " + LOG4CXX_DEBUG(logger_, "Send AudioStartStream retry. retry_number = " << curr_retry_number); MessageHelper::SendAudioStartStream(app->app_id()); app->set_audio_stream_retry_number(++curr_retry_number); } else { - LOG4CXX_INFO(logger_, "Audio start stream retry sequence stopped. " + LOG4CXX_DEBUG(logger_, "Audio start stream retry sequence stopped. " << "Attempts expired."); app->set_audio_stream_retry_number(0); - app_mgr->EndNaviServices(app->app_id()); + ApplicationManagerImpl::instance()->EndNaviServices(app->app_id()); } } void AudioStartStreamRequest::onTimeOut() { RetryStartSession(); - ApplicationManagerImpl* app_mgr = ApplicationManagerImpl::instance(); - DCHECK_OR_RETURN_VOID(app_mgr); - app_mgr->TerminateRequest(connection_key(), correlation_id()); + ApplicationManagerImpl::instance()->TerminateRequest( + connection_key(), correlation_id()); } void AudioStartStreamRequest::Run() { @@ -102,15 +99,15 @@ void AudioStartStreamRequest::Run() { SetAllowedToTerminate(false); subscribe_on_event(hmi_apis::FunctionID::Navigation_StartAudioStream, correlation_id()); - ApplicationManagerImpl* app_mgr = ApplicationManagerImpl::instance(); - DCHECK_OR_RETURN_VOID(app_mgr); - ApplicationSharedPtr app = app_mgr->application_by_hmi_app(application_id()); + + ApplicationSharedPtr app = ApplicationManagerImpl::instance()-> + application_by_hmi_app(application_id()); if (app) { app->set_audio_streaming_allowed(true); SendRequest(); } else { LOG4CXX_ERROR(logger_, "Applcation with hmi_app_id " - << application_id() << " does not exist"); + << application_id() << " does not exist"); } } @@ -118,12 +115,10 @@ void AudioStartStreamRequest::on_event(const event_engine::Event& event) { using namespace protocol_handler; LOG4CXX_AUTO_TRACE(logger_); - ApplicationManagerImpl* app_mgr = ApplicationManagerImpl::instance(); - DCHECK_OR_RETURN_VOID(app_mgr); - - ApplicationSharedPtr app = app_mgr->application_by_hmi_app(application_id()); + ApplicationSharedPtr app = ApplicationManagerImpl::instance()-> + application_by_hmi_app(application_id()); if (!app) { - LOG4CXX_ERROR_EXT(logger_, + LOG4CXX_ERROR(logger_, "StartAudioStreamRequest aborted. Application not found"); return; } @@ -139,7 +134,8 @@ void AudioStartStreamRequest::on_event(const event_engine::Event& event) { if (hmi_apis::Common_Result::SUCCESS == code) { LOG4CXX_DEBUG(logger_, "StartAudioStreamResponse SUCCESS"); - if (app_mgr->HMILevelAllowsStreaming(app->app_id(), ServiceType::kAudio)) { + if (ApplicationManagerImpl::instance()-> + HMILevelAllowsStreaming(app->app_id(), ServiceType::kAudio)) { app->set_audio_streaming_approved(true); } else { LOG4CXX_DEBUG(logger_, diff --git a/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc b/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc index e95ebf2b66..1ff7916b9a 100644 --- a/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc +++ b/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc @@ -61,9 +61,9 @@ void NaviStartStreamRequest::Run() { SetAllowedToTerminate(false); subscribe_on_event(hmi_apis::FunctionID::Navigation_StartStream, correlation_id()); - ApplicationManagerImpl* app_mgr = ApplicationManagerImpl::instance(); - DCHECK_OR_RETURN_VOID(app_mgr); - ApplicationSharedPtr app = app_mgr->application_by_hmi_app(application_id()); + + ApplicationSharedPtr app = ApplicationManagerImpl::instance()-> + application_by_hmi_app(application_id()); if (app) { app->set_video_streaming_allowed(true); SendRequest(); @@ -77,12 +77,10 @@ void NaviStartStreamRequest::on_event(const event_engine::Event& event) { using namespace protocol_handler; LOG4CXX_AUTO_TRACE(logger_); - ApplicationManagerImpl* app_mgr = ApplicationManagerImpl::instance(); - DCHECK_OR_RETURN_VOID(app_mgr); - - ApplicationSharedPtr app = app_mgr->application_by_hmi_app(application_id()); + ApplicationSharedPtr app = ApplicationManagerImpl::instance()-> + application_by_hmi_app(application_id()); if (!app) { - LOG4CXX_ERROR_EXT(logger_, + LOG4CXX_ERROR(logger_, "NaviStartStreamRequest aborted. Application not found"); return; } @@ -98,7 +96,8 @@ void NaviStartStreamRequest::on_event(const event_engine::Event& event) { if (hmi_apis::Common_Result::SUCCESS == code) { LOG4CXX_DEBUG(logger_, "NaviStartStreamResponse SUCCESS"); - if (app_mgr->HMILevelAllowsStreaming(app->app_id(), ServiceType::kMobileNav)) { + if (ApplicationManagerImpl::instance()-> + HMILevelAllowsStreaming(app->app_id(), ServiceType::kMobileNav)) { app->set_video_streaming_approved(true); } else { LOG4CXX_DEBUG(logger_, @@ -117,25 +116,22 @@ void NaviStartStreamRequest::on_event(const event_engine::Event& event) { void NaviStartStreamRequest::onTimeOut() { RetryStartSession(); - ApplicationManagerImpl* app_mgr = ApplicationManagerImpl::instance(); - DCHECK_OR_RETURN_VOID(app_mgr); - app_mgr->TerminateRequest(connection_key(), correlation_id()); + ApplicationManagerImpl::instance()->TerminateRequest( + connection_key(), correlation_id()); } void NaviStartStreamRequest::RetryStartSession() { LOG4CXX_AUTO_TRACE(logger_); - ApplicationManagerImpl* app_mgr = ApplicationManagerImpl::instance(); - DCHECK_OR_RETURN_VOID(app_mgr); - - ApplicationSharedPtr app = app_mgr->application_by_hmi_app(application_id()); + ApplicationSharedPtr app = ApplicationManagerImpl::instance()-> + application_by_hmi_app(application_id()); if (!app) { - LOG4CXX_ERROR_EXT(logger_, + LOG4CXX_ERROR(logger_, "NaviStartStreamRequest aborted. Application not found"); return; } if (app->video_streaming_approved()) { - LOG4CXX_INFO(logger_, "NaviStartStream retry sequence stopped. " + LOG4CXX_DEBUG(logger_, "NaviStartStream retry sequence stopped. " << "SUCCESS received"); app->set_video_stream_retry_number(0); return; @@ -143,15 +139,15 @@ void NaviStartStreamRequest::RetryStartSession() { uint32_t curr_retry_number = app->video_stream_retry_number(); if (curr_retry_number < retry_number_ - 1) { - LOG4CXX_INFO(logger_, "Send NaviStartStream retry. retry_number = " + LOG4CXX_DEBUG(logger_, "Send NaviStartStream retry. retry_number = " << curr_retry_number); MessageHelper::SendNaviStartStream(app->app_id()); app->set_video_stream_retry_number(++curr_retry_number); } else { - LOG4CXX_INFO(logger_, "NaviStartStream retry sequence stopped. " + LOG4CXX_DEBUG(logger_, "NaviStartStream retry sequence stopped. " << "Attempts expired"); app->set_video_stream_retry_number(0); - app_mgr->EndNaviServices(app->app_id()); + ApplicationManagerImpl::instance()->EndNaviServices(app->app_id()); } } -- cgit v1.2.1 From 9e15ae233de81a4aac923d706225a5b605d3fe11 Mon Sep 17 00:00:00 2001 From: Artem Nosach Date: Fri, 5 Jun 2015 16:17:42 +0300 Subject: Remove redundant database close. --- src/components/policy/src/policy/sqlite_wrapper/src/sql_database.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/policy/src/policy/sqlite_wrapper/src/sql_database.cc b/src/components/policy/src/policy/sqlite_wrapper/src/sql_database.cc index 7d698a6dd1..097e38a481 100644 --- a/src/components/policy/src/policy/sqlite_wrapper/src/sql_database.cc +++ b/src/components/policy/src/policy/sqlite_wrapper/src/sql_database.cc @@ -50,7 +50,9 @@ SQLDatabase::SQLDatabase(const std::string& db_name) error_(SQLITE_OK) {} SQLDatabase::~SQLDatabase() { - Close(); + if (conn_) { + Close(); + } } bool SQLDatabase::Open() { -- cgit v1.2.1 From 4e7ee0a886c3dad56a49293f98a2324b3d148a6f Mon Sep 17 00:00:00 2001 From: Artem Nosach Date: Mon, 8 Jun 2015 12:14:03 +0300 Subject: Make message broker thread safety. --- .../include/CMessageBrokerRegistry.hpp | 3 + .../lib_messagebroker/CMessageBrokerRegistry.cpp | 74 ++++++++++++++++------ 2 files changed, 56 insertions(+), 21 deletions(-) diff --git a/src/3rd_party-static/MessageBroker/include/CMessageBrokerRegistry.hpp b/src/3rd_party-static/MessageBroker/include/CMessageBrokerRegistry.hpp index 55550eab3a..b4c5376621 100644 --- a/src/3rd_party-static/MessageBroker/include/CMessageBrokerRegistry.hpp +++ b/src/3rd_party-static/MessageBroker/include/CMessageBrokerRegistry.hpp @@ -5,6 +5,7 @@ #include #include #include +#include "utils/lock.h" /** * \namespace NsMessageBroker @@ -91,12 +92,14 @@ namespace NsMessageBroker * For example PhoneController:1080 */ std::map mControllersList; + sync_primitives::Lock mControllersListLock; /** * \brief Map to store subscribers information like ComponentName.PropertyName:socketFd:. * For example PhoneController.onPhoneBookChanged:1080 */ std::multimap mSubscribersList; + sync_primitives::Lock mSubscribersListLock; }; } /* namespace NsMessageBroker */ diff --git a/src/3rd_party-static/MessageBroker/src/lib_messagebroker/CMessageBrokerRegistry.cpp b/src/3rd_party-static/MessageBroker/src/lib_messagebroker/CMessageBrokerRegistry.cpp index 2d55cecd67..278821c8a2 100644 --- a/src/3rd_party-static/MessageBroker/src/lib_messagebroker/CMessageBrokerRegistry.cpp +++ b/src/3rd_party-static/MessageBroker/src/lib_messagebroker/CMessageBrokerRegistry.cpp @@ -32,6 +32,8 @@ namespace NsMessageBroker DBG_MSG(("CMessageBrokerRegistry::addController()\n")); bool result = false; std::map ::iterator it; + + sync_primitives::AutoLock lock(mControllersListLock); it = mControllersList.find(name); if (it == mControllersList.end()) { @@ -41,6 +43,7 @@ namespace NsMessageBroker { DBG_MSG(("Controller already exists!\n")); } + DBG_MSG(("Count of controllers: %d\n", mControllersList.size())); return result; } @@ -49,43 +52,62 @@ namespace NsMessageBroker { DBG_MSG(("CMessageBrokerRegistry::deleteController()\n")); std::map ::iterator it; - it = mControllersList.find(name); - if (it != mControllersList.end()) + + int fd; { - int fd = it->second; - mControllersList.erase(it); - std::multimap ::iterator it_s = mSubscribersList.begin(); - for (; it_s !=mSubscribersList.end(); ) { - if (it_s->second == fd) { - mSubscribersList.erase(it_s++); - } else { - ++it_s; - } + sync_primitives::AutoLock controllers_lock(mControllersListLock); + it = mControllersList.find(name); + if (it != mControllersList.end()) + { + fd = it->second; + mControllersList.erase(it); + } else { + DBG_MSG(("No such controller in the list!\n")); + return; + } + DBG_MSG(("Count of controllers: %d\n", mControllersList.size())); + } + + sync_primitives::AutoLock subscribers_lock(mSubscribersListLock); + std::multimap ::iterator it_s = mSubscribersList.begin(); + for (; it_s !=mSubscribersList.end(); ) { + if (it_s->second == fd) { + mSubscribersList.erase(it_s++); + } else { + ++it_s; } - } else - { - DBG_MSG(("No such controller in the list!\n")); } - DBG_MSG(("Count of controllers: %d\n", mControllersList.size())); } void CMessageBrokerRegistry::removeControllersByDescriptor(const int fd) { DBG_MSG(("CMessageBrokerRegistry::removeControllersByDescriptor(%d)\n", fd)); - std::map ::iterator it = mControllersList.begin(); - while(it != mControllersList.end()) { - if (it->second == fd) { - deleteController((it++)->first); - } else { - ++it; + std::vector controllers_to_delete; + { + sync_primitives::AutoLock controllers_lock(mControllersListLock); + std::map ::iterator it = mControllersList.begin(); + for (; it != mControllersList.end();) { + if (it->second == fd) { + controllers_to_delete.push_back((it++)->first); + } else { + ++it; + } } } + + std::vector::iterator delete_it = + controllers_to_delete.begin(); + for (; controllers_to_delete.end() != delete_it; ++delete_it) { + deleteController(*delete_it); + } } bool CMessageBrokerRegistry::addSubscriber(int fd, std::string name) { DBG_MSG(("CMessageBrokerRegistry::addSubscriber()\n")); bool result = true; + + sync_primitives::AutoLock lock(mSubscribersListLock); std::pair::iterator, std::multimap ::iterator> p = mSubscribersList.equal_range(name); if (p.first != p.second) { @@ -103,6 +125,7 @@ namespace NsMessageBroker { mSubscribersList.insert(std::map ::value_type(name, fd)); } + DBG_MSG(("Count of subscribers: %d\n", mSubscribersList.size())); return result; } @@ -110,6 +133,8 @@ namespace NsMessageBroker void CMessageBrokerRegistry::deleteSubscriber(int fd, std::string name) { DBG_MSG(("CMessageBrokerRegistry::deleteSubscriber()\n")); + + sync_primitives::AutoLock lock(mSubscribersListLock); std::pair::iterator, std::multimap ::iterator> p = mSubscribersList.equal_range(name); if (p.first != p.second) { std::multimap ::iterator itr; @@ -122,6 +147,7 @@ namespace NsMessageBroker } } } + DBG_MSG(("Count of subscribers: %d\n", mSubscribersList.size())); } @@ -130,11 +156,14 @@ namespace NsMessageBroker DBG_MSG(("CMessageBrokerRegistry::getDestinationFd()\n")); int result = -1; std::map ::iterator it; + + sync_primitives::AutoLock lock(mControllersListLock); it = mControllersList.find(name); if (it != mControllersList.end()) { result = it->second; } + DBG_MSG(("Controllers Fd: %d\n", result)); return result; } @@ -144,6 +173,8 @@ namespace NsMessageBroker DBG_MSG(("CMessageBrokerRegistry::getSubscribersFd()\n")); int res = 0; std::map ::iterator it; + + sync_primitives::AutoLock lock(mSubscribersListLock); std::pair::iterator, std::multimap ::iterator> p = mSubscribersList.equal_range(name); if (p.first != p.second) { @@ -154,6 +185,7 @@ namespace NsMessageBroker DBG_MSG(("Controllers Fd: %d\n", itr->second)); } } + res = result.size(); DBG_MSG(("Result vector size: %d\n", res)); return res; -- cgit v1.2.1 From ba12e8f88e8ddc22e13842d8fddb2f2da3210db3 Mon Sep 17 00:00:00 2001 From: Artem Nosach Date: Tue, 9 Jun 2015 10:44:38 +0300 Subject: Post review changes. --- .../include/CMessageBrokerRegistry.hpp | 6 ++++ .../lib_messagebroker/CMessageBrokerRegistry.cpp | 36 ++++++++++------------ .../src/policy/sqlite_wrapper/src/sql_database.cc | 8 +++-- 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/3rd_party-static/MessageBroker/include/CMessageBrokerRegistry.hpp b/src/3rd_party-static/MessageBroker/include/CMessageBrokerRegistry.hpp index b4c5376621..001f978bbf 100644 --- a/src/3rd_party-static/MessageBroker/include/CMessageBrokerRegistry.hpp +++ b/src/3rd_party-static/MessageBroker/include/CMessageBrokerRegistry.hpp @@ -52,6 +52,12 @@ namespace NsMessageBroker */ void removeControllersByDescriptor(const int fd); + /** + * \brief Remove all subscribers by descriptor + * \param fd descriptor + */ + void removeSubscribersByDescriptor(const int fd); + /** * \brief adds notification subscriber to the registry. * \param fd file descriptor of controller. diff --git a/src/3rd_party-static/MessageBroker/src/lib_messagebroker/CMessageBrokerRegistry.cpp b/src/3rd_party-static/MessageBroker/src/lib_messagebroker/CMessageBrokerRegistry.cpp index 278821c8a2..1e63f0ba31 100644 --- a/src/3rd_party-static/MessageBroker/src/lib_messagebroker/CMessageBrokerRegistry.cpp +++ b/src/3rd_party-static/MessageBroker/src/lib_messagebroker/CMessageBrokerRegistry.cpp @@ -5,7 +5,6 @@ */ #include "CMessageBrokerRegistry.hpp" - #include "libMBDebugHelper.h" #include @@ -55,7 +54,7 @@ namespace NsMessageBroker int fd; { - sync_primitives::AutoLock controllers_lock(mControllersListLock); + sync_primitives::AutoLock lock(mControllersListLock); it = mControllersList.find(name); if (it != mControllersList.end()) { @@ -67,38 +66,37 @@ namespace NsMessageBroker } DBG_MSG(("Count of controllers: %d\n", mControllersList.size())); } - - sync_primitives::AutoLock subscribers_lock(mSubscribersListLock); - std::multimap ::iterator it_s = mSubscribersList.begin(); - for (; it_s !=mSubscribersList.end(); ) { - if (it_s->second == fd) { - mSubscribersList.erase(it_s++); - } else { - ++it_s; - } - } + removeSubscribersByDescriptor(fd); } void CMessageBrokerRegistry::removeControllersByDescriptor(const int fd) { DBG_MSG(("CMessageBrokerRegistry::removeControllersByDescriptor(%d)\n", fd)); - std::vector controllers_to_delete; { - sync_primitives::AutoLock controllers_lock(mControllersListLock); + sync_primitives::AutoLock lock(mControllersListLock); std::map ::iterator it = mControllersList.begin(); for (; it != mControllersList.end();) { if (it->second == fd) { - controllers_to_delete.push_back((it++)->first); + mControllersList.erase(it); } else { ++it; } } } + removeSubscribersByDescriptor(fd); + } - std::vector::iterator delete_it = - controllers_to_delete.begin(); - for (; controllers_to_delete.end() != delete_it; ++delete_it) { - deleteController(*delete_it); + void CMessageBrokerRegistry::removeSubscribersByDescriptor(const int fd) { + DBG_MSG(("CMessageBrokerRegistry::removeSubscribersByDescriptor(%d)\n", + fd)); + sync_primitives::AutoLock lock(mSubscribersListLock); + std::multimap ::iterator it_s = mSubscribersList.begin(); + for (; it_s !=mSubscribersList.end(); ) { + if (it_s->second == fd) { + mSubscribersList.erase(it_s++); + } else { + ++it_s; + } } } diff --git a/src/components/policy/src/policy/sqlite_wrapper/src/sql_database.cc b/src/components/policy/src/policy/sqlite_wrapper/src/sql_database.cc index 097e38a481..6a1d70f005 100644 --- a/src/components/policy/src/policy/sqlite_wrapper/src/sql_database.cc +++ b/src/components/policy/src/policy/sqlite_wrapper/src/sql_database.cc @@ -50,9 +50,7 @@ SQLDatabase::SQLDatabase(const std::string& db_name) error_(SQLITE_OK) {} SQLDatabase::~SQLDatabase() { - if (conn_) { - Close(); - } + Close(); } bool SQLDatabase::Open() { @@ -68,6 +66,10 @@ bool SQLDatabase::IsReadWrite() { } void SQLDatabase::Close() { + if (!conn_) { + return; + } + sync_primitives::AutoLock auto_lock(conn_lock_); error_ = sqlite3_close(conn_); if (error_ == SQLITE_OK) { -- cgit v1.2.1 From 8d07cfb824c4ee65ba5b859d068ff3e3d24c6067 Mon Sep 17 00:00:00 2001 From: Artem Nosach Date: Wed, 20 May 2015 17:35:04 +0300 Subject: Set background HMI level only for non-audio applications. --- src/components/application_manager/src/state_controller.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/application_manager/src/state_controller.cc b/src/components/application_manager/src/state_controller.cc index 57927f46ac..0434e471fd 100644 --- a/src/components/application_manager/src/state_controller.cc +++ b/src/components/application_manager/src/state_controller.cc @@ -116,14 +116,14 @@ void StateController::SetupRegularHmiState(ApplicationSharedPtr app, if (state->hmi_level() == mobile_apis::HMILevel::HMI_NONE) { app->ResetDataInNone(); } - if (!app->is_media_application()) { + if (!app->IsAudioApplication()) { if (state->hmi_level() == HMILevel::HMI_LIMITED) { - LOG4CXX_ERROR(logger_, "Trying to setup LIMITED to non media app"); + LOG4CXX_ERROR(logger_, "Trying to setup LIMITED to non audio app"); state->set_hmi_level(HMILevel::HMI_BACKGROUND); } if (state->audio_streaming_state() != AudioStreamingState::NOT_AUDIBLE) { LOG4CXX_ERROR(logger_, "Trying to setup audio state " << - state->audio_streaming_state() <<" to non media app"); + state->audio_streaming_state() <<" to non audio app"); state->set_audio_streaming_state(AudioStreamingState::NOT_AUDIBLE); } } -- cgit v1.2.1 From 29dc04cf5eb7bb120695e526072517561b86f34c Mon Sep 17 00:00:00 2001 From: Artem Nosach Date: Sun, 10 May 2015 20:51:49 +0300 Subject: Remove redundant calls. --- src/components/media_manager/src/media_manager_impl.cc | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/components/media_manager/src/media_manager_impl.cc b/src/components/media_manager/src/media_manager_impl.cc index cb9d5c4ff8..61b2c5bb92 100644 --- a/src/components/media_manager/src/media_manager_impl.cc +++ b/src/components/media_manager/src/media_manager_impl.cc @@ -211,18 +211,12 @@ void MediaManagerImpl::StartStreaming( if (streamer_[service_type]) { streamer_[service_type]->StartActivity(application_key); } - if (streamer_listener_[service_type]) { - streamer_listener_[service_type]->OnActivityStarted(application_key); - } } void MediaManagerImpl::StopStreaming( int32_t application_key, protocol_handler::ServiceType service_type) { LOG4CXX_AUTO_TRACE(logger_); - if (streamer_listener_[service_type]) { - streamer_listener_[service_type]->OnActivityEnded(application_key); - } if (streamer_[service_type]) { streamer_[service_type]->StopActivity(application_key); } -- cgit v1.2.1 From e6f3f2be73f11b3955fa15ad9e91d38d6dc6bda1 Mon Sep 17 00:00:00 2001 From: Artem Nosach Date: Sun, 10 May 2015 22:36:44 +0300 Subject: Wake up streaming correctly. --- .../application_manager/application_manager_impl.h | 4 ++- .../application_manager/src/application_impl.cc | 14 +++++--- .../src/application_manager_impl.cc | 40 +++++++--------------- .../application_manager/application_manager_impl.h | 2 +- 4 files changed, 26 insertions(+), 34 deletions(-) diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index 90d26ac88d..1a82f53501 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -703,9 +703,11 @@ class ApplicationManagerImpl : public ApplicationManager, /** * @brief Callback calls when application starts/stops data streaming * @param app_id Streaming application id + * @param service_type Streaming service type * @param state Shows if streaming started or stopped */ - void OnAppStreaming(uint32_t app_id, bool state); + void OnAppStreaming( + uint32_t app_id, protocol_handler::ServiceType service_type, bool state); /** * @brief OnHMILevelChanged the callback that allows SDL to react when diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 69b8c91bbd..59b3830447 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -434,6 +434,8 @@ void ApplicationImpl::StopStreaming( using namespace protocol_handler; LOG4CXX_AUTO_TRACE(logger_); + SuspendStreaming(service_type); + if (ServiceType::kMobileNav == service_type) { if (video_streaming_approved()) { video_stream_suspend_timer_->stop(); @@ -456,12 +458,14 @@ void ApplicationImpl::SuspendStreaming( if (ServiceType::kMobileNav == service_type) { video_stream_suspend_timer_->suspend(); - ApplicationManagerImpl::instance()->OnAppStreaming(app_id(), false); + ApplicationManagerImpl::instance()->OnAppStreaming( + app_id(), service_type, false); sync_primitives::AutoLock lock(video_streaming_suspended_lock_); video_streaming_suspended_ = true; } else if (ServiceType::kAudio == service_type) { audio_stream_suspend_timer_->suspend(); - ApplicationManagerImpl::instance()->OnAppStreaming(app_id(), false); + ApplicationManagerImpl::instance()->OnAppStreaming( + app_id(), service_type, false); sync_primitives::AutoLock lock(audio_streaming_suspended_lock_); audio_streaming_suspended_ = true; } @@ -476,7 +480,8 @@ void ApplicationImpl::WakeUpStreaming( if (ServiceType::kMobileNav == service_type) { sync_primitives::AutoLock lock(video_streaming_suspended_lock_); if (video_streaming_suspended_) { - ApplicationManagerImpl::instance()->OnAppStreaming(app_id(), true); + ApplicationManagerImpl::instance()->OnAppStreaming( + app_id(), service_type, true); MessageHelper::SendOnDataStreaming(ServiceType::kMobileNav, true); video_streaming_suspended_ = false; } @@ -484,7 +489,8 @@ void ApplicationImpl::WakeUpStreaming( } else if (ServiceType::kAudio == service_type) { sync_primitives::AutoLock lock(audio_streaming_suspended_lock_); if (audio_streaming_suspended_) { - ApplicationManagerImpl::instance()->OnAppStreaming(app_id(), true); + ApplicationManagerImpl::instance()->OnAppStreaming( + app_id(), service_type, true); MessageHelper::SendOnDataStreaming(ServiceType::kAudio, true); audio_streaming_suspended_ = false; } diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 6f01b3595e..b8ba76541a 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -992,11 +992,6 @@ bool ApplicationManagerImpl::StartNaviService( using namespace protocol_handler; LOG4CXX_AUTO_TRACE(logger_); - if (!media_manager_) { - LOG4CXX_DEBUG(logger_, "The media manager is not initialized."); - return false; - } - if (HMILevelAllowsStreaming(app_id, service_type)) { NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id); @@ -1016,8 +1011,6 @@ bool ApplicationManagerImpl::StartNaviService( true : it->second.second = true; application(app_id)->StartStreaming(service_type); - media_manager_->StartStreaming(app_id, service_type); - return true; } return false; @@ -1041,12 +1034,6 @@ void ApplicationManagerImpl::StopNaviService( false : it->second.second = false; } - if (!media_manager_) { - LOG4CXX_DEBUG(logger_, "The media manager is not initialized."); - return; - } - media_manager_->StopStreaming(app_id, service_type); - ApplicationSharedPtr app = application(app_id); if (!app) { LOG4CXX_WARN(logger_, "An application is not registered."); @@ -2600,7 +2587,9 @@ void ApplicationManagerImpl::ForbidStreaming(uint32_t app_id) { EndNaviServices(app_id); } -void ApplicationManagerImpl::OnAppStreaming(uint32_t app_id, bool state) { +void ApplicationManagerImpl::OnAppStreaming( + uint32_t app_id, protocol_handler::ServiceType service_type, bool state) { + using namespace protocol_handler; LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr app = application(app_id); @@ -2608,8 +2597,15 @@ void ApplicationManagerImpl::OnAppStreaming(uint32_t app_id, bool state) { LOG4CXX_DEBUG(logger_, " There is no navi application with id: " << app_id); return; } - state ? state_ctrl_.OnNaviStreamingStarted() : - state_ctrl_.OnNaviStreamingStopped(); + DCHECK_OR_RETURN_VOID(media_manager_); + + if (state) { + state_ctrl_.OnNaviStreamingStarted(); + media_manager_->StartStreaming(app_id, service_type); + } else { + media_manager_->StopStreaming(app_id, service_type); + state_ctrl_.OnNaviStreamingStopped(); + } } void ApplicationManagerImpl::EndNaviServices(uint32_t app_id) { @@ -2756,15 +2752,9 @@ void ApplicationManagerImpl::DisallowStreaming(uint32_t app_id) { navi_service_status_.find(app_id); if (navi_service_status_.end() != it) { if (it->second.first) { - if (media_manager_) { - media_manager_->StopStreaming(app_id, ServiceType::kMobileNav); - } app->set_video_streaming_allowed(false); } if (it->second.second) { - if (media_manager_) { - media_manager_->StopStreaming(app_id, ServiceType::kAudio); - } app->set_audio_streaming_allowed(false); } } @@ -2784,15 +2774,9 @@ void ApplicationManagerImpl::AllowStreaming(uint32_t app_id) { navi_service_status_.find(app_id); if (navi_service_status_.end() != it) { if (it->second.first) { - if (media_manager_) { - media_manager_->StartStreaming(app_id, ServiceType::kMobileNav); - } app->set_video_streaming_allowed(true); } if (it->second.second) { - if (media_manager_) { - media_manager_->StartStreaming(app_id, ServiceType::kAudio); - } app->set_audio_streaming_allowed(true); } } diff --git a/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h b/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h index cbccdfd85b..eb97730ebf 100644 --- a/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h @@ -250,7 +250,7 @@ class ApplicationManagerImpl : public ApplicationManager, MOCK_METHOD2(CanAppStream, bool(uint32_t, protocol_handler::ServiceType)); MOCK_METHOD1(EndNaviServices, void(int32_t)); MOCK_METHOD1(ForbidStreaming, void(int32_t)); - MOCK_METHOD2(OnAppStreaming, void(int32_t, bool)); + MOCK_METHOD2(OnAppStreaming, void(int32_t, protocol_handler::ServiceType, bool)); MOCK_METHOD1(Unmute, void(VRTTSSessionChanging)); MOCK_METHOD1(Mute, void(VRTTSSessionChanging)); -- cgit v1.2.1 From 06a0c36d33a7b8d621a03f787c88eff2b1d388e0 Mon Sep 17 00:00:00 2001 From: Artem Nosach Date: Fri, 15 May 2015 10:31:59 +0300 Subject: Fix tests build. --- .../test/mock/include/application_manager/application_manager_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h b/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h index eb97730ebf..cad956ead5 100644 --- a/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h @@ -250,7 +250,7 @@ class ApplicationManagerImpl : public ApplicationManager, MOCK_METHOD2(CanAppStream, bool(uint32_t, protocol_handler::ServiceType)); MOCK_METHOD1(EndNaviServices, void(int32_t)); MOCK_METHOD1(ForbidStreaming, void(int32_t)); - MOCK_METHOD2(OnAppStreaming, void(int32_t, protocol_handler::ServiceType, bool)); + MOCK_METHOD3(OnAppStreaming, void(int32_t, protocol_handler::ServiceType, bool)); MOCK_METHOD1(Unmute, void(VRTTSSessionChanging)); MOCK_METHOD1(Mute, void(VRTTSSessionChanging)); -- cgit v1.2.1