summaryrefslogtreecommitdiff
path: root/src/components/application_manager
diff options
context:
space:
mode:
authorAlexander Kutsan (GitHub) <akutsan@luxoft.com>2019-08-30 21:10:04 +0300
committerJacob Keeler <jacob.keeler@livioradio.com>2019-08-30 14:10:04 -0400
commit0186b8c46584aa86e96f0bfa8c38e735c3f0ac0a (patch)
tree88bb8aa0c100284fb4dfb838ebc6cf0903123035 /src/components/application_manager
parent4566d5196109591fd3cc515826ecfc725c95c79b (diff)
downloadsdl_core-0186b8c46584aa86e96f0bfa8c38e735c3f0ac0a.tar.gz
[SDL 0173] - Read Generic Network Signal Data Implementation (#2977)
* Generate policy enums from MOBILE_API Policy manager HMI level enum reorder * Add RPC vehicle data and endpoint_properties to sdl_preloaded_pt Set default version of custom vehicle data mapping * Add VehicleDataItem to policy table SQL storage implementation for VehicleDataItems Fix validation of double values in policy table Change isDouble to isNumeric during validation double values "0" should be validated as correct double value Add validation vehicle data during PTU Send in PT snapshot only version of custom VDI - During snapshot generation remove vehicle data items section - Add validation for Policy table depended on PT type Fix wrong check for vehicle data snapshot Allow empty vehicle data in PTU Change max value of string for URL from 255 to INT_MAX * Make Policy Handler forward declared to avoid high coupling * Add vehicle_info_command_params for vehicle info plugin Vehicle info params added to hmi commands * Process CustomVehicleData in GetVehicleData request * CustomVehicleDataManager implementation * Process Custom vehicle data subscriptions Refactored code. Extracted CheckFrequency to separate method in class * Check update of content of functional groups Fixes https://github.com/smartdevicelink/sdl_core/issues/2962 Add additional check for functional group content before OnPermissionChangeNotification. * rename comparing functions to make more clear their return value sense * change variable names * extra check for null values in HasNewGroups() New unit test to cover changes within functional group * Add GetPolicyConfigurationData GetPolicyCOnfigurationData Implementation * Add CustomVehicleData functionality for POLICY_EXTERNAL flow Change max value url for external policy fixes for external flow * since unti validation for the database * empty vehicle data validation * Convert data_type to VehicleDataType enum value * Validation of VehicleDataItem name and key Introduces validation of vehicle_data_item name and key validation: * they should not contain spaces; * they should not be empty or consist only spaces; * they should not contain invalid chars like '!@#$%^&*'. * Add engineOilLife to HMI_API * Remove deprecated RPC GetUrls due to major version update * Add ability to extend Smart schema with parameters Extract SMember from CObjectSchemaItem Add methods to ISchemaItem (Using composite pattern) - GetMemberSchemaItem - AddMemberSchemaItem Add implementation of VehicleDataItemSchema class Add appropriate unit tests Add creation of vehicle_data items schemes on policy event
Diffstat (limited to 'src/components/application_manager')
-rw-r--r--src/components/application_manager/CMakeLists.txt3
-rw-r--r--src/components/application_manager/include/application_manager/application_manager_impl.h3
-rw-r--r--src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin.h5
-rw-r--r--src/components/application_manager/include/application_manager/policies/custom_vehicle_data_provider.h25
-rw-r--r--src/components/application_manager/include/application_manager/policies/policy_handler.h19
-rw-r--r--src/components/application_manager/include/application_manager/rpc_handler_impl.h8
-rw-r--r--src/components/application_manager/include/application_manager/rpc_service_impl.h19
-rw-r--r--src/components/application_manager/include/application_manager/smart_object_keys.h4
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_hmi_command_factory.h1
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_mobile_command_factory.h1
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc6
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_policy_configuration_data_request.h (renamed from src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_urls.h)58
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_policy_configuration_data_response.h (renamed from src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_urls_response.h)34
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_response.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_urls.cc230
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_device_state_changed_notification.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_driver_distraction_notification.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ignition_cycle_over_notification.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_policy_update.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_received_policy_update.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_error_notification.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_info_changed_notification.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_command_notification.cc2
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_list_of_permissions_request.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_policy_configuration_data_request.cc156
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_policy_configuration_data_response.cc (renamed from src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_urls_response.cc)13
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_status_update_request.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_request.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_sdl_request.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_request.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_cloud_app_properties_request.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloud_app_properties_request.cc3
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc16
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc4
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_urls_response_test.cc88
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_urls_test.cc338
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_policy_configuration_data_request_test.cc180
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/on_vi_vehicle_data_notification.h6
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_diagnostic_message_request.h6
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_diagnostic_message_response.h6
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_dtcs_request.h6
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_dtcs_response.h6
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_request.h9
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_response.h6
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_type_request.h6
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_type_response.h9
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_is_ready_request.h6
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_is_ready_response.h6
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_read_did_request.h6
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_read_did_response.h6
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_subscribe_vehicle_data_request.h9
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_subscribe_vehicle_data_response.h6
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_unsubscribe_vehicle_data_request.h9
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_unsubscribe_vehicle_data_response.h6
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/diagnostic_message_request.h6
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/diagnostic_message_response.h6
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_dtcs_request.h6
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_dtcs_response.h6
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_vehicle_data_request.h20
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_vehicle_data_response.h7
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/on_vehicle_data_notification.h9
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/read_did_request.h7
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/read_did_response.h7
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h56
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_response.h7
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_request.h62
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_response.h7
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/custom_vehicle_data_manager.h44
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/custom_vehicle_data_manager_impl.h97
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_data_item_schema.h115
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_app_extension.h8
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_command_factory.h29
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_command_params.h31
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_hmi_command_factory.h6
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_mobile_command_factory.h7
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_plugin.h2
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/on_vi_vehicle_data_notification.cc18
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_diagnostic_message_request.cc15
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_diagnostic_message_response.cc13
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_dtcs_request.cc13
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_dtcs_response.cc13
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_data_request.cc34
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_data_response.cc15
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_type_request.cc13
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_type_response.cc13
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_is_ready_request.cc16
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_is_ready_response.cc13
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_read_did_request.cc13
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_read_did_response.cc13
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_subscribe_vehicle_data_request.cc34
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_subscribe_vehicle_data_response.cc13
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_unsubscribe_vehicle_data_request.cc34
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_unsubscribe_vehicle_data_response.cc13
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/diagnostic_message_request.cc13
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/diagnostic_message_response.cc13
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_dtcs_request.cc13
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_dtcs_response.cc13
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_request.cc95
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_response.cc13
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc110
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/read_did_request.cc13
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/read_did_response.cc13
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc354
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_response.cc13
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_request.cc304
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_response.cc13
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/custom_vehicle_data_manager_impl.cc531
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_data_item_schema.cc184
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_app_extension.cc21
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_command_factory.cc22
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_hmi_command_factory.cc75
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc99
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_plugin.cc34
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/CMakeLists.txt25
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_get_vehicle_data_request_test.cc110
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_get_vehicle_data_response_test.cc8
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_is_ready_request_test.cc6
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_subscribe_vehicle_data_request_test.cc110
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_unsubscribe_vehicle_data_request_test.cc109
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/diagnostic_message_request_test.cc16
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_dtcs_request_test.cc15
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_vehicle_data_request_test.cc55
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_vehicle_data_response_test.cc6
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/on_vehicle_data_notification_test.cc65
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/read_did_request_test.cc17
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/unsubscribe_vehicle_request_test.cc92
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/unsubscribe_vehicle_response_test.cc14
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/custom_vehicle_data_manager_test.cc316
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/commands/vi_command_request_test.h99
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/commands/vi_commands_test.h104
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/mock_custom_vehicle_data_manager.h22
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/vehicle_data_item_schema_test.cc395
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc26
-rw-r--r--src/components/application_manager/src/commands/command_request_impl.cc75
-rw-r--r--src/components/application_manager/src/hmi_interfaces_impl.cc1
-rw-r--r--src/components/application_manager/src/message_helper/message_helper.cc3
-rw-r--r--src/components/application_manager/src/policies/policy_handler.cc11
-rw-r--r--src/components/application_manager/src/rpc_handler_impl.cc23
-rw-r--r--src/components/application_manager/src/rpc_passing_handler.cc3
-rw-r--r--src/components/application_manager/src/rpc_service_impl.cc38
-rw-r--r--src/components/application_manager/src/smart_object_keys.cc4
-rwxr-xr-xsrc/components/application_manager/test/CMakeLists.txt1
-rw-r--r--src/components/application_manager/test/commands/command_request_impl_test.cc20
-rw-r--r--src/components/application_manager/test/include/application_manager/commands/commands_test.h6
-rw-r--r--src/components/application_manager/test/policy_handler_test.cc10
147 files changed, 4193 insertions, 1745 deletions
diff --git a/src/components/application_manager/CMakeLists.txt b/src/components/application_manager/CMakeLists.txt
index 625e119270..c7f2aede9a 100644
--- a/src/components/application_manager/CMakeLists.txt
+++ b/src/components/application_manager/CMakeLists.txt
@@ -142,6 +142,7 @@ set(LIBRARIES
formatters
dbms
Utils
+ policy_struct
bson -L${BSON_LIBS_DIRECTORY}
emhashmap -L${EMHASHMAP_LIBS_DIRECTORY}
)
@@ -159,7 +160,7 @@ add_library("AMEventEngine" ${EVENT_ENGINE_SOURCES})
target_link_libraries("AMEventEngine" ${LIBRARIES})
add_library("AMPolicyLibrary" ${POLICIES_MANAGER_SOURCES} )
-target_link_libraries("AMPolicyLibrary" ${LIBRARIES} AMEventEngine)
+target_link_libraries("AMPolicyLibrary" ${LIBRARIES} AMEventEngine policy_struct)
add_library("SystemTimeLibrary" ${SYSTEM_TIME_SOURCES})
target_link_libraries("SystemTimeLibrary" ${LIBRARIES} AMEventEngine)
diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h
index 702f7a9a4d..59df2430f9 100644
--- a/src/components/application_manager/include/application_manager/application_manager_impl.h
+++ b/src/components/application_manager/include/application_manager/application_manager_impl.h
@@ -289,8 +289,7 @@ class ApplicationManagerImpl
* @param vehicle_info Enum value of type of vehicle data
* @param new value (for integer values currently) of vehicle data
*/
- void IviInfoUpdated(mobile_apis::VehicleDataType::eType vehicle_info,
- int value) OVERRIDE;
+ void IviInfoUpdated(const std::string& vehicle_info, int value) OVERRIDE;
void OnApplicationRegistered(ApplicationSharedPtr app) OVERRIDE;
diff --git a/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin.h b/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin.h
index c3b0d67d67..c36f560ed5 100644
--- a/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin.h
+++ b/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin.h
@@ -36,10 +36,13 @@
#include "application_manager/application.h"
#include "application_manager/commands/command.h"
#include "application_manager/hmi_capabilities.h"
-#include "application_manager/policies/policy_handler_interface.h"
#include "application_manager/rpc_service.h"
#include "utils/macro.h"
+namespace policy {
+class PolicyHandlerInterface;
+}
+
namespace application_manager {
class CommandFactory;
diff --git a/src/components/application_manager/include/application_manager/policies/custom_vehicle_data_provider.h b/src/components/application_manager/include/application_manager/policies/custom_vehicle_data_provider.h
new file mode 100644
index 0000000000..edd0a29c48
--- /dev/null
+++ b/src/components/application_manager/include/application_manager/policies/custom_vehicle_data_provider.h
@@ -0,0 +1,25 @@
+#ifndef CUSTOM_VEHICLE_DATA_PROVIDER_H
+#define CUSTOM_VEHICLE_DATA_PROVIDER_H
+
+#include <vector>
+
+namespace rpc {
+namespace policy_table_interface_base {
+struct VehicleDataItem;
+}
+} // namespace rpc
+
+namespace policy {
+
+class VehicleDataItemProvider {
+ public:
+ /**
+ * @brief Gets vehicle data items
+ * @return Structure with vehicle data items
+ */
+ virtual const std::vector<rpc::policy_table_interface_base::VehicleDataItem>
+ GetVehicleDataItems() const = 0;
+};
+} // namespace policy
+
+#endif // CUSTOM_VEHICLE_DATA_PROVIDER_H
diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h
index 5ddac88dd9..141c679aad 100644
--- a/src/components/application_manager/include/application_manager/policies/policy_handler.h
+++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h
@@ -45,6 +45,8 @@
#include "application_manager/policies/policy_event_observer.h"
#include "application_manager/policies/policy_handler_interface.h"
#include "application_manager/policies/policy_handler_observer.h"
+
+#include "application_manager/policies/custom_vehicle_data_provider.h"
#include "policy/policy_manager.h"
#include "policy/policy_settings.h"
#include "policy/usage_statistics/statistics_manager.h"
@@ -122,6 +124,8 @@ class PolicyHandler : public PolicyHandlerInterface,
virtual DeviceConsent GetUserConsentForDevice(
const std::string& device_id) const OVERRIDE;
+ Json::Value GetPolicyTableData() const OVERRIDE;
+
/**
* @brief Sets HMI default type for specified application
* @param device_handle device identifier
@@ -646,12 +650,6 @@ class PolicyHandler : public PolicyHandlerInterface,
const std::vector<std::string> GetAppRequestSubTypes(
const std::string& policy_app_id) const OVERRIDE;
- /**
- * @brief Gets vehicle information
- * @return Structure with vehicle information
- */
- const VehicleInfo GetVehicleInfo() const OVERRIDE;
-
#ifdef EXTERNAL_PROPRIETARY_MODE
/**
* @brief Gets meta information
@@ -696,6 +694,14 @@ class PolicyHandler : public PolicyHandlerInterface,
void OnDeviceSwitching(const std::string& device_id_from,
const std::string& device_id_to) FINAL;
+ // VehicleDataItemProvider interface :
+ /**
+ * @brief Gets vehicle data items
+ * @return Structure with vehicle data items
+ */
+ const std::vector<rpc::policy_table_interface_base::VehicleDataItem>
+ GetVehicleDataItems() const OVERRIDE;
+
void OnLockScreenDismissalStateChanged() FINAL;
protected:
@@ -844,6 +850,7 @@ class PolicyHandler : public PolicyHandlerInterface,
std::vector<FunctionalGroupPermission> CollectAppPermissions(
const uint32_t connection_key);
+ private:
static const std::string kLibrary;
/**
diff --git a/src/components/application_manager/include/application_manager/rpc_handler_impl.h b/src/components/application_manager/include/application_manager/rpc_handler_impl.h
index 2909a38cf7..b1e94ab331 100644
--- a/src/components/application_manager/include/application_manager/rpc_handler_impl.h
+++ b/src/components/application_manager/include/application_manager/rpc_handler_impl.h
@@ -93,7 +93,9 @@ class RPCHandlerImpl : public RPCHandler,
public impl::FromMobileQueue::Handler,
public impl::FromHmiQueue::Handler {
public:
- RPCHandlerImpl(ApplicationManager& app_manager);
+ RPCHandlerImpl(ApplicationManager& app_manager,
+ hmi_apis::HMI_API& hmi_so_factory,
+ mobile_apis::MOBILE_API& mobile_so_factory);
~RPCHandlerImpl();
// CALLED ON messages_from_mobile_ thread!
@@ -177,8 +179,8 @@ class RPCHandlerImpl : public RPCHandler,
// Thread that pumps messages coming from HMI.
impl::FromHmiQueue messages_from_hmi_;
- hmi_apis::HMI_API hmi_so_factory_;
- mobile_apis::MOBILE_API mobile_so_factory_;
+ hmi_apis::HMI_API& hmi_so_factory_;
+ mobile_apis::MOBILE_API& mobile_so_factory_;
#ifdef TELEMETRY_MONITOR
AMTelemetryObserver* metric_observer_;
#endif // TELEMETRY_MONITOR
diff --git a/src/components/application_manager/include/application_manager/rpc_service_impl.h b/src/components/application_manager/include/application_manager/rpc_service_impl.h
index e32cdf42a2..ce3d1f1e22 100644
--- a/src/components/application_manager/include/application_manager/rpc_service_impl.h
+++ b/src/components/application_manager/include/application_manager/rpc_service_impl.h
@@ -113,7 +113,9 @@ class RPCServiceImpl : public RPCService,
protocol_handler::ProtocolHandler* protocol_handler,
hmi_message_handler::HMIMessageHandler* hmi_handler,
CommandHolder& commands_holder,
- RPCProtectionManagerSPtr rpc_protection_manager);
+ RPCProtectionManagerSPtr rpc_protection_manager,
+ hmi_apis::HMI_API& hmi_so_factory_,
+ mobile_apis::MOBILE_API& mobile_so_factory_);
~RPCServiceImpl();
bool ManageMobileCommand(const commands::MessageSharedPtr message,
@@ -132,13 +134,22 @@ class RPCServiceImpl : public RPCService,
void SendMessageToHMI(const commands::MessageSharedPtr message) OVERRIDE;
bool IsAppServiceRPC(int32_t function_id,
- commands::Command::CommandSource source);
+ commands::Command::CommandSource source) OVERRIDE;
void set_protocol_handler(
protocol_handler::ProtocolHandler* handler) OVERRIDE;
void set_hmi_message_handler(
hmi_message_handler::HMIMessageHandler* handler) OVERRIDE;
+ void UpdateMobileRPCParams(
+ const mobile_apis::FunctionID::eType& function_id,
+ const mobile_apis::messageType::eType& message_type,
+ const std::map<std::string, SMember>& members) OVERRIDE;
+ void UpdateHMIRPCParams(
+ const hmi_apis::FunctionID::eType& function_id,
+ const hmi_apis::messageType::eType& message_type,
+ const std::map<std::string, SMember>& members) OVERRIDE;
+
private:
bool ConvertSOtoMessage(const smart_objects::SmartObject& message,
Message& output,
@@ -165,8 +176,8 @@ class RPCServiceImpl : public RPCService,
// Thread that pumps messages being passed to HMI.
impl::ToHmiQueue messages_to_hmi_;
- hmi_apis::HMI_API hmi_so_factory_;
- mobile_apis::MOBILE_API mobile_so_factory_;
+ hmi_apis::HMI_API& hmi_so_factory_;
+ mobile_apis::MOBILE_API& mobile_so_factory_;
};
} // namespace rpc_service
} // namespace application_manager
diff --git a/src/components/application_manager/include/application_manager/smart_object_keys.h b/src/components/application_manager/include/application_manager/smart_object_keys.h
index b3ca00013a..d95432af4c 100644
--- a/src/components/application_manager/include/application_manager/smart_object_keys.h
+++ b/src/components/application_manager/include/application_manager/smart_object_keys.h
@@ -218,6 +218,8 @@ extern const char* is_cloud_application;
extern const char* cloud_connection_status;
extern const char* endpoint;
extern const char* display_capabilities;
+extern const char* policy_type;
+extern const char* property;
// PutFile
extern const char* sync_file_name;
@@ -307,6 +309,7 @@ extern const char* e_call_info;
extern const char* airbag_status;
extern const char* emergency_event;
extern const char* cluster_mode_status;
+extern const char* cluster_modes;
extern const char* my_key;
extern const char* help_prompt;
extern const char* scroll_message_body;
@@ -326,6 +329,7 @@ extern const char* sdl_version;
extern const char* system_software_version;
extern const char* priority;
extern const char* engine_oil_life;
+extern const char* oem_custom_data_type;
// app services
extern const char* app_service_manifest;
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_hmi_command_factory.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_hmi_command_factory.h
index c42b64f559..fd96bf0fb6 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_hmi_command_factory.h
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_hmi_command_factory.h
@@ -34,6 +34,7 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_APP_SERVICE_RPC_HMI_COMMAND_FACTORY_H
#include "application_manager/application_manager.h"
+#include "application_manager/command_factory.h"
namespace app_service_rpc_plugin {
namespace app_mngr = application_manager;
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_mobile_command_factory.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_mobile_command_factory.h
index bd1e10f267..a6300dbb3d 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_mobile_command_factory.h
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_mobile_command_factory.h
@@ -34,6 +34,7 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_APP_SERVICE_RPC_MOBILE_COMMAND_FACTORY_H
#include "application_manager/application_manager.h"
+#include "application_manager/command_factory.h"
namespace app_service_rpc_plugin {
namespace app_mngr = application_manager;
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc
index 065425dd02..4088a25ed5 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc
@@ -33,6 +33,7 @@
#include "rc_rpc_plugin/commands/rc_command_request.h"
#include "application_manager/hmi_interfaces.h"
#include "application_manager/message_helper.h"
+#include "application_manager/policies/policy_handler_interface.h"
#include "rc_rpc_plugin/interior_data_cache.h"
#include "rc_rpc_plugin/rc_module_constants.h"
#include "smart_objects/enum_schema_item.h"
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc
index c607721bbd..6e9502f5a3 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc
@@ -109,7 +109,9 @@ class RCGetInteriorVehicleDataConsentTest
&mock_protocol_handler,
&mock_hmi_handler,
command_holder,
- rpc_protection_manager_)
+ rpc_protection_manager_,
+ hmi_so_factory_,
+ mobile_so_factoy_)
, rc_app_extention_(std::make_shared<RCAppExtension>(kPluginID))
, mock_rpc_plugin_manager(
std::make_shared<NiceMock<MockRPCPluginManager> >())
@@ -203,6 +205,8 @@ class RCGetInteriorVehicleDataConsentTest
mock_rpc_plugin_manager;
utils::Optional<RPCPlugin> rpc_plugin;
utils::Optional<MockRPCPlugin> optional_mock_rpc_plugin;
+ hmi_apis::HMI_API hmi_so_factory_;
+ mobile_apis::MOBILE_API mobile_so_factoy_;
};
TEST_F(RCGetInteriorVehicleDataConsentTest,
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_urls.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_policy_configuration_data_request.h
index c3f7453583..043a4369c5 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_urls.h
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_policy_configuration_data_request.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Ford Motor Company
+ * Copyright (c) 2019, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,36 +30,38 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_URLS_H_
-#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_URLS_H_
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_POLICY_CONFIGURATION_DATA_REQUEST_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_POLICY_CONFIGURATION_DATA_REQUEST_H_
#include "application_manager/commands/request_from_hmi.h"
-#include "policy/policy_types.h"
-#include "smart_objects/smart_object.h"
namespace sdl_rpc_plugin {
namespace app_mngr = application_manager;
+
namespace commands {
+
/**
- * @brief GetUrls command class
+ * @brief SDLGetPolicyConfigurationDataRequest command class
**/
-class GetUrls : public app_mngr::commands::RequestFromHMI {
+class SDLGetPolicyConfigurationDataRequest
+ : public app_mngr::commands::RequestFromHMI {
public:
/**
- * @brief GetUrls class constructor
+ * @brief SDLGetPolicyConfigurationDataRequest class constructor
*
* @param message Incoming SmartObject message
**/
- GetUrls(const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle);
+ SDLGetPolicyConfigurationDataRequest(
+ const app_mngr::commands::MessageSharedPtr& message,
+ app_mngr::ApplicationManager& application_manager,
+ app_mngr::rpc_service::RPCService& rpc_service,
+ app_mngr::HMICapabilities& hmi_capabilities,
+ policy::PolicyHandlerInterface& policy_handle);
/**
- * @brief GetUrls class destructor
+ * @brief SDLGetPolicyConfigurationDataRequest class destructor
**/
- virtual ~GetUrls();
+ ~SDLGetPolicyConfigurationDataRequest() OVERRIDE;
/**
* @brief Execute command
@@ -67,30 +69,16 @@ class GetUrls : public app_mngr::commands::RequestFromHMI {
void Run() OVERRIDE;
private:
-#ifdef PROPRIETARY_MODE
- /**
- * @brief Processes URLs collecting for policy service
- * @param endpoints Endpoints section of policy table
- */
- void ProcessPolicyServiceURLs(const policy::EndpointUrls& endpoints);
-#endif // PROPRIETARY_MODE
+ hmi_apis::Common_Result::eType PrepareResponseParams(
+ smart_objects::SmartObject& response_out) const;
- /**
- * @brief Process URLs collecting for service
- * @param endpoints Endpoints section of policy table
- */
- void ProcessServiceURLs(const policy::EndpointUrls& endpoints);
-
- /**
- * @brief Sends response to HMI
- * @param result Result code
- */
- void SendResponseToHMI(hmi_apis::Common_Result::eType result);
+ smart_objects::SmartObject GetValueParam(
+ const Json::Value& policy_property) const;
- DISALLOW_COPY_AND_ASSIGN(GetUrls);
+ DISALLOW_COPY_AND_ASSIGN(SDLGetPolicyConfigurationDataRequest);
};
} // namespace commands
} // namespace sdl_rpc_plugin
-#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_URLS_H_
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_POLICY_CONFIGURATION_DATA_REQUEST_H_
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_urls_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_policy_configuration_data_response.h
index 06af3c6ea5..2c22f69281 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_urls_response.h
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_policy_configuration_data_response.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Ford Motor Company
+ * Copyright (c) 2019, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,32 +30,38 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_URLS_RESPONSE_H_
-#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_URLS_RESPONSE_H_
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_POLICY_CONFIGURATION_DATA_RESPONSE_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_POLICY_CONFIGURATION_DATA_RESPONSE_H_
#include "application_manager/commands/response_to_hmi.h"
namespace sdl_rpc_plugin {
namespace app_mngr = application_manager;
+
namespace commands {
-class GetUrlsResponse : public app_mngr::commands::ResponseToHMI {
+/**
+ * @brief SDLGetPolicyConfigurationDataResponse command class
+ **/
+class SDLGetPolicyConfigurationDataResponse
+ : public app_mngr::commands::ResponseToHMI {
public:
/**
- * @brief GetUrlsResponse class constructor
+ * @brief SDLGetPolicyConfigurationDataResponse class constructor
*
* @param message Incoming SmartObject message
**/
- GetUrlsResponse(const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle);
+ SDLGetPolicyConfigurationDataResponse(
+ const app_mngr::commands::MessageSharedPtr& message,
+ app_mngr::ApplicationManager& application_manager,
+ app_mngr::rpc_service::RPCService& rpc_service,
+ app_mngr::HMICapabilities& hmi_capabilities,
+ policy::PolicyHandlerInterface& policy_handle);
/**
- * @brief GetUrlsResponse class destructor
+ * @brief SDLGetPolicyConfigurationDataResponse class destructor
**/
- virtual ~GetUrlsResponse();
+ virtual ~SDLGetPolicyConfigurationDataResponse();
/**
* @brief Execute command
@@ -63,10 +69,10 @@ class GetUrlsResponse : public app_mngr::commands::ResponseToHMI {
virtual void Run();
private:
- DISALLOW_COPY_AND_ASSIGN(GetUrlsResponse);
+ DISALLOW_COPY_AND_ASSIGN(SDLGetPolicyConfigurationDataResponse);
};
} // namespace commands
} // namespace sdl_rpc_plugin
-#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_URLS_RESPONSE_H_
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_POLICY_CONFIGURATION_DATA_RESPONSE_H_
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_response.cc
index 3dbdf528a5..baff925a4e 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_response.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_response.cc
@@ -31,6 +31,7 @@
*/
#include "sdl_rpc_plugin/commands/hmi/get_system_info_response.h"
#include "application_manager/message_helper.h"
+#include "application_manager/policies/policy_handler_interface.h"
namespace sdl_rpc_plugin {
using namespace application_manager;
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_urls.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_urls.cc
deleted file mode 100644
index 54a9633a37..0000000000
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_urls.cc
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Copyright (c) 2018, Ford Motor Company
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of the Ford Motor Company nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "sdl_rpc_plugin/commands/hmi/get_urls.h"
-#include "application_manager/application_manager.h"
-#include "application_manager/message.h"
-#include "application_manager/policies/policy_handler.h"
-#include "application_manager/rpc_service.h"
-#include "utils/helpers.h"
-
-namespace sdl_rpc_plugin {
-using namespace application_manager;
-namespace commands {
-
-GetUrls::GetUrls(const application_manager::commands::MessageSharedPtr& message,
- ApplicationManager& application_manager,
- rpc_service::RPCService& rpc_service,
- HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle)
- : RequestFromHMI(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle) {}
-
-GetUrls::~GetUrls() {}
-
-void GetUrls::Run() {
- LOG4CXX_AUTO_TRACE(logger_);
- namespace Common_Result = hmi_apis::Common_Result;
- using policy::EndpointUrls;
-
- if (!policy_handler_.PolicyEnabled()) {
- SendResponseToHMI(Common_Result::DATA_NOT_AVAILABLE);
- return;
- }
-
- const uint32_t service_to_check =
- (*message_)[strings::msg_params][hmi_request::service].asUInt();
-
- EndpointUrls endpoints;
- policy_handler_.GetUpdateUrls(service_to_check, endpoints);
-
- if (endpoints.empty()) {
- LOG4CXX_ERROR(logger_, "No URLs for service " << service_to_check);
- SendResponseToHMI(Common_Result::DATA_NOT_AVAILABLE);
- return;
- }
-
-#ifdef PROPRIETARY_MODE
- const uint32_t policy_service = 7u;
-
- if (policy_service == service_to_check) {
- ProcessPolicyServiceURLs(endpoints);
- return;
- }
-#endif // PROPRIETARY_MODE
-
- ProcessServiceURLs(endpoints);
-}
-
-void GetUrls::ProcessServiceURLs(const policy::EndpointUrls& endpoints) {
- namespace Common_Result = hmi_apis::Common_Result;
- using smart_objects::SmartObject;
-
- (*message_)[strings::msg_params].erase(hmi_request::service);
- SmartObject& urls = (*message_)[strings::msg_params][hmi_response::urls];
-
- size_t index = 0;
- for (size_t e = 0; e < endpoints.size(); ++e) {
- ApplicationSharedPtr app =
- application_manager_.application_by_policy_id(endpoints[e].app_id);
-
-#ifndef PROPRIETARY_MODE
- bool registered_not_default = false;
- if (policy::kDefaultId != endpoints[e].app_id) {
- if (!app) {
- LOG4CXX_ERROR(logger_,
- "Can't find application with policy id "
- << endpoints[e].app_id
- << " URLs adding for this application is skipped.");
- continue;
- }
- registered_not_default = true;
- }
-#endif // EXTERNAL_PROPRIETARY_MODE || HTTP
- for (size_t u = 0; u < endpoints[e].url.size(); ++u, ++index) {
- const std::string& app_url = endpoints[e].url[u];
- SmartObject& service_info = urls[index];
-
- service_info[strings::url] = app_url;
-#ifndef PROPRIETARY_MODE
- if (registered_not_default) {
- service_info[strings::app_id] = app->hmi_app_id();
- }
-#else // EXTERNAL_PROPRIETARY_MODE || HTTP
- service_info[hmi_response::policy_app_id] = endpoints[e].app_id;
-#endif
- }
- }
- SendResponseToHMI(Common_Result::SUCCESS);
-}
-
-void GetUrls::SendResponseToHMI(hmi_apis::Common_Result::eType result) {
- (*message_)[strings::params][strings::message_type] = MessageType::kResponse;
- (*message_)[strings::params][hmi_response::code] = result;
- rpc_service_.ManageHMICommand(message_);
-}
-
-#ifdef PROPRIETARY_MODE
-struct PolicyAppIdComparator {
- PolicyAppIdComparator(const std::string& policy_app_id)
- : policy_app_id_(policy_app_id) {}
-
- bool operator()(const policy::EndpointData& data) {
- return data.app_id == policy_app_id_;
- }
- std::string policy_app_id_;
-};
-
-void FillSODefaultUrls(smart_objects::SmartObject& urls,
- const policy::EndpointUrls& endpoints) {
- using smart_objects::SmartObject;
- PolicyAppIdComparator comparator(policy::kDefaultId);
- policy::EndpointUrls::const_iterator it =
- std::find_if(endpoints.begin(), endpoints.end(), comparator);
- if (it == endpoints.end()) {
- return;
- }
- SmartObject service_info = SmartObject(smart_objects::SmartType_Map);
- for (size_t i = 0; i < (*it).url.size(); ++i) {
- service_info[strings::url] = (*it).url[i];
- urls[i] = service_info;
- }
-}
-
-void GetUrls::ProcessPolicyServiceURLs(const policy::EndpointUrls& endpoints) {
- LOG4CXX_AUTO_TRACE(logger_);
- using namespace smart_objects;
- using namespace application_manager;
- using namespace strings;
- using namespace hmi_apis;
-
- const uint32_t app_id_to_send_to = policy_handler_.GetAppIdForSending();
-
- if (!app_id_to_send_to) {
- LOG4CXX_ERROR(logger_,
- "There are no available applications for processing.");
- SmartObject urls(SmartType_Array);
- FillSODefaultUrls(urls, endpoints);
- if (!urls.empty()) {
- (*message_)[msg_params][hmi_response::urls] = urls;
- }
- (*message_).erase(hmi_request::service);
- SendResponseToHMI(Common_Result::SUCCESS);
- return;
- }
-
- ApplicationSharedPtr app =
- application_manager_.application(app_id_to_send_to);
-
- if (app.use_count() == 0) {
- LOG4CXX_WARN(logger_,
- "There is no registered application with "
- "connection key '"
- << app_id_to_send_to << "'");
- SendResponseToHMI(Common_Result::DATA_NOT_AVAILABLE);
- return;
- }
-
- SmartObject& object = *message_;
- object[msg_params].erase(hmi_request::service);
- object[msg_params][hmi_response::urls] = SmartObject(SmartType_Array);
- SmartObject& urls = object[msg_params][hmi_response::urls];
- const std::string mobile_app_id = app->policy_app_id();
-
- size_t index = 0;
- for (size_t i = 0; i < endpoints.size(); ++i) {
- using namespace helpers;
-
- const bool to_add = Compare<std::string, EQ, ONE>(
- endpoints[i].app_id, mobile_app_id, policy::kDefaultId);
- const bool is_default = policy::kDefaultId == endpoints[i].app_id;
-
- if (to_add) {
- for (size_t k = 0; k < endpoints[i].url.size(); ++k) {
- if (!is_default) {
- urls[index][strings::app_id] = app_id_to_send_to;
- }
- urls[index][strings::url] = endpoints[i].url[k];
- ++index;
- }
- }
- }
- SendResponseToHMI(Common_Result::SUCCESS);
- return;
-}
-#endif // PROPRIETARY_MODE
-
-} // namespace commands
-} // namespace sdl_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_device_state_changed_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_device_state_changed_notification.cc
index 9ddd822b1c..129ba8c9ba 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_device_state_changed_notification.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_device_state_changed_notification.cc
@@ -34,6 +34,7 @@
#include <algorithm>
#include "application_manager/application_manager.h"
#include "application_manager/message_helper.h"
+#include "application_manager/policies/policy_handler_interface.h"
#include "encryption/hashing.h"
#include "interfaces/HMI_API.h"
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_driver_distraction_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_driver_distraction_notification.cc
index a29b9721e9..a743c58672 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_driver_distraction_notification.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_driver_distraction_notification.cc
@@ -35,6 +35,7 @@
#include "application_manager/application_impl.h"
#include "application_manager/message_helper.h"
+#include "application_manager/policies/policy_handler_interface.h"
#include "interfaces/HMI_API.h"
#include "interfaces/MOBILE_API.h"
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ignition_cycle_over_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ignition_cycle_over_notification.cc
index 9c2c68989f..1e8da19c0a 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ignition_cycle_over_notification.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ignition_cycle_over_notification.cc
@@ -32,6 +32,7 @@
#include "sdl_rpc_plugin/commands/hmi/on_ignition_cycle_over_notification.h"
#include "application_manager/application_manager.h"
+#include "application_manager/policies/policy_handler_interface.h"
namespace sdl_rpc_plugin {
using namespace application_manager;
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_policy_update.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_policy_update.cc
index 67352fbc4a..a0e75371b5 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_policy_update.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_policy_update.cc
@@ -32,6 +32,7 @@
#include "sdl_rpc_plugin/commands/hmi/on_policy_update.h"
#include "application_manager/application_manager.h"
+#include "application_manager/policies/policy_handler_interface.h"
namespace sdl_rpc_plugin {
using namespace application_manager;
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_received_policy_update.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_received_policy_update.cc
index 4a8c8df0ee..b2c9151b40 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_received_policy_update.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_received_policy_update.cc
@@ -33,6 +33,7 @@
#include "sdl_rpc_plugin/commands/hmi/on_received_policy_update.h"
#include <string>
#include "application_manager/application_manager.h"
+#include "application_manager/policies/policy_handler_interface.h"
#include "utils/file_system.h"
namespace sdl_rpc_plugin {
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_error_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_error_notification.cc
index 6a5ee4fce4..9b8523e882 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_error_notification.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_error_notification.cc
@@ -32,6 +32,7 @@
#include "sdl_rpc_plugin/commands/hmi/on_system_error_notification.h"
#include "application_manager/application_manager.h"
+#include "application_manager/policies/policy_handler_interface.h"
#include "interfaces/HMI_API.h"
namespace sdl_rpc_plugin {
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_info_changed_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_info_changed_notification.cc
index b7ba6951fb..171c144055 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_info_changed_notification.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_info_changed_notification.cc
@@ -33,6 +33,7 @@
#include "sdl_rpc_plugin/commands/hmi/on_system_info_changed_notification.h"
#include "application_manager/application_manager.h"
#include "application_manager/message_helper.h"
+#include "application_manager/policies/policy_handler_interface.h"
namespace sdl_rpc_plugin {
using namespace application_manager;
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_command_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_command_notification.cc
index 19b4047b1b..c4678f69e0 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_command_notification.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_command_notification.cc
@@ -65,7 +65,7 @@ void OnVRCommandNotification::Run() {
(*message_)[strings::msg_params][strings::cmd_id].asUInt();
uint32_t max_cmd_id = application_manager_.get_settings().max_cmd_id();
- // Check if this is one of standart VR commands (i.e. "Help")
+ // Check if this is one of standard VR commands (i.e. "Help")
if (cmd_id > max_cmd_id + 1) {
LOG4CXX_INFO(logger_, "Switched App");
const uint32_t app_id = cmd_id - max_cmd_id;
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc
index 30184be7a1..13690809bb 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc
@@ -32,6 +32,7 @@
#include "sdl_rpc_plugin/commands/hmi/sdl_activate_app_request.h"
#include "application_manager/message_helper.h"
+#include "application_manager/policies/policy_handler_interface.h"
#include "application_manager/state_controller.h"
namespace sdl_rpc_plugin {
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_list_of_permissions_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_list_of_permissions_request.cc
index 095ffbd9c7..c8266e0f39 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_list_of_permissions_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_list_of_permissions_request.cc
@@ -32,6 +32,7 @@
#include "sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_request.h"
#include "application_manager/application_manager.h"
+#include "application_manager/policies/policy_handler_interface.h"
namespace sdl_rpc_plugin {
using namespace application_manager;
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_policy_configuration_data_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_policy_configuration_data_request.cc
new file mode 100644
index 0000000000..2607754228
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_policy_configuration_data_request.cc
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2019, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "sdl_rpc_plugin/commands/hmi/sdl_get_policy_configuration_data_request.h"
+#include "application_manager/application_manager.h"
+#include "application_manager/policies/policy_handler_interface.h"
+
+namespace sdl_rpc_plugin {
+using namespace application_manager;
+
+namespace commands {
+
+SDLGetPolicyConfigurationDataRequest::SDLGetPolicyConfigurationDataRequest(
+ const application_manager::commands::MessageSharedPtr& message,
+ ApplicationManager& application_manager,
+ rpc_service::RPCService& rpc_service,
+ HMICapabilities& hmi_capabilities,
+ policy::PolicyHandlerInterface& policy_handle)
+ : RequestFromHMI(message,
+ application_manager,
+ rpc_service,
+ hmi_capabilities,
+ policy_handle) {}
+
+SDLGetPolicyConfigurationDataRequest::~SDLGetPolicyConfigurationDataRequest() {}
+
+void SDLGetPolicyConfigurationDataRequest::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ smart_objects::SmartObject response_value(
+ smart_objects::SmartType::SmartType_Array);
+
+ hmi_apis::Common_Result::eType result_code =
+ PrepareResponseParams(response_value);
+
+ if (hmi_apis::Common_Result::SUCCESS != result_code) {
+ LOG4CXX_ERROR(logger_, "Unable to PrepareResponseParams");
+ SendErrorResponse(
+ correlation_id(),
+ hmi_apis::FunctionID::SDL_GetPolicyConfigurationData,
+ result_code,
+ "",
+ application_manager::commands::Command::SOURCE_SDL_TO_HMI);
+ return;
+ }
+
+ smart_objects::SmartObject response_msg_params(
+ smart_objects::SmartType::SmartType_Map);
+ response_msg_params[strings::value] = response_value;
+ SendResponse(true,
+ correlation_id(),
+ hmi_apis::FunctionID::SDL_GetPolicyConfigurationData,
+ result_code,
+ &response_msg_params,
+ application_manager::commands::Command::SOURCE_SDL_TO_HMI);
+}
+
+hmi_apis::Common_Result::eType
+SDLGetPolicyConfigurationDataRequest::PrepareResponseParams(
+ smart_objects::SmartObject& response_out) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ const auto policy_type =
+ (*message_)[strings::msg_params][strings::policy_type].asString();
+
+ const auto property =
+ (*message_)[strings::msg_params][strings::property].asString();
+
+ auto policy_table_data = policy_handler_.GetPolicyTableData();
+ if (!policy_table_data.isMember(policy_type)) {
+ LOG4CXX_ERROR(
+ logger_,
+ "policy_type " << policy_type << " doesn't exist in policy table.");
+ return hmi_apis::Common_Result::DATA_NOT_AVAILABLE;
+ }
+
+ auto& policy_section_table_data = policy_table_data[policy_type];
+ if (!policy_section_table_data.isMember(property)) {
+ LOG4CXX_ERROR(
+ logger_,
+ "property " << property << " doesn't exist in " << policy_type);
+ return hmi_apis::Common_Result::DATA_NOT_AVAILABLE;
+ }
+
+ auto& property_table_data = policy_section_table_data[property];
+ response_out = GetValueParam(property_table_data);
+
+ return hmi_apis::Common_Result::SUCCESS;
+}
+
+void clear_new_line_symbol(std::string& str_to_clear) {
+ str_to_clear.erase(
+ std::remove_if(str_to_clear.begin(),
+ str_to_clear.end(),
+ [](char character) { return '\n' == character; }),
+ str_to_clear.end());
+}
+
+smart_objects::SmartObject SDLGetPolicyConfigurationDataRequest::GetValueParam(
+ const Json::Value& policy_property) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ smart_objects::SmartObject value(smart_objects::SmartType_Array);
+
+ auto put_element_in_value_array = [&value](const Json::Value& element,
+ const int32_t index) {
+ Json::FastWriter writer;
+ std::string str;
+ if (element.type() == Json::objectValue) {
+ str = writer.write(element);
+ clear_new_line_symbol(str);
+ } else {
+ str = element.asString();
+ }
+ value[index] = str;
+ };
+
+ if (policy_property.type() == Json::arrayValue) {
+ for (Json::ArrayIndex i = 0; i < policy_property.size(); i++) {
+ put_element_in_value_array(policy_property[i], i);
+ }
+ return value;
+ }
+ put_element_in_value_array(policy_property, 0);
+ return value;
+}
+
+} // namespace commands
+} // namespace sdl_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_urls_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_policy_configuration_data_response.cc
index 77d90ec8bb..21b7dea41c 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_urls_response.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_policy_configuration_data_response.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Ford Motor Company
+ * Copyright (c) 2019, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,14 +30,15 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "sdl_rpc_plugin/commands/hmi/get_urls_response.h"
+#include "sdl_rpc_plugin/commands/hmi/sdl_get_policy_configuration_data_response.h"
#include "application_manager/rpc_service.h"
namespace sdl_rpc_plugin {
using namespace application_manager;
+
namespace commands {
-GetUrlsResponse::GetUrlsResponse(
+SDLGetPolicyConfigurationDataResponse::SDLGetPolicyConfigurationDataResponse(
const application_manager::commands::MessageSharedPtr& message,
ApplicationManager& application_manager,
rpc_service::RPCService& rpc_service,
@@ -49,13 +50,13 @@ GetUrlsResponse::GetUrlsResponse(
hmi_capabilities,
policy_handle) {}
-GetUrlsResponse::~GetUrlsResponse() {}
+SDLGetPolicyConfigurationDataResponse::
+ ~SDLGetPolicyConfigurationDataResponse() {}
-void GetUrlsResponse::Run() {
+void SDLGetPolicyConfigurationDataResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
(*message_)[strings::params][strings::protocol_type] = hmi_protocol_type_;
(*message_)[strings::params][strings::protocol_version] = protocol_version_;
-
rpc_service_.SendMessageToHMI(message_);
}
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_status_update_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_status_update_request.cc
index 7200f6918c..b494be56e8 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_status_update_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_status_update_request.cc
@@ -32,6 +32,7 @@
#include "sdl_rpc_plugin/commands/hmi/sdl_get_status_update_request.h"
#include "application_manager/application_manager.h"
+#include "application_manager/policies/policy_handler_interface.h"
namespace sdl_rpc_plugin {
using namespace application_manager;
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_request.cc
index 28167df047..38a63611fa 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_request.cc
@@ -32,6 +32,7 @@
#include "sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_request.h"
#include "application_manager/message_helper.h"
+#include "application_manager/policies/policy_handler_interface.h"
namespace sdl_rpc_plugin {
using namespace application_manager;
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_sdl_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_sdl_request.cc
index 96d454d4ee..a52f03b998 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_sdl_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_sdl_request.cc
@@ -32,6 +32,7 @@
*/
#include "sdl_rpc_plugin/commands/hmi/update_sdl_request.h"
+#include "application_manager/policies/policy_handler_interface.h"
namespace sdl_rpc_plugin {
using namespace application_manager;
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_request.cc
index 8940ea3f59..50217a9c8a 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_request.cc
@@ -37,6 +37,7 @@
#include "application_manager/application_impl.h"
#include "application_manager/application_manager.h"
#include "application_manager/message_helper.h"
+#include "application_manager/policies/policy_handler_interface.h"
#include "interfaces/HMI_API.h"
#include "interfaces/MOBILE_API.h"
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_cloud_app_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_cloud_app_properties_request.cc
index 34ed30c243..0b7e611e59 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_cloud_app_properties_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_cloud_app_properties_request.cc
@@ -1,4 +1,5 @@
#include "sdl_rpc_plugin/commands/mobile/get_cloud_app_properties_request.h"
+#include "application_manager/policies/policy_handler_interface.h"
namespace sdl_rpc_plugin {
using namespace application_manager;
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloud_app_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloud_app_properties_request.cc
index 5173be56d6..3bb1e1c107 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloud_app_properties_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloud_app_properties_request.cc
@@ -1,4 +1,5 @@
#include "sdl_rpc_plugin/commands/mobile/set_cloud_app_properties_request.h"
+#include "application_manager/policies/policy_handler_interface.h"
namespace sdl_rpc_plugin {
using namespace application_manager;
@@ -40,4 +41,4 @@ void SetCloudAppPropertiesRequest::on_event(
}
} // namespace commands
-} // namespace sdl_rpc_plugin \ No newline at end of file
+} // namespace sdl_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc
index a0dee162dd..6a231f8e35 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc
@@ -71,6 +71,8 @@
#include "sdl_rpc_plugin/commands/hmi/sdl_activate_app_response.h"
#include "sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_request.h"
#include "sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_response.h"
+#include "sdl_rpc_plugin/commands/hmi/sdl_get_policy_configuration_data_request.h"
+#include "sdl_rpc_plugin/commands/hmi/sdl_get_policy_configuration_data_response.h"
#include "sdl_rpc_plugin/commands/hmi/sdl_get_status_update_request.h"
#include "sdl_rpc_plugin/commands/hmi/sdl_get_status_update_response.h"
#include "sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_request.h"
@@ -171,8 +173,6 @@
#include "sdl_rpc_plugin/commands/hmi/basic_communication_system_response.h"
#include "sdl_rpc_plugin/commands/hmi/dial_number_request.h"
#include "sdl_rpc_plugin/commands/hmi/dial_number_response.h"
-#include "sdl_rpc_plugin/commands/hmi/get_urls.h"
-#include "sdl_rpc_plugin/commands/hmi/get_urls_response.h"
#include "sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_request.h"
#include "sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_response.h"
#include "sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_request.h"
@@ -358,11 +358,6 @@ CommandCreator& HMICommandFactory::get_creator_factory(
? factory.GetCreator<commands::SDLPolicyUpdate>()
: factory.GetCreator<commands::SDLPolicyUpdateResponse>();
}
- case hmi_apis::FunctionID::SDL_GetURLS: {
- return hmi_apis::messageType::request == message_type
- ? factory.GetCreator<commands::GetUrls>()
- : factory.GetCreator<commands::GetUrlsResponse>();
- }
case hmi_apis::FunctionID::SDL_OnAppPermissionChanged: {
return factory.GetCreator<commands::OnAppPermissionChangedNotification>();
}
@@ -385,6 +380,13 @@ CommandCreator& HMICommandFactory::get_creator_factory(
? factory.GetCreator<commands::SDLGetStatusUpdateRequest>()
: factory.GetCreator<commands::SDLGetStatusUpdateResponse>();
}
+ case hmi_apis::FunctionID::SDL_GetPolicyConfigurationData: {
+ return hmi_apis::messageType::request == message_type
+ ? factory.GetCreator<
+ commands::SDLGetPolicyConfigurationDataRequest>()
+ : factory.GetCreator<
+ commands::SDLGetPolicyConfigurationDataResponse>();
+ }
case hmi_apis::FunctionID::SDL_OnStatusUpdate: {
return factory.GetCreator<commands::OnStatusUpdateNotification>();
}
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc
index f5593bf241..c66cb81141 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc
@@ -56,8 +56,6 @@
#include "hmi/dial_number_response.h"
#include "hmi/get_system_info_request.h"
#include "hmi/get_system_info_response.h"
-#include "hmi/get_urls.h"
-#include "hmi/get_urls_response.h"
#include "hmi/mixing_audio_supported_request.h"
#include "hmi/mixing_audio_supported_response.h"
#include "hmi/navi_alert_maneuver_request.h"
@@ -320,8 +318,6 @@ typedef Types<commands::OnStartDeviceDiscovery,
commands::SDLActivateAppRequest,
commands::SDLPolicyUpdateResponse,
commands::SDLPolicyUpdate,
- commands::GetUrlsResponse,
- commands::GetUrls,
commands::OnAppPermissionChangedNotification,
commands::SDLGetListOfPermissionsResponse,
commands::SDLGetListOfPermissionsRequest,
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_urls_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_urls_response_test.cc
deleted file mode 100644
index f030701710..0000000000
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_urls_response_test.cc
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2018, Ford Motor Company
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of the Ford Motor Company nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdint.h>
-#include <string>
-
-#include "application_manager/application.h"
-#include "application_manager/commands/command.h"
-#include "application_manager/commands/commands_test.h"
-#include "application_manager/commands/response_to_hmi.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/smart_object_keys.h"
-#include "gtest/gtest.h"
-#include "hmi/get_urls_response.h"
-#include "smart_objects/smart_object.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace hmi_commands_test {
-namespace get_urls_response {
-
-using ::testing::_;
-using ::testing::Return;
-namespace am = ::application_manager;
-namespace strings = ::application_manager::strings;
-using am::commands::CommandImpl;
-using am::commands::ResponseToHMI;
-using sdl_rpc_plugin::commands::GetUrlsResponse;
-
-typedef std::shared_ptr<ResponseToHMI> ResponseToHMIPtr;
-
-namespace {
-const uint32_t kConnectionKey = 2u;
-} // namespace
-
-class GetUrlResponseTest : public CommandsTest<CommandsTestMocks::kIsNice> {};
-
-TEST_F(GetUrlResponseTest, RUN_SendRequest_SUCCESS) {
- MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
- (*command_msg)[strings::msg_params][strings::number] = "123";
- (*command_msg)[strings::params][strings::connection_key] = kConnectionKey;
-
- ResponseToHMIPtr command(CreateCommand<GetUrlsResponse>(command_msg));
- EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(command_msg));
-
- command->Run();
-
- EXPECT_EQ((*command_msg)[strings::params][strings::protocol_type].asInt(),
- CommandImpl::hmi_protocol_type_);
- EXPECT_EQ((*command_msg)[strings::params][strings::protocol_version].asInt(),
- CommandImpl::protocol_version_);
-}
-
-} // namespace get_urls_response
-} // namespace hmi_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_urls_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_urls_test.cc
deleted file mode 100644
index b19207cc14..0000000000
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_urls_test.cc
+++ /dev/null
@@ -1,338 +0,0 @@
-/*
- * Copyright (c) 2018, Ford Motor Company
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of the Ford Motor Company nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdint.h>
-#include <string>
-
-#include "application_manager/commands/command.h"
-#include "application_manager/commands/command_request_test.h"
-#include "application_manager/commands/commands_test.h"
-#include "application_manager/commands/request_from_hmi.h"
-#include "application_manager/event_engine/event_dispatcher.h"
-#include "application_manager/message.h"
-#include "application_manager/mock_application.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/policies/mock_policy_handler_interface.h"
-#include "application_manager/policies/policy_handler.h"
-#include "application_manager/smart_object_keys.h"
-#include "gtest/gtest.h"
-#include "hmi/get_urls.h"
-#include "policy/mock_policy_manager.h"
-#include "smart_objects/smart_object.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace hmi_commands_test {
-namespace get_urls {
-
-using namespace hmi_apis;
-using namespace policy;
-using ::test::components::application_manager_test::MockApplication;
-using ::testing::_;
-using ::testing::NiceMock;
-using ::testing::SetArgReferee;
-namespace am = ::application_manager;
-namespace strings = ::application_manager::strings;
-using am::commands::CommandImpl;
-using am::commands::RequestFromHMI;
-using policy::PolicyHandler;
-using policy_test::MockPolicyHandlerInterface;
-using sdl_rpc_plugin::commands::GetUrls;
-
-typedef std::shared_ptr<RequestFromHMI> RequestFromHMIPtr;
-
-namespace {
-const uint32_t kInvalidAppId_ = 0u;
-const uint32_t kAppIdForSending = 1u;
-const uint32_t kConnectionKey = 2u;
-const uint32_t kServiceType = 0u;
-const std::string kInitialService = "0x0";
-const std::string kPolicyService = "7";
-const std::string kDefaultUrl = "URL is not found";
-const std::string kDefaultId = "default";
-const std::string kPolicyAppId = "policy_app_id";
-} // namespace
-
-class GetUrlsTest : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- MessageSharedPtr command_msg_;
- RequestFromHMIPtr request_command_;
-
- GetUrlsTest() {
- command_msg_ =
- CreateMessage(ns_smart_device_link::ns_smart_objects::SmartType_Map);
- (*command_msg_)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
- (*command_msg_)[am::strings::msg_params][am::hmi_request::service] =
- kInitialService;
-
- request_command_ = CreateCommand<GetUrls>(command_msg_);
- }
-};
-
-TEST_F(GetUrlsTest, RUN_SUCCESS) {
- EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true));
- // EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(_, _));
-
- request_command_->Run();
-}
-
-TEST_F(GetUrlsTest, RUN_PolicyNotEnabled_UNSUCCESS) {
- EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(false));
-
- EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_, _))
- .WillOnce(Return(true));
-
- request_command_->Run();
-
- EXPECT_EQ(am::MessageType::kResponse,
- (*command_msg_)[strings::params][strings::message_type].asInt());
- EXPECT_EQ(Common_Result::DATA_NOT_AVAILABLE,
- (*command_msg_)[strings::params][am::hmi_response::code].asInt());
-}
-
-TEST_F(GetUrlsTest, RUN_EmptyEndpoints_UNSUCCESS) {
- EndpointUrls endpoints_;
- EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kServiceType, _))
- .WillOnce(SetArgReferee<1>(endpoints_));
- EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true));
-
- EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_, _))
- .WillOnce(Return(true));
-
- request_command_->Run();
-
- EXPECT_EQ(am::MessageType::kResponse,
- (*command_msg_)[strings::params][strings::message_type].asInt());
- EXPECT_EQ(Common_Result::DATA_NOT_AVAILABLE,
- (*command_msg_)[strings::params][am::hmi_response::code].asInt());
-}
-
-#ifdef EXTENDED_POLICY
-TEST_F(GetUrlsTest, ProcessPolicyServiceURLs_SUCCESS) {
- (*command_msg_)[am::strings::msg_params][am::hmi_request::service] =
- kPolicyService;
-
- EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true));
-
- EndpointUrls endpoints_;
- EndpointData data(kDefaultUrl);
- endpoints_.push_back(data);
-
- EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kPolicyService, _))
- .WillOnce(SetArgReferee<1>(endpoints_));
-
- MockAppPtr mock_app = CreateMockApp();
-
- EXPECT_CALL(mock_policy_handler_, GetAppIdForSending())
- .WillOnce(Return(kAppIdForSending));
-
- EXPECT_CALL(app_mngr_, application(kAppIdForSending))
- .WillOnce(Return(mock_app));
- EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kAppIdForSending));
- EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_, _))
- .WillOnce(Return(true));
-
- request_command_->Run();
-
- EXPECT_FALSE((*command_msg_)[am::strings::msg_params].keyExists(
- am::hmi_request::service));
-
- EXPECT_EQ(am::MessageType::kResponse,
- (*command_msg_)[strings::params][strings::message_type].asInt());
- EXPECT_EQ(Common_Result::SUCCESS,
- (*command_msg_)[strings::params][am::hmi_response::code].asInt());
-
- EXPECT_EQ(kAppIdForSending,
- (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0]
- [strings::app_id]
- .asInt());
- EXPECT_EQ(kDefaultUrl,
- (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0]
- [strings::url]
- .asString());
-}
-
-TEST_F(GetUrlsTest, ProcessPolicyServiceURLs_IncorrectIdForSending_UNSUCCESS) {
- (*command_msg_)[am::strings::msg_params][am::hmi_request::service] =
- kPolicyService;
-
- EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true));
-
- EndpointUrls endpoints_;
- EndpointData data(kDefaultUrl);
- endpoints_.push_back(data);
-
- EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kPolicyService, _))
- .WillOnce(SetArgReferee<1>(endpoints_));
-
- EXPECT_CALL(mock_policy_handler_, GetAppIdForSending())
- .WillOnce(Return(kInvalidAppId_));
-
- EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_, _))
- .WillOnce(Return(true));
-
- EXPECT_CALL(app_mngr_, application(kInvalidAppId_)).Times(0);
-
- request_command_->Run();
-}
-
-TEST_F(GetUrlsTest, ProcessPolicyServiceURLs_ApplicationIsNotValid_UNSUCCESS) {
- (*command_msg_)[am::strings::msg_params][am::hmi_request::service] =
- kPolicyService;
-
- EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true));
-
- EndpointUrls endpoints_;
- EndpointData data(kDefaultUrl);
- endpoints_.push_back(data);
-
- EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kPolicyService, _))
- .WillOnce(SetArgReferee<1>(endpoints_));
-
- MockAppPtr invalid_mock_app;
-
- EXPECT_CALL(mock_policy_handler_, GetAppIdForSending())
- .WillOnce(Return(kAppIdForSending));
-
- EXPECT_CALL(app_mngr_, application(kAppIdForSending))
- .WillOnce(Return(invalid_mock_app));
-
- EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_, _))
- .WillOnce(Return(true));
-
- request_command_->Run();
-
- EXPECT_EQ(am::MessageType::kResponse,
- (*command_msg_)[strings::params][strings::message_type].asInt());
- EXPECT_EQ(Common_Result::DATA_NOT_AVAILABLE,
- (*command_msg_)[strings::params][am::hmi_response::code].asInt());
-}
-
-TEST_F(GetUrlsTest, ProcessPolicyServiceURLs_FoundURLForApplication_SUCCESS) {
- (*command_msg_)[am::strings::msg_params][am::hmi_request::service] =
- kPolicyService;
-
- EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true));
-
- EndpointUrls endpoints_;
- EndpointData data(kDefaultUrl);
- data.app_id = kPolicyAppId;
- endpoints_.push_back(data);
-
- EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kPolicyService, _))
- .WillOnce(SetArgReferee<1>(endpoints_));
-
- MockAppPtr mock_app = CreateMockApp();
-
- EXPECT_CALL(mock_policy_handler_, GetAppIdForSending())
- .WillOnce(Return(kAppIdForSending));
-
- EXPECT_CALL(app_mngr_, application(kAppIdForSending))
- .WillOnce(Return(mock_app));
-
- EXPECT_CALL(*mock_app, policy_app_id()).WillOnce(Return(kPolicyAppId));
-
- EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_, _))
- .WillOnce(Return(true));
-
- request_command_->Run();
-
- EXPECT_FALSE((*command_msg_)[am::strings::msg_params].keyExists(
- am::hmi_request::service));
-
- EXPECT_EQ(am::MessageType::kResponse,
- (*command_msg_)[strings::params][strings::message_type].asInt());
- EXPECT_EQ(Common_Result::SUCCESS,
- (*command_msg_)[strings::params][am::hmi_response::code].asInt());
-}
-#endif
-
-TEST_F(GetUrlsTest, DISABLED_ProcessServiceURLs_SUCCESS) {
- (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] =
- kDefaultUrl;
- (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0]
- [am::hmi_response::policy_app_id] = "1";
-
- EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true));
-
- EndpointUrls endpoints_;
- EndpointData data(kDefaultUrl);
- data.app_id = "1";
- endpoints_.push_back(data);
- EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kServiceType, _))
- .WillOnce(SetArgReferee<1>(endpoints_));
-
- request_command_->Run();
-
- EXPECT_FALSE((*command_msg_)[am::strings::msg_params].keyExists(
- am::hmi_request::service));
- EXPECT_EQ(kDefaultUrl,
- (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0]
- [am::strings::url]
- .asString());
- EXPECT_EQ(endpoints_[0].app_id,
- (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0]
- [am::hmi_response::policy_app_id]
- .asString());
-}
-
-TEST_F(GetUrlsTest, ProcessServiceURLs_PolicyDefaultId_SUCCESS) {
- (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] =
- kDefaultUrl;
- (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0]
- [am::hmi_response::policy_app_id] = kDefaultId;
-
- EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true));
- EndpointUrls endpoints_;
- EndpointData data(kDefaultUrl);
- endpoints_.push_back(data);
- EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kServiceType, _))
- .WillOnce(SetArgReferee<1>(endpoints_));
- MockAppPtr mock_app = CreateMockApp();
- EXPECT_CALL(app_mngr_, application_by_policy_id(_))
- .WillOnce(Return(mock_app));
- request_command_->Run();
-
- EXPECT_FALSE((*command_msg_)[am::strings::msg_params].keyExists(
- am::hmi_request::service));
- EXPECT_TRUE(
- (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0]
- .keyExists(am::hmi_response::policy_app_id));
-}
-
-} // namespace get_urls
-} // namespace hmi_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_policy_configuration_data_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_policy_configuration_data_request_test.cc
new file mode 100644
index 0000000000..8e802bbd7d
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_policy_configuration_data_request_test.cc
@@ -0,0 +1,180 @@
+/*
+ * Copyright (c) 2019, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "hmi/sdl_get_policy_configuration_data_request.h"
+#include "application_manager/commands/command_request_test.h"
+#include "gtest/gtest.h"
+#include "smart_objects/smart_object.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace hmi_commands_test {
+namespace sdl_get_policy_configuration_data_request {
+
+using testing::Return;
+
+using sdl_rpc_plugin::commands::SDLGetPolicyConfigurationDataRequest;
+using test::components::policy_test::MockPolicyHandlerInterface;
+
+namespace strings = ::app_mngr::strings;
+namespace hmi_response = ::app_mngr::hmi_response;
+
+class SDLGetPolicyConfigurationDataRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {};
+
+MATCHER_P(GetPolicyConfigurationDataFirstElementMatches,
+ string_first_element_value,
+ "") {
+ auto message = static_cast<smart_objects::SmartObject>(*arg);
+ if (!message.keyExists(strings::msg_params) ||
+ !message[strings::msg_params].keyExists(strings::value)) {
+ return false;
+ }
+
+ if (message[strings::msg_params][strings::value].getType() !=
+ smart_objects::SmartType::SmartType_Array ||
+ message[strings::msg_params][strings::value].empty()) {
+ return false;
+ }
+
+ Json::Reader reader;
+ Json::Value msg_json_value(Json::ValueType::arrayValue);
+
+ auto msg_value_first = message[strings::msg_params][strings::value][0];
+ return msg_value_first.asString() == string_first_element_value;
+}
+
+MATCHER_P(HMIResultCodeIs, result_code, "") {
+ return result_code ==
+ static_cast<hmi_apis::Common_Result::eType>(
+ (*arg)[strings::params][hmi_response::code].asInt());
+}
+
+TEST_F(SDLGetPolicyConfigurationDataRequestTest, Run_Fail_DataNotAvailable) {
+ std::string kInvalidKey = "invalid_key";
+
+ PolicyTable pt;
+ ON_CALL(mock_policy_handler_, GetPolicyTableData())
+ .WillByDefault(Return(pt.ToJsonValue()));
+
+ MessageSharedPtr msg = CreateMessage();
+ (*msg)[strings::msg_params][strings::policy_type] = kInvalidKey;
+ (*msg)[strings::msg_params][strings::property] = kInvalidKey;
+
+ std::shared_ptr<SDLGetPolicyConfigurationDataRequest> command(
+ CreateCommand<SDLGetPolicyConfigurationDataRequest>(msg));
+
+ EXPECT_CALL(mock_rpc_service_,
+ ManageHMICommand(
+ HMIResultCodeIs(hmi_apis::Common_Result::DATA_NOT_AVAILABLE),
+ Command::SOURCE_SDL_TO_HMI));
+
+ command->Run();
+}
+
+void clear_new_line_symbol(std::string& str_to_clear) {
+ str_to_clear.erase(
+ std::remove_if(str_to_clear.begin(),
+ str_to_clear.end(),
+ [](char character) { return '\n' == character; }),
+ str_to_clear.end());
+}
+
+TEST_F(SDLGetPolicyConfigurationDataRequestTest, Run_Success) {
+ MessageSharedPtr msg = CreateMessage();
+ (*msg)[strings::msg_params][strings::policy_type] = "module_config";
+ (*msg)[strings::msg_params][strings::property] = "endpoints";
+
+ std::shared_ptr<SDLGetPolicyConfigurationDataRequest> command(
+ CreateCommand<SDLGetPolicyConfigurationDataRequest>(msg));
+
+ policy_table::ModuleConfig module_config_with_endpoints;
+ policy_table::URLList endpoint_url_list;
+ policy_table::URL urls;
+ urls.push_back("https://url1.com");
+ urls.push_back("https://url2.com");
+ endpoint_url_list["default"] = urls;
+ module_config_with_endpoints.endpoints["0x9"] = endpoint_url_list;
+
+ PolicyTable pt;
+ pt.mark_initialized();
+ pt.module_config.mark_initialized();
+ pt.module_config = module_config_with_endpoints;
+
+ ON_CALL(mock_policy_handler_, GetPolicyTableData())
+ .WillByDefault(Return(pt.ToJsonValue()));
+
+ auto json_val = module_config_with_endpoints.endpoints.ToJsonValue();
+ Json::FastWriter writer;
+ std::string expected_string = writer.write(json_val);
+ clear_new_line_symbol(expected_string);
+
+ EXPECT_CALL(mock_rpc_service_,
+ ManageHMICommand(GetPolicyConfigurationDataFirstElementMatches(
+ expected_string),
+ Command::SOURCE_SDL_TO_HMI));
+ command->Run();
+}
+
+TEST_F(SDLGetPolicyConfigurationDataRequestTest,
+ Run_RetriveStringValueFromPolicy) {
+ MessageSharedPtr msg = CreateMessage();
+ (*msg)[strings::msg_params][strings::policy_type] =
+ "consumer_friendly_messages";
+ (*msg)[strings::msg_params][strings::property] = "version";
+
+ auto command = CreateCommand<SDLGetPolicyConfigurationDataRequest>(msg);
+
+ const std::string version_test_value("version string");
+ PolicyTable pt;
+ pt.mark_initialized();
+ pt.consumer_friendly_messages->mark_initialized();
+ pt.consumer_friendly_messages->version =
+ rpc::String<1, 100>(version_test_value);
+
+ ON_CALL(mock_policy_handler_, GetPolicyTableData())
+ .WillByDefault(Return(pt.ToJsonValue()));
+
+ EXPECT_CALL(mock_rpc_service_,
+ ManageHMICommand(GetPolicyConfigurationDataFirstElementMatches(
+ version_test_value),
+ Command::SOURCE_SDL_TO_HMI));
+
+ command->Run();
+}
+
+} // namespace sdl_get_policy_configuration_data_request
+} // namespace hmi_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/on_vi_vehicle_data_notification.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/on_vi_vehicle_data_notification.h
index 103bfb56dc..be2f123f4a 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/on_vi_vehicle_data_notification.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/on_vi_vehicle_data_notification.h
@@ -35,6 +35,7 @@
#include "application_manager/application_manager.h"
#include "application_manager/commands/notification_from_hmi.h"
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
namespace vehicle_info_plugin {
namespace app_mngr = application_manager;
@@ -55,10 +56,7 @@ class OnVIVehicleDataNotification
**/
OnVIVehicleDataNotification(
const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle);
+ const VehicleInfoCommandParams& params);
/**
* @brief OnVIVehicleDataNotification class destructor
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_diagnostic_message_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_diagnostic_message_request.h
index 162a6b338a..6ae6d1f7f6 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_diagnostic_message_request.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_diagnostic_message_request.h
@@ -34,6 +34,7 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_DIAGNOSTIC_MESSAGE_REQUEST_H_
#include "application_manager/commands/request_to_hmi.h"
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
namespace vehicle_info_plugin {
namespace app_mngr = application_manager;
@@ -52,10 +53,7 @@ class VIDiagnosticMessageRequest : public app_mngr::commands::RequestToHMI {
**/
VIDiagnosticMessageRequest(
const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle);
+ const VehicleInfoCommandParams& params);
/**
* @brief VIDiagnosticMessageRequest class destructor
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_diagnostic_message_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_diagnostic_message_response.h
index a427bbe362..9b172b9e74 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_diagnostic_message_response.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_diagnostic_message_response.h
@@ -34,6 +34,7 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_DIAGNOSTIC_MESSAGE_RESPONSE_H_
#include "application_manager/commands/response_from_hmi.h"
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
namespace vehicle_info_plugin {
namespace app_mngr = application_manager;
@@ -52,10 +53,7 @@ class VIDiagnosticMessageResponse : public app_mngr::commands::ResponseFromHMI {
**/
VIDiagnosticMessageResponse(
const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle);
+ const VehicleInfoCommandParams& params);
/**
* @brief VIDiagnosticMessageResponse class destructor
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_dtcs_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_dtcs_request.h
index df9e84eab4..c77464835b 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_dtcs_request.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_dtcs_request.h
@@ -34,6 +34,7 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_DTCS_REQUEST_H_
#include "application_manager/commands/request_to_hmi.h"
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
namespace vehicle_info_plugin {
namespace app_mngr = application_manager;
@@ -51,10 +52,7 @@ class VIGetDTCsRequest : public app_mngr::commands::RequestToHMI {
* @param message Incoming SmartObject message
**/
VIGetDTCsRequest(const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle);
+ const VehicleInfoCommandParams& params);
/**
* @brief VIGetDTCsRequest class destructor
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_dtcs_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_dtcs_response.h
index d8351c1a61..f1ddcbe373 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_dtcs_response.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_dtcs_response.h
@@ -34,6 +34,7 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_DTCS_RESPONSE_H_
#include "application_manager/commands/response_from_hmi.h"
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
namespace vehicle_info_plugin {
namespace app_mngr = application_manager;
@@ -51,10 +52,7 @@ class VIGetDTCsResponse : public app_mngr::commands::ResponseFromHMI {
* @param message Incoming SmartObject message
**/
VIGetDTCsResponse(const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle);
+ const VehicleInfoCommandParams& params);
/**
* @brief VIGetDTCsResponse class destructor
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_request.h
index 437e7c8933..bce49f8201 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_request.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_request.h
@@ -34,6 +34,8 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_VEHICLE_DATA_REQUEST_H_
#include "application_manager/commands/request_to_hmi.h"
+#include "vehicle_info_plugin/custom_vehicle_data_manager.h"
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
namespace vehicle_info_plugin {
namespace app_mngr = application_manager;
@@ -51,10 +53,7 @@ class VIGetVehicleDataRequest : public app_mngr::commands::RequestToHMI {
* @param message Incoming SmartObject message
**/
VIGetVehicleDataRequest(const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle);
+ const VehicleInfoCommandParams& params);
/**
* @brief VIGetVehicleDataRequest class destructor
@@ -67,6 +66,8 @@ class VIGetVehicleDataRequest : public app_mngr::commands::RequestToHMI {
virtual void Run();
private:
+ CustomVehicleDataManager& custom_vehicle_data_manager_;
+
DISALLOW_COPY_AND_ASSIGN(VIGetVehicleDataRequest);
};
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_response.h
index 651a0af79c..7504168aec 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_response.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_response.h
@@ -35,6 +35,7 @@
#include "application_manager/application_manager.h"
#include "application_manager/commands/response_from_hmi.h"
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
namespace vehicle_info_plugin {
namespace app_mngr = application_manager;
@@ -52,10 +53,7 @@ class VIGetVehicleDataResponse : public app_mngr::commands::ResponseFromHMI {
* @param message Incoming SmartObject message
**/
VIGetVehicleDataResponse(const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle);
+ const VehicleInfoCommandParams& params);
/**
* @brief VIGetVehicleDataResponse class destructor
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_type_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_type_request.h
index 1166d3f774..7f2e8389ad 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_type_request.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_type_request.h
@@ -34,6 +34,7 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_VEHICLE_TYPE_REQUEST_H_
#include "application_manager/commands/request_to_hmi.h"
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
namespace vehicle_info_plugin {
namespace app_mngr = application_manager;
@@ -51,10 +52,7 @@ class VIGetVehicleTypeRequest : public app_mngr::commands::RequestToHMI {
* @param message Incoming SmartObject message
**/
VIGetVehicleTypeRequest(const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle);
+ const VehicleInfoCommandParams& params);
/**
* @brief VIGetVehicleTypeRequest class destructor
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_type_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_type_response.h
index 00c1944c0f..f71eda8077 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_type_response.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_type_response.h
@@ -34,6 +34,7 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_VEHICLE_TYPE_RESPONSE_H_
#include "application_manager/commands/response_from_hmi.h"
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
namespace vehicle_info_plugin {
namespace app_mngr = application_manager;
@@ -50,12 +51,8 @@ class VIGetVehicleTypeResponse : public app_mngr::commands::ResponseFromHMI {
*
* @param message Incoming SmartObject message
**/
- VIGetVehicleTypeResponse(
- const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- application_manager::rpc_service::RPCService& rpc_service,
- application_manager::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle);
+ VIGetVehicleTypeResponse(const app_mngr::commands::MessageSharedPtr& message,
+ const VehicleInfoCommandParams& params);
/**
* @brief VIGetVehicleTypeResponse class destructor
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_is_ready_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_is_ready_request.h
index 7a8ca3a4b6..fa9bfebad4 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_is_ready_request.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_is_ready_request.h
@@ -34,6 +34,7 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_IS_READY_REQUEST_H_
#include "application_manager/commands/request_to_hmi.h"
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
namespace vehicle_info_plugin {
namespace app_mngr = application_manager;
@@ -52,10 +53,7 @@ class VIIsReadyRequest : public app_mngr::commands::RequestToHMI,
* @param message Incoming SmartObject message
**/
VIIsReadyRequest(const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle);
+ const VehicleInfoCommandParams& params);
/**
* @brief VIIsReadyRequest class destructor
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_is_ready_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_is_ready_response.h
index e0ff20b8bb..f87d9370f5 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_is_ready_response.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_is_ready_response.h
@@ -35,6 +35,7 @@
#include "application_manager/application_manager.h"
#include "application_manager/commands/response_from_hmi.h"
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
namespace vehicle_info_plugin {
namespace app_mngr = application_manager;
@@ -52,10 +53,7 @@ class VIIsReadyResponse : public app_mngr::commands::ResponseFromHMI {
* @param message Incoming SmartObject message
**/
VIIsReadyResponse(const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle);
+ const VehicleInfoCommandParams& params);
/**
* @brief VIIsReadyResponse class destructor
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_read_did_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_read_did_request.h
index 1e91a4c3af..63bbf10e41 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_read_did_request.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_read_did_request.h
@@ -34,6 +34,7 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_READ_DID_REQUEST_H_
#include "application_manager/commands/request_to_hmi.h"
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
namespace vehicle_info_plugin {
namespace app_mngr = application_manager;
@@ -51,10 +52,7 @@ class VIReadDIDRequest : public app_mngr::commands::RequestToHMI {
* @param message Incoming SmartObject message
**/
VIReadDIDRequest(const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle);
+ const VehicleInfoCommandParams& params);
/**
* @brief VIReadDIDRequest class destructor
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_read_did_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_read_did_response.h
index f659f7ae87..307960e145 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_read_did_response.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_read_did_response.h
@@ -34,6 +34,7 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_READ_DID_RESPONSE_H_
#include "application_manager/commands/response_from_hmi.h"
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
namespace vehicle_info_plugin {
namespace app_mngr = application_manager;
@@ -51,10 +52,7 @@ class VIReadDIDResponse : public app_mngr::commands::ResponseFromHMI {
* @param message Incoming SmartObject message
**/
VIReadDIDResponse(const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle);
+ const VehicleInfoCommandParams& params);
/**
* @brief VIReadDIDResponse class destructor
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_subscribe_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_subscribe_vehicle_data_request.h
index dab5989e9e..0e91006e52 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_subscribe_vehicle_data_request.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_subscribe_vehicle_data_request.h
@@ -34,6 +34,8 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_SUBSCRIBE_VEHICLE_DATA_REQUEST_H_
#include "application_manager/commands/request_to_hmi.h"
+#include "vehicle_info_plugin/custom_vehicle_data_manager.h"
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
namespace vehicle_info_plugin {
namespace app_mngr = application_manager;
@@ -52,10 +54,7 @@ class VISubscribeVehicleDataRequest : public app_mngr::commands::RequestToHMI {
**/
VISubscribeVehicleDataRequest(
const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle);
+ const VehicleInfoCommandParams& params);
/**
* @brief VISubscribeVehicleDataRequest class destructor
@@ -68,6 +67,8 @@ class VISubscribeVehicleDataRequest : public app_mngr::commands::RequestToHMI {
virtual void Run();
private:
+ CustomVehicleDataManager& custom_vehicle_data_manager_;
+
DISALLOW_COPY_AND_ASSIGN(VISubscribeVehicleDataRequest);
};
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_subscribe_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_subscribe_vehicle_data_response.h
index 8eea8d0cfa..523867d87e 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_subscribe_vehicle_data_response.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_subscribe_vehicle_data_response.h
@@ -34,6 +34,7 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_SUBSCRIBE_VEHICLE_DATA_RESPONSE_H_
#include "application_manager/commands/response_from_hmi.h"
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
namespace vehicle_info_plugin {
namespace app_mngr = application_manager;
@@ -53,10 +54,7 @@ class VISubscribeVehicleDataResponse
**/
VISubscribeVehicleDataResponse(
const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle);
+ const VehicleInfoCommandParams& params);
/**
* @brief VISubscribeVehicleDataResponse class destructor
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_unsubscribe_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_unsubscribe_vehicle_data_request.h
index a8ebf34ea2..4e3cc59c2e 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_unsubscribe_vehicle_data_request.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_unsubscribe_vehicle_data_request.h
@@ -34,6 +34,8 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_UNSUBSCRIBE_VEHICLE_DATA_REQUEST_H_
#include "application_manager/commands/request_to_hmi.h"
+#include "vehicle_info_plugin/custom_vehicle_data_manager.h"
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
namespace vehicle_info_plugin {
namespace app_mngr = application_manager;
@@ -53,10 +55,7 @@ class VIUnsubscribeVehicleDataRequest
**/
VIUnsubscribeVehicleDataRequest(
const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle);
+ const VehicleInfoCommandParams& params);
/**
* @brief VIUnsubscribeVehicleDataRequest class destructor
@@ -69,6 +68,8 @@ class VIUnsubscribeVehicleDataRequest
virtual void Run();
private:
+ CustomVehicleDataManager& custom_vehicle_data_manager_;
+
DISALLOW_COPY_AND_ASSIGN(VIUnsubscribeVehicleDataRequest);
};
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_unsubscribe_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_unsubscribe_vehicle_data_response.h
index 780d1e9eae..e8f2267ce6 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_unsubscribe_vehicle_data_response.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_unsubscribe_vehicle_data_response.h
@@ -34,6 +34,7 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_UNSUBSCRIBE_VEHICLE_DATA_RESPONSE_H_
#include "application_manager/commands/response_from_hmi.h"
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
namespace vehicle_info_plugin {
namespace app_mngr = application_manager;
@@ -53,10 +54,7 @@ class VIUnsubscribeVehicleDataResponse
**/
VIUnsubscribeVehicleDataResponse(
const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle);
+ const VehicleInfoCommandParams& params);
/**
* @brief VIUnsubscribeVehicleDataResponse class destructor
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/diagnostic_message_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/diagnostic_message_request.h
index bd9ce31325..56f0e39621 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/diagnostic_message_request.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/diagnostic_message_request.h
@@ -36,6 +36,7 @@
#include "application_manager/commands/command_request_impl.h"
#include "utils/macro.h"
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
namespace vehicle_info_plugin {
namespace app_mngr = application_manager;
@@ -53,10 +54,7 @@ class DiagnosticMessageRequest : public app_mngr::commands::CommandRequestImpl {
* @param message Incoming SmartObject message
**/
DiagnosticMessageRequest(const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler);
+ const VehicleInfoCommandParams& params);
/**
* @brief DiagnosticMessageRequest class destructor
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/diagnostic_message_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/diagnostic_message_response.h
index 7b6364fe41..5308551f5a 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/diagnostic_message_response.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/diagnostic_message_response.h
@@ -36,6 +36,7 @@
#include "application_manager/commands/command_response_impl.h"
#include "utils/macro.h"
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
namespace vehicle_info_plugin {
namespace app_mngr = application_manager;
@@ -54,10 +55,7 @@ class DiagnosticMessageResponse
* @param message Incoming SmartObject message
**/
DiagnosticMessageResponse(const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler);
+ const VehicleInfoCommandParams& params);
/**
* @brief DiagnosticMessageResponse class destructor
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_dtcs_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_dtcs_request.h
index 9175900610..562d7f236b 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_dtcs_request.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_dtcs_request.h
@@ -36,6 +36,7 @@
#include "application_manager/commands/command_request_impl.h"
#include "utils/macro.h"
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
namespace vehicle_info_plugin {
namespace app_mngr = application_manager;
@@ -53,10 +54,7 @@ class GetDTCsRequest : public app_mngr::commands::CommandRequestImpl {
* @param message Incoming SmartObject message
**/
GetDTCsRequest(const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler);
+ const VehicleInfoCommandParams& params);
/**
* @brief GetDTCsRequest class destructor
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_dtcs_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_dtcs_response.h
index 473174fd0d..52836e895f 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_dtcs_response.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_dtcs_response.h
@@ -36,6 +36,7 @@
#include "application_manager/commands/command_response_impl.h"
#include "utils/macro.h"
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
namespace vehicle_info_plugin {
namespace app_mngr = application_manager;
@@ -53,10 +54,7 @@ class GetDTCsResponse : public app_mngr::commands::CommandResponseImpl {
* @param message Incoming SmartObject message
**/
GetDTCsResponse(const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler);
+ const VehicleInfoCommandParams& params);
/**
* @brief GetDTCsResponse class destructor
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_vehicle_data_request.h
index ff04ca1e2c..8a594b0647 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_vehicle_data_request.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_vehicle_data_request.h
@@ -36,12 +36,11 @@
#include "application_manager/commands/command_request_impl.h"
#include "utils/macro.h"
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
namespace vehicle_info_plugin {
namespace app_mngr = application_manager;
-class SmartObject;
-
namespace commands {
/**
@@ -55,10 +54,7 @@ class GetVehicleDataRequest : public app_mngr::commands::CommandRequestImpl {
* @param message Incoming SmartObject message
**/
GetVehicleDataRequest(const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler);
+ const VehicleInfoCommandParams& params);
/**
* @brief GetVehicleDataRequest class destructor
@@ -73,6 +69,18 @@ class GetVehicleDataRequest : public app_mngr::commands::CommandRequestImpl {
protected:
virtual void on_event(const app_mngr::event_engine::Event& event);
+ private:
+ /**
+ * @brief CheckFrequency check if mobile does not spam SDL with frequent
+ * GetVehicleData requests
+ * @return
+ */
+ bool CheckFrequency(application_manager::Application& app);
+
+ std::set<std::string> pending_vehicle_data_;
+
+ CustomVehicleDataManager& custom_vehicle_data_manager_;
+
DISALLOW_COPY_AND_ASSIGN(GetVehicleDataRequest);
};
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_vehicle_data_response.h
index 25fd27b67c..8d9722b2b6 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_vehicle_data_response.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_vehicle_data_response.h
@@ -36,7 +36,7 @@
#include "application_manager/commands/command_response_impl.h"
#include "utils/macro.h"
-
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
namespace vehicle_info_plugin {
namespace app_mngr = application_manager;
@@ -53,10 +53,7 @@ class GetVehicleDataResponse : public app_mngr::commands::CommandResponseImpl {
* @param message Incoming SmartObject message
**/
GetVehicleDataResponse(const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler);
+ const VehicleInfoCommandParams& params);
/**
* @brief GetVehicleDataResponse class destructor
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/on_vehicle_data_notification.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/on_vehicle_data_notification.h
index ce1b732775..9163e78b5e 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/on_vehicle_data_notification.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/on_vehicle_data_notification.h
@@ -37,6 +37,8 @@
#include "application_manager/application.h"
#include "application_manager/commands/command_notification_impl.h"
#include "utils/macro.h"
+#include "vehicle_info_plugin/custom_vehicle_data_manager.h"
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
namespace vehicle_info_plugin {
namespace app_mngr = application_manager;
@@ -56,10 +58,7 @@ class OnVehicleDataNotification
* @param message Incoming SmartObject message
**/
OnVehicleDataNotification(const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler);
+ const VehicleInfoCommandParams& params);
/**
* @brief OnVehicleDataNotification class destructor
@@ -79,6 +78,8 @@ class OnVehicleDataNotification
*/
void SendVehicleData(app_mngr::ApplicationConstSharedPtr app);
+ CustomVehicleDataManager& custom_vehicle_data_manager_;
+
DISALLOW_COPY_AND_ASSIGN(OnVehicleDataNotification);
};
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/read_did_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/read_did_request.h
index d006cf02ef..8566075504 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/read_did_request.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/read_did_request.h
@@ -36,7 +36,7 @@
#include "application_manager/commands/command_request_impl.h"
#include "utils/macro.h"
-
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
namespace vehicle_info_plugin {
namespace app_mngr = application_manager;
@@ -53,10 +53,7 @@ class ReadDIDRequest : public app_mngr::commands::CommandRequestImpl {
* @param message Incoming SmartObject message
**/
ReadDIDRequest(const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler);
+ const VehicleInfoCommandParams& params);
/**
* @brief ReadDIDRequest class destructor
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/read_did_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/read_did_response.h
index d3c0e14c93..30e5aa45de 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/read_did_response.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/read_did_response.h
@@ -36,7 +36,7 @@
#include "application_manager/commands/command_response_impl.h"
#include "utils/macro.h"
-
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
namespace vehicle_info_plugin {
namespace app_mngr = application_manager;
@@ -53,10 +53,7 @@ class ReadDIDResponse : public app_mngr::commands::CommandResponseImpl {
* @param message Incoming SmartObject message
**/
ReadDIDResponse(const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler);
+ const VehicleInfoCommandParams& params);
/**
* @brief ReadDIDResponse class destructor
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 2671173ba3..deac8a8295 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
@@ -40,7 +40,9 @@
#include "application_manager/application.h"
#include "application_manager/commands/command_request_impl.h"
#include "utils/macro.h"
+#include "vehicle_info_plugin/custom_vehicle_data_manager.h"
#include "vehicle_info_plugin/vehicle_info_app_extension.h"
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
namespace vehicle_info_plugin {
namespace app_mngr = application_manager;
@@ -60,10 +62,7 @@ class SubscribeVehicleDataRequest
**/
SubscribeVehicleDataRequest(
const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler);
+ VehicleInfoCommandParams params);
/**
* @brief SubscribeButtonCommandRequest class destructor
@@ -94,7 +93,7 @@ class SubscribeVehicleDataRequest
* @return true, if there are registered apps subscribed for VI parameter,
* otherwise - false
*/
- bool IsSomeoneSubscribedFor(const uint32_t param_id) const;
+ bool IsSomeoneSubscribedFor(const std::string& param_name) const;
/**
* @brief Adds VI parameters being subscribed by another or the same app to
@@ -104,14 +103,14 @@ class SubscribeVehicleDataRequest
void AddAlreadySubscribedVI(smart_objects::SmartObject& msg_params) const;
/**
- * @brief Removes subscription for VI parameters which subsription attempt
- * returned an error
+ * @brief Actual subscription to pending vehicle data after successful
+ * response from HMI
* @param app Pointer to application sent subscribe request
* @param msg_params 'message_parameters' response section reference
*/
- void UnsubscribeFailedSubscriptions(
+ bool SubscribePendingVehicleData(
app_mngr::ApplicationSharedPtr app,
- const smart_objects::SmartObject& msg_params) const;
+ const smart_objects::SmartObject& msg_params);
/**
* @brief Checks if current application and other applications
@@ -134,6 +133,43 @@ class SubscribeVehicleDataRequest
bool& out_result);
/**
+ * @brief ConvertResponseToRequestName convert RPCSpec vehicle data names
+ * from response naming to request naming.
+ * This is workaround for cluster mode.
+ * Parameter named in request message as `cluster_mode` and in response
+ * message as `cluster_mode_status`
+ * @param name mobile RPCSpec vehicle data name
+ * @return hmi RPCSpec vehicle data name
+ */
+ const std::string& ConvertResponseToRequestName(const std::string& name);
+
+ /**
+ * @brief ConvertRequestToResponseName convert RPCSpec vehicle data names from
+ * request to response
+ * * This is workaround for cluster mode.
+ * Parameter named in request message as `cluster_mode` and in response
+ * message as `cluster_mode_status`
+ * @param name mobile RPCSpec vehicle data name
+ * @return hmi RPCSpec vehicle data name
+ */
+ const std::string& ConvertRequestToResponseName(const std::string& name);
+
+ /**
+ * @brief Appends data types for vehicle data in response to mobile
+ * @param msg_params 'message_parameters' response section reference
+ */
+ void AppendDataTypesToMobileResponse(
+ smart_objects::SmartObject& msg_params) const;
+
+ /**
+ * @brief Checks subscription status of certain vehicle_item
+ * @param vi_name name of vehicle item to be checked
+ * @param msg_params 'message_parameters' response section reference
+ */
+ bool CheckSubscriptionStatus(std::string vi_name,
+ const smart_objects::SmartObject& msg_params);
+
+ /**
* @brief VI parameters which had been already subscribed by another apps
* befor particular app subscribed for these parameters
*/
@@ -149,6 +185,8 @@ class SubscribeVehicleDataRequest
*/
VehicleInfoSubscriptions vi_waiting_for_subscribe_;
+ CustomVehicleDataManager& custom_vehicle_data_manager_;
+
DISALLOW_COPY_AND_ASSIGN(SubscribeVehicleDataRequest);
};
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_response.h
index 2212af0846..39af8b019b 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_response.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_response.h
@@ -36,7 +36,7 @@
#include "application_manager/commands/command_response_impl.h"
#include "utils/macro.h"
-
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
namespace vehicle_info_plugin {
namespace app_mngr = application_manager;
@@ -55,10 +55,7 @@ class SubscribeVehicleDataResponse
**/
SubscribeVehicleDataResponse(
const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler);
+ const VehicleInfoCommandParams& params);
/**
* @brief UnsubscribeVehicleDataCommandRequest class destructor
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_request.h
index b246dbc9ef..4f2a01244f 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_request.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_request.h
@@ -37,7 +37,9 @@
#include "application_manager/application.h"
#include "application_manager/commands/command_request_impl.h"
#include "utils/macro.h"
+#include "vehicle_info_plugin/custom_vehicle_data_manager.h"
#include "vehicle_info_plugin/vehicle_info_app_extension.h"
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
namespace vehicle_info_plugin {
namespace app_mngr = application_manager;
@@ -57,10 +59,7 @@ class UnsubscribeVehicleDataRequest
**/
UnsubscribeVehicleDataRequest(
const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler);
+ const VehicleInfoCommandParams& params);
/**
* @brief UnsubscribeVehicleDataRequest class destructor
@@ -91,7 +90,7 @@ class UnsubscribeVehicleDataRequest
* @return true, if there are registered apps subscribed for VI parameter,
* otherwise - false
*/
- bool IsSomeoneSubscribedFor(const uint32_t param_id) const;
+ bool IsSomeoneSubscribedFor(const std::string& param_name) const;
/**
* @brief Adds VI parameters being unsubscribed by another or the same app to
@@ -101,16 +100,67 @@ class UnsubscribeVehicleDataRequest
void AddAlreadyUnsubscribedVI(smart_objects::SmartObject& response) const;
/**
+ * @brief Actual unsubscription from all pending vehicle data. To be called
+ * after successful HMI response
+ * @param app shared pointer to application, which initialized unsubscription
+ * @param msg_params 'message_params' response section reference
+ */
+ bool UnsubscribePendingVehicleData(
+ app_mngr::ApplicationSharedPtr app,
+ const smart_objects::SmartObject& msg_params);
+
+ /**
+ * @brief ConvertRequestToResponseName convert RPCSpec vehicle data names
+ * from hmi api to mobile api
+ * @param name mobile RPCSpec vehicle data name
+ * @return hmi RPCSpec vehicle data name
+ */
+ const std::string& ConvertRequestToResponseName(const std::string& name);
+
+ /**
+ * @brief ConvertResponseToRequestName convert RPCSpec vehicle data names
+ * from hmi api to mobile api
+ * @param name mobile RPCSpec vehicle data name
+ * @return hmi RPCSpec vehicle data name
+ */
+ const std::string& ConvertResponseToRequestName(const std::string& name);
+
+ /**
+ * @brief Appends data types for vehicle data in response to mobile
+ * @param msg_params 'message_parameters' response section reference
+ */
+ void AppendDataTypesToMobileResponse(
+ smart_objects::SmartObject& msg_params) const;
+
+ /**
+ * @brief Checks subscription status of certain vehicle_item
+ * @param key name of vehicle item to be checked
+ * @param msg_params 'message_parameters' response section reference
+ */
+ bool CheckSubscriptionStatus(std::string key,
+ const smart_objects::SmartObject& msg_params);
+
+ smart_objects::SmartObject response_params_;
+
+ /**
* @brief VI parameters which still being subscribed by another apps after
* particular app had been unsubscribed from these parameters
*/
VehicleInfoSubscriptions vi_still_subscribed_by_another_apps_;
/**
- * @brief VI parameters which had been unsubscribed already by particular app
+ * @brief VI parameters which had been unsubscribed already by particular
+ * app
*/
VehicleInfoSubscriptions vi_already_unsubscribed_by_this_app_;
+ /**
+ * @brief VI parameters to be unsubscribed after HMI response
+ */
+ VehicleInfoSubscriptions vi_waiting_for_unsubscribe_;
+
+ CustomVehicleDataManager& custom_vehicle_data_manager_;
+
DISALLOW_COPY_AND_ASSIGN(UnsubscribeVehicleDataRequest);
};
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_response.h
index 67f09a68a8..f181e7f8c3 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_response.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_response.h
@@ -36,7 +36,7 @@
#include "application_manager/commands/command_response_impl.h"
#include "utils/macro.h"
-
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
namespace vehicle_info_plugin {
namespace app_mngr = application_manager;
@@ -55,10 +55,7 @@ class UnsubscribeVehicleDataResponse
**/
UnsubscribeVehicleDataResponse(
const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler);
+ const VehicleInfoCommandParams& params);
/**
* @brief UnsubscribeVehicleDataResponse class destructor
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/custom_vehicle_data_manager.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/custom_vehicle_data_manager.h
new file mode 100644
index 0000000000..45c7da726d
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/custom_vehicle_data_manager.h
@@ -0,0 +1,44 @@
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_CUSTOM_VEHICLE_DATA_MANAGER_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_CUSTOM_VEHICLE_DATA_MANAGER_H_
+#include <set>
+#include <string>
+
+#include "application_manager/plugin_manager/rpc_plugin.h"
+#include "application_manager/rpc_handler.h"
+#include "smart_objects/smart_object.h"
+
+namespace vehicle_info_plugin {
+
+namespace plugin_manager = application_manager::plugin_manager;
+
+class CustomVehicleDataManager {
+ public:
+ /**
+ * @brief Creates message params (nested if needed) to be sent to HMI
+ * according to vehicle data item schema
+ * @param item_names set of names of vehicle data items to be processed
+ * @return smartMap with prepared message params
+ */
+ virtual smart_objects::SmartObject CreateHMIMessageParams(
+ const std::set<std::string>& item_names) = 0;
+
+ /**
+ * @brief Gets data type of vehicle data item
+ * @param vehicle_data_item_name name of vehicle data
+ * @return data type of vehicle_data if one found, item name otherwise
+ */
+ virtual std::string GetVehicleDataItemType(
+ const std::string& vehicle_data_item_name) const = 0;
+
+ /**
+ * @brief Creates message params (nested if needed) to be sent to Mobile
+ * according to vehicle data item schema
+ * @param input_params message params received from hmi
+ */
+ virtual void CreateMobileMessageParams(
+ smart_objects::SmartObject& msg_params) = 0;
+
+ virtual void OnPolicyEvent(plugin_manager::PolicyEvent policy_event) = 0;
+};
+} // namespace vehicle_info_plugin
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_CUSTOM_VEHICLE_DATA_MANAGER_H_
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/custom_vehicle_data_manager_impl.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/custom_vehicle_data_manager_impl.h
new file mode 100644
index 0000000000..1d689b087b
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/custom_vehicle_data_manager_impl.h
@@ -0,0 +1,97 @@
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_VEHICLE_DATA_VALIDATION_MANAGER_IMPL_H
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_VEHICLE_DATA_VALIDATION_MANAGER_IMPL_H
+
+#include <boost/optional.hpp>
+
+#include "smart_objects/smart_object.h"
+#include "vehicle_info_plugin/custom_vehicle_data_manager.h"
+
+namespace rpc {
+namespace policy_table_interface_base {
+class VehicleDataItem;
+}
+} // namespace rpc
+
+namespace policy {
+class VehicleDataItemProvider;
+}
+
+namespace vehicle_info_plugin {
+namespace policy_table = rpc::policy_table_interface_base;
+namespace plugin_manager = application_manager::plugin_manager;
+
+typedef boost::optional<const policy_table::VehicleDataItem> OptionalDataItem;
+typedef std::set<std::string> VehicleInfoSubscriptions;
+
+class CustomVehicleDataManagerImpl : public CustomVehicleDataManager {
+ public:
+ CustomVehicleDataManagerImpl(
+ policy::VehicleDataItemProvider& vehicle_data_provider,
+ application_manager::rpc_service::RPCService& rpc_service);
+
+ virtual smart_objects::SmartObject CreateHMIMessageParams(
+ const std::set<std::string>& item_names) OVERRIDE;
+
+ std::string GetVehicleDataItemType(
+ const std::string& vehicle_data_item_name) const OVERRIDE;
+
+ virtual void CreateMobileMessageParams(
+ smart_objects::SmartObject& msg_params) OVERRIDE;
+
+ void OnPolicyEvent(plugin_manager::PolicyEvent policy_event) OVERRIDE;
+
+ private:
+ class RPCParams {
+ public:
+ RPCParams() {}
+ ~RPCParams() {}
+
+ void addBoolParam(
+ const std::pair<std::string, smart_objects::SMember>& param) {
+ rpc_params_bool_.insert(param);
+ }
+ void addVDRParam(
+ const std::pair<std::string, smart_objects::SMember>& param) {
+ rpc_params_vdr_.insert(param);
+ }
+ void addParam(const std::pair<std::string, smart_objects::SMember>& param) {
+ rpc_params_.insert(param);
+ }
+
+ const std::map<std::string, smart_objects::SMember>& getBoolParams() {
+ return rpc_params_bool_;
+ }
+ const std::map<std::string, smart_objects::SMember>& getVDRParams() {
+ return rpc_params_vdr_;
+ }
+ const std::map<std::string, smart_objects::SMember>& getParams() {
+ return rpc_params_;
+ }
+
+ private:
+ std::map<std::string, smart_objects::SMember> rpc_params_bool_;
+ std::map<std::string, smart_objects::SMember> rpc_params_vdr_;
+ std::map<std::string, smart_objects::SMember> rpc_params_;
+ };
+
+ /**
+ * @brief Updates vehicle data schemas according to policy update.
+ */
+ void UpdateVehicleDataItems();
+
+ const OptionalDataItem FindSchemaByNameNonRecursive(
+ const std::string& name) const;
+ const OptionalDataItem FindSchemaByKeyNonRecursive(
+ const std::string& key) const;
+ const OptionalDataItem FindSchemaByNameRecursive(
+ const std::string& name) const;
+ const OptionalDataItem FindSchemaByKeyRecursive(
+ const std::string& name) const;
+
+ policy::VehicleDataItemProvider& vehicle_data_provider_;
+ application_manager::rpc_service::RPCService& rpc_service_;
+};
+
+} // namespace vehicle_info_plugin
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_VEHICLE_DATA_VALIDATION_MANAGER_IMPL_H
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_data_item_schema.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_data_item_schema.h
new file mode 100644
index 0000000000..5ea73e2dec
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_data_item_schema.h
@@ -0,0 +1,115 @@
+#ifndef VEHICLE_DATA_ITEM_SCHEMA_H
+#define VEHICLE_DATA_ITEM_SCHEMA_H
+#include "policy/policy_table/types.h"
+#include "smart_objects/always_false_schema_item.h"
+#include "smart_objects/always_true_schema_item.h"
+#include "smart_objects/array_schema_item.h"
+#include "smart_objects/bool_schema_item.h"
+#include "smart_objects/enum_schema_item.h"
+#include "smart_objects/number_schema_item.h"
+#include "smart_objects/object_schema_item.h"
+#include "smart_objects/schema_item.h"
+#include "smart_objects/schema_item_parameter.h"
+#include "smart_objects/smart_object.h"
+#include "smart_objects/string_schema_item.h"
+#include "utils/logger.h"
+
+namespace vehicle_info_plugin {
+namespace smart_objects = ns_smart_device_link::ns_smart_objects;
+namespace policy_table = rpc::policy_table_interface_base;
+
+class VehicleDataItemSchema;
+typedef std::shared_ptr<VehicleDataItemSchema> VehicleDataItemSchemaPtr;
+typedef smart_objects::TSchemaItemParameter<policy_table::VehicleDataItem>
+ PolicyDataItem;
+
+/**
+ * @brief VehicleData schema item.
+ **/
+class VehicleDataItemSchema : public smart_objects::ISchemaItem {
+ public:
+ enum SchemaType { MOBILE = 0, HMI };
+
+ /**
+ * @brief Create a new schema item.
+ * @param PolicyDataItem& SchemaItem for VehicleDataItem elements.
+ * @return Shared pointer to a new schema item.
+ **/
+ static VehicleDataItemSchemaPtr create(PolicyDataItem& policy_item,
+ SchemaType schema_type);
+
+ /**
+ * @brief Validate smart object.
+ * @param Object Object to validate.
+ * @param report__ object for reporting errors during validation
+ * @param MessageVersion to check mobile RPC version against RPC Spec History
+ * @param allow_unknown_enums
+ * false - unknown enum values (left as string values after applySchema)
+ * will be considered invalid.
+ * true - such values will be considered valid.
+ * @return ns_smart_objects::errors::eType
+ **/
+ smart_objects::errors::eType validate(
+ const smart_objects::SmartObject& Object,
+ rpc::ValidationReport* report__,
+ const utils::SemanticVersion& MessageVersion = utils::SemanticVersion(),
+ const bool allow_unknown_enums = false) OVERRIDE;
+
+ private:
+ /**
+ * @brief Constructor.
+ * @param PolicyDataItem& SchemaItem for VehicleDataItem elements.
+ * @param SchemaType defines api type for schema to be generated.
+ **/
+ VehicleDataItemSchema(PolicyDataItem& policy_item, SchemaType schema_type);
+
+ /*
+ * @brief Check whether provided type is POD type
+ * @param const std::string& type_name - name of type to check
+ * @return true - if type is POD type and false - if not
+ */
+ const bool isPODType(const std::string& type_name) const;
+
+ /*
+ * @brief Get Enum schema for provided type
+ * @param const std::string& type_name - name of enum type to provide
+ * @return Shared pointer to a new schema item. If no schema found - nullptr
+ * is returned.
+ */
+ smart_objects::ISchemaItemPtr getEnumSchema(
+ const std::string& type_name) const;
+
+ /**
+ * @brief Apply schema.
+ * @param Object Object to apply schema.
+ * @param remove_unknown_parameters contains true if need to remove unknown
+ * parameters from smart object otherwise contains false.
+ **/
+ void applySchema(smart_objects::SmartObject& Object,
+ const bool remove_unknown_parameters,
+ const utils::SemanticVersion& MessageVersion) OVERRIDE;
+
+ /**
+ * @brief Unapply schema.
+ * @param Object Object to unapply schema.
+ * @param remove_unknown_parameters contains true if need to remove unknown
+ * parameters
+ **/
+ void unapplySchema(smart_objects::SmartObject& Object,
+ const bool remove_unknown_parameters) OVERRIDE;
+
+ /*
+ * @brief Get schema for a POD type
+ * @param const VehicleDataItem& policy_item - item, that contains info about
+ * type
+ * @return Shared pointer to a new schema item. If no schema found - nullptr
+ * is returned.
+ */
+ smart_objects::ISchemaItemPtr GetPODTypeSchema(
+ const policy_table::VehicleDataItem& policy_item, SchemaType schema_type);
+
+ smart_objects::ISchemaItemPtr so_schema_item_;
+};
+
+} // namespace vehicle_info_plugin
+#endif // VEHICLE_DATA_ITEM_SCHEMA_H
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_app_extension.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_app_extension.h
index b3ba768b1b..fb7c2b0f82 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_app_extension.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_app_extension.h
@@ -47,7 +47,7 @@ typedef mobile_apis::VehicleDataType::eType VehicleDataType;
/**
* @brief Defines set of vehicle info types
*/
-typedef std::set<mobile_apis::VehicleDataType::eType> VehicleInfoSubscriptions;
+typedef std::set<std::string> VehicleInfoSubscriptions;
class VehicleInfoAppExtension : public app_mngr::AppExtension {
public:
@@ -66,7 +66,7 @@ class VehicleInfoAppExtension : public app_mngr::AppExtension {
* @param vehicle_data data to subscribe
* @return true in case if subscription is successful
*/
- bool subscribeToVehicleInfo(const VehicleDataType vehicle_data);
+ bool subscribeToVehicleInfo(const std::string& vehicle_data);
/**
* @brief unsubscribeFromVehicleInfo remove vehicle_data from list of
@@ -74,7 +74,7 @@ class VehicleInfoAppExtension : public app_mngr::AppExtension {
* @param vehicle_data data to unsubscribe
* @return true in case if unsubscription is successful
*/
- bool unsubscribeFromVehicleInfo(const VehicleDataType vehicle_data);
+ bool unsubscribeFromVehicleInfo(const std::string& vehicle_data);
/**
* @brief unsubscribeFromVehicleInfo unsubscribe from all vehicle info data
*/
@@ -87,7 +87,7 @@ class VehicleInfoAppExtension : public app_mngr::AppExtension {
* @return true if extension is subscribed this vehicle_data_type, otherwise
* return false
*/
- bool isSubscribedToVehicleInfo(const VehicleDataType vehicle_data_type) const;
+ bool isSubscribedToVehicleInfo(const std::string& vehicle_data_type) const;
/**
* @brief Subscriptions get list of subscriptions for application extension
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_command_factory.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_command_factory.h
index 58100ba1ae..3356f0f823 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_command_factory.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_command_factory.h
@@ -34,36 +34,37 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_VEHICLE_INFO_COMMAND_FACTORY_H
#include "application_manager/application_manager.h"
+#include "vehicle_info_plugin/custom_vehicle_data_manager.h"
#include "vehicle_info_plugin/vehicle_info_hmi_command_factory.h"
#include "vehicle_info_plugin/vehicle_info_mobile_command_factory.h"
namespace vehicle_info_plugin {
-namespace app_mngr = application_manager;
-namespace commands = application_manager::commands;
-
/**
* @brief The Vehicle Info command factory.
*/
-class VehicleInfoCommandFactory : public app_mngr::CommandFactory {
+class VehicleInfoCommandFactory : public application_manager::CommandFactory {
public:
- VehicleInfoCommandFactory(app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler);
+ VehicleInfoCommandFactory(
+ application_manager::ApplicationManager& application_manager,
+ application_manager::rpc_service::RPCService& rpc_service,
+ application_manager::HMICapabilities& hmi_capabilities,
+ policy::PolicyHandlerInterface& policy_handler,
+ CustomVehicleDataManager& custom_vehicle_data_manager);
virtual ~VehicleInfoCommandFactory();
- app_mngr::CommandSharedPtr CreateCommand(
- const commands::MessageSharedPtr& message,
- commands::Command::CommandSource source) OVERRIDE;
+ application_manager::CommandSharedPtr CreateCommand(
+ const application_manager::commands::MessageSharedPtr& message,
+ application_manager::commands::Command::CommandSource source) OVERRIDE;
bool IsAbleToProcess(
const int32_t function_id,
- const commands::Command::CommandSource source) const OVERRIDE;
+ const application_manager::commands::Command::CommandSource source)
+ const OVERRIDE;
private:
- std::unique_ptr<app_mngr::CommandFactory> hmi_command_factory_;
- std::unique_ptr<app_mngr::CommandFactory> mob_command_factory_;
+ std::unique_ptr<application_manager::CommandFactory> hmi_command_factory_;
+ std::unique_ptr<application_manager::CommandFactory> mob_command_factory_;
};
} // namespace vehicle_info_plugin
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_command_params.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_command_params.h
new file mode 100644
index 0000000000..df8dbfd802
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_command_params.h
@@ -0,0 +1,31 @@
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_VEHICLE_INFO_COMMAND_PARAMS_H
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_VEHICLE_INFO_COMMAND_PARAMS_H
+
+namespace application_manager {
+class ApplicationManager;
+class HMICapabilities;
+namespace rpc_service {
+class RPCService;
+}
+class ApplicationManager;
+} // namespace application_manager
+
+namespace policy {
+class PolicyHandlerInterface;
+}
+
+namespace vehicle_info_plugin {
+namespace app_mngr = application_manager;
+
+class CustomVehicleDataManager;
+
+struct VehicleInfoCommandParams {
+ app_mngr::ApplicationManager& application_manager_;
+ app_mngr::rpc_service::RPCService& rpc_service_;
+ app_mngr::HMICapabilities& hmi_capabilities_;
+ policy::PolicyHandlerInterface& policy_handler_;
+ CustomVehicleDataManager& custom_vehicle_data_manager_;
+};
+} // namespace vehicle_info_plugin
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_VEHICLE_INFO_COMMAND_PARAMS_H
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_hmi_command_factory.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_hmi_command_factory.h
index c927f3f2bb..60d81b5446 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_hmi_command_factory.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_hmi_command_factory.h
@@ -34,6 +34,8 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_VEHICLE_INFO_HMI_COMMAND_FACTORY_H
#include "application_manager/application_manager.h"
+#include "application_manager/command_factory.h"
+#include "vehicle_info_plugin/custom_vehicle_data_manager.h"
namespace vehicle_info_plugin {
namespace app_mngr = application_manager;
@@ -47,7 +49,8 @@ class VehicleInfoHmiCommandFactory : public app_mngr::CommandFactory {
app_mngr::ApplicationManager& application_manager,
app_mngr::rpc_service::RPCService& rpc_service,
app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler);
+ policy::PolicyHandlerInterface& policy_handler,
+ CustomVehicleDataManager& custom_vehicle_data_manager);
app_mngr::CommandSharedPtr CreateCommand(
const app_mngr::commands::MessageSharedPtr& message,
@@ -62,6 +65,7 @@ class VehicleInfoHmiCommandFactory : public app_mngr::CommandFactory {
app_mngr::rpc_service::RPCService& rpc_service_;
app_mngr::HMICapabilities& hmi_capabilities_;
policy::PolicyHandlerInterface& policy_handler_;
+ CustomVehicleDataManager& custom_vehicle_data_manager_;
app_mngr::CommandCreator& buildCommandCreator(
const int32_t function_id, const int32_t message_type) const;
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_mobile_command_factory.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_mobile_command_factory.h
index 41bd355852..e3403df5e5 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_mobile_command_factory.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_mobile_command_factory.h
@@ -34,7 +34,8 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_VEHICLE_INFO_MOBILE_COMMAND_FACTORY_H
#include "application_manager/application_manager.h"
-
+#include "application_manager/command_factory.h"
+#include "vehicle_info_plugin/custom_vehicle_data_manager.h"
namespace vehicle_info_plugin {
namespace app_mngr = application_manager;
@@ -47,7 +48,8 @@ class VehicleInfoMobileCommandFactory : public app_mngr::CommandFactory {
app_mngr::ApplicationManager& application_manager,
app_mngr::rpc_service::RPCService& rpc_service,
app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler);
+ policy::PolicyHandlerInterface& policy_handler,
+ CustomVehicleDataManager& custom_vehicle_data_manager);
app_mngr::CommandSharedPtr CreateCommand(
const app_mngr::commands::MessageSharedPtr& message,
@@ -62,6 +64,7 @@ class VehicleInfoMobileCommandFactory : public app_mngr::CommandFactory {
app_mngr::rpc_service::RPCService& rpc_service_;
app_mngr::HMICapabilities& hmi_capabilities_;
policy::PolicyHandlerInterface& policy_handler_;
+ CustomVehicleDataManager& custom_vehicle_data_manager_;
app_mngr::CommandCreator& get_creator_factory(
const mobile_apis::FunctionID::eType function_id,
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_plugin.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_plugin.h
index 7b0b0a59b8..4781fa396c 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_plugin.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_plugin.h
@@ -34,6 +34,7 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_VEHICLE_INFO_PLUGIN_H
#include "application_manager/command_factory.h"
+#include "vehicle_info_plugin/custom_vehicle_data_manager.h"
namespace vehicle_info_plugin {
class VehicleInfoAppExtension;
@@ -73,6 +74,7 @@ class VehicleInfoPlugin : public plugins::RPCPlugin {
void DeleteSubscriptions(app_mngr::ApplicationSharedPtr app);
std::unique_ptr<app_mngr::CommandFactory> command_factory_;
+ std::unique_ptr<CustomVehicleDataManager> custom_vehicle_data_manager_;
app_mngr::ApplicationManager* application_manager_;
};
} // namespace vehicle_info_plugin
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/on_vi_vehicle_data_notification.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/on_vi_vehicle_data_notification.cc
index 23dd3da879..b8d1b3a100 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/on_vi_vehicle_data_notification.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/on_vi_vehicle_data_notification.cc
@@ -40,15 +40,12 @@ namespace commands {
OnVIVehicleDataNotification::OnVIVehicleDataNotification(
const application_manager::commands::MessageSharedPtr& message,
- ApplicationManager& application_manager,
- rpc_service::RPCService& rpc_service,
- HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle)
+ const VehicleInfoCommandParams& params)
: NotificationFromHMI(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle) {}
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_) {}
OnVIVehicleDataNotification::~OnVIVehicleDataNotification() {}
@@ -62,9 +59,8 @@ void OnVIVehicleDataNotification::Run() {
const smart_objects::SmartObject& msg_params =
(*message_)[strings::msg_params];
if (msg_params.keyExists(strings::odometer)) {
- application_manager_.IviInfoUpdated(
- mobile_apis::VehicleDataType::VEHICLEDATA_ODOMETER,
- msg_params[strings::odometer].asInt());
+ application_manager_.IviInfoUpdated(strings::odometer,
+ msg_params[strings::odometer].asInt());
}
SendNotificationToMobile(message_);
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_diagnostic_message_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_diagnostic_message_request.cc
index 97d035a20b..ae64c74f26 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_diagnostic_message_request.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_diagnostic_message_request.cc
@@ -38,16 +38,13 @@ using namespace application_manager;
namespace commands {
VIDiagnosticMessageRequest::VIDiagnosticMessageRequest(
- const application_manager::commands::MessageSharedPtr& message,
- ApplicationManager& application_manager,
- rpc_service::RPCService& rpc_service,
- HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle)
+ const app_mngr::commands::MessageSharedPtr& message,
+ const VehicleInfoCommandParams& params)
: RequestToHMI(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle) {}
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_) {}
VIDiagnosticMessageRequest::~VIDiagnosticMessageRequest() {}
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_diagnostic_message_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_diagnostic_message_response.cc
index f4079fc6fd..6482d97d10 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_diagnostic_message_response.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_diagnostic_message_response.cc
@@ -40,15 +40,12 @@ namespace commands {
VIDiagnosticMessageResponse::VIDiagnosticMessageResponse(
const application_manager::commands::MessageSharedPtr& message,
- ApplicationManager& application_manager,
- rpc_service::RPCService& rpc_service,
- HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle)
+ const VehicleInfoCommandParams& params)
: ResponseFromHMI(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle) {}
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_) {}
VIDiagnosticMessageResponse::~VIDiagnosticMessageResponse() {}
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_dtcs_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_dtcs_request.cc
index d67d0909a9..620ee4c3e4 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_dtcs_request.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_dtcs_request.cc
@@ -39,15 +39,12 @@ namespace commands {
VIGetDTCsRequest::VIGetDTCsRequest(
const application_manager::commands::MessageSharedPtr& message,
- ApplicationManager& application_manager,
- rpc_service::RPCService& rpc_service,
- HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle)
+ const VehicleInfoCommandParams& params)
: RequestToHMI(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle) {}
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_) {}
VIGetDTCsRequest::~VIGetDTCsRequest() {}
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_dtcs_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_dtcs_response.cc
index 494e779c4d..64e948a4e1 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_dtcs_response.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_dtcs_response.cc
@@ -40,15 +40,12 @@ namespace commands {
VIGetDTCsResponse::VIGetDTCsResponse(
const application_manager::commands::MessageSharedPtr& message,
- ApplicationManager& application_manager,
- rpc_service::RPCService& rpc_service,
- HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle)
+ const VehicleInfoCommandParams& params)
: ResponseFromHMI(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle) {}
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_) {}
VIGetDTCsResponse::~VIGetDTCsResponse() {}
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_data_request.cc
index e2c1ed4e3a..eded6c685b 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_data_request.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_data_request.cc
@@ -31,6 +31,7 @@
*/
#include "vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_request.h"
+#include "application_manager/message_helper.h"
namespace vehicle_info_plugin {
using namespace application_manager;
@@ -39,24 +40,39 @@ namespace commands {
VIGetVehicleDataRequest::VIGetVehicleDataRequest(
const application_manager::commands::MessageSharedPtr& message,
- ApplicationManager& application_manager,
- rpc_service::RPCService& rpc_service,
- HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle)
+ const VehicleInfoCommandParams& params)
: RequestToHMI(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle) {}
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_)
+ , custom_vehicle_data_manager_(params.custom_vehicle_data_manager_) {}
VIGetVehicleDataRequest::~VIGetVehicleDataRequest() {}
void VIGetVehicleDataRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
+ const auto& rpc_spec_vehicle_data = MessageHelper::vehicle_data();
+ auto& msg_params = (*message_)[strings::msg_params];
+
+ smart_objects::SmartObject custom_data;
+ for (const auto& name : msg_params.enumerate()) {
+ const auto& found_it = rpc_spec_vehicle_data.find(name);
+ if (rpc_spec_vehicle_data.end() == found_it) {
+ custom_data[name] = msg_params[name];
+ msg_params.erase(name);
+ }
+ }
+
+ auto hmi_custom_msg_params =
+ custom_vehicle_data_manager_.CreateHMIMessageParams(
+ custom_data.enumerate());
+ for (const auto& param : hmi_custom_msg_params.enumerate()) {
+ msg_params[param] = hmi_custom_msg_params[param];
+ }
SendRequest();
}
} // namespace commands
-
} // namespace vehicle_info_plugin
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_data_response.cc
index a4b778a487..6a60cc968e 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_data_response.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_data_response.cc
@@ -31,6 +31,8 @@
*/
#include "vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_response.h"
#include "application_manager/event_engine/event.h"
+#include "application_manager/policies/policy_handler_interface.h"
+
#include "interfaces/HMI_API.h"
namespace vehicle_info_plugin {
@@ -39,15 +41,12 @@ namespace commands {
VIGetVehicleDataResponse::VIGetVehicleDataResponse(
const application_manager::commands::MessageSharedPtr& message,
- ApplicationManager& application_manager,
- rpc_service::RPCService& rpc_service,
- HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle)
+ const VehicleInfoCommandParams& params)
: ResponseFromHMI(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle) {}
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_) {}
VIGetVehicleDataResponse::~VIGetVehicleDataResponse() {}
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_type_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_type_request.cc
index 96d27a120b..250584bd12 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_type_request.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_type_request.cc
@@ -39,15 +39,12 @@ namespace commands {
VIGetVehicleTypeRequest::VIGetVehicleTypeRequest(
const application_manager::commands::MessageSharedPtr& message,
- ApplicationManager& application_manager,
- rpc_service::RPCService& rpc_service,
- HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle)
+ const VehicleInfoCommandParams& params)
: RequestToHMI(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle) {}
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_) {}
VIGetVehicleTypeRequest::~VIGetVehicleTypeRequest() {}
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_type_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_type_response.cc
index add55f9a40..fb6eadf747 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_type_response.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_type_response.cc
@@ -38,15 +38,12 @@ namespace commands {
VIGetVehicleTypeResponse::VIGetVehicleTypeResponse(
const application_manager::commands::MessageSharedPtr& message,
- ApplicationManager& application_manager,
- rpc_service::RPCService& rpc_service,
- HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle)
+ const VehicleInfoCommandParams& params)
: ResponseFromHMI(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle) {}
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_) {}
VIGetVehicleTypeResponse::~VIGetVehicleTypeResponse() {}
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_is_ready_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_is_ready_request.cc
index 6479676094..93781a7420 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_is_ready_request.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_is_ready_request.cc
@@ -32,6 +32,7 @@
#include "vehicle_info_plugin/commands/hmi/vi_is_ready_request.h"
#include "application_manager/message_helper.h"
+#include "application_manager/policies/policy_handler_interface.h"
#include "application_manager/rpc_service.h"
namespace vehicle_info_plugin {
@@ -41,16 +42,13 @@ namespace commands {
VIIsReadyRequest::VIIsReadyRequest(
const application_manager::commands::MessageSharedPtr& message,
- ApplicationManager& application_manager,
- rpc_service::RPCService& rpc_service,
- HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle)
+ const VehicleInfoCommandParams& params)
: RequestToHMI(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle)
- , EventObserver(application_manager.event_dispatcher()) {}
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_)
+ , EventObserver(application_manager_.event_dispatcher()) {}
VIIsReadyRequest::~VIIsReadyRequest() {}
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_is_ready_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_is_ready_response.cc
index 0db30afb87..349a1137ce 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_is_ready_response.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_is_ready_response.cc
@@ -38,15 +38,12 @@ namespace commands {
VIIsReadyResponse::VIIsReadyResponse(
const application_manager::commands::MessageSharedPtr& message,
- ApplicationManager& application_manager,
- rpc_service::RPCService& rpc_service,
- HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle)
+ const VehicleInfoCommandParams& params)
: ResponseFromHMI(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle) {}
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_) {}
VIIsReadyResponse::~VIIsReadyResponse() {}
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_read_did_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_read_did_request.cc
index fbcc59849d..47373bb4bf 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_read_did_request.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_read_did_request.cc
@@ -39,15 +39,12 @@ namespace commands {
VIReadDIDRequest::VIReadDIDRequest(
const application_manager::commands::MessageSharedPtr& message,
- ApplicationManager& application_manager,
- rpc_service::RPCService& rpc_service,
- HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle)
+ const VehicleInfoCommandParams& params)
: RequestToHMI(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle) {}
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_) {}
VIReadDIDRequest::~VIReadDIDRequest() {}
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_read_did_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_read_did_response.cc
index 0b8d0f3055..7c2db1e875 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_read_did_response.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_read_did_response.cc
@@ -39,15 +39,12 @@ namespace commands {
VIReadDIDResponse::VIReadDIDResponse(
const application_manager::commands::MessageSharedPtr& message,
- ApplicationManager& application_manager,
- rpc_service::RPCService& rpc_service,
- HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle)
+ const VehicleInfoCommandParams& params)
: ResponseFromHMI(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle) {}
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_) {}
VIReadDIDResponse::~VIReadDIDResponse() {}
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_subscribe_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_subscribe_vehicle_data_request.cc
index 84e41a26dc..4c5f067d0d 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_subscribe_vehicle_data_request.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_subscribe_vehicle_data_request.cc
@@ -31,6 +31,7 @@
*/
#include "vehicle_info_plugin/commands/hmi/vi_subscribe_vehicle_data_request.h"
+#include "application_manager/message_helper.h"
namespace vehicle_info_plugin {
using namespace application_manager;
@@ -39,24 +40,39 @@ namespace commands {
VISubscribeVehicleDataRequest::VISubscribeVehicleDataRequest(
const application_manager::commands::MessageSharedPtr& message,
- ApplicationManager& application_manager,
- rpc_service::RPCService& rpc_service,
- HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle)
+ const VehicleInfoCommandParams& params)
: RequestToHMI(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle) {}
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_)
+ , custom_vehicle_data_manager_(params.custom_vehicle_data_manager_) {}
VISubscribeVehicleDataRequest::~VISubscribeVehicleDataRequest() {}
void VISubscribeVehicleDataRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
+ const auto& rpc_spec_vehicle_data = MessageHelper::vehicle_data();
+ auto& msg_params = (*message_)[strings::msg_params];
+
+ smart_objects::SmartObject custom_data;
+ for (const auto& name : msg_params.enumerate()) {
+ const auto& found_it = rpc_spec_vehicle_data.find(name);
+ if (rpc_spec_vehicle_data.end() == found_it) {
+ custom_data[name] = msg_params[name];
+ msg_params.erase(name);
+ }
+ }
+
+ auto hmi_custom_msg_params =
+ custom_vehicle_data_manager_.CreateHMIMessageParams(
+ custom_data.enumerate());
+ for (const auto& item : hmi_custom_msg_params.enumerate()) {
+ msg_params[item] = hmi_custom_msg_params[item];
+ }
SendRequest();
}
} // namespace commands
-
} // namespace vehicle_info_plugin
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_subscribe_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_subscribe_vehicle_data_response.cc
index 25d876a125..061e13c766 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_subscribe_vehicle_data_response.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_subscribe_vehicle_data_response.cc
@@ -39,15 +39,12 @@ namespace commands {
VISubscribeVehicleDataResponse::VISubscribeVehicleDataResponse(
const application_manager::commands::MessageSharedPtr& message,
- ApplicationManager& application_manager,
- rpc_service::RPCService& rpc_service,
- HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle)
+ const VehicleInfoCommandParams& params)
: ResponseFromHMI(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle) {}
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_) {}
VISubscribeVehicleDataResponse::~VISubscribeVehicleDataResponse() {}
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_unsubscribe_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_unsubscribe_vehicle_data_request.cc
index 50565e95d2..aa24ac7375 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_unsubscribe_vehicle_data_request.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_unsubscribe_vehicle_data_request.cc
@@ -31,6 +31,7 @@
*/
#include "vehicle_info_plugin/commands/hmi/vi_unsubscribe_vehicle_data_request.h"
+#include "application_manager/message_helper.h"
namespace vehicle_info_plugin {
using namespace application_manager;
@@ -39,24 +40,39 @@ namespace commands {
VIUnsubscribeVehicleDataRequest::VIUnsubscribeVehicleDataRequest(
const application_manager::commands::MessageSharedPtr& message,
- ApplicationManager& application_manager,
- rpc_service::RPCService& rpc_service,
- HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle)
+ const VehicleInfoCommandParams& params)
: RequestToHMI(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle) {}
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_)
+ , custom_vehicle_data_manager_(params.custom_vehicle_data_manager_) {}
VIUnsubscribeVehicleDataRequest::~VIUnsubscribeVehicleDataRequest() {}
void VIUnsubscribeVehicleDataRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
+ const auto& rpc_spec_vehicle_data = MessageHelper::vehicle_data();
+ auto& msg_params = (*message_)[strings::msg_params];
+
+ smart_objects::SmartObject custom_data;
+ for (const auto& name : msg_params.enumerate()) {
+ const auto& found_it = rpc_spec_vehicle_data.find(name);
+ if (rpc_spec_vehicle_data.end() == found_it) {
+ custom_data[name] = msg_params[name];
+ msg_params.erase(name);
+ }
+ }
+
+ auto hmi_custom_msg_params =
+ custom_vehicle_data_manager_.CreateHMIMessageParams(
+ custom_data.enumerate());
+ for (const auto& param : hmi_custom_msg_params.enumerate()) {
+ msg_params[param] = true;
+ }
SendRequest();
}
} // namespace commands
-
} // namespace vehicle_info_plugin
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_unsubscribe_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_unsubscribe_vehicle_data_response.cc
index 722073edc7..01fc521b10 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_unsubscribe_vehicle_data_response.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_unsubscribe_vehicle_data_response.cc
@@ -39,15 +39,12 @@ namespace commands {
VIUnsubscribeVehicleDataResponse::VIUnsubscribeVehicleDataResponse(
const application_manager::commands::MessageSharedPtr& message,
- ApplicationManager& application_manager,
- rpc_service::RPCService& rpc_service,
- HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle)
+ const VehicleInfoCommandParams& params)
: ResponseFromHMI(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle) {}
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_) {}
VIUnsubscribeVehicleDataResponse::~VIUnsubscribeVehicleDataResponse() {}
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/diagnostic_message_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/diagnostic_message_request.cc
index a1dfe1e936..ef6c284faf 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/diagnostic_message_request.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/diagnostic_message_request.cc
@@ -46,15 +46,12 @@ namespace commands {
DiagnosticMessageRequest::DiagnosticMessageRequest(
const application_manager::commands::MessageSharedPtr& message,
- ApplicationManager& application_manager,
- rpc_service::RPCService& rpc_service,
- HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler)
+ const VehicleInfoCommandParams& params)
: CommandRequestImpl(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handler) {}
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_) {}
DiagnosticMessageRequest::~DiagnosticMessageRequest() {}
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/diagnostic_message_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/diagnostic_message_response.cc
index f5ad1c89a2..f5ccc4d0a7 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/diagnostic_message_response.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/diagnostic_message_response.cc
@@ -41,15 +41,12 @@ namespace commands {
DiagnosticMessageResponse::DiagnosticMessageResponse(
const application_manager::commands::MessageSharedPtr& message,
- ApplicationManager& application_manager,
- rpc_service::RPCService& rpc_service,
- HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler)
+ const VehicleInfoCommandParams& params)
: CommandResponseImpl(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handler) {}
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_) {}
DiagnosticMessageResponse::~DiagnosticMessageResponse() {}
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_dtcs_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_dtcs_request.cc
index af941e3ea7..dfa1cf305b 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_dtcs_request.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_dtcs_request.cc
@@ -44,15 +44,12 @@ namespace commands {
GetDTCsRequest::GetDTCsRequest(
const application_manager::commands::MessageSharedPtr& message,
- ApplicationManager& application_manager,
- rpc_service::RPCService& rpc_service,
- HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler)
+ const VehicleInfoCommandParams& params)
: CommandRequestImpl(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handler) {}
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_) {}
GetDTCsRequest::~GetDTCsRequest() {}
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_dtcs_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_dtcs_response.cc
index 894c564a0b..33945a2f00 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_dtcs_response.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_dtcs_response.cc
@@ -41,15 +41,12 @@ namespace commands {
GetDTCsResponse::GetDTCsResponse(
const application_manager::commands::MessageSharedPtr& message,
- ApplicationManager& application_manager,
- rpc_service::RPCService& rpc_service,
- HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler)
+ const VehicleInfoCommandParams& params)
: CommandResponseImpl(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handler) {}
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_) {}
GetDTCsResponse::~GetDTCsResponse() {}
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 8d762e30e5..e389c87894 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
@@ -32,12 +32,15 @@
*/
#include "vehicle_info_plugin/commands/mobile/get_vehicle_data_request.h"
+#include "vehicle_info_plugin/custom_vehicle_data_manager.h"
+
#include <string>
#include "application_manager/application_impl.h"
#include "application_manager/message_helper.h"
#include "interfaces/HMI_API.h"
#include "interfaces/MOBILE_API.h"
+#include "policy/policy_table/types.h"
namespace vehicle_info_plugin {
using namespace application_manager;
@@ -48,55 +51,57 @@ namespace str = strings;
GetVehicleDataRequest::GetVehicleDataRequest(
const application_manager::commands::MessageSharedPtr& message,
- ApplicationManager& application_manager,
- rpc_service::RPCService& rpc_service,
- HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler)
+ const VehicleInfoCommandParams& params)
: CommandRequestImpl(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handler) {}
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_)
+ , custom_vehicle_data_manager_(params.custom_vehicle_data_manager_) {}
GetVehicleDataRequest::~GetVehicleDataRequest() {}
void GetVehicleDataRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- int32_t app_id =
- (*message_)[strings::params][strings::connection_key].asUInt();
- ApplicationSharedPtr app = application_manager_.application(app_id);
+ auto app = application_manager_.application(connection_key());
if (!app) {
- LOG4CXX_ERROR(logger_, "NULL pointer");
+ LOG4CXX_ERROR(logger_, "No such application : " << connection_key());
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
return;
}
- if (app->AreCommandLimitsExceeded(
- static_cast<mobile_apis::FunctionID::eType>(function_id()),
- application_manager::TLimitSource::CONFIG_FILE)) {
- LOG4CXX_ERROR(logger_, "GetVehicleData frequency is too high.");
+ if (!CheckFrequency(*app)) {
SendResponse(false, mobile_apis::Result::REJECTED);
return;
}
- const VehicleData& vehicle_data = MessageHelper::vehicle_data();
- VehicleData::const_iterator it = vehicle_data.begin();
- smart_objects::SmartObject msg_params =
+
+ auto hmi_msg_params =
smart_objects::SmartObject(smart_objects::SmartType_Map);
- msg_params[strings::app_id] = app->app_id();
- const uint32_t min_length_msg_params = 1;
- for (; vehicle_data.end() != it; ++it) {
- if (true == (*message_)[str::msg_params].keyExists(it->first) &&
- true == (*message_)[str::msg_params][it->first].asBool()) {
- msg_params[it->first] = (*message_)[strings::msg_params][it->first];
+ hmi_msg_params[strings::app_id] = app->app_id();
+
+ int params_count = 0;
+ auto& msg_params = (*message_)[strings::msg_params];
+ for (const auto& name : msg_params.enumerate()) {
+ auto enabled = msg_params[name].asBool();
+ if (!enabled) {
+ continue;
}
+ hmi_msg_params[name] = msg_params[name];
+ params_count++;
}
- if (msg_params.length() > min_length_msg_params) {
+
+ const int minimal_params_count = 1;
+
+ if (params_count >= minimal_params_count) {
+ for (const auto& param : msg_params.enumerate()) {
+ pending_vehicle_data_.insert(param);
+ }
StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo);
- SendHMIRequest(
- hmi_apis::FunctionID::VehicleInfo_GetVehicleData, &msg_params, true);
- return;
+ SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_GetVehicleData,
+ &hmi_msg_params,
+ true);
} else if (HasDisallowedParams()) {
SendResponse(false, mobile_apis::Result::DISALLOWED);
} else {
@@ -129,6 +134,27 @@ void GetVehicleDataRequest::on_event(const event_engine::Event& event) {
if (true == message[strings::params].keyExists(strings::error_msg)) {
response_info = message[strings::params][strings::error_msg].asString();
}
+
+ custom_vehicle_data_manager_.CreateMobileMessageParams(
+ const_cast<smart_objects::SmartObject&>(
+ message[strings::msg_params]));
+
+ if (result) {
+ for (const auto& item : message[strings::msg_params].enumerate()) {
+ const auto& found_item = pending_vehicle_data_.find(item);
+ if (pending_vehicle_data_.end() == found_item) {
+ message[strings::msg_params].erase(item);
+ }
+ }
+
+ if (message[strings::msg_params].empty()) {
+ response_info = "Failed to retrieve data from vehicle";
+ SendResponse(
+ false, mobile_apis::Result::GENERIC_ERROR, response_info.c_str());
+ return;
+ }
+ }
+
SendResponse(result,
MessageHelper::HMIToMobileResult(result_code),
response_info.empty() ? NULL : response_info.c_str(),
@@ -142,6 +168,15 @@ void GetVehicleDataRequest::on_event(const event_engine::Event& event) {
}
}
-} // namespace commands
+bool GetVehicleDataRequest::CheckFrequency(Application& app) {
+ if (app.AreCommandLimitsExceeded(
+ static_cast<mobile_apis::FunctionID::eType>(function_id()),
+ application_manager::TLimitSource::CONFIG_FILE)) {
+ LOG4CXX_ERROR(logger_, "GetVehicleData frequency is too high.");
+ return false;
+ }
+ return true;
+}
+} // namespace commands
} // namespace vehicle_info_plugin
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_response.cc
index f634915354..60a44745a5 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_response.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_response.cc
@@ -42,15 +42,12 @@ namespace commands {
GetVehicleDataResponse::GetVehicleDataResponse(
const application_manager::commands::MessageSharedPtr& message,
- ApplicationManager& application_manager,
- rpc_service::RPCService& rpc_service,
- HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler)
+ const VehicleInfoCommandParams& params)
: CommandResponseImpl(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handler) {}
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_) {}
GetVehicleDataResponse::~GetVehicleDataResponse() {}
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 7d34bbbe37..79134cae40 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
@@ -47,90 +47,74 @@ namespace commands {
OnVehicleDataNotification::OnVehicleDataNotification(
const application_manager::commands::MessageSharedPtr& message,
- ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler)
+ const VehicleInfoCommandParams& params)
: CommandNotificationImpl(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handler) {}
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_)
+ , custom_vehicle_data_manager_(params.custom_vehicle_data_manager_) {}
OnVehicleDataNotification::~OnVehicleDataNotification() {}
void OnVehicleDataNotification::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- std::vector<ApplicationSharedPtr> appNotification;
- std::vector<ApplicationSharedPtr>::iterator appNotification_it =
- appNotification.begin();
+ std::vector<ApplicationSharedPtr> notify_apps;
+ std::vector<ApplicationSharedPtr>::iterator notified_app_it =
+ notify_apps.begin();
std::vector<smart_objects::SmartObject> appSO;
- const VehicleData& vehicle_data = MessageHelper::vehicle_data();
- VehicleData::const_iterator it = vehicle_data.begin();
-
- for (; vehicle_data.end() != it; ++it) {
- if (true == (*message_)[strings::msg_params].keyExists(it->first)) {
- LOG4CXX_DEBUG(logger_, "vehicle_data name" << it->first);
- auto vehicle_data_value =
- (*message_)[strings::msg_params][it->first].asInt();
-
- application_manager_.IviInfoUpdated(it->second, vehicle_data_value);
-
- auto subscribed_to_ivi_predicate = [&it](const ApplicationSharedPtr app) {
- DCHECK_OR_RETURN(app, false);
- auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app);
- return ext.isSubscribedToVehicleInfo(it->second);
- };
-
- const std::vector<ApplicationSharedPtr>& applications =
- application_manager::FindAllApps(application_manager_.applications(),
- subscribed_to_ivi_predicate);
-
- std::vector<ApplicationSharedPtr>::const_iterator app_it =
- applications.begin();
-
- for (; applications.end() != app_it; ++app_it) {
- const ApplicationSharedPtr app = *app_it;
- if (!app) {
- LOG4CXX_ERROR(logger_, "NULL pointer");
- continue;
- }
-
- appNotification_it =
- find(appNotification.begin(), appNotification.end(), app);
- if (appNotification_it == appNotification.end()) {
- 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];
- 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];
- }
+ custom_vehicle_data_manager_.CreateMobileMessageParams(
+ (*message_)[strings::msg_params]);
+
+ const auto& param_names = (*message_)[strings::msg_params].enumerate();
+ for (const auto& name : param_names) {
+ LOG4CXX_DEBUG(logger_, "vehicle_data name: " << name);
+ auto vehicle_data_value = (*message_)[strings::msg_params][name].asInt();
+ application_manager_.IviInfoUpdated(name, vehicle_data_value);
+
+ auto subscribed_to_ivi_predicate = [&name](const ApplicationSharedPtr app) {
+ DCHECK_OR_RETURN(app, false);
+ auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app);
+ return ext.isSubscribedToVehicleInfo(name);
+ };
+
+ const auto& applications = application_manager::FindAllApps(
+ application_manager_.applications(), subscribed_to_ivi_predicate);
+ for (const auto& app : applications) {
+ if (!app) {
+ LOG4CXX_ERROR(logger_, "NULL pointer");
+ continue;
+ }
+ notified_app_it = find(notify_apps.begin(), notify_apps.end(), app);
+ if (notified_app_it == notify_apps.end()) {
+ notify_apps.push_back(app);
+ smart_objects::SmartObject msg_param =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ msg_param[name] = (*message_)[strings::msg_params][name];
+ appSO.push_back(msg_param);
+ } else {
+ size_t idx = std::distance(notify_apps.begin(), notified_app_it);
+ appSO[idx][name] = (*message_)[strings::msg_params][name];
}
}
}
- LOG4CXX_DEBUG(
- logger_,
- "Number of Notifications to be send: " << appNotification.size());
+ LOG4CXX_DEBUG(logger_,
+ "Number of Notifications to be send: " << notify_apps.size());
- for (size_t idx = 0; idx < appNotification.size(); idx++) {
+ for (size_t idx = 0; idx < notify_apps.size(); idx++) {
LOG4CXX_INFO(logger_,
"Send OnVehicleData PRNDL notification to "
- << appNotification[idx]->name().c_str()
- << " application id " << appNotification[idx]->app_id());
+ << notify_apps[idx]->name().c_str() << " application id "
+ << notify_apps[idx]->app_id());
(*message_)[strings::params][strings::connection_key] =
- appNotification[idx]->app_id();
+ notify_apps[idx]->app_id();
(*message_)[strings::msg_params] = appSO[idx];
SendNotification();
}
}
} // namespace commands
-
} // namespace vehicle_info_plugin
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/read_did_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/read_did_request.cc
index ed83f53516..c090df7852 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/read_did_request.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/read_did_request.cc
@@ -45,15 +45,12 @@ namespace commands {
ReadDIDRequest::ReadDIDRequest(
const application_manager::commands::MessageSharedPtr& message,
- ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler)
+ const VehicleInfoCommandParams& params)
: CommandRequestImpl(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handler) {}
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_) {}
ReadDIDRequest::~ReadDIDRequest() {}
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/read_did_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/read_did_response.cc
index f0b9e3097a..42e7fc1ba9 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/read_did_response.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/read_did_response.cc
@@ -41,15 +41,12 @@ namespace commands {
ReadDIDResponse::ReadDIDResponse(
const application_manager::commands::MessageSharedPtr& message,
- ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler)
+ const VehicleInfoCommandParams& params)
: CommandResponseImpl(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handler) {}
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_) {}
ReadDIDResponse::~ReadDIDResponse() {}
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 815ffeb3d2..b125a7de7d 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
@@ -29,8 +29,10 @@
#include "vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h"
+#include <boost/algorithm/string.hpp>
#include "application_manager/application_impl.h"
#include "application_manager/message_helper.h"
+#include "smart_objects/enum_schema_item.h"
#include "utils/helpers.h"
#include "vehicle_info_plugin/vehicle_info_app_extension.h"
@@ -40,15 +42,13 @@ namespace commands {
SubscribeVehicleDataRequest::SubscribeVehicleDataRequest(
const application_manager::commands::MessageSharedPtr& message,
- ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler)
+ VehicleInfoCommandParams params)
: CommandRequestImpl(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handler) {}
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_)
+ , custom_vehicle_data_manager_(params.custom_vehicle_data_manager_) {}
SubscribeVehicleDataRequest::~SubscribeVehicleDataRequest() {}
@@ -73,6 +73,7 @@ void SubscribeVehicleDataRequest::Run() {
app, info, result_code, response_params, msg_params, result);
if (mobile_apis::Result::INVALID_ENUM != result_code) {
+ AppendDataTypesToMobileResponse(response_params);
SendResponse(result,
result_code,
info.empty() ? NULL : info.c_str(),
@@ -118,35 +119,103 @@ void SubscribeVehicleDataRequest::on_event(const event_engine::Event& event) {
mobile_apis::Result::eType result_code =
MessageHelper::HMIToMobileResult(hmi_result);
+ smart_objects::SmartObject converted_msg_params(message[strings::msg_params]);
+ custom_vehicle_data_manager_.CreateMobileMessageParams(converted_msg_params);
+
if (is_succeeded) {
if (!vi_already_subscribed_by_this_app_.empty()) {
result_code = mobile_apis::Result::IGNORED;
response_info = "Already subscribed on some provided VehicleData.";
}
- if (!vi_waiting_for_subscribe_.empty()) {
- LOG4CXX_DEBUG(logger_, "Subscribing to all pending VehicleData");
- VehicleInfoSubscriptions::const_iterator key =
- vi_waiting_for_subscribe_.begin();
- for (; key != vi_waiting_for_subscribe_.end(); ++key) {
- auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app);
- ext.subscribeToVehicleInfo(*key);
+ for (const auto& param : converted_msg_params.enumerate()) {
+ const auto& converted_name = ConvertResponseToRequestName(param);
+ if (vi_waiting_for_subscribe_.end() ==
+ vi_waiting_for_subscribe_.find(converted_name)) {
+ LOG4CXX_DEBUG(logger_, "erase " << converted_name);
+ converted_msg_params.erase(param);
}
}
- }
- UnsubscribeFailedSubscriptions(app, message[strings::msg_params]);
+ if (!SubscribePendingVehicleData(app, converted_msg_params)) {
+ result_code = mobile_apis::Result::GENERIC_ERROR;
+ response_info = "Subscription failed for some Vehicle data";
+ SendResponse(false, result_code, response_info.c_str());
+ return;
+ }
+ }
if (!vi_already_subscribed_by_another_apps_.empty() ||
!vi_already_subscribed_by_this_app_.empty()) {
- AddAlreadySubscribedVI(
- const_cast<smart_objects::SmartObject&>(message[strings::msg_params]));
+ AddAlreadySubscribedVI(converted_msg_params);
}
+ AppendDataTypesToMobileResponse(converted_msg_params);
SendResponse(is_succeeded,
result_code,
response_info.empty() ? NULL : response_info.c_str(),
- &(message[strings::msg_params]));
+ &converted_msg_params);
+}
+
+void SubscribeVehicleDataRequest::AppendDataTypesToMobileResponse(
+ smart_objects::SmartObject& msg_params) const {
+ using namespace smart_objects;
+
+ std::string oem_vehicle_data_type_str;
+ EnumConversionHelper<VehicleDataType>::EnumToString(
+ VehicleDataType::VEHICLEDATA_OEM_CUSTOM_DATA, &oem_vehicle_data_type_str);
+
+ const auto& rpc_spec_vehicle_data = MessageHelper::vehicle_data();
+ for (const auto& item : msg_params.enumerate()) {
+ const auto& rpc_spec_vehicle_data_item = rpc_spec_vehicle_data.find(item);
+ if (rpc_spec_vehicle_data.end() == rpc_spec_vehicle_data_item) {
+ msg_params[item][strings::data_type] = oem_vehicle_data_type_str;
+ msg_params[item][strings::oem_custom_data_type] =
+ custom_vehicle_data_manager_.GetVehicleDataItemType(item);
+ } else {
+ msg_params[item][strings::data_type] = rpc_spec_vehicle_data_item->second;
+ }
+ }
+}
+
+bool SubscribeVehicleDataRequest::CheckSubscriptionStatus(
+ std::string vi_name, const smart_objects::SmartObject& msg_params) {
+ const auto subscribed_items = msg_params.enumerate();
+ if (subscribed_items.end() == subscribed_items.find(vi_name)) {
+ LOG4CXX_WARN(logger_,
+ vi_name << " is waiting to be subscribed, but missing in "
+ "vehicle response.");
+ return false;
+ }
+
+ 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) {
+ LOG4CXX_WARN(logger_,
+ "Subscription to " << vi_name << " for " << connection_key()
+ << " failed.");
+ return false;
+ }
+ return true;
+}
+
+bool SubscribeVehicleDataRequest::SubscribePendingVehicleData(
+ ApplicationSharedPtr app, const smart_objects::SmartObject& msg_params) {
+ LOG4CXX_DEBUG(logger_, "Subscribing to all pending VehicleData");
+
+ for (const auto& vi_name : vi_waiting_for_subscribe_) {
+ const bool is_subscription_successful = CheckSubscriptionStatus(
+ 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);
+ }
+ }
+
+ return vi_waiting_for_subscribe_.empty();
}
bool SubscribeVehicleDataRequest::Init() {
@@ -158,76 +227,33 @@ void SubscribeVehicleDataRequest::AddAlreadySubscribedVI(
smart_objects::SmartObject& msg_params) const {
LOG4CXX_AUTO_TRACE(logger_);
using namespace mobile_apis;
- auto vi_to_string =
- [](const mobile_apis::VehicleDataType::eType vehicle_data) {
- for (auto& vi_str_to_int_pair : MessageHelper::vehicle_data()) {
- if (vehicle_data == vi_str_to_int_pair.second) {
- return vi_str_to_int_pair.first;
- }
- }
- return std::string();
- };
- VehicleInfoSubscriptions::const_iterator it_same_app =
- vi_already_subscribed_by_this_app_.begin();
- for (; vi_already_subscribed_by_this_app_.end() != it_same_app;
- ++it_same_app) {
- msg_params[vi_to_string(*it_same_app)][strings::result_code] =
+ for (const auto& item : vi_already_subscribed_by_this_app_) {
+ msg_params[item][strings::result_code] =
VehicleDataResultCode::VDRC_DATA_ALREADY_SUBSCRIBED;
- msg_params[vi_to_string(*it_same_app)][strings::data_type] = *it_same_app;
}
- VehicleInfoSubscriptions::const_iterator it_another_app =
- vi_already_subscribed_by_another_apps_.begin();
- for (; vi_already_subscribed_by_another_apps_.end() != it_another_app;
- ++it_another_app) {
- msg_params[vi_to_string(*it_another_app)][strings::result_code] =
+ for (const auto& item : vi_already_subscribed_by_another_apps_) {
+ msg_params[item][strings::result_code] =
VehicleDataResultCode::VDRC_SUCCESS;
- msg_params[vi_to_string(*it_another_app)][strings::data_type] =
- *it_another_app;
- }
-}
-
-void SubscribeVehicleDataRequest::UnsubscribeFailedSubscriptions(
- ApplicationSharedPtr app,
- const smart_objects::SmartObject& msg_params) const {
- LOG4CXX_AUTO_TRACE(logger_);
- const VehicleData& vehicle_data = MessageHelper::vehicle_data();
- VehicleData::const_iterator it = vehicle_data.begin();
-
- for (; vehicle_data.end() != it; ++it) {
- if (msg_params.keyExists(it->first)) {
- if (msg_params[it->first][strings::result_code].asInt() !=
- hmi_apis::Common_VehicleDataResultCode::VDRC_SUCCESS) {
- LOG4CXX_DEBUG(logger_,
- "Subscription for VehicleDataType "
- << it->first
- << " is unsuccessfull. "
- "Unsubscribing app with connection key "
- << connection_key() << " from it.");
- VehicleInfoAppExtension::ExtractVIExtension(*app)
- .unsubscribeFromVehicleInfo(it->second);
- }
- }
}
}
struct SubscribedToIVIPredicate {
- int32_t vehicle_info_;
- SubscribedToIVIPredicate(int32_t vehicle_info)
+ std::string vehicle_info_;
+ SubscribedToIVIPredicate(std::string vehicle_info)
: vehicle_info_(vehicle_info) {}
bool operator()(const ApplicationSharedPtr app) const {
DCHECK_OR_RETURN(app, false);
auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app);
- return ext.isSubscribedToVehicleInfo(
- static_cast<mobile_apis::VehicleDataType::eType>(vehicle_info_));
+ return ext.isSubscribedToVehicleInfo(vehicle_info_);
}
};
bool SubscribeVehicleDataRequest::IsSomeoneSubscribedFor(
- const uint32_t param_id) const {
+ const std::string& param_name) const {
LOG4CXX_AUTO_TRACE(logger_);
- SubscribedToIVIPredicate finder(param_id);
+ SubscribedToIVIPredicate finder(param_name);
DataAccessor<ApplicationSet> accessor = application_manager_.applications();
ApplicationSetConstIt it = std::find_if(
accessor.GetData().begin(), accessor.GetData().end(), finder);
@@ -241,86 +267,95 @@ void SubscribeVehicleDataRequest::CheckVISubscriptions(
smart_objects::SmartObject& out_response_params,
smart_objects::SmartObject& out_request_params,
bool& out_result) {
- // counter for items to subscribe
- VehicleInfoSubscriptions::size_type items_to_subscribe = 0;
- // counter for subscribed items by application
- uint32_t subscribed_items = 0;
+ const bool is_interface_not_available =
+ (HmiInterfaces::STATE_NOT_AVAILABLE ==
+ application_manager_.hmi_interfaces().GetInterfaceState(
+ HmiInterfaces::HMI_INTERFACE_VehicleInfo));
+
+ VehicleInfoSubscriptions::size_type subscribed_items = 0;
+
+ auto app_already_subscribed =
+ [this, &out_response_params](
+ const std::string& key_name,
+ const mobile_apis::VehicleDataType::eType vd_type) {
+ LOG4CXX_DEBUG(
+ logger_,
+ "App with connection key "
+ << connection_key()
+ << " is subscribed already for VehicleData: " << key_name);
+ vi_already_subscribed_by_this_app_.insert(key_name);
+ out_response_params[key_name][strings::data_type] = vd_type;
+ out_response_params[key_name][strings::result_code] =
+ mobile_apis::VehicleDataResultCode::VDRC_DATA_ALREADY_SUBSCRIBED;
+ };
- const VehicleData& vehicle_data = MessageHelper::vehicle_data();
- VehicleData::const_iterator it = vehicle_data.begin();
+ auto another_app_subscribed =
+ [this, &out_response_params, &subscribed_items](
+ const std::string& key_name,
+ const mobile_apis::VehicleDataType::eType vd_type,
+ vehicle_info_plugin::VehicleInfoAppExtension& ext) {
+ LOG4CXX_DEBUG(logger_,
+ "There are apps subscribed already for "
+ "VehicleDataType: "
+ << key_name);
+
+ if (!ext.subscribeToVehicleInfo(key_name)) {
+ LOG4CXX_ERROR(
+ logger_, "Unable to subscribe for VehicleDataType: " << key_name);
+ return;
+ }
+ LOG4CXX_DEBUG(
+ logger_,
+ "App with connection key "
+ << connection_key()
+ << " have been subscribed for VehicleDataType: " << key_name);
+ vi_already_subscribed_by_another_apps_.insert(key_name);
+ out_response_params[key_name][strings::data_type] = vd_type;
+ out_response_params[key_name][strings::result_code] =
+ mobile_apis::VehicleDataResultCode::VDRC_SUCCESS;
+ ++subscribed_items;
+ };
- HmiInterfaces::InterfaceState interface_state =
- application_manager_.hmi_interfaces().GetInterfaceState(
- HmiInterfaces::HMI_INTERFACE_VehicleInfo);
+ auto first_subscription = [this, &out_request_params, &subscribed_items](
+ const std::string& vi_name) {
+ out_request_params[vi_name] = (*message_)[strings::msg_params][vi_name];
- const bool is_interface_not_available =
- interface_state == HmiInterfaces::STATE_NOT_AVAILABLE;
-
- for (; vehicle_data.end() != it; ++it) {
- const std::string& key_name = it->first;
- if ((*message_)[strings::msg_params].keyExists(key_name)) {
- const bool is_key_enabled =
- (*message_)[strings::msg_params][key_name].asBool();
- if (is_key_enabled) {
- ++items_to_subscribe;
- }
- if (!is_interface_not_available && is_key_enabled) {
- mobile_apis::VehicleDataType::eType key_type = it->second;
- const auto is_subscribed =
- VehicleInfoAppExtension::ExtractVIExtension(*app)
- .isSubscribedToVehicleInfo(key_type);
- if (is_subscribed) {
- LOG4CXX_DEBUG(logger_,
- "App with connection key "
- << connection_key()
- << " is subscribed already for VehicleDataType: "
- << key_type);
- ++subscribed_items;
- vi_already_subscribed_by_this_app_.insert(key_type);
- out_response_params[key_name][strings::data_type] = key_type;
- out_response_params[key_name][strings::result_code] =
- mobile_apis::VehicleDataResultCode::VDRC_DATA_ALREADY_SUBSCRIBED;
- continue;
- }
+ vi_waiting_for_subscribe_.insert(vi_name);
+ LOG4CXX_DEBUG(
+ logger_,
+ "App with connection key "
+ << connection_key()
+ << " will be subscribed for VehicleDataType: " << vi_name);
+ ++subscribed_items;
+ return true;
+ };
- if (IsSomeoneSubscribedFor(key_type)) {
- LOG4CXX_DEBUG(logger_,
- "There are apps subscribed already for "
- "VehicleDataType: "
- << key_type);
- auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app);
-
- if (!ext.subscribeToVehicleInfo(key_type)) {
- LOG4CXX_ERROR(
- logger_,
- "Unable to subscribe for VehicleDataType: " << key_type);
- continue;
- }
- LOG4CXX_DEBUG(
- logger_,
- "App with connection key "
- << connection_key()
- << " have been subscribed for VehicleDataType: " << key_type);
- ++subscribed_items;
- vi_already_subscribed_by_another_apps_.insert(key_type);
- out_response_params[key_name][strings::data_type] = key_type;
- out_response_params[key_name][strings::result_code] =
- mobile_apis::VehicleDataResultCode::VDRC_SUCCESS;
- continue;
- }
+ auto rpc_spec_vehicle_data = MessageHelper::vehicle_data();
+ auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app);
- out_request_params[key_name] = is_key_enabled;
+ VehicleInfoSubscriptions::size_type items_to_subscribe = 0;
+ auto item_names = (*message_)[strings::msg_params].enumerate();
+ if (!is_interface_not_available) {
+ for (const auto& name : item_names) {
+ auto enabled = (*message_)[strings::msg_params][name].asBool();
+ if (!enabled) {
+ continue;
+ }
- if (is_key_enabled) {
- vi_waiting_for_subscribe_.insert(key_type);
- LOG4CXX_DEBUG(
- logger_,
- "App with connection key "
- << connection_key()
- << " will be subscribed for VehicleDataType: " << key_type);
- ++subscribed_items;
- }
+ auto vehicle_data = rpc_spec_vehicle_data.find(name);
+ auto vehicle_data_type =
+ (vehicle_data == rpc_spec_vehicle_data.end())
+ ? VehicleDataType::VEHICLEDATA_OEM_CUSTOM_DATA
+ : vehicle_data->second;
+ if (ext.isSubscribedToVehicleInfo(name)) {
+ app_already_subscribed(name, vehicle_data_type);
+ } else if (IsSomeoneSubscribedFor(name)) {
+ another_app_subscribed(name, vehicle_data_type, ext);
+ } else if (!first_subscription(name)) {
+ continue;
}
+
+ ++items_to_subscribe;
}
}
@@ -336,12 +371,14 @@ void SubscribeVehicleDataRequest::CheckVISubscriptions(
out_info = "No data in the request";
}
out_result = false;
+ return;
}
if (0 == subscribed_items && !is_interface_not_available) {
out_result_code = mobile_apis::Result::IGNORED;
out_info = "Already subscribed on provided VehicleData.";
out_result = false;
+ return;
}
if (is_everything_already_subscribed) {
@@ -352,8 +389,35 @@ void SubscribeVehicleDataRequest::CheckVISubscriptions(
out_info = "Already subscribed on some provided VehicleData.";
}
out_result = true;
+ return;
}
}
+const std::string& SubscribeVehicleDataRequest::ConvertResponseToRequestName(
+ const std::string& name) {
+ static std::map<std::string, std::string> parameter_name_conversion_map = {
+ {strings::cluster_modes, strings::cluster_mode_status}};
+ const auto converted_it = parameter_name_conversion_map.find(name);
+ auto result = parameter_name_conversion_map.end() == converted_it
+ ? name
+ : converted_it->second;
+ return parameter_name_conversion_map.end() == converted_it
+ ? name
+ : converted_it->second;
+}
+
+const std::string& SubscribeVehicleDataRequest::ConvertRequestToResponseName(
+ const std::string& name) {
+ static std::map<std::string, std::string> parameter_name_conversion_map = {
+ {strings::cluster_mode_status, strings::cluster_modes}};
+ const auto converted_it = parameter_name_conversion_map.find(name);
+ auto result = parameter_name_conversion_map.end() == converted_it
+ ? name
+ : converted_it->second;
+ return parameter_name_conversion_map.end() == converted_it
+ ? name
+ : converted_it->second;
+}
+
} // namespace commands
} // namespace vehicle_info_plugin
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_response.cc
index b0d09e1a5b..8330176af6 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_response.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_response.cc
@@ -42,15 +42,12 @@ namespace commands {
SubscribeVehicleDataResponse::SubscribeVehicleDataResponse(
const application_manager::commands::MessageSharedPtr& message,
- ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler)
+ const VehicleInfoCommandParams& params)
: CommandResponseImpl(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handler) {}
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_) {}
SubscribeVehicleDataResponse::~SubscribeVehicleDataResponse() {}
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_request.cc
index 40bd9182e7..32d63f0c35 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_request.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_request.cc
@@ -39,6 +39,7 @@
#include "application_manager/smart_object_keys.h"
#include "interfaces/HMI_API.h"
#include "interfaces/MOBILE_API.h"
+#include "smart_objects/enum_schema_item.h"
#include "utils/helpers.h"
#include "vehicle_info_plugin/vehicle_info_app_extension.h"
@@ -48,15 +49,13 @@ namespace commands {
UnsubscribeVehicleDataRequest::UnsubscribeVehicleDataRequest(
const application_manager::commands::MessageSharedPtr& message,
- ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler)
+ const VehicleInfoCommandParams& params)
: CommandRequestImpl(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handler) {}
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_)
+ , custom_vehicle_data_manager_(params.custom_vehicle_data_manager_) {}
UnsubscribeVehicleDataRequest::~UnsubscribeVehicleDataRequest() {}
@@ -74,67 +73,64 @@ void UnsubscribeVehicleDataRequest::Run() {
int32_t items_to_unsubscribe = 0;
int32_t unsubscribed_items = 0;
- const VehicleData& vehicle_data = MessageHelper::vehicle_data();
- VehicleData::const_iterator it = vehicle_data.begin();
-
smart_objects::SmartObject msg_params =
smart_objects::SmartObject(smart_objects::SmartType_Map);
- smart_objects::SmartObject response_params =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
+ response_params_ = smart_objects::SmartObject(smart_objects::SmartType_Map);
+
+ auto rpc_spec_vehicle_data = MessageHelper::vehicle_data();
+ std::set<std::string> custom_vehicle_data;
+
+ auto app_not_subscribed_response = [this](const std::string& key_name) {
+ LOG4CXX_DEBUG(logger_,
+ "App with connection key "
+ << connection_key()
+ << " is not subscribed for VehicleData: " << key_name);
+ vi_already_unsubscribed_by_this_app_.insert(key_name);
+ response_params_[key_name][strings::result_code] =
+ mobile_apis::VehicleDataResultCode::VDRC_DATA_NOT_SUBSCRIBED;
+ };
+
+ auto other_app_subscribed_response = [this](const std::string& key_name) {
+ LOG4CXX_DEBUG(logger_,
+ "There are apps still subscribed for "
+ "VehicleDataType: "
+ << key_name);
+ vi_still_subscribed_by_another_apps_.insert(key_name);
+ response_params_[key_name][strings::result_code] =
+ mobile_apis::VehicleDataResultCode::VDRC_SUCCESS;
+ };
+
+ auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app);
+
+ const auto& param_names = (*message_)[strings::msg_params].enumerate();
+ for (const auto& name : param_names) {
+ const bool enabled = (*message_)[strings::msg_params][name].asBool();
+ if (!enabled) {
+ continue;
+ }
- for (; vehicle_data.end() != it; ++it) {
- const std::string& key_name = it->first;
- if ((*message_)[strings::msg_params].keyExists(key_name)) {
- bool is_key_enabled = (*message_)[strings::msg_params][key_name].asBool();
- if (is_key_enabled) {
- ++items_to_unsubscribe;
-
- mobile_apis::VehicleDataType::eType key_type = it->second;
- const auto is_subscribed =
- VehicleInfoAppExtension::ExtractVIExtension(*app)
- .isSubscribedToVehicleInfo(key_type);
- if (!is_subscribed) {
- ++unsubscribed_items;
- vi_already_unsubscribed_by_this_app_.insert(key_type);
- response_params[key_name][strings::data_type] = key_type;
- response_params[key_name][strings::result_code] =
- mobile_apis::VehicleDataResultCode::VDRC_DATA_NOT_SUBSCRIBED;
- continue;
- }
-
- if (!VehicleInfoAppExtension::ExtractVIExtension(*app)
- .unsubscribeFromVehicleInfo(it->second)) {
- LOG4CXX_ERROR(logger_,
- "Unable to unsubscribe from "
- "VehicleDataType: "
- << key_type);
- continue;
- }
-
- LOG4CXX_DEBUG(logger_,
- "Unsubscribed app with connection key "
- << connection_key()
- << " from VehicleDataType: " << key_type);
-
- ++unsubscribed_items;
-
- if (IsSomeoneSubscribedFor(key_type)) {
- LOG4CXX_DEBUG(logger_,
- "There are another apps still subscribed for "
- "VehicleDataType: "
- << key_type);
-
- vi_still_subscribed_by_another_apps_.insert(key_type);
- response_params[key_name][strings::data_type] = key_type;
- response_params[key_name][strings::result_code] =
- mobile_apis::VehicleDataResultCode::VDRC_SUCCESS;
- continue;
- }
-
- msg_params[key_name] = is_key_enabled;
- }
+ ++items_to_unsubscribe;
+
+ if (!(ext.isSubscribedToVehicleInfo(name))) {
+ app_not_subscribed_response(name);
+ continue;
+ }
+
+ LOG4CXX_DEBUG(logger_,
+ "Unsubscribed app with connection key "
+ << connection_key() << " from VehicleDataType: " << name);
+
+ ++unsubscribed_items;
+
+ if (IsSomeoneSubscribedFor(name)) {
+ other_app_subscribed_response(name);
+ ext.unsubscribeFromVehicleInfo(name);
+ continue;
}
+
+ vi_waiting_for_unsubscribe_.insert(name);
+ msg_params[name] = true;
}
bool is_everything_already_unsubscribed =
@@ -142,6 +138,8 @@ void UnsubscribeVehicleDataRequest::Run() {
vi_still_subscribed_by_another_apps_.size() +
vi_already_unsubscribed_by_this_app_.size();
+ AppendDataTypesToMobileResponse(response_params_);
+
if (0 == items_to_unsubscribe) {
if (HasDisallowedParams()) {
SendResponse(false, mobile_apis::Result::DISALLOWED);
@@ -156,7 +154,7 @@ void UnsubscribeVehicleDataRequest::Run() {
SendResponse(false,
mobile_apis::Result::IGNORED,
"Was not subscribed on any VehicleData.",
- &response_params);
+ &response_params_);
return;
}
@@ -165,9 +163,9 @@ void UnsubscribeVehicleDataRequest::Run() {
SendResponse(false,
mobile_apis::Result::IGNORED,
"Some provided VehicleData was not subscribed.",
- &response_params);
+ &response_params_);
} else {
- SendResponse(true, mobile_apis::Result::SUCCESS, NULL, &response_params);
+ SendResponse(true, mobile_apis::Result::SUCCESS, NULL, &response_params_);
}
return;
}
@@ -203,36 +201,56 @@ void UnsubscribeVehicleDataRequest::on_event(const event_engine::Event& event) {
message[strings::params][hmi_response::code].asInt());
std::string response_info;
GetInfo(message, response_info);
- const bool result = PrepareResultForMobileResponse(
+ bool result = PrepareResultForMobileResponse(
hmi_result, HmiInterfaces::HMI_INTERFACE_VehicleInfo);
+ auto hmi_response_msg_params = message[strings::msg_params];
+
mobile_apis::Result::eType result_code =
MessageHelper::HMIToMobileResult(hmi_result);
+ custom_vehicle_data_manager_.CreateMobileMessageParams(
+ hmi_response_msg_params);
+
+ if (!vi_still_subscribed_by_another_apps_.empty() ||
+ !vi_already_unsubscribed_by_this_app_.empty()) {
+ AddAlreadyUnsubscribedVI(hmi_response_msg_params);
+ }
+
if (result) {
if (vi_already_unsubscribed_by_this_app_.size()) {
result_code = mobile_apis::Result::IGNORED;
response_info = "Some provided VehicleData was not subscribed.";
}
- }
- if (!vi_still_subscribed_by_another_apps_.empty() ||
- !vi_already_unsubscribed_by_this_app_.empty()) {
- AddAlreadyUnsubscribedVI(
- const_cast<smart_objects::SmartObject&>(message[strings::msg_params]));
- }
+ for (const auto& param : hmi_response_msg_params.enumerate()) {
+ const auto converted_param = ConvertResponseToRequestName(param);
+ if (vi_waiting_for_unsubscribe_.end() ==
+ vi_waiting_for_unsubscribe_.find(converted_param)) {
+ hmi_response_msg_params.erase(param);
+ }
+ }
- if (result) {
- SetAllowedToTerminate(false);
+ if (!UnsubscribePendingVehicleData(app, hmi_response_msg_params)) {
+ result = false;
+ result_code = mobile_apis::Result::GENERIC_ERROR;
+ response_info = "Unsubscription failed for some Vehicle data";
+ hmi_response_msg_params = smart_objects::SmartObject();
+ }
}
- SendResponse(result,
- result_code,
- response_info.empty() ? NULL : response_info.c_str(),
- &(message[strings::msg_params]));
- if (result) {
- application_manager_.TerminateRequest(
- connection_key(), correlation_id(), function_id());
+
+ AppendDataTypesToMobileResponse(hmi_response_msg_params);
+ for (const auto& key : hmi_response_msg_params.enumerate()) {
+ response_params_[key] = hmi_response_msg_params[key];
}
+
+ SendResponse(
+ result,
+ result_code,
+ response_info.empty() ? NULL : response_info.c_str(),
+ smart_objects::SmartType::SmartType_Null == response_params_.getType()
+ ? NULL
+ : &response_params_);
}
bool UnsubscribeVehicleDataRequest::Init() {
@@ -240,25 +258,23 @@ bool UnsubscribeVehicleDataRequest::Init() {
return true;
}
-struct SubscribedToIVIPredicate {
- int32_t vehicle_info_;
- SubscribedToIVIPredicate(int32_t vehicle_info)
- : vehicle_info_(vehicle_info) {}
- bool operator()(const ApplicationSharedPtr app) const {
+bool UnsubscribeVehicleDataRequest::IsSomeoneSubscribedFor(
+ const std::string& param_name) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ const auto conn_key = connection_key();
+ auto subscribed_to_ivi = [&param_name,
+ &conn_key](const ApplicationSharedPtr app) {
DCHECK_OR_RETURN(app, false);
+ if (conn_key == app->app_id()) {
+ return false;
+ }
auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app);
- return ext.isSubscribedToVehicleInfo(
- static_cast<mobile_apis::VehicleDataType::eType>(vehicle_info_));
- }
-};
+ return (ext.isSubscribedToVehicleInfo(param_name));
+ };
-bool UnsubscribeVehicleDataRequest::IsSomeoneSubscribedFor(
- const uint32_t param_id) const {
- LOG4CXX_AUTO_TRACE(logger_);
- SubscribedToIVIPredicate finder(param_id);
DataAccessor<ApplicationSet> accessor = application_manager_.applications();
ApplicationSetConstIt it = std::find_if(
- accessor.GetData().begin(), accessor.GetData().end(), finder);
+ accessor.GetData().begin(), accessor.GetData().end(), subscribed_to_ivi);
return it != accessor.GetData().end();
}
@@ -266,20 +282,92 @@ void UnsubscribeVehicleDataRequest::AddAlreadyUnsubscribedVI(
smart_objects::SmartObject& response) const {
LOG4CXX_AUTO_TRACE(logger_);
using namespace mobile_apis;
- VehicleInfoSubscriptions::const_iterator it_same_app =
- vi_already_unsubscribed_by_this_app_.begin();
- for (; vi_already_unsubscribed_by_this_app_.end() != it_same_app;
- ++it_same_app) {
- response[*it_same_app][strings::result_code] =
+
+ for (const auto& item : vi_already_unsubscribed_by_this_app_) {
+ response[item][strings::result_code] =
VehicleDataResultCode::VDRC_DATA_NOT_SUBSCRIBED;
}
- VehicleInfoSubscriptions::const_iterator it_another_app =
- vi_still_subscribed_by_another_apps_.begin();
- for (; vi_still_subscribed_by_another_apps_.end() != it_another_app;
- ++it_another_app) {
- response[*it_another_app][strings::result_code] =
- VehicleDataResultCode::VDRC_SUCCESS;
+ for (const auto& item : vi_still_subscribed_by_another_apps_) {
+ response[item][strings::result_code] = VehicleDataResultCode::VDRC_SUCCESS;
+ }
+}
+
+bool UnsubscribeVehicleDataRequest::CheckSubscriptionStatus(
+ std::string key, const smart_objects::SmartObject& msg_params) {
+ const auto unsubscribed_items = msg_params.enumerate();
+ if (unsubscribed_items.end() == unsubscribed_items.find(key)) {
+ LOG4CXX_WARN(logger_,
+ key << " is waiting to be unsubscribed, but missing in "
+ "vehicle response.");
+ return false;
+ }
+
+ auto res_code = msg_params[key][strings::result_code].asInt();
+ if (hmi_apis::Common_VehicleDataResultCode::VDRC_SUCCESS != res_code) {
+ LOG4CXX_WARN(logger_,
+ "Unubscribing from " << key << " for " << connection_key()
+ << " failed.");
+ return false;
+ }
+ return true;
+}
+
+bool UnsubscribeVehicleDataRequest::UnsubscribePendingVehicleData(
+ ApplicationSharedPtr app, const smart_objects::SmartObject& msg_params) {
+ LOG4CXX_DEBUG(logger_, "Unsubscribing from all pending VehicleData");
+
+ for (const auto& vi_name : vi_waiting_for_unsubscribe_) {
+ const auto converted_item = ConvertRequestToResponseName(vi_name);
+ const bool is_unsubscription_successful =
+ CheckSubscriptionStatus(converted_item, msg_params);
+ if (is_unsubscription_successful) {
+ auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app);
+ ext.unsubscribeFromVehicleInfo(vi_name);
+ vi_waiting_for_unsubscribe_.erase(vi_name);
+ }
+ }
+ return vi_waiting_for_unsubscribe_.empty();
+}
+
+const std::string& UnsubscribeVehicleDataRequest::ConvertRequestToResponseName(
+ const std::string& name) {
+ static std::map<std::string, std::string> parameter_name_converion_map = {
+ {strings::cluster_mode_status, strings::cluster_modes}};
+ const auto converted_it = parameter_name_converion_map.find(name);
+ return parameter_name_converion_map.end() == converted_it
+ ? name
+ : converted_it->second;
+}
+
+const std::string& UnsubscribeVehicleDataRequest::ConvertResponseToRequestName(
+ const std::string& name) {
+ static std::map<std::string, std::string> parameter_name_converion_map = {
+ {strings::cluster_modes, strings::cluster_mode_status}};
+ const auto converted_it = parameter_name_converion_map.find(name);
+ return parameter_name_converion_map.end() == converted_it
+ ? name
+ : converted_it->second;
+}
+
+void UnsubscribeVehicleDataRequest::AppendDataTypesToMobileResponse(
+ smart_objects::SmartObject& msg_params) const {
+ using namespace smart_objects;
+
+ std::string oem_vehicle_data_type_str;
+ EnumConversionHelper<VehicleDataType>::EnumToString(
+ VehicleDataType::VEHICLEDATA_OEM_CUSTOM_DATA, &oem_vehicle_data_type_str);
+
+ const auto& rpc_spec_vehicle_data = MessageHelper::vehicle_data();
+ for (const auto& item : msg_params.enumerate()) {
+ const auto& rpc_spec_vehicle_data_item = rpc_spec_vehicle_data.find(item);
+ if (rpc_spec_vehicle_data.end() == rpc_spec_vehicle_data_item) {
+ msg_params[item][strings::data_type] = oem_vehicle_data_type_str;
+ msg_params[item][strings::oem_custom_data_type] =
+ custom_vehicle_data_manager_.GetVehicleDataItemType(item);
+ } else {
+ msg_params[item][strings::data_type] = rpc_spec_vehicle_data_item->second;
+ }
}
}
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_response.cc
index a4a486a5e7..352239c331 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_response.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_response.cc
@@ -40,15 +40,12 @@ namespace commands {
UnsubscribeVehicleDataResponse::UnsubscribeVehicleDataResponse(
const application_manager::commands::MessageSharedPtr& message,
- ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler)
+ const VehicleInfoCommandParams& params)
: CommandResponseImpl(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handler) {}
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_) {}
UnsubscribeVehicleDataResponse::~UnsubscribeVehicleDataResponse() {}
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/custom_vehicle_data_manager_impl.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/custom_vehicle_data_manager_impl.cc
new file mode 100644
index 0000000000..dd51d172c9
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/custom_vehicle_data_manager_impl.cc
@@ -0,0 +1,531 @@
+/**
+ * Copyright (c) 2019, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "vehicle_info_plugin/custom_vehicle_data_manager_impl.h"
+#include <strings.h>
+#include <limits>
+#include "policy/policy_table/types.h"
+#include "vehicle_info_plugin/vehicle_data_item_schema.h"
+
+#include "application_manager/application_manager.h"
+#include "application_manager/message_helper.h"
+#include "application_manager/policies/custom_vehicle_data_provider.h"
+#include "interfaces/MOBILE_API_schema.h"
+#include "policy/policy_table/policy_enum_schema_factory.h"
+#include "smart_objects/enum_schema_item.h"
+#include "utils/helpers.h"
+#include "utils/optional.h"
+
+CREATE_LOGGERPTR_GLOBAL(logger_, "VehicleInfoPlugin")
+
+namespace vehicle_info_plugin {
+
+template <typename T, typename U>
+U GetOptional(const rpc::Optional<T>& optional, U def_val) {
+ return optional.is_initialized() ? static_cast<U>(*optional) : def_val;
+}
+
+enum SearchMethod { RECURSIVE = 0, NON_RECURSIVE };
+
+CustomVehicleDataManagerImpl::CustomVehicleDataManagerImpl(
+ policy::VehicleDataItemProvider& vehicle_data_provider,
+ application_manager::rpc_service::RPCService& rpc_service)
+ : vehicle_data_provider_(vehicle_data_provider)
+ , rpc_service_(rpc_service) {}
+
+std::string CustomVehicleDataManagerImpl::GetVehicleDataItemType(
+ const std::string& vehicle_data_item_name) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ const auto& schema = FindSchemaByNameNonRecursive(vehicle_data_item_name);
+
+ return schema.is_initialized() ? std::string(schema->type)
+ : vehicle_data_item_name;
+}
+
+void CustomVehicleDataManagerImpl::CreateMobileMessageParams(
+ smart_objects::SmartObject& msg_params) {
+ using namespace application_manager;
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ typedef std::function<smart_objects::SmartObject(
+ const smart_objects::SmartObject& input_params,
+ SearchMethod search_method)>
+ MobileMsgConstructor;
+
+ MobileMsgConstructor fill_mobile_msg =
+ [this, &fill_mobile_msg](
+ const smart_objects::SmartObject& input_params,
+ SearchMethod search_method) -> smart_objects::SmartObject {
+ smart_objects::SmartObject out_params;
+
+ const auto& items = input_params.enumerate();
+ for (const auto& key : items) {
+ auto schema = search_method == SearchMethod::RECURSIVE
+ ? FindSchemaByKeyRecursive(key)
+ : FindSchemaByKeyNonRecursive(key);
+ if (!schema.is_initialized()) {
+ LOG4CXX_DEBUG(logger_, "Schema for: " << key << " cannot be found");
+ continue;
+ }
+
+ const auto& item_name = schema->name;
+ if (policy_table::VehicleDataItem::kStruct == std::string(schema->type)) {
+ const auto param =
+ fill_mobile_msg(input_params[key], SearchMethod::RECURSIVE);
+ if (!param.empty()) {
+ out_params[item_name] = param;
+ continue;
+ }
+ }
+
+ out_params[item_name] = input_params[key];
+ }
+
+ return out_params;
+ };
+
+ const auto& rpc_spec_vehicle_data = MessageHelper::vehicle_data();
+ const auto& item_names = msg_params.enumerate();
+ smart_objects::SmartObject params_to_convert;
+
+ for (const auto& item_key : item_names) {
+ const auto& found_it = rpc_spec_vehicle_data.find(item_key);
+ if (found_it == rpc_spec_vehicle_data.end()) {
+ params_to_convert[item_key] = msg_params[item_key];
+ msg_params.erase(item_key);
+ }
+ }
+
+ const auto& mobile_msg_params =
+ fill_mobile_msg(params_to_convert, SearchMethod::NON_RECURSIVE);
+ for (const auto& name : mobile_msg_params.enumerate()) {
+ msg_params[name] = mobile_msg_params[name];
+ }
+}
+
+smart_objects::SmartObject CustomVehicleDataManagerImpl::CreateHMIMessageParams(
+ const std::set<std::string>& item_names) {
+ typedef std::function<smart_objects::SmartObject(
+ const policy_table::VehicleDataItem&)>
+ ParamsConstructor;
+
+ auto fill_param = [](ParamsConstructor& constructor,
+ const policy_table::VehicleDataItem& param,
+ smart_objects::SmartObject* out_params) {
+ DCHECK_OR_RETURN_VOID(out_params)
+ const auto param_key = std::string(param.key);
+ const auto param_type = std::string(param.type);
+ if (policy_table::VehicleDataItem::kStruct == param_type) {
+ (*out_params)[param_key] = constructor(param);
+ } else {
+ (*out_params)[param_key] = true;
+ }
+ };
+
+ ParamsConstructor fill_hmi_params =
+ [&fill_hmi_params,
+ fill_param](const policy_table::VehicleDataItem& item) {
+ smart_objects::SmartObject out_params;
+ DCHECK(policy_table::VehicleDataItem::kStruct ==
+ std::string(item.type));
+ for (auto& param : *(item.params)) {
+ fill_param(fill_hmi_params, param, &out_params);
+ }
+ return out_params;
+ };
+
+ smart_objects::SmartObject out_params(smart_objects::SmartType_Map);
+ for (const auto& name : item_names) {
+ auto schema = FindSchemaByNameNonRecursive(name);
+ if (schema.is_initialized()) {
+ fill_param(fill_hmi_params, *schema, &out_params);
+ }
+ }
+
+ return out_params;
+}
+
+template <typename Comparer>
+const OptionalDataItem FindSchema(
+ const std::vector<policy_table::VehicleDataItem>& oem_items,
+ SearchMethod search_method,
+ Comparer comparer) {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ std::vector<policy_table::VehicleDataItem> items;
+ for (const auto& item : oem_items) {
+ if (comparer(item)) {
+ items.push_back(item);
+ }
+ if (search_method == SearchMethod::RECURSIVE &&
+ policy_table::VehicleDataItem::kStruct == std::string(item.type)) {
+ auto found_in_params =
+ FindSchema(*(item.params), search_method, comparer);
+ if (found_in_params.is_initialized()) {
+ items.push_back(*found_in_params);
+ }
+ }
+ }
+ std::sort(items.begin(),
+ items.end(),
+ [](const policy_table::VehicleDataItem& left,
+ const policy_table::VehicleDataItem& right) {
+ if (!right.since.is_initialized()) {
+ return false;
+ }
+ if (!left.since.is_initialized()) {
+ return true;
+ }
+ const std::string l = *left.since;
+ const std::string r = *right.since;
+ return std::stof(l.c_str()) > std::stof(r.c_str());
+ });
+
+ if (!items.empty()) {
+ return OptionalDataItem(*items.begin());
+ }
+
+ return OptionalDataItem();
+}
+
+void CustomVehicleDataManagerImpl::UpdateVehicleDataItems() {
+ using namespace ns_smart_device_link::ns_smart_objects;
+ using namespace policy_table;
+
+ enum class SMemberType {
+ SMEMBER_MOBILE,
+ SMEMBER_HMI,
+ SMEMBER_BOOL_MOBILE,
+ SMEMBER_BOOL_HMI,
+ SMEMBER_VDR_MOBILE,
+ SMEMBER_VDR_HMI
+ };
+
+ auto get_custom_vdi = [this]()
+ -> std::vector<rpc::policy_table_interface_base::VehicleDataItem> {
+ using namespace rpc::policy_table_interface_base;
+ std::vector<VehicleDataItem> custom_vehicle_data_items;
+ auto vehicle_data_items = vehicle_data_provider_.GetVehicleDataItems();
+ for (const auto& item : vehicle_data_items) {
+ policy_table::Parameter parameter_enum;
+ if (!policy_table::EnumFromJsonString(item.name, &parameter_enum)) {
+ custom_vehicle_data_items.push_back(item);
+ }
+ }
+ return custom_vehicle_data_items;
+ };
+
+ auto vehicle_data_items = get_custom_vdi();
+
+ auto get_ischema_item = [](VehicleDataItem item,
+ SMemberType type,
+ std::vector<SMember> history = {}) -> SMember {
+ switch (type) {
+ case SMemberType::SMEMBER_BOOL_MOBILE: {
+ auto member_schema =
+ CBoolSchemaItem::create(TSchemaItemParameter<bool>());
+ return SMember(
+ member_schema,
+ false, // root level items should not be mandatory
+ item.since.is_initialized() ? std::string(*item.since) : "",
+ item.until.is_initialized() ? std::string(*item.until) : "",
+ bool(*item.deprecated),
+ bool(*item.removed),
+ history);
+ }
+ case SMemberType::SMEMBER_VDR_MOBILE: {
+ // valid since struct_schema_items is not used in
+ // InitStructSchemaItem_VehicleDataResult
+ mobile_apis::MOBILE_API::TStructsSchemaItems mobile_struct_schema_items;
+ auto member_schema =
+ mobile_apis::MOBILE_API::InitStructSchemaItem_VehicleDataResult(
+ mobile_struct_schema_items);
+ return SMember(
+ member_schema,
+ false, // root level items should not be mandatory
+ item.since.is_initialized() ? std::string(*item.since) : "",
+ item.until.is_initialized() ? std::string(*item.until) : "",
+ bool(*item.deprecated),
+ bool(*item.removed),
+ history);
+ }
+ case SMemberType::SMEMBER_MOBILE: {
+ TSchemaItemParameter<VehicleDataItem> tschema_item(item);
+ auto member_schema = VehicleDataItemSchema::create(
+ tschema_item, VehicleDataItemSchema::SchemaType::MOBILE);
+ return SMember(
+ member_schema,
+ false, // root level items should not be mandatory
+ item.since.is_initialized() ? std::string(*item.since) : "",
+ item.until.is_initialized() ? std::string(*item.until) : "",
+ bool(*item.deprecated),
+ bool(*item.removed),
+ history);
+ }
+ case SMemberType::SMEMBER_BOOL_HMI: {
+ auto member_schema =
+ CBoolSchemaItem::create(TSchemaItemParameter<bool>());
+ return SMember(member_schema,
+ false // root level items should not be mandatory
+ );
+ }
+ case SMemberType::SMEMBER_VDR_HMI: {
+ // valid since struct_schema_items is not used in
+ // InitStructSchemaItem_Common_VehicleDataResult
+ hmi_apis::HMI_API::TStructsSchemaItems hmi_struct_schema_items;
+ auto member_schema =
+ hmi_apis::HMI_API::InitStructSchemaItem_Common_VehicleDataResult(
+ hmi_struct_schema_items);
+ return SMember(
+ member_schema, false // root level items should not be mandatory
+ );
+ }
+ case SMemberType::SMEMBER_HMI: {
+ TSchemaItemParameter<VehicleDataItem> tschema_item(item);
+ auto member_schema = VehicleDataItemSchema::create(
+ tschema_item, VehicleDataItemSchema::SchemaType::HMI);
+ return SMember(
+ member_schema, false // root level items should not be mandatory
+ );
+ }
+ default: {
+ auto member_schema = CAlwaysFalseSchemaItem::create();
+ return SMember(member_schema, false);
+ }
+ }
+ };
+
+ auto get_vehicle_data_history =
+ [&vehicle_data_items](std::string name) -> std::vector<VehicleDataItem> {
+ std::vector<VehicleDataItem> result;
+ std::copy_if(vehicle_data_items.begin(),
+ vehicle_data_items.end(),
+ std::back_inserter(result),
+ [&name](VehicleDataItem item) { return item.name == name; });
+
+ std::sort(result.begin(),
+ result.end(),
+ [](const policy_table::VehicleDataItem& left,
+ const policy_table::VehicleDataItem& right) {
+ if (!right.since.is_initialized()) {
+ return false;
+ }
+ if (!left.since.is_initialized()) {
+ return true;
+ }
+ const std::string l = *left.since;
+ const std::string r = *right.since;
+ return std::stof(l.c_str()) > std::stof(r.c_str());
+ });
+
+ return result;
+ };
+
+ auto get_member_with_history = [&get_ischema_item](
+ std::vector<VehicleDataItem> items,
+ SMemberType type) -> SMember {
+ std::vector<SMember> history = {};
+ std::vector<SMemberType> types{SMemberType::SMEMBER_MOBILE,
+ SMemberType::SMEMBER_VDR_MOBILE,
+ SMemberType::SMEMBER_BOOL_MOBILE};
+ if (helpers::in_range(types, type) && items.size() > 1) {
+ auto history_iterator = items.begin() + 1;
+ for (; history_iterator < items.end(); ++history_iterator) {
+ const auto& item = (*history_iterator);
+ history.push_back(get_ischema_item(item, type));
+ }
+ }
+
+ auto latest_item = (*items.begin());
+ return get_ischema_item(latest_item, type, history);
+ };
+
+ CustomVehicleDataManagerImpl::RPCParams mobile_params;
+ CustomVehicleDataManagerImpl::RPCParams hmi_params;
+
+ std::set<std::string> vehicle_data_names;
+ for (const auto& item : vehicle_data_items) {
+ vehicle_data_names.insert(item.name);
+ }
+
+ for (const auto& name : vehicle_data_names) {
+ auto vehicle_data_history = get_vehicle_data_history(name);
+ const auto& vdi = vehicle_data_history.begin();
+
+ SMember member_bool_hmi = get_member_with_history(
+ vehicle_data_history, SMemberType::SMEMBER_BOOL_HMI);
+ SMember member_bool_mobile = get_member_with_history(
+ vehicle_data_history, SMemberType::SMEMBER_BOOL_MOBILE);
+
+ SMember member_vdr_hmi = get_member_with_history(
+ vehicle_data_history, SMemberType::SMEMBER_VDR_HMI);
+ SMember member_vdr_mobile = get_member_with_history(
+ vehicle_data_history, SMemberType::SMEMBER_VDR_MOBILE);
+ SMember member_hmi =
+ get_member_with_history(vehicle_data_history, SMemberType::SMEMBER_HMI);
+ SMember member_mobile = get_member_with_history(
+ vehicle_data_history, SMemberType::SMEMBER_MOBILE);
+
+ mobile_params.addBoolParam(
+ std::pair<std::string, SMember>(vdi->name, member_bool_mobile));
+ mobile_params.addVDRParam(
+ std::pair<std::string, SMember>(vdi->name, member_vdr_mobile));
+ mobile_params.addParam(
+ std::pair<std::string, SMember>(vdi->name, member_mobile));
+
+ hmi_params.addBoolParam(
+ std::pair<std::string, SMember>(vdi->key, member_bool_hmi));
+ hmi_params.addVDRParam(
+ std::pair<std::string, SMember>(vdi->key, member_vdr_hmi));
+ hmi_params.addParam(std::pair<std::string, SMember>(vdi->key, member_hmi));
+ }
+
+ std::vector<mobile_apis::FunctionID::eType> mobile_subscribe_functions{
+ mobile_apis::FunctionID::SubscribeVehicleDataID,
+ mobile_apis::FunctionID::UnsubscribeVehicleDataID};
+
+ for (const auto& function_id : mobile_subscribe_functions) {
+ rpc_service_.UpdateMobileRPCParams(function_id,
+ mobile_apis::messageType::request,
+ mobile_params.getBoolParams());
+ rpc_service_.UpdateMobileRPCParams(function_id,
+ mobile_apis::messageType::response,
+ mobile_params.getVDRParams());
+ }
+
+ std::vector<hmi_apis::FunctionID::eType> hmi_subscribe_functions{
+ hmi_apis::FunctionID::VehicleInfo_SubscribeVehicleData,
+ hmi_apis::FunctionID::VehicleInfo_UnsubscribeVehicleData};
+
+ for (const auto& function_id : hmi_subscribe_functions) {
+ rpc_service_.UpdateHMIRPCParams(function_id,
+ hmi_apis::messageType::request,
+ hmi_params.getBoolParams());
+ rpc_service_.UpdateHMIRPCParams(function_id,
+ hmi_apis::messageType::response,
+ hmi_params.getVDRParams());
+ }
+
+ rpc_service_.UpdateMobileRPCParams(mobile_apis::FunctionID::GetVehicleDataID,
+ mobile_apis::messageType::request,
+ mobile_params.getBoolParams());
+
+ rpc_service_.UpdateMobileRPCParams(mobile_apis::FunctionID::GetVehicleDataID,
+ mobile_apis::messageType::response,
+ mobile_params.getParams());
+
+ rpc_service_.UpdateMobileRPCParams(mobile_apis::FunctionID::OnVehicleDataID,
+ mobile_apis::messageType::notification,
+ mobile_params.getParams());
+
+ rpc_service_.UpdateHMIRPCParams(
+ hmi_apis::FunctionID::VehicleInfo_GetVehicleData,
+ hmi_apis::messageType::request,
+ hmi_params.getBoolParams());
+
+ rpc_service_.UpdateHMIRPCParams(
+ hmi_apis::FunctionID::VehicleInfo_GetVehicleData,
+ hmi_apis::messageType::response,
+ hmi_params.getParams());
+
+ rpc_service_.UpdateHMIRPCParams(
+ hmi_apis::FunctionID::VehicleInfo_OnVehicleData,
+ hmi_apis::messageType::notification,
+ hmi_params.getParams());
+}
+
+void CustomVehicleDataManagerImpl::OnPolicyEvent(
+ plugin_manager::PolicyEvent policy_event) {
+ using namespace plugin_manager;
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ switch (policy_event) {
+ case kApplicationPolicyUpdated:
+ UpdateVehicleDataItems();
+ break;
+ case kApplicationsDisabled:
+ default:
+ return;
+ }
+}
+
+const OptionalDataItem
+CustomVehicleDataManagerImpl::FindSchemaByNameNonRecursive(
+ const std::string& name) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ auto& oem_items = vehicle_data_provider_.GetVehicleDataItems();
+ auto compare_by_name = [&name](const policy_table::VehicleDataItem& item) {
+ return (name == std::string(item.name));
+ };
+
+ return FindSchema(oem_items, SearchMethod::NON_RECURSIVE, compare_by_name);
+}
+
+const OptionalDataItem CustomVehicleDataManagerImpl::FindSchemaByNameRecursive(
+ const std::string& name) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ auto& oem_items = vehicle_data_provider_.GetVehicleDataItems();
+ auto compare_by_name = [&name](const policy_table::VehicleDataItem& item) {
+ return (name == std::string(item.name));
+ };
+
+ return FindSchema(oem_items, SearchMethod::RECURSIVE, compare_by_name);
+}
+
+const OptionalDataItem
+CustomVehicleDataManagerImpl::FindSchemaByKeyNonRecursive(
+ const std::string& key) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ auto& oem_items = vehicle_data_provider_.GetVehicleDataItems();
+ auto compare_by_key = [&key](const policy_table::VehicleDataItem& item) {
+ return (key == std::string(item.key));
+ };
+
+ return FindSchema(oem_items, SearchMethod::NON_RECURSIVE, compare_by_key);
+}
+
+const OptionalDataItem CustomVehicleDataManagerImpl::FindSchemaByKeyRecursive(
+ const std::string& key) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ auto& oem_items = vehicle_data_provider_.GetVehicleDataItems();
+ auto compare_by_key = [&key](const policy_table::VehicleDataItem& item) {
+ return (key == std::string(item.key));
+ };
+
+ return FindSchema(oem_items, SearchMethod::RECURSIVE, compare_by_key);
+}
+
+} // namespace vehicle_info_plugin
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_data_item_schema.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_data_item_schema.cc
new file mode 100644
index 0000000000..bb8ba49213
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_data_item_schema.cc
@@ -0,0 +1,184 @@
+#include "vehicle_info_plugin/vehicle_data_item_schema.h"
+#include <limits>
+
+namespace vehicle_info_plugin {
+
+#ifdef ENABLE_LOG
+CREATE_LOGGERPTR_LOCAL(vehicle_data_logger, "VehicleDataItemSchema");
+#endif // ENABLE_LOG
+
+VehicleDataItemSchema::VehicleDataItemSchema(PolicyDataItem& policy_item,
+ SchemaType schema_type) {
+ policy_table::VehicleDataItem policy_data_item;
+ policy_item.getValue(policy_data_item);
+
+ auto get_object_schema = [&policy_data_item,
+ &schema_type]() -> decltype(so_schema_item_) {
+ smart_objects::Members members;
+ auto object_schema = smart_objects::CObjectSchemaItem::create(members);
+
+ for (auto& e : *policy_data_item.params) {
+ auto schema_item = PolicyDataItem(e);
+ smart_objects::SMember member(create(schema_item, schema_type),
+ bool(e.mandatory),
+ std::string(*e.since),
+ std::string(*e.until),
+ bool(*e.deprecated),
+ bool(*e.removed));
+ std::string name;
+ switch (schema_type) {
+ case VehicleDataItemSchema::SchemaType::HMI:
+ name = e.key;
+ break;
+ case VehicleDataItemSchema::SchemaType::MOBILE:
+ default:
+ name = e.name;
+ break;
+ }
+ object_schema->AddMemberSchemaItem(name, member);
+ }
+
+ return object_schema;
+ };
+
+ auto get_schema = [&policy_data_item,
+ &get_object_schema,
+ &schema_type,
+ this]() -> decltype(so_schema_item_) {
+ // Check if policy item has POD type
+ if (isPODType(policy_data_item.type)) {
+ return GetPODTypeSchema(policy_data_item, schema_type);
+ }
+
+ // Check if policy item has Struct type
+ if (policy_data_item.type == policy_table::VehicleDataItem::kStruct) {
+ return get_object_schema();
+ }
+
+ // Check if policy item has Enum type
+ auto enum_schema = getEnumSchema(policy_data_item.type);
+ if (enum_schema != nullptr) {
+ return enum_schema;
+ }
+
+ return nullptr;
+ };
+
+ if (*policy_data_item.array) {
+ so_schema_item_ = smart_objects::CArraySchemaItem::create(
+ get_schema(),
+ policy_data_item.minsize.is_initialized()
+ ? smart_objects::TSchemaItemParameter<size_t>(
+ *policy_data_item.minsize)
+ : smart_objects::TSchemaItemParameter<size_t>(),
+ policy_data_item.maxsize.is_initialized()
+ ? smart_objects::TSchemaItemParameter<size_t>(
+ *policy_data_item.maxsize)
+ : smart_objects::TSchemaItemParameter<size_t>());
+ } else {
+ so_schema_item_ = get_schema();
+ }
+}
+
+VehicleDataItemSchemaPtr VehicleDataItemSchema::create(
+ PolicyDataItem& policy_item, SchemaType schema_type) {
+ return VehicleDataItemSchemaPtr(
+ new VehicleDataItemSchema(policy_item, schema_type));
+}
+
+smart_objects::errors::eType
+vehicle_info_plugin::VehicleDataItemSchema::validate(
+ const smart_objects::SmartObject& Object,
+ rpc::ValidationReport* report__,
+ const utils::SemanticVersion& MessageVersion,
+ const bool allow_unknown_enums) {
+ if (!so_schema_item_) {
+ std::string validation_info =
+ "Invalid type: " +
+ smart_objects::SmartObject::typeToString(Object.getType());
+ report__->set_validation_info(validation_info);
+ return smart_objects::errors::eType::ERROR;
+ }
+
+ return so_schema_item_->validate(
+ Object, report__, MessageVersion, allow_unknown_enums);
+}
+
+smart_objects::ISchemaItemPtr VehicleDataItemSchema::GetPODTypeSchema(
+ const policy_table::VehicleDataItem& policy_item, SchemaType schema_type) {
+ using IntSchemaItem = smart_objects::TNumberSchemaItem<int64_t>;
+ using IntItemParam = smart_objects::TSchemaItemParameter<int64_t>;
+ using FloatSchemaItem = smart_objects::TNumberSchemaItem<double>;
+ using FloatItemParam = smart_objects::TSchemaItemParameter<double>;
+ using StringSchemaItem = smart_objects::CStringSchemaItem;
+ using StringItemParam = smart_objects::TSchemaItemParameter<size_t>;
+ using BoolSchemaItem = smart_objects::CBoolSchemaItem;
+ using BoolItemParam = smart_objects::TSchemaItemParameter<bool>;
+
+ if (policy_item.type == policy_table::VehicleDataItem::kInteger) {
+ return IntSchemaItem::create(
+ IntItemParam(policy_item.minvalue.is_initialized()
+ ? *policy_item.minvalue
+ : std::numeric_limits<int64_t>::min()),
+ IntItemParam(policy_item.maxvalue.is_initialized()
+ ? *policy_item.maxvalue
+ : std::numeric_limits<int64_t>::max()));
+ }
+ if (policy_item.type == policy_table::VehicleDataItem::kFloat ||
+ policy_item.type == policy_table::VehicleDataItem::kDouble) {
+ return FloatSchemaItem::create(
+ FloatItemParam(policy_item.minvalue.is_initialized()
+ ? double(*policy_item.minvalue)
+ : std::numeric_limits<double>::min()),
+ FloatItemParam(policy_item.maxvalue.is_initialized()
+ ? double(*policy_item.maxvalue)
+ : std::numeric_limits<double>::max()));
+ }
+ if (policy_item.type == policy_table::VehicleDataItem::kString) {
+ return StringSchemaItem::create(
+ StringItemParam(policy_item.minlength.is_initialized()
+ ? *policy_item.minlength
+ : 0),
+ StringItemParam(policy_item.maxlength.is_initialized()
+ ? *policy_item.maxlength
+ : std::numeric_limits<uint32_t>::max()));
+ }
+ if (policy_item.type == policy_table::VehicleDataItem::kBoolean) {
+ return BoolSchemaItem::create(BoolItemParam(true));
+ }
+
+ std::string error_msg = std::string("Invalid POD type provided: ") +
+ std::string(policy_item.type);
+ LOG4CXX_ERROR(vehicle_data_logger, error_msg.c_str());
+ return nullptr;
+}
+
+const bool VehicleDataItemSchema::isPODType(
+ const std::string& type_name) const {
+ return std::find(policy_table::VehicleDataItem::kPODTypes.begin(),
+ policy_table::VehicleDataItem::kPODTypes.end(),
+ type_name) != policy_table::VehicleDataItem::kPODTypes.end();
+}
+
+smart_objects::ISchemaItemPtr VehicleDataItemSchema::getEnumSchema(
+ const std::string& type_name) const {
+ auto enum_schema = policy_table::EnumSchemaItemFactory::Get(type_name);
+ if (!enum_schema) {
+ LOG4CXX_ERROR(vehicle_data_logger, "NULL pointer: " << type_name);
+ }
+ return enum_schema;
+}
+
+void VehicleDataItemSchema::applySchema(
+ smart_objects::SmartObject& Object,
+ const bool remove_unknown_parameters,
+ const utils::SemanticVersion& MessageVersion) {
+ so_schema_item_->applySchema(
+ Object, remove_unknown_parameters, MessageVersion);
+}
+
+void VehicleDataItemSchema::unapplySchema(
+ smart_objects::SmartObject& Object, const bool remove_unknown_parameters) {
+ so_schema_item_->unapplySchema(Object, remove_unknown_parameters);
+}
+} // namespace vehicle_info_plugin
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_app_extension.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_app_extension.cc
index 730812e9c8..149299d3bb 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_app_extension.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_app_extension.cc
@@ -53,13 +53,13 @@ VehicleInfoAppExtension::~VehicleInfoAppExtension() {
}
bool VehicleInfoAppExtension::subscribeToVehicleInfo(
- const VehicleDataType vehicle_data) {
+ const std::string& vehicle_data) {
LOG4CXX_DEBUG(logger_, vehicle_data);
return subscribed_data_.insert(vehicle_data).second;
}
bool VehicleInfoAppExtension::unsubscribeFromVehicleInfo(
- const VehicleDataType vehicle_data) {
+ const std::string& vehicle_data) {
LOG4CXX_DEBUG(logger_, vehicle_data);
auto it = subscribed_data_.find(vehicle_data);
if (it != subscribed_data_.end()) {
@@ -75,7 +75,7 @@ void VehicleInfoAppExtension::unsubscribeFromVehicleInfo() {
}
bool VehicleInfoAppExtension::isSubscribedToVehicleInfo(
- const VehicleDataType vehicle_data) const {
+ const std::string& vehicle_data) const {
LOG4CXX_DEBUG(logger_, vehicle_data);
return subscribed_data_.find(vehicle_data) != subscribed_data_.end();
}
@@ -91,7 +91,7 @@ void VehicleInfoAppExtension::SaveResumptionData(
smart_objects::SmartObject(smart_objects::SmartType_Array);
int i = 0;
for (const auto& subscription : subscribed_data_) {
- resumption_data[application_vehicle_info][i] = subscription;
+ resumption_data[application_vehicle_info][i++] = subscription;
}
}
@@ -99,13 +99,12 @@ void VehicleInfoAppExtension::ProcessResumption(
const smart_objects::SmartObject& resumption_data) {
const char* application_vehicle_info = "vehicleInfo";
if (resumption_data.keyExists(application_vehicle_info)) {
- const smart_objects::SmartObject& subscriptions_ivi =
- resumption_data[application_vehicle_info];
- for (size_t i = 0; i < subscriptions_ivi.length(); ++i) {
- mobile_apis::VehicleDataType::eType ivi =
- static_cast<mobile_apis::VehicleDataType::eType>(
- (resumption_data[i]).asInt());
- subscribeToVehicleInfo(ivi);
+ const auto* subscriptions_ivi =
+ resumption_data[application_vehicle_info].asArray();
+ if (subscriptions_ivi) {
+ for (const auto& ivi : (*subscriptions_ivi)) {
+ subscribeToVehicleInfo(ivi.asString());
+ }
}
plugin_.ProcessResumptionSubscription(app_, *this);
}
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_command_factory.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_command_factory.cc
index 617925589f..52ee9f476d 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_command_factory.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_command_factory.cc
@@ -36,15 +36,27 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "VehicleInfoPlugin")
namespace vehicle_info_plugin {
+namespace app_mngr = application_manager;
+namespace commands = application_manager::commands;
+
VehicleInfoCommandFactory::VehicleInfoCommandFactory(
app_mngr::ApplicationManager& application_manager,
app_mngr::rpc_service::RPCService& rpc_service,
app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler)
- : hmi_command_factory_(new VehicleInfoHmiCommandFactory(
- application_manager, rpc_service, hmi_capabilities, policy_handler))
- , mob_command_factory_(new VehicleInfoMobileCommandFactory(
- application_manager, rpc_service, hmi_capabilities, policy_handler)) {
+ policy::PolicyHandlerInterface& policy_handler,
+ CustomVehicleDataManager& custom_vehicle_data_manager)
+ : hmi_command_factory_(
+ new VehicleInfoHmiCommandFactory(application_manager,
+ rpc_service,
+ hmi_capabilities,
+ policy_handler,
+ custom_vehicle_data_manager))
+ , mob_command_factory_(
+ new VehicleInfoMobileCommandFactory(application_manager,
+ rpc_service,
+ hmi_capabilities,
+ policy_handler,
+ custom_vehicle_data_manager)) {
LOG4CXX_AUTO_TRACE(logger_);
}
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_hmi_command_factory.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_hmi_command_factory.cc
index dd3b43920a..e8d852b612 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_hmi_command_factory.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_hmi_command_factory.cc
@@ -57,15 +57,75 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "VehicleInfoPlugin")
namespace vehicle_info_plugin {
namespace strings = app_mngr::strings;
+template <typename VehicleInfoCommandType>
+class VehicleInfoCommandCreator : public application_manager::CommandCreator {
+ public:
+ VehicleInfoCommandCreator(const VehicleInfoCommandParams& params)
+ : params_(params) {}
+
+ private:
+ bool CanBeCreated() const override {
+ return true;
+ }
+
+ application_manager::CommandSharedPtr create(
+ const application_manager::commands::MessageSharedPtr& message)
+ const override {
+ application_manager::CommandSharedPtr command(
+ new VehicleInfoCommandType(message, params_));
+ return command;
+ }
+
+ VehicleInfoCommandParams params_;
+};
+
+struct VehicleInfoInvalidCommand {};
+
+template <>
+class VehicleInfoCommandCreator<VehicleInfoInvalidCommand>
+ : public application_manager::CommandCreator {
+ public:
+ VehicleInfoCommandCreator(const VehicleInfoCommandParams& params) {
+ UNUSED(params);
+ }
+
+ private:
+ bool CanBeCreated() const override {
+ return false;
+ }
+
+ application_manager::CommandSharedPtr create(
+ const application_manager::commands::MessageSharedPtr& message)
+ const override {
+ UNUSED(message);
+ return application_manager::CommandSharedPtr();
+ }
+};
+
+struct VehicleInfoCommandCreatorFactory {
+ VehicleInfoCommandCreatorFactory(const VehicleInfoCommandParams& params)
+ : params_(params) {}
+
+ template <typename VehicleInfoCommandType>
+ application_manager::CommandCreator& GetCreator() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ static VehicleInfoCommandCreator<VehicleInfoCommandType> res(params_);
+ return res;
+ }
+ const VehicleInfoCommandParams params_;
+};
+
VehicleInfoHmiCommandFactory::VehicleInfoHmiCommandFactory(
application_manager::ApplicationManager& application_manager,
application_manager::rpc_service::RPCService& rpc_service,
application_manager::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler)
+ policy::PolicyHandlerInterface& policy_handler,
+ CustomVehicleDataManager& custom_vehicle_data_manager)
: application_manager_(application_manager)
, rpc_service_(rpc_service)
, hmi_capabilities_(hmi_capabilities)
- , policy_handler_(policy_handler) {
+ , policy_handler_(policy_handler)
+ , custom_vehicle_data_manager_(custom_vehicle_data_manager) {
LOG4CXX_AUTO_TRACE(logger_);
}
@@ -107,9 +167,12 @@ bool VehicleInfoHmiCommandFactory::IsAbleToProcess(
app_mngr::CommandCreator& VehicleInfoHmiCommandFactory::buildCommandCreator(
const int32_t function_id, const int32_t message_type) const {
- auto factory = app_mngr::CommandCreatorFactory(
- application_manager_, rpc_service_, hmi_capabilities_, policy_handler_);
-
+ VehicleInfoCommandParams params = {application_manager_,
+ rpc_service_,
+ hmi_capabilities_,
+ policy_handler_,
+ custom_vehicle_data_manager_};
+ auto factory = VehicleInfoCommandCreatorFactory(params);
switch (function_id) {
case hmi_apis::FunctionID::VehicleInfo_GetVehicleType:
return hmi_apis::messageType::request == message_type
@@ -150,7 +213,7 @@ app_mngr::CommandCreator& VehicleInfoHmiCommandFactory::buildCommandCreator(
: factory.GetCreator<commands::VIDiagnosticMessageResponse>();
default:
LOG4CXX_WARN(logger_, "Unsupported function_id: " << function_id);
- return factory.GetCreator<app_mngr::InvalidCommand>();
+ return factory.GetCreator<VehicleInfoInvalidCommand>();
}
}
} // namespace vehicle_info_plugin
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc
index dffc836a89..c3c8d9c8d7 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc
@@ -34,6 +34,9 @@
#include "application_manager/message.h"
#include "interfaces/MOBILE_API.h"
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
+
+#include "vehicle_info_plugin/custom_vehicle_data_manager.h"
#include "vehicle_info_plugin/commands/mobile/diagnostic_message_request.h"
#include "vehicle_info_plugin/commands/mobile/diagnostic_message_response.h"
@@ -54,21 +57,83 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "VehicleInfoPlugin")
namespace vehicle_info_plugin {
namespace strings = app_mngr::strings;
+template <typename VehicleInfoCommandType>
+class VehicleInfoCommandCreator : public application_manager::CommandCreator {
+ public:
+ VehicleInfoCommandCreator(const VehicleInfoCommandParams& params)
+ : params_(params) {}
+
+ private:
+ bool CanBeCreated() const override {
+ return true;
+ }
+
+ application_manager::CommandSharedPtr create(
+ const application_manager::commands::MessageSharedPtr& message)
+ const override {
+ application_manager::CommandSharedPtr command(
+ new VehicleInfoCommandType(message, params_));
+ return command;
+ }
+
+ VehicleInfoCommandParams params_;
+};
+
+struct VehicleInfoInvalidCommand {};
+
+template <>
+class VehicleInfoCommandCreator<VehicleInfoInvalidCommand>
+ : public application_manager::CommandCreator {
+ public:
+ VehicleInfoCommandCreator(const VehicleInfoCommandParams& params) {
+ UNUSED(params);
+ }
+
+ private:
+ bool CanBeCreated() const override {
+ return false;
+ }
+
+ application_manager::CommandSharedPtr create(
+ const application_manager::commands::MessageSharedPtr& message)
+ const override {
+ UNUSED(message);
+ return application_manager::CommandSharedPtr();
+ }
+};
+
+struct VehicleInfoCommandCreatorFactory {
+ VehicleInfoCommandCreatorFactory(const VehicleInfoCommandParams& params)
+ : params_(params) {}
+
+ template <typename VehicleInfoCommandType>
+ application_manager::CommandCreator& GetCreator() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ static VehicleInfoCommandCreator<VehicleInfoCommandType> res(params_);
+ return res;
+ }
+ const VehicleInfoCommandParams params_;
+};
+
VehicleInfoMobileCommandFactory::VehicleInfoMobileCommandFactory(
application_manager::ApplicationManager& application_manager,
application_manager::rpc_service::RPCService& rpc_service,
application_manager::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler)
+ policy::PolicyHandlerInterface& policy_handler,
+ CustomVehicleDataManager& custom_vehicle_data_manager)
: application_manager_(application_manager)
, rpc_service_(rpc_service)
, hmi_capabilities_(hmi_capabilities)
- , policy_handler_(policy_handler) {
+ , policy_handler_(policy_handler)
+ , custom_vehicle_data_manager_(custom_vehicle_data_manager) {
LOG4CXX_AUTO_TRACE(logger_);
}
app_mngr::CommandSharedPtr VehicleInfoMobileCommandFactory::CreateCommand(
const app_mngr::commands::MessageSharedPtr& message,
app_mngr::commands::Command::CommandSource source) {
+ UNUSED(source);
+
const mobile_apis::FunctionID::eType function_id =
static_cast<mobile_apis::FunctionID::eType>(
(*message)[strings::params][strings::function_id].asInt());
@@ -105,8 +170,12 @@ bool VehicleInfoMobileCommandFactory::IsAbleToProcess(
app_mngr::CommandCreator& VehicleInfoMobileCommandFactory::get_command_creator(
const mobile_apis::FunctionID::eType id,
const mobile_apis::messageType::eType message_type) const {
- auto factory = app_mngr::CommandCreatorFactory(
- application_manager_, rpc_service_, hmi_capabilities_, policy_handler_);
+ VehicleInfoCommandParams params = {application_manager_,
+ rpc_service_,
+ hmi_capabilities_,
+ policy_handler_,
+ custom_vehicle_data_manager_};
+ auto factory = VehicleInfoCommandCreatorFactory(params);
switch (id) {
case mobile_apis::FunctionID::GetVehicleDataID: {
return mobile_apis::messageType::request == message_type
@@ -141,21 +210,25 @@ app_mngr::CommandCreator& VehicleInfoMobileCommandFactory::get_command_creator(
}
default: {}
}
- return factory.GetCreator<app_mngr::InvalidCommand>();
+ return factory.GetCreator<VehicleInfoInvalidCommand>();
}
app_mngr::CommandCreator&
VehicleInfoMobileCommandFactory::get_notification_creator(
const mobile_apis::FunctionID::eType id) const {
- auto factory = app_mngr::CommandCreatorFactory(
- application_manager_, rpc_service_, hmi_capabilities_, policy_handler_);
+ VehicleInfoCommandParams params = {application_manager_,
+ rpc_service_,
+ hmi_capabilities_,
+ policy_handler_,
+ custom_vehicle_data_manager_};
+ auto factory = VehicleInfoCommandCreatorFactory(params);
switch (id) {
case mobile_apis::FunctionID::OnVehicleDataID: {
return factory.GetCreator<commands::OnVehicleDataNotification>();
}
default: {}
}
- return factory.GetCreator<app_mngr::InvalidCommand>();
+ return factory.GetCreator<VehicleInfoInvalidCommand>();
}
app_mngr::CommandCreator& VehicleInfoMobileCommandFactory::get_creator_factory(
@@ -183,8 +256,12 @@ app_mngr::CommandCreator& VehicleInfoMobileCommandFactory::get_creator_factory(
}
default: {}
}
- auto factory = app_mngr::CommandCreatorFactory(
- application_manager_, rpc_service_, hmi_capabilities_, policy_handler_);
- return factory.GetCreator<app_mngr::InvalidCommand>();
+ VehicleInfoCommandParams params = {application_manager_,
+ rpc_service_,
+ hmi_capabilities_,
+ policy_handler_,
+ custom_vehicle_data_manager_};
+ auto factory = VehicleInfoCommandCreatorFactory(params);
+ return factory.GetCreator<VehicleInfoInvalidCommand>();
}
} // namespace vehicle_info_plugin
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_plugin.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_plugin.cc
index cc1c22a248..d2aa4c64fb 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_plugin.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_plugin.cc
@@ -33,7 +33,9 @@
#include "vehicle_info_plugin/vehicle_info_plugin.h"
#include "application_manager/message_helper.h"
#include "application_manager/plugin_manager/plugin_keys.h"
+#include "application_manager/rpc_handler.h"
#include "application_manager/smart_object_keys.h"
+#include "vehicle_info_plugin/custom_vehicle_data_manager_impl.h"
#include "vehicle_info_plugin/vehicle_info_app_extension.h"
#include "vehicle_info_plugin/vehicle_info_command_factory.h"
@@ -42,6 +44,7 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "VehicleInfoPlugin")
namespace strings = application_manager::strings;
namespace plugins = application_manager::plugin_manager;
+namespace commands = application_manager::commands;
VehicleInfoPlugin::VehicleInfoPlugin() : application_manager_(nullptr) {}
@@ -51,8 +54,14 @@ bool VehicleInfoPlugin::Init(
application_manager::HMICapabilities& hmi_capabilities,
policy::PolicyHandlerInterface& policy_handler) {
application_manager_ = &app_manager;
+ custom_vehicle_data_manager_.reset(
+ new CustomVehicleDataManagerImpl(policy_handler, rpc_service));
command_factory_.reset(new vehicle_info_plugin::VehicleInfoCommandFactory(
- app_manager, rpc_service, hmi_capabilities, policy_handler));
+ app_manager,
+ rpc_service,
+ hmi_capabilities,
+ policy_handler,
+ *(custom_vehicle_data_manager_.get())));
return true;
}
@@ -69,7 +78,9 @@ app_mngr::CommandFactory& VehicleInfoPlugin::GetCommandFactory() {
return *command_factory_;
}
-void VehicleInfoPlugin::OnPolicyEvent(plugins::PolicyEvent event) {}
+void VehicleInfoPlugin::OnPolicyEvent(plugins::PolicyEvent event) {
+ custom_vehicle_data_manager_->OnPolicyEvent(event);
+}
void VehicleInfoPlugin::OnApplicationEvent(
plugins::ApplicationEvent event,
@@ -89,12 +100,8 @@ void VehicleInfoPlugin::ProcessResumptionSubscription(
smart_objects::SmartObject(smart_objects::SmartType_Map);
msg_params[strings::app_id] = app.app_id();
const auto& subscriptions = ext.Subscriptions();
- for (auto& ivi_data : application_manager::MessageHelper::vehicle_data()) {
- mobile_apis::VehicleDataType::eType type_id = ivi_data.second;
- if (subscriptions.end() != subscriptions.find(type_id)) {
- std::string key_name = ivi_data.first;
- msg_params[key_name] = true;
- }
+ for (const auto& item : subscriptions) {
+ msg_params[item] = true;
}
smart_objects::SmartObjectSPtr request =
application_manager::MessageHelper::CreateModuleInfoSO(
@@ -105,13 +112,13 @@ void VehicleInfoPlugin::ProcessResumptionSubscription(
}
application_manager::ApplicationSharedPtr FindAppSubscribedToIVI(
- mobile_apis::VehicleDataType::eType ivi_data,
+ const std::string& ivi_name,
application_manager::ApplicationManager& app_mngr) {
auto applications = app_mngr.applications();
for (auto& app : applications.GetData()) {
auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app);
- if (ext.isSubscribedToVehicleInfo(ivi_data)) {
+ if (ext.isSubscribedToVehicleInfo(ivi_name)) {
return app;
}
}
@@ -119,12 +126,13 @@ application_manager::ApplicationSharedPtr FindAppSubscribedToIVI(
}
smart_objects::SmartObjectSPtr GetUnsubscribeIVIRequest(
- int32_t ivi_id, application_manager::ApplicationManager& app_mngr) {
+ const std::string& ivi_name,
+ application_manager::ApplicationManager& app_mngr) {
using namespace smart_objects;
- auto find_ivi_name = [ivi_id]() {
+ auto find_ivi_name = [ivi_name]() {
for (auto item : application_manager::MessageHelper::vehicle_data()) {
- if (ivi_id == item.second) {
+ if (ivi_name == item.first) {
return item.first;
}
}
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/CMakeLists.txt b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/CMakeLists.txt
index 92984b6ad5..95d49f9a20 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/CMakeLists.txt
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/CMakeLists.txt
@@ -31,28 +31,41 @@
include(${CMAKE_SOURCE_DIR}/tools/cmake/helpers/sources.cmake)
include_directories(
+ include
${GMOCK_INCLUDE_DIRECTORY}
${COMPONENTS_DIR}/application_manager/rpc_plugins/vehicle_info_plugin/include
- ${COMPONENTS_DIR}/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/
+ ${COMPONENTS_DIR}/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands
${COMPONENTS_DIR}/application_manager/test/include/
-)
-
-
+ ${COMPONENTS_DIR}/include/test/application_manager/
+ )
set(COMMANDS_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/commands)
file(GLOB SOURCES
${COMPONENTS_DIR}/application_manager/test/mock_message_helper.cc
${COMPONENTS_DIR}/application_manager/test/mock_application_helper.cc
${COMPONENTS_DIR}/application_manager/src/smart_object_keys.cc
+ ${COMPONENTS_DIR}/${POLICY_PATH}/src/policy_table/types.cc
+ ${COMPONENTS_DIR}/${POLICY_PATH}/src/policy_table/validation.cc
+ ${COMPONENTS_DIR}/${POLICY_PATH}/src/policy_table/enums.cc
${COMMANDS_TEST_DIR}/hmi/*
${COMMANDS_TEST_DIR}/mobile/*
+ ${CMAKE_CURRENT_SOURCE_DIR}/custom_vehicle_data_manager_test.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/vehicle_data_item_schema_test.cc
${COMPONENTS_DIR}/application_manager/src/message.cc
${COMPONENTS_DIR}/application_manager/src/event_engine/*
)
set(LIBRARIES
- gmock
- vehicle_info_plugin_static
+ gmock
+ Utils
+ SmartObjects
+ HMI_API
+ MOBILE_API
+ connectionHandler
+ vehicle_info_plugin
+ SmartObjects
+ formatters
+ jsoncpp
)
create_cotired_test("vi_commands_test" "${SOURCES}" "${LIBRARIES}" )
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_get_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_get_vehicle_data_request_test.cc
new file mode 100644
index 0000000000..6bc956f65f
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_get_vehicle_data_request_test.cc
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2019, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "hmi/vi_get_vehicle_data_request.h"
+
+#include "gtest/gtest.h"
+
+#include "smart_objects/enum_schema_item.h"
+#include "smart_objects/smart_object.h"
+#include "vehicle_info_plugin/commands/vi_command_request_test.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace hmi_commands_test {
+namespace vi_get_vehicle_data_request {
+
+using ::testing::_;
+using ::testing::Return;
+using ::testing::ReturnRef;
+
+using vehicle_info_plugin::commands::VIGetVehicleDataRequest;
+
+namespace {
+const std::string kMobileParam = "mobile_param";
+const std::string kHMIParam = "hmi_param";
+} // namespace
+
+class VIGetVehicleDataRequestTest
+ : public VICommandRequestTest<CommandsTestMocks::kIsNice> {};
+
+MATCHER_P(EqualMsgParams, msg_params, "") {
+ using namespace app_mngr;
+ auto message = static_cast<smart_objects::SmartObject>(*arg);
+ if (!message.keyExists(strings::msg_params)) {
+ return false;
+ }
+
+ return msg_params == message[strings::msg_params];
+}
+
+TEST_F(VIGetVehicleDataRequestTest, Run_Success) {
+ using namespace app_mngr;
+ auto command_msg = CreateMessage(smart_objects::SmartType_Map);
+ (*command_msg)[strings::msg_params][strings::rpm] = true;
+ (*command_msg)[strings::msg_params][kMobileParam] = true;
+
+ am::VehicleData vehicle_data;
+ vehicle_data.insert(am::VehicleData::value_type(
+ strings::rpm, mobile_apis::VehicleDataType::VEHICLEDATA_RPM));
+ ON_CALL(mock_message_helper_, vehicle_data())
+ .WillByDefault(ReturnRef(vehicle_data));
+
+ std::string oem_vehicle_data_type_str;
+ smart_objects::EnumConversionHelper<mobile_apis::VehicleDataType::eType>::
+ EnumToString(mobile_apis::VehicleDataType::VEHICLEDATA_OEM_CUSTOM_DATA,
+ &oem_vehicle_data_type_str);
+
+ smart_objects::SmartObject hmi_params;
+ hmi_params[kHMIParam] = smart_objects::SmartType_Map;
+ hmi_params[kHMIParam][strings::data_type] = oem_vehicle_data_type_str;
+ ON_CALL(mock_custom_vehicle_data_manager_, CreateHMIMessageParams(_))
+ .WillByDefault(Return(hmi_params));
+
+ smart_objects::SmartObject hmi_request_msg;
+ hmi_request_msg[strings::rpm] =
+ (*command_msg)[strings::msg_params][strings::rpm];
+ hmi_request_msg[kHMIParam] = hmi_params[kHMIParam];
+
+ EXPECT_CALL(mock_rpc_service_,
+ SendMessageToHMI(EqualMsgParams(hmi_request_msg)));
+
+ auto command = CreateCommandVI<VIGetVehicleDataRequest>(command_msg);
+ command->Run();
+}
+
+} // namespace vi_get_vehicle_data_request
+} // namespace hmi_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_get_vehicle_data_response_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_get_vehicle_data_response_test.cc
index 575df4ce50..45bc748df4 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_get_vehicle_data_response_test.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_get_vehicle_data_response_test.cc
@@ -37,7 +37,6 @@
#include "gtest/gtest.h"
#include "application_manager/application.h"
-#include "application_manager/commands/commands_test.h"
#include "application_manager/event_engine/event.h"
#include "application_manager/message_helper.h"
#include "application_manager/mock_application_manager.h"
@@ -47,6 +46,7 @@
#include "application_manager/smart_object_keys.h"
#include "hmi/vi_get_vehicle_data_response.h"
#include "smart_objects/smart_object.h"
+#include "vehicle_info_plugin/commands/vi_commands_test.h"
namespace test {
namespace components {
@@ -74,7 +74,7 @@ const std::string kStrNumber = "123";
} // namespace
class VIGetVehicleDataResponseTest
- : public CommandsTest<CommandsTestMocks::kIsNice> {};
+ : public VICommandsTest<CommandsTestMocks::kIsNice> {};
TEST_F(VIGetVehicleDataResponseTest, RUN_SUCCESS) {
MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
@@ -84,7 +84,7 @@ TEST_F(VIGetVehicleDataResponseTest, RUN_SUCCESS) {
hmi_apis::messageType::response;
VIGetVehicleDataResponsePtr command(
- CreateCommand<VIGetVehicleDataResponse>(command_msg));
+ CreateCommandVI<VIGetVehicleDataResponse>(command_msg));
am::event_engine::Event event(
hmi_apis::FunctionID::VehicleInfo_GetVehicleData);
@@ -132,7 +132,7 @@ TEST_F(VIGetVehicleDataResponseTest, ErrorResponse_SUCCESS) {
(*command_msg)[strings::params][strings::protocol_version];
VIGetVehicleDataResponsePtr command(
- CreateCommand<VIGetVehicleDataResponse>(command_msg));
+ CreateCommandVI<VIGetVehicleDataResponse>(command_msg));
am::event_engine::Event event(
hmi_apis::FunctionID::VehicleInfo_GetVehicleData);
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_is_ready_request_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_is_ready_request_test.cc
index 8c77b492ee..c083bf4d60 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_is_ready_request_test.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_is_ready_request_test.cc
@@ -34,7 +34,6 @@
#include "gtest/gtest.h"
-#include "application_manager/commands/command_request_test.h"
#include "application_manager/event_engine/event.h"
#include "application_manager/hmi_interfaces.h"
#include "application_manager/mock_application_manager.h"
@@ -44,6 +43,7 @@
#include "application_manager/policies/mock_policy_handler_interface.h"
#include "application_manager/smart_object_keys.h"
#include "smart_objects/smart_object.h"
+#include "vehicle_info_plugin/commands/vi_command_request_test.h"
namespace test {
namespace components {
@@ -62,9 +62,9 @@ using vehicle_info_plugin::commands::VIIsReadyRequest;
typedef std::shared_ptr<VIIsReadyRequest> VIIsReadyRequestPtr;
class VIIsReadyRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ : public VICommandRequestTest<CommandsTestMocks::kIsNice> {
public:
- VIIsReadyRequestTest() : command_(CreateCommand<VIIsReadyRequest>()) {}
+ VIIsReadyRequestTest() : command_(CreateCommandVI<VIIsReadyRequest>()) {}
void SetUpExpectations(bool is_vi_cooperating_available,
bool is_send_message_to_hmi,
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_subscribe_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_subscribe_vehicle_data_request_test.cc
new file mode 100644
index 0000000000..fbaabfed06
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_subscribe_vehicle_data_request_test.cc
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2019, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "hmi/vi_subscribe_vehicle_data_request.h"
+
+#include "gtest/gtest.h"
+
+#include "smart_objects/enum_schema_item.h"
+#include "smart_objects/smart_object.h"
+#include "vehicle_info_plugin/commands/vi_command_request_test.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace hmi_commands_test {
+namespace vi_subscribe_vehicle_data_request {
+
+using ::testing::_;
+using ::testing::Return;
+using ::testing::ReturnRef;
+
+using vehicle_info_plugin::commands::VISubscribeVehicleDataRequest;
+
+namespace {
+const std::string kMobileParam = "mobile_param";
+const std::string kHMIParam = "hmi_param";
+} // namespace
+
+class VISubscribeVehicleDataRequestTest
+ : public VICommandRequestTest<CommandsTestMocks::kIsNice> {};
+
+MATCHER_P(EqualMsgParams, msg_params, "") {
+ using namespace app_mngr;
+ auto message = static_cast<smart_objects::SmartObject>(*arg);
+ if (!message.keyExists(strings::msg_params)) {
+ return false;
+ }
+
+ return msg_params == message[strings::msg_params];
+}
+
+TEST_F(VISubscribeVehicleDataRequestTest, Run_Success) {
+ using namespace app_mngr;
+ auto command_msg = CreateMessage(smart_objects::SmartType_Map);
+ (*command_msg)[strings::msg_params][strings::rpm] = true;
+ (*command_msg)[strings::msg_params][kMobileParam] = true;
+
+ am::VehicleData vehicle_data;
+ vehicle_data.insert(am::VehicleData::value_type(
+ strings::rpm, mobile_apis::VehicleDataType::VEHICLEDATA_RPM));
+ ON_CALL(mock_message_helper_, vehicle_data())
+ .WillByDefault(ReturnRef(vehicle_data));
+
+ std::string oem_vehicle_data_type_str;
+ smart_objects::EnumConversionHelper<mobile_apis::VehicleDataType::eType>::
+ EnumToString(mobile_apis::VehicleDataType::VEHICLEDATA_OEM_CUSTOM_DATA,
+ &oem_vehicle_data_type_str);
+
+ smart_objects::SmartObject hmi_params;
+ hmi_params[kHMIParam] = smart_objects::SmartType_Map;
+ hmi_params[kHMIParam][strings::data_type] = oem_vehicle_data_type_str;
+ ON_CALL(mock_custom_vehicle_data_manager_, CreateHMIMessageParams(_))
+ .WillByDefault(Return(hmi_params));
+
+ smart_objects::SmartObject hmi_request_msg;
+ hmi_request_msg[strings::rpm] =
+ (*command_msg)[strings::msg_params][strings::rpm];
+ hmi_request_msg[kHMIParam] = hmi_params[kHMIParam];
+
+ EXPECT_CALL(mock_rpc_service_,
+ SendMessageToHMI(EqualMsgParams(hmi_request_msg)));
+
+ auto command = CreateCommandVI<VISubscribeVehicleDataRequest>(command_msg);
+ command->Run();
+}
+
+} // namespace vi_subscribe_vehicle_data_request
+} // namespace hmi_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_unsubscribe_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_unsubscribe_vehicle_data_request_test.cc
new file mode 100644
index 0000000000..2ce04aa21a
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_unsubscribe_vehicle_data_request_test.cc
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2019, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "hmi/vi_unsubscribe_vehicle_data_request.h"
+
+#include "gtest/gtest.h"
+
+#include "smart_objects/enum_schema_item.h"
+#include "smart_objects/smart_object.h"
+#include "vehicle_info_plugin/commands/vi_command_request_test.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace hmi_commands_test {
+namespace vi_unsubscribe_vehicle_data_request {
+
+using ::testing::_;
+using ::testing::Return;
+using ::testing::ReturnRef;
+
+using vehicle_info_plugin::commands::VIUnsubscribeVehicleDataRequest;
+
+namespace {
+const std::string kMobileParam = "mobile_param";
+const std::string kHMIParam = "hmi_param";
+} // namespace
+
+class VIUnsubscribeVehicleDataRequestTest
+ : public VICommandRequestTest<CommandsTestMocks::kIsNice> {};
+
+MATCHER_P(EqualMsgParams, msg_params, "") {
+ using namespace app_mngr;
+ auto message = static_cast<smart_objects::SmartObject>(*arg);
+ if (!message.keyExists(strings::msg_params)) {
+ return false;
+ }
+
+ return msg_params == message[strings::msg_params];
+}
+
+TEST_F(VIUnsubscribeVehicleDataRequestTest, Run_Success) {
+ using namespace app_mngr;
+ auto command_msg = CreateMessage(smart_objects::SmartType_Map);
+ (*command_msg)[strings::msg_params][strings::rpm] = true;
+ (*command_msg)[strings::msg_params][kMobileParam] = true;
+
+ am::VehicleData vehicle_data;
+ vehicle_data.insert(am::VehicleData::value_type(
+ strings::rpm, mobile_apis::VehicleDataType::VEHICLEDATA_RPM));
+ ON_CALL(mock_message_helper_, vehicle_data())
+ .WillByDefault(ReturnRef(vehicle_data));
+
+ std::string oem_vehicle_data_type_str;
+ smart_objects::EnumConversionHelper<mobile_apis::VehicleDataType::eType>::
+ EnumToString(mobile_apis::VehicleDataType::VEHICLEDATA_OEM_CUSTOM_DATA,
+ &oem_vehicle_data_type_str);
+
+ smart_objects::SmartObject hmi_params;
+ hmi_params[kHMIParam] = smart_objects::SmartType_Map;
+ hmi_params[kHMIParam][strings::data_type] = oem_vehicle_data_type_str;
+ ON_CALL(mock_custom_vehicle_data_manager_, CreateHMIMessageParams(_))
+ .WillByDefault(Return(hmi_params));
+
+ smart_objects::SmartObject hmi_request_msg;
+ hmi_request_msg[strings::rpm] = true;
+ hmi_request_msg[kHMIParam] = true;
+
+ EXPECT_CALL(mock_rpc_service_,
+ SendMessageToHMI(EqualMsgParams(hmi_request_msg)));
+
+ auto command = CreateCommandVI<VIUnsubscribeVehicleDataRequest>(command_msg);
+ command->Run();
+}
+
+} // namespace vi_unsubscribe_vehicle_data_request
+} // namespace hmi_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/diagnostic_message_request_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/diagnostic_message_request_test.cc
index 3763e033fc..afafd1c6c6 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/diagnostic_message_request_test.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/diagnostic_message_request_test.cc
@@ -37,8 +37,6 @@
#include "gtest/gtest.h"
#include "application_manager/application.h"
-#include "application_manager/commands/command_request_test.h"
-#include "application_manager/commands/commands_test.h"
#include "application_manager/event_engine/event.h"
#include "application_manager/mock_application.h"
#include "application_manager/mock_application_manager.h"
@@ -47,6 +45,8 @@
#include "interfaces/MOBILE_API.h"
#include "smart_objects/smart_object.h"
#include "vehicle_info_plugin/commands/mobile/diagnostic_message_request.h"
+#include "vehicle_info_plugin/commands/vi_command_request_test.h"
+#include "vehicle_info_plugin/mock_custom_vehicle_data_manager.h"
namespace test {
namespace components {
@@ -71,7 +71,7 @@ const uint32_t kDiagnosticMode = 5u;
} // namespace
class DiagnosticMessageRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {};
+ : public VICommandRequestTest<CommandsTestMocks::kIsNice> {};
TEST_F(DiagnosticMessageRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) {
MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
@@ -79,7 +79,7 @@ TEST_F(DiagnosticMessageRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) {
kConnectionKey;
DiagnosticMessageRequestPtr command(
- CreateCommand<DiagnosticMessageRequest>(command_msg));
+ CreateCommandVI<DiagnosticMessageRequest>(command_msg));
EXPECT_CALL(app_mngr_, application(kConnectionKey))
.WillOnce(Return(ApplicationSharedPtr()));
@@ -100,7 +100,7 @@ TEST_F(DiagnosticMessageRequestTest, Run_NotSupportedDiagnosticMode_UNSUCCESS) {
kConnectionKey;
DiagnosticMessageRequestPtr command(
- CreateCommand<DiagnosticMessageRequest>(command_msg));
+ CreateCommandVI<DiagnosticMessageRequest>(command_msg));
MockAppPtr app(CreateMockApp());
EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app));
@@ -127,7 +127,7 @@ TEST_F(DiagnosticMessageRequestTest, Run_SUCCESS) {
kConnectionKey;
DiagnosticMessageRequestPtr command(
- CreateCommand<DiagnosticMessageRequest>(command_msg));
+ CreateCommandVI<DiagnosticMessageRequest>(command_msg));
MockAppPtr app(CreateMockApp());
EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app));
@@ -154,7 +154,7 @@ TEST_F(DiagnosticMessageRequestTest, OnEvent_UNSUCCESS) {
Event event(hmi_apis::FunctionID::INVALID_ENUM);
DiagnosticMessageRequestPtr command(
- CreateCommand<DiagnosticMessageRequest>());
+ CreateCommandVI<DiagnosticMessageRequest>());
EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0);
@@ -171,7 +171,7 @@ TEST_F(DiagnosticMessageRequestTest, OnEvent_SUCCESS) {
event.set_smart_object(*event_message);
DiagnosticMessageRequestPtr command(
- CreateCommand<DiagnosticMessageRequest>());
+ CreateCommandVI<DiagnosticMessageRequest>());
EXPECT_CALL(
mock_rpc_service_,
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_dtcs_request_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_dtcs_request_test.cc
index 1575fe2bd8..e4613feb83 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_dtcs_request_test.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_dtcs_request_test.cc
@@ -37,8 +37,6 @@
#include "gtest/gtest.h"
#include "application_manager/application.h"
-#include "application_manager/commands/command_request_test.h"
-#include "application_manager/commands/commands_test.h"
#include "application_manager/event_engine/event.h"
#include "application_manager/mock_application.h"
#include "application_manager/mock_application_manager.h"
@@ -47,6 +45,7 @@
#include "interfaces/MOBILE_API.h"
#include "mobile/get_dtcs_request.h"
#include "smart_objects/smart_object.h"
+#include "vehicle_info_plugin/commands/vi_command_request_test.h"
namespace test {
namespace components {
@@ -67,13 +66,13 @@ namespace mobile_result = mobile_apis::Result;
typedef std::shared_ptr<GetDTCsRequest> GetDTCsRequestPtr;
class GetDTCsRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ : public VICommandRequestTest<CommandsTestMocks::kIsNice> {
public:
- GetDTCsRequestTest() : CommandRequestTest<CommandsTestMocks::kIsNice>() {}
+ GetDTCsRequestTest() : VICommandRequestTest<CommandsTestMocks::kIsNice>() {}
};
TEST_F(GetDTCsRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) {
- GetDTCsRequestPtr command(CreateCommand<GetDTCsRequest>());
+ GetDTCsRequestPtr command(CreateCommandVI<GetDTCsRequest>());
EXPECT_CALL(app_mngr_, application(_))
.WillOnce(Return(ApplicationSharedPtr()));
@@ -93,7 +92,7 @@ TEST_F(GetDTCsRequestTest, Run_SUCCESS) {
(*command_msg)[am::strings::params][am::strings::connection_key] =
kConnectionKey;
- GetDTCsRequestPtr command(CreateCommand<GetDTCsRequest>(command_msg));
+ GetDTCsRequestPtr command(CreateCommandVI<GetDTCsRequest>(command_msg));
MockAppPtr app(CreateMockApp());
EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app));
@@ -107,7 +106,7 @@ TEST_F(GetDTCsRequestTest, Run_SUCCESS) {
}
TEST_F(GetDTCsRequestTest, OnEvent_UnknownEvent_UNSUCCESS) {
- GetDTCsRequestPtr command(CreateCommand<GetDTCsRequest>());
+ GetDTCsRequestPtr command(CreateCommandVI<GetDTCsRequest>());
Event event(hmi_apis::FunctionID::INVALID_ENUM);
@@ -132,7 +131,7 @@ TEST_F(GetDTCsRequestTest, OnEvent_SUCCESS) {
MockAppPtr app(CreateMockApp());
EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app));
- GetDTCsRequestPtr command(CreateCommand<GetDTCsRequest>());
+ GetDTCsRequestPtr command(CreateCommandVI<GetDTCsRequest>());
command->on_event(event);
}
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_vehicle_data_request_test.cc
index ed9fe9d1c0..3d33566ca9 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_vehicle_data_request_test.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_vehicle_data_request_test.cc
@@ -37,8 +37,6 @@
#include "gtest/gtest.h"
#include "application_manager/application.h"
-#include "application_manager/commands/command_request_test.h"
-#include "application_manager/commands/commands_test.h"
#include "application_manager/event_engine/event.h"
#include "application_manager/message_helper.h"
#include "application_manager/mock_application_manager.h"
@@ -47,6 +45,8 @@
#include "interfaces/MOBILE_API.h"
#include "mobile/get_vehicle_data_request.h"
#include "smart_objects/smart_object.h"
+#include "vehicle_info_plugin/commands/vi_command_request_test.h"
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
namespace test {
namespace components {
@@ -70,20 +70,14 @@ const uint32_t kConnectionKey = 2u;
} // namespace
class GetVehicleDataRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {};
+ : public VICommandRequestTest<CommandsTestMocks::kIsNice> {};
class UnwrappedGetVehicleDataRequest : public GetVehicleDataRequest {
public:
- UnwrappedGetVehicleDataRequest(const MessageSharedPtr& message,
- am::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler)
- : GetVehicleDataRequest(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handler) {}
+ UnwrappedGetVehicleDataRequest(
+ const MessageSharedPtr& message,
+ const vehicle_info_plugin::VehicleInfoCommandParams& params)
+ : GetVehicleDataRequest(message, params) {}
policy::RPCParams& get_disallowed_params() {
return removed_parameters_permissions_.disallowed_params;
@@ -93,7 +87,7 @@ class UnwrappedGetVehicleDataRequest : public GetVehicleDataRequest {
};
TEST_F(GetVehicleDataRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) {
- GetVehicleDataRequestPtr command(CreateCommand<GetVehicleDataRequest>());
+ GetVehicleDataRequestPtr command(CreateCommandVI<GetVehicleDataRequest>());
EXPECT_CALL(app_mngr_, application(_))
.WillOnce(Return(ApplicationSharedPtr()));
@@ -115,7 +109,7 @@ TEST_F(GetVehicleDataRequestTest, Run_TooHighFrequency_UNSUCCESS) {
kConnectionKey;
GetVehicleDataRequestPtr command(
- CreateCommand<GetVehicleDataRequest>(command_msg));
+ CreateCommandVI<GetVehicleDataRequest>(command_msg));
MockAppPtr app(CreateMockApp());
EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app));
@@ -138,14 +132,17 @@ TEST_F(GetVehicleDataRequestTest, Run_EmptyMsgParams_UNSUCCESS) {
kConnectionKey;
GetVehicleDataRequestPtr command(
- CreateCommand<GetVehicleDataRequest>(command_msg));
+ CreateCommandVI<GetVehicleDataRequest>(command_msg));
const am::VehicleData kEmptyVehicleData;
- EXPECT_CALL(mock_message_helper_, vehicle_data())
- .WillOnce(ReturnRef(kEmptyVehicleData));
+ ON_CALL(mock_message_helper_, vehicle_data())
+ .WillByDefault(ReturnRef(kEmptyVehicleData));
+ smart_objects::SmartObject empty_hmi_custom_params;
+ ON_CALL(mock_custom_vehicle_data_manager_, CreateHMIMessageParams(_))
+ .WillByDefault(Return(empty_hmi_custom_params));
MockAppPtr app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app));
+ ON_CALL(app_mngr_, application(kConnectionKey)).WillByDefault(Return(app));
EXPECT_CALL(
mock_rpc_service_,
@@ -161,11 +158,15 @@ TEST_F(GetVehicleDataRequestTest,
kConnectionKey;
std::shared_ptr<UnwrappedGetVehicleDataRequest> command(
- CreateCommand<UnwrappedGetVehicleDataRequest>(command_msg));
+ CreateCommandVI<UnwrappedGetVehicleDataRequest>(command_msg));
+
+ smart_objects::SmartObject empty_hmi_custom_params;
+ ON_CALL(mock_custom_vehicle_data_manager_, CreateHMIMessageParams(_))
+ .WillByDefault(Return(empty_hmi_custom_params));
const am::VehicleData kEmptyVehicleData;
- EXPECT_CALL(mock_message_helper_, vehicle_data())
- .WillRepeatedly(ReturnRef(kEmptyVehicleData));
+ ON_CALL(mock_message_helper_, vehicle_data())
+ .WillByDefault(ReturnRef(kEmptyVehicleData));
policy::RPCParams& disallowed_params = command->get_disallowed_params();
disallowed_params.insert("test_param");
@@ -189,13 +190,13 @@ TEST_F(GetVehicleDataRequestTest, Run_SUCCESS) {
(*command_msg)[am::strings::msg_params][kMsgParamKey] = true;
GetVehicleDataRequestPtr command(
- CreateCommand<GetVehicleDataRequest>(command_msg));
+ CreateCommandVI<GetVehicleDataRequest>(command_msg));
am::VehicleData vehicle_data;
vehicle_data.insert(am::VehicleData::value_type(
kMsgParamKey, mobile_apis::VehicleDataType::VEHICLEDATA_SPEED));
- EXPECT_CALL(mock_message_helper_, vehicle_data())
- .WillOnce(ReturnRef(vehicle_data));
+ ON_CALL(mock_message_helper_, vehicle_data())
+ .WillByDefault(ReturnRef(vehicle_data));
MockAppPtr app(CreateMockApp());
EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app));
@@ -215,7 +216,7 @@ TEST_F(GetVehicleDataRequestTest, OnEvent_UnknownEvent_UNSUCCESS) {
kConnectionKey;
std::shared_ptr<UnwrappedGetVehicleDataRequest> command(
- CreateCommand<UnwrappedGetVehicleDataRequest>(command_msg));
+ CreateCommandVI<UnwrappedGetVehicleDataRequest>(command_msg));
Event event(hmi_apis::FunctionID::INVALID_ENUM);
@@ -235,7 +236,7 @@ TEST_F(GetVehicleDataRequestTest, OnEvent_DataNotAvailable_SUCCESS) {
kConnectionKey;
std::shared_ptr<UnwrappedGetVehicleDataRequest> command(
- CreateCommand<UnwrappedGetVehicleDataRequest>(command_msg));
+ CreateCommandVI<UnwrappedGetVehicleDataRequest>(command_msg));
MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map));
(*event_msg)[am::strings::params][am::hmi_response::code] = hmi_response_code;
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_vehicle_data_response_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_vehicle_data_response_test.cc
index fb14373bcf..ad7a14ce40 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_vehicle_data_response_test.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_vehicle_data_response_test.cc
@@ -33,6 +33,8 @@
#include "gtest/gtest.h"
#include "application_manager/commands/commands_test.h"
+#include "vehicle_info_plugin/commands/vi_commands_test.h"
+
#include "mobile/get_vehicle_data_response.h"
#include "smart_objects/smart_object.h"
@@ -49,12 +51,12 @@ using vehicle_info_plugin::commands::GetVehicleDataResponse;
typedef std::shared_ptr<GetVehicleDataResponse> GetVehicleDataResponsePtr;
class GetVehicleDataResponseTest
- : public CommandsTest<CommandsTestMocks::kIsNice> {};
+ : public VICommandsTest<CommandsTestMocks::kIsNice> {};
TEST_F(GetVehicleDataResponseTest, GetVehicleDataResponse_SUCCESS) {
MessageSharedPtr message(CreateMessage(smart_objects::SmartType_Map));
GetVehicleDataResponsePtr command(
- CreateCommand<GetVehicleDataResponse>(message));
+ CreateCommandVI<GetVehicleDataResponse>(message));
EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(message, _));
command->Run();
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/on_vehicle_data_notification_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/on_vehicle_data_notification_test.cc
index 8df00521de..82eb19c45f 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/on_vehicle_data_notification_test.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/on_vehicle_data_notification_test.cc
@@ -43,6 +43,7 @@
#include "smart_objects/smart_object.h"
#include "utils/custom_string.h"
#include "utils/helpers.h"
+#include "vehicle_info_plugin/commands/vi_commands_test.h"
#include "vehicle_info_plugin/vehicle_info_app_extension.h"
#include "vehicle_info_plugin/vehicle_info_plugin.h"
@@ -72,7 +73,7 @@ const utils::custom_string::CustomString kAppName("test_app");
} // namespace
class OnVehicleDataNotificationTest
- : public CommandsTest<CommandsTestMocks::kIsNice> {
+ : public VICommandsTest<CommandsTestMocks::kIsNice> {
public:
OnVehicleDataNotificationTest() : mock_app_(CreateMockApp()) {}
@@ -87,47 +88,47 @@ class OnVehicleDataNotificationTest
MockAppPtr mock_app_;
};
-TEST_F(OnVehicleDataNotificationTest, OnVehicleDataNotification_SUCCESS) {
- MessageSharedPtr message(CreateMessage(smart_objects::SmartType_Map));
- smart_objects::SmartObject gps_data;
- gps_data[am::strings::longitude_degrees] = 1.0;
- gps_data[am::strings::latitude_degrees] = 1.0;
- gps_data[am::strings::shifted] = true;
+MATCHER_P(SmartObjectCheck, checker, "") {
+ return checker(arg);
+}
- (*message)[am::strings::msg_params][am::strings::gps] = gps_data;
- (*message)[am::strings::msg_params][am::strings::speed] = 0;
+TEST_F(OnVehicleDataNotificationTest, OnVehicleDataNotification_SUCCESS) {
+ am::VehicleData vehicle_data;
+ vehicle_data.insert(am::VehicleData::value_type(
+ am::strings::gps, mobile_apis::VehicleDataType::VEHICLEDATA_GPS));
+ vehicle_data.insert(am::VehicleData::value_type(
+ am::strings::speed, mobile_apis::VehicleDataType::VEHICLEDATA_SPEED));
+ ON_CALL(mock_message_helper_, vehicle_data())
+ .WillByDefault(ReturnRef(vehicle_data));
- NotificationPtr command(CreateCommand<OnVehicleDataNotification>(message));
+ application_manager::ApplicationSet apps;
+ apps.insert(mock_app_);
+ std::shared_ptr<sync_primitives::Lock> apps_lock =
+ std::make_shared<sync_primitives::Lock>();
+ ApplicationSetDA apps_da(apps, apps_lock);
+ ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_da));
vehicle_info_plugin::VehicleInfoPlugin vi_plugin;
VehicleInfoAppExtensionPtr vi_app_extention_ptr =
std::make_shared<vehicle_info_plugin::VehicleInfoAppExtension>(
vi_plugin, *mock_app_);
- vi_app_extention_ptr->subscribeToVehicleInfo(
- mobile_apis::VehicleDataType::VEHICLEDATA_GPS);
- vi_app_extention_ptr->subscribeToVehicleInfo(
- mobile_apis::VehicleDataType::VEHICLEDATA_SPEED);
-
- EXPECT_CALL(*mock_app_,
- QueryInterface(vehicle_info_plugin::VehicleInfoAppExtension::
- VehicleInfoAppExtensionUID))
- .WillOnce(Return(vi_app_extention_ptr));
+ vi_app_extention_ptr->subscribeToVehicleInfo("gps");
+ vi_app_extention_ptr->subscribeToVehicleInfo("speed");
+ ON_CALL(*mock_app_,
+ QueryInterface(vehicle_info_plugin::VehicleInfoAppExtension::
+ VehicleInfoAppExtensionUID))
+ .WillByDefault(Return(vi_app_extention_ptr));
- application_manager::ApplicationSet apps;
- apps.insert(mock_app_);
- std::shared_ptr<sync_primitives::Lock> apps_lock =
- std::make_shared<sync_primitives::Lock>();
- ApplicationSetDA apps_da(apps, apps_lock);
- EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(apps_da));
+ MessageSharedPtr message(CreateMessage(smart_objects::SmartType_Map));
+ smart_objects::SmartObject gps_data;
+ gps_data[am::strings::longitude_degrees] = 1.0;
+ gps_data[am::strings::latitude_degrees] = 1.0;
+ gps_data[am::strings::shifted] = true;
- am::VehicleData vehicle_data;
- vehicle_data.insert(am::VehicleData::value_type(
- am::strings::gps, mobile_apis::VehicleDataType::VEHICLEDATA_GPS));
- vehicle_data.insert(am::VehicleData::value_type(
- am::strings::gps, mobile_apis::VehicleDataType::VEHICLEDATA_SPEED));
- EXPECT_CALL(mock_message_helper_, vehicle_data())
- .WillOnce(ReturnRef(vehicle_data));
+ (*message)[am::strings::msg_params][am::strings::gps] = gps_data;
+ (*message)[am::strings::msg_params][am::strings::speed] = 0;
+ NotificationPtr command(CreateCommandVI<OnVehicleDataNotification>(message));
EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(message, _));
command->Run();
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/read_did_request_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/read_did_request_test.cc
index baf75bd93b..372d562965 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/read_did_request_test.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/read_did_request_test.cc
@@ -36,8 +36,6 @@
#include "gtest/gtest.h"
#include "application_manager/application.h"
-#include "application_manager/commands/command_request_test.h"
-#include "application_manager/commands/commands_test.h"
#include "application_manager/event_engine/event.h"
#include "application_manager/mock_application.h"
#include "application_manager/mock_application_manager.h"
@@ -47,6 +45,7 @@
#include "interfaces/MOBILE_API.h"
#include "smart_objects/smart_object.h"
#include "vehicle_info_plugin/commands/mobile/read_did_request.h"
+#include "vehicle_info_plugin/commands/vi_command_request_test.h"
namespace test {
namespace components {
@@ -64,11 +63,11 @@ using am::event_engine::Event;
using vehicle_info_plugin::commands::ReadDIDRequest;
class ReadDIDRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {};
+ : public VICommandRequestTest<CommandsTestMocks::kIsNice> {};
TEST_F(ReadDIDRequestTest, OnEvent_WrongEventId_UNSUCCESS) {
Event event(Event::EventID::INVALID_ENUM);
- std::shared_ptr<ReadDIDRequest> command(CreateCommand<ReadDIDRequest>());
+ std::shared_ptr<ReadDIDRequest> command(CreateCommandVI<ReadDIDRequest>());
EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0);
command->on_event(event);
}
@@ -76,7 +75,7 @@ TEST_F(ReadDIDRequestTest, OnEvent_WrongEventId_UNSUCCESS) {
TEST_F(ReadDIDRequestTest, OnEvent_SUCCESS) {
Event event(Event::EventID::VehicleInfo_ReadDID);
- std::shared_ptr<ReadDIDRequest> command(CreateCommand<ReadDIDRequest>());
+ std::shared_ptr<ReadDIDRequest> command(CreateCommandVI<ReadDIDRequest>());
const hmi_apis::Common_Result::eType hmi_response_code =
hmi_apis::Common_Result::SUCCESS;
@@ -98,7 +97,7 @@ TEST_F(ReadDIDRequestTest, OnEvent_SUCCESS) {
}
TEST_F(ReadDIDRequestTest, Run_AppNotRegistered_UNSUCCESS) {
- std::shared_ptr<ReadDIDRequest> command(CreateCommand<ReadDIDRequest>());
+ std::shared_ptr<ReadDIDRequest> command(CreateCommandVI<ReadDIDRequest>());
ON_CALL(app_mngr_, application(_))
.WillByDefault(Return(std::shared_ptr<am::Application>()));
@@ -111,7 +110,7 @@ TEST_F(ReadDIDRequestTest, Run_AppNotRegistered_UNSUCCESS) {
}
TEST_F(ReadDIDRequestTest, Run_CommandLimitsExceeded_UNSUCCESS) {
- std::shared_ptr<ReadDIDRequest> command(CreateCommand<ReadDIDRequest>());
+ std::shared_ptr<ReadDIDRequest> command(CreateCommandVI<ReadDIDRequest>());
MockAppPtr app(CreateMockApp());
ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
@@ -127,7 +126,7 @@ TEST_F(ReadDIDRequestTest, Run_CommandLimitsExceeded_UNSUCCESS) {
TEST_F(ReadDIDRequestTest, Run_EmptyDidLocation_UNSUCCESS) {
MockAppPtr app(CreateMockApp());
- std::shared_ptr<ReadDIDRequest> command(CreateCommand<ReadDIDRequest>());
+ std::shared_ptr<ReadDIDRequest> command(CreateCommandVI<ReadDIDRequest>());
ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
@@ -144,7 +143,7 @@ TEST_F(ReadDIDRequestTest, Run_SUCCESS) {
MockAppPtr app(CreateMockApp());
MessageSharedPtr msg(CreateMessage(smart_objects::SmartType_Map));
(*msg)[am::strings::msg_params][am::strings::did_location]["SomeData"] = 0;
- std::shared_ptr<ReadDIDRequest> command(CreateCommand<ReadDIDRequest>(msg));
+ std::shared_ptr<ReadDIDRequest> command(CreateCommandVI<ReadDIDRequest>(msg));
ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/unsubscribe_vehicle_request_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/unsubscribe_vehicle_request_test.cc
index 0126e7c762..a88ea3f8b8 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/unsubscribe_vehicle_request_test.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/unsubscribe_vehicle_request_test.cc
@@ -35,13 +35,15 @@
#include "gtest/gtest.h"
-#include "application_manager/commands/command_request_test.h"
#include "application_manager/mock_application_manager.h"
#include "application_manager/mock_message_helper.h"
#include "mobile/unsubscribe_vehicle_data_request.h"
+#include "vehicle_info_plugin/commands/vi_command_request_test.h"
#include "vehicle_info_plugin/vehicle_info_app_extension.h"
#include "vehicle_info_plugin/vehicle_info_plugin.h"
+#include "application_manager/mock_rpc_handler.h"
+
namespace test {
namespace components {
namespace commands_test {
@@ -63,10 +65,11 @@ const uint32_t kConnectionKey = 1u;
const std::string kMsgParamKey = "test_key";
const mobile_apis::VehicleDataType::eType kVehicleType =
mobile_apis::VehicleDataType::VEHICLEDATA_SPEED;
+const std::string kVehicleTypeStr = am::strings::speed;
} // namespace
class UnsubscribeVehicleRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ : public VICommandRequestTest<CommandsTestMocks::kIsNice> {
public:
UnsubscribeVehicleRequestTest()
: mock_app_(CreateMockApp())
@@ -78,6 +81,9 @@ class UnsubscribeVehicleRequestTest
protected:
void UnsubscribeSuccessfully();
void SetUp() OVERRIDE {
+ ON_CALL(app_mngr_, GetRPCHandler())
+ .WillByDefault(ReturnRef(mock_rpc_handler_));
+
vi_plugin_.Init(app_mngr_,
mock_rpc_service_,
mock_hmi_capabilities_,
@@ -90,16 +96,18 @@ class UnsubscribeVehicleRequestTest
QueryInterface(vehicle_info_plugin::VehicleInfoAppExtension::
VehicleInfoAppExtensionUID))
.WillByDefault(Return(vi_app_extension_ptr_));
+ ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey));
}
MockAppPtr mock_app_;
application_manager::AppExtensionPtr vi_app_extension_ptr_;
std::shared_ptr<sync_primitives::Lock> app_set_lock_ptr_;
vehicle_info_plugin::VehicleInfoPlugin vi_plugin_;
+ application_manager_test::MockRPCHandler mock_rpc_handler_;
};
TEST_F(UnsubscribeVehicleRequestTest, Run_AppNotRegistered_UNSUCCESS) {
- CommandPtr command(CreateCommand<UnsubscribeVehicleDataRequest>());
+ CommandPtr command(CreateCommandVI<UnsubscribeVehicleDataRequest>());
EXPECT_CALL(app_mngr_, application(_))
.WillOnce(Return(ApplicationSharedPtr()));
@@ -117,11 +125,18 @@ TEST_F(UnsubscribeVehicleRequestTest,
(*command_msg)[am::strings::params][am::strings::connection_key] =
kConnectionKey;
(*command_msg)[am::strings::msg_params][am::strings::button_name] =
- kVehicleType;
+ kVehicleTypeStr;
am::VehicleData data;
- EXPECT_CALL(mock_message_helper_, vehicle_data()).WillOnce(ReturnRef(data));
- CommandPtr command(CreateCommand<UnsubscribeVehicleDataRequest>(command_msg));
+ EXPECT_CALL(mock_message_helper_, vehicle_data())
+ .WillRepeatedly(ReturnRef(data));
+
+ smart_objects::SmartObject empty_hmi_custom_params;
+ ON_CALL(mock_custom_vehicle_data_manager_, CreateHMIMessageParams(_))
+ .WillByDefault(Return(empty_hmi_custom_params));
+
+ CommandPtr command(
+ CreateCommandVI<UnsubscribeVehicleDataRequest>(command_msg));
EXPECT_CALL(app_mngr_, application(kConnectionKey))
.WillOnce(Return(mock_app_));
@@ -138,12 +153,15 @@ TEST_F(UnsubscribeVehicleRequestTest,
MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
(*command_msg)[am::strings::params][am::strings::connection_key] =
kConnectionKey;
- (*command_msg)[am::strings::msg_params][kMsgParamKey] = true;
+ (*command_msg)[am::strings::msg_params][kVehicleTypeStr] = true;
am::VehicleData vehicle_data;
vehicle_data.insert(am::VehicleData::value_type(kMsgParamKey, kVehicleType));
- EXPECT_CALL(mock_message_helper_, vehicle_data())
- .WillOnce(ReturnRef(vehicle_data));
+ ON_CALL(mock_message_helper_, vehicle_data())
+ .WillByDefault(ReturnRef(vehicle_data));
+
+ smart_objects::SmartObject hmi_custom_params(smart_objects::SmartType_Map);
+ hmi_custom_params[kVehicleTypeStr] = true;
EXPECT_CALL(app_mngr_, application(kConnectionKey))
.WillOnce(Return(mock_app_));
@@ -157,13 +175,14 @@ TEST_F(UnsubscribeVehicleRequestTest,
vehicle_info_plugin::VehicleInfoAppExtension* vi_app_extension =
dynamic_cast<vehicle_info_plugin::VehicleInfoAppExtension*>(
vi_app_extension_ptr_.get());
- ASSERT_TRUE(vi_app_extension->subscribeToVehicleInfo(kVehicleType));
+ ASSERT_TRUE(vi_app_extension->subscribeToVehicleInfo(kVehicleTypeStr));
application_manager::ApplicationSet app_set = {mock_app_};
DataAccessor<application_manager::ApplicationSet> accessor(app_set,
app_set_lock_ptr_);
// Expectations
EXPECT_CALL(app_mngr_, applications()).WillRepeatedly(Return(accessor));
- CommandPtr command(CreateCommand<UnsubscribeVehicleDataRequest>(command_msg));
+ CommandPtr command(
+ CreateCommandVI<UnsubscribeVehicleDataRequest>(command_msg));
command->Run();
}
@@ -171,9 +190,12 @@ TEST_F(UnsubscribeVehicleRequestTest,
Run_EmptyVehicleData_INVALID_DATA_SentToMobile) {
am::VehicleData vehicle_data;
EXPECT_CALL(mock_message_helper_, vehicle_data())
- .WillOnce(ReturnRef(vehicle_data));
+ .WillRepeatedly(ReturnRef(vehicle_data));
+
+ smart_objects::SmartObject empty_hmi_custom_params;
+ ON_CALL(mock_custom_vehicle_data_manager_, CreateHMIMessageParams(_))
+ .WillByDefault(Return(empty_hmi_custom_params));
- MockAppPtr mock_app(CreateMockApp());
EXPECT_CALL(app_mngr_, application(kConnectionKey))
.WillOnce(Return(mock_app_));
@@ -185,17 +207,21 @@ TEST_F(UnsubscribeVehicleRequestTest,
(*command_msg)[am::strings::params][am::strings::connection_key] =
kConnectionKey;
(*command_msg)[am::strings::msg_params][kMsgParamKey] = false;
- CommandPtr command(CreateCommand<UnsubscribeVehicleDataRequest>(command_msg));
+ CommandPtr command(
+ CreateCommandVI<UnsubscribeVehicleDataRequest>(command_msg));
command->Run();
}
TEST_F(UnsubscribeVehicleRequestTest,
Run_UnsubscribeFromNotSubscribedBeforeData_UNSUCCESS) {
+ smart_objects::SmartObject empty_hmi_custom_params;
+ ON_CALL(mock_custom_vehicle_data_manager_, CreateHMIMessageParams(_))
+ .WillByDefault(Return(empty_hmi_custom_params));
+
am::VehicleData vehicle_data;
vehicle_data.insert(am::VehicleData::value_type(kMsgParamKey, kVehicleType));
EXPECT_CALL(mock_message_helper_, vehicle_data())
- .WillOnce(ReturnRef(vehicle_data));
-
+ .WillRepeatedly(ReturnRef(vehicle_data));
EXPECT_CALL(app_mngr_, application(kConnectionKey))
.WillOnce(Return(mock_app_));
@@ -207,7 +233,8 @@ TEST_F(UnsubscribeVehicleRequestTest,
(*command_msg)[am::strings::params][am::strings::connection_key] =
kConnectionKey;
(*command_msg)[am::strings::msg_params][kMsgParamKey] = true;
- CommandPtr command(CreateCommand<UnsubscribeVehicleDataRequest>(command_msg));
+ CommandPtr command(
+ CreateCommandVI<UnsubscribeVehicleDataRequest>(command_msg));
command->Run();
}
@@ -216,15 +243,19 @@ TEST_F(UnsubscribeVehicleRequestTest, Run_UnsubscribeDataDisabled_UNSUCCESS) {
(*command_msg)[am::strings::params][am::strings::connection_key] =
kConnectionKey;
+ smart_objects::SmartObject empty_hmi_custom_params;
+ ON_CALL(mock_custom_vehicle_data_manager_, CreateHMIMessageParams(_))
+ .WillByDefault(Return(empty_hmi_custom_params));
+
+ CommandPtr command(
+ CreateCommandVI<UnsubscribeVehicleDataRequest>(command_msg));
+
am::VehicleData vehicle_data;
vehicle_data.insert(am::VehicleData::value_type(kMsgParamKey, kVehicleType));
EXPECT_CALL(mock_message_helper_, vehicle_data())
- .WillOnce(ReturnRef(vehicle_data));
- CommandPtr command(CreateCommand<UnsubscribeVehicleDataRequest>(command_msg));
-
- MockAppPtr mock_app(CreateMockApp());
+ .WillRepeatedly(ReturnRef(vehicle_data));
EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
+ .WillOnce(Return(mock_app_));
EXPECT_CALL(
mock_rpc_service_,
@@ -238,7 +269,8 @@ TEST_F(UnsubscribeVehicleRequestTest, OnEvent_DataNotSubscribed_IGNORED) {
(*command_msg)[am::strings::params][am::strings::connection_key] =
kConnectionKey;
(*command_msg)[am::strings::msg_params][kMsgParamKey] = true;
- CommandPtr command(CreateCommand<UnsubscribeVehicleDataRequest>(command_msg));
+ CommandPtr command(
+ CreateCommandVI<UnsubscribeVehicleDataRequest>(command_msg));
am::VehicleData vehicle_data;
@@ -246,7 +278,11 @@ TEST_F(UnsubscribeVehicleRequestTest, OnEvent_DataNotSubscribed_IGNORED) {
.WillRepeatedly(Return(mock_app_));
vehicle_data.insert(am::VehicleData::value_type(kMsgParamKey, kVehicleType));
EXPECT_CALL(mock_message_helper_, vehicle_data())
- .WillOnce(ReturnRef(vehicle_data));
+ .WillRepeatedly(ReturnRef(vehicle_data));
+
+ smart_objects::SmartObject empty_hmi_custom_params;
+ ON_CALL(mock_custom_vehicle_data_manager_, CreateHMIMessageParams(_))
+ .WillByDefault(Return(empty_hmi_custom_params));
EXPECT_CALL(
mock_rpc_service_,
@@ -276,7 +312,8 @@ TEST_F(UnsubscribeVehicleRequestTest, OnEvent_DataUnsubscribed_SUCCESS) {
(*command_msg)[am::strings::params][am::strings::connection_key] =
kConnectionKey;
(*command_msg)[am::strings::msg_params][kMsgParamKey] = true;
- CommandPtr command(CreateCommand<UnsubscribeVehicleDataRequest>(command_msg));
+ CommandPtr command(
+ CreateCommandVI<UnsubscribeVehicleDataRequest>(command_msg));
EXPECT_CALL(app_mngr_, application(kConnectionKey))
.WillRepeatedly(Return(mock_app_));
@@ -289,6 +326,11 @@ TEST_F(UnsubscribeVehicleRequestTest, OnEvent_DataUnsubscribed_SUCCESS) {
message[am::strings::msg_params][kMsgParamKey] = true;
test_event.set_smart_object(message);
+ am::VehicleData vehicle_data;
+ vehicle_data.insert(am::VehicleData::value_type(kMsgParamKey, kVehicleType));
+ EXPECT_CALL(mock_message_helper_, vehicle_data())
+ .WillRepeatedly(ReturnRef(vehicle_data));
+
EXPECT_CALL(
mock_rpc_service_,
ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _));
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/unsubscribe_vehicle_response_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/unsubscribe_vehicle_response_test.cc
index 89dbfe1cdb..7c610c8adb 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/unsubscribe_vehicle_response_test.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/unsubscribe_vehicle_response_test.cc
@@ -32,11 +32,13 @@
#include <stdint.h>
#include <string>
+#include "application_manager/mock_application_manager.h"
#include "gtest/gtest.h"
#include "mobile/unsubscribe_vehicle_data_response.h"
-#include "application_manager/commands/commands_test.h"
-#include "application_manager/mock_application_manager.h"
+#include "vehicle_info_plugin/commands/vi_commands_test.h"
+#include "vehicle_info_plugin/mock_custom_vehicle_data_manager.h"
+#include "vehicle_info_plugin/vehicle_info_command_factory.h"
namespace test {
namespace components {
@@ -55,7 +57,7 @@ using vehicle_info_plugin::commands::UnsubscribeVehicleDataResponse;
namespace am = ::application_manager;
class UnsubscribeVehicleResponseTest
- : public CommandsTest<CommandsTestMocks::kIsNice> {};
+ : public VICommandsTest<CommandsTestMocks::kIsNice> {};
MATCHER_P(ResultCodeIs, result_code, "") {
return result_code ==
@@ -70,7 +72,7 @@ TEST_F(UnsubscribeVehicleResponseTest,
(*command_msg)[am::strings::msg_params][am::strings::success] = false;
std::shared_ptr<UnsubscribeVehicleDataResponse> command =
- CreateCommand<UnsubscribeVehicleDataResponse>(command_msg);
+ CreateCommandVI<UnsubscribeVehicleDataResponse>(command_msg);
EXPECT_CALL(
mock_rpc_service_,
@@ -84,7 +86,7 @@ TEST_F(UnsubscribeVehicleResponseTest,
std::make_shared<SmartObject>(smart_objects::SmartType_Map);
(*command_msg)[am::strings::msg_params][am::strings::success] = true;
std::shared_ptr<UnsubscribeVehicleDataResponse> command =
- CreateCommand<UnsubscribeVehicleDataResponse>(command_msg);
+ CreateCommandVI<UnsubscribeVehicleDataResponse>(command_msg);
EXPECT_CALL(
mock_rpc_service_,
@@ -102,7 +104,7 @@ TEST_F(UnsubscribeVehicleResponseTest,
(*command_msg)[am::strings::msg_params][am::strings::result_code] =
result_type;
std::shared_ptr<UnsubscribeVehicleDataResponse> command =
- CreateCommand<UnsubscribeVehicleDataResponse>(command_msg);
+ CreateCommandVI<UnsubscribeVehicleDataResponse>(command_msg);
command->Run();
}
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/custom_vehicle_data_manager_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/custom_vehicle_data_manager_test.cc
new file mode 100644
index 0000000000..2ef2d285ab
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/custom_vehicle_data_manager_test.cc
@@ -0,0 +1,316 @@
+/*
+ * Copyright (c) 2018, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE. */
+
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/mock_rpc_service.h"
+#include "application_manager/policies/mock_custom_vehicle_data_provider.h"
+#include "gtest/gtest.h"
+#include "test/application_manager/mock_application_manager.h"
+#include "vehicle_info_plugin/custom_vehicle_data_manager_impl.h"
+
+namespace vehicle_info_plugin_test {
+
+using ::testing::NiceMock;
+using ::testing::Return;
+using ::testing::ReturnRef;
+
+using application_manager::MockMessageHelper;
+namespace {
+std::string kName = "rpm";
+std::string kKey = "VD_RPM";
+} // namespace
+class CustomVehicleDataManagerTest : public ::testing::Test {
+ public:
+ CustomVehicleDataManagerTest()
+ : mock_message_helper_(
+ *application_manager::MockMessageHelper::message_helper_mock()) {}
+
+ void SetUp() OVERRIDE {}
+
+ void InitValidationManager(const policy_table::VehicleDataItems& items) {
+ using vehicle_info_plugin::CustomVehicleDataManagerImpl;
+
+ ON_CALL(mock_custom_vehicle_data_provider_, GetVehicleDataItems())
+ .WillByDefault(Return(items));
+ custom_vd_manager_.reset(new CustomVehicleDataManagerImpl(
+ mock_custom_vehicle_data_provider_, mock_rpc_service_));
+ }
+
+ test::components::application_manager_test::MockApplicationManager
+ app_manager_mock_;
+ std::unique_ptr<vehicle_info_plugin::CustomVehicleDataManager>
+ custom_vd_manager_;
+ NiceMock<test::components::policy_test::MockCustomVehicleDataProvider>
+ mock_custom_vehicle_data_provider_;
+ NiceMock<test::components::application_manager_test::MockRPCService>
+ mock_rpc_service_;
+ MockMessageHelper& mock_message_helper_;
+};
+
+TEST_F(CustomVehicleDataManagerTest, CreateHMIMessageParamsEmptyItems) {
+ policy_table::VehicleDataItems schema_items;
+ InitValidationManager(schema_items);
+ const std::set<std::string> items;
+ const auto msg_params = custom_vd_manager_->CreateHMIMessageParams(items);
+ EXPECT_EQ(msg_params.getType(), smart_objects::SmartType_Map);
+ EXPECT_TRUE(msg_params.empty());
+}
+
+TEST_F(CustomVehicleDataManagerTest, CreateHMIMessageParamsOnePODItem) {
+ policy_table::VehicleDataItem rpm;
+ rpm.mark_initialized();
+ rpm.name = kName;
+ rpm.type = "Integer";
+ rpm.key = "OEM_REF_RPM";
+ rpm.mandatory = false;
+ *rpm.array = false;
+ rpm.params->mark_initialized();
+
+ policy_table::VehicleDataItems schema_items;
+ schema_items.push_back(rpm);
+ InitValidationManager(schema_items);
+
+ const std::set<std::string> items = {kName};
+ const auto msg_params = custom_vd_manager_->CreateHMIMessageParams(items);
+ EXPECT_EQ(msg_params.getType(), smart_objects::SmartType_Map);
+ EXPECT_EQ(msg_params.length(), 1u);
+ EXPECT_TRUE(msg_params.keyExists("OEM_REF_RPM"));
+ auto key_value = msg_params["OEM_REF_RPM"];
+ EXPECT_TRUE(key_value.asBool());
+}
+
+TEST_F(CustomVehicleDataManagerTest, CreateHMIMessageParamsSeveralPODItems) {
+ policy_table::VehicleDataItem rpm;
+ rpm.mark_initialized();
+ rpm.name = kName;
+ rpm.type = "Integer";
+ rpm.key = "OEM_REF_RPM";
+ rpm.mandatory = false;
+ *rpm.array = false;
+ rpm.params->mark_initialized();
+
+ policy_table::VehicleDataItem speed;
+ speed.mark_initialized();
+ speed.name = "speed";
+ speed.type = "float";
+ speed.key = "OEM_REF_SPEED";
+ speed.mandatory = false;
+ *speed.array = false;
+ speed.params->mark_initialized();
+
+ policy_table::VehicleDataItems schema_items;
+ schema_items.push_back(rpm);
+ schema_items.push_back(speed);
+ InitValidationManager(schema_items);
+
+ const std::set<std::string> items = {kName, "speed"};
+
+ const auto msg_params = custom_vd_manager_->CreateHMIMessageParams(items);
+ EXPECT_EQ(msg_params.getType(), smart_objects::SmartType_Map);
+ EXPECT_EQ(msg_params.length(), 2u);
+
+ EXPECT_TRUE(msg_params.keyExists("OEM_REF_RPM"));
+ auto rpm_key_value = msg_params["OEM_REF_RPM"];
+ EXPECT_TRUE(rpm_key_value.asBool());
+
+ EXPECT_TRUE(msg_params.keyExists("OEM_REF_SPEED"));
+ auto speed_key_value = msg_params["OEM_REF_SPEED"];
+ EXPECT_TRUE(speed_key_value.asBool());
+}
+
+TEST_F(CustomVehicleDataManagerTest,
+ CreateHMIMessageParamsSchemaWithSeveralItemsRequestWithOneItem) {
+ policy_table::VehicleDataItem rpm;
+ rpm.mark_initialized();
+ rpm.name = kName;
+ rpm.type = "Integer";
+ rpm.key = "OEM_REF_RPM";
+ rpm.mandatory = false;
+ *rpm.array = false;
+ rpm.params->mark_initialized();
+
+ policy_table::VehicleDataItem speed;
+ speed.mark_initialized();
+ speed.name = "speed";
+ speed.type = "float";
+ speed.key = "OEM_REF_SPEED";
+ speed.mandatory = false;
+ *speed.array = false;
+ speed.params->mark_initialized();
+
+ policy_table::VehicleDataItems schema_items;
+ schema_items.push_back(rpm);
+ schema_items.push_back(speed);
+ InitValidationManager(schema_items);
+
+ const std::set<std::string> items = {kName};
+
+ const auto msg_params = custom_vd_manager_->CreateHMIMessageParams(items);
+ EXPECT_EQ(msg_params.getType(), smart_objects::SmartType_Map);
+ EXPECT_EQ(msg_params.length(), 1u);
+
+ EXPECT_TRUE(msg_params.keyExists("OEM_REF_RPM"));
+ auto rpm_key_value = msg_params["OEM_REF_RPM"];
+ EXPECT_TRUE(rpm_key_value.asBool());
+}
+
+TEST_F(CustomVehicleDataManagerTest, CreateHMIMessageParamsStructType) {
+ policy_table::VehicleDataItem alss;
+ alss.mark_initialized();
+ alss.name = "ambientLightSensorStatus";
+ alss.type = "AmbientLightStatus";
+ alss.key = "OEM_REF_AMB_LIGHT";
+ alss.mandatory = false;
+ alss.params->mark_initialized();
+
+ policy_table::VehicleDataItem lss;
+ lss.mark_initialized();
+ lss.name = "LightSensorStatus";
+ lss.type = "Struct";
+ lss.key = "OEM_REF_SEN_LIGHT";
+ lss.mandatory = false;
+ lss.params->mark_initialized();
+ lss.params->push_back(alss);
+
+ policy_table::VehicleDataItem hbo;
+ hbo.mark_initialized();
+ hbo.name = "highBeamsOn";
+ hbo.type = "Boolean";
+ hbo.key = "OEM_REF_HIGH_BEAM";
+ hbo.mandatory = true;
+ hbo.params->mark_initialized();
+
+ policy_table::VehicleDataItem lbo;
+ lbo.mark_initialized();
+ lbo.name = "lowBeamsOn";
+ lbo.type = "Boolean";
+ lbo.key = "OEM_REF_LOW_BEAM";
+ lbo.mandatory = false;
+ lbo.params->mark_initialized();
+
+ policy_table::VehicleDataItem hls;
+ hls.mark_initialized();
+ hls.name = "headLampStatus";
+ hls.type = "Struct";
+ hls.key = "OEM_REF_HLSTATUS";
+ hls.mandatory = false;
+ hls.params->mark_initialized();
+ hls.params->push_back(lss);
+ hls.params->push_back(lbo);
+ hls.params->push_back(hbo);
+
+ policy_table::VehicleDataItems schema_items;
+ schema_items.push_back(hls);
+ InitValidationManager(schema_items);
+
+ const std::set<std::string> items = {"headLampStatus"};
+
+ const auto msg_params = custom_vd_manager_->CreateHMIMessageParams(items);
+ EXPECT_EQ(msg_params.getType(), smart_objects::SmartType_Map);
+ EXPECT_EQ(msg_params.length(), 1u);
+
+ EXPECT_TRUE(msg_params.keyExists("OEM_REF_HLSTATUS"));
+ const auto head_lamp_status = msg_params["OEM_REF_HLSTATUS"];
+ EXPECT_EQ(head_lamp_status.getType(), smart_objects::SmartType_Map);
+
+ EXPECT_EQ(head_lamp_status.length(), 3u);
+
+ EXPECT_TRUE(head_lamp_status.keyExists("OEM_REF_HIGH_BEAM"));
+ EXPECT_TRUE(head_lamp_status.keyExists("OEM_REF_LOW_BEAM"));
+ EXPECT_TRUE(head_lamp_status.keyExists("OEM_REF_SEN_LIGHT"));
+
+ EXPECT_TRUE(head_lamp_status["OEM_REF_HIGH_BEAM"].asBool());
+ EXPECT_TRUE(head_lamp_status["OEM_REF_LOW_BEAM"].asBool());
+ auto light_sensor_status = head_lamp_status["OEM_REF_SEN_LIGHT"];
+
+ EXPECT_EQ(light_sensor_status.length(), 1u);
+ EXPECT_TRUE(light_sensor_status.keyExists("OEM_REF_AMB_LIGHT"));
+ EXPECT_TRUE(light_sensor_status["OEM_REF_AMB_LIGHT"].asBool());
+}
+
+TEST_F(CustomVehicleDataManagerTest, CreateHMIMessageParamsNoSchemaForItem) {
+ policy_table::VehicleDataItems schema_items;
+ InitValidationManager(schema_items);
+
+ const std::set<std::string> items = {kName};
+
+ const auto msg_params = custom_vd_manager_->CreateHMIMessageParams(items);
+ EXPECT_EQ(msg_params.getType(), smart_objects::SmartType_Map);
+ EXPECT_TRUE(msg_params.empty());
+}
+
+TEST_F(CustomVehicleDataManagerTest, CreateMobileMessageParamsStruct) {
+ const application_manager::VehicleData kEmptyVehicleData;
+ ON_CALL(mock_message_helper_, vehicle_data())
+ .WillByDefault(ReturnRef(kEmptyVehicleData));
+
+ policy_table::VehicleDataItems schema_items;
+
+ policy_table::VehicleDataItem custom_vd_item11_struct;
+ custom_vd_item11_struct.mark_initialized();
+ custom_vd_item11_struct.name = "custom_vd_item11_struct";
+ custom_vd_item11_struct.type = "Struct";
+ custom_vd_item11_struct.key = "OEM_REF_STRUCT";
+ custom_vd_item11_struct.mandatory = false;
+ custom_vd_item11_struct.params->mark_initialized();
+
+ policy_table::VehicleDataItem struct_element_1_int;
+ struct_element_1_int.mark_initialized();
+ struct_element_1_int.name = "struct_element_1_int";
+ struct_element_1_int.type = "Integer";
+ struct_element_1_int.key = "OEM_REF_STRUCT_1_INT";
+ struct_element_1_int.mandatory = false;
+ struct_element_1_int.params->mark_initialized();
+ custom_vd_item11_struct.params->push_back(struct_element_1_int);
+ schema_items.push_back(custom_vd_item11_struct);
+ InitValidationManager(schema_items);
+
+ smart_objects::SmartObject msg_params(smart_objects::SmartType_Map);
+ msg_params["OEM_REF_STRUCT"] =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ auto& oem_ref_struct = msg_params["OEM_REF_STRUCT"];
+ oem_ref_struct["OEM_REF_STRUCT_1_INT"] = 100;
+ custom_vd_manager_->CreateMobileMessageParams(msg_params);
+
+ EXPECT_EQ(msg_params.getType(), smart_objects::SmartType_Map);
+ EXPECT_TRUE(msg_params.keyExists("custom_vd_item11_struct"));
+
+ auto& mobile_response_vd_item_11 = msg_params["custom_vd_item11_struct"];
+ EXPECT_EQ(mobile_response_vd_item_11.getType(), smart_objects::SmartType_Map);
+ EXPECT_TRUE(mobile_response_vd_item_11.keyExists("struct_element_1_int"));
+
+ auto& mobile_response_element1 =
+ mobile_response_vd_item_11["struct_element_1_int"];
+ EXPECT_EQ(mobile_response_element1.getType(),
+ smart_objects::SmartType_Integer);
+ EXPECT_EQ(mobile_response_element1.asInt(), 100);
+}
+} // namespace vehicle_info_plugin_test
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/commands/vi_command_request_test.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/commands/vi_command_request_test.h
new file mode 100644
index 0000000000..a6eac01e1c
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/commands/vi_command_request_test.h
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2019, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_TEST_INCLUDE_VIHICLE_INFO_PLUGIN_COMMANDS_VI_COMMAND_REQUEST_TEST_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_TEST_INCLUDE_VIHICLE_INFO_PLUGIN_COMMANDS_VI_COMMAND_REQUEST_TEST_H_
+
+#include <stdint.h>
+
+#include "gtest/gtest.h"
+
+#include "application_manager/commands/command_request_impl.h"
+#include "application_manager/commands/command_request_test.h"
+#include "application_manager/event_engine/event.h"
+#include "application_manager/smart_object_keys.h"
+#include "smart_objects/smart_object.h"
+#include "vehicle_info_plugin/mock_custom_vehicle_data_manager.h"
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+
+using ::test::components::event_engine_test::MockEventDispatcher;
+using ::testing::NiceMock;
+using ::testing::Return;
+using ::testing::SaveArg;
+namespace am = ::application_manager;
+using am::commands::Command;
+using am::commands::CommandRequestImpl;
+using am::event_engine::Event;
+
+template <const CommandsTestMocks kIsNice = CommandsTestMocks::kNotNice>
+class VICommandRequestTest : public CommandRequestTest<kIsNice> {
+ public:
+ enum { kDefaultTimeout_ = 100 };
+
+ template <class Command>
+ std::shared_ptr<Command> CreateCommandVI() {
+ auto msg = CommandsTest<kIsNice>::CreateMessage();
+ return CreateCommandVI<Command>(msg);
+ }
+
+ template <class Command>
+ std::shared_ptr<Command> CreateCommandVI(MessageSharedPtr& msg) {
+ InitCommandVI(kDefaultTimeout_);
+ vehicle_info_plugin::VehicleInfoCommandParams params = {
+ CommandsTest<kIsNice>::app_mngr_,
+ CommandsTest<kIsNice>::mock_rpc_service_,
+ CommandsTest<kIsNice>::mock_hmi_capabilities_,
+ CommandsTest<kIsNice>::mock_policy_handler_,
+ mock_custom_vehicle_data_manager_};
+ return std::make_shared<Command>(msg, params);
+ }
+
+ testing::NiceMock<vehicle_info_plugin::MockCustomVehicleDataManager>
+ mock_custom_vehicle_data_manager_;
+
+ protected:
+ VICommandRequestTest() : CommandRequestTest<kIsNice>() {}
+
+ void InitCommandVI(const uint32_t& timeout) {
+ CommandRequestTest<kIsNice>::InitCommand(kDefaultTimeout_);
+ }
+};
+
+} // namespace commands_test
+} // namespace components
+} // namespace test
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_TEST_INCLUDE_VIHICLE_INFO_PLUGIN_COMMANDS_VI_COMMAND_REQUEST_TEST_H_
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/commands/vi_commands_test.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/commands/vi_commands_test.h
new file mode 100644
index 0000000000..ae25acea87
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/commands/vi_commands_test.h
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2019, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_TEST_INCLUDE_VI_COMMAND_TEST_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_TEST_INCLUDE_VI_COMMAND_TEST_H_
+
+#include <stdint.h>
+#include "gtest/gtest.h"
+
+#include "application_manager/commands/command.h"
+#include "smart_objects/smart_object.h"
+
+#include "application_manager/commands/commands_test.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/mock_application_manager_settings.h"
+#include "application_manager/mock_hmi_interface.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/policies/mock_policy_handler_interface.h"
+#include "vehicle_info_plugin/mock_custom_vehicle_data_manager.h"
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+
+namespace am = ::application_manager;
+
+using ::testing::_;
+using ::testing::Mock;
+using ::testing::NiceMock;
+using ::testing::Return;
+using ::testing::ReturnRef;
+
+using am::commands::MessageSharedPtr;
+using ::smart_objects::SmartObject;
+
+template <const CommandsTestMocks kIsNice = CommandsTestMocks::kNotNice>
+class VICommandsTest : public CommandsTest<kIsNice> {
+ public:
+ enum { kDefaultTimeout_ = 100 };
+
+ template <class Command>
+ std::shared_ptr<Command> CreateCommandVI() {
+ auto msg = CommandsTest<kIsNice>::CreateMessage();
+ return CreateCommandVI<Command>(msg);
+ }
+
+ template <class Command>
+ std::shared_ptr<Command> CreateCommandVI(MessageSharedPtr& msg) {
+ InitCommandVI(kDefaultTimeout_);
+ vehicle_info_plugin::VehicleInfoCommandParams params = {
+ CommandsTest<kIsNice>::app_mngr_,
+ CommandsTest<kIsNice>::mock_rpc_service_,
+ CommandsTest<kIsNice>::mock_hmi_capabilities_,
+ CommandsTest<kIsNice>::mock_policy_handler_,
+ mock_custom_vehicle_data_manager_};
+ return std::make_shared<Command>(msg, params);
+ }
+
+ testing::NiceMock<vehicle_info_plugin::MockCustomVehicleDataManager>
+ mock_custom_vehicle_data_manager_;
+
+ protected:
+ void InitCommandVI(const uint32_t& timeout) {
+ ON_CALL(CommandsTest<kIsNice>::app_mngr_, get_settings())
+ .WillByDefault(ReturnRef(CommandsTest<kIsNice>::app_mngr_settings_));
+ ON_CALL(CommandsTest<kIsNice>::app_mngr_settings_, default_timeout())
+ .WillByDefault(ReturnRef(timeout));
+ }
+};
+} // namespace commands_test
+} // namespace components
+} // namespace test
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_TEST_INCLUDE_VI_COMMAND_TEST_H_
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/mock_custom_vehicle_data_manager.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/mock_custom_vehicle_data_manager.h
new file mode 100644
index 0000000000..df7ecc8904
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/mock_custom_vehicle_data_manager.h
@@ -0,0 +1,22 @@
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_TEST_INCLUDE_VEHICLE_INFO_PLUGIN_MOCK_CUSTOM_VEHICLE_DATA_MANAGER_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_TEST_INCLUDE_VEHICLE_INFO_PLUGIN_MOCK_CUSTOM_VEHICLE_DATA_MANAGER_H_
+
+#include "gmock/gmock.h"
+#include "vehicle_info_plugin/custom_vehicle_data_manager.h"
+
+namespace vehicle_info_plugin {
+namespace plugin_manager = application_manager::plugin_manager;
+class MockCustomVehicleDataManager : public CustomVehicleDataManager {
+ public:
+ MOCK_METHOD1(
+ CreateHMIMessageParams,
+ smart_objects::SmartObject(const std::set<std::string>& msg_params));
+ MOCK_METHOD1(CreateMobileMessageParams,
+ void(smart_objects::SmartObject& msg_params));
+ MOCK_CONST_METHOD1(GetVehicleDataItemType,
+ std::string(const std::string& vehicle_data_item_name));
+ MOCK_METHOD1(OnPolicyEvent, void(plugin_manager::PolicyEvent policy_event));
+};
+
+} // namespace vehicle_info_plugin
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_TEST_INCLUDE_VEHICLE_INFO_PLUGIN_MOCK_CUSTOM_VEHICLE_DATA_MANAGER_H_
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/vehicle_data_item_schema_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/vehicle_data_item_schema_test.cc
new file mode 100644
index 0000000000..1fcd5a0a60
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/vehicle_data_item_schema_test.cc
@@ -0,0 +1,395 @@
+/*
+ * Copyright (c) 2019, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE. */
+
+#include "vehicle_info_plugin/vehicle_data_item_schema.h"
+#include <limits>
+#include <set>
+#include <type_traits>
+#include "formatters/formatter_json_rpc.h"
+#include "formatters/generic_json_formatter.h"
+#include "gtest/gtest.h"
+#include "interfaces/HMI_API.h"
+#include "smart_objects/smart_object.h"
+
+namespace vehicle_info_plugin_test {
+using namespace vehicle_info_plugin;
+using namespace rpc;
+namespace smart_objects = ns_smart_device_link::ns_smart_objects;
+namespace policy_table = rpc::policy_table_interface_base;
+
+using namespace ns_smart_device_link::ns_json_handler::strings;
+using namespace hmi_apis;
+
+using ::testing::NiceMock;
+using ::testing::Return;
+using ::testing::ReturnRef;
+
+using application_manager::MockMessageHelper;
+using ErrorCode = smart_objects::errors::eType;
+
+namespace {
+const int kInvalidValue = std::numeric_limits<int32_t>::max();
+const int kDefaultInteger = 20;
+const double kDefaultFloat = 10.05;
+const bool kDefaultBoolean = true;
+const std::string kDefaultString = "string value";
+const std::string kVehicleDataKey = "key";
+} // namespace
+
+typedef Common_ComponentVolumeStatus::eType TestEnumType;
+
+class VehicleDataItemSchemaTest : public ::testing::Test {
+ public:
+ /*
+ * @brief
+ * Specifies whether user wants to generate valid value of SmartObject or not.
+ */
+ enum class SetValidItemValue { NO = 0, YES = 1 };
+
+ /*
+ * @brief
+ * VehicleDataTestObject struct combines schema and data structures for test
+ * object.
+ */
+ struct VehicleDataTestObject {
+ VehicleDataTestObject(const int& key_number) {
+ schema.mark_initialized();
+ schema.params->mark_initialized();
+ schema.mandatory = true;
+ *schema.array = false;
+ // default value bounds
+ *schema.minvalue = 10;
+ *schema.maxvalue = 100;
+ // default string length
+ *schema.minlength = 5;
+ *schema.maxlength = 30;
+ // default array length
+ *schema.minsize = 5;
+ *schema.maxsize = 30;
+ // generate schema unique key
+ schema.key = kVehicleDataKey + std::to_string(key_number);
+ }
+
+ policy_table::VehicleDataItem schema;
+ smart_objects::SmartObject data;
+ };
+
+ public:
+ VehicleDataItemSchemaTest() : key_number_(1) {
+ test_enum_.insert(TestEnumType::CVS_UNKNOWN);
+ test_enum_.insert(TestEnumType::CVS_NORMAL);
+ test_enum_.insert(TestEnumType::CVS_LOW);
+ test_enum_.insert(TestEnumType::CVS_FAULT);
+ test_enum_.insert(TestEnumType::CVS_ALERT);
+ test_enum_.insert(TestEnumType::CVS_NOT_SUPPORTED);
+ }
+
+ void assertSmartObjectSize(const size_t& expected_size,
+ const size_t& actual_size) {
+ ASSERT_EQ(expected_size, actual_size);
+ }
+
+ std::vector<VehicleDataTestObject> generatePODObjects(
+ const SetValidItemValue& set_valid_item) {
+ std::vector<VehicleDataTestObject> generated_objects;
+ VehicleDataTestObject custom_object(key_number_++);
+
+ // Integer item
+ custom_object.schema.type = policy_table::VehicleDataItem::kInteger;
+ if (set_valid_item == SetValidItemValue::YES) {
+ custom_object.data = kDefaultInteger;
+ } else {
+ custom_object.data = kInvalidValue;
+ }
+ generated_objects.push_back(custom_object);
+
+ // Float item
+ custom_object.schema.type = policy_table::VehicleDataItem::kFloat;
+ if (set_valid_item == SetValidItemValue::YES) {
+ custom_object.data = kDefaultFloat;
+ } else {
+ custom_object.data = kInvalidValue;
+ }
+ generated_objects.push_back(custom_object);
+
+ // String item
+ custom_object.schema.type = policy_table::VehicleDataItem::kString;
+ if (set_valid_item == SetValidItemValue::YES) {
+ custom_object.data = kDefaultString;
+ } else {
+ custom_object.data = kInvalidValue;
+ }
+ generated_objects.push_back(custom_object);
+
+ // Boolean item
+ custom_object.schema.type = policy_table::VehicleDataItem::kBoolean;
+ if (set_valid_item == SetValidItemValue::YES) {
+ custom_object.data = kDefaultBoolean;
+ } else {
+ custom_object.data = kInvalidValue;
+ }
+ generated_objects.push_back(custom_object);
+
+ return generated_objects;
+ }
+
+ VehicleDataTestObject generateTestObject(
+ const SetValidItemValue& set_valid_item) {
+ // Enum parameter
+ VehicleDataTestObject enum_object(key_number_++);
+ enum_object.schema.type = "ComponentVolumeStatus";
+ enum_object.data = (set_valid_item == SetValidItemValue::YES)
+ ? TestEnumType::CVS_LOW
+ : kInvalidValue;
+
+ // Integer parameter
+ VehicleDataTestObject int_object(key_number_++);
+ int_object.schema.type = policy_table::VehicleDataItem::kInteger;
+ int_object.data = (set_valid_item == SetValidItemValue::YES)
+ ? kDefaultInteger
+ : kInvalidValue;
+
+ // Main object
+ VehicleDataTestObject main_object(key_number_++);
+ main_object.schema.type = policy_table::VehicleDataItem::kStruct;
+ *main_object.schema.params = std::vector<policy_table::VehicleDataItem>{
+ enum_object.schema, int_object.schema};
+ main_object.data[enum_object.schema.key] = enum_object.data;
+ main_object.data[int_object.schema.key] = int_object.data;
+
+ assertSmartObjectSize(2u, main_object.data.length());
+ return main_object;
+ }
+
+ VehicleDataTestObject generateRecursiveTestObject(
+ const SetValidItemValue& set_valid_item) {
+ // Float item
+ VehicleDataTestObject float_object(key_number_++);
+ float_object.schema.type = policy_table::VehicleDataItem::kFloat;
+ if (set_valid_item == SetValidItemValue::YES) {
+ float_object.data = kDefaultFloat;
+ } else {
+ float_object.data = kInvalidValue;
+ }
+
+ // String item
+ VehicleDataTestObject string_object(key_number_++);
+ string_object.schema.type = policy_table::VehicleDataItem::kString;
+ if (set_valid_item == SetValidItemValue::YES) {
+ string_object.data = kDefaultString;
+ } else {
+ string_object.data = kInvalidValue;
+ }
+
+ // Sub Object
+ VehicleDataTestObject sub_object = generateTestObject(set_valid_item);
+
+ // Main Object
+ VehicleDataTestObject main_object(key_number_++);
+ main_object.schema.type = policy_table::VehicleDataItem::kStruct;
+ *main_object.schema.params = std::vector<policy_table::VehicleDataItem>{
+ float_object.schema, string_object.schema, sub_object.schema};
+ main_object.data[float_object.schema.key] = float_object.data;
+ main_object.data[string_object.schema.key] = string_object.data;
+ main_object.data[sub_object.schema.key] = sub_object.data;
+
+ assertSmartObjectSize(3u, main_object.data.length());
+ return main_object;
+ }
+
+ protected:
+ std::set<TestEnumType> test_enum_;
+ int key_number_;
+};
+
+TEST_F(VehicleDataItemSchemaTest, ValidatePOD_SUCCESS) {
+ rpc::ValidationReport report("RPC");
+ auto valid_pod_objects = generatePODObjects(SetValidItemValue::YES);
+
+ for (auto& object : valid_pod_objects) {
+ auto test_param = PolicyDataItem(object.schema);
+ auto result = VehicleDataItemSchema::create(
+ test_param, VehicleDataItemSchema::SchemaType::HMI);
+ EXPECT_EQ(ErrorCode::OK, result->validate(object.data, &report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
+ }
+}
+
+TEST_F(VehicleDataItemSchemaTest, ValidatePOD_FAIL) {
+ rpc::ValidationReport report("RPC");
+ std::vector<VehicleDataTestObject> valid_pod_objects =
+ generatePODObjects(SetValidItemValue::NO);
+
+ for (auto& object : valid_pod_objects) {
+ auto test_param = PolicyDataItem(object.schema);
+ auto result = VehicleDataItemSchema::create(
+ test_param, VehicleDataItemSchema::SchemaType::MOBILE);
+ EXPECT_NE(ErrorCode::OK, result->validate(object.data, &report));
+ EXPECT_NE(std::string(""), rpc::PrettyFormat(report));
+ }
+}
+
+TEST_F(VehicleDataItemSchemaTest, ValidateEnum_SUCCESS) {
+ rpc::ValidationReport report("RPC");
+
+ VehicleDataTestObject test_enum_object(key_number_++);
+ test_enum_object.schema.type = "ComponentVolumeStatus";
+ test_enum_object.data = TestEnumType::CVS_NORMAL;
+
+ auto test_schema = PolicyDataItem(test_enum_object.schema);
+
+ for (auto& enum_value : test_enum_) {
+ test_enum_object.data = enum_value;
+ auto result = VehicleDataItemSchema::create(
+ test_schema, VehicleDataItemSchema::SchemaType::HMI);
+ EXPECT_EQ(ErrorCode::OK, result->validate(test_enum_object.data, &report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
+ }
+}
+
+TEST_F(VehicleDataItemSchemaTest, ValidateEnum_FAIL) {
+ rpc::ValidationReport report("RPC");
+
+ VehicleDataTestObject test_enum_object(key_number_++);
+ test_enum_object.schema.type = "ComponentVolumeStatus";
+ test_enum_object.data = kInvalidValue;
+
+ auto test_schema = PolicyDataItem(test_enum_object.schema);
+ auto result = VehicleDataItemSchema::create(
+ test_schema, VehicleDataItemSchema::SchemaType::HMI);
+ EXPECT_EQ(ErrorCode::OUT_OF_RANGE,
+ result->validate(test_enum_object.data, &report));
+ EXPECT_NE(std::string(""), rpc::PrettyFormat(report));
+}
+
+TEST_F(VehicleDataItemSchemaTest, ValidateObject_SUCCESS) {
+ rpc::ValidationReport report("RPC");
+ VehicleDataTestObject complex_object =
+ generateTestObject(SetValidItemValue::YES);
+ auto test_schema = PolicyDataItem(complex_object.schema);
+ auto result = VehicleDataItemSchema::create(
+ test_schema, VehicleDataItemSchema::SchemaType::HMI);
+ EXPECT_EQ(ErrorCode::OK, result->validate(complex_object.data, &report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
+}
+
+TEST_F(VehicleDataItemSchemaTest, ValidateObject_FAIL) {
+ rpc::ValidationReport report("RPC");
+ VehicleDataTestObject complex_object =
+ generateTestObject(SetValidItemValue::NO);
+ auto test_schema = PolicyDataItem(complex_object.schema);
+ auto result = VehicleDataItemSchema::create(
+ test_schema, VehicleDataItemSchema::SchemaType::HMI);
+ EXPECT_NE(ErrorCode::OK, result->validate(complex_object.data, &report));
+ EXPECT_NE(std::string(""), rpc::PrettyFormat(report));
+}
+
+TEST_F(VehicleDataItemSchemaTest, ValidateRecursiveObject_SUCCESS) {
+ rpc::ValidationReport report("RPC");
+ VehicleDataTestObject complex_recursive_object =
+ generateRecursiveTestObject(SetValidItemValue::YES);
+ auto test_schema = PolicyDataItem(complex_recursive_object.schema);
+ auto result = VehicleDataItemSchema::create(
+ test_schema, VehicleDataItemSchema::SchemaType::HMI);
+ EXPECT_EQ(ErrorCode::OK,
+ result->validate(complex_recursive_object.data, &report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
+}
+
+TEST_F(VehicleDataItemSchemaTest, ValidateRecursiveObject_FAIL) {
+ rpc::ValidationReport report("RPC");
+ VehicleDataTestObject complex_recursive_object =
+ generateRecursiveTestObject(SetValidItemValue::NO);
+ auto test_schema = PolicyDataItem(complex_recursive_object.schema);
+ auto result = VehicleDataItemSchema::create(
+ test_schema, VehicleDataItemSchema::SchemaType::HMI);
+ EXPECT_NE(ErrorCode::OK,
+ result->validate(complex_recursive_object.data, &report));
+ EXPECT_NE(std::string(""), rpc::PrettyFormat(report));
+}
+
+TEST_F(VehicleDataItemSchemaTest, ValidateArray_SUCCESS) {
+ rpc::ValidationReport report("RPC");
+ VehicleDataTestObject array_object(key_number_++);
+ *array_object.schema.array = true;
+ array_object.schema.type = policy_table::VehicleDataItem::kInteger;
+ array_object.data =
+ smart_objects::SmartObject(smart_objects::SmartType_Array);
+ array_object.data.asArray()->push_back(smart_objects::SmartObject(10));
+ array_object.data.asArray()->push_back(smart_objects::SmartObject(20));
+ array_object.data.asArray()->push_back(smart_objects::SmartObject(30));
+ array_object.data.asArray()->push_back(smart_objects::SmartObject(40));
+ array_object.data.asArray()->push_back(smart_objects::SmartObject(50));
+ array_object.data.asArray()->push_back(smart_objects::SmartObject(60));
+ array_object.data.asArray()->push_back(smart_objects::SmartObject(70));
+
+ auto test_schema = PolicyDataItem(array_object.schema);
+ auto result = VehicleDataItemSchema::create(
+ test_schema, VehicleDataItemSchema::SchemaType::HMI);
+ EXPECT_EQ(ErrorCode::OK, result->validate(array_object.data, &report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
+}
+
+TEST_F(VehicleDataItemSchemaTest, ValidateArray_FAIL) {
+ rpc::ValidationReport report("RPC");
+ VehicleDataTestObject array_object(key_number_++);
+ *array_object.schema.array = true;
+ array_object.schema.type = policy_table::VehicleDataItem::kInteger;
+ array_object.data =
+ smart_objects::SmartObject(smart_objects::SmartType_Array);
+ array_object.data.asArray()->push_back(smart_objects::SmartObject(10));
+ array_object.data.asArray()->push_back(smart_objects::SmartObject(20));
+ array_object.data.asArray()->push_back(smart_objects::SmartObject(30));
+
+ auto test_schema = PolicyDataItem(array_object.schema);
+ auto result = VehicleDataItemSchema::create(
+ test_schema, VehicleDataItemSchema::SchemaType::HMI);
+ EXPECT_NE(ErrorCode::OK, result->validate(array_object.data, &report));
+ EXPECT_NE(std::string(""), rpc::PrettyFormat(report));
+}
+
+TEST_F(VehicleDataItemSchemaTest, ValidateUnknownType) {
+ rpc::ValidationReport report("RPC");
+
+ VehicleDataTestObject test_object_with_invalid_type(key_number_++);
+ // Set invalid name of type
+ test_object_with_invalid_type.schema.type = "omponentolumetatus";
+ test_object_with_invalid_type.data = TestEnumType::CVS_NORMAL;
+
+ auto test_schema = PolicyDataItem(test_object_with_invalid_type.schema);
+ auto result = VehicleDataItemSchema::create(
+ test_schema, VehicleDataItemSchema::SchemaType::HMI);
+ EXPECT_EQ(ErrorCode::ERROR,
+ result->validate(test_object_with_invalid_type.data, &report));
+ EXPECT_NE(std::string(""), rpc::PrettyFormat(report));
+}
+
+} // namespace vehicle_info_plugin_test
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index 94e67a0c80..5b5da8ea64 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -208,7 +208,8 @@ ApplicationManagerImpl::ApplicationManagerImpl(
const uint32_t timeout_ms = 10000u;
clearing_timer->Start(timeout_ms, timer::kSingleShot);
timer_pool_.push_back(clearing_timer);
- rpc_handler_.reset(new rpc_handler::RPCHandlerImpl(*this));
+ rpc_handler_.reset(new rpc_handler::RPCHandlerImpl(
+ *this, hmi_so_factory(), mobile_so_factory()));
commands_holder_.reset(new CommandHolderImpl(*this));
std::shared_ptr<RPCProtectionManager> rpc_protection_manager =
std::make_shared<RPCProtectionManagerImpl>(*policy_handler_);
@@ -218,7 +219,9 @@ ApplicationManagerImpl::ApplicationManagerImpl(
protocol_handler_,
hmi_handler_,
*commands_holder_,
- rpc_protection_manager));
+ rpc_protection_manager,
+ hmi_so_factory(),
+ mobile_so_factory()));
}
ApplicationManagerImpl::~ApplicationManagerImpl() {
@@ -400,16 +403,12 @@ struct IsApplication {
connection_handler::DeviceHandle device_handle_;
const std::string& policy_app_id_;
};
-void ApplicationManagerImpl::IviInfoUpdated(
- mobile_apis::VehicleDataType::eType vehicle_info, int value) {
+void ApplicationManagerImpl::IviInfoUpdated(const std::string& vehicle_info,
+ int value) {
// Notify Policy Manager if available about info it's interested in,
// i.e. odometer etc
- switch (vehicle_info) {
- case mobile_apis::VehicleDataType::VEHICLEDATA_ODOMETER:
- GetPolicyHandler().KmsChanged(value);
- break;
- default:
- break;
+ if (strings::odometer == vehicle_info) {
+ GetPolicyHandler().KmsChanged(value);
}
}
@@ -2321,6 +2320,13 @@ bool ApplicationManagerImpl::Init(resumption::LastState& last_state,
app_service_manager_.reset(
new application_manager::AppServiceManager(*this, last_state));
+
+ auto on_app_policy_updated = [](plugin_manager::RPCPlugin& plugin) {
+ plugin.OnPolicyEvent(plugin_manager::kApplicationPolicyUpdated);
+ };
+
+ plugin_manager_->ForEachPlugin(on_app_policy_updated);
+
return true;
}
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 06e0220158..4e321b18b0 100644
--- a/src/components/application_manager/src/commands/command_request_impl.cc
+++ b/src/components/application_manager/src/commands/command_request_impl.cc
@@ -144,19 +144,21 @@ struct DisallowedParamsInserter {
: response_(response), code_(code) {}
bool operator()(const std::string& param) {
- const VehicleData& vehicle_data =
- application_manager::MessageHelper::vehicle_data();
- VehicleData::const_iterator it = vehicle_data.find(param);
- if (vehicle_data.end() != it) {
- smart_objects::SmartObjectSPtr disallowed_param =
- std::make_shared<smart_objects::SmartObject>(
- smart_objects::SmartType_Map);
- (*disallowed_param)[strings::data_type] = (*it).second;
- (*disallowed_param)[strings::result_code] = code_;
- response_[strings::msg_params][param.c_str()] = *disallowed_param;
- return true;
- }
- return false;
+ smart_objects::SmartObjectSPtr disallowed_param =
+ std::make_shared<smart_objects::SmartObject>(
+ smart_objects::SmartType_Map);
+
+ auto rpc_spec_vehicle_data = MessageHelper::vehicle_data();
+ auto vehicle_data = rpc_spec_vehicle_data.find(param);
+ auto vehicle_data_type =
+ vehicle_data == rpc_spec_vehicle_data.end()
+ ? mobile_apis::VehicleDataType::VEHICLEDATA_OEM_CUSTOM_DATA
+ : vehicle_data->second;
+
+ (*disallowed_param)[strings::data_type] = vehicle_data_type;
+ (*disallowed_param)[strings::result_code] = code_;
+ response_[strings::msg_params][param.c_str()] = *disallowed_param;
+ return true;
}
private:
@@ -306,9 +308,9 @@ void CommandRequestImpl::SendResponse(
}
// Add disallowed parameters and info from request back to response with
- // appropriate
- // reasons (VehicleData result codes)
- if (result_code != mobile_apis::Result::APPLICATION_NOT_REGISTERED) {
+ // appropriate reasons (VehicleData result codes)
+ if (result_code != mobile_apis::Result::APPLICATION_NOT_REGISTERED &&
+ result_code != mobile_apis::Result::INVALID_DATA) {
const mobile_apis::FunctionID::eType& id =
static_cast<mobile_apis::FunctionID::eType>(function_id());
if ((id == mobile_apis::FunctionID::SubscribeVehicleDataID) ||
@@ -804,49 +806,28 @@ void CommandRequestImpl::RemoveDisallowedParameters() {
smart_objects::SmartObject& params = (*message_)[strings::msg_params];
- // Remove from request all disallowed parameters
- RPCParams::const_iterator it_disallowed =
- parameters_permissions_.disallowed_params.begin();
- RPCParams::const_iterator it_disallowed_end =
- parameters_permissions_.disallowed_params.end();
- for (; it_disallowed != it_disallowed_end; ++it_disallowed) {
- if (params.keyExists(*it_disallowed)) {
- const std::string key = *it_disallowed;
+ for (const auto& key : params.enumerate()) {
+ if (parameters_permissions_.disallowed_params.end() !=
+ parameters_permissions_.disallowed_params.find(key)) {
+ // Remove from request all disallowed parameters
params.erase(key);
removed_parameters_permissions_.disallowed_params.insert(key);
LOG4CXX_INFO(logger_,
"Following parameter is disallowed by user: " << key);
}
- }
- // Remove from request all undefined yet parameters
- RPCParams::const_iterator it_undefined =
- parameters_permissions_.undefined_params.begin();
- RPCParams::const_iterator it_undefined_end =
- parameters_permissions_.undefined_params.end();
- for (; it_undefined != it_undefined_end; ++it_undefined) {
- if (params.keyExists(*it_undefined)) {
- const std::string key = *it_undefined;
+ else if (removed_parameters_permissions_.undefined_params.end() !=
+ removed_parameters_permissions_.undefined_params.find(key)) {
+ // Remove from request all undefined yet parameters
params.erase(key);
removed_parameters_permissions_.undefined_params.insert(key);
LOG4CXX_INFO(logger_,
"Following parameter is disallowed by policy: " << key);
}
- }
- // Remove from request all parameters missed in allowed
- const VehicleData& vehicle_data =
- application_manager::MessageHelper::vehicle_data();
-
- VehicleData::const_iterator it_vehicle_data = vehicle_data.begin();
- VehicleData::const_iterator it_vehicle_data_end = vehicle_data.end();
- for (; it_vehicle_data != it_vehicle_data_end; ++it_vehicle_data) {
- const std::string key = it_vehicle_data->first;
- if (params.keyExists(key) &&
- parameters_permissions_.allowed_params.end() ==
- std::find(parameters_permissions_.allowed_params.begin(),
- parameters_permissions_.allowed_params.end(),
- key)) {
+ else if (parameters_permissions_.allowed_params.end() ==
+ parameters_permissions_.allowed_params.find(key)) {
+ // Remove from request all parameters missed in allowed
params.erase(key);
removed_parameters_permissions_.undefined_params.insert(key);
LOG4CXX_INFO(logger_,
diff --git a/src/components/application_manager/src/hmi_interfaces_impl.cc b/src/components/application_manager/src/hmi_interfaces_impl.cc
index 64ec2374a9..0e79930e89 100644
--- a/src/components/application_manager/src/hmi_interfaces_impl.cc
+++ b/src/components/application_manager/src/hmi_interfaces_impl.cc
@@ -227,7 +227,6 @@ generate_function_to_interface_convert_map() {
convert_map[SDL_OnStatusUpdate] = HmiInterfaces::HMI_INTERFACE_SDL;
convert_map[SDL_OnSystemError] = HmiInterfaces::HMI_INTERFACE_SDL;
convert_map[SDL_AddStatisticsInfo] = HmiInterfaces::HMI_INTERFACE_SDL;
- convert_map[SDL_GetURLS] = HmiInterfaces::HMI_INTERFACE_SDL;
convert_map[RC_IsReady] = HmiInterfaces::HMI_INTERFACE_RC;
convert_map[RC_GetCapabilities] = HmiInterfaces::HMI_INTERFACE_RC;
convert_map[Buttons_ButtonPress] = HmiInterfaces::HMI_INTERFACE_RC;
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 31eaa54e5d..fb0c9f15bf 100644
--- a/src/components/application_manager/src/message_helper/message_helper.cc
+++ b/src/components/application_manager/src/message_helper/message_helper.cc
@@ -221,6 +221,9 @@ std::pair<std::string, mobile_apis::VehicleDataType::eType>
std::make_pair(
strings::cluster_mode_status,
mobile_apis::VehicleDataType::VEHICLEDATA_CLUSTERMODESTATUS),
+ std::make_pair(
+ strings::cluster_modes,
+ mobile_apis::VehicleDataType::VEHICLEDATA_CLUSTERMODESTATUS),
std::make_pair(strings::my_key,
mobile_apis::VehicleDataType::VEHICLEDATA_MYKEY),
/*
diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc
index c3b4520613..ac428426e6 100644
--- a/src/components/application_manager/src/policies/policy_handler.cc
+++ b/src/components/application_manager/src/policies/policy_handler.cc
@@ -1597,6 +1597,10 @@ DeviceConsent PolicyHandler::GetUserConsentForDevice(
return policy_manager_->GetUserConsentForDevice(device_id);
}
+Json::Value PolicyHandler::GetPolicyTableData() const {
+ return policy_manager_->GetPolicyTableData();
+}
+
bool PolicyHandler::GetDefaultHmi(const std::string& device_id,
const std::string& policy_app_id,
std::string* default_hmi) const {
@@ -2287,9 +2291,10 @@ const std::vector<std::string> PolicyHandler::GetAppRequestSubTypes(
return policy_manager_->GetAppRequestSubTypes(policy_app_id);
}
-const VehicleInfo policy::PolicyHandler::GetVehicleInfo() const {
- POLICY_LIB_CHECK(VehicleInfo());
- return policy_manager_->GetVehicleInfo();
+const std::vector<policy_table::VehicleDataItem>
+policy::PolicyHandler::GetVehicleDataItems() const {
+ POLICY_LIB_CHECK(std::vector<policy_table::VehicleDataItem>());
+ return policy_manager_->GetVehicleDataItems();
}
#ifdef EXTERNAL_PROPRIETARY_MODE
diff --git a/src/components/application_manager/src/rpc_handler_impl.cc b/src/components/application_manager/src/rpc_handler_impl.cc
index e17eaa264e..a2b1245882 100644
--- a/src/components/application_manager/src/rpc_handler_impl.cc
+++ b/src/components/application_manager/src/rpc_handler_impl.cc
@@ -43,12 +43,14 @@ namespace formatters = ns_smart_device_link::ns_json_handler::formatters;
namespace jhs = ns_smart_device_link::ns_json_handler::strings;
namespace plugin_names = application_manager::plugin_manager::plugin_names;
-RPCHandlerImpl::RPCHandlerImpl(ApplicationManager& app_manager)
+RPCHandlerImpl::RPCHandlerImpl(ApplicationManager& app_manager,
+ hmi_apis::HMI_API& hmi_so_factory,
+ mobile_apis::MOBILE_API& mobile_so_factory)
: app_manager_(app_manager)
, messages_from_mobile_("AM FromMobile", this)
, messages_from_hmi_("AM FromHMI", this)
- , hmi_so_factory_(hmi_apis::HMI_API())
- , mobile_so_factory_(mobile_apis::MOBILE_API())
+ , hmi_so_factory_(hmi_so_factory)
+ , mobile_so_factory_(mobile_so_factory)
#ifdef TELEMETRY_MONITOR
, metric_observer_(NULL)
#endif // TELEMETRY_MONITOR
@@ -165,13 +167,13 @@ void RPCHandlerImpl::ProcessMessageFromHMI(
hmi_apis::messageType::eType>(
message->json_message(), converted_result);
+ const auto function_id = static_cast<int32_t>(
+ converted_result[jhs::S_PARAMS][jhs::S_FUNCTION_ID].asInt());
if (app_manager_.GetRPCService().IsAppServiceRPC(
- converted_result[jhs::S_PARAMS][jhs::S_FUNCTION_ID].asInt(),
- commands::Command::SOURCE_HMI)) {
+ function_id, commands::Command::SOURCE_HMI)) {
LOG4CXX_DEBUG(
logger_,
- "Allowing unknown parameters for request function "
- << converted_result[jhs::S_PARAMS][jhs::S_FUNCTION_ID].asInt());
+ "Allowing unknown parameters for request function " << function_id);
allow_unknown_parameters = true;
}
@@ -403,7 +405,7 @@ bool RPCHandlerImpl::ConvertMessageToSO(
"Convertion result: "
<< result << " function id "
<< output[jhs::S_PARAMS][jhs::S_FUNCTION_ID].asInt());
- if (!hmi_so_factory().attachSchema(output, false)) {
+ if (!hmi_so_factory().attachSchema(output, !allow_unknown_parameters)) {
LOG4CXX_WARN(logger_, "Failed to attach schema to object.");
return false;
}
@@ -412,8 +414,9 @@ bool RPCHandlerImpl::ConvertMessageToSO(
utils::SemanticVersion empty_version;
if (validate_params &&
- output.validate(&report, empty_version, allow_unknown_parameters) !=
- smart_objects::errors::OK) {
+ smart_objects::errors::OK !=
+ output.validate(
+ &report, empty_version, allow_unknown_parameters)) {
LOG4CXX_ERROR(
logger_,
"Incorrect parameter from HMI - " << rpc::PrettyFormat(report));
diff --git a/src/components/application_manager/src/rpc_passing_handler.cc b/src/components/application_manager/src/rpc_passing_handler.cc
index 8d63e9489f..7f72632bb1 100644
--- a/src/components/application_manager/src/rpc_passing_handler.cc
+++ b/src/components/application_manager/src/rpc_passing_handler.cc
@@ -40,6 +40,7 @@
#include "application_manager/application_manager.h"
#include "application_manager/commands/command_impl.h"
#include "application_manager/message_helper.h"
+#include "application_manager/policies/policy_handler_interface.h"
#include "application_manager/rpc_handler.h"
#include "application_manager/rpc_passing_handler.h"
#include "application_manager/smart_object_keys.h"
@@ -143,7 +144,7 @@ bool RPCPassingHandler::IsPassthroughAllowed(
rpc_message[strings::params][strings::function_id].asInt());
std::string function_id_str =
MessageHelper::StringifiedFunctionID(function_id);
- PolicyHandlerInterface& policy_handler = app_manager_.GetPolicyHandler();
+ auto& policy_handler = app_manager_.GetPolicyHandler();
if (function_id_str.empty()) {
// Unknown RPC, just do basic revoked and user consent checks
diff --git a/src/components/application_manager/src/rpc_service_impl.cc b/src/components/application_manager/src/rpc_service_impl.cc
index cfd5335a42..9bcb43eae0 100644
--- a/src/components/application_manager/src/rpc_service_impl.cc
+++ b/src/components/application_manager/src/rpc_service_impl.cc
@@ -34,6 +34,8 @@
#include "application_manager/rpc_protection_manager_impl.h"
#include "application_manager/app_service_manager.h"
+#include "application_manager/command_factory.h"
+#include "application_manager/commands/command.h"
#include "application_manager/plugin_manager/plugin_keys.h"
namespace application_manager {
@@ -50,7 +52,9 @@ RPCServiceImpl::RPCServiceImpl(
protocol_handler::ProtocolHandler* protocol_handler,
hmi_message_handler::HMIMessageHandler* hmi_handler,
CommandHolder& commands_holder,
- RPCProtectionManagerSPtr rpc_protection_manager)
+ RPCProtectionManagerSPtr rpc_protection_manager,
+ hmi_apis::HMI_API& hmi_so_factory,
+ mobile_apis::MOBILE_API& mobile_so_factory)
: app_manager_(app_manager)
, request_ctrl_(request_ctrl)
, protocol_handler_(protocol_handler)
@@ -59,8 +63,8 @@ RPCServiceImpl::RPCServiceImpl(
, commands_holder_(commands_holder)
, messages_to_mobile_("AM ToMobile", this)
, messages_to_hmi_("AM ToHMI", this)
- , hmi_so_factory_(hmi_apis::HMI_API())
- , mobile_so_factory_(mobile_apis::MOBILE_API()) {}
+ , hmi_so_factory_(hmi_so_factory)
+ , mobile_so_factory_(mobile_so_factory) {}
RPCServiceImpl::~RPCServiceImpl() {}
@@ -546,10 +550,6 @@ void RPCServiceImpl::SendMessageToMobile(
msg_to_mobile[strings::params][strings::connection_key].asUInt(),
msg_to_mobile[strings::params][strings::function_id].asInt());
} else if (app) {
- mobile_apis::FunctionID::eType function_id =
- static_cast<mobile_apis::FunctionID::eType>(
- (*message)[strings::params][strings::function_id].asUInt());
-
RPCParams params;
const smart_objects::SmartObject& s_map = (*message)[strings::msg_params];
@@ -604,7 +604,6 @@ void RPCServiceImpl::SendMessageToMobile(
void RPCServiceImpl::SendMessageToHMI(
const commands::MessageSharedPtr message) {
LOG4CXX_AUTO_TRACE(logger_);
-
if (!message) {
LOG4CXX_WARN(logger_, "Null-pointer message received.");
NOTREACHED();
@@ -645,7 +644,6 @@ void RPCServiceImpl::SendMessageToHMI(
"Cannot send message to HMI: failed to create string");
return;
}
-
messages_to_hmi_.PostMessage(impl::MessageToHmi(message_to_send));
}
@@ -797,6 +795,28 @@ bool RPCServiceImpl::ConvertSOtoMessage(
return true;
}
+void RPCServiceImpl::UpdateMobileRPCParams(
+ const mobile_apis::FunctionID::eType& function_id,
+ const mobile_apis::messageType::eType& message_type,
+ const std::map<std::string, SMember>& members) {
+ mobile_so_factory().ResetFunctionSchema(function_id, message_type);
+ for (const auto& item : members) {
+ mobile_so_factory().AddCustomMember(
+ function_id, message_type, item.first, item.second);
+ }
+}
+
+void RPCServiceImpl::UpdateHMIRPCParams(
+ const hmi_apis::FunctionID::eType& function_id,
+ const hmi_apis::messageType::eType& message_type,
+ const std::map<std::string, SMember>& members) {
+ hmi_so_factory().ResetFunctionSchema(function_id, message_type);
+ for (const auto& item : members) {
+ hmi_so_factory().AddCustomMember(
+ function_id, message_type, item.first, item.second);
+ }
+}
+
hmi_apis::HMI_API& RPCServiceImpl::hmi_so_factory() {
return hmi_so_factory_;
}
diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc
index e67c87a234..badffe9b39 100644
--- a/src/components/application_manager/src/smart_object_keys.cc
+++ b/src/components/application_manager/src/smart_object_keys.cc
@@ -185,6 +185,8 @@ const char* is_cloud_application = "isCloudApplication";
const char* cloud_connection_status = "cloudConnectionStatus";
const char* endpoint = "endpoint";
const char* display_capabilities = "displayCapabilities";
+const char* policy_type = "policyType";
+const char* property = "property";
// PutFile
const char* sync_file_name = "syncFileName";
@@ -274,6 +276,7 @@ const char* e_call_info = "eCallInfo";
const char* airbag_status = "airbagStatus";
const char* emergency_event = "emergencyEvent";
const char* cluster_mode_status = "clusterModeStatus";
+const char* cluster_modes = "clusterModes";
const char* my_key = "myKey";
const char* help_prompt = "helpPrompt";
const char* scroll_message_body = "scrollableMessageBody";
@@ -293,6 +296,7 @@ const char* sdl_version = "sdlVersion";
const char* system_software_version = "systemSoftwareVersion";
const char* priority = "priority";
const char* engine_oil_life = "engineOilLife";
+const char* oem_custom_data_type = "oemCustomDataType";
// app services
const char* app_service_manifest = "appServiceManifest";
diff --git a/src/components/application_manager/test/CMakeLists.txt b/src/components/application_manager/test/CMakeLists.txt
index 5b7aa80f20..f6146f96f9 100755
--- a/src/components/application_manager/test/CMakeLists.txt
+++ b/src/components/application_manager/test/CMakeLists.txt
@@ -46,6 +46,7 @@ include_directories(
${COMPONENTS_DIR}/security_manager/include/
${COMPONENTS_DIR}/application_manager/test/include/
${COMPONENTS_DIR}/application_manager/rpc_plugins/sdl_rpc_plugin/include/
+ ${COMPONENTS_DIR}/application_manager/rpc_plugins/vehicle_info_plugin/include/
${BSON_INCLUDE_DIRECTORY}
)
diff --git a/src/components/application_manager/test/commands/command_request_impl_test.cc b/src/components/application_manager/test/commands/command_request_impl_test.cc
index 27e21efd8d..86dba1c5ac 100644
--- a/src/components/application_manager/test/commands/command_request_impl_test.cc
+++ b/src/components/application_manager/test/commands/command_request_impl_test.cc
@@ -318,13 +318,6 @@ TEST_F(CommandRequestImplTest, SendHMIRequest_UseEvent_SUCCESS) {
}
TEST_F(CommandRequestImplTest, RemoveDisallowedParameters_SUCCESS) {
- am::VehicleData vehicle_data;
- vehicle_data.insert(am::VehicleData::value_type(
- kMissedParam, mobile_apis::VehicleDataType::VEHICLEDATA_MYKEY));
-
- EXPECT_CALL(mock_message_helper_, vehicle_data())
- .WillOnce(ReturnRef(vehicle_data));
-
MessageSharedPtr msg = CreateMessage();
(*msg)[strings::msg_params][kDisallowedParam1] = 0u;
(*msg)[strings::msg_params][kDisallowedParam2] = 0u;
@@ -333,7 +326,6 @@ TEST_F(CommandRequestImplTest, RemoveDisallowedParameters_SUCCESS) {
(*msg)[strings::msg_params][kMissedParam] = 0u;
CommandPtr command = CreateCommand<UCommandRequestImpl>(msg);
-
CommandParametersPermissions& permission = command->parameters_permissions();
permission.disallowed_params.insert(kDisallowedParam1);
permission.disallowed_params.insert(kDisallowedParam2);
@@ -456,13 +448,13 @@ TEST_F(CommandRequestImplTest, AddDisallowedParameters_SUCCESS) {
vehicle_data.insert(am::VehicleData::value_type(
kDisallowedParam1, mobile_apis::VehicleDataType::VEHICLEDATA_MYKEY));
- EXPECT_CALL(mock_message_helper_, vehicle_data())
- .WillOnce(ReturnRef(vehicle_data));
-
MessageSharedPtr msg;
CommandPtr command = CreateCommand<UCommandRequestImpl>(msg);
+ ON_CALL(mock_message_helper_, vehicle_data())
+ .WillByDefault(ReturnRef(vehicle_data));
+
command->removed_parameters_permissions().disallowed_params.insert(
kDisallowedParam1);
@@ -509,9 +501,6 @@ TEST_F(CommandRequestImplTest,
vehicle_data.insert(am::VehicleData::value_type(
kDisallowedParam1, mobile_apis::VehicleDataType::VEHICLEDATA_MYKEY));
- EXPECT_CALL(mock_message_helper_, vehicle_data())
- .WillOnce(ReturnRef(vehicle_data));
-
MessageSharedPtr msg = CreateMessage();
(*msg)[strings::params][strings::function_id] =
mobile_apis::FunctionID::SubscribeVehicleDataID;
@@ -523,6 +512,9 @@ TEST_F(CommandRequestImplTest,
MessageSharedPtr result;
+ ON_CALL(mock_message_helper_, vehicle_data())
+ .WillByDefault(ReturnRef(vehicle_data));
+
EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _))
.WillOnce(DoAll(SaveArg<0>(&result), Return(true)));
diff --git a/src/components/application_manager/test/include/application_manager/commands/commands_test.h b/src/components/application_manager/test/include/application_manager/commands/commands_test.h
index cd0514a0da..a047de81b9 100644
--- a/src/components/application_manager/test/include/application_manager/commands/commands_test.h
+++ b/src/components/application_manager/test/include/application_manager/commands/commands_test.h
@@ -30,8 +30,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_COMMANDS_TEST_H_
-#define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_COMMANDS_TEST_H_
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMANDS_TEST_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMANDS_TEST_H_
#include <stdint.h>
#include "gtest/gtest.h"
@@ -259,4 +259,4 @@ MATCHER_P3(MobileResponseIs, result_code, result_info, result_success, "") {
} // namespace components
} // namespace test
-#endif // SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_COMMANDS_TEST_H_
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMANDS_TEST_H_
diff --git a/src/components/application_manager/test/policy_handler_test.cc b/src/components/application_manager/test/policy_handler_test.cc
index b7cdf9a4d2..18a1443ba6 100644
--- a/src/components/application_manager/test/policy_handler_test.cc
+++ b/src/components/application_manager/test/policy_handler_test.cc
@@ -1540,16 +1540,6 @@ TEST_F(PolicyHandlerTest, IsRequestSubTypeAllowed) {
EXPECT_TRUE(policy_handler_.IsRequestSubTypeAllowed(kPolicyAppId_, subtype));
}
-TEST_F(PolicyHandlerTest, GetVehicleInfo) {
- // Arrange
- EnablePolicyAndPolicyManagerMock();
- // Check expectations
- EXPECT_CALL(*mock_policy_manager_, GetVehicleInfo())
- .WillOnce(Return(VehicleInfo()));
- // Act
- policy_handler_.GetVehicleInfo();
-}
-
TEST_F(PolicyHandlerTest, Increment_method_WithOneParameter) {
// Arrange
EnablePolicyAndPolicyManagerMock();