diff options
Diffstat (limited to 'src/components')
7 files changed, 93 insertions, 55 deletions
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 609180197c..489610b6ee 100644 --- a/src/components/application_manager/src/commands/command_request_impl.cc +++ b/src/components/application_manager/src/commands/command_request_impl.cc @@ -68,6 +68,9 @@ const std::string CreateInfoForUnsupportedResult( case (HmiInterfaces::InterfaceID::HMI_INTERFACE_Navigation): { return "Navi is not supported by system"; } + case (HmiInterfaces::InterfaceID::HMI_INTERFACE_VehicleInfo): { + return "VehicleInfo is not supported by system"; + } default: #ifdef ENABLE_LOG CREATE_LOGGERPTR_LOCAL(logger, "Commands"); diff --git a/src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc b/src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc index 5252ea0e33..072a4aaf47 100644 --- a/src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc +++ b/src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc @@ -37,6 +37,7 @@ #include "application_manager/application_impl.h" #include "interfaces/HMI_API.h" +#include "application_manager/message_helper.h" namespace application_manager { @@ -93,13 +94,20 @@ void DiagnosticMessageRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::VehicleInfo_DiagnosticMessage: { - mobile_apis::Result::eType result_code = - static_cast<mobile_apis::Result::eType>( + hmi_apis::Common_Result::eType result_code = + static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); - - bool result = mobile_apis::Result::SUCCESS == result_code; - - SendResponse(result, result_code, NULL, &(message[strings::msg_params])); + const bool result = PrepareResultForMobileResponse( + result_code, HmiInterfaces::HMI_INTERFACE_VehicleInfo); + std::string response_info; + GetInfo(HmiInterfaces::InterfaceID::HMI_INTERFACE_VehicleInfo, + result_code, + message, + response_info); + 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/get_dtcs_request.cc b/src/components/application_manager/src/commands/mobile/get_dtcs_request.cc index 80bc89f853..90d9b20285 100644 --- a/src/components/application_manager/src/commands/mobile/get_dtcs_request.cc +++ b/src/components/application_manager/src/commands/mobile/get_dtcs_request.cc @@ -35,6 +35,7 @@ #include "application_manager/application_impl.h" #include "interfaces/HMI_API.h" +#include "application_manager/message_helper.h" namespace application_manager { @@ -80,13 +81,22 @@ void GetDTCsRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::VehicleInfo_GetDTCs: { - mobile_apis::Result::eType result_code = - static_cast<mobile_apis::Result::eType>( + hmi_apis::Common_Result::eType result_code = + static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); - bool result = mobile_apis::Result::SUCCESS == result_code; - - SendResponse(result, result_code, NULL, &(message[strings::msg_params])); + const bool result = PrepareResultForMobileResponse( + result_code, HmiInterfaces::HMI_INTERFACE_VehicleInfo); + std::string response_info; + GetInfo(HmiInterfaces::InterfaceID::HMI_INTERFACE_VehicleInfo, + result_code, + message, + response_info); + + 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/get_vehicle_data_request.cc b/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc index 330cbdef30..a572a2cf8f 100644 --- a/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc +++ b/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc @@ -266,27 +266,31 @@ void GetVehicleDataRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::VehicleInfo_GetVehicleData: { - mobile_apis::Result::eType result_code = - static_cast<mobile_apis::Result::eType>( + hmi_apis::Common_Result::eType result_code = + static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); - bool result = false; - if (mobile_apis::Result::SUCCESS == result_code || - (hmi_apis::Common_Result::DATA_NOT_AVAILABLE == - static_cast<hmi_apis::Common_Result::eType>(result_code) && - message[strings::msg_params].length() > 1)) { - result = true; - } - const char* info = NULL; - std::string error_message; + bool result = PrepareResultForMobileResponse( + result_code, HmiInterfaces::HMI_INTERFACE_VehicleInfo); + std::string response_info; + GetInfo(HmiInterfaces::InterfaceID::HMI_INTERFACE_VehicleInfo, + result_code, + message, + response_info); + result = result || + ((hmi_apis::Common_Result::DATA_NOT_AVAILABLE == result_code) && + (message[strings::msg_params].length() > 1)); + if (true == message[strings::msg_params].keyExists(hmi_response::method)) { message[strings::msg_params].erase(hmi_response::method); } if (true == message[strings::params].keyExists(strings::error_msg)) { - error_message = message[strings::params][strings::error_msg].asString(); - info = error_message.c_str(); + response_info = message[strings::params][strings::error_msg].asString(); } - SendResponse(result, result_code, info, &(message[strings::msg_params])); + 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/read_did_request.cc b/src/components/application_manager/src/commands/mobile/read_did_request.cc index 18482b5b63..3b53bc427e 100644 --- a/src/components/application_manager/src/commands/mobile/read_did_request.cc +++ b/src/components/application_manager/src/commands/mobile/read_did_request.cc @@ -36,6 +36,7 @@ #include "application_manager/application_impl.h" #include "interfaces/MOBILE_API.h" #include "interfaces/HMI_API.h" +#include "application_manager/message_helper.h" namespace application_manager { @@ -96,13 +97,21 @@ void ReadDIDRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::VehicleInfo_ReadDID: { - mobile_apis::Result::eType result_code = - static_cast<mobile_apis::Result::eType>( + hmi_apis::Common_Result::eType result_code = + static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); - - bool result = mobile_apis::Result::SUCCESS == result_code; - - SendResponse(result, result_code, NULL, &(message[strings::msg_params])); + const bool result = PrepareResultForMobileResponse( + result_code, HmiInterfaces::HMI_INTERFACE_VehicleInfo); + std::string response_info; + GetInfo(HmiInterfaces::InterfaceID::HMI_INTERFACE_VehicleInfo, + result_code, + message, + response_info); + + 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/subscribe_vehicle_data_request.cc b/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc index 485c5d0009..f3082476f9 100644 --- a/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc +++ b/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc @@ -325,27 +325,27 @@ void SubscribeVehicleDataRequest::on_event(const event_engine::Event& event) { } } #else + hmi_apis::Common_Result::eType hmi_result = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); - - const bool is_result_no_error = - Compare<hmi_apis::Common_Result::eType, EQ, ONE>( + std::string response_info; + GetInfo(HmiInterfaces::InterfaceID::HMI_INTERFACE_VehicleInfo, hmi_result, - hmi_apis::Common_Result::SUCCESS, - hmi_apis::Common_Result::WARNINGS); + message, + response_info); + const bool result = PrepareResultForMobileResponse( + hmi_result, HmiInterfaces::HMI_INTERFACE_VehicleInfo); - bool is_succeeded = - is_result_no_error || !vi_already_subscribed_by_another_apps_.empty(); + bool is_succeeded = result || !vi_already_subscribed_by_another_apps_.empty(); mobile_apis::Result::eType result_code = MessageHelper::HMIToMobileResult(hmi_result); - const char* return_info = NULL; if (is_succeeded) { if (!vi_already_subscribed_by_this_app_.empty()) { result_code = mobile_apis::Result::IGNORED; - return_info = "Already subscribed on some provided VehicleData."; + response_info = "Already subscribed on some provided VehicleData."; } } @@ -357,8 +357,10 @@ void SubscribeVehicleDataRequest::on_event(const event_engine::Event& event) { const_cast<smart_objects::SmartObject&>(message[strings::msg_params])); } - SendResponse( - is_succeeded, result_code, return_info, &(message[strings::msg_params])); + SendResponse(is_succeeded, + result_code, + response_info.empty() ? NULL : response_info.c_str(), + &(message[strings::msg_params])); if (is_succeeded) { app->UpdateHash(); diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc index 4fcc04c7be..373a0cf039 100644 --- a/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc +++ b/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc @@ -315,21 +315,21 @@ void UnsubscribeVehicleDataRequest::on_event(const event_engine::Event& event) { hmi_apis::Common_Result::eType hmi_result = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); - - bool is_succeeded = Compare<hmi_apis::Common_Result::eType, EQ, ONE>( - hmi_result, - hmi_apis::Common_Result::SUCCESS, - hmi_apis::Common_Result::WARNINGS); + std::string response_info; + GetInfo(HmiInterfaces::InterfaceID::HMI_INTERFACE_VehicleInfo, + hmi_result, + message, + response_info); + const bool result = PrepareResultForMobileResponse( + hmi_result, HmiInterfaces::HMI_INTERFACE_VehicleInfo); mobile_apis::Result::eType result_code = MessageHelper::HMIToMobileResult(hmi_result); - const char* return_info = NULL; - - if (is_succeeded) { + if (result) { if (vi_already_unsubscribed_by_this_app_.size()) { result_code = mobile_apis::Result::IGNORED; - return_info = "Some provided VehicleData was not subscribed."; + response_info = "Some provided VehicleData was not subscribed."; } } @@ -339,12 +339,14 @@ void UnsubscribeVehicleDataRequest::on_event(const event_engine::Event& event) { const_cast<smart_objects::SmartObject&>(message[strings::msg_params])); } - if (is_succeeded) { + if (result) { SetAllowedToTerminate(false); } - SendResponse( - is_succeeded, result_code, return_info, &(message[strings::msg_params])); - if (is_succeeded) { + SendResponse(result, + result_code, + response_info.empty() ? NULL : response_info.c_str(), + &(message[strings::msg_params])); + if (result) { UpdateHash(); } #endif // #ifdef HMI_DBUS_API |