From 31041084b3ded5367a97060c081976e9e3251985 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Mon, 1 Apr 2019 16:24:58 -0400 Subject: Add timeout logic for HMI App Service Consumer RPCs --- .../include/application_manager/commands/request_from_hmi.h | 13 +++++++++---- .../commands/hmi/as_get_app_service_data_request_from_hmi.h | 5 +++++ .../as_perform_app_service_interaction_request_from_hmi.h | 5 +++++ .../hmi/as_get_app_service_data_request_from_hmi.cc | 12 ++++++++++++ .../as_perform_app_service_interaction_request_from_hmi.cc | 13 +++++++++++++ .../application_manager/src/commands/request_from_hmi.cc | 7 ++++--- 6 files changed, 48 insertions(+), 7 deletions(-) diff --git a/src/components/application_manager/include/application_manager/commands/request_from_hmi.h b/src/components/application_manager/include/application_manager/commands/request_from_hmi.h index a37e0a289e..4464056175 100644 --- a/src/components/application_manager/include/application_manager/commands/request_from_hmi.h +++ b/src/components/application_manager/include/application_manager/commands/request_from_hmi.h @@ -61,6 +61,8 @@ class RequestFromHMI : public CommandImpl, public event_engine::EventObserver { * @param correlation_id the correlation id for the rfesponse. * @param function_id the function id for which response will be sent * @param result_code the result code. + * @param response_params extra response params. + * @param source command source. */ void SendResponse( const bool success, @@ -76,11 +78,14 @@ class RequestFromHMI : public CommandImpl, public event_engine::EventObserver { * @param function_id the function id for which response will be sent * @param result_code the result code. * @param error_message info message for error. + * @param source command source. */ - void SendErrorResponse(const uint32_t correlation_id, - const hmi_apis::FunctionID::eType function_id, - const hmi_apis::Common_Result::eType result_code, - const std::string error_message); + void SendErrorResponse( + const uint32_t correlation_id, + const hmi_apis::FunctionID::eType function_id, + const hmi_apis::Common_Result::eType result_code, + const std::string error_message, + commands::Command::CommandSource source = commands::Command::SOURCE_HMI); void SendProviderRequest( const mobile_apis::FunctionID::eType& mobile_function_id, diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_data_request_from_hmi.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_data_request_from_hmi.h index 847b921502..7b175fc0d4 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_data_request_from_hmi.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_data_request_from_hmi.h @@ -68,6 +68,11 @@ class ASGetAppServiceDataRequestFromHMI **/ virtual void Run(); + /** + * @brief onTimeOut from request controller + */ + virtual void onTimeOut(); + /** * @brief on_event allows to handle events * diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_perform_app_service_interaction_request_from_hmi.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_perform_app_service_interaction_request_from_hmi.h index 775bb9f812..36acf116f4 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_perform_app_service_interaction_request_from_hmi.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_perform_app_service_interaction_request_from_hmi.h @@ -83,6 +83,11 @@ class ASPerformAppServiceInteractionRequestFromHMI */ void on_event(const app_mngr::event_engine::MobileEvent& event) OVERRIDE; + /** + * @brief onTimeOut from request controller + */ + virtual void onTimeOut(); + private: DISALLOW_COPY_AND_ASSIGN(ASPerformAppServiceInteractionRequestFromHMI); }; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_request_from_hmi.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_request_from_hmi.cc index 5cdbbfc012..a339ffb9a6 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_request_from_hmi.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_request_from_hmi.cc @@ -110,5 +110,17 @@ void ASGetAppServiceDataRequestFromHMI::on_event( application_manager::commands::Command::SOURCE_SDL_TO_HMI); } +void ASGetAppServiceDataRequestFromHMI::onTimeOut() { + LOG4CXX_AUTO_TRACE(logger_); + smart_objects::SmartObject response_params; + response_params[strings::info] = + "The provider did not respond to the request"; + SendErrorResponse(correlation_id(), + hmi_apis::FunctionID::AppService_GetAppServiceData, + hmi_apis::Common_Result::GENERIC_ERROR, + "The provider did not respond to the request", + application_manager::commands::Command::SOURCE_SDL_TO_HMI); +} + } // namespace commands } // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc index 70a5a10be0..1588845274 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc @@ -153,5 +153,18 @@ void ASPerformAppServiceInteractionRequestFromHMI::on_event( application_manager::commands::Command::SOURCE_SDL_TO_HMI); } +void ASPerformAppServiceInteractionRequestFromHMI::onTimeOut() { + LOG4CXX_AUTO_TRACE(logger_); + smart_objects::SmartObject response_params; + response_params[strings::info] = + "The provider did not respond to the request"; + SendErrorResponse( + correlation_id(), + hmi_apis::FunctionID::AppService_PerformAppServiceInteraction, + hmi_apis::Common_Result::GENERIC_ERROR, + "The provider did not respond to the request", + application_manager::commands::Command::SOURCE_SDL_TO_HMI); +} + } // namespace commands } // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/src/commands/request_from_hmi.cc b/src/components/application_manager/src/commands/request_from_hmi.cc index 5581f027c0..570bc6017d 100644 --- a/src/components/application_manager/src/commands/request_from_hmi.cc +++ b/src/components/application_manager/src/commands/request_from_hmi.cc @@ -89,7 +89,7 @@ void RequestFromHMI::SendResponse( smart_objects::SmartType_Map); FillCommonParametersOfSO(*message, correlation_id, function_id); (*message)[strings::params][strings::message_type] = MessageType::kResponse; - (*message)[strings::params][hmi_response::code] = 0; + (*message)[strings::params][hmi_response::code] = result_code; (*message)[strings::msg_params][strings::success] = success; (*message)[strings::msg_params][strings::result_code] = result_code; @@ -104,7 +104,8 @@ void RequestFromHMI::SendErrorResponse( const uint32_t correlation_id, const hmi_apis::FunctionID::eType function_id, const hmi_apis::Common_Result::eType result_code, - const std::string error_message) { + const std::string error_message, + commands::Command::CommandSource source) { smart_objects::SmartObjectSPtr message = std::make_shared( smart_objects::SmartType_Map); @@ -114,7 +115,7 @@ void RequestFromHMI::SendErrorResponse( (*message)[strings::params][hmi_response::code] = result_code; (*message)[strings::params][strings::error_msg] = error_message; - rpc_service_.ManageHMICommand(message); + rpc_service_.ManageHMICommand(message, source); } void RequestFromHMI::FillCommonParametersOfSO( -- cgit v1.2.1