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/PrepareResultCodeForResponse function
- PrepareResultForMobileResponse is currently virtual
  • Loading branch information
AKalinich-Luxoft committed May 29, 2017
1 parent 09e4eac commit 75e8ed3
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,33 +187,51 @@ 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);

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;
Expand Down

0 comments on commit 75e8ed3

Please sign in to comment.