Skip to content

Commit

Permalink
Fix AlertManeuver success result in case of UNSUPPORTED_RESOURCE
Browse files Browse the repository at this point in the history
Fixed AlertManeuver success result in case of UNSUPPORTED_RESOURCE.
The problem was that SDL does not check success result in this
specific case.

In this commit:
- Added check for UNSUPPORTED_RESOURCE case
- All specific checks were moved to PrepareResultForMobileResponse function
- PrepareResultForMobileResponse is currently virtual
  • Loading branch information
AKalinich-Luxoft committed May 29, 2017
1 parent 09e4eac commit 553abdd
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,18 @@ 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 response
* @param second - contains result_code from HMI response and
* interface that returns response
* @return true if result code UNSUPPORTED_RESOURCE otherwise false
*/
bool IsResultCodeUnsupported(const ResponseInfo& first,
const ResponseInfo& second);

class CommandRequestImpl : public CommandImpl,
public event_engine::EventObserver {
public:
Expand Down Expand Up @@ -233,8 +245,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
Expand All @@ -256,7 +268,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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,21 @@ 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 response
* @param tts_alert_info contains result_code from HMI response and
* interface that returns response
* @return true if result code complies successful result code
* otherwise returns false
*/
bool PrepareResultForMobileResponse(
ResponseInfo& navigation_alert_info,
ResponseInfo& tts_alert_info) const OVERRIDE;

/**
* @brief Checks alert maneuver params(ttsChunks, ...).
* When type is String there is a check on the contents \t\n \\t \\n
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,30 +187,40 @@ 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_,
HmiInterfaces::HMI_INTERFACE_Navigation);

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);
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_);

const bool result = CommandRequestImpl::PrepareResultForMobileResponse(
navigation_alert_info, tts_alert_info);
if (result && (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE ==
tts_speak_result_code_ &&
tts_alert_info.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;
tts_alert_info.result_code = hmi_apis::Common_Result::WARNINGS;
} else if (IsResultCodeUnsupported(navigation_alert_info, tts_alert_info)) {
return true;
}
result_code =
PrepareResultCodeForResponse(navigation_alert_info, tts_alert_info);
return_info =
MergeInfos(navigation_alert_info, info_navi_, tts_alert_info, info_tts_);

return result;
}

Expand Down

0 comments on commit 553abdd

Please sign in to comment.