summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlha Vorobiova (GitHub) <86727408+OlhaVorobiova@users.noreply.github.com>2022-02-14 19:37:15 +0200
committerGitHub <noreply@github.com>2022-02-14 12:37:15 -0500
commitb74c738101f282143094394454d20d12aa8e0d05 (patch)
treed843e27957772beea08c45cafcd245c150cd3391
parent7a4a4e02b9edf2602596bf5608e05a2daf7dbfeb (diff)
downloadsdl_core-b74c738101f282143094394454d20d12aa8e0d05.tar.gz
Fix result code for PrepareAudioPassThru (#3854)
* Fix result code for PrepareAudioPassThru * Fix result code for PrepareAudioPassThru in error structure
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_request.cc41
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_audio_pass_thru_test.cc2
-rw-r--r--src/components/utils/include/utils/helpers.h9
3 files changed, 31 insertions, 21 deletions
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_request.cc
index a690c0bc9b..dc46bd7f7c 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_request.cc
@@ -175,6 +175,7 @@ void PerformAudioPassThruRequest::on_event(const event_engine::Event& event) {
hmi_apis::Common_Result::WRONG_LANGUAGE,
hmi_apis::Common_Result::RETRY,
hmi_apis::Common_Result::SAVED,
+ hmi_apis::Common_Result::TRUNCATED_DATA,
hmi_apis::Common_Result::UNSUPPORTED_RESOURCE);
if (is_tts_speak_success_unsuported) {
@@ -198,7 +199,7 @@ void PerformAudioPassThruRequest::on_event(const event_engine::Event& event) {
return;
}
- const ResponseParams response_params = PrepareResponseParameters();
+ ResponseParams response_params = PrepareResponseParameters();
SendResponse(
response_params.success,
@@ -220,7 +221,9 @@ PerformAudioPassThruRequest::PrepareResponseParameters() {
response_params_.success =
PrepareResultForMobileResponse(ui_perform_info, tts_perform_info);
- if (ui_perform_info.is_ok && tts_perform_info.is_unsupported_resource &&
+
+ if ((ui_perform_info.result_code == hmi_apis::Common_Result::SUCCESS) &&
+ ui_perform_info.is_ok && tts_perform_info.is_unsupported_resource &&
HmiInterfaces::STATE_AVAILABLE == tts_perform_info.interface_state) {
response_params_.result_code = mobile_apis::Result::WARNINGS;
response_params_.info = app_mngr::commands::MergeInfos(
@@ -231,12 +234,13 @@ PerformAudioPassThruRequest::PrepareResponseParameters() {
if (IsResultCodeUnsupported(ui_perform_info, tts_perform_info)) {
response_params_.result_code = mobile_apis::Result::UNSUPPORTED_RESOURCE;
- } else {
- AudioPassThruResults results = PrepareAudioPassThruResultCodeForResponse(
- ui_perform_info, tts_perform_info);
- response_params_.success = results.second;
- response_params_.result_code = results.first;
}
+
+ AudioPassThruResults results = PrepareAudioPassThruResultCodeForResponse(
+ ui_perform_info, tts_perform_info);
+ response_params_.success = results.second;
+ response_params_.result_code = results.first;
+
response_params_.info = app_mngr::commands::MergeInfos(
ui_perform_info, ui_info_, tts_perform_info, tts_info_);
@@ -407,23 +411,19 @@ PerformAudioPassThruRequest::PrepareAudioPassThruResultCodeForResponse(
const hmi_apis::Common_Result::eType tts_result = tts_response.result_code;
bool result = false;
- if ((ui_result == hmi_apis::Common_Result::SUCCESS) &&
- (tts_result == hmi_apis::Common_Result::SUCCESS)) {
- result = true;
- }
-
- if ((ui_result == hmi_apis::Common_Result::SUCCESS) &&
- (tts_result == hmi_apis::Common_Result::INVALID_ENUM)) {
+ if ((application_manager::commands::IsHMIResultSuccess(ui_result) ||
+ (ui_result == hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)) &&
+ (application_manager::commands::IsHMIResultSuccess(tts_result) ||
+ (tts_result == hmi_apis::Common_Result::UNSUPPORTED_RESOURCE) ||
+ (tts_result == hmi_apis::Common_Result::INVALID_ENUM))) {
result = true;
}
if ((ui_result == hmi_apis::Common_Result::SUCCESS) &&
- (tts_result != hmi_apis::Common_Result::SUCCESS) &&
- (tts_result != hmi_apis::Common_Result::INVALID_ENUM)) {
- common_result = hmi_apis::Common_Result::WARNINGS;
- result = true;
- } else if (ui_response.is_ok &&
- tts_result == hmi_apis::Common_Result::WARNINGS) {
+ (((tts_result != hmi_apis::Common_Result::SUCCESS) &&
+ (tts_result != hmi_apis::Common_Result::INVALID_ENUM)) ||
+ (ui_response.is_ok &&
+ tts_result == hmi_apis::Common_Result::WARNINGS))) {
common_result = hmi_apis::Common_Result::WARNINGS;
result = true;
} else if (ui_result == hmi_apis::Common_Result::INVALID_ENUM) {
@@ -431,6 +431,7 @@ PerformAudioPassThruRequest::PrepareAudioPassThruResultCodeForResponse(
} else {
common_result = ui_result;
}
+
result_code = MessageHelper::HMIToMobileResult(common_result);
return std::make_pair(result_code, result);
}
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_audio_pass_thru_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_audio_pass_thru_test.cc
index b23e8eefeb..739041523b 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_audio_pass_thru_test.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_audio_pass_thru_test.cc
@@ -261,7 +261,7 @@ TEST_F(PerformAudioPassThruRequestTest,
EXPECT_EQ((*response_to_mobile)[am::strings::msg_params][am::strings::success]
.asBool(),
- false);
+ true);
EXPECT_EQ(
(*response_to_mobile)[am::strings::msg_params][am::strings::result_code]
.asInt(),
diff --git a/src/components/utils/include/utils/helpers.h b/src/components/utils/include/utils/helpers.h
index 1ef336dadd..34b3583dae 100644
--- a/src/components/utils/include/utils/helpers.h
+++ b/src/components/utils/include/utils/helpers.h
@@ -126,6 +126,15 @@ bool Compare(T what, T to, T to1, T to2, T to3, T to4, T to5) {
Compare<T, CompareType, CmpStrategy>(what, to4, to5));
}
+template <typename T,
+ bool (*CompareType)(T, T),
+ bool (*CmpStrategy)(bool, bool)>
+bool Compare(T what, T to, T to1, T to2, T to3, T to4, T to5, T to6) {
+ return CmpStrategy(
+ Compare<T, CompareType, CmpStrategy>(what, to, to1, to2, to3),
+ Compare<T, CompareType, CmpStrategy>(what, to4, to5, to6));
+}
+
template <typename Container>
bool in_range(const Container& container,
const typename Container::value_type& value) {