diff options
Diffstat (limited to 'src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_request.cc')
-rw-r--r-- | src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_request.cc | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_request.cc index e389c87894..d15cf6a580 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_request.cc @@ -116,16 +116,31 @@ void GetVehicleDataRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::VehicleInfo_GetVehicleData: { EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); - hmi_apis::Common_Result::eType result_code = - static_cast<hmi_apis::Common_Result::eType>( - message[strings::params][hmi_response::code].asInt()); + auto result_code = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + auto mobile_result_code = GetMobileResultCode(result_code); bool result = PrepareResultForMobileResponse( result_code, HmiInterfaces::HMI_INTERFACE_VehicleInfo); std::string response_info; GetInfo(message, response_info); - result = result || - ((hmi_apis::Common_Result::DATA_NOT_AVAILABLE == result_code) && - (message[strings::msg_params].length() > 1)); + + auto data_not_available_with_params = [this, &result_code, &message]() { + if (hmi_apis::Common_Result::DATA_NOT_AVAILABLE != result_code) { + return false; + } + + const auto& vehicle_data = MessageHelper::vehicle_data(); + const auto& msg_params = message[strings::msg_params]; + for (const auto& item : msg_params.enumerate()) { + if (vehicle_data.end() != vehicle_data.find(item) || + custom_vehicle_data_manager_.IsValidCustomVehicleDataName(item)) { + return true; + } + } + return false; + }; + + result = result || data_not_available_with_params(); if (true == message[strings::msg_params].keyExists(hmi_response::method)) { @@ -147,7 +162,8 @@ void GetVehicleDataRequest::on_event(const event_engine::Event& event) { } } - if (message[strings::msg_params].empty()) { + if (message[strings::msg_params].empty() && + hmi_apis::Common_Result::DATA_NOT_AVAILABLE != result_code) { response_info = "Failed to retrieve data from vehicle"; SendResponse( false, mobile_apis::Result::GENERIC_ERROR, response_info.c_str()); @@ -156,7 +172,7 @@ void GetVehicleDataRequest::on_event(const event_engine::Event& event) { } SendResponse(result, - MessageHelper::HMIToMobileResult(result_code), + mobile_result_code, response_info.empty() ? NULL : response_info.c_str(), &(message[strings::msg_params])); break; |