diff options
author | Kostiantyn Grygoriev (GitHub) <KVGrygoriev@luxoft.com> | 2018-08-21 10:10:08 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-21 10:10:08 +0300 |
commit | 7fa7793946ec57a3a6744510c7625adcfb910edf (patch) | |
tree | c51c9dab4fa4f1bd9c4dfac787d5db2989631a3e | |
parent | 2e20fe9a9cda25a54be7847b38e7b1998fe4ef72 (diff) | |
parent | e254b3cfc0d7b8ba8a1d04ff679725b0e5eb9a68 (diff) | |
download | sdl_core-fix/does_not_send_GENERIC_ERROR_in_receiving_empty_gpsData.tar.gz |
Merge pull request #2268 from KVGrygoriev/fix/does_not_send_GENERIC_ERROR_in_receiving_empty_gpsDatafix/does_not_send_GENERIC_ERROR_in_receiving_empty_gpsData
Fix processing of receiving empty 'gpsData' struct
3 files changed, 29 insertions, 11 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 87a9ace377..dd28c9a8d9 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 @@ -111,6 +111,18 @@ void GetVehicleDataRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::VehicleInfo_GetVehicleData: { EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); + smart_objects::SmartObject& incoming_msg_params = + message[strings::msg_params]; + + if (incoming_msg_params.keyExists(strings::gps) && + incoming_msg_params[strings::gps].empty()) { + LOG4CXX_ERROR(logger_, "Invalid response received from system"); + SendResponse(false, + mobile_apis::Result::GENERIC_ERROR, + "Invalid response received from system"); + return; + } + hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); @@ -120,11 +132,10 @@ void GetVehicleDataRequest::on_event(const event_engine::Event& event) { GetInfo(message, response_info); result = result || ((hmi_apis::Common_Result::DATA_NOT_AVAILABLE == result_code) && - (message[strings::msg_params].length() > 1)); + !incoming_msg_params.empty()); - if (true == - message[strings::msg_params].keyExists(hmi_response::method)) { - message[strings::msg_params].erase(hmi_response::method); + if (incoming_msg_params.keyExists(hmi_response::method)) { + incoming_msg_params.erase(hmi_response::method); } if (true == message[strings::params].keyExists(strings::error_msg)) { response_info = message[strings::params][strings::error_msg].asString(); @@ -132,7 +143,7 @@ void GetVehicleDataRequest::on_event(const event_engine::Event& event) { SendResponse(result, MessageHelper::HMIToMobileResult(result_code), response_info.empty() ? NULL : response_info.c_str(), - &(message[strings::msg_params])); + &incoming_msg_params); break; } default: { diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc index f8553c84f8..e1a19ff5f6 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc @@ -68,13 +68,20 @@ void OnVehicleDataNotification::Run() { std::vector<smart_objects::SmartObject> appSO; const VehicleData& vehicle_data = MessageHelper::vehicle_data(); + const smart_objects::SmartObject& incoming_msg_params = + (*message_)[strings::msg_params]; VehicleData::const_iterator it = vehicle_data.begin(); for (; vehicle_data.end() != it; ++it) { - if (true == (*message_)[strings::msg_params].keyExists(it->first)) { + const std::string& key = it->first; + if (incoming_msg_params.keyExists(key)) { + if (strings::gps == key && incoming_msg_params[key].empty()) { + LOG4CXX_ERROR(logger_, "Invalid response received from system"); + continue; + } + LOG4CXX_ERROR(logger_, "vehicle_data nanme" << it->first); - auto vehicle_data_value = - (*message_)[strings::msg_params][it->first].asInt(); + auto vehicle_data_value = incoming_msg_params[key].asInt(); application_manager_.IviInfoUpdated(it->second, vehicle_data_value); @@ -104,12 +111,12 @@ void OnVehicleDataNotification::Run() { appNotification.push_back(app); smart_objects::SmartObject msg_param = smart_objects::SmartObject(smart_objects::SmartType_Map); - msg_param[it->first] = (*message_)[strings::msg_params][it->first]; + msg_param[key] = incoming_msg_params[key]; appSO.push_back(msg_param); } else { size_t idx = std::distance(appNotification.begin(), appNotification_it); - appSO[idx][it->first] = (*message_)[strings::msg_params][it->first]; + appSO[idx][key] = incoming_msg_params[key]; } } } diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 386bfe4825..951f2529a1 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -1949,7 +1949,7 @@ bool ApplicationManagerImpl::Stop() { application_list_update_timer_.Stop(); try { SetUnregisterAllApplicationsReason( - mobile_api::AppInterfaceUnregisteredReason::IGNITION_OFF); + mobile_api::AppInterfaceUnregisteredReason::IGNITION_OFF); UnregisterAllApplications(); } catch (...) { LOG4CXX_ERROR(logger_, |