From 9ee67118478f2b3ad8ac3504762ad70400ce109f Mon Sep 17 00:00:00 2001 From: Alexander Kutsan Date: Mon, 27 Nov 2017 18:24:02 +0200 Subject: Use VehicleDataType from MOBILE APi xml imstead of hardcoded values Delete include of application_manager/vehicle_info_data.h Fix unit tests --- .../application_manager/src/application_impl.cc | 14 ++-- .../src/application_manager_impl.cc | 4 +- .../hmi/on_vi_vehicle_data_notification.cc | 5 +- .../mobile/subscribe_vehicle_data_request.cc | 2 +- .../mobile/unsubscribe_vehicle_data_request.cc | 2 +- .../src/message_helper/message_helper.cc | 77 ++++++++++++++-------- .../src/resumption/resume_ctrl_impl.cc | 5 +- .../src/resumption/resumption_data.cc | 1 - 8 files changed, 69 insertions(+), 41 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 4a752febf8..569880bb56 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -720,19 +720,23 @@ bool ApplicationImpl::UnsubscribeFromButton( bool ApplicationImpl::SubscribeToIVI(uint32_t vehicle_info_type) { sync_primitives::AutoLock lock(vi_lock_); - return subscribed_vehicle_info_.insert(vehicle_info_type).second; + return subscribed_vehicle_info_ + .insert( + static_cast(vehicle_info_type)) + .second; } bool ApplicationImpl::IsSubscribedToIVI(uint32_t vehicle_info_type) const { sync_primitives::AutoLock lock(vi_lock_); - VehicleInfoSubscriptions::const_iterator it = - subscribed_vehicle_info_.find(vehicle_info_type); + VehicleInfoSubscriptions::const_iterator it = subscribed_vehicle_info_.find( + static_cast(vehicle_info_type)); return (subscribed_vehicle_info_.end() != it); } bool ApplicationImpl::UnsubscribeFromIVI(uint32_t vehicle_info_type) { sync_primitives::AutoLock lock(vi_lock_); - return subscribed_vehicle_info_.erase(vehicle_info_type); + return subscribed_vehicle_info_.erase( + static_cast(vehicle_info_type)); } UsageStatistics& ApplicationImpl::usage_report() { @@ -1045,7 +1049,7 @@ void ApplicationImpl::set_hmi_level( usage_report_.RecordHmiStateChanged(new_hmi_level); } -const std::set& ApplicationImpl::SubscribesIVI() const { +const VehicleInfoSubscriptions& ApplicationImpl::SubscribesIVI() const { return subscribed_vehicle_info_; } diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 9814b4cff8..a2cba5198e 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -354,11 +354,11 @@ struct IsApplication { }; std::vector ApplicationManagerImpl::IviInfoUpdated( - VehicleDataType vehicle_info, int value) { + mobile_apis::VehicleDataType::eType vehicle_info, int value) { // Notify Policy Manager if available about info it's interested in, // i.e. odometer etc switch (vehicle_info) { - case ODOMETER: + case mobile_apis::VehicleDataType::VEHICLEDATA_ODOMETER: GetPolicyHandler().KmsChanged(value); break; default: diff --git a/src/components/application_manager/src/commands/hmi/on_vi_vehicle_data_notification.cc b/src/components/application_manager/src/commands/hmi/on_vi_vehicle_data_notification.cc index 5383876714..bba7e2f3ff 100644 --- a/src/components/application_manager/src/commands/hmi/on_vi_vehicle_data_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_vi_vehicle_data_notification.cc @@ -53,8 +53,9 @@ void OnVIVehicleDataNotification::Run() { const smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; if (msg_params.keyExists(strings::odometer)) { - application_manager_.IviInfoUpdated(ODOMETER, - msg_params[strings::odometer].asInt()); + application_manager_.IviInfoUpdated( + mobile_apis::VehicleDataType::VEHICLEDATA_ODOMETER, + msg_params[strings::odometer].asInt()); } SendNotificationToMobile(message_); 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 f4b7e7c8aa..f529e271b4 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 @@ -376,7 +376,7 @@ void SubscribeVehicleDataRequest::CheckVISubscribtions( ++items_to_subscribe; } if (!is_interface_not_available && is_key_enabled) { - VehicleDataType key_type = it->second; + mobile_apis::VehicleDataType::eType key_type = it->second; if (app->IsSubscribedToIVI(key_type)) { LOG4CXX_DEBUG(logger_, "App with connection key " 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 037c3fa4a4..f7317d72f9 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 @@ -134,7 +134,7 @@ void UnsubscribeVehicleDataRequest::Run() { if (is_key_enabled) { ++items_to_unsubscribe; - VehicleDataType key_type = it->second; + mobile_apis::VehicleDataType::eType key_type = it->second; if (!app->IsSubscribedToIVI(key_type)) { ++unsubscribed_items; vi_already_unsubscribed_by_this_app_.insert(key_type); diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index 65f4c79fa6..cf64152315 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -158,37 +158,60 @@ struct ExternalConsentStatusAppender } // namespace -std::pair kVehicleDataInitializer[] = { - std::make_pair(strings::gps, GPS), - std::make_pair(strings::speed, SPEED), - std::make_pair(strings::rpm, RPM), - std::make_pair(strings::fuel_level, FUELLEVEL), - std::make_pair(strings::fuel_level_state, FUELLEVEL_STATE), - std::make_pair(strings::instant_fuel_consumption, FUELCONSUMPTION), - std::make_pair(strings::external_temp, EXTERNTEMP), - std::make_pair(strings::vin, VIN), - std::make_pair(strings::prndl, PRNDL), - std::make_pair(strings::tire_pressure, TIREPRESSURE), - std::make_pair(strings::odometer, ODOMETER), - std::make_pair(strings::belt_status, BELTSTATUS), - std::make_pair(strings::body_information, BODYINFO), - std::make_pair(strings::device_status, DEVICESTATUS), - std::make_pair(strings::driver_braking, BRAKING), - std::make_pair(strings::wiper_status, WIPERSTATUS), - std::make_pair(strings::head_lamp_status, HEADLAMPSTATUS), - std::make_pair(strings::e_call_info, ECALLINFO), - std::make_pair(strings::airbag_status, AIRBAGSTATUS), - std::make_pair(strings::emergency_event, EMERGENCYEVENT), - std::make_pair(strings::cluster_mode_status, CLUSTERMODESTATUS), - std::make_pair(strings::my_key, MYKEY), +std::pair kVehicleDataInitializer[] = { + std::make_pair(strings::gps, mobile_apis::VehicleDataType::VEHICLEDATA_GPS), + std::make_pair(strings::speed, + mobile_apis::VehicleDataType::VEHICLEDATA_SPEED), + std::make_pair(strings::rpm, mobile_apis::VehicleDataType::VEHICLEDATA_RPM), + std::make_pair(strings::fuel_level, + mobile_apis::VehicleDataType::VEHICLEDATA_FUELLEVEL), + std::make_pair(strings::fuel_level_state, + mobile_apis::VehicleDataType::VEHICLEDATA_FUELLEVEL_STATE), + std::make_pair(strings::instant_fuel_consumption, + mobile_apis::VehicleDataType::VEHICLEDATA_FUELCONSUMPTION), + std::make_pair(strings::external_temp, + mobile_apis::VehicleDataType::VEHICLEDATA_EXTERNTEMP), + std::make_pair(strings::vin, mobile_apis::VehicleDataType::VEHICLEDATA_VIN), + std::make_pair(strings::prndl, + mobile_apis::VehicleDataType::VEHICLEDATA_PRNDL), + std::make_pair(strings::tire_pressure, + mobile_apis::VehicleDataType::VEHICLEDATA_TIREPRESSURE), + std::make_pair(strings::odometer, + mobile_apis::VehicleDataType::VEHICLEDATA_ODOMETER), + std::make_pair(strings::belt_status, + mobile_apis::VehicleDataType::VEHICLEDATA_BELTSTATUS), + std::make_pair(strings::body_information, + mobile_apis::VehicleDataType::VEHICLEDATA_BODYINFO), + std::make_pair(strings::device_status, + mobile_apis::VehicleDataType::VEHICLEDATA_DEVICESTATUS), + std::make_pair(strings::driver_braking, + mobile_apis::VehicleDataType::VEHICLEDATA_BRAKING), + std::make_pair(strings::wiper_status, + mobile_apis::VehicleDataType::VEHICLEDATA_WIPERSTATUS), + std::make_pair(strings::head_lamp_status, + mobile_apis::VehicleDataType::VEHICLEDATA_HEADLAMPSTATUS), + std::make_pair(strings::e_call_info, + mobile_apis::VehicleDataType::VEHICLEDATA_ECALLINFO), + std::make_pair(strings::airbag_status, + mobile_apis::VehicleDataType::VEHICLEDATA_AIRBAGSTATUS), + std::make_pair(strings::emergency_event, + mobile_apis::VehicleDataType::VEHICLEDATA_EMERGENCYEVENT), + std::make_pair(strings::cluster_mode_status, + mobile_apis::VehicleDataType::VEHICLEDATA_CLUSTERMODESTATUS), + std::make_pair(strings::my_key, + mobile_apis::VehicleDataType::VEHICLEDATA_MYKEY), /* NOT DEFINED in mobile API std::make_pair(strings::gps, BATTVOLTAGE), */ - std::make_pair(strings::engine_torque, ENGINETORQUE), - std::make_pair(strings::acc_pedal_pos, ACCPEDAL), - std::make_pair(strings::steering_wheel_angle, STEERINGWHEEL), + std::make_pair(strings::engine_torque, + mobile_apis::VehicleDataType::VEHICLEDATA_ENGINETORQUE), + std::make_pair(strings::acc_pedal_pos, + mobile_apis::VehicleDataType::VEHICLEDATA_ACCPEDAL), + std::make_pair(strings::steering_wheel_angle, + mobile_apis::VehicleDataType::VEHICLEDATA_STEERINGWHEEL), }; const VehicleData MessageHelper::vehicle_data_( @@ -829,7 +852,7 @@ smart_objects::SmartObjectList MessageHelper::GetIVISubscriptionRequests( const VehicleInfoSubscriptions& subscriptions = vi_accessor.GetData(); for (; vehicle_data.end() != ivi_it; ++ivi_it) { - uint32_t type_id = static_cast(ivi_it->second); + mobile_apis::VehicleDataType::eType type_id = ivi_it->second; if (subscriptions.end() != subscriptions.find(type_id)) { std::string key_name = ivi_it->first; msg_params[key_name] = true; diff --git a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc index e7788bf9ff..c8740227df 100644 --- a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc +++ b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc @@ -609,9 +609,10 @@ void ResumeCtrlImpl::AddSubscriptions( if (subscribtions.keyExists(strings::application_vehicle_info)) { const smart_objects::SmartObject& subscribtions_ivi = subscribtions[strings::application_vehicle_info]; - VehicleDataType ivi; + mobile_apis::VehicleDataType::eType ivi; for (size_t i = 0; i < subscribtions_ivi.length(); ++i) { - ivi = static_cast((subscribtions_ivi[i]).asInt()); + ivi = static_cast( + (subscribtions_ivi[i]).asInt()); application->SubscribeToIVI(ivi); } ProcessHMIRequests(MessageHelper::GetIVISubscriptionRequests( diff --git a/src/components/application_manager/src/resumption/resumption_data.cc b/src/components/application_manager/src/resumption/resumption_data.cc index 273cd5413e..bd5bdbddab 100644 --- a/src/components/application_manager/src/resumption/resumption_data.cc +++ b/src/components/application_manager/src/resumption/resumption_data.cc @@ -33,7 +33,6 @@ #include "application_manager/resumption/resumption_data.h" #include "utils/logger.h" #include "application_manager/smart_object_keys.h" -#include "application_manager/vehicle_info_data.h" #include "application_manager/application_manager_settings.h" namespace resumption { -- cgit v1.2.1