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 f585410e97c..a9298c952a4 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 @@ -107,6 +107,33 @@ std::string MergeInfos(const std::string& first, const std::string& second, const std::string& third); +/** + * @brief IsResultCodeUnsupported check if overall result code of provided infos + * is UNSUPPORTED_RESOURCE + * @param first - contains result_code from HMI response and + * interface that returns first response + * @param second - contains result_code from HMI response and + * interface that returns second response + * @return true if overall result code is UNSUPPORTED_RESOURCE otherwise false + */ +bool IsResultCodeUnsupported(const ResponseInfo& first, + const ResponseInfo& second); + +/** + * @brief IsResultCodeUnsupported check if overall result code of provided infos + * is UNSUPPORTED_RESOURCE + * @param first - contains result_code from HMI response and + * interface that returns first response + * @param second - contains result_code from HMI response and + * interface that returns second response + * @param third - contains result_code from HMI response and + * interface that returns third response + * @return true if overall result code is UNSUPPORTED_RESOURCE otherwise false + */ +bool IsResultCodeUnsupported(const ResponseInfo& first, + const ResponseInfo& second, + const ResponseInfo& third); + class CommandRequestImpl : public CommandImpl, public event_engine::EventObserver { public: @@ -233,8 +260,8 @@ class CommandRequestImpl : public CommandImpl, * @return true if result code complies successful result code * otherwise returns false */ - bool PrepareResultForMobileResponse(ResponseInfo& out_first, - ResponseInfo& out_second) const; + virtual bool PrepareResultForMobileResponse(ResponseInfo& out_first, + ResponseInfo& out_second) const; /** * @brief If message from HMI contains returns this info @@ -256,7 +283,7 @@ class CommandRequestImpl : public CommandImpl, * interface that returns response. * @return resulting code for sending to mobile application. */ - mobile_apis::Result::eType PrepareResultCodeForResponse( + virtual mobile_apis::Result::eType PrepareResultCodeForResponse( const ResponseInfo& first, const ResponseInfo& second); protected: 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 17ad75b7a62..94286a13b6f 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 @@ -83,6 +83,32 @@ class AlertManeuverRequest : public CommandRequestImpl { */ bool PrepareResponseParameters(mobile_apis::Result::eType& result_code, std::string& return_info); + + /** + * @brief Checks result code from HMI for splitted RPC + * and returns parameter for sending to mobile app. + * @param navigation_alert_info contains result_code from HMI response and + * interface that returns navi response + * @param tts_alert_info contains result_code from HMI response and + * interface that returns tts response + * @return true if result code complies successful result code + * otherwise returns false + */ + bool PrepareResultForMobileResponse(ResponseInfo& navigation_alert_info, + ResponseInfo& tts_alert_info) const FINAL; + + /** + * @brief Prepare result code for sending to mobile application + * @param navigation_alert_info contains result_code from HMI response and + * interface that returns navi response + * @param tts_alert_info contains result_code from HMI response and + * interface that returns tts response. + * @return resulting code for sending to mobile application. + */ + mobile_apis::Result::eType PrepareResultCodeForResponse( + const ResponseInfo& navigation_alert_info, + const ResponseInfo& tts_alert_info) FINAL; + /** * @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/src/commands/command_request_impl.cc b/src/components/application_manager/src/commands/command_request_impl.cc index bafad525638..ade3d0f140d 100644 --- a/src/components/application_manager/src/commands/command_request_impl.cc +++ b/src/components/application_manager/src/commands/command_request_impl.cc @@ -118,6 +118,13 @@ bool IsResultCodeUnsupported(const ResponseInfo& first, (first.is_unsupported_resource && second.is_unsupported_resource); } +bool IsResultCodeUnsupported(const ResponseInfo& first, + const ResponseInfo& second, + const ResponseInfo& third) { + return IsResultCodeUnsupported(first, second) || + IsResultCodeUnsupported(second, third); +} + struct DisallowedParamsInserter { DisallowedParamsInserter(smart_objects::SmartObject& response, mobile_apis::VehicleDataResultCode::eType code) 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 b1519902892..caeab5b626c 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 @@ -187,7 +187,6 @@ void AlertManeuverRequest::on_event(const event_engine::Event& event) { bool AlertManeuverRequest::PrepareResponseParameters( mobile_apis::Result::eType& result_code, std::string& return_info) { LOG4CXX_AUTO_TRACE(logger_); - using namespace helpers; application_manager::commands::ResponseInfo navigation_alert_info( navi_alert_maneuver_result_code_, @@ -195,25 +194,44 @@ bool AlertManeuverRequest::PrepareResponseParameters( application_manager::commands::ResponseInfo tts_alert_info( tts_speak_result_code_, HmiInterfaces::HMI_INTERFACE_TTS); + const bool result = PrepareResultForMobileResponse(navigation_alert_info, tts_alert_info); - - if (result && (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == - tts_speak_result_code_ && - (HmiInterfaces::STATE_AVAILABLE == - application_manager_.hmi_interfaces().GetInterfaceState( - HmiInterfaces::HMI_INTERFACE_TTS)))) { - result_code = mobile_apis::Result::WARNINGS; - 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(navigation_alert_info, info_navi_, tts_alert_info, info_tts_); + return result; } +bool AlertManeuverRequest::PrepareResultForMobileResponse( + ResponseInfo& navigation_alert_info, ResponseInfo& tts_alert_info) const { + LOG4CXX_AUTO_TRACE(logger_); + + bool result = CommandRequestImpl::PrepareResultForMobileResponse( + navigation_alert_info, tts_alert_info); + if (IsResultCodeUnsupported(navigation_alert_info, tts_alert_info)) { + result = true; + } + + return result; +} + +mobile_apis::Result::eType AlertManeuverRequest::PrepareResultCodeForResponse( + const ResponseInfo& navigation_alert_info, + const ResponseInfo& tts_alert_info) { + LOG4CXX_AUTO_TRACE(logger_); + + if (tts_alert_info.is_unsupported_resource && + (navigation_alert_info.is_ok || navigation_alert_info.is_invalid_enum)) { + return mobile_apis::Result::WARNINGS; + } + + return CommandRequestImpl::PrepareResultCodeForResponse(navigation_alert_info, + tts_alert_info); +} + bool AlertManeuverRequest::IsWhiteSpaceExist() { LOG4CXX_AUTO_TRACE(logger_); const char* str = NULL;