summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYana Chernysheva (GitHub) <59469418+ychernysheva@users.noreply.github.com>2020-04-22 16:55:51 +0300
committerGitHub <noreply@github.com>2020-04-22 09:55:51 -0400
commit6ce1872b62ab097b4b249f569dc2742cf270a5fd (patch)
tree0b5f6953e5ed9606f095625c6d83d4e88180c0f6
parenta34275c507f95eb82d611abde4015ce504286801 (diff)
downloadsdl_core-6ce1872b62ab097b4b249f569dc2742cf270a5fd.tar.gz
Fix result code generic error while subscribing to vehicle data (#3264)
* Fix iteration on set with possible erase * Add and process set with skiped result codes * fixup! Add and process set with skiped result codes * fixup! Add and process set with skiped result codes
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h5
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc38
2 files changed, 31 insertions, 12 deletions
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h
index deac8a8295..663e64f2a0 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h
@@ -108,9 +108,8 @@ class SubscribeVehicleDataRequest
* @param app Pointer to application sent subscribe request
* @param msg_params 'message_parameters' response section reference
*/
- bool SubscribePendingVehicleData(
- app_mngr::ApplicationSharedPtr app,
- const smart_objects::SmartObject& msg_params);
+ bool SubscribePendingVehicleData(app_mngr::ApplicationSharedPtr app,
+ smart_objects::SmartObject& msg_params);
/**
* @brief Checks if current application and other applications
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc
index b125a7de7d..36d972d5fd 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc
@@ -36,6 +36,8 @@
#include "utils/helpers.h"
#include "vehicle_info_plugin/vehicle_info_app_extension.h"
+namespace VD_ResultCode = hmi_apis::Common_VehicleDataResultCode;
+
namespace vehicle_info_plugin {
using namespace application_manager;
namespace commands {
@@ -189,9 +191,8 @@ bool SubscribeVehicleDataRequest::CheckSubscriptionStatus(
}
auto res_code = msg_params[vi_name][strings::result_code].asInt();
- if (hmi_apis::Common_VehicleDataResultCode::VDRC_SUCCESS != res_code &&
- hmi_apis::Common_VehicleDataResultCode::VDRC_DATA_ALREADY_SUBSCRIBED !=
- res_code) {
+ if (VD_ResultCode::VDRC_SUCCESS != res_code &&
+ VD_ResultCode::VDRC_DATA_ALREADY_SUBSCRIBED != res_code) {
LOG4CXX_WARN(logger_,
"Subscription to " << vi_name << " for " << connection_key()
<< " failed.");
@@ -201,20 +202,39 @@ bool SubscribeVehicleDataRequest::CheckSubscriptionStatus(
}
bool SubscribeVehicleDataRequest::SubscribePendingVehicleData(
- ApplicationSharedPtr app, const smart_objects::SmartObject& msg_params) {
+ ApplicationSharedPtr app, smart_objects::SmartObject& msg_params) {
LOG4CXX_DEBUG(logger_, "Subscribing to all pending VehicleData");
- for (const auto& vi_name : vi_waiting_for_subscribe_) {
+ std::set<hmi_apis::Common_VehicleDataResultCode::eType> skiped_result_codes(
+ {VD_ResultCode::VDRC_TRUNCATED_DATA,
+ VD_ResultCode::VDRC_DISALLOWED,
+ VD_ResultCode::VDRC_USER_DISALLOWED,
+ VD_ResultCode::VDRC_INVALID_ID,
+ VD_ResultCode::VDRC_DATA_NOT_AVAILABLE,
+ VD_ResultCode::VDRC_DATA_NOT_SUBSCRIBED,
+ VD_ResultCode::VDRC_IGNORED});
+
+ for (auto vi_name = vi_waiting_for_subscribe_.begin();
+ vi_name != vi_waiting_for_subscribe_.end();) {
const bool is_subscription_successful = CheckSubscriptionStatus(
- ConvertRequestToResponseName(vi_name), msg_params);
+ ConvertRequestToResponseName(*vi_name), msg_params);
if (is_subscription_successful) {
auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app);
- ext.subscribeToVehicleInfo(vi_name);
- vi_waiting_for_subscribe_.erase(vi_name);
+ ext.subscribeToVehicleInfo(*vi_name);
+ vi_name = vi_waiting_for_subscribe_.erase(vi_name);
+ } else {
+ auto res_code =
+ static_cast<hmi_apis::Common_VehicleDataResultCode::eType>(
+ msg_params[*vi_name][strings::result_code].asInt());
+ if (skiped_result_codes.find(res_code) != skiped_result_codes.end()) {
+ msg_params[*vi_name][strings::result_code] = res_code;
+ vi_name = vi_waiting_for_subscribe_.erase(vi_name);
+ } else {
+ ++vi_name;
+ }
}
}
-
return vi_waiting_for_subscribe_.empty();
}