summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md6
-rw-r--r--customer-specific/pasa/src/appMain/smartDeviceLink.ini2
-rw-r--r--src/3rd_party-static/MessageBroker/include/CMessageBrokerRegistry.hpp9
-rw-r--r--src/3rd_party-static/MessageBroker/src/lib_messagebroker/CMessageBrokerRegistry.cpp74
-rw-r--r--src/appMain/smartDeviceLink.ini4
-rw-r--r--src/components/application_manager/include/application_manager/application_manager_impl.h8
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/create_interaction_choice_set_request.h17
-rw-r--r--src/components/application_manager/src/application_impl.cc14
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc93
-rw-r--r--src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc56
-rw-r--r--src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc53
-rw-r--r--src/components/application_manager/src/commands/hmi/on_tts_language_change_notification.cc4
-rw-r--r--src/components/application_manager/src/commands/hmi/on_ui_language_change_notification.cc4
-rw-r--r--src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc111
-rw-r--r--src/components/application_manager/src/commands/mobile/delete_command_request.cc2
-rw-r--r--src/components/application_manager/src/commands/mobile/unregister_app_interface_request.cc3
-rw-r--r--src/components/application_manager/src/hmi_state.cc3
-rw-r--r--src/components/application_manager/src/state_controller.cc6
-rw-r--r--src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h9
-rw-r--r--src/components/connection_handler/include/connection_handler/connection_handler_observer.h18
-rw-r--r--src/components/connection_handler/src/connection.cc3
-rw-r--r--src/components/connection_handler/src/connection_handler_impl.cc34
-rw-r--r--src/components/connection_handler/test/connection_handler_impl_test.cc301
-rw-r--r--src/components/media_manager/src/media_manager_impl.cc6
-rw-r--r--src/components/protocol_handler/test/include/protocol_observer_mock.h17
-rw-r--r--src/components/utils/src/sqlite_wrapper/sql_database.cc4
26 files changed, 621 insertions, 240 deletions
diff --git a/README.md b/README.md
index 8d8b6079c6..e81f690d5d 100644
--- a/README.md
+++ b/README.md
@@ -49,6 +49,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.
diff --git a/customer-specific/pasa/src/appMain/smartDeviceLink.ini b/customer-specific/pasa/src/appMain/smartDeviceLink.ini
index a606049e38..e868562011 100644
--- a/customer-specific/pasa/src/appMain/smartDeviceLink.ini
+++ b/customer-specific/pasa/src/appMain/smartDeviceLink.ini
@@ -64,6 +64,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/3rd_party-static/MessageBroker/include/CMessageBrokerRegistry.hpp b/src/3rd_party-static/MessageBroker/include/CMessageBrokerRegistry.hpp
index 55550eab3a..001f978bbf 100644
--- a/src/3rd_party-static/MessageBroker/include/CMessageBrokerRegistry.hpp
+++ b/src/3rd_party-static/MessageBroker/include/CMessageBrokerRegistry.hpp
@@ -5,6 +5,7 @@
#include <vector>
#include <iostream>
#include <string>
+#include "utils/lock.h"
/**
* \namespace NsMessageBroker
@@ -52,6 +53,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.
* \param name name of property which should be observed.
@@ -91,12 +98,14 @@ namespace NsMessageBroker
* For example PhoneController:1080
*/
std::map <std::string, int> mControllersList;
+ sync_primitives::Lock mControllersListLock;
/**
* \brief Map to store subscribers information like ComponentName.PropertyName:socketFd:.
* For example PhoneController.onPhoneBookChanged:1080
*/
std::multimap <std::string, int> 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..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 <vector>
@@ -32,6 +31,8 @@ namespace NsMessageBroker
DBG_MSG(("CMessageBrokerRegistry::addController()\n"));
bool result = false;
std::map <std::string, int>::iterator it;
+
+ sync_primitives::AutoLock lock(mControllersListLock);
it = mControllersList.find(name);
if (it == mControllersList.end())
{
@@ -41,6 +42,7 @@ namespace NsMessageBroker
{
DBG_MSG(("Controller already exists!\n"));
}
+
DBG_MSG(("Count of controllers: %d\n", mControllersList.size()));
return result;
}
@@ -49,43 +51,61 @@ namespace NsMessageBroker
{
DBG_MSG(("CMessageBrokerRegistry::deleteController()\n"));
std::map <std::string, int>::iterator it;
- it = mControllersList.find(name);
- if (it != mControllersList.end())
+
+ int fd;
{
- int fd = it->second;
- mControllersList.erase(it);
- std::multimap <std::string, int>::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 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;
}
- } else
- {
- DBG_MSG(("No such controller in the list!\n"));
+ DBG_MSG(("Count of controllers: %d\n", mControllersList.size()));
}
- DBG_MSG(("Count of controllers: %d\n", mControllersList.size()));
+ removeSubscribersByDescriptor(fd);
}
void CMessageBrokerRegistry::removeControllersByDescriptor(const int fd) {
DBG_MSG(("CMessageBrokerRegistry::removeControllersByDescriptor(%d)\n",
fd));
- std::map <std::string, int>::iterator it = mControllersList.begin();
- while(it != mControllersList.end()) {
- if (it->second == fd) {
- deleteController((it++)->first);
- } else {
- ++it;
+ {
+ sync_primitives::AutoLock lock(mControllersListLock);
+ std::map <std::string, int>::iterator it = mControllersList.begin();
+ for (; it != mControllersList.end();) {
+ if (it->second == fd) {
+ mControllersList.erase(it);
+ } else {
+ ++it;
+ }
}
}
+ removeSubscribersByDescriptor(fd);
+ }
+
+ void CMessageBrokerRegistry::removeSubscribersByDescriptor(const int fd) {
+ DBG_MSG(("CMessageBrokerRegistry::removeSubscribersByDescriptor(%d)\n",
+ fd));
+ sync_primitives::AutoLock lock(mSubscribersListLock);
+ std::multimap <std::string, int>::iterator it_s = mSubscribersList.begin();
+ for (; it_s !=mSubscribersList.end(); ) {
+ if (it_s->second == fd) {
+ mSubscribersList.erase(it_s++);
+ } else {
+ ++it_s;
+ }
+ }
}
bool CMessageBrokerRegistry::addSubscriber(int fd, std::string name)
{
DBG_MSG(("CMessageBrokerRegistry::addSubscriber()\n"));
bool result = true;
+
+ sync_primitives::AutoLock lock(mSubscribersListLock);
std::pair<std::multimap <std::string, int>::iterator, std::multimap <std::string, int>::iterator> p = mSubscribersList.equal_range(name);
if (p.first != p.second)
{
@@ -103,6 +123,7 @@ namespace NsMessageBroker
{
mSubscribersList.insert(std::map <std::string, int>::value_type(name, fd));
}
+
DBG_MSG(("Count of subscribers: %d\n", mSubscribersList.size()));
return result;
}
@@ -110,6 +131,8 @@ namespace NsMessageBroker
void CMessageBrokerRegistry::deleteSubscriber(int fd, std::string name)
{
DBG_MSG(("CMessageBrokerRegistry::deleteSubscriber()\n"));
+
+ sync_primitives::AutoLock lock(mSubscribersListLock);
std::pair<std::multimap <std::string, int>::iterator, std::multimap <std::string, int>::iterator> p = mSubscribersList.equal_range(name);
if (p.first != p.second) {
std::multimap <std::string, int>::iterator itr;
@@ -122,6 +145,7 @@ namespace NsMessageBroker
}
}
}
+
DBG_MSG(("Count of subscribers: %d\n", mSubscribersList.size()));
}
@@ -130,11 +154,14 @@ namespace NsMessageBroker
DBG_MSG(("CMessageBrokerRegistry::getDestinationFd()\n"));
int result = -1;
std::map <std::string, int>::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 +171,8 @@ namespace NsMessageBroker
DBG_MSG(("CMessageBrokerRegistry::getSubscribersFd()\n"));
int res = 0;
std::map <std::string, int>::iterator it;
+
+ sync_primitives::AutoLock lock(mSubscribersListLock);
std::pair<std::multimap <std::string, int>::iterator, std::multimap <std::string, int>::iterator> p = mSubscribersList.equal_range(name);
if (p.first != p.second)
{
@@ -154,6 +183,7 @@ namespace NsMessageBroker
DBG_MSG(("Controllers Fd: %d\n", itr->second));
}
}
+
res = result.size();
DBG_MSG(("Result vector size: %d\n", res));
return res;
diff --git a/src/appMain/smartDeviceLink.ini b/src/appMain/smartDeviceLink.ini
index 27cd255665..dcad14a611 100644
--- a/src/appMain/smartDeviceLink.ini
+++ b/src/appMain/smartDeviceLink.ini
@@ -63,8 +63,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/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h
index 611b9fe7fc..7c9d7ca896 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"
@@ -610,8 +611,7 @@ 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;
- void OnMalformedMessageCallback(const uint32_t& connection_key) OVERRIDE;
+
/**
* @ Add notification to collection
*
@@ -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/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/application_impl.cc b/src/components/application_manager/src/application_impl.cc
index ba9bff81a9..1c5347e646 100644
--- a/src/components/application_manager/src/application_impl.cc
+++ b/src/components/application_manager/src/application_impl.cc
@@ -440,6 +440,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();
@@ -462,12 +464,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;
}
@@ -482,7 +486,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;
}
@@ -490,7 +495,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 2c9048d870..9f91389722 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -519,6 +519,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<false>(app, hmi_level, audio_state);
return true;
}
@@ -1016,11 +1017,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);
@@ -1040,8 +1036,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;
@@ -1065,12 +1059,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.");
@@ -1117,6 +1105,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
@@ -1124,9 +1113,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;
@@ -1172,30 +1163,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;
@@ -2270,6 +2237,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);
@@ -2318,9 +2294,6 @@ void ApplicationManagerImpl::UnregisterApplication(
}
//remove appID from tts_global_properties_app_list_
- MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile(
- app_id, unregister_reason_);
-
RemoveAppFromTTSGlobalPropertiesList(app_id);
switch (reason) {
@@ -2394,7 +2367,6 @@ void ApplicationManagerImpl::UnregisterApplication(
return;
}
-
void ApplicationManagerImpl::OnAppUnauthorized(const uint32_t& app_id) {
connection_handler_->CloseSession(app_id, connection_handler::kUnauthorizedApp);
}
@@ -2658,14 +2630,17 @@ 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;
}
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);
@@ -2673,8 +2648,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) {
@@ -2786,7 +2768,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);
}
}
@@ -2820,15 +2803,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);
}
}
@@ -2848,15 +2825,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/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..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
@@ -46,12 +46,10 @@ AudioStartStreamRequest::AudioStartStreamRequest(
LOG4CXX_AUTO_TRACE(logger_);
std::pair<uint32_t, int32_t> 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_);
- //stream_retry.first times after stream_retry.second timeout
- //SDL should resend AudioStartStreamRequest
}
AudioStartStreamRequest::~AudioStartStreamRequest() {
@@ -59,41 +57,57 @@ 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);
+
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->
+ application_by_hmi_app(application_id());
+ if (!app) {
+ LOG4CXX_ERROR(logger_,
+ "StartAudioStreamRequest aborted. Application not found");
+ return;
+ }
+ if (app->audio_streaming_approved()) {
+ LOG4CXX_DEBUG(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) {
- 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 squence stopped");
- app_mgr->EndNaviServices(app->app_id());
+ LOG4CXX_DEBUG(logger_, "Audio start stream retry sequence stopped. "
+ << "Attempts expired.");
app->set_audio_stream_retry_number(0);
+ ApplicationManagerImpl::instance()->EndNaviServices(app->app_id());
}
}
void AudioStartStreamRequest::onTimeOut() {
RetryStartSession();
+
+ ApplicationManagerImpl::instance()->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();
- 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");
}
}
@@ -101,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;
}
@@ -122,15 +134,13 @@ 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_,
"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 66a7e14fad..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
@@ -46,7 +46,7 @@ NaviStartStreamRequest::NaviStartStreamRequest(
LOG4CXX_AUTO_TRACE(logger_);
std::pair<uint32_t, int32_t> 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_);
@@ -58,16 +58,17 @@ 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();
- 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();
} else {
- LOG4CXX_ERROR(logger_, "Applcation with hhi_app_id "
+ LOG4CXX_ERROR(logger_, "Applcation with hmi_app_id "
<< application_id() << "does not exist");
}
}
@@ -76,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;
}
@@ -97,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_,
@@ -115,24 +115,39 @@ void NaviStartStreamRequest::on_event(const event_engine::Event& event) {
void NaviStartStreamRequest::onTimeOut() {
RetryStartSession();
+
+ 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());
- DCHECK_OR_RETURN_VOID(app);
- uint32_t curr_retry_number = app->video_stream_retry_number();
+
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->
+ application_by_hmi_app(application_id());
+ if (!app) {
+ LOG4CXX_ERROR(logger_,
+ "NaviStartStreamRequest aborted. Application not found");
+ return;
+ }
+ if (app->video_streaming_approved()) {
+ LOG4CXX_DEBUG(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) {
- 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 squence stopped");
- app_mgr->EndNaviServices(app->app_id());
+ LOG4CXX_DEBUG(logger_, "NaviStartStream retry sequence stopped. "
+ << "Attempts expired");
app->set_video_stream_retry_number(0);
+ ApplicationManagerImpl::instance()->EndNaviServices(app->app_id());
}
}
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_);
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..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
@@ -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<Common_Result::eType>(
- 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<uint32_t>(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<uint32_t>(message[strings::params]
+ [strings::correlation_id].asUInt());
+ SentCommandsMap::iterator it = sent_commands_map_.find(corr_id);
+ if (sent_commands_map_.end() == it) {
+ LOG4CXX_WARN(logger_, "HMI response for unknown VR command received");
+ return;
+ }
+
+ Common_Result::eType vr_result_ = static_cast<Common_Result::eType>(
+ 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");
+ << ". Stop sending VRAddCommand requests");
+ 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,20 +403,22 @@ 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
+ // according to SDLAQ-CRS-2976
+ 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_);
ApplicationSharedPtr application =
ApplicationManagerImpl::instance()->application(connection_key());
@@ -399,18 +426,21 @@ void CreateInteractionChoiceSetRequest::DeleteChoices() {
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,17 @@ void CreateInteractionChoiceSetRequest::DeleteChoices() {
void CreateInteractionChoiceSetRequest::OnAllHMIResponsesReceived() {
LOG4CXX_AUTO_TRACE(logger_);
- if (error_from_hmi_) {
- DeleteChoices();
- } else {
+
+ 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());
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 59d8b8345c..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,7 +170,7 @@ void DeleteCommandRequest::on_event(const event_engine::Event& event) {
}
SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
- if (true == result) {
+ if (result) {
application->UpdateHash();
}
}
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/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<HMILevel::eType, EQ, ONE> (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;
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);
}
}
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 1d89f6e8d6..29ba9e0c96 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,10 +174,9 @@ 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&,
- const protocol_handler::ServiceType&));
- MOCK_METHOD1(OnApplicationFloodCallBack, void(const uint32_t&));
- MOCK_METHOD1(OnMalformedMessageCallback, void(const uint32_t&));
+ MOCK_METHOD3(OnServiceEndedCallback, void (const int32_t&,
+ const protocol_handler::ServiceType&,
+ const connection_handler::CloseSessionReason&));
MOCK_METHOD1(Handle, void (const impl::MessageFromMobile));
MOCK_METHOD1(Handle, void (const impl::MessageToMobile));
MOCK_METHOD1(Handle, void (const impl::MessageFromHmi));
@@ -253,7 +252,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_METHOD3(OnAppStreaming, void(int32_t, protocol_handler::ServiceType, bool));
MOCK_METHOD1(Unmute, void(VRTTSSessionChanging));
MOCK_METHOD1(Mute, void(VRTTSSessionChanging));
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..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
@@ -96,24 +96,10 @@ 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;
- /**
- * \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;
-
- /**
- * \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.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_);
diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc
index 4521f52cbb..550eb236d6 100644
--- a/src/components/connection_handler/src/connection_handler_impl.cc
+++ b/src/components/connection_handler/src/connection_handler_impl.cc
@@ -358,14 +358,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);
@@ -379,14 +375,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);
@@ -444,7 +436,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;
}
@@ -765,6 +757,12 @@ void ConnectionHandlerImpl::CloseSession(ConnectionHandle connection_handle,
LOG4CXX_AUTO_TRACE(logger_);
LOG4CXX_DEBUG(logger_, "Closing session with id: " << session_id);
+ // 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);
+ }
+
transport_manager::ConnectionUID connection_id =
ConnectionUIDFromHandle(connection_handle);
@@ -775,9 +773,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
@@ -935,7 +931,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);
}
}
}
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/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);
}
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
diff --git a/src/components/utils/src/sqlite_wrapper/sql_database.cc b/src/components/utils/src/sqlite_wrapper/sql_database.cc
index 8f36ea9a0f..d69bb8231e 100644
--- a/src/components/utils/src/sqlite_wrapper/sql_database.cc
+++ b/src/components/utils/src/sqlite_wrapper/sql_database.cc
@@ -66,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) {