summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYana Chernysheva (GitHub) <59469418+ychernysheva@users.noreply.github.com>2020-10-23 17:59:35 +0300
committerGitHub <noreply@github.com>2020-10-23 10:59:35 -0400
commit3a9dd1a661bef9d013baa3fca6f9fcc25b596c54 (patch)
tree0c2b0598e134ba68ac239fe730626333278284c6
parent93d12eb664afd667379741fabda47d177893bbb9 (diff)
downloadsdl_core-3a9dd1a661bef9d013baa3fca6f9fcc25b596c54.tar.gz
Add missed NACK reasons (#3545)
* Add missed NACK reasons, update UTs and add minor changes
-rw-r--r--src/components/application_manager/include/application_manager/application_manager_impl.h19
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_set_video_config_request.cc26
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_set_video_config_request_test.cc27
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc122
-rw-r--r--src/components/application_manager/test/application_manager_impl_test.cc87
-rw-r--r--src/components/connection_handler/include/connection_handler/connection_handler_impl.h8
-rw-r--r--src/components/connection_handler/src/connection_handler_impl.cc7
-rw-r--r--src/components/connection_handler/test/connection_handler_impl_test.cc36
-rw-r--r--src/components/include/application_manager/application_manager.h22
-rw-r--r--src/components/include/connection_handler/connection_handler.h3
-rw-r--r--src/components/include/protocol_handler/protocol_handler.h2
-rw-r--r--src/components/include/test/application_manager/mock_application_manager.h10
-rw-r--r--src/components/include/test/connection_handler/mock_connection_handler.h5
-rw-r--r--src/components/include/test/protocol_handler/mock_protocol_handler.h3
-rw-r--r--src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h4
-rw-r--r--src/components/protocol_handler/src/protocol_handler_impl.cc22
-rw-r--r--src/components/protocol_handler/test/protocol_handler_tm_test.cc2
17 files changed, 204 insertions, 201 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 965f63e7cb..af7fe19f48 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
@@ -870,19 +870,12 @@ class ApplicationManagerImpl
void ForbidStreaming(uint32_t app_id,
protocol_handler::ServiceType service_type) OVERRIDE;
- /**
- * @brief Called when application completes streaming configuration
- * @param app_id Streaming application id
- * @param service_type Streaming service type
- * @param result true if configuration is successful, false otherwise
- * @param rejected_params list of rejected parameters' name. Valid
- * only when result is false.
- */
- void OnStreamingConfigured(
- uint32_t app_id,
- protocol_handler::ServiceType service_type,
- bool result,
- std::vector<std::string>& rejected_params) OVERRIDE;
+ void OnStreamingConfigurationSuccessful(
+ uint32_t app_id, protocol_handler::ServiceType service_type) OVERRIDE;
+
+ void OnStreamingConfigurationFailed(uint32_t app_id,
+ std::vector<std::string>& rejected_params,
+ const std::string& reason) OVERRIDE;
void OnAppStreaming(uint32_t app_id,
protocol_handler::ServiceType service_type,
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_set_video_config_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_set_video_config_request.cc
index e4fbdaa0d6..ff9d861def 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_set_video_config_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_set_video_config_request.cc
@@ -93,16 +93,15 @@ void NaviSetVideoConfigRequest::on_event(const event_engine::Event& event) {
const hmi_apis::Common_Result::eType code =
static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
- bool result = false;
- std::vector<std::string> rejected_params;
if (code == hmi_apis::Common_Result::SUCCESS) {
SDL_LOG_DEBUG("Received SetVideoConfig success response");
- result = true;
+ application_manager_.OnStreamingConfigurationSuccessful(
+ app->app_id(), protocol_handler::ServiceType::kMobileNav);
} else {
SDL_LOG_DEBUG("Received SetVideoConfig failure response (" << event.id()
<< ")");
- result = false;
+ std::vector<std::string> rejected_params;
if (message[strings::msg_params].keyExists(strings::rejected_params)) {
const smart_objects::SmartArray* list =
message[strings::msg_params][strings::rejected_params].asArray();
@@ -118,13 +117,14 @@ void NaviSetVideoConfigRequest::on_event(const event_engine::Event& event) {
}
}
}
+
+ application_manager_.OnStreamingConfigurationFailed(
+ app->app_id(),
+ rejected_params,
+ "Received SetVideoConfig failure response");
+
+ break;
}
- application_manager_.OnStreamingConfigured(
- app->app_id(),
- protocol_handler::ServiceType::kMobileNav,
- result,
- rejected_params);
- break;
}
default:
SDL_LOG_ERROR("Received unknown event " << event.id());
@@ -143,8 +143,10 @@ void NaviSetVideoConfigRequest::onTimeOut() {
}
std::vector<std::string> empty;
- application_manager_.OnStreamingConfigured(
- app->app_id(), protocol_handler::ServiceType::kMobileNav, false, empty);
+ application_manager_.OnStreamingConfigurationFailed(
+ app->app_id(),
+ empty,
+ "Timed out while waiting for SetVideoConfig response");
application_manager_.TerminateRequest(
connection_key(), correlation_id(), function_id());
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_set_video_config_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_set_video_config_request_test.cc
index d6ef540bc0..7ce3a353e9 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_set_video_config_request_test.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_set_video_config_request_test.cc
@@ -101,11 +101,9 @@ TEST_F(NaviSetVideoConfigRequestTest, OnEventWithSuccessResponse) {
Event event(kEventID);
event.set_smart_object(*event_msg);
- std::vector<std::string> empty;
- EXPECT_CALL(
- app_mngr_,
- OnStreamingConfigured(
- kAppId, protocol_handler::ServiceType::kMobileNav, true, empty))
+ EXPECT_CALL(app_mngr_,
+ OnStreamingConfigurationSuccessful(
+ kAppId, protocol_handler::ServiceType::kMobileNav))
.Times(1);
command->on_event(event);
@@ -151,10 +149,9 @@ TEST_F(NaviSetVideoConfigRequestTest, OnEventWithRejectedResponse) {
event.set_smart_object(*event_msg);
std::vector<std::string> rejected_params;
- EXPECT_CALL(app_mngr_,
- OnStreamingConfigured(
- kAppId, protocol_handler::ServiceType::kMobileNav, false, _))
- .WillOnce(SaveArg<3>(&rejected_params));
+ std::string reason("Received SetVideoConfig failure response");
+ EXPECT_CALL(app_mngr_, OnStreamingConfigurationFailed(kAppId, _, reason))
+ .WillOnce(SaveArg<1>(&rejected_params));
command->on_event(event);
@@ -181,10 +178,8 @@ TEST_F(NaviSetVideoConfigRequestTest,
event.set_smart_object(*event_msg);
std::vector<std::string> empty;
- EXPECT_CALL(
- app_mngr_,
- OnStreamingConfigured(
- kAppId, protocol_handler::ServiceType::kMobileNav, false, empty))
+ std::string reason("Received SetVideoConfig failure response");
+ EXPECT_CALL(app_mngr_, OnStreamingConfigurationFailed(kAppId, empty, reason))
.WillOnce(Return());
command->on_event(event);
@@ -198,10 +193,8 @@ TEST_F(NaviSetVideoConfigRequestTest, OnTimeout) {
CreateCommand<NaviSetVideoConfigRequest>(request_msg);
std::vector<std::string> empty;
- EXPECT_CALL(
- app_mngr_,
- OnStreamingConfigured(
- kAppId, protocol_handler::ServiceType::kMobileNav, false, empty))
+ std::string reason("Timed out while waiting for SetVideoConfig response");
+ EXPECT_CALL(app_mngr_, OnStreamingConfigurationFailed(kAppId, empty, reason))
.WillOnce(Return());
EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _)).Times(1);
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index ff22480cd5..26557163d0 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -1926,7 +1926,7 @@ bool ApplicationManagerImpl::StartNaviService(
}
if (!rejected_params.empty()) {
- OnStreamingConfigured(app_id, service_type, false, rejected_params);
+ OnStreamingConfigurationFailed(app_id, rejected_params, std::string());
return false;
} else if (!converted_params.empty()) {
SDL_LOG_INFO("Sending video configuration params");
@@ -1939,78 +1939,82 @@ bool ApplicationManagerImpl::StartNaviService(
}
}
// no configuration is needed, or SetVideoConfig is not sent
- std::vector<std::string> empty;
- OnStreamingConfigured(app_id, service_type, true, empty);
+ OnStreamingConfigurationSuccessful(app_id, service_type);
return true;
-
- } else {
- SDL_LOG_WARN("Refused navi service by HMI level");
}
+ SDL_LOG_WARN("Refused navi service by HMI level");
std::vector<std::string> empty;
- OnStreamingConfigured(app_id, service_type, false, empty);
+ OnStreamingConfigurationFailed(
+ app_id,
+ empty,
+ "Service type: " + std::to_string(service_type) +
+ " disallowed with current HMI level");
return false;
}
-void ApplicationManagerImpl::OnStreamingConfigured(
- uint32_t app_id,
- protocol_handler::ServiceType service_type,
- bool result,
- std::vector<std::string>& rejected_params) {
- using namespace protocol_handler;
+void ApplicationManagerImpl::OnStreamingConfigurationSuccessful(
+ uint32_t app_id, protocol_handler::ServiceType service_type) {
SDL_LOG_AUTO_TRACE();
- SDL_LOG_INFO("OnStreamingConfigured called for service "
- << service_type << ", result=" << result);
-
- if (result) {
- std::vector<std::string> empty;
- {
- sync_primitives::AutoLock lock(navi_service_status_lock_);
+ SDL_LOG_INFO("Streaming configuration successful for service "
+ << service_type);
+ std::vector<std::string> empty;
+ std::string reason;
+ {
+ sync_primitives::AutoLock lock(navi_service_status_lock_);
- NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id);
- if (navi_service_status_.end() == it) {
- SDL_LOG_WARN("Application not found in navi status map");
- connection_handler().NotifyServiceStartedResult(app_id, false, empty);
- return;
- }
+ NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id);
+ if (navi_service_status_.end() == it) {
+ SDL_LOG_WARN("Application not found in navi status map");
+ connection_handler().NotifyServiceStartedResult(
+ app_id, false, empty, reason);
+ return;
+ }
- // Fill NaviServices map. Set true to first value of pair if
- // we've started video service or to second value if we've
- // started audio service
- service_type == ServiceType::kMobileNav ? it->second.first = true
- : it->second.second = true;
+ // Fill NaviServices map. Set true to first value of pair if
+ // we've started video service or to second value if we've
+ // started audio service
+ service_type == protocol_handler::ServiceType::kMobileNav
+ ? it->second.first = true
+ : it->second.second = true;
- {
- sync_primitives::AutoLock lock(navi_app_to_stop_lock_);
- for (size_t i = 0; i < navi_app_to_stop_.size(); ++i) {
- if (app_id == navi_app_to_stop_[i]) {
- sync_primitives::AutoLock lock(close_app_timer_pool_lock_);
- close_app_timer_pool_.erase(close_app_timer_pool_.begin() + i);
- navi_app_to_stop_.erase(navi_app_to_stop_.begin() + i);
- break;
- }
+ {
+ sync_primitives::AutoLock lock(navi_app_to_stop_lock_);
+ for (size_t i = 0; i < navi_app_to_stop_.size(); ++i) {
+ if (app_id == navi_app_to_stop_[i]) {
+ sync_primitives::AutoLock lock(close_app_timer_pool_lock_);
+ close_app_timer_pool_.erase(close_app_timer_pool_.begin() + i);
+ navi_app_to_stop_.erase(navi_app_to_stop_.begin() + i);
+ break;
}
}
}
+ }
- application(app_id)->StartStreaming(service_type);
- connection_handler().NotifyServiceStartedResult(app_id, true, empty);
+ application(app_id)->StartStreaming(service_type);
+ connection_handler().NotifyServiceStartedResult(app_id, true, empty, reason);
- // Fix: For wifi Secondary
- // Should erase appid from deque of ForbidStreaming() push in the last time
- std::deque<uint32_t>::const_iterator iter = std::find(
- navi_app_to_end_stream_.begin(), navi_app_to_end_stream_.end(), app_id);
- if (navi_app_to_end_stream_.end() != iter) {
- navi_app_to_end_stream_.erase(iter);
- }
- } else {
- std::vector<std::string> converted_params =
- ConvertRejectedParamList(rejected_params);
- connection_handler().NotifyServiceStartedResult(
- app_id, false, converted_params);
+ // Fix: For wifi Secondary
+ // Should erase appid from deque of ForbidStreaming() push in the last time
+ std::deque<uint32_t>::const_iterator iter = std::find(
+ navi_app_to_end_stream_.begin(), navi_app_to_end_stream_.end(), app_id);
+ if (navi_app_to_end_stream_.end() != iter) {
+ navi_app_to_end_stream_.erase(iter);
}
}
+void ApplicationManagerImpl::OnStreamingConfigurationFailed(
+ uint32_t app_id,
+ std::vector<std::string>& rejected_params,
+ const std::string& reason) {
+ SDL_LOG_AUTO_TRACE();
+
+ std::vector<std::string> converted_params =
+ ConvertRejectedParamList(rejected_params);
+ connection_handler().NotifyServiceStartedResult(
+ app_id, false, converted_params, reason);
+}
+
void ApplicationManagerImpl::StopNaviService(
uint32_t app_id, protocol_handler::ServiceType service_type) {
using namespace protocol_handler;
@@ -2083,17 +2087,18 @@ void ApplicationManagerImpl::OnServiceStartedCallback(
SDL_LOG_DEBUG("ServiceType = " << type << ". Session = " << std::hex
<< session_key);
std::vector<std::string> empty;
+ std::string reason;
if (kRpc == type) {
SDL_LOG_DEBUG("RPC service is about to be started.");
- connection_handler().NotifyServiceStartedResult(session_key, true, empty);
+ connection_handler().NotifyServiceStartedResult(
+ session_key, true, empty, reason);
return;
}
ApplicationSharedPtr app = application(session_key);
if (!app) {
SDL_LOG_WARN("The application with id:" << session_key
<< " doesn't exists.");
- connection_handler().NotifyServiceStartedResult(session_key, false, empty);
return;
}
@@ -2106,12 +2111,15 @@ void ApplicationManagerImpl::OnServiceStartedCallback(
return;
} else {
SDL_LOG_WARN("Refuse not navi/projection application");
+ reason = "Service type: " + std::to_string(type) +
+ " disallowed with current HMI type";
}
} else {
SDL_LOG_WARN("Refuse unknown service");
}
- connection_handler().NotifyServiceStartedResult(session_key, false, empty);
+ connection_handler().NotifyServiceStartedResult(
+ session_key, false, empty, reason);
}
void ApplicationManagerImpl::OnServiceEndedCallback(
diff --git a/src/components/application_manager/test/application_manager_impl_test.cc b/src/components/application_manager/test/application_manager_impl_test.cc
index 78bd956316..cf8aadb080 100644
--- a/src/components/application_manager/test/application_manager_impl_test.cc
+++ b/src/components/application_manager/test/application_manager_impl_test.cc
@@ -94,9 +94,14 @@ using test::components::policy_test::MockPolicyHandlerInterface;
using namespace application_manager;
-// custom action to call a member function with 4 arguments
-ACTION_P6(InvokeMemberFuncWithArg4, ptr, memberFunc, a, b, c, d) {
- (ptr->*memberFunc)(a, b, c, d);
+// custom action to call a member function with 2 arguments
+ACTION_P4(InvokeMemberFuncWithArg2, ptr, memberFunc, a, b) {
+ (ptr->*memberFunc)(a, b);
+}
+
+// custom action to call a member function with 3 arguments
+ACTION_P5(InvokeMemberFuncWithArg3, ptr, memberFunc, a, b, c) {
+ (ptr->*memberFunc)(a, b, c);
}
namespace {
@@ -541,7 +546,7 @@ TEST_F(ApplicationManagerImplTest, OnServiceStartedCallback_RpcService) {
bool result = false;
std::vector<std::string> rejected_params;
- EXPECT_CALL(mock_connection_handler_, NotifyServiceStartedResult(_, _, _))
+ EXPECT_CALL(mock_connection_handler_, NotifyServiceStartedResult(_, _, _, _))
.WillOnce(DoAll(SaveArg<1>(&result), SaveArg<2>(&rejected_params)));
app_manager_impl_->OnServiceStartedCallback(
@@ -552,28 +557,6 @@ TEST_F(ApplicationManagerImplTest, OnServiceStartedCallback_RpcService) {
EXPECT_TRUE(rejected_params.empty());
}
-TEST_F(ApplicationManagerImplTest, OnServiceStartedCallback_UnknownApp) {
- AddMockApplication();
-
- const connection_handler::DeviceHandle device_handle = 0;
- const protocol_handler::ServiceType service_type =
- protocol_handler::ServiceType::kInvalidServiceType;
- const int32_t session_key = 123;
- EXPECT_CALL(*mock_app_ptr_, app_id()).WillRepeatedly(Return(456));
-
- bool result = false;
- std::vector<std::string> rejected_params;
- EXPECT_CALL(mock_connection_handler_, NotifyServiceStartedResult(_, _, _))
- .WillOnce(DoAll(SaveArg<1>(&result), SaveArg<2>(&rejected_params)));
-
- app_manager_impl_->OnServiceStartedCallback(
- device_handle, session_key, service_type, NULL);
-
- // check: return value is false and list is empty
- EXPECT_FALSE(result);
- EXPECT_TRUE(rejected_params.empty());
-}
-
TEST_F(ApplicationManagerImplTest, OnServiceStartedCallback_UnknownService) {
AddMockApplication();
@@ -585,7 +568,7 @@ TEST_F(ApplicationManagerImplTest, OnServiceStartedCallback_UnknownService) {
bool result = false;
std::vector<std::string> rejected_params;
- EXPECT_CALL(mock_connection_handler_, NotifyServiceStartedResult(_, _, _))
+ EXPECT_CALL(mock_connection_handler_, NotifyServiceStartedResult(_, _, _, _))
.WillOnce(DoAll(SaveArg<1>(&result), SaveArg<2>(&rejected_params)));
app_manager_impl_->OnServiceStartedCallback(
@@ -616,7 +599,7 @@ TEST_F(ApplicationManagerImplTest, OnServiceStartedCallback_VideoServiceStart) {
bool result = false;
std::vector<std::string> rejected_params;
- EXPECT_CALL(mock_connection_handler_, NotifyServiceStartedResult(_, _, _))
+ EXPECT_CALL(mock_connection_handler_, NotifyServiceStartedResult(_, _, _, _))
.WillOnce(DoAll(SaveArg<1>(&result), SaveArg<2>(&rejected_params)));
// check: SetVideoConfig() should not be called, StartStreaming() is called
@@ -647,7 +630,7 @@ TEST_F(ApplicationManagerImplTest,
bool result = false;
std::vector<std::string> rejected_params;
- EXPECT_CALL(mock_connection_handler_, NotifyServiceStartedResult(_, _, _))
+ EXPECT_CALL(mock_connection_handler_, NotifyServiceStartedResult(_, _, _, _))
.WillOnce(DoAll(SaveArg<1>(&result), SaveArg<2>(&rejected_params)));
// check: SetVideoConfig() and StartStreaming() should not be called
@@ -684,7 +667,7 @@ TEST_F(ApplicationManagerImplTest,
bool result = false;
std::vector<std::string> rejected_params;
- EXPECT_CALL(mock_connection_handler_, NotifyServiceStartedResult(_, _, _))
+ EXPECT_CALL(mock_connection_handler_, NotifyServiceStartedResult(_, _, _, _))
.WillOnce(DoAll(SaveArg<1>(&result), SaveArg<2>(&rejected_params)));
// check: SetVideoConfig() and StartStreaming() should not be called
@@ -720,7 +703,7 @@ TEST_F(ApplicationManagerImplTest,
bool result = false;
std::vector<std::string> rejected_params;
- EXPECT_CALL(mock_connection_handler_, NotifyServiceStartedResult(_, _, _))
+ EXPECT_CALL(mock_connection_handler_, NotifyServiceStartedResult(_, _, _, _))
.WillOnce(DoAll(SaveArg<1>(&result), SaveArg<2>(&rejected_params)));
BsonObject input_params;
@@ -746,18 +729,15 @@ TEST_F(ApplicationManagerImplTest,
converted_params[strings::height] = 640;
converted_params[strings::width] = 480;
- std::vector<std::string> empty;
-
// check: SetVideoConfig() and StartStreaming() are called
EXPECT_CALL(*mock_app_ptr_, SetVideoConfig(service_type, converted_params))
- .WillOnce(DoAll(InvokeMemberFuncWithArg4(
- app_manager_impl_.get(),
- &ApplicationManagerImpl::OnStreamingConfigured,
- session_key,
- service_type,
- true,
- ByRef(empty)),
- Return(true)));
+ .WillOnce(
+ DoAll(InvokeMemberFuncWithArg2(
+ app_manager_impl_.get(),
+ &ApplicationManagerImpl::OnStreamingConfigurationSuccessful,
+ session_key,
+ service_type),
+ Return(true)));
EXPECT_CALL(*mock_app_ptr_, StartStreaming(service_type)).WillOnce(Return());
app_manager_impl_->OnServiceStartedCallback(
@@ -809,7 +789,7 @@ TEST_F(ApplicationManagerImplTest,
bool result = false;
std::vector<std::string> rejected_params;
- EXPECT_CALL(mock_connection_handler_, NotifyServiceStartedResult(_, _, _))
+ EXPECT_CALL(mock_connection_handler_, NotifyServiceStartedResult(_, _, _, _))
.WillOnce(DoAll(SaveArg<1>(&result), SaveArg<2>(&rejected_params)));
BsonObject input_params;
@@ -838,17 +818,18 @@ TEST_F(ApplicationManagerImplTest,
std::vector<std::string> rejected_list;
rejected_list.push_back(std::string("protocol"));
rejected_list.push_back(std::string("codec"));
+ std::string reason;
// simulate HMI returning negative response
EXPECT_CALL(*mock_app_ptr_, SetVideoConfig(service_type, converted_params))
- .WillOnce(DoAll(InvokeMemberFuncWithArg4(
- app_manager_impl_.get(),
- &ApplicationManagerImpl::OnStreamingConfigured,
- session_key,
- service_type,
- false,
- ByRef(rejected_list)),
- Return(true)));
+ .WillOnce(
+ DoAll(InvokeMemberFuncWithArg3(
+ app_manager_impl_.get(),
+ &ApplicationManagerImpl::OnStreamingConfigurationFailed,
+ session_key,
+ ByRef(rejected_list),
+ ByRef(reason)),
+ Return(true)));
// check: StartStreaming() should not be called
EXPECT_CALL(*mock_app_ptr_, StartStreaming(service_type)).Times(0);
@@ -888,7 +869,7 @@ TEST_F(ApplicationManagerImplTest,
bool result = false;
std::vector<std::string> rejected_params;
- EXPECT_CALL(mock_connection_handler_, NotifyServiceStartedResult(_, _, _))
+ EXPECT_CALL(mock_connection_handler_, NotifyServiceStartedResult(_, _, _, _))
.WillOnce(DoAll(SaveArg<1>(&result), SaveArg<2>(&rejected_params)));
BsonObject input_params;
@@ -928,7 +909,7 @@ TEST_F(ApplicationManagerImplTest, OnServiceStartedCallback_AudioServiceStart) {
bool result = false;
std::vector<std::string> rejected_params;
- EXPECT_CALL(mock_connection_handler_, NotifyServiceStartedResult(_, _, _))
+ EXPECT_CALL(mock_connection_handler_, NotifyServiceStartedResult(_, _, _, _))
.WillOnce(DoAll(SaveArg<1>(&result), SaveArg<2>(&rejected_params)));
// check: SetVideoConfig() should not be called, StartStreaming() is called
@@ -963,7 +944,7 @@ TEST_F(ApplicationManagerImplTest,
bool result = false;
std::vector<std::string> rejected_params;
- EXPECT_CALL(mock_connection_handler_, NotifyServiceStartedResult(_, _, _))
+ EXPECT_CALL(mock_connection_handler_, NotifyServiceStartedResult(_, _, _, _))
.WillOnce(DoAll(SaveArg<1>(&result), SaveArg<2>(&rejected_params)));
BsonObject input_params;
diff --git a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h
index fb859330b9..08b64ec9b8 100644
--- a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h
+++ b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h
@@ -606,10 +606,10 @@ class ConnectionHandlerImpl
* \note This is invoked only once but can be invoked by multiple threads.
* Also it can be invoked before OnServiceStartedCallback() returns.
**/
- virtual void NotifyServiceStartedResult(
- uint32_t session_key,
- bool result,
- std::vector<std::string>& rejected_params);
+ void NotifyServiceStartedResult(uint32_t session_key,
+ bool result,
+ std::vector<std::string>& rejected_params,
+ const std::string& reason) OVERRIDE;
/**
* \brief Called when secondary transport with given session ID is established
diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc
index 8cefa390e8..e3ab3db324 100644
--- a/src/components/connection_handler/src/connection_handler_impl.cc
+++ b/src/components/connection_handler/src/connection_handler_impl.cc
@@ -520,7 +520,7 @@ void ConnectionHandlerImpl::OnSessionStartedCallback(
context,
rejected_params,
"Cannot start " +
- std::string(is_protected ? "a protected" : " an unprotected") +
+ std::string(is_protected ? "a protected" : "an unprotected") +
" service of type " + std::to_string(service_type) + ". " +
err_reason);
return;
@@ -558,7 +558,8 @@ void ConnectionHandlerImpl::OnSessionStartedCallback(
void ConnectionHandlerImpl::NotifyServiceStartedResult(
uint32_t session_key,
bool result,
- std::vector<std::string>& rejected_params) {
+ std::vector<std::string>& rejected_params,
+ const std::string& reason) {
SDL_LOG_AUTO_TRACE();
protocol_handler::SessionContext context;
@@ -599,7 +600,7 @@ void ConnectionHandlerImpl::NotifyServiceStartedResult(
}
if (protocol_handler_ != NULL) {
- protocol_handler_->NotifySessionStarted(context, rejected_params);
+ protocol_handler_->NotifySessionStarted(context, rejected_params, reason);
}
}
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 5a8feda2db..3fbdf62474 100644
--- a/src/components/connection_handler/test/connection_handler_impl_test.cc
+++ b/src/components/connection_handler/test/connection_handler_impl_test.cc
@@ -65,9 +65,9 @@ using ::testing::ReturnRefOfCopy;
using ::testing::SaveArg;
using ::testing::SaveArgPointee;
-// custom action to call a member function with 3 arguments
-ACTION_P5(InvokeMemberFuncWithArg3, ptr, memberFunc, a, b, c) {
- (ptr->*memberFunc)(a, b, c);
+// custom action to call a member function with 4 arguments
+ACTION_P6(InvokeMemberFuncWithArg4, ptr, memberFunc, a, b, c, d) {
+ (ptr->*memberFunc)(a, b, c, d);
}
namespace {
@@ -1307,16 +1307,18 @@ TEST_F(ConnectionHandlerTest, SessionStarted_WithRpc) {
connection_handler_->set_connection_handler_observer(
&mock_connection_handler_observer);
std::vector<std::string> empty;
+ std::string reason;
uint32_t session_key =
connection_handler_->KeyFromPair(uid_, out_context_.initial_session_id_);
EXPECT_CALL(mock_connection_handler_observer,
OnServiceStartedCallback(device_handle_, _, kRpc, NULL))
- .WillOnce(InvokeMemberFuncWithArg3(
+ .WillOnce(InvokeMemberFuncWithArg4(
connection_handler_,
&ConnectionHandler::NotifyServiceStartedResult,
session_key,
true,
- ByRef(empty)));
+ ByRef(empty),
+ reason));
connection_handler_->set_protocol_handler(&mock_protocol_handler_);
EXPECT_CALL(mock_protocol_handler_, NotifySessionStarted(_, _, _))
@@ -1345,15 +1347,17 @@ TEST_F(ConnectionHandlerTest, ServiceStarted_Video_SUCCESS) {
uint32_t session_key =
connection_handler_->KeyFromPair(uid_, out_context_.new_session_id_);
std::vector<std::string> empty;
+ std::string reason;
EXPECT_CALL(mock_connection_handler_observer,
OnServiceStartedCallback(
device_handle_, session_key, kMobileNav, dummy_params))
- .WillOnce(InvokeMemberFuncWithArg3(
+ .WillOnce(InvokeMemberFuncWithArg4(
connection_handler_,
&ConnectionHandler::NotifyServiceStartedResult,
session_key,
true,
- ByRef(empty)));
+ ByRef(empty),
+ reason));
// confirm that NotifySessionStarted() is called
connection_handler_->set_protocol_handler(&mock_protocol_handler_);
@@ -1385,15 +1389,17 @@ TEST_F(ConnectionHandlerTest, ServiceStarted_Video_FAILURE) {
uint32_t session_key =
connection_handler_->KeyFromPair(uid_, out_context_.new_session_id_);
std::vector<std::string> empty;
+ std::string reason;
EXPECT_CALL(mock_connection_handler_observer,
OnServiceStartedCallback(
device_handle_, session_key, kMobileNav, dummy_params))
- .WillOnce(InvokeMemberFuncWithArg3(
+ .WillOnce(InvokeMemberFuncWithArg4(
connection_handler_,
&ConnectionHandler::NotifyServiceStartedResult,
session_key,
false,
- ByRef(empty)));
+ ByRef(empty),
+ reason));
// confirm that NotifySessionStarted() is called
connection_handler_->set_protocol_handler(&mock_protocol_handler_);
@@ -1455,6 +1461,8 @@ TEST_F(ConnectionHandlerTest, ServiceStarted_Video_Multiple) {
connection_handler_->KeyFromPair(uid_, context_second.new_session_id_);
std::vector<std::string> empty;
+ std::string reason;
+
ChangeProtocol(uid_,
context_first.new_session_id_,
protocol_handler::PROTOCOL_VERSION_3);
@@ -1472,18 +1480,20 @@ TEST_F(ConnectionHandlerTest, ServiceStarted_Video_Multiple) {
device_handle_, session_key2, kMobileNav, dummy_params))
// call NotifyServiceStartedResult() twice, first for the second session
// then for the first session
- .WillOnce(DoAll(InvokeMemberFuncWithArg3(
+ .WillOnce(DoAll(InvokeMemberFuncWithArg4(
connection_handler_,
&ConnectionHandler::NotifyServiceStartedResult,
session_key2,
false,
- ByRef(empty)),
- InvokeMemberFuncWithArg3(
+ ByRef(empty),
+ reason),
+ InvokeMemberFuncWithArg4(
connection_handler_,
&ConnectionHandler::NotifyServiceStartedResult,
session_key1,
true,
- ByRef(empty))));
+ ByRef(empty),
+ reason)));
// verify that connection handler will not mix up the two results
SessionContext new_context_first, new_context_second;
diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h
index bc7d90e02e..67f23956be 100644
--- a/src/components/include/application_manager/application_manager.h
+++ b/src/components/include/application_manager/application_manager.h
@@ -873,18 +873,24 @@ class ApplicationManager {
protocol_handler::ServiceType service_type) = 0;
/**
- * @brief Called when application completes streaming configuration
+ * @brief Called when application successfully completes streaming
+ * configuration
* @param app_id Streaming application id
* @param service_type Streaming service type
- * @param result true if configuration is successful, false otherwise
- * @param rejected_params list of rejected parameters' name. Valid
- * only when result is false.
*/
- virtual void OnStreamingConfigured(
+ virtual void OnStreamingConfigurationSuccessful(
+ uint32_t app_id, protocol_handler::ServiceType service_type) = 0;
+
+ /**
+ * @brief Called when application fails streaming configuration
+ * @param app_id Streaming application id
+ * @param rejected_params list of rejected parameter names
+ * @param reason NACK reason
+ */
+ virtual void OnStreamingConfigurationFailed(
uint32_t app_id,
- protocol_handler::ServiceType service_type,
- bool result,
- std::vector<std::string>& rejected_params) = 0;
+ std::vector<std::string>& rejected_params,
+ const std::string& reason) = 0;
virtual const ApplicationManagerSettings& get_settings() const = 0;
// Extract the app ID to use internally based on the UseFullAppID .ini setting
diff --git a/src/components/include/connection_handler/connection_handler.h b/src/components/include/connection_handler/connection_handler.h
index de78024e61..c5f8c175e6 100644
--- a/src/components/include/connection_handler/connection_handler.h
+++ b/src/components/include/connection_handler/connection_handler.h
@@ -297,7 +297,8 @@ class ConnectionHandler {
virtual void NotifyServiceStartedResult(
uint32_t session_key,
bool result,
- std::vector<std::string>& rejected_params) = 0;
+ std::vector<std::string>& rejected_params,
+ const std::string& reason) = 0;
/**
* \brief Called when secondary transport with given session ID is established
diff --git a/src/components/include/protocol_handler/protocol_handler.h b/src/components/include/protocol_handler/protocol_handler.h
index bb596631a0..c7ee670972 100644
--- a/src/components/include/protocol_handler/protocol_handler.h
+++ b/src/components/include/protocol_handler/protocol_handler.h
@@ -134,6 +134,8 @@ class ProtocolHandler {
* @param rejected_params list of parameters name that are rejected.
* Only valid when generated_session_id is 0. Note, even if
* generated_session_id is 0, the list may be empty.
+ * @param err_reason string with NACK reason. Only valid when
+ * generated_session_id is 0.
*/
virtual void NotifySessionStarted(
const SessionContext& context,
diff --git a/src/components/include/test/application_manager/mock_application_manager.h b/src/components/include/test/application_manager/mock_application_manager.h
index a85a651f80..ee5d7f315a 100644
--- a/src/components/include/test/application_manager/mock_application_manager.h
+++ b/src/components/include/test/application_manager/mock_application_manager.h
@@ -377,11 +377,13 @@ class MockApplicationManager : public application_manager::ApplicationManager {
MOCK_METHOD0(OnTimerSendTTSGlobalProperties, void());
MOCK_METHOD0(OnLowVoltage, void());
MOCK_METHOD0(OnWakeUp, void());
- MOCK_METHOD4(OnStreamingConfigured,
+ MOCK_METHOD2(OnStreamingConfigurationSuccessful,
void(uint32_t app_id,
- protocol_handler::ServiceType service_type,
- bool result,
- std::vector<std::string>& rejected_params));
+ protocol_handler::ServiceType service_type));
+ MOCK_METHOD3(OnStreamingConfigurationFailed,
+ void(uint32_t app_id,
+ std::vector<std::string>& rejected_params,
+ const std::string& reason));
MOCK_METHOD2(ProcessReconnection,
void(application_manager::ApplicationSharedPtr application,
const uint32_t connection_key));
diff --git a/src/components/include/test/connection_handler/mock_connection_handler.h b/src/components/include/test/connection_handler/mock_connection_handler.h
index d44dd94ddd..bf266751d4 100644
--- a/src/components/include/test/connection_handler/mock_connection_handler.h
+++ b/src/components/include/test/connection_handler/mock_connection_handler.h
@@ -123,10 +123,11 @@ class MockConnectionHandler : public connection_handler::ConnectionHandler {
transport_manager::ConnectionUID secondary_transport_id));
MOCK_CONST_METHOD1(GetSessionTransports,
const SessionTransports(uint8_t session_id));
- MOCK_METHOD3(NotifyServiceStartedResult,
+ MOCK_METHOD4(NotifyServiceStartedResult,
void(uint32_t session_key,
bool result,
- std::vector<std::string>& rejected_params));
+ std::vector<std::string>& rejected_params,
+ const std::string& reason));
MOCK_METHOD3(
OnSecondaryTransportStarted,
bool(transport_manager::ConnectionUID& primary_connection_handle,
diff --git a/src/components/include/test/protocol_handler/mock_protocol_handler.h b/src/components/include/test/protocol_handler/mock_protocol_handler.h
index e3a52157ec..94a9efd9e5 100644
--- a/src/components/include/test/protocol_handler/mock_protocol_handler.h
+++ b/src/components/include/test/protocol_handler/mock_protocol_handler.h
@@ -64,9 +64,6 @@ class MockProtocolHandler : public ::protocol_handler::ProtocolHandler {
MOCK_CONST_METHOD0(get_settings,
const ::protocol_handler::ProtocolHandlerSettings&());
MOCK_METHOD0(get_session_observer, protocol_handler::SessionObserver&());
- MOCK_METHOD2(NotifySessionStarted,
- void(const ::protocol_handler::SessionContext& context,
- std::vector<std::string>& rejected_params));
MOCK_METHOD3(NotifySessionStarted,
void(const ::protocol_handler::SessionContext& context,
std::vector<std::string>& rejected_params,
diff --git a/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h b/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h
index ead997da69..33abd4a96b 100644
--- a/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h
+++ b/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h
@@ -379,7 +379,7 @@ class ProtocolHandlerImpl
uint8_t session_id,
uint8_t protocol_version,
uint8_t service_type,
- const std::string reason);
+ const std::string& reason);
/**
* \brief Sends fail of starting session to mobile application
@@ -395,7 +395,7 @@ class ProtocolHandlerImpl
uint8_t protocol_version,
uint8_t service_type,
std::vector<std::string>& rejectedParams,
- const std::string reason);
+ const std::string& reason);
/**
* \brief Sends acknowledgement of end session/service to mobile application
diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc
index dc710549cd..36e98e723c 100644
--- a/src/components/protocol_handler/src/protocol_handler_impl.cc
+++ b/src/components/protocol_handler/src/protocol_handler_impl.cc
@@ -451,7 +451,7 @@ void ProtocolHandlerImpl::SendStartSessionNAck(ConnectionID connection_id,
uint8_t session_id,
uint8_t protocol_version,
uint8_t service_type,
- const std::string reason) {
+ const std::string& reason) {
std::vector<std::string> rejectedParams;
SendStartSessionNAck(connection_id,
session_id,
@@ -467,7 +467,7 @@ void ProtocolHandlerImpl::SendStartSessionNAck(
uint8_t protocol_version,
uint8_t service_type,
std::vector<std::string>& rejectedParams,
- const std::string reason) {
+ const std::string& reason) {
SDL_LOG_AUTO_TRACE();
ProtocolFramePtr ptr(
@@ -1736,12 +1736,18 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessageStartSession(
<< service_type << ", disallowed by settings.");
service_status_update_handler_->OnServiceUpdate(
connection_key, service_type, settings_check);
- SendStartSessionNAck(connection_id,
- session_id,
- protocol_version,
- service_type,
- "Service type: " + std::to_string(service_type) +
- " disallowed by settings");
+
+ std::string reason("Service type: " + std::to_string(service_type) +
+ " disallowed by settings.");
+ if (ServiceStatus::PROTECTION_ENFORCED == settings_check) {
+ reason += " Allowed only in protected mode";
+ }
+ if (ServiceStatus::UNSECURE_START_FAILED == settings_check) {
+ reason += " Allowed only in unprotected mode";
+ }
+
+ SendStartSessionNAck(
+ connection_id, session_id, protocol_version, service_type, reason);
return RESULT_OK;
}
diff --git a/src/components/protocol_handler/test/protocol_handler_tm_test.cc b/src/components/protocol_handler/test/protocol_handler_tm_test.cc
index d5d68d9b83..6edb77d0cd 100644
--- a/src/components/protocol_handler/test/protocol_handler_tm_test.cc
+++ b/src/components/protocol_handler/test/protocol_handler_tm_test.cc
@@ -3954,7 +3954,7 @@ TEST_F(ProtocolHandlerImplTest, StartSession_NACKReason_DisallowedBySettings) {
bson_object_initialize_default(&bson_nack_params);
// NAK reason param
std::string reason = "Service type: " + std::to_string(service_type) +
- " disallowed by settings";
+ " disallowed by settings.";
bson_object_put_string(&bson_nack_params,
protocol_handler::strings::reason,
const_cast<char*>(reason.c_str()));