From b232e7d4d206fb19944c92173fcf35c765adf347 Mon Sep 17 00:00:00 2001 From: igapchuck Date: Thu, 22 Nov 2018 17:15:33 +0200 Subject: [PATCH] Fix subscribing on event. We need subscribe on ActivateAppResponse event, not on CloseApplicationRequest. --- src/appMain/sdl_preloaded_pt.json | 3 +- .../mobile/close_application_request.h | 13 ++---- .../mobile/close_application_request.cc | 45 +++++++------------ 3 files changed, 22 insertions(+), 39 deletions(-) diff --git a/src/appMain/sdl_preloaded_pt.json b/src/appMain/sdl_preloaded_pt.json index a19444f1891..77104ae56e0 100644 --- a/src/appMain/sdl_preloaded_pt.json +++ b/src/appMain/sdl_preloaded_pt.json @@ -61,7 +61,8 @@ "CloseApplication": { "hmi_levels": ["BACKGROUND", "FULL", - "LIMITED"] + "LIMITED", + "NONE"] }, "CreateInteractionChoiceSet": { "hmi_levels": ["BACKGROUND", diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/close_application_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/close_application_request.h index b630f75c22f..8d8545763a4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/close_application_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/close_application_request.h @@ -87,19 +87,14 @@ class CloseApplicationRequest : public app_mngr::commands::CommandRequestImpl { * @param hmi_level - New HMI level for specified application. * @param send_policy_priority - Defines whether to send "priority" field * with request + * @param activate_app_corr_id - Variable for detting ActivateAppRequest + * correlation id. * @return - True if command is executed, otherwise return false. */ bool SendBCActivateApp(app_mngr::ApplicationConstSharedPtr app, hmi_apis::Common_HMILevel::eType hmi_level, - bool send_policy_priority); - - /** - * @brief Send OnHMIStatus notification to mobile. - * @param app - Application to with will send OnHMIStatus. - * @param app_manager - Referance to Application Manager instance. - */ - void SendHMIStatusNotification(app_mngr::ApplicationConstSharedPtr app, - app_mngr::ApplicationManager& app_manager); + bool send_policy_priority, + uint32_t& activate_app_corr_id); }; } // namespace commands diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/close_application_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/close_application_request.cc index 0c04c34c303..195a9870c2b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/close_application_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/close_application_request.cc @@ -76,14 +76,13 @@ void CloseApplicationRequest::Run() { SendResponse(false, mobile_apis::Result::IGNORED); } - const bool sent_success = - SendBCActivateApp(application, hmi_apis::Common_HMILevel::NONE, true); + uint32_t activate_app_corr_id = 0; + const bool sent_success = SendBCActivateApp( + application, hmi_apis::Common_HMILevel::NONE, true, activate_app_corr_id); if (sent_success) { - const uint32_t corr_id = static_cast( - (*message_)[strings::params][strings::correlation_id].asUInt()); subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_ActivateApp, - corr_id); + activate_app_corr_id); } else { LOG4CXX_ERROR(logger_, "Unable to send BC.ActivateApp"); SendResponse(false, mobile_apis::Result::IGNORED); @@ -109,15 +108,17 @@ void CloseApplicationRequest::on_event(const event_engine::Event& event) { hmi_apis::Common_Result::SUCCESS, hmi_apis::Common_Result::WARNINGS); + auto application = application_manager_.application(connection_key()); if (success) { - auto application = application_manager_.application(connection_key()); application->set_hmi_level(mobile_apis::HMILevel::HMI_NONE); - SendHMIStatusNotification(application, application_manager_); LOG4CXX_DEBUG(logger_, - "OnHMIStatusNotification did send to Mobile with HMI_level: " - << application->hmi_level()); + "Application with id " << application->app_id() + << " has switched to HMI_level NONE."); } else { - LOG4CXX_WARN(logger_, "OnHMIStatusNotification didn't send to Mobile."); + LOG4CXX_WARN(logger_, + "Application with id " + << application->app_id() + << " hasn't switched to HMI_level NONE."); } SendResponse(success, mobile_result); } @@ -125,7 +126,8 @@ void CloseApplicationRequest::on_event(const event_engine::Event& event) { bool CloseApplicationRequest::SendBCActivateApp( ApplicationConstSharedPtr app, hmi_apis::Common_HMILevel::eType hmi_level, - bool send_policy_priority) { + bool send_policy_priority, + uint32_t& activate_app_corr_id) { LOG4CXX_AUTO_TRACE(logger_); smart_objects::SmartObjectSPtr bc_activate_app_request = MessageHelper::GetBCActivateAppRequestToHMI( @@ -145,26 +147,11 @@ bool CloseApplicationRequest::SendBCActivateApp( LOG4CXX_ERROR(logger_, "Unable to send BC.ActivateAppRequest"); return false; } + activate_app_corr_id = + (*bc_activate_app_request)[strings::params][strings::correlation_id] + .asUInt(); return true; } -void CloseApplicationRequest::SendHMIStatusNotification( - ApplicationConstSharedPtr app, ApplicationManager& app_manager) { - using namespace application_manager; - LOG4CXX_AUTO_TRACE(logger_); - - smart_objects::SmartObjectSPtr message = MessageHelper::CreateNotification( - mobile_apis::FunctionID::OnHMIStatusID, app->app_id()); - - (*message)[strings::msg_params][strings::hmi_level] = - static_cast(app->hmi_level()); - (*message)[strings::msg_params][strings::audio_streaming_state] = - static_cast(app->audio_streaming_state()); - (*message)[strings::msg_params][strings::system_context] = - static_cast(app->system_context()); - application_manager_.GetRPCService().ManageMobileCommand(message, - Command::SOURCE_SDL); -} - } // namespace commands } // namespace sdl_rpc_plugin