diff options
author | Artem Nosach (GitHub) <ANosach@luxoft.com> | 2016-10-11 17:31:25 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-11 17:31:25 +0300 |
commit | bce24f3ee2211c27cd9c8dae4c6a7f76773a1aa2 (patch) | |
tree | 6133154b603b9ceb77b4c7740069af8f39f0fdc7 | |
parent | c665222e3729b6d213df9ffe146b6c4a62ff25d8 (diff) | |
parent | 10772ba87420736ca6db279d8dcf7d04b591f8bf (diff) | |
download | sdl_core-bce24f3ee2211c27cd9c8dae4c6a7f76773a1aa2.tar.gz |
Merge pull request #768 from dtrunov/feature/Navigation_interface_SDL_behavior_in_case_HMI_does_not_respond_to_IsReady_request_or_respond_with_available_false
Navigation interface sdl behavior in case hmi does not respond to is ready request or respond with available false
23 files changed, 196 insertions, 93 deletions
diff --git a/src/components/application_manager/include/application_manager/commands/command_request_impl.h b/src/components/application_manager/include/application_manager/commands/command_request_impl.h index 30859765ba..47ec32cc74 100644 --- a/src/components/application_manager/include/application_manager/commands/command_request_impl.h +++ b/src/components/application_manager/include/application_manager/commands/command_request_impl.h @@ -1,5 +1,5 @@ /* - Copyright (c) 2014, Ford Motor Company + Copyright (c) 2016, Ford Motor Company All rights reserved. Redistribution and use in source and binary forms, with or without @@ -85,6 +85,23 @@ namespace NsSmart = NsSmartDeviceLink::NsSmartObjects; std::string MergeInfos(const std::string& first, const std::string& second); /** + * @brief MergeInfos merge 2 infos into one string with info + * @param first_info -contains result_code from HMI response and + * interface that returns response + * @param first_str - info string that should be first in result info + * @param second_info -contains result_code from HMI response and + * interface that returns response + * @param second_str - info string that should be second in result info + * @return if first_info is not available and second_str not empty return second + * if second_info is not available and first_str not empty return first + * other cases return result MergeInfos for 2 params + */ +std::string MergeInfos(const ResponseInfo& first_info, + const std::string& first_str, + const ResponseInfo& second_info, + const std::string& second_str); + +/** * @brief MergeInfos merge 3 infos in one string * @param first - info string that should be first in result info * @param second - info string that should be second in result info @@ -223,6 +240,7 @@ class CommandRequestImpl : public CommandImpl, */ bool PrepareResultForMobileResponse(ResponseInfo& out_first, ResponseInfo& out_second) const; + /** * @brief If message from HMI contains returns this info * or process result code from HMI and checks state of interface diff --git a/src/components/application_manager/include/application_manager/commands/hmi/navi_is_ready_request.h b/src/components/application_manager/include/application_manager/commands/hmi/navi_is_ready_request.h index 9f1adaeee0..77ce48a2cc 100644 --- a/src/components/application_manager/include/application_manager/commands/hmi/navi_is_ready_request.h +++ b/src/components/application_manager/include/application_manager/commands/hmi/navi_is_ready_request.h @@ -42,7 +42,8 @@ namespace commands { /** * @brief NaviIsReadyRequest command class **/ -class NaviIsReadyRequest : public RequestToHMI { +class NaviIsReadyRequest : public RequestToHMI, + public event_engine::EventObserver { public: /** * @brief NaviIsReadyRequest class constructor @@ -60,7 +61,12 @@ class NaviIsReadyRequest : public RequestToHMI { /** * @brief Execute command **/ - virtual void Run(); + void Run() OVERRIDE; + + /** + * @brief On event callback + **/ + void on_event(const event_engine::Event& event) OVERRIDE; private: DISALLOW_COPY_AND_ASSIGN(NaviIsReadyRequest); diff --git a/src/components/application_manager/include/application_manager/commands/hmi/request_to_hmi.h b/src/components/application_manager/include/application_manager/commands/hmi/request_to_hmi.h index 9ebb5761c1..b30044fd26 100644 --- a/src/components/application_manager/include/application_manager/commands/hmi/request_to_hmi.h +++ b/src/components/application_manager/include/application_manager/commands/hmi/request_to_hmi.h @@ -48,6 +48,7 @@ namespace commands { */ bool CheckAvailabilityHMIInterfaces(ApplicationManager& application_manager, HmiInterfaces::InterfaceID interface); + /** * @brief Change interface state * @param application_manager contains ApplicationManager instance diff --git a/src/components/application_manager/include/application_manager/commands/hmi/tts_is_ready_request.h b/src/components/application_manager/include/application_manager/commands/hmi/tts_is_ready_request.h index b0acec73b2..340a00d294 100644 --- a/src/components/application_manager/include/application_manager/commands/hmi/tts_is_ready_request.h +++ b/src/components/application_manager/include/application_manager/commands/hmi/tts_is_ready_request.h @@ -56,7 +56,7 @@ class TTSIsReadyRequest : public RequestToHMI, /** * @brief TTSIsReadyRequest class destructor **/ - ~TTSIsReadyRequest() OVERRIDE; + virtual ~TTSIsReadyRequest(); /** * @brief Execute command diff --git a/src/components/application_manager/include/application_manager/commands/hmi/ui_is_ready_request.h b/src/components/application_manager/include/application_manager/commands/hmi/ui_is_ready_request.h index 33da7a67b7..49942d81a7 100644 --- a/src/components/application_manager/include/application_manager/commands/hmi/ui_is_ready_request.h +++ b/src/components/application_manager/include/application_manager/commands/hmi/ui_is_ready_request.h @@ -56,7 +56,7 @@ class UIIsReadyRequest : public RequestToHMI, /** * @brief UIIsReadyRequest class destructor **/ - ~UIIsReadyRequest() OVERRIDE; + virtual ~UIIsReadyRequest(); /** * @brief Execute command diff --git a/src/components/application_manager/include/application_manager/commands/hmi/vi_is_ready_request.h b/src/components/application_manager/include/application_manager/commands/hmi/vi_is_ready_request.h index a81a8c8b7c..07ab9df605 100644 --- a/src/components/application_manager/include/application_manager/commands/hmi/vi_is_ready_request.h +++ b/src/components/application_manager/include/application_manager/commands/hmi/vi_is_ready_request.h @@ -56,7 +56,7 @@ class VIIsReadyRequest : public RequestToHMI, /** * @brief VIIsReadyRequest class destructor **/ - ~VIIsReadyRequest() OVERRIDE; + virtual ~VIIsReadyRequest(); /** * @brief Execute command diff --git a/src/components/application_manager/include/application_manager/commands/hmi/vr_is_ready_request.h b/src/components/application_manager/include/application_manager/commands/hmi/vr_is_ready_request.h index 784a6e4a48..55a2101e1a 100644 --- a/src/components/application_manager/include/application_manager/commands/hmi/vr_is_ready_request.h +++ b/src/components/application_manager/include/application_manager/commands/hmi/vr_is_ready_request.h @@ -62,17 +62,17 @@ class VRIsReadyRequest : public RequestToHMI, /** * @brief Execute command **/ - virtual void Run(); + void Run() OVERRIDE; /** * @brief On event callback **/ - virtual void on_event(const event_engine::Event& event); + void on_event(const event_engine::Event& event) OVERRIDE; /** * @brief onTimeOut from requrst Controller */ - virtual void onTimeOut(); + void onTimeOut() OVERRIDE; /** * @brief Send request to HMI for fetching of cappabilities diff --git a/src/components/application_manager/include/application_manager/commands/mobile/alert_maneuver_request.h b/src/components/application_manager/include/application_manager/commands/mobile/alert_maneuver_request.h index 03d767563e..92211b54a2 100644 --- a/src/components/application_manager/include/application_manager/commands/mobile/alert_maneuver_request.h +++ b/src/components/application_manager/include/application_manager/commands/mobile/alert_maneuver_request.h @@ -77,11 +77,12 @@ class AlertManeuverRequest : public CommandRequestImpl { /** * @brief Prepare parameters for sending to mobile application * @param result_code contains result code for sending to mobile application + * @param return_info contains resulting info for sending to mobile + * application * @return result for sending to mobile application. */ bool PrepareResponseParameters(mobile_apis::Result::eType& result_code, std::string& return_info); - /** * @brief Checks alert maneuver params(ttsChunks, ...). * When type is String there is a check on the contents \t\n \\t \\n diff --git a/src/components/application_manager/include/application_manager/hmi_interfaces.h b/src/components/application_manager/include/application_manager/hmi_interfaces.h index 1c6559db37..df1e2a9067 100644 --- a/src/components/application_manager/include/application_manager/hmi_interfaces.h +++ b/src/components/application_manager/include/application_manager/hmi_interfaces.h @@ -35,6 +35,7 @@ * (Buttons, BasicCommunication, VR, TTS, UI, Navigation,VehicleInfo, * SDL) and provides this information through public interfaces. */ + #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_HMI_INTERFACES_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_HMI_INTERFACES_H_ diff --git a/src/components/application_manager/src/commands/command_request_impl.cc b/src/components/application_manager/src/commands/command_request_impl.cc index 489610b6ee..16f4b9e35a 100644 --- a/src/components/application_manager/src/commands/command_request_impl.cc +++ b/src/components/application_manager/src/commands/command_request_impl.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2013, Ford Motor Company + Copyright (c) 2016, Ford Motor Company All rights reserved. Redistribution and use in source and binary forms, with or without @@ -37,11 +37,29 @@ #include "application_manager/application_manager.h" #include "application_manager/message_helper.h" #include "smart_objects/smart_object.h" - namespace application_manager { namespace commands { +std::string MergeInfos(const ResponseInfo& first_info, + const std::string& first_str, + const ResponseInfo& second_info, + const std::string& second_str) { + if ((first_info.interface_state == HmiInterfaces::STATE_NOT_AVAILABLE) && + (second_info.interface_state != HmiInterfaces::STATE_NOT_AVAILABLE) && + !second_str.empty()) { + return second_str; + } + + if ((second_info.interface_state == HmiInterfaces::STATE_NOT_AVAILABLE) && + (first_info.interface_state != HmiInterfaces::STATE_NOT_AVAILABLE) && + !first_str.empty()) { + return first_str; + } + + return MergeInfos(first_str, second_str); +} + std::string MergeInfos(const std::string& first, const std::string& second) { return first + ((!first.empty() && !second.empty()) ? ", " : "") + second; } @@ -655,7 +673,6 @@ bool CommandRequestImpl::PrepareResultForMobileResponse( hmi_apis::Common_Result::eType result_code, HmiInterfaces::InterfaceID interface) const { using namespace helpers; - if (Compare<hmi_apis::Common_Result::eType, EQ, ONE>( result_code, hmi_apis::Common_Result::SUCCESS, 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 920c6fbdf9..8bdfa7dd81 100644 --- a/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc +++ b/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc @@ -58,7 +58,11 @@ AudioStartStreamRequest::~AudioStartStreamRequest() {} void AudioStartStreamRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); - + if (!CheckAvailabilityHMIInterfaces( + application_manager_, HmiInterfaces::HMI_INTERFACE_Navigation)) { + LOG4CXX_INFO(logger_, "Interface Navi is not supported by system"); + return; + } SetAllowedToTerminate(false); subscribe_on_event(hmi_apis::FunctionID::Navigation_StartAudioStream, correlation_id()); diff --git a/src/components/application_manager/src/commands/hmi/navi_audio_stop_stream_request.cc b/src/components/application_manager/src/commands/hmi/navi_audio_stop_stream_request.cc index d0f1a96282..f86ee8302a 100644 --- a/src/components/application_manager/src/commands/hmi/navi_audio_stop_stream_request.cc +++ b/src/components/application_manager/src/commands/hmi/navi_audio_stop_stream_request.cc @@ -43,7 +43,11 @@ AudioStopStreamRequest::~AudioStopStreamRequest() {} void AudioStopStreamRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); - + if (!CheckAvailabilityHMIInterfaces( + application_manager_, HmiInterfaces::HMI_INTERFACE_Navigation)) { + LOG4CXX_INFO(logger_, "Interface Navi is not supported by system"); + return; + } SendRequest(); } diff --git a/src/components/application_manager/src/commands/hmi/navi_is_ready_request.cc b/src/components/application_manager/src/commands/hmi/navi_is_ready_request.cc index 92e972e8f4..4392258a31 100644 --- a/src/components/application_manager/src/commands/hmi/navi_is_ready_request.cc +++ b/src/components/application_manager/src/commands/hmi/navi_is_ready_request.cc @@ -38,16 +38,42 @@ namespace commands { NaviIsReadyRequest::NaviIsReadyRequest(const MessageSharedPtr& message, ApplicationManager& application_manager) - : RequestToHMI(message, application_manager) {} + : RequestToHMI(message, application_manager) + , EventObserver(application_manager.event_dispatcher()) {} NaviIsReadyRequest::~NaviIsReadyRequest() {} void NaviIsReadyRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); - + subscribe_on_event(hmi_apis::FunctionID::Navigation_IsReady, + correlation_id()); SendRequest(); } +void NaviIsReadyRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + const smart_objects::SmartObject& message = event.smart_object(); + switch (event.id()) { + case hmi_apis::FunctionID::Navigation_IsReady: { + LOG4CXX_DEBUG(logger_, "Received Navigation_IsReady event"); + unsubscribe_from_event(hmi_apis::FunctionID::Navigation_IsReady); + const bool is_available = + ChangeInterfaceState(application_manager_, + message, + HmiInterfaces::HMI_INTERFACE_Navigation); + + HMICapabilities& hmi_capabilities = + application_manager_.hmi_capabilities(); + hmi_capabilities.set_is_navi_cooperating(is_available); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + } +} + } // namespace commands } // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/navi_is_ready_response.cc b/src/components/application_manager/src/commands/hmi/navi_is_ready_response.cc index 129900c60f..7daba4258b 100644 --- a/src/components/application_manager/src/commands/hmi/navi_is_ready_response.cc +++ b/src/components/application_manager/src/commands/hmi/navi_is_ready_response.cc @@ -43,16 +43,9 @@ NaviIsReadyResponse::~NaviIsReadyResponse() {} void NaviIsReadyResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - smart_objects::SmartObject& object = *message_; - - bool is_available = false; - if (object[strings::msg_params].keyExists(strings::available)) { - is_available = object[strings::msg_params][strings::available].asBool(); - } - - HMICapabilities& hmi_capabilities = application_manager_.hmi_capabilities(); - - hmi_capabilities.set_is_navi_cooperating(is_available); + event_engine::Event event(hmi_apis::FunctionID::Navigation_IsReady); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); } } // namespace commands 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 f0104cbaee..0c03f19bdd 100644 --- a/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc +++ b/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc @@ -58,6 +58,11 @@ NaviStartStreamRequest::~NaviStartStreamRequest() {} void NaviStartStreamRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); + if (!CheckAvailabilityHMIInterfaces( + application_manager_, HmiInterfaces::HMI_INTERFACE_Navigation)) { + LOG4CXX_INFO(logger_, "Interface Navi is not supported by system"); + return; + } SetAllowedToTerminate(false); subscribe_on_event(hmi_apis::FunctionID::Navigation_StartStream, diff --git a/src/components/application_manager/src/commands/hmi/navi_stop_stream_request.cc b/src/components/application_manager/src/commands/hmi/navi_stop_stream_request.cc index 4b72ff28b4..a40ee13b68 100644 --- a/src/components/application_manager/src/commands/hmi/navi_stop_stream_request.cc +++ b/src/components/application_manager/src/commands/hmi/navi_stop_stream_request.cc @@ -12,7 +12,11 @@ NaviStopStreamRequest::~NaviStopStreamRequest() {} void NaviStopStreamRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); - + if (!CheckAvailabilityHMIInterfaces( + application_manager_, HmiInterfaces::HMI_INTERFACE_Navigation)) { + LOG4CXX_INFO(logger_, "Interface Navi is not supported by system"); + return; + } SendRequest(); } diff --git a/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc b/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc index 60de5c91eb..2b55f76115 100644 --- a/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc +++ b/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc @@ -179,7 +179,6 @@ void AlertManeuverRequest::on_event(const event_engine::Event& event) { std::string return_info; mobile_apis::Result::eType result_code; const bool result = PrepareResponseParameters(result_code, return_info); - bool must_be_empty_info = false; if (return_info.find("\n") != std::string::npos || return_info.find("\t") != std::string::npos) { @@ -201,7 +200,7 @@ bool AlertManeuverRequest::PrepareResponseParameters( HmiInterfaces::HMI_INTERFACE_Navigation); application_manager::commands::ResponseInfo tts_alert_info( - tts_speak_result_code_, HmiInterfaces::HMI_INTERFACE_Navigation); + tts_speak_result_code_, HmiInterfaces::HMI_INTERFACE_TTS); const bool result = PrepareResultForMobileResponse(navigation_alert_info, tts_alert_info); @@ -214,10 +213,10 @@ bool AlertManeuverRequest::PrepareResponseParameters( return_info = std::string("Unsupported phoneme type sent in a prompt"); return result; } - result_code = PrepareResultCodeForResponse(navigation_alert_info, tts_alert_info); - return_info = MergeInfos(info_navi_, info_tts_); + return_info = + MergeInfos(navigation_alert_info, info_navi_, tts_alert_info, info_tts_); return result; } diff --git a/src/components/application_manager/src/commands/mobile/get_way_points_request.cc b/src/components/application_manager/src/commands/mobile/get_way_points_request.cc index 9baf747ee4..3a253d1d7f 100644 --- a/src/components/application_manager/src/commands/mobile/get_way_points_request.cc +++ b/src/components/application_manager/src/commands/mobile/get_way_points_request.cc @@ -1,5 +1,6 @@ #include "application_manager/application_manager.h" #include "application_manager/commands/mobile/get_way_points_request.h" +#include "application_manager/message_helper.h" namespace application_manager { @@ -35,16 +36,24 @@ void GetWayPointsRequest::Run() { void GetWayPointsRequest::on_event(const event_engine::Event& event) { LOG4CXX_AUTO_TRACE(logger_); - ApplicationSharedPtr app = application_manager_.application(connection_key()); const smart_objects::SmartObject& message = event.smart_object(); switch (event.id()) { case hmi_apis::FunctionID::Navigation_GetWayPoints: { LOG4CXX_INFO(logger_, "Received Navigation_GetWayPoints event"); - mobile_apis::Result::eType result_code = - GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>( - message[strings::params][hmi_response::code].asUInt())); - bool result = mobile_apis::Result::SUCCESS == result_code; - SendResponse(result, result_code, NULL, &(message[strings::msg_params])); + const hmi_apis::Common_Result::eType result_code = + static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + std::string response_info; + GetInfo(HmiInterfaces::HMI_INTERFACE_Navigation, + result_code, + message, + response_info); + const bool result = PrepareResultForMobileResponse( + result_code, HmiInterfaces::HMI_INTERFACE_Navigation); + SendResponse(result, + MessageHelper::HMIToMobileResult(result_code), + response_info.empty() ? NULL : response_info.c_str(), + &(message[strings::msg_params])); break; } default: { diff --git a/src/components/application_manager/src/commands/mobile/send_location_request.cc b/src/components/application_manager/src/commands/mobile/send_location_request.cc index 975f7e43c3..4f1f1c9783 100644 --- a/src/components/application_manager/src/commands/mobile/send_location_request.cc +++ b/src/components/application_manager/src/commands/mobile/send_location_request.cc @@ -31,11 +31,8 @@ POSSIBILITY OF SUCH DAMAGE. */ #include <algorithm> - #include "application_manager/commands/mobile/send_location_request.h" - #include "application_manager/message_helper.h" -#include "utils/helpers.h" #include "utils/custom_string.h" namespace application_manager { @@ -136,21 +133,23 @@ void SendLocationRequest::Run() { void SendLocationRequest::on_event(const event_engine::Event& event) { LOG4CXX_AUTO_TRACE(logger_); - namespace Result = mobile_apis::Result; - using namespace helpers; + using namespace hmi_apis; const smart_objects::SmartObject& message = event.smart_object(); if (hmi_apis::FunctionID::Navigation_SendLocation == event.id()) { LOG4CXX_INFO(logger_, "Received Navigation_SendLocation event"); - mobile_apis::Result::eType result_code = - GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>( - message[strings::params][hmi_response::code].asUInt())); - const bool result = - Compare<Result::eType, EQ, ONE>(result_code, - Result::SAVED, - Result::SUCCESS, - Result::WARNINGS, - Result::UNSUPPORTED_RESOURCE); - SendResponse(result, result_code, NULL, &(message[strings::params])); + const Common_Result::eType result_code = static_cast<Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + std::string response_info; + GetInfo(HmiInterfaces::HMI_INTERFACE_Navigation, + result_code, + message, + response_info); + const bool result = PrepareResultForMobileResponse( + result_code, HmiInterfaces::HMI_INTERFACE_Navigation); + SendResponse(result, + MessageHelper::HMIToMobileResult(result_code), + response_info.empty() ? NULL : response_info.c_str(), + &(message[strings::params])); return; } LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); diff --git a/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc b/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc index 2d79e13582..7c2bd7722b 100644 --- a/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc +++ b/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc @@ -178,31 +178,25 @@ void ShowConstantTBTRequest::Run() { void ShowConstantTBTRequest::on_event(const event_engine::Event& event) { LOG4CXX_AUTO_TRACE(logger_); + using namespace hmi_apis; const smart_objects::SmartObject& message = event.smart_object(); switch (event.id()) { case hmi_apis::FunctionID::Navigation_ShowConstantTBT: { LOG4CXX_INFO(logger_, "Received Navigation_ShowConstantTBT event"); - std::string return_info; - - mobile_apis::Result::eType result_code = - GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>( - message[strings::params][hmi_response::code].asInt())); - HMICapabilities& hmi_capabilities = - application_manager_.hmi_capabilities(); - bool result = false; - if (mobile_apis::Result::SUCCESS == result_code) { - result = true; - return_info = - message[strings::msg_params][hmi_response::message].asString(); - } else if ((mobile_apis::Result::UNSUPPORTED_RESOURCE == result_code) && - hmi_capabilities.is_ui_cooperating()) { - result = true; - } - + const Common_Result::eType result_code = + static_cast<Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + std::string response_info; + GetInfo(HmiInterfaces::HMI_INTERFACE_Navigation, + result_code, + message, + response_info); + const bool result = PrepareResultForMobileResponse( + result_code, HmiInterfaces::HMI_INTERFACE_Navigation); SendResponse(result, - result_code, - return_info.empty() ? 0 : return_info.c_str(), + MessageHelper::HMIToMobileResult(result_code), + response_info.empty() ? NULL : response_info.c_str(), &(message[strings::msg_params])); break; } diff --git a/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc b/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc index 8134730eee..26e89b44bf 100644 --- a/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc +++ b/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc @@ -1,5 +1,6 @@ #include "application_manager/application_manager.h" #include "application_manager/commands/mobile/subscribe_way_points_request.h" +#include "application_manager/message_helper.h" namespace application_manager { @@ -47,14 +48,23 @@ void SubscribeWayPointsRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::Navigation_SubscribeWayPoints: { LOG4CXX_INFO(logger_, "Received Navigation_SubscribeWayPoints event"); - mobile_apis::Result::eType result_code = - GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>( - message[strings::params][hmi_response::code].asUInt())); - bool result = mobile_apis::Result::SUCCESS == result_code; + const hmi_apis::Common_Result::eType result_code = + static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + std::string response_info; + GetInfo(HmiInterfaces::HMI_INTERFACE_Navigation, + result_code, + message, + response_info); + const bool result = PrepareResultForMobileResponse( + result_code, HmiInterfaces::HMI_INTERFACE_Navigation); if (result) { application_manager_.SubscribeAppForWayPoints(app->app_id()); } - SendResponse(result, result_code, NULL, &(message[strings::msg_params])); + SendResponse(result, + MessageHelper::HMIToMobileResult(result_code), + response_info.empty() ? NULL : response_info.c_str(), + &(message[strings::msg_params])); if (result) { app->UpdateHash(); } diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc index b19e292025..d5c98e1a36 100644 --- a/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc +++ b/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc @@ -1,5 +1,6 @@ #include "application_manager/application_manager.h" #include "application_manager/commands/mobile/unsubscribe_way_points_request.h" +#include "application_manager/message_helper.h" namespace application_manager { @@ -40,14 +41,23 @@ void UnSubscribeWayPointsRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints: { LOG4CXX_INFO(logger_, "Received Navigation_UnSubscribeWayPoints event"); - mobile_apis::Result::eType result_code = - GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>( - message[strings::params][hmi_response::code].asUInt())); - bool result = mobile_apis::Result::SUCCESS == result_code; + const hmi_apis::Common_Result::eType result_code = + static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + std::string response_info; + GetInfo(HmiInterfaces::HMI_INTERFACE_Navigation, + result_code, + message, + response_info); + const bool result = PrepareResultForMobileResponse( + result_code, HmiInterfaces::HMI_INTERFACE_Navigation); if (result) { application_manager_.UnsubscribeAppFromWayPoints(app->app_id()); } - SendResponse(result, result_code, NULL, &(message[strings::msg_params])); + SendResponse(result, + MessageHelper::HMIToMobileResult(result_code), + response_info.empty() ? NULL : response_info.c_str(), + &(message[strings::msg_params])); if (result) { app->UpdateHash(); } diff --git a/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc b/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc index 9b3b221446..a17f1acd55 100644 --- a/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc +++ b/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc @@ -155,18 +155,20 @@ void UpdateTurnListRequest::on_event(const event_engine::Event& event) { case hmi_apis::FunctionID::Navigation_UpdateTurnList: { LOG4CXX_INFO(logger_, "Received Navigation_UpdateTurnList event"); - mobile_apis::Result::eType result_code = - static_cast<mobile_apis::Result::eType>( + const hmi_apis::Common_Result::eType result_code = + static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); - HMICapabilities& hmi_capabilities = - application_manager_.hmi_capabilities(); - - bool result = - (mobile_apis::Result::SUCCESS == result_code) || - ((mobile_apis::Result::UNSUPPORTED_RESOURCE == result_code) && - (hmi_capabilities.is_ui_cooperating())); - - SendResponse(result, result_code, NULL, &(message[strings::msg_params])); + std::string response_info; + GetInfo(HmiInterfaces::HMI_INTERFACE_Navigation, + result_code, + message, + response_info); + const bool result = PrepareResultForMobileResponse( + result_code, HmiInterfaces::HMI_INTERFACE_Navigation); + SendResponse(result, + MessageHelper::HMIToMobileResult(result_code), + response_info.empty() ? NULL : response_info.c_str(), + &(message[strings::msg_params])); break; } default: { |