summaryrefslogtreecommitdiff
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
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
-rw-r--r--CMakeLists.txt8
-rw-r--r--src/appMain/sdl_preloaded_pt.json2812
-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
-rw-r--r--src/components/formatters/include/formatters/CFormatterJsonBase.h2
-rw-r--r--src/components/formatters/test/meta_formatter_test.cc82
-rw-r--r--src/components/formatters/test/src/SmartFactoryTestHelper.cc213
-rw-r--r--src/components/formatters/test/src/create_smartSchema.cc136
-rw-r--r--src/components/include/application_manager/application_manager.h9
-rw-r--r--src/components/include/application_manager/policies/policy_handler_interface.h10
-rw-r--r--src/components/include/application_manager/rpc_handler.h3
-rw-r--r--src/components/include/application_manager/rpc_service.h16
-rw-r--r--src/components/include/hmi_message_handler/hmi_message_adapter.h2
-rw-r--r--src/components/include/policy/policy_external/policy/policy_manager.h13
-rw-r--r--src/components/include/policy/policy_regular/policy/policy_manager.h12
-rw-r--r--src/components/include/test/application_manager/mock_application_manager.h3
-rw-r--r--src/components/include/test/application_manager/mock_rpc_service.h12
-rw-r--r--src/components/include/test/application_manager/policies/mock_custom_vehicle_data_provider.h21
-rw-r--r--src/components/include/test/application_manager/policies/mock_policy_handler_interface.h5
-rw-r--r--src/components/include/test/policy/policy_external/policy/mock_cache_manager.h4
-rw-r--r--src/components/include/test/policy/policy_external/policy/mock_policy_manager.h4
-rw-r--r--src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h4
-rw-r--r--src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h4
-rw-r--r--src/components/interfaces/HMI_API.xml26
-rw-r--r--src/components/interfaces/MOBILE_API.xml4
-rw-r--r--src/components/media_manager/CMakeLists.txt1
-rw-r--r--src/components/policy/policy_external/CMakeLists.txt66
-rw-r--r--src/components/policy/policy_external/doc/doxygen/components/SmartObjects/Smart Objects Validation/Schema Structure.txt26
-rw-r--r--src/components/policy/policy_external/include/policy/cache_manager.h44
-rw-r--r--src/components/policy/policy_external/include/policy/cache_manager_interface.h12
-rw-r--r--src/components/policy/policy_external/include/policy/policy_helper.h9
-rw-r--r--src/components/policy/policy_external/include/policy/policy_manager_impl.h13
-rw-r--r--src/components/policy/policy_external/include/policy/policy_table/enums.h582
-rw-r--r--src/components/policy/policy_external/include/policy/policy_table/policy_enum_schema_factory.h62
-rw-r--r--src/components/policy/policy_external/include/policy/policy_table/types.h114
-rw-r--r--src/components/policy/policy_external/include/policy/policy_types.h2
-rw-r--r--src/components/policy/policy_external/include/policy/pt_representation.h5
-rw-r--r--src/components/policy/policy_external/include/policy/sql_pt_queries.h15
-rw-r--r--src/components/policy/policy_external/include/policy/sql_pt_representation.h34
-rw-r--r--src/components/policy/policy_external/src/cache_manager.cc109
-rw-r--r--src/components/policy/policy_external/src/policy_helper.cc157
-rw-r--r--src/components/policy/policy_external/src/policy_manager_impl.cc85
-rw-r--r--src/components/policy/policy_external/src/policy_table/enums.cc1439
-rw-r--r--src/components/policy/policy_external/src/policy_table/types.cc498
-rw-r--r--src/components/policy/policy_external/src/policy_table/validation.cc51
-rw-r--r--src/components/policy/policy_external/src/sql_pt_queries.cc131
-rw-r--r--src/components/policy/policy_external/src/sql_pt_representation.cc460
-rw-r--r--src/components/policy/policy_external/test/include/policy/mock_pt_representation.h1
-rw-r--r--src/components/policy/policy_external/test/include/policy/policy_manager_impl_test_base.h2
-rw-r--r--src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc24
-rw-r--r--src/components/policy/policy_external/test/policy_manager_impl_test.cc9
-rw-r--r--src/components/policy/policy_external/test/policy_manager_impl_test_base.cc4
-rw-r--r--src/components/policy/policy_external/test/sql_pt_ext_representation_test.cc18
-rw-r--r--src/components/policy/policy_external/test/sql_pt_representation_test.cc123
-rw-r--r--src/components/policy/policy_regular/CMakeLists.txt71
-rw-r--r--src/components/policy/policy_regular/include/policy/cache_manager.h38
-rw-r--r--src/components/policy/policy_regular/include/policy/cache_manager_interface.h12
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_helper.h2
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_manager_impl.h12
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_table/enums.h574
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_table/policy_enum_schema_factory.h60
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_table/types.h114
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_types.h2
-rw-r--r--src/components/policy/policy_regular/include/policy/pt_representation.h5
-rw-r--r--src/components/policy/policy_regular/include/policy/sql_pt_queries.h13
-rw-r--r--src/components/policy/policy_regular/include/policy/sql_pt_representation.h33
-rw-r--r--src/components/policy/policy_regular/src/cache_manager.cc112
-rw-r--r--src/components/policy/policy_regular/src/policy_helper.cc161
-rw-r--r--src/components/policy/policy_regular/src/policy_manager_impl.cc74
-rw-r--r--src/components/policy/policy_regular/src/policy_table/enums.cc1518
-rw-r--r--src/components/policy/policy_regular/src/policy_table/types.cc496
-rw-r--r--src/components/policy/policy_regular/src/policy_table/validation.cc49
-rw-r--r--src/components/policy/policy_regular/src/sql_pt_queries.cc135
-rw-r--r--src/components/policy/policy_regular/src/sql_pt_representation.cc469
-rw-r--r--src/components/policy/policy_regular/test/include/policy/mock_pt_representation.h1
-rw-r--r--src/components/policy/policy_regular/test/policy_manager_impl_test.cc387
-rw-r--r--src/components/policy/policy_regular/test/sql_pt_representation_test.cc158
-rw-r--r--src/components/policy/policy_regular/test/vehicle_data_item_type_test.cc250
-rw-r--r--src/components/rpc_base/include/rpc_base/rpc_base.h7
-rw-r--r--src/components/rpc_base/include/rpc_base/rpc_base_inl.h38
-rw-r--r--src/components/rpc_base/include/rpc_base/rpc_base_json_inl.h4
-rw-r--r--src/components/smart_objects/include/smart_objects/object_schema_item.h100
-rw-r--r--src/components/smart_objects/include/smart_objects/schema_item.h13
-rw-r--r--src/components/smart_objects/include/smart_objects/smart_schema.h7
-rw-r--r--src/components/smart_objects/src/object_schema_item.cc46
-rw-r--r--src/components/smart_objects/src/smart_schema.cc4
-rw-r--r--src/components/smart_objects/test/CObjectSchemaItem_test.cc62
-rw-r--r--src/components/smart_objects/test/SmartObjectConvertionTime_test.cc57
-rwxr-xr-xtools/InterfaceGenerator/Generator.py7
-rw-r--r--tools/InterfaceGenerator/generator/generators/PolicyTypes.py691
-rwxr-xr-xtools/InterfaceGenerator/generator/generators/SmartFactoryBase.py163
-rwxr-xr-xtools/InterfaceGenerator/generator/generators/SmartFactoryJSONRPC.py38
-rwxr-xr-xtools/InterfaceGenerator/generator/generators/SmartFactorySDLRPC.py15
-rwxr-xr-xtools/InterfaceGenerator/generator/parsers/JSONRPC.py14
-rwxr-xr-xtools/InterfaceGenerator/generator/parsers/RPCBase.py2
-rwxr-xr-xtools/InterfaceGenerator/generator/parsers/SDLRPCV2.py2
-rwxr-xr-xtools/InterfaceGenerator/test/generator/generators/test_SmartFactoryJSONRPC.py50
-rwxr-xr-xtools/InterfaceGenerator/test/generator/generators/test_SmartFactorySDLRPC.py10
-rw-r--r--tools/InterfaceGenerator/test/generator/generators/test_expected_jsonrpc.cc118
-rw-r--r--tools/InterfaceGenerator/test/generator/generators/test_expected_sdlrpc.cc94
-rw-r--r--tools/cmake/helpers/generators.cmake13
-rw-r--r--tools/policy_table_validator/CMakeLists.txt5
247 files changed, 12287 insertions, 7458 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 69c81f3310..351bfb4ab6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -343,7 +343,9 @@ endif()
if (${EXTENDED_POLICY} STREQUAL "EXTERNAL_PROPRIETARY")
add_definitions(-DEXTERNAL_PROPRIETARY_MODE)
set(POLICY_PATH ${COMPONENTS_DIR}/policy/policy_external/)
- set(POLICY_GLOBAL_INCLUDE_PATH ${COMPONENTS_DIR}/include/policy/policy_external/)
+ set(POLICY_GLOBAL_INCLUDE_PATH
+ ${COMPONENTS_DIR}/include/policy/policy_external/
+ ${CMAKE_BINARY_DIR}/src/components/policy/policy_external/)
set(POLICY_MOCK_INCLUDE_PATH ${COMPONENTS_DIR}/include/test/policy/policy_external/)
message(STATUS "EXTERNAL_PROPRIETARY policy enabled")
else()
@@ -354,7 +356,9 @@ else()
message(STATUS "HTTP policy enabled")
endif()
set(POLICY_PATH ${COMPONENTS_DIR}/policy/policy_regular/)
- set(POLICY_GLOBAL_INCLUDE_PATH ${COMPONENTS_DIR}/include/policy/policy_regular/)
+ set(POLICY_GLOBAL_INCLUDE_PATH
+ ${COMPONENTS_DIR}/include/policy/policy_regular/
+ ${CMAKE_BINARY_DIR}/src/components/policy/policy_regular/)
set(POLICY_MOCK_INCLUDE_PATH ${COMPONENTS_DIR}/include/test/policy/policy_regular/)
endif()
diff --git a/src/appMain/sdl_preloaded_pt.json b/src/appMain/sdl_preloaded_pt.json
index ade41f209f..a3db070a99 100644
--- a/src/appMain/sdl_preloaded_pt.json
+++ b/src/appMain/sdl_preloaded_pt.json
@@ -6,23 +6,43 @@
"exchange_after_x_kilometers": 1800,
"exchange_after_x_days": 30,
"timeout_after_x_seconds": 60,
- "seconds_between_retries": [1,
- 5,
- 25,
- 125,
- 625],
+ "seconds_between_retries": [
+ 1,
+ 5,
+ 25,
+ 125,
+ 625
+ ],
"endpoints": {
"0x07": {
- "default": ["http://x.x.x.x:3000/api/1/policies/proprietary"]
+ "default": [
+ "http://x.x.x.x:3000/api/1/policies/proprietary"
+ ]
},
"0x04": {
- "default": ["http://x.x.x.x:3000/api/1/softwareUpdate"]
+ "default": [
+ "http://x.x.x.x:3000/api/1/softwareUpdate"
+ ]
},
"queryAppsUrl": {
- "default": ["http://sdl.shaid.server"]
+ "default": [
+ "http://sdl.shaid.server"
+ ]
},
"lock_screen_icon_url": {
- "default": ["http://i.imgur.com/TgkvOIZ.png"]
+ "default": [
+ "http://i.imgur.com/TgkvOIZ.png"
+ ]
+ },
+ "custom_vehicle_data_mapping_url": {
+ "default": [
+ "http://x.x.x.x:3000/api/1/vehicleDataMap"
+ ]
+ }
+ },
+ "endpoint_properties": {
+ "custom_vehicle_data_mapping_url": {
+ "version": "0.0.0"
}
},
"notifications_per_minute_by_priority": {
@@ -40,252 +60,337 @@
"Base-4": {
"rpcs": {
"AddCommand": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"AddSubMenu": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"ShowAppMenu": {
- "hmi_levels": ["FULL"]
+ "hmi_levels": [
+ "FULL"
+ ]
},
"Alert": {
- "hmi_levels": ["FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "FULL",
+ "LIMITED"
+ ]
},
"ChangeRegistration": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"CreateInteractionChoiceSet": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"DeleteCommand": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"DeleteFile": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"DeleteInteractionChoiceSet": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"DeleteSubMenu": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"EncodedSyncPData": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"EndAudioPassThru": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"GenericResponse": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"GetSystemCapability": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"ListFiles": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"OnAppInterfaceUnregistered": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"OnAudioPassThru": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"OnButtonEvent": {
- "hmi_levels": ["FULL",
- "LIMITED",
- "BACKGROUND"]
+ "hmi_levels": [
+ "FULL",
+ "LIMITED",
+ "BACKGROUND"
+ ]
},
"OnButtonPress": {
- "hmi_levels": ["FULL",
- "LIMITED",
- "BACKGROUND"]
+ "hmi_levels": [
+ "FULL",
+ "LIMITED",
+ "BACKGROUND"
+ ]
},
"OnCommand": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"OnDriverDistraction": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"OnEncodedSyncPData": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"OnHashChange": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"OnHMIStatus": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"OnLanguageChange": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"OnPermissionsChange": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"OnSystemRequest": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"OnSystemCapabilityUpdated": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"PerformAudioPassThru": {
- "hmi_levels": ["FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "FULL",
+ "LIMITED"
+ ]
},
"PerformInteraction": {
- "hmi_levels": ["FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "FULL",
+ "LIMITED"
+ ]
},
"PutFile": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
- },
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
+ },
"RegisterAppInterface": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"ResetGlobalProperties": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"ScrollableMessage": {
- "hmi_levels": ["FULL"]
+ "hmi_levels": [
+ "FULL"
+ ]
},
"SetAppIcon": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"SetDisplayLayout": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"SetGlobalProperties": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"SetMediaClockTimer": {
- "hmi_levels": ["FULL",
- "LIMITED",
- "BACKGROUND"]
+ "hmi_levels": [
+ "FULL",
+ "LIMITED",
+ "BACKGROUND"
+ ]
},
"Show": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"Slider": {
- "hmi_levels": ["FULL"]
+ "hmi_levels": [
+ "FULL"
+ ]
},
"Speak": {
- "hmi_levels": ["FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "FULL",
+ "LIMITED"
+ ]
},
"SubscribeButton": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"SystemRequest": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"UnregisterAppInterface": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"UnsubscribeButton": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
- },
- "CancelInteraction": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"CloseApplication": {
"hmi_levels": [
- "FULL",
- "LIMITED",
- "BACKGROUND"
+ "FULL",
+ "LIMITED",
+ "BACKGROUND"
]
}
}
@@ -294,32 +399,48 @@
"user_consent_prompt": "Location",
"rpcs": {
"GetVehicleData": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"],
- "parameters": ["gps",
- "speed"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ],
+ "parameters": [
+ "gps",
+ "speed"
+ ]
},
"OnVehicleData": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"],
- "parameters": ["gps",
- "speed"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ],
+ "parameters": [
+ "gps",
+ "speed"
+ ]
},
"SubscribeVehicleData": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"],
- "parameters": ["gps",
- "speed"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ],
+ "parameters": [
+ "gps",
+ "speed"
+ ]
},
"UnsubscribeVehicleData": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"],
- "parameters": ["gps",
- "speed"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ],
+ "parameters": [
+ "gps",
+ "speed"
+ ]
}
}
},
@@ -327,7 +448,9 @@
"user_consent_prompt": "Notifications",
"rpcs": {
"Alert": {
- "hmi_levels": ["BACKGROUND"]
+ "hmi_levels": [
+ "BACKGROUND"
+ ]
}
}
},
@@ -363,56 +486,72 @@
"user_consent_prompt": "DrivingCharacteristics",
"rpcs": {
"GetVehicleData": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"],
- "parameters": ["accPedalPosition",
- "beltStatus",
- "electronicParkBrakeStatus",
- "driverBraking",
- "myKey",
- "prndl",
- "rpm",
- "steeringWheelAngle"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ],
+ "parameters": [
+ "accPedalPosition",
+ "beltStatus",
+ "electronicParkBrakeStatus",
+ "driverBraking",
+ "myKey",
+ "prndl",
+ "rpm",
+ "steeringWheelAngle"
+ ]
},
"OnVehicleData": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"],
- "parameters": ["accPedalPosition",
- "beltStatus",
- "electronicParkBrakeStatus",
- "driverBraking",
- "myKey",
- "prndl",
- "rpm",
- "steeringWheelAngle"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ],
+ "parameters": [
+ "accPedalPosition",
+ "beltStatus",
+ "electronicParkBrakeStatus",
+ "driverBraking",
+ "myKey",
+ "prndl",
+ "rpm",
+ "steeringWheelAngle"
+ ]
},
"SubscribeVehicleData": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"],
- "parameters": ["accPedalPosition",
- "beltStatus",
- "electronicParkBrakeStatus",
- "driverBraking",
- "myKey",
- "prndl",
- "rpm",
- "steeringWheelAngle"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ],
+ "parameters": [
+ "accPedalPosition",
+ "beltStatus",
+ "electronicParkBrakeStatus",
+ "driverBraking",
+ "myKey",
+ "prndl",
+ "rpm",
+ "steeringWheelAngle"
+ ]
},
"UnsubscribeVehicleData": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"],
- "parameters": ["accPedalPosition",
- "beltStatus",
- "electronicParkBrakeStatus",
- "driverBraking",
- "myKey",
- "prndl",
- "rpm",
- "steeringWheelAngle"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ],
+ "parameters": [
+ "accPedalPosition",
+ "beltStatus",
+ "electronicParkBrakeStatus",
+ "driverBraking",
+ "myKey",
+ "prndl",
+ "rpm",
+ "steeringWheelAngle"
+ ]
}
}
},
@@ -420,187 +559,231 @@
"user_consent_prompt": "VehicleInfo",
"rpcs": {
"GetVehicleData": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"],
- "parameters": ["bodyInformation",
- "deviceStatus",
- "engineOilLife",
- "engineTorque",
- "externalTemperature",
- "turnSignal",
- "fuelLevel",
- "fuelLevel_State",
- "headLampStatus",
- "instantFuelConsumption",
- "fuelRange",
- "cloudAppVehicleID",
- "odometer",
- "tirePressure",
- "vin",
- "wiperStatus"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ],
+ "parameters": [
+ "bodyInformation",
+ "deviceStatus",
+ "engineOilLife",
+ "engineTorque",
+ "externalTemperature",
+ "turnSignal",
+ "fuelLevel",
+ "fuelLevel_State",
+ "headLampStatus",
+ "instantFuelConsumption",
+ "fuelRange",
+ "cloudAppVehicleID",
+ "odometer",
+ "tirePressure",
+ "vin",
+ "wiperStatus"
+ ]
},
"OnVehicleData": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"],
- "parameters": ["bodyInformation",
- "deviceStatus",
- "engineOilLife",
- "engineTorque",
- "externalTemperature",
- "turnSignal",
- "fuelLevel",
- "fuelLevel_State",
- "headLampStatus",
- "instantFuelConsumption",
- "fuelRange",
- "cloudAppVehicleID",
- "odometer",
- "tirePressure",
- "vin",
- "wiperStatus"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ],
+ "parameters": [
+ "bodyInformation",
+ "deviceStatus",
+ "engineOilLife",
+ "engineTorque",
+ "externalTemperature",
+ "turnSignal",
+ "fuelLevel",
+ "fuelLevel_State",
+ "headLampStatus",
+ "instantFuelConsumption",
+ "fuelRange",
+ "cloudAppVehicleID",
+ "odometer",
+ "tirePressure",
+ "vin",
+ "wiperStatus"
+ ]
},
"SubscribeVehicleData": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"],
- "parameters": ["bodyInformation",
- "deviceStatus",
- "engineOilLife",
- "engineTorque",
- "externalTemperature",
- "turnSignal",
- "fuelLevel",
- "fuelLevel_State",
- "headLampStatus",
- "instantFuelConsumption",
- "fuelRange",
- "cloudAppVehicleID",
- "odometer",
- "tirePressure",
- "wiperStatus"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ],
+ "parameters": [
+ "bodyInformation",
+ "deviceStatus",
+ "engineOilLife",
+ "engineTorque",
+ "externalTemperature",
+ "turnSignal",
+ "fuelLevel",
+ "fuelLevel_State",
+ "headLampStatus",
+ "instantFuelConsumption",
+ "fuelRange",
+ "cloudAppVehicleID",
+ "odometer",
+ "tirePressure",
+ "wiperStatus"
+ ]
},
"UnsubscribeVehicleData": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"],
- "parameters": ["bodyInformation",
- "deviceStatus",
- "engineOilLife",
- "engineTorque",
- "externalTemperature",
- "turnSignal",
- "fuelLevel",
- "fuelLevel_State",
- "headLampStatus",
- "instantFuelConsumption",
- "fuelRange",
- "cloudAppVehicleID",
- "odometer",
- "tirePressure",
- "wiperStatus"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ],
+ "parameters": [
+ "bodyInformation",
+ "deviceStatus",
+ "engineOilLife",
+ "engineTorque",
+ "externalTemperature",
+ "turnSignal",
+ "fuelLevel",
+ "fuelLevel_State",
+ "headLampStatus",
+ "instantFuelConsumption",
+ "fuelRange",
+ "cloudAppVehicleID",
+ "odometer",
+ "tirePressure",
+ "wiperStatus"
+ ]
}
}
},
"PropriataryData-1": {
"rpcs": {
"DiagnosticMessage": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"GetDTCs": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"ReadDID": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
}
}
},
"PropriataryData-2": {
"rpcs": {
"DiagnosticMessage": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"GetDTCs": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"ReadDID": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
}
}
},
"ProprietaryData-3": {
"rpcs": {
"GetDTCs": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"ReadDID": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
}
}
},
"CloudAppStore": {
"rpcs": {
- "SetCloudAppProperties":{
- "hmi_levels":["BACKGROUND",
- "FULL",
- "LIMITED"]
- },
- "GetCloudAppProperties":{
- "hmi_levels":["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "SetCloudAppProperties": {
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
+ },
+ "GetCloudAppProperties": {
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
}
}
},
"CloudApp": {
"rpcs": {
"GetVehicleData": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"],
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ],
"parameters": [
- "cloudAppVehicleID"
+ "cloudAppVehicleID"
]
},
"OnVehicleData": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"],
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ],
"parameters": [
- "cloudAppVehicleID"
+ "cloudAppVehicleID"
]
},
"SubscribeVehicleData": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"],
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ],
"parameters": [
- "cloudAppVehicleID"
+ "cloudAppVehicleID"
]
},
"UnsubscribeVehicleData": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"],
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ],
"parameters": [
- "cloudAppVehicleID"
+ "cloudAppVehicleID"
]
}
}
@@ -616,12 +799,12 @@
]
},
"UnpublishAppService": {
- "hmi_levels": [
- "FULL",
- "LIMITED",
- "BACKGROUND",
- "NONE"
- ]
+ "hmi_levels": [
+ "FULL",
+ "LIMITED",
+ "BACKGROUND",
+ "NONE"
+ ]
},
"GetAppServiceData": {
"hmi_levels": [
@@ -688,339 +871,465 @@
"RemoteControl": {
"rpcs": {
"ButtonPress": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"GetInteriorVehicleData": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"SetInteriorVehicleData": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"OnInteriorVehicleData": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"SystemRequest": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"OnRCStatus": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
}
}
},
"Emergency-1": {
"rpcs": {
"GetVehicleData": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"],
- "parameters": ["airbagStatus",
- "clusterModeStatus",
- "eCallInfo",
- "emergencyEvent"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ],
+ "parameters": [
+ "airbagStatus",
+ "clusterModeStatus",
+ "eCallInfo",
+ "emergencyEvent"
+ ]
},
"OnVehicleData": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"],
- "parameters": ["airbagStatus",
- "clusterModeStatus",
- "eCallInfo",
- "emergencyEvent"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ],
+ "parameters": [
+ "airbagStatus",
+ "clusterModeStatus",
+ "eCallInfo",
+ "emergencyEvent"
+ ]
},
"SubscribeVehicleData": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"],
- "parameters": ["airbagStatus",
- "clusterModeStatus",
- "eCallInfo",
- "emergencyEvent"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ],
+ "parameters": [
+ "airbagStatus",
+ "clusterModeStatus",
+ "eCallInfo",
+ "emergencyEvent"
+ ]
},
"UnsubscribeVehicleData": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"],
- "parameters": ["airbagStatus",
- "clusterModeStatus",
- "eCallInfo",
- "emergencyEvent"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ],
+ "parameters": [
+ "airbagStatus",
+ "clusterModeStatus",
+ "eCallInfo",
+ "emergencyEvent"
+ ]
}
}
},
"Navigation-1": {
"rpcs": {
"AlertManeuver": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"ShowConstantTBT": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"UpdateTurnList": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
}
}
},
"Base-6": {
"rpcs": {
"AddCommand": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"AddSubMenu": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"ShowAppMenu": {
- "hmi_levels": ["FULL"]
+ "hmi_levels": [
+ "FULL"
+ ]
},
"Alert": {
- "hmi_levels": ["FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "FULL",
+ "LIMITED"
+ ]
},
"ChangeRegistration": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"CreateInteractionChoiceSet": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"DeleteCommand": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"DeleteFile": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"DeleteInteractionChoiceSet": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"DeleteSubMenu": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"EncodedSyncPData": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"EndAudioPassThru": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"GenericResponse": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"ListFiles": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"OnAppInterfaceUnregistered": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"OnAudioPassThru": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"OnButtonEvent": {
- "hmi_levels": ["FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "FULL",
+ "LIMITED"
+ ]
},
"OnButtonPress": {
- "hmi_levels": ["FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "FULL",
+ "LIMITED"
+ ]
},
"OnCommand": {
- "hmi_levels": ["FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "FULL",
+ "LIMITED"
+ ]
},
"OnDriverDistraction": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"OnEncodedSyncPData": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"OnHMIStatus": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"OnLanguageChange": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"OnPermissionsChange": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"OnSyncPData": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"OnTBTClientState": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"PerformAudioPassThru": {
- "hmi_levels": ["FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "FULL",
+ "LIMITED"
+ ]
},
"PerformInteraction": {
- "hmi_levels": ["FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "FULL",
+ "LIMITED"
+ ]
},
"PutFile": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"RegisterAppInterface": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"ResetGlobalProperties": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"ScrollableMessage": {
- "hmi_levels": ["FULL"]
+ "hmi_levels": [
+ "FULL"
+ ]
},
"SetAppIcon": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"SetDisplayLayout": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"SetGlobalProperties": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"SetMediaClockTimer": {
- "hmi_levels": ["FULL"]
+ "hmi_levels": [
+ "FULL"
+ ]
},
"Show": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"Slider": {
- "hmi_levels": ["FULL"]
+ "hmi_levels": [
+ "FULL"
+ ]
},
"Speak": {
- "hmi_levels": ["FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "FULL",
+ "LIMITED"
+ ]
},
"SubscribeButton": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"SyncPData": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"UnregisterAppInterface": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"UnsubscribeButton": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
}
}
},
"OnKeyboardInputOnlyGroup": {
"rpcs": {
"OnKeyboardInput": {
- "hmi_levels": ["FULL"]
+ "hmi_levels": [
+ "FULL"
+ ]
}
}
},
"OnTouchEventOnlyGroup": {
"rpcs": {
"OnTouchEvent": {
- "hmi_levels": ["FULL"]
+ "hmi_levels": [
+ "FULL"
+ ]
}
}
},
"DiagnosticMessageOnly": {
"rpcs": {
"DiagnosticMessage": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
}
}
},
@@ -1031,164 +1340,218 @@
"BaseBeforeDataConsent": {
"rpcs": {
"ChangeRegistration": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"DeleteFile": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"EncodedSyncPData": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"ListFiles": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"OnAppInterfaceUnregistered": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"OnEncodedSyncPData": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"OnHashChange": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"OnHMIStatus": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"OnLanguageChange": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"OnPermissionsChange": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"OnSystemRequest": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"PutFile": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"RegisterAppInterface": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"ResetGlobalProperties": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"SetGlobalProperties": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"SetAppIcon": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"SetDisplayLayout": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"SystemRequest": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
},
"UnregisterAppInterface": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
}
}
},
"SendLocation": {
"rpcs": {
"SendLocation": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
}
}
},
"WayPoints": {
"rpcs": {
"GetWayPoints": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"SubscribeWayPoints": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"UnsubscribeWayPoints": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"OnWayPointChange": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
}
}
},
"BackgroundAPT": {
"rpcs": {
"EndAudioPassThru": {
- "hmi_levels": ["BACKGROUND"]
+ "hmi_levels": [
+ "BACKGROUND"
+ ]
},
"OnAudioPassThru": {
- "hmi_levels": ["BACKGROUND"]
+ "hmi_levels": [
+ "BACKGROUND"
+ ]
},
"PerformAudioPassThru": {
- "hmi_levels": ["BACKGROUND"]
+ "hmi_levels": [
+ "BACKGROUND"
+ ]
}
}
},
@@ -1198,32 +1561,42 @@
"hmi_levels": ["FULL"]
},
"SendHapticData": {
- "hmi_levels": ["FULL"]
+ "hmi_levels": [
+ "FULL"
+ ]
}
}
},
"WidgetSupport": {
"rpcs": {
"CreateWindow": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"DeleteWindow": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"Show": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED"
+ ]
},
"OnSystemCapabilityUpdated": {
- "hmi_levels": ["BACKGROUND",
- "FULL",
- "LIMITED",
- "NONE"]
+ "hmi_levels": [
+ "BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"
+ ]
}
}
}
@@ -1964,9 +2337,9 @@
}
}
},
- "LockScreenDismissalWarning":{
- "languages":{
- "en-us":{
+ "LockScreenDismissalWarning": {
+ "languages": {
+ "en-us": {
"textBody": "Swipe down to dismiss, acknowledging that you are not the driver"
}
}
@@ -2565,7 +2938,9 @@
"steal_focus": false,
"priority": "NONE",
"default_hmi": "NONE",
- "groups": ["Base-4"],
+ "groups": [
+ "Base-4"
+ ],
"RequestType": [],
"RequestSubType": []
},
@@ -2574,15 +2949,1120 @@
"steal_focus": false,
"priority": "NONE",
"default_hmi": "NONE",
- "groups": ["DataConsent-2"]
+ "groups": [
+ "DataConsent-2"
+ ]
},
"pre_DataConsent": {
"keep_context": false,
"steal_focus": false,
"priority": "NONE",
"default_hmi": "NONE",
- "groups": ["BaseBeforeDataConsent"]
+ "groups": [
+ "BaseBeforeDataConsent"
+ ]
}
+ },
+ "vehicle_data": {
+ "schema_version": "0.0.0",
+ "schema_items": [
+ {
+ "name": "gps",
+ "params": [
+ {
+ "name": "longitudeDegrees",
+ "key": "OEM_REF_LONG_DEG",
+ "type": "Float",
+ "mandatory": true,
+ "minvalue": -180,
+ "maxvalue": 180
+ },
+ {
+ "name": "latitudeDegrees",
+ "key": "OEM_REF_LAT_DEG",
+ "type": "Float",
+ "mandatory": true,
+ "minvalue": -90,
+ "maxvalue": 90
+ },
+ {
+ "name": "utcYear",
+ "key": "OEM_REF_UTC_YEAR",
+ "type": "Integer",
+ "mandatory": false,
+ "minvalue": 2010,
+ "maxvalue": 2100,
+ "since": "5.0"
+ },
+ {
+ "name": "utcYear",
+ "key": "OEM_REF_UTC_YEAR",
+ "type": "Integer",
+ "mandatory": true,
+ "minvalue": 2010,
+ "maxvalue": 2100,
+ "since": "2.0",
+ "until": "5.0"
+ },
+ {
+ "name": "utcMonth",
+ "key": "OEM_REF_UTC_MONTH",
+ "type": "Integer",
+ "mandatory": false,
+ "minvalue": 1,
+ "maxvalue": 12,
+ "since": "5.0"
+ },
+ {
+ "name": "utcMonth",
+ "key": "OEM_REF_UTC_MONTH",
+ "type": "Integer",
+ "mandatory": true,
+ "minvalue": 1,
+ "maxvalue": 12,
+ "since": "2.0",
+ "until": "5.0"
+ },
+ {
+ "name": "utcDay",
+ "key": "OEM_REF_UTC_DAY",
+ "type": "Integer",
+ "mandatory": false,
+ "minvalue": 1,
+ "maxvalue": 31,
+ "since": "5.0"
+ },
+ {
+ "name": "utcDay",
+ "key": "OEM_REF_UTC_DAY",
+ "type": "Integer",
+ "mandatory": true,
+ "minvalue": 1,
+ "maxvalue": 31,
+ "since": "2.0",
+ "until": "5.0"
+ },
+ {
+ "name": "utcHours",
+ "key": "OEM_REF_UTC_HOURS",
+ "type": "Integer",
+ "mandatory": false,
+ "minvalue": 0,
+ "maxvalue": 23,
+ "since": "5.0"
+ },
+ {
+ "name": "utcHours",
+ "key": "OEM_REF_UTC_HOURS",
+ "type": "Integer",
+ "mandatory": true,
+ "minvalue": 0,
+ "maxvalue": 23,
+ "since": "2.0",
+ "until": "5.0"
+ },
+ {
+ "name": "utcMinutes",
+ "key": "OEM_REF_UTC_MIN",
+ "type": "Integer",
+ "mandatory": false,
+ "minvalue": 0,
+ "maxvalue": 59,
+ "since": "5.0"
+ },
+ {
+ "name": "utcMinutes",
+ "key": "OEM_REF_UTC_MIN",
+ "type": "Integer",
+ "mandatory": true,
+ "minvalue": 0,
+ "maxvalue": 59,
+ "since": "2.0",
+ "until": "5.0"
+ },
+ {
+ "name": "utcSeconds",
+ "key": "OEM_REF_UTC_SEC",
+ "type": "Integer",
+ "mandatory": false,
+ "minvalue": 0,
+ "maxvalue": 59,
+ "since": "5.0"
+ },
+ {
+ "name": "utcSeconds",
+ "key": "OEM_REF_UTC_SEC",
+ "type": "Integer",
+ "mandatory": true,
+ "minvalue": 0,
+ "maxvalue": 59,
+ "since": "2.0",
+ "until": "5.0"
+ },
+ {
+ "name": "compassDirection",
+ "key": "OEM_REF_COM_DIR",
+ "type": "CompassDirection",
+ "mandatory": false,
+ "since": "5.0"
+ },
+ {
+ "name": "compassDirection",
+ "key": "OEM_REF_COM_DIR",
+ "type": "CompassDirection",
+ "mandatory": true,
+ "since": "2.0",
+ "until": "5.0"
+ },
+ {
+ "name": "pdop",
+ "key": "OEM_REF_PDOP",
+ "type": "Float",
+ "mandatory": false,
+ "minvalue": 0,
+ "maxvalue": 1000,
+ "since": "5.0"
+ },
+ {
+ "name": "pdop",
+ "key": "OEM_REF_PDOP",
+ "type": "Float",
+ "mandatory": true,
+ "minvalue": 0,
+ "maxvalue": 10,
+ "since": "2.0",
+ "until": "5.0"
+ },
+ {
+ "name": "hdop",
+ "key": "OEM_REF_HDOP",
+ "type": "Float",
+ "mandatory": true,
+ "minvalue": 0,
+ "maxvalue": 1000,
+ "since": "2.0",
+ "until": "5.0"
+ },
+ {
+ "name": "hdop",
+ "key": "OEM_REF_HDOP",
+ "type": "Float",
+ "mandatory": false,
+ "minvalue": 0,
+ "maxvalue": 1000,
+ "since": "5.0"
+ },
+ {
+ "name": "vdop",
+ "key": "OEM_REF_VDOP",
+ "type": "Float",
+ "mandatory": false,
+ "minvalue": 0,
+ "maxvalue": 10,
+ "since": "5.0"
+ },
+ {
+ "name": "vdop",
+ "key": "OEM_REF_VDOP",
+ "type": "Float",
+ "mandatory": true,
+ "minvalue": 0,
+ "maxvalue": 10,
+ "since": "2.0",
+ "until": "5.0"
+ },
+ {
+ "name": "actual",
+ "key": "OEM_REF_ACT",
+ "type": "Boolean",
+ "mandatory": false,
+ "since": "5.0"
+ },
+ {
+ "name": "actual",
+ "key": "OEM_REF_ACT",
+ "type": "Boolean",
+ "mandatory": true,
+ "since": "2.0",
+ "until": "5.0"
+ },
+ {
+ "name": "satellites",
+ "key": "OEM_REF_SAT",
+ "type": "Integer",
+ "mandatory": false,
+ "minvalue": 0,
+ "maxvalue": 31,
+ "until": "5.0"
+ },
+ {
+ "name": "satellites",
+ "key": "OEM_REF_SAT",
+ "type": "Integer",
+ "mandatory": true,
+ "minvalue": 0,
+ "maxvalue": 31,
+ "since": "2.0",
+ "until": "5.0"
+ },
+ {
+ "name": "dimension",
+ "key": "OEM_REF_DIM",
+ "type": "Dimension",
+ "mandatory": false,
+ "since": "5.0"
+ },
+ {
+ "name": "dimension",
+ "key": "OEM_REF_DIM",
+ "type": "Dimension",
+ "mandatory": true,
+ "since": "2.0",
+ "until": "5.0"
+ },
+ {
+ "name": "altitude",
+ "key": "OEM_REF_ALT",
+ "type": "Float",
+ "mandatory": false,
+ "minvalue": -10000,
+ "maxvalue": 10000,
+ "since": "5.0"
+ },
+ {
+ "name": "altitude",
+ "key": "OEM_REF_ALT",
+ "type": "Float",
+ "mandatory": true,
+ "minvalue": -10000,
+ "maxvalue": 10000,
+ "since": "2.0",
+ "until": "5.0"
+ },
+ {
+ "name": "heading",
+ "key": "OEM_REF_HEAD",
+ "type": "Float",
+ "mandatory": false,
+ "minvalue": 0,
+ "maxvalue": 359.99,
+ "until": "5.0"
+ },
+ {
+ "name": "heading",
+ "key": "OEM_REF_HEAD",
+ "type": "Float",
+ "mandatory": true,
+ "minvalue": 0,
+ "maxvalue": 359.99,
+ "since": "2.0",
+ "until": "5.0"
+ },
+ {
+ "name": "speed",
+ "key": "OEM_REF_GPS_SPEED",
+ "type": "Float",
+ "mandatory": false,
+ "minvalue": 0,
+ "maxvalue": 500,
+ "until": "5.0"
+ },
+ {
+ "name": "speed",
+ "key": "OEM_REF_GPS_SPEED",
+ "type": "Float",
+ "mandatory": true,
+ "minvalue": 0,
+ "maxvalue": 500,
+ "since": "2.0",
+ "until": "5.0"
+ },
+ {
+ "name": "shifted",
+ "key": "OEM_REF_SHIFT",
+ "type": "Boolean",
+ "mandatory": false,
+ "minvalue": 0,
+ "maxvalue": 500,
+ "since": "6.0"
+ }
+ ],
+ "key": "OEM_REF_GPS",
+ "type": "Struct",
+ "mandatory": false
+ },
+ {
+ "name": "speed",
+ "key": "OEM_REF_SPEED",
+ "type": "Float",
+ "mandatory": false,
+ "minvalue": 0,
+ "maxvalue": 700
+ },
+ {
+ "name": "rpm",
+ "key": "OEM_REF_RPM",
+ "type": "Integer",
+ "mandatory": false,
+ "minvalue": 0,
+ "maxvalue": 20000
+ },
+ {
+ "name": "fuelLevel",
+ "key": "OEM_REF_FUEL_LEV",
+ "type": "Float",
+ "mandatory": false,
+ "minvalue": -6,
+ "maxvalue": 106
+ },
+ {
+ "name": "fuelLevel_State",
+ "key": "OEM_REF_FUEL_LEV_ST",
+ "type": "ComponentVolumeStatus",
+ "mandatory": false
+ },
+ {
+ "name": "instantFuelConsumption",
+ "key": "OEM_REF_INS_FUEL_CON",
+ "type": "Float",
+ "mandatory": false,
+ "minvalue": 0,
+ "maxvalue": 25575
+ },
+ {
+ "name": "fuelRange",
+ "params": [
+ {
+ "name": "type",
+ "key": "OEM_REF_FUEL_RAN_TYPE",
+ "type": "Float",
+ "mandatory": false,
+ "minvalue": 0,
+ "maxvalue": 10000
+ },
+ {
+ "name": "range",
+ "key": "OEM_REF_FUEL_RAN_RANG",
+ "type": "FuelType",
+ "mandatory": false
+ }
+ ],
+ "key": "OEM_REF_FUEL_RAN",
+ "array": true,
+ "type": "Struct",
+ "mandatory": false,
+ "minsize": 0,
+ "maxsize": 100,
+ "since": "5.0"
+ },
+ {
+ "name": "externalTemperature",
+ "key": "OEM_REF_EXT_TEMP",
+ "type": "Float",
+ "mandatory": false,
+ "minvalue": -40,
+ "maxvalue": 100
+ },
+ {
+ "name": "turnSignal",
+ "key": "OEM_REF_TURN_SIGN",
+ "type": "TurnSignal",
+ "mandatory": false,
+ "since": "5.0"
+ },
+ {
+ "name": "vin",
+ "key": "OEM_REF_VIN",
+ "type": "String",
+ "mandatory": false,
+ "maxlength": 17,
+ "since": "5.0"
+ },
+ {
+ "name": "prndl",
+ "key": "OEM_REF_PRNDL",
+ "type": "PRNDL",
+ "mandatory": false
+ },
+ {
+ "name": "tirePressure",
+ "params": [
+ {
+ "name": "pressureTelltale",
+ "key": "OEM_REF_PRES_TEL",
+ "type": "WarningLightStatus",
+ "mandatory": true
+ },
+ {
+ "name": "leftFront",
+ "params": [
+ {
+ "name": "status",
+ "key": "OEM_REF_LEFT_FR_ST",
+ "type": "ComponentVolumeStatus",
+ "mandatory": true
+ },
+ {
+ "name": "tpms",
+ "key": "OEM_REF_LEFT_FR_TMPS",
+ "type": "TPMS",
+ "mandatory": false,
+ "since": "5.0"
+ },
+ {
+ "name": "pressure",
+ "key": "OEM_REF_LEFT_FR_PRES",
+ "type": "Float",
+ "mandatory": false,
+ "minvalue": 0,
+ "maxvalue": 2000,
+ "since": "5.0"
+ }
+ ],
+ "key": "OEM_REF_LEFT_FR",
+ "type": "Struct",
+ "mandatory": true
+ },
+ {
+ "name": "rightFront",
+ "params": [
+ {
+ "name": "status",
+ "key": "OEM_REF_RIGHT_FR_ST",
+ "type": "ComponentVolumeStatus",
+ "mandatory": true
+ },
+ {
+ "name": "tpms",
+ "key": "OEM_REF_RIGHT_FR_TMPS",
+ "type": "TPMS",
+ "mandatory": false,
+ "since": "5.0"
+ },
+ {
+ "name": "pressure",
+ "key": "OEM_REF_RIGHT_FR_PRES",
+ "type": "Float",
+ "mandatory": false,
+ "minvalue": 0,
+ "maxvalue": 2000,
+ "since": "5.0"
+ }
+ ],
+ "key": "OEM_REF_RIGHT_FR",
+ "type": "Struct",
+ "mandatory": true
+ },
+ {
+ "name": "leftRear",
+ "params": [
+ {
+ "name": "status",
+ "key": "OEM_REF_LEFT_REAR_ST",
+ "type": "ComponentVolumeStatus",
+ "mandatory": true
+ },
+ {
+ "name": "tpms",
+ "key": "OEM_REF_LEFT_REAR_TMPS",
+ "type": "TPMS",
+ "mandatory": false,
+ "since": "5.0"
+ },
+ {
+ "name": "pressure",
+ "key": "OEM_REF_LEFT_REAR_PRES",
+ "type": "Float",
+ "mandatory": false,
+ "minvalue": 0,
+ "maxvalue": 2000,
+ "since": "5.0"
+ }
+ ],
+ "key": "OEM_REF_LEFT_REAR",
+ "type": "Struct",
+ "mandatory": true
+ },
+ {
+ "name": "rightRear",
+ "params": [
+ {
+ "name": "status",
+ "key": "OEM_REF_RIGHT_REAR_ST",
+ "type": "ComponentVolumeStatus",
+ "mandatory": true
+ },
+ {
+ "name": "tpms",
+ "key": "OEM_REF_RIGHT_REAR_TMPS",
+ "type": "TPMS",
+ "mandatory": false,
+ "since": "5.0"
+ },
+ {
+ "name": "pressure",
+ "key": "OEM_REF_RIGHT_REAR_PRES",
+ "type": "Float",
+ "mandatory": false,
+ "minvalue": 0,
+ "maxvalue": 2000,
+ "since": "5.0"
+ }
+ ],
+ "key": "OEM_REF_RIGHT_REAR",
+ "type": "Struct",
+ "mandatory": true
+ },
+ {
+ "name": "innerLeftRear",
+ "params": [
+ {
+ "name": "status",
+ "key": "OEM_REF_IN_LEFT_REAR_ST",
+ "type": "ComponentVolumeStatus",
+ "mandatory": true
+ },
+ {
+ "name": "tpms",
+ "key": "OEM_REF_IN_LEFT_REAR_TMPS",
+ "type": "TPMS",
+ "mandatory": false,
+ "since": "5.0"
+ },
+ {
+ "name": "pressure",
+ "key": "OEM_REF_IN_LEFT_REAR_PRES",
+ "type": "Float",
+ "mandatory": false,
+ "minvalue": 0,
+ "maxvalue": 2000,
+ "since": "5.0"
+ }
+ ],
+ "key": "OEM_REF_IN_LEFT_REAR",
+ "type": "Struct",
+ "mandatory": true
+ },
+ {
+ "name": "innerRightRear",
+ "params": [
+ {
+ "name": "status",
+ "key": "OEM_REF_IN_RIGHT_REAR_ST",
+ "type": "ComponentVolumeStatus",
+ "mandatory": true
+ },
+ {
+ "name": "tpms",
+ "key": "OEM_REF_IN_RIGHT_REAR_TMPS",
+ "type": "TPMS",
+ "mandatory": false,
+ "since": "5.0"
+ },
+ {
+ "name": "pressure",
+ "key": "OEM_REF_IN_RIGHT_REAR_PRES",
+ "type": "Float",
+ "mandatory": false,
+ "minvalue": 0,
+ "maxvalue": 2000,
+ "since": "5.0"
+ }
+ ],
+ "key": "OEM_REF_IN_RIGHT_REAR",
+ "type": "Struct",
+ "mandatory": true
+ }
+ ],
+ "key": "OEM_REF_TIRE_PRES",
+ "type": "Struct",
+ "mandatory": false
+ },
+ {
+ "name": "odometer",
+ "key": "OEM_REF_ODOM",
+ "type": "Integer",
+ "mandatory": false,
+ "minvalue": 0,
+ "maxvalue": 17000000
+ },
+ {
+ "name": "beltStatus",
+ "params": [
+ {
+ "name": "driverBeltDeployed",
+ "key": "OEM_REF_DR_BELT_DEP",
+ "type": "VehicleDataEventStatus",
+ "mandatory": true
+ },
+ {
+ "name": "passengerBeltDeployed",
+ "key": "OEM_REF_PAS_BELT_DEP",
+ "type": "VehicleDataEventStatus",
+ "mandatory": true
+ },
+ {
+ "name": "passengerBuckleBelted",
+ "key": "OEM_REF_PAS_BUCK_BELT",
+ "type": "VehicleDataEventStatus",
+ "mandatory": true
+ },
+ {
+ "name": "driverBuckleBelted",
+ "key": "OEM_REF_DR_BUCK_BELT",
+ "type": "VehicleDataEventStatus",
+ "mandatory": true
+ },
+ {
+ "name": "leftRow2BuckleBelted",
+ "key": "OEM_REF_LEFT_R2_BUCK_BELT",
+ "type": "VehicleDataEventStatus",
+ "mandatory": true
+ },
+ {
+ "name": "passengerChildDetected",
+ "key": "OEM_REF_PASS_CH_DET",
+ "type": "VehicleDataEventStatus",
+ "mandatory": true
+ },
+ {
+ "name": "rightRow2BuckleBelted",
+ "key": "OEM_REF_RIGHT_R2_BUCK_BELT",
+ "type": "VehicleDataEventStatus",
+ "mandatory": true
+ },
+ {
+ "name": "middleRow2BuckleBelted",
+ "key": "OEM_REF_MID_R2_BUCK_BELT",
+ "type": "VehicleDataEventStatus",
+ "mandatory": true
+ },
+ {
+ "name": "middleRow3BuckleBelted",
+ "key": "OEM_REF_MID_R3_BUCK_BELT",
+ "type": "VehicleDataEventStatus",
+ "mandatory": true
+ },
+ {
+ "name": "leftRow3BuckleBelted",
+ "key": "OEM_REF_LEFT_R3_BUCK_BELT",
+ "type": "VehicleDataEventStatus",
+ "mandatory": true
+ },
+ {
+ "name": "rightRow3BuckleBelted",
+ "key": "OEM_REF_RIGHT_R3_BUCK_BELT",
+ "type": "VehicleDataEventStatus",
+ "mandatory": true
+ },
+ {
+ "name": "leftRearInflatableBelted",
+ "key": "OEM_REF_LEFT_REAR_INF_BELT",
+ "type": "VehicleDataEventStatus",
+ "mandatory": true
+ },
+ {
+ "name": "rightRearInflatableBelted",
+ "key": "OEM_REF_RIGHT_REAR_INF_BELT",
+ "type": "VehicleDataEventStatus",
+ "mandatory": true
+ },
+ {
+ "name": "middleRow1BeltDeployed",
+ "key": "OEM_REF_MID_R1_BELT_DEP",
+ "type": "VehicleDataEventStatus",
+ "mandatory": true
+ },
+ {
+ "name": "middleRow1BuckleBelted",
+ "key": "OEM_REF_MID_R1_BUCK_BELT",
+ "type": "VehicleDataEventStatus",
+ "mandatory": true
+ }
+ ],
+ "key": "OEM_REF_BELT_ST",
+ "type": "Struct",
+ "mandatory": false
+ },
+ {
+ "name": "bodyInformation",
+ "params": [
+ {
+ "name": "parkBrakeActive",
+ "key": "OEM_REF_PARK_BR_ACT",
+ "type": "Boolean",
+ "mandatory": true
+ },
+ {
+ "name": "ignitionStableStatus",
+ "key": "OEM_REF_IGN_STAB_ST",
+ "type": "IgnitionStableStatus",
+ "mandatory": true
+ },
+ {
+ "name": "ignitionStatus",
+ "key": "OEM_REF_IGN_ST",
+ "type": "IgnitionStatus",
+ "mandatory": true
+ },
+ {
+ "name": "driverDoorAjar",
+ "key": "OEM_REF_DR_DOOR_AJ",
+ "type": "Boolean",
+ "mandatory": false
+ },
+ {
+ "name": "passengerDoorAjar",
+ "key": "OEM_REF_PAS_DOOR_AJ",
+ "type": "Boolean",
+ "mandatory": false
+ },
+ {
+ "name": "rearLeftDoorAjar",
+ "key": "OEM_REF_REAR_LEFT_DOOR_AJ",
+ "type": "Boolean",
+ "mandatory": false
+ },
+ {
+ "name": "rearRightDoorAjar",
+ "key": "OEM_REF_REAR_RIGHT_DOOR_AJ",
+ "type": "Boolean",
+ "mandatory": false
+ }
+ ],
+ "key": "OEM_REF_BODY_INF",
+ "type": "Struct",
+ "mandatory": false
+ },
+ {
+ "name": "deviceStatus",
+ "params": [
+ {
+ "name": "voiceRecOn",
+ "key": "OEM_REF_VOICE_REC_ON",
+ "type": "Boolean",
+ "mandatory": true
+ },
+ {
+ "name": "btIconOn",
+ "key": "OEM_REF_BT_ICO_ON",
+ "type": "Boolean",
+ "mandatory": true
+ },
+ {
+ "name": "callActive",
+ "key": "OEM_REF_CAL_ACT",
+ "type": "Boolean",
+ "mandatory": true
+ },
+ {
+ "name": "phoneRoaming",
+ "key": "OEM_REF_PH_ROAM",
+ "type": "Boolean",
+ "mandatory": true
+ },
+ {
+ "name": "textMsgAvailable",
+ "key": "OEM_REF_TEXT_MSG_AV",
+ "type": "Boolean",
+ "mandatory": true
+ },
+ {
+ "name": "battLevelStatus",
+ "key": "OEM_REF_BAT_LEV_ST",
+ "type": "DeviceLevelStatus",
+ "mandatory": true
+ },
+ {
+ "name": "stereoAudioOutputMuted",
+ "key": "OEM_REF_STER_AUD_OUT_MUT",
+ "type": "Boolean",
+ "mandatory": true
+ },
+ {
+ "name": "monoAudioOutputMuted",
+ "key": "OEM_REF_MONO_AUD_OUT_MUT",
+ "type": "Boolean",
+ "mandatory": true
+ },
+ {
+ "name": "signalLevelStatus",
+ "key": "OEM_REF_SIG_LEV_ST",
+ "type": "DeviceLevelStatus",
+ "mandatory": true
+ },
+ {
+ "name": "primaryAudioSource",
+ "key": "OEM_REF_PR_AUD_SOUR",
+ "type": "PrimaryAudioSource",
+ "mandatory": true
+ },
+ {
+ "name": "eCallEventActive",
+ "key": "OEM_REF_E_CALL_INF_ACT",
+ "type": "Boolean",
+ "mandatory": true
+ }
+ ],
+ "key": "OEM_REF_DEV_ST",
+ "type": "Struct",
+ "mandatory": false
+ },
+ {
+ "name": "driverBraking",
+ "key": "OEM_REF_DR_BRAK",
+ "type": "VehicleDataEventStatus",
+ "mandatory": false
+ },
+ {
+ "name": "wiperStatus",
+ "key": "OEM_REF_WI_ST",
+ "type": "WiperStatus",
+ "mandatory": false
+ },
+ {
+ "name": "headLampStatus",
+ "params": [
+ {
+ "name": "ambientLightSensorStatus",
+ "key": "OEM_REF_AMB_LIGHT",
+ "type": "AmbientLightStatus",
+ "mandatory": false
+ },
+ {
+ "name": "highBeamsOn",
+ "key": "OEM_REF_HIGH_BEAM",
+ "type": "Boolean",
+ "mandatory": true
+ },
+ {
+ "name": "lowBeamsOn",
+ "key": "OEM_REF_LOW_BEAM",
+ "type": "Boolean",
+ "mandatory": true
+ }
+ ],
+ "key": "OEM_REF_HLSTATUS",
+ "type": "Struct",
+ "mandatory": false
+ },
+ {
+ "name": "engineTorque",
+ "key": "OEM_REF_ENG_TORQ",
+ "type": "Float",
+ "mandatory": false,
+ "minvalue": -1000,
+ "maxvalue": 2000
+ },
+ {
+ "name": "accPedalPosition",
+ "key": "OEM_REF_ACC_PED_POS",
+ "type": "Float",
+ "mandatory": false,
+ "minvalue": 0,
+ "maxvalue": 100
+ },
+ {
+ "name": "steeringWheelAngle",
+ "key": "OEM_REF_STE_WH_ANG",
+ "type": "Float",
+ "mandatory": false,
+ "minvalue": -2000,
+ "maxvalue": 2000
+ },
+ {
+ "name": "engineOilLife",
+ "key": "OEM_REF_ENG_OIL_LIFE",
+ "type": "Float",
+ "mandatory": false,
+ "minvalue": 0,
+ "maxvalue": 100,
+ "since": "5.0"
+ },
+ {
+ "name": "electronicParkBrakeStatus",
+ "key": "OEM_REF_EL_PARK_BR_ST",
+ "type": "ElectronicParkBrakeStatus",
+ "mandatory": false,
+ "since": "5.0"
+ },
+ {
+ "name": "cloudAppVehicleID",
+ "key": "OEM_REF_CL_APP_VEH_ID",
+ "type": "String",
+ "mandatory": false,
+ "since": "5.1"
+ },
+ {
+ "name": "eCallInfo",
+ "params": [
+ {
+ "name": "eCallNotificationStatus",
+ "key": "OEM_REF_E_CALL_NOT_ST",
+ "type": "VehicleDataNotificationStatus",
+ "mandatory": true
+ },
+ {
+ "name": "auxECallNotificationStatus",
+ "key": "OEM_REF_AUX_E_CALL_NOT_ST",
+ "type": "VehicleDataNotificationStatus",
+ "mandatory": true
+ },
+ {
+ "name": "eCallConfirmationStatus",
+ "key": "OEM_REF_E_CALL_CONF_ST",
+ "type": "ECallConfirmationStatus",
+ "mandatory": true
+ }
+ ],
+ "key": "OEM_REF_E_CALL_INF",
+ "type": "Struct",
+ "mandatory": false
+ },
+ {
+ "name": "airbagStatus",
+ "params": [
+ {
+ "name": "driverAirbagDeployed",
+ "key": "OEM_REF_DR_AIR_DEP",
+ "type": "VehicleDataEventStatus",
+ "mandatory": true
+ },
+ {
+ "name": "driverSideAirbagDeployed",
+ "key": "OEM_REF_DR_SIDE_AIR_DEP",
+ "type": "VehicleDataEventStatus",
+ "mandatory": true
+ },
+ {
+ "name": "driverCurtainAirbagDeployed",
+ "key": "OEM_REF_DR_CUR_AIR_DEP",
+ "type": "VehicleDataEventStatus",
+ "mandatory": true
+ },
+ {
+ "name": "passengerAirbagDeployed",
+ "key": "OEM_REF_PASS_AIR_DEP",
+ "type": "VehicleDataEventStatus",
+ "mandatory": true
+ },
+ {
+ "name": "passengerCurtainAirbagDeployed",
+ "key": "OEM_REF_PASS_CUR_AIR_DEP",
+ "type": "VehicleDataEventStatus",
+ "mandatory": true
+ },
+ {
+ "name": "driverKneeAirbagDeployed",
+ "key": "OEM_REF_DR_KNEE_AIR_DEP",
+ "type": "VehicleDataEventStatus",
+ "mandatory": true
+ },
+ {
+ "name": "passengerSideAirbagDeployed",
+ "key": "OEM_REF_PASS_SIDE_AIR_DEP",
+ "type": "VehicleDataEventStatus",
+ "mandatory": true
+ },
+ {
+ "name": "passengerKneeAirbagDeployed",
+ "key": "OEM_REF_PASS_KNEE_AIR_DEP",
+ "type": "VehicleDataEventStatus",
+ "mandatory": true
+ }
+ ],
+ "key": "OEM_REF_AIR_ST",
+ "type": "Struct",
+ "mandatory": false
+ },
+ {
+ "name": "emergencyEvent",
+ "params": [
+ {
+ "name": "emergencyEventType",
+ "key": "OEM_REF_EM_EV_TYPE",
+ "type": "EmergencyEventType",
+ "mandatory": true
+ },
+ {
+ "name": "fuelCutoffStatus",
+ "key": "OEM_REF_FUEL_CUT_ST",
+ "type": "FuelCutoffStatus",
+ "mandatory": true
+ },
+ {
+ "name": "rolloverEvent",
+ "key": "OEM_REF_ROL_EV",
+ "type": "VehicleDataEventStatus",
+ "mandatory": true
+ },
+ {
+ "name": "maximumChangeVelocity",
+ "key": "OEM_REF_MAX_CH_VEL",
+ "type": "Integer",
+ "mandatory": true,
+ "minvalue": 0,
+ "maxvalue": 255
+ },
+ {
+ "name": "multipleEvents",
+ "key": "OEM_REF_MUL_EV",
+ "type": "VehicleDataEventStatus",
+ "mandatory": true
+ }
+ ],
+ "key": "OEM_REF_EM_EV",
+ "type": "Struct",
+ "mandatory": false
+ },
+ {
+ "name": "clusterModeStatus",
+ "params": [
+ {
+ "name": "powerModeActive",
+ "key": "OEM_REF_POW_MOD_ACT",
+ "type": "Boolean",
+ "mandatory": true
+ },
+ {
+ "name": "powerModeQualificationStatus",
+ "key": "OEM_REF_POW_MOD_QU_ST",
+ "type": "PowerModeQualificationStatus",
+ "mandatory": true
+ },
+ {
+ "name": "carModeStatus",
+ "key": "OEM_REF_CAR_MOD_ST",
+ "type": "CarModeStatus",
+ "mandatory": true
+ },
+ {
+ "name": "powerModeStatus",
+ "key": "OEM_REF_POW_MOD_ST",
+ "type": "PowerModeStatus",
+ "mandatory": true
+ }
+ ],
+ "key": "OEM_REF_CL_MOD_ST",
+ "type": "Struct",
+ "mandatory": false
+ },
+ {
+ "name": "myKey",
+ "params": [
+ {
+ "name": "e911Override",
+ "key": "OEM_REF_E_9110_VE",
+ "type": "VehicleDataStatus",
+ "mandatory": true,
+ "since": "2.0"
+ }
+ ],
+ "key": "OEM_REF_MY_KEY",
+ "type": "Struct",
+ "mandatory": false
+ }
+ ]
}
}
}
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();
diff --git a/src/components/formatters/include/formatters/CFormatterJsonBase.h b/src/components/formatters/include/formatters/CFormatterJsonBase.h
index b800ac1559..01c84bfba3 100644
--- a/src/components/formatters/include/formatters/CFormatterJsonBase.h
+++ b/src/components/formatters/include/formatters/CFormatterJsonBase.h
@@ -59,7 +59,7 @@ static const tMetaFormatterErrorCode kErrorOk = 0x0;
static const tMetaFormatterErrorCode kErrorObjectIsNotFunction = 0x01;
/**
- * @brief smart shema describes object which is not function
+ * @brief smart schema describes object which is not function
*/
static const tMetaFormatterErrorCode kErrorSchemaIsNotFunction = 0x02;
diff --git a/src/components/formatters/test/meta_formatter_test.cc b/src/components/formatters/test/meta_formatter_test.cc
index e405ff68eb..5de0b619bf 100644
--- a/src/components/formatters/test/meta_formatter_test.cc
+++ b/src/components/formatters/test/meta_formatter_test.cc
@@ -123,7 +123,7 @@ TEST_F(CMetaFormatterTestHelper,
}
TEST_F(CMetaFormatterTestHelper, ObjectWithEmptyMap) {
- std::map<std::string, CObjectSchemaItem::SMember> schemaMembersMap;
+ std::map<std::string, SMember> schemaMembersMap;
CSmartSchema map_schema =
CSmartSchema(CObjectSchemaItem::create(schemaMembersMap));
@@ -211,67 +211,63 @@ TEST_F(CMetaFormatterTestHelper,
SmartObject result_object;
SmartObject object;
- std::map<std::string, CObjectSchemaItem::SMember> paramsMembersMap;
+ std::map<std::string, SMember> paramsMembersMap;
- paramsMembersMap[S_FUNCTION_ID] = CObjectSchemaItem::SMember(
+ paramsMembersMap[S_FUNCTION_ID] = SMember(
TEnumSchemaItem<FunctionIDTest::eType>::create(function_id_items_), true);
- paramsMembersMap[S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(
+ paramsMembersMap[S_MESSAGE_TYPE] = SMember(
TEnumSchemaItem<MessageTypeTest::eType>::create(message_type_items_),
true);
- paramsMembersMap[S_CORRELATION_ID] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(TSchemaItemParameter<int>(0),
- TSchemaItemParameter<int>(100),
- TSchemaItemParameter<int>(55)),
- true);
+ paramsMembersMap[S_CORRELATION_ID] =
+ SMember(TNumberSchemaItem<int>::create(TSchemaItemParameter<int>(0),
+ TSchemaItemParameter<int>(100),
+ TSchemaItemParameter<int>(55)),
+ true);
- paramsMembersMap[S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(TSchemaItemParameter<int>(1),
- TSchemaItemParameter<int>(2)),
- false);
+ paramsMembersMap[S_PROTOCOL_VERSION] =
+ SMember(TNumberSchemaItem<int>::create(TSchemaItemParameter<int>(1),
+ TSchemaItemParameter<int>(2)),
+ false);
paramsMembersMap[S_PROTOCOL_TYPE] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), false);
+ SMember(TNumberSchemaItem<int>::create(), false);
- std::map<std::string, CObjectSchemaItem::SMember> schemaMembersMap;
+ std::map<std::string, SMember> schemaMembersMap;
- schemaMembersMap["mandatory_emptyMap1"] = CObjectSchemaItem::SMember(
- CObjectSchemaItem::create(
- std::map<std::string, CObjectSchemaItem::SMember>()),
- true);
+ schemaMembersMap["mandatory_emptyMap1"] = SMember(
+ CObjectSchemaItem::create(std::map<std::string, SMember>()), true);
- schemaMembersMap["mandatory_emptyMap2"] = CObjectSchemaItem::SMember(
- CObjectSchemaItem::create(
- std::map<std::string, CObjectSchemaItem::SMember>()),
- true);
+ schemaMembersMap["mandatory_emptyMap2"] = SMember(
+ CObjectSchemaItem::create(std::map<std::string, SMember>()), true);
- schemaMembersMap["mandatory_emptyAray"] = CObjectSchemaItem::SMember(
- CArraySchemaItem::create(TNumberSchemaItem<int>::create()), true);
+ schemaMembersMap["mandatory_emptyAray"] =
+ SMember(CArraySchemaItem::create(TNumberSchemaItem<int>::create()), true);
- schemaMembersMap["non_mandatory_Array"] = CObjectSchemaItem::SMember(
- CArraySchemaItem::create(TNumberSchemaItem<int>::create(),
- TSchemaItemParameter<size_t>(1),
- TSchemaItemParameter<size_t>(2)),
- false);
+ schemaMembersMap["non_mandatory_Array"] =
+ SMember(CArraySchemaItem::create(TNumberSchemaItem<int>::create(),
+ TSchemaItemParameter<size_t>(1),
+ TSchemaItemParameter<size_t>(2)),
+ false);
- schemaMembersMap["mandatory_string"] = CObjectSchemaItem::SMember(
+ schemaMembersMap["mandatory_string"] = SMember(
CStringSchemaItem::create(TSchemaItemParameter<size_t>(0),
TSchemaItemParameter<size_t>(500),
TSchemaItemParameter<std::string>("defValue")),
true);
- schemaMembersMap["non_mandatory_string"] = CObjectSchemaItem::SMember(
- CStringSchemaItem::create(
- TSchemaItemParameter<size_t>(0),
- TSchemaItemParameter<size_t>(500),
- TSchemaItemParameter<std::string>("ignoredDefValue")),
- false);
-
- std::map<std::string, CObjectSchemaItem::SMember> rootMembersMap;
- rootMembersMap[S_MSG_PARAMS] = CObjectSchemaItem::SMember(
- CObjectSchemaItem::create(schemaMembersMap), true);
- rootMembersMap[S_PARAMS] = CObjectSchemaItem::SMember(
- CObjectSchemaItem::create(paramsMembersMap), true);
+ schemaMembersMap["non_mandatory_string"] =
+ SMember(CStringSchemaItem::create(
+ TSchemaItemParameter<size_t>(0),
+ TSchemaItemParameter<size_t>(500),
+ TSchemaItemParameter<std::string>("ignoredDefValue")),
+ false);
+
+ std::map<std::string, SMember> rootMembersMap;
+ rootMembersMap[S_MSG_PARAMS] =
+ SMember(CObjectSchemaItem::create(schemaMembersMap), true);
+ rootMembersMap[S_PARAMS] =
+ SMember(CObjectSchemaItem::create(paramsMembersMap), true);
CSmartSchema schema = CSmartSchema(CObjectSchemaItem::create(rootMembersMap));
diff --git a/src/components/formatters/test/src/SmartFactoryTestHelper.cc b/src/components/formatters/test/src/SmartFactoryTestHelper.cc
index d48f9f58a0..4d089ff9b1 100644
--- a/src/components/formatters/test/src/SmartFactoryTestHelper.cc
+++ b/src/components/formatters/test/src/SmartFactoryTestHelper.cc
@@ -169,27 +169,24 @@ void CSmartFactoryTest::InitFunctionSchemes(
const TStructsSchemaItems& struct_schema_items,
const std::set<FunctionIdTest::eType>& function_id_items,
const std::set<MessageTypeTest::eType>& message_type_items) {
- CObjectSchemaItem::Members params_members;
- params_members[S_FUNCTION_ID] = CObjectSchemaItem::SMember(
+ Members params_members;
+ params_members[S_FUNCTION_ID] = SMember(
TEnumSchemaItem<FunctionIdTest::eType>::create(function_id_items), true);
- params_members[S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(
+ params_members[S_MESSAGE_TYPE] = SMember(
TEnumSchemaItem<MessageTypeTest::eType>::create(message_type_items),
true);
params_members[S_PROTOCOL_VERSION] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ SMember(TNumberSchemaItem<int>::create(), true);
params_members[S_PROTOCOL_TYPE] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ SMember(TNumberSchemaItem<int>::create(), true);
params_members[S_CORRELATION_ID] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
- params_members[kCode] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
- params_members[kMessage] =
- CObjectSchemaItem::SMember(CStringSchemaItem::create(), true);
+ SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[kCode] = SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[kMessage] = SMember(CStringSchemaItem::create(), true);
- CObjectSchemaItem::Members root_members_map;
+ Members root_members_map;
root_members_map[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] =
- CObjectSchemaItem::SMember(CObjectSchemaItem::create(params_members),
- true);
+ SMember(CObjectSchemaItem::create(params_members), true);
CSmartSchema error_response_schema(
CObjectSchemaItem::create(root_members_map));
@@ -240,26 +237,26 @@ void CSmartFactoryTest::InitFunctionSchemes(
CSmartSchema CSmartFactoryTest::InitFunction_Function1_request(
const std::set<FunctionIdTest::eType>& function_id_items,
const std::set<MessageTypeTest::eType>& message_type_items) {
- CObjectSchemaItem::Members schema_members;
- CObjectSchemaItem::Members params_members;
+ Members schema_members;
+ Members params_members;
- params_members[S_FUNCTION_ID] = CObjectSchemaItem::SMember(
+ params_members[S_FUNCTION_ID] = SMember(
TEnumSchemaItem<FunctionIdTest::eType>::create(function_id_items), true);
- params_members[S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(
+ params_members[S_MESSAGE_TYPE] = SMember(
TEnumSchemaItem<MessageTypeTest::eType>::create(message_type_items),
true);
params_members[S_PROTOCOL_VERSION] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ SMember(TNumberSchemaItem<int>::create(), true);
params_members[S_PROTOCOL_TYPE] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ SMember(TNumberSchemaItem<int>::create(), true);
params_members[S_CORRELATION_ID] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ SMember(TNumberSchemaItem<int>::create(), true);
- CObjectSchemaItem::Members root_members_map;
- root_members_map[S_MSG_PARAMS] = CObjectSchemaItem::SMember(
- CObjectSchemaItem::create(schema_members), true);
- root_members_map[S_PARAMS] = CObjectSchemaItem::SMember(
- CObjectSchemaItem::create(params_members), true);
+ Members root_members_map;
+ root_members_map[S_MSG_PARAMS] =
+ SMember(CObjectSchemaItem::create(schema_members), true);
+ root_members_map[S_PARAMS] =
+ SMember(CObjectSchemaItem::create(params_members), true);
return CSmartSchema(CObjectSchemaItem::create(root_members_map));
}
@@ -272,31 +269,29 @@ CSmartSchema CSmartFactoryTest::InitFunction_Function1_response(
std::shared_ptr<ISchemaItem> available_SchemaItem =
CBoolSchemaItem::create(TSchemaItemParameter<bool>());
- CObjectSchemaItem::Members schema_members;
+ Members schema_members;
- schema_members["available"] =
- CObjectSchemaItem::SMember(available_SchemaItem, true);
+ schema_members["available"] = SMember(available_SchemaItem, true);
- CObjectSchemaItem::Members params_members;
- params_members[S_FUNCTION_ID] = CObjectSchemaItem::SMember(
+ Members params_members;
+ params_members[S_FUNCTION_ID] = SMember(
TEnumSchemaItem<FunctionIdTest::eType>::create(function_id_items), true);
- params_members[S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(
+ params_members[S_MESSAGE_TYPE] = SMember(
TEnumSchemaItem<MessageTypeTest::eType>::create(message_type_items),
true);
params_members[S_PROTOCOL_VERSION] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ SMember(TNumberSchemaItem<int>::create(), true);
params_members[S_PROTOCOL_TYPE] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ SMember(TNumberSchemaItem<int>::create(), true);
params_members[S_CORRELATION_ID] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
- params_members[kCode] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[kCode] = SMember(TNumberSchemaItem<int>::create(), true);
- CObjectSchemaItem::Members root_members_map;
- root_members_map[S_MSG_PARAMS] = CObjectSchemaItem::SMember(
- CObjectSchemaItem::create(schema_members), true);
- root_members_map[S_PARAMS] = CObjectSchemaItem::SMember(
- CObjectSchemaItem::create(params_members), true);
+ Members root_members_map;
+ root_members_map[S_MSG_PARAMS] =
+ SMember(CObjectSchemaItem::create(schema_members), true);
+ root_members_map[S_PARAMS] =
+ SMember(CObjectSchemaItem::create(params_members), true);
return CSmartSchema(CObjectSchemaItem::create(root_members_map));
}
@@ -304,26 +299,26 @@ CSmartSchema CSmartFactoryTest::InitFunction_Function1_response(
CSmartSchema CSmartFactoryTest::InitFunction_Function2_request(
const std::set<FunctionIdTest::eType>& function_id_items,
const std::set<MessageTypeTest::eType>& message_type_items) {
- CObjectSchemaItem::Members schema_members;
+ Members schema_members;
- CObjectSchemaItem::Members params_members;
- params_members[S_FUNCTION_ID] = CObjectSchemaItem::SMember(
+ Members params_members;
+ params_members[S_FUNCTION_ID] = SMember(
TEnumSchemaItem<FunctionIdTest::eType>::create(function_id_items), true);
- params_members[S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(
+ params_members[S_MESSAGE_TYPE] = SMember(
TEnumSchemaItem<MessageTypeTest::eType>::create(message_type_items),
true);
params_members[S_PROTOCOL_VERSION] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ SMember(TNumberSchemaItem<int>::create(), true);
params_members[S_PROTOCOL_TYPE] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ SMember(TNumberSchemaItem<int>::create(), true);
params_members[S_CORRELATION_ID] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ SMember(TNumberSchemaItem<int>::create(), true);
- CObjectSchemaItem::Members root_members_map;
- root_members_map[S_MSG_PARAMS] = CObjectSchemaItem::SMember(
- CObjectSchemaItem::create(schema_members), true);
- root_members_map[S_PARAMS] = CObjectSchemaItem::SMember(
- CObjectSchemaItem::create(params_members), true);
+ Members root_members_map;
+ root_members_map[S_MSG_PARAMS] =
+ SMember(CObjectSchemaItem::create(schema_members), true);
+ root_members_map[S_PARAMS] =
+ SMember(CObjectSchemaItem::create(params_members), true);
return CSmartSchema(CObjectSchemaItem::create(root_members_map));
}
@@ -336,31 +331,29 @@ CSmartSchema CSmartFactoryTest::InitFunction_Function2_response(
std::shared_ptr<ISchemaItem> available_SchemaItem =
CBoolSchemaItem::create(TSchemaItemParameter<bool>());
- CObjectSchemaItem::Members schema_members;
+ Members schema_members;
- schema_members["available"] =
- CObjectSchemaItem::SMember(available_SchemaItem, true);
+ schema_members["available"] = SMember(available_SchemaItem, true);
- CObjectSchemaItem::Members params_members;
- params_members[S_FUNCTION_ID] = CObjectSchemaItem::SMember(
+ Members params_members;
+ params_members[S_FUNCTION_ID] = SMember(
TEnumSchemaItem<FunctionIdTest::eType>::create(function_id_items), true);
- params_members[S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(
+ params_members[S_MESSAGE_TYPE] = SMember(
TEnumSchemaItem<MessageTypeTest::eType>::create(message_type_items),
true);
params_members[S_PROTOCOL_VERSION] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ SMember(TNumberSchemaItem<int>::create(), true);
params_members[S_PROTOCOL_TYPE] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ SMember(TNumberSchemaItem<int>::create(), true);
params_members[S_CORRELATION_ID] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
- params_members[kCode] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[kCode] = SMember(TNumberSchemaItem<int>::create(), true);
- CObjectSchemaItem::Members root_members_map;
- root_members_map[S_MSG_PARAMS] = CObjectSchemaItem::SMember(
- CObjectSchemaItem::create(schema_members), true);
- root_members_map[S_PARAMS] = CObjectSchemaItem::SMember(
- CObjectSchemaItem::create(params_members), true);
+ Members root_members_map;
+ root_members_map[S_MSG_PARAMS] =
+ SMember(CObjectSchemaItem::create(schema_members), true);
+ root_members_map[S_PARAMS] =
+ SMember(CObjectSchemaItem::create(params_members), true);
return CSmartSchema(CObjectSchemaItem::create(root_members_map));
}
@@ -368,26 +361,26 @@ CSmartSchema CSmartFactoryTest::InitFunction_Function2_response(
CSmartSchema CSmartFactoryTest::InitFunction_Function3_request(
const std::set<FunctionIdTest::eType>& function_id_items,
const std::set<MessageTypeTest::eType>& message_type_items) {
- CObjectSchemaItem::Members schema_members;
+ Members schema_members;
- CObjectSchemaItem::Members params_members;
- params_members[S_FUNCTION_ID] = CObjectSchemaItem::SMember(
+ Members params_members;
+ params_members[S_FUNCTION_ID] = SMember(
TEnumSchemaItem<FunctionIdTest::eType>::create(function_id_items), true);
- params_members[S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(
+ params_members[S_MESSAGE_TYPE] = SMember(
TEnumSchemaItem<MessageTypeTest::eType>::create(message_type_items),
true);
params_members[S_PROTOCOL_VERSION] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ SMember(TNumberSchemaItem<int>::create(), true);
params_members[S_PROTOCOL_TYPE] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ SMember(TNumberSchemaItem<int>::create(), true);
params_members[S_CORRELATION_ID] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ SMember(TNumberSchemaItem<int>::create(), true);
- CObjectSchemaItem::Members root_members_map;
- root_members_map[S_MSG_PARAMS] = CObjectSchemaItem::SMember(
- CObjectSchemaItem::create(schema_members), true);
- root_members_map[S_PARAMS] = CObjectSchemaItem::SMember(
- CObjectSchemaItem::create(params_members), true);
+ Members root_members_map;
+ root_members_map[S_MSG_PARAMS] =
+ SMember(CObjectSchemaItem::create(schema_members), true);
+ root_members_map[S_PARAMS] =
+ SMember(CObjectSchemaItem::create(params_members), true);
return CSmartSchema(CObjectSchemaItem::create(root_members_map));
}
@@ -402,31 +395,29 @@ CSmartSchema CSmartFactoryTest::InitFunction_Function3_response(
std::shared_ptr<ISchemaItem> available_SchemaItem =
CBoolSchemaItem::create(TSchemaItemParameter<bool>());
- CObjectSchemaItem::Members schema_members;
+ Members schema_members;
- schema_members["available"] =
- CObjectSchemaItem::SMember(available_SchemaItem, true);
+ schema_members["available"] = SMember(available_SchemaItem, true);
- CObjectSchemaItem::Members params_members;
- params_members[S_FUNCTION_ID] = CObjectSchemaItem::SMember(
+ Members params_members;
+ params_members[S_FUNCTION_ID] = SMember(
TEnumSchemaItem<FunctionIdTest::eType>::create(function_id_items), true);
- params_members[S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(
+ params_members[S_MESSAGE_TYPE] = SMember(
TEnumSchemaItem<MessageTypeTest::eType>::create(message_type_items),
true);
params_members[S_PROTOCOL_VERSION] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ SMember(TNumberSchemaItem<int>::create(), true);
params_members[S_PROTOCOL_TYPE] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ SMember(TNumberSchemaItem<int>::create(), true);
params_members[S_CORRELATION_ID] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
- params_members[kCode] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[kCode] = SMember(TNumberSchemaItem<int>::create(), true);
- CObjectSchemaItem::Members root_members_map;
- root_members_map[S_MSG_PARAMS] = CObjectSchemaItem::SMember(
- CObjectSchemaItem::create(schema_members), true);
- root_members_map[S_PARAMS] = CObjectSchemaItem::SMember(
- CObjectSchemaItem::create(params_members), true);
+ Members root_members_map;
+ root_members_map[S_MSG_PARAMS] =
+ SMember(CObjectSchemaItem::create(schema_members), true);
+ root_members_map[S_PARAMS] =
+ SMember(CObjectSchemaItem::create(params_members), true);
return CSmartSchema(CObjectSchemaItem::create(root_members_map));
}
@@ -455,20 +446,19 @@ std::shared_ptr<ISchemaItem> CSmartFactoryTest::InitStructSchemaItem_Common_1(
TNumberSchemaItem<int32_t>::create(TSchemaItemParameter<int32_t>(1),
TSchemaItemParameter<int32_t>(500),
TSchemaItemParameter<int32_t>());
- CObjectSchemaItem::Members struct_members;
- struct_members["image"] = CObjectSchemaItem::SMember(image_SchemaItem, false);
+ Members struct_members;
+ struct_members["image"] = SMember(image_SchemaItem, false);
- CObjectSchemaItem::Members schema_members;
+ Members schema_members;
- schema_members["text"] = CObjectSchemaItem::SMember(text_SchemaItem, true);
- schema_members["position"] =
- CObjectSchemaItem::SMember(position_SchemaItem, true);
+ schema_members["text"] = SMember(text_SchemaItem, true);
+ schema_members["position"] = SMember(position_SchemaItem, true);
- CObjectSchemaItem::Members root_members_map;
- root_members_map[""] = CObjectSchemaItem::SMember(
- CObjectSchemaItem::create(struct_members), true);
- root_members_map[""] = CObjectSchemaItem::SMember(
- CObjectSchemaItem::create(schema_members), true);
+ Members root_members_map;
+ root_members_map[""] =
+ SMember(CObjectSchemaItem::create(struct_members), true);
+ root_members_map[""] =
+ SMember(CObjectSchemaItem::create(schema_members), true);
return CObjectSchemaItem::create(schema_members);
}
@@ -489,10 +479,9 @@ CSmartFactoryTest::InitStructSchemaItem_Common_2() {
TSchemaItemParameter<int32_t>(500),
TSchemaItemParameter<int32_t>());
- CObjectSchemaItem::Members schema_members;
- schema_members["text"] = CObjectSchemaItem::SMember(text_SchemaItem, true);
- schema_members["position"] =
- CObjectSchemaItem::SMember(position_SchemaItem, true);
+ Members schema_members;
+ schema_members["text"] = SMember(text_SchemaItem, true);
+ schema_members["position"] = SMember(position_SchemaItem, true);
return CObjectSchemaItem::create(schema_members);
}
diff --git a/src/components/formatters/test/src/create_smartSchema.cc b/src/components/formatters/test/src/create_smartSchema.cc
index 3602fc3de7..c852c65ea1 100644
--- a/src/components/formatters/test/src/create_smartSchema.cc
+++ b/src/components/formatters/test/src/create_smartSchema.cc
@@ -189,39 +189,36 @@ CSmartSchema initObjectSchema() {
TSchemaItemParameter<int>());
// Map of parameters
- std::map<std::string, CObjectSchemaItem::SMember> schemaMembersMap;
+ std::map<std::string, SMember> schemaMembersMap;
- schemaMembersMap["success"] =
- CObjectSchemaItem::SMember(success_SchemaItem, false);
- schemaMembersMap["resultCode"] =
- CObjectSchemaItem::SMember(resultCode_SchemaItem, false);
- schemaMembersMap["info"] = CObjectSchemaItem::SMember(info_SchemaItem, false);
- schemaMembersMap["tryAgainTime"] =
- CObjectSchemaItem::SMember(tryAgainTime_SchemaItem, false);
+ schemaMembersMap["success"] = SMember(success_SchemaItem, false);
+ schemaMembersMap["resultCode"] = SMember(resultCode_SchemaItem, false);
+ schemaMembersMap["info"] = SMember(info_SchemaItem, false);
+ schemaMembersMap["tryAgainTime"] = SMember(tryAgainTime_SchemaItem, false);
- std::map<std::string, CObjectSchemaItem::SMember> paramsMembersMap;
+ std::map<std::string, SMember> paramsMembersMap;
paramsMembersMap[S_FUNCTION_ID] =
- CObjectSchemaItem::SMember(TEnumSchemaItem<FunctionIDTest::eType>::create(
- functionId_allowedEnumSubsetValues),
- true);
- paramsMembersMap[S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(
- TEnumSchemaItem<MessageTypeTest::eType>::create(
- messageType_allowedEnumSubsetValues),
- true);
+ SMember(TEnumSchemaItem<FunctionIDTest::eType>::create(
+ functionId_allowedEnumSubsetValues),
+ true);
+ paramsMembersMap[S_MESSAGE_TYPE] =
+ SMember(TEnumSchemaItem<MessageTypeTest::eType>::create(
+ messageType_allowedEnumSubsetValues),
+ true);
paramsMembersMap[S_CORRELATION_ID] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
- paramsMembersMap[S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(TSchemaItemParameter<int>(1),
- TSchemaItemParameter<int>(2)),
- true);
+ SMember(TNumberSchemaItem<int>::create(), true);
+ paramsMembersMap[S_PROTOCOL_VERSION] =
+ SMember(TNumberSchemaItem<int>::create(TSchemaItemParameter<int>(1),
+ TSchemaItemParameter<int>(2)),
+ true);
paramsMembersMap[S_PROTOCOL_TYPE] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ SMember(TNumberSchemaItem<int>::create(), true);
- std::map<std::string, CObjectSchemaItem::SMember> rootMembersMap;
- rootMembersMap[S_MSG_PARAMS] = CObjectSchemaItem::SMember(
- CObjectSchemaItem::create(schemaMembersMap), true);
- rootMembersMap[S_PARAMS] = CObjectSchemaItem::SMember(
- CObjectSchemaItem::create(paramsMembersMap), true);
+ std::map<std::string, SMember> rootMembersMap;
+ rootMembersMap[S_MSG_PARAMS] =
+ SMember(CObjectSchemaItem::create(schemaMembersMap), true);
+ rootMembersMap[S_PARAMS] =
+ SMember(CObjectSchemaItem::create(paramsMembersMap), true);
return CSmartSchema(CObjectSchemaItem::create(rootMembersMap));
};
@@ -294,9 +291,9 @@ CSmartSchema initSchemaForMetaFormatter() {
speechCapabilities_allowedEnumSubsetValues,
TSchemaItemParameter<SpeechCapabilities::eType>());
- std::map<std::string, CObjectSchemaItem::SMember> ttsMap;
- ttsMap["text"] = CObjectSchemaItem::SMember(ttsNameItem_SchemaItem, false);
- ttsMap["type"] = CObjectSchemaItem::SMember(ttstype_SchemaItem, false);
+ std::map<std::string, SMember> ttsMap;
+ ttsMap["text"] = SMember(ttsNameItem_SchemaItem, false);
+ ttsMap["type"] = SMember(ttstype_SchemaItem, false);
;
ISchemaItemPtr hmiDisplayLanguageDesired_SchemaItem =
@@ -350,62 +347,57 @@ CSmartSchema initSchemaForMetaFormatter() {
TSchemaItemParameter<size_t>(1000));
// Creation map for syncMsgVersion
- std::map<std::string, CObjectSchemaItem::SMember> schemaSyncMsgVersionMap;
+ std::map<std::string, SMember> schemaSyncMsgVersionMap;
schemaSyncMsgVersionMap["majorVersion"] =
- CObjectSchemaItem::SMember(majorVersion_SchemaItem, false);
+ SMember(majorVersion_SchemaItem, false);
schemaSyncMsgVersionMap["minorVersion"] =
- CObjectSchemaItem::SMember(minorVersion_SchemaItem, false);
+ SMember(minorVersion_SchemaItem, false);
schemaSyncMsgVersionMap["patchVersion"] =
- CObjectSchemaItem::SMember(patchVersion_SchemaItem, false);
+ SMember(patchVersion_SchemaItem, false);
;
// Map of parameters
- std::map<std::string, CObjectSchemaItem::SMember> schemaMembersMap;
-
- schemaMembersMap["appID"] =
- CObjectSchemaItem::SMember(appID_SchemaItem, false);
- schemaMembersMap["appName"] =
- CObjectSchemaItem::SMember(appName_SchemaItem, false);
- schemaMembersMap["appType"] =
- CObjectSchemaItem::SMember(appType_SchemaItem, false);
+ std::map<std::string, SMember> schemaMembersMap;
+
+ schemaMembersMap["appID"] = SMember(appID_SchemaItem, false);
+ schemaMembersMap["appName"] = SMember(appName_SchemaItem, false);
+ schemaMembersMap["appType"] = SMember(appType_SchemaItem, false);
schemaMembersMap["hmiDisplayLanguageDesired"] =
- CObjectSchemaItem::SMember(hmiDisplayLanguageDesired_SchemaItem, false);
+ SMember(hmiDisplayLanguageDesired_SchemaItem, false);
schemaMembersMap["isMediaApplication"] =
- CObjectSchemaItem::SMember(isMediaApplication_SchemaItem, false);
+ SMember(isMediaApplication_SchemaItem, false);
schemaMembersMap["languageDesired"] =
- CObjectSchemaItem::SMember(languageDesired_SchemaItem, false);
+ SMember(languageDesired_SchemaItem, false);
schemaMembersMap["ngnMediaScreenAppName"] =
- CObjectSchemaItem::SMember(ngnMediaScreenAppName_SchemaItem, false);
- schemaMembersMap["syncMsgVersion"] = CObjectSchemaItem::SMember(
- CObjectSchemaItem::create(schemaSyncMsgVersionMap), false);
- schemaMembersMap["ttsName"] =
- CObjectSchemaItem::SMember(ttsName_SchemaItem, false);
- schemaMembersMap["vrSynonyms"] =
- CObjectSchemaItem::SMember(vrSynonyms_SchemaItem, false);
-
- std::map<std::string, CObjectSchemaItem::SMember> paramsMembersMap;
+ SMember(ngnMediaScreenAppName_SchemaItem, false);
+ schemaMembersMap["syncMsgVersion"] =
+ SMember(CObjectSchemaItem::create(schemaSyncMsgVersionMap), false);
+ schemaMembersMap["ttsName"] = SMember(ttsName_SchemaItem, false);
+ schemaMembersMap["vrSynonyms"] = SMember(vrSynonyms_SchemaItem, false);
+
+ std::map<std::string, SMember> paramsMembersMap;
paramsMembersMap[S_FUNCTION_ID] =
- CObjectSchemaItem::SMember(TEnumSchemaItem<FunctionIDTest::eType>::create(
- functionId_allowedEnumSubsetValues),
- true);
- paramsMembersMap[S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(
- TEnumSchemaItem<MessageTypeTest::eType>::create(
- messageType_allowedEnumSubsetValues),
- true);
+ SMember(TEnumSchemaItem<FunctionIDTest::eType>::create(
+ functionId_allowedEnumSubsetValues),
+ true);
+ paramsMembersMap[S_MESSAGE_TYPE] =
+ SMember(TEnumSchemaItem<MessageTypeTest::eType>::create(
+ messageType_allowedEnumSubsetValues),
+ true);
paramsMembersMap[S_CORRELATION_ID] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
- paramsMembersMap[S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(TSchemaItemParameter<int>(1),
- TSchemaItemParameter<int>(2)),
- true);
+ SMember(TNumberSchemaItem<int>::create(), true);
+ paramsMembersMap[S_PROTOCOL_VERSION] =
+ SMember(TNumberSchemaItem<int>::create(TSchemaItemParameter<int>(1),
+ TSchemaItemParameter<int>(2)),
+ true);
paramsMembersMap[S_PROTOCOL_TYPE] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ SMember(TNumberSchemaItem<int>::create(), true);
- std::map<std::string, CObjectSchemaItem::SMember> rootMembersMap;
- rootMembersMap[S_MSG_PARAMS] = CObjectSchemaItem::SMember(
- CObjectSchemaItem::create(schemaMembersMap), true);
- rootMembersMap[S_PARAMS] = CObjectSchemaItem::SMember(
- CObjectSchemaItem::create(paramsMembersMap), true);
+ std::map<std::string, SMember> rootMembersMap;
+ rootMembersMap[S_MSG_PARAMS] =
+ SMember(CObjectSchemaItem::create(schemaMembersMap), true);
+ rootMembersMap[S_PARAMS] =
+ SMember(CObjectSchemaItem::create(paramsMembersMap), true);
return CSmartSchema(CObjectSchemaItem::create(rootMembersMap));
};
diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h
index 1e17974da4..e4a0417e40 100644
--- a/src/components/include/application_manager/application_manager.h
+++ b/src/components/include/application_manager/application_manager.h
@@ -38,7 +38,6 @@
#include <string>
#include <vector>
#include "application_manager/application.h"
-#include "application_manager/command_factory.h"
#include "application_manager/commands/command.h"
#include "connection_handler/connection_handler.h"
#include "utils/data_accessor.h"
@@ -46,7 +45,6 @@
#include "application_manager/application_manager_settings.h"
#include "application_manager/hmi_interfaces.h"
#include "application_manager/plugin_manager/rpc_plugin_manager.h"
-#include "application_manager/policies/policy_handler_interface.h"
#include "application_manager/state_controller.h"
#include "policy/policy_types.h"
#include "telemetry_monitor/telemetry_observable.h"
@@ -76,6 +74,10 @@ namespace resumption {
class ResumeCtrl;
}
+namespace policy {
+class PolicyHandlerInterface;
+}
+
namespace application_manager {
namespace event_engine {
@@ -460,8 +462,7 @@ class ApplicationManager {
* @param vehicle_info Enum value of type of vehicle data
* @param new value (for integer values currently) of vehicle data
*/
- virtual void IviInfoUpdated(mobile_apis::VehicleDataType::eType vehicle_info,
- int value) = 0;
+ virtual void IviInfoUpdated(const std::string& vehicle_info, int value) = 0;
virtual ApplicationSharedPtr RegisterApplication(
const std::shared_ptr<smart_objects::SmartObject>&
diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h
index 6c08dbcb0b..f6ecd050ae 100644
--- a/src/components/include/application_manager/policies/policy_handler_interface.h
+++ b/src/components/include/application_manager/policies/policy_handler_interface.h
@@ -41,6 +41,7 @@
#include "boost/optional.hpp"
#include "application_manager/application.h"
+#include "application_manager/policies/custom_vehicle_data_provider.h"
#include "application_manager/policies/policy_encryption_flag_getter.h"
#include "application_manager/policies/policy_handler_observer.h"
#include "interfaces/MOBILE_API.h"
@@ -65,7 +66,7 @@ typedef std::shared_ptr<PolicyEncryptionFlagGetterInterface>
class PTURetryHandler;
-class PolicyHandlerInterface {
+class PolicyHandlerInterface : public VehicleDataItemProvider {
public:
virtual ~PolicyHandlerInterface() {}
@@ -123,6 +124,7 @@ class PolicyHandlerInterface {
EndpointUrls& out_end_points) = 0;
virtual void GetUpdateUrls(const uint32_t service_type,
EndpointUrls& out_end_points) = 0;
+ virtual Json::Value GetPolicyTableData() const = 0;
virtual std::string GetLockScreenIconUrl() const = 0;
virtual std::string GetIconUrl(const std::string& policy_app_id) const = 0;
virtual uint32_t NextRetryTimeout() = 0;
@@ -471,12 +473,6 @@ class PolicyHandlerInterface {
const std::string& policy_app_id) const = 0;
/**
- * @brief Gets vehicle information
- * @return Structure with vehicle information
- */
- virtual const VehicleInfo GetVehicleInfo() const = 0;
-
- /**
* @brief Get a list of enabled cloud applications
* @param enabled_apps List filled with the policy app id of each enabled
* cloud application
diff --git a/src/components/include/application_manager/rpc_handler.h b/src/components/include/application_manager/rpc_handler.h
index f42d7deb2f..aafb81b853 100644
--- a/src/components/include/application_manager/rpc_handler.h
+++ b/src/components/include/application_manager/rpc_handler.h
@@ -38,11 +38,14 @@
#ifdef TELEMETRY_MONITOR
#include "application_manager/telemetry_observer.h"
+#include "telemetry_monitor/telemetry_observable.h"
#endif // TELEMETRY_MONITOR
namespace application_manager {
namespace rpc_handler {
+using ns_smart_device_link::ns_smart_objects::SMember;
+
class RPCHandler
: public hmi_message_handler::HMIMessageObserver,
public protocol_handler::ProtocolObserver
diff --git a/src/components/include/application_manager/rpc_service.h b/src/components/include/application_manager/rpc_service.h
index d052c4ed0a..fb1d280880 100644
--- a/src/components/include/application_manager/rpc_service.h
+++ b/src/components/include/application_manager/rpc_service.h
@@ -36,11 +36,16 @@
#include "application_manager/commands/command.h"
#include "application_manager/message.h"
#include "hmi_message_handler/hmi_message_handler.h"
+#include "interfaces/HMI_API_schema.h"
+#include "interfaces/MOBILE_API_schema.h"
#include "protocol_handler/protocol_handler.h"
+#include "smart_objects/object_schema_item.h"
namespace application_manager {
namespace rpc_service {
+using ns_smart_device_link::ns_smart_objects::SMember;
+
class RPCService {
public:
virtual ~RPCService() {}
@@ -81,12 +86,21 @@ class RPCService {
* to app services or handled by app services plugin)
* @param function_id RPC function id
* @param source RPC command source
- * @param rpc_passing Reference to bool. Set to true to enable rpc pasing
* @return true if App Services can handle RPC
*/
virtual bool IsAppServiceRPC(int32_t function_id,
commands::Command::CommandSource source) = 0;
+ virtual void UpdateMobileRPCParams(
+ const mobile_apis::FunctionID::eType& function_id,
+ const mobile_apis::messageType::eType& message_type,
+ const std::map<std::string, SMember>& members) = 0;
+
+ virtual void UpdateHMIRPCParams(
+ const hmi_apis::FunctionID::eType& function_id,
+ const hmi_apis::messageType::eType& message_type,
+ const std::map<std::string, SMember>& members) = 0;
+
/**
* @brief set_protocol_handler
* @param handler
diff --git a/src/components/include/hmi_message_handler/hmi_message_adapter.h b/src/components/include/hmi_message_handler/hmi_message_adapter.h
index 704cc619be..af8cddcf32 100644
--- a/src/components/include/hmi_message_handler/hmi_message_adapter.h
+++ b/src/components/include/hmi_message_handler/hmi_message_adapter.h
@@ -53,7 +53,7 @@ class HMIMessageAdapter : public HMIMessageSender {
/**
* \brief Interface for subscriptions.
* Each class implementing interface should use it according to
- * standarts of transport for which it is to be an adapter.
+ * standards of transport for which it is to be an adapter.
* For example, Adapter for MessageBroker will use it to subscribe to
* notifications
* from HMI.
diff --git a/src/components/include/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h
index bf0e03b0b8..cce52da626 100644
--- a/src/components/include/policy/policy_external/policy/policy_manager.h
+++ b/src/components/include/policy/policy_external/policy/policy_manager.h
@@ -568,10 +568,17 @@ class PolicyManager : public usage_statistics::StatisticsManager,
const std::string& policy_app_id) const = 0;
/**
- * @brief Get information about vehicle
- * @return vehicle information
+ * @brief Gets vehicle data items
+ * @return Structure with vehicle data items
*/
- virtual const VehicleInfo GetVehicleInfo() const = 0;
+ virtual const std::vector<policy_table::VehicleDataItem> GetVehicleDataItems()
+ const = 0;
+
+ /**
+ * @brief Gets copy of current policy table data
+ * @return policy_table as json object
+ */
+ virtual Json::Value GetPolicyTableData() const = 0;
/**
* @brief Get a list of enabled cloud applications
diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h
index 27ae18eca8..def0a3660e 100644
--- a/src/components/include/policy/policy_regular/policy/policy_manager.h
+++ b/src/components/include/policy/policy_regular/policy/policy_manager.h
@@ -544,12 +544,18 @@ class PolicyManager : public usage_statistics::StatisticsManager,
const std::string& policy_app_id) const = 0;
/**
- * @brief Get information about vehicle
- * @return vehicle information
+ * @brief Gets vehicle data items
+ * @return Structure with vehicle data items
*/
- virtual const VehicleInfo GetVehicleInfo() const = 0;
+ virtual const std::vector<policy_table::VehicleDataItem> GetVehicleDataItems()
+ const = 0;
/**
+ * @brief Gets copy of current policy table data
+ * @return policy_table as json object
+ */
+ virtual Json::Value GetPolicyTableData() const = 0;
+ /**
* @brief Get a list of enabled cloud applications
* @param enabled_apps List filled with the policy app id of each enabled
* cloud application
diff --git a/src/components/include/test/application_manager/mock_application_manager.h b/src/components/include/test/application_manager/mock_application_manager.h
index 60ee73c996..c05a082e5b 100644
--- a/src/components/include/test/application_manager/mock_application_manager.h
+++ b/src/components/include/test/application_manager/mock_application_manager.h
@@ -194,8 +194,7 @@ class MockApplicationManager : public application_manager::ApplicationManager {
MOCK_METHOD1(SetIconFileFromSystemRequest, void(const std::string policy_id));
MOCK_CONST_METHOD0(IsHMICooperating, bool());
MOCK_METHOD2(IviInfoUpdated,
- void(mobile_apis::VehicleDataType::eType vehicle_info,
- int value));
+ void(const std::string& vehicle_info, int value));
MOCK_METHOD1(RegisterApplication,
application_manager::ApplicationSharedPtr(
const std::shared_ptr<smart_objects::SmartObject>&
diff --git a/src/components/include/test/application_manager/mock_rpc_service.h b/src/components/include/test/application_manager/mock_rpc_service.h
index fbdc451265..bdbd3d17c7 100644
--- a/src/components/include/test/application_manager/mock_rpc_service.h
+++ b/src/components/include/test/application_manager/mock_rpc_service.h
@@ -3,11 +3,14 @@
#include "application_manager/rpc_service.h"
#include "gmock/gmock.h"
+#include "smart_objects/object_schema_item.h"
namespace test {
namespace components {
namespace application_manager_test {
+using ns_smart_device_link::ns_smart_objects::SMember;
+
class MockRPCService : public application_manager::rpc_service::RPCService {
public:
MOCK_METHOD2(
@@ -31,6 +34,15 @@ class MockRPCService : public application_manager::rpc_service::RPCService {
IsAppServiceRPC,
bool(int32_t function_id,
application_manager::commands::Command::CommandSource source));
+ MOCK_METHOD3(UpdateMobileRPCParams,
+ void(const mobile_apis::FunctionID::eType& function_id,
+ const mobile_apis::messageType::eType& message_type,
+ const std::map<std::string, SMember>& members));
+
+ MOCK_METHOD3(UpdateHMIRPCParams,
+ void(const hmi_apis::FunctionID::eType& function_id,
+ const hmi_apis::messageType::eType& message_type,
+ const std::map<std::string, SMember>& members));
};
} // namespace application_manager_test
} // namespace components
diff --git a/src/components/include/test/application_manager/policies/mock_custom_vehicle_data_provider.h b/src/components/include/test/application_manager/policies/mock_custom_vehicle_data_provider.h
new file mode 100644
index 0000000000..b6533521ed
--- /dev/null
+++ b/src/components/include/test/application_manager/policies/mock_custom_vehicle_data_provider.h
@@ -0,0 +1,21 @@
+#ifndef MOCK_CUSTOM_VEHICLE_DATA_MANAGER_H
+#define MOCK_CUSTOM_VEHICLE_DATA_MANAGER_H
+
+#include "application_manager/policies/custom_vehicle_data_provider.h"
+#include "gmock/gmock.h"
+
+namespace test {
+namespace components {
+namespace policy_test {
+
+class MockCustomVehicleDataProvider : public policy::VehicleDataItemProvider {
+ public:
+ MOCK_CONST_METHOD0(
+ GetVehicleDataItems,
+ const std::vector<rpc::policy_table_interface_base::VehicleDataItem>());
+};
+
+} // namespace policy_test
+} // namespace components
+} // namespace test
+#endif // MOCK_CUSTOM_VEHICLE_DATA_MANAGER_H
diff --git a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h
index defdad38f7..3b6a4af54d 100644
--- a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h
+++ b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h
@@ -69,6 +69,10 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface {
void(const std::string& device_id,
const std::string& policy_app_id,
const policy::Permissions& permissions));
+ MOCK_CONST_METHOD0(GetPolicyTableData, Json::Value());
+ MOCK_CONST_METHOD0(
+ GetVehicleDataItems,
+ const std::vector<rpc::policy_table_interface_base::VehicleDataItem>());
#ifdef EXTERNAL_PROPRIETARY_MODE
MOCK_METHOD3(OnSnapshotCreated,
@@ -234,7 +238,6 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface {
const std::vector<std::string>(
const transport_manager::DeviceHandle& device_handle,
const std::string& policy_app_id));
- MOCK_CONST_METHOD0(GetVehicleInfo, const policy::VehicleInfo());
MOCK_CONST_METHOD1(GetEnabledCloudApps,
void(std::vector<std::string>& enabled_apps));
MOCK_CONST_METHOD1(CheckCloudAppEnabled,
diff --git a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h
index 938be4eb85..35b01d20c1 100644
--- a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h
+++ b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h
@@ -76,7 +76,9 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface {
MOCK_METHOD0(TimeoutResponse, int());
MOCK_METHOD1(SecondsBetweenRetries, bool(std::vector<int>& seconds));
MOCK_CONST_METHOD1(IsDeviceConsentCached, bool(const std::string& device_id));
- MOCK_CONST_METHOD0(GetVehicleInfo, const VehicleInfo());
+ MOCK_CONST_METHOD0(GetPolicyTableData, Json::Value());
+ MOCK_CONST_METHOD0(GetVehicleDataItems,
+ const std::vector<policy_table::VehicleDataItem>());
MOCK_CONST_METHOD1(GetEnabledCloudApps,
void(std::vector<std::string>& enabled_apps));
MOCK_CONST_METHOD7(GetCloudAppParameters,
diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h
index cfe5844757..455954795f 100644
--- a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h
+++ b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h
@@ -218,7 +218,9 @@ class MockPolicyManager : public PolicyManager {
const std::vector<std::string>(
const transport_manager::DeviceHandle& device_handle,
const std::string policy_app_id));
- MOCK_CONST_METHOD0(GetVehicleInfo, const policy::VehicleInfo());
+ MOCK_CONST_METHOD0(GetPolicyTableData, Json::Value());
+ MOCK_CONST_METHOD0(GetVehicleDataItems,
+ const std::vector<policy_table::VehicleDataItem>());
MOCK_CONST_METHOD1(GetEnabledCloudApps,
void(std::vector<std::string>& enabled_apps));
MOCK_CONST_METHOD7(GetCloudAppParameters,
diff --git a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h
index 194445b8b6..d3da4d74c3 100644
--- a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h
+++ b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h
@@ -62,7 +62,9 @@ class MockCacheManagerInterface : public CacheManagerInterface {
MOCK_METHOD0(ResetIgnitionCycles, void());
MOCK_METHOD0(TimeoutResponse, int());
MOCK_METHOD1(SecondsBetweenRetries, bool(std::vector<int>& seconds));
- MOCK_CONST_METHOD0(GetVehicleInfo, const VehicleInfo());
+ MOCK_CONST_METHOD0(GetPolicyTableData, Json::Value());
+ MOCK_CONST_METHOD0(GetVehicleDataItems,
+ const std::vector<policy_table::VehicleDataItem>());
MOCK_CONST_METHOD1(GetEnabledCloudApps,
void(std::vector<std::string>& enabled_apps));
MOCK_CONST_METHOD7(GetCloudAppParameters,
diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h
index d23674c060..a446128cad 100644
--- a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h
+++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h
@@ -213,7 +213,9 @@ class MockPolicyManager : public PolicyManager {
MOCK_CONST_METHOD1(
GetAppRequestTypes,
const std::vector<std::string>(const std::string policy_app_id));
- MOCK_CONST_METHOD0(GetVehicleInfo, const policy::VehicleInfo());
+ MOCK_CONST_METHOD0(GetPolicyTableData, Json::Value());
+ MOCK_CONST_METHOD0(GetVehicleDataItems,
+ const std::vector<policy_table::VehicleDataItem>());
MOCK_CONST_METHOD1(GetEnabledCloudApps,
void(std::vector<std::string>& enabled_apps));
MOCK_CONST_METHOD7(GetCloudAppParameters,
diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml
index ff4947e7a8..9afb64b174 100644
--- a/src/components/interfaces/HMI_API.xml
+++ b/src/components/interfaces/HMI_API.xml
@@ -1160,6 +1160,7 @@
<element name="VEHICLEDATA_ENGINEOILLIFE" />
<element name="VEHICLEDATA_ELECTRONICPARKBRAKESTATUS" />
<element name="VEHICLEDATA_CLOUDAPPVEHICLEID" />
+ <element name="VEHICLEDATA_OEM_CUSTOM_DATA" />
</enum>
<enum name="WiperStatus">
@@ -6489,6 +6490,9 @@
<param name="cloudAppVehicleID" type="String" mandatory="false">
<description>Parameter used by cloud apps to identify a head unit</description>
</param>
+ <param name="engineOilLife" type="Float" minvalue="0" maxvalue="100" mandatory="false">
+ <description>The estimated percentage of remaining oil life of the engine.</description>
+ </param>
<!-- Ford Specific Data Items -->
<param name="eCallInfo" type="Common.ECallInfo" mandatory="false">
@@ -6671,18 +6675,26 @@
<param name="statisticType" type="Common.StatisticsType" mandatory="true"/>
</function>
- <function name="GetURLS" messagetype="request" scope="internal">
- <description>Sent by system to SDL to get list of URL for specified service type and optionally policy's application id.</description>
- <param name="service" type="Integer" minvalue="0" maxvalue="100" mandatory="true"/>
- </function>
- <function name="GetURLS" messagetype="response" scope="internal">
- <param name="urls" type="Common.ServiceInfo" array="true" mandatory="false" minsize="1" maxsize="100"/>
- </function>
<function name="OnDeviceStateChanged" messagetype="notification" scope="internal">
<param name="deviceState" type="Common.DeviceState" mandatory="true" />
<param name="deviceInternalId" type="String" mandatory="true" minlength="0" maxlength="500" />
<param name="deviceId" type="Common.DeviceInfo" mandatory="false"/>
</function>
+
+ <function name="GetPolicyConfigurationData" messagetype="request" scope="internal">
+ <description>Request from HMI to SDL core to get policy configuration data (i.e. OEM Network Mapping table file version etc.) from Policy Table.</description>
+ <param name="policyType" type="String" minlength="1" maxlength="1000" mandatory="true">
+ <description>Name of the Struct where configuration data is located in Policy Table, i.e. module_config etc.</description>
+ </param>
+ <param name="property" type="String" minlength="1" maxlength="1000" mandatory="true">
+ <description>Name of the property located within the policyType Struct, i.e. vehicle_year etc.</description>
+ </param>
+ </function>
+ <function name="GetPolicyConfigurationData" messagetype="response">
+ <param name="value" type="String" array="true" maxlength="1000" minsize="1" maxsize="100" mandatory="false">
+ <description>Value of requested property from policyType in PT. If no value is found in PT for specified policyType and property, this parameter will be omitted.</description>
+ </param>
+ </function>
</interface>
<interface name="RC" version="2.0.0" date="2018-09-05">
diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml
index d4cae5249d..b74ee7f384 100644
--- a/src/components/interfaces/MOBILE_API.xml
+++ b/src/components/interfaces/MOBILE_API.xml
@@ -568,6 +568,7 @@
<element name="VEHICLEDATA_ENGINEOILLIFE" since="5.0" />
<element name="VEHICLEDATA_ELECTRONICPARKBRAKESTATUS" since="5.0" />
<element name="VEHICLEDATA_CLOUDAPPVEHICLEID" since="5.1"/>
+ <element name="VEHICLEDATA_OEM_CUSTOM_DATA" since="6.0"/>
</enum>
<enum name="HybridAppPreference" since="5.1">
@@ -2090,6 +2091,9 @@
<param name="resultCode" type="VehicleDataResultCode" mandatory="true">
<description>Published data result code.</description>
</param>
+ <param name="oemCustomDataType" type="String" mandatory="false" since="6.0">
+ <description>Type of requested oem specific parameter </description>
+ </param>
</struct>
<struct name="DIDResult" since="2.0">
diff --git a/src/components/media_manager/CMakeLists.txt b/src/components/media_manager/CMakeLists.txt
index 6a582b4e3b..50c9fce20a 100644
--- a/src/components/media_manager/CMakeLists.txt
+++ b/src/components/media_manager/CMakeLists.txt
@@ -65,6 +65,7 @@ set(EXCLUDE_PATHS
set(LIBRARIES
MOBILE_API
ProtocolLibrary
+ PolicyStatic
Utils
)
diff --git a/src/components/policy/policy_external/CMakeLists.txt b/src/components/policy/policy_external/CMakeLists.txt
index 80c3cb60e6..361c48a598 100644
--- a/src/components/policy/policy_external/CMakeLists.txt
+++ b/src/components/policy/policy_external/CMakeLists.txt
@@ -28,6 +28,8 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
+include(${CMAKE_SOURCE_DIR}/tools/cmake/helpers/generators.cmake)
+
# --- Policy
set(install_destination bin)
set(copy_destination ${CMAKE_BINARY_DIR}/src/appMain)
@@ -36,13 +38,16 @@ set(library_name ${CMAKE_SHARED_LIBRARY_PREFIX}Policy${CMAKE_SHARED_LIBRARY_SUFF
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
include_directories (
- include
- ${COMPONENTS_DIR}/rpc_base/include
+ ${POLICY_PATH}/include/
+ ${COMPONENTS_DIR}/
${COMPONENTS_DIR}/utils/include/
${COMPONENTS_DIR}/config_profile/include
+ ${COMPONENTS_DIR}/smart_objects/include/
+ ${COMPONENTS_DIR}/rpc_base/include
+ ${CMAKE_BINARY_DIR}/src/components/
${POLICY_GLOBAL_INCLUDE_PATH}/
- ${LOG4CXX_INCLUDE_DIRECTORY}
${BOOST_INCLUDE_DIR}
+ ${LOG4CXX_INCLUDE_DIRECTORY}
${JSONCPP_INCLUDE_DIRECTORY}
)
@@ -59,12 +64,54 @@ set(SOURCES
${COMPONENTS_DIR}/rpc_base/src/rpc_base/rpc_base.cc
)
+set(GENERATED_MOBILE_POLICY_TYPES_CPP
+ "${CMAKE_CURRENT_BINARY_DIR}/generated_MOBILE_API_policy_types.cc"
+ "${CMAKE_CURRENT_BINARY_DIR}/generated_MOBILE_API_enum_schema_factory.cc")
+
+set(GENERATED_MOBILE_POLICY_TYPES_HPP
+ "${CMAKE_CURRENT_BINARY_DIR}/generated_MOBILE_API_policy_types.h")
+
+set(GENERATED_MOBILE_POLICY_TYPES
+ ${GENERATED_MOBILE_POLICY_TYPES_HPP}
+ ${GENERATED_MOBILE_POLICY_TYPES_CPP})
+
+generate_policy_types("${GENERATED_MOBILE_POLICY_TYPES}"
+ "${COMPONENTS_DIR}/interfaces/MOBILE_API.xml"
+ "rpc::policy_table_interface_base"
+ "mobile-policy-types")
+
+set(GENERATED_HMI_POLICY_TYPES_CPP
+ "${CMAKE_CURRENT_BINARY_DIR}/generated_HMI_API_policy_types.cc")
+
+set(GENERATED_HMI_POLICY_TYPES_HPP
+ "${CMAKE_CURRENT_BINARY_DIR}/generated_HMI_API_policy_types.h")
+
+set(GENERATED_HMI_POLICY_TYPES
+ ${GENERATED_HMI_POLICY_TYPES_HPP}
+ ${GENERATED_HMI_POLICY_TYPES_CPP})
+
+
+generate_policy_types("${GENERATED_HMI_POLICY_TYPES}"
+ "${COMPONENTS_DIR}/interfaces/HMI_API.xml"
+ "rpc::policy_table_interface_base"
+ "hmi-policy-types")
+
+if (REMOTE_CONTROL)
+ list(APPEND SOURCES ${POLICY_PATH}/src/access_remote_impl.cc)
+endif()
+
list(APPEND SOURCES
${POLICY_PATH}/src/sql_pt_ext_queries.cc
${POLICY_PATH}/src/sql_pt_ext_representation.cc
)
-set(LIBRARIES ConfigProfile policy_struct dbms jsoncpp Utils)
+set(LIBRARIES
+ ConfigProfile
+ policy_struct
+ dbms jsoncpp
+ Utils
+)
+
if (CMAKE_SYSTEM_NAME STREQUAL "QNX")
# --- QDB Wrapper
include_directories (${COMPONENTS_DIR}/utils/include/utils)
@@ -103,13 +150,22 @@ install(TARGETS Policy
set(struct_target policy_struct)
set(TABLE_STRUCT_SOURCES
+ ${GENERATED_MOBILE_POLICY_TYPES_CPP}
+ ${GENERATED_HMI_POLICY_TYPES_CPP}
${POLICY_PATH}/src/policy_table/enums.cc
${POLICY_PATH}/src/policy_table/types.cc
${POLICY_PATH}/src/policy_table/validation.cc
)
add_library(${struct_target} ${TABLE_STRUCT_SOURCES})
-target_link_libraries(${struct_target} Utils)
+target_link_libraries(${struct_target}
+MOBILE_API
+HMI_API
+Utils
+SmartObjects
+formatters
+jsoncpp
+)
# --- Usage statistics
set(USAGE_STATISTICS_SOURCES
diff --git a/src/components/policy/policy_external/doc/doxygen/components/SmartObjects/Smart Objects Validation/Schema Structure.txt b/src/components/policy/policy_external/doc/doxygen/components/SmartObjects/Smart Objects Validation/Schema Structure.txt
index a031e9fd86..d4be0ce490 100644
--- a/src/components/policy/policy_external/doc/doxygen/components/SmartObjects/Smart Objects Validation/Schema Structure.txt
+++ b/src/components/policy/policy_external/doc/doxygen/components/SmartObjects/Smart Objects Validation/Schema Structure.txt
@@ -19,7 +19,7 @@ ns_smart_device_link::ns_smart_objects::CArraySchemaItem provides validation for
ns_smart_device_link::ns_smart_objects::CObjectSchemaItem used in case when Schema Item includes another Schema Item. Actually this is only way to create tree node of new Schema. All other Schema Items will be used only to become leafs of validation tree.
After creation of all required Schema Items (which is actually bind in the tree) it is possible to create Schema.
-Schema can be initialized not only by raw root Schema Item, but also by special abstraction called Member (defined by ns_smart_device_link::ns_smart_objects::CObjectSchemaItem::SMember class). So every root item (ns_smart_device_link::ns_smart_objects::CObjectSchemaItem) firstly should be wrapped as Member. This wrapping process also allows to set "is mandatory" status for every Member.
+Schema can be initialized not only by raw root Schema Item, but also by special abstraction called Member (defined by ns_smart_device_link::ns_smart_objects::SMember class). So every root item (ns_smart_device_link::ns_smart_objects::CObjectSchemaItem) firstly should be wrapped as Member. This wrapping process also allows to set "is mandatory" status for every Member.
and pass root Schema Item as initial parameter to the new Schema.
@@ -69,29 +69,29 @@ TSharedPtr<ISchemaItem> resultCode_SchemaItem = TEnumSchemaItem<Result::eType>::
// Provides additional human readable info regarding the result.
TSharedPtr<ISchemaItem> info_SchemaItem = CStringSchemaItem::create(TSchemaItemParameter<size_t>(1000), TSchemaItemParameter<std::string>());
-schemaMembersMap["success"] = CObjectSchemaItem::SMember(success_SchemaItem, true);
+schemaMembersMap["success"] = SMember(success_SchemaItem, true);
-schemaMembersMap["resultCode"] = CObjectSchemaItem::SMember(resultCode_SchemaItem, true);
+schemaMembersMap["resultCode"] = SMember(resultCode_SchemaItem, true);
-schemaMembersMap["info"] = CObjectSchemaItem::SMember(info_SchemaItem, false);
+schemaMembersMap["info"] = SMember(info_SchemaItem, false);
-std::map<std::string, CObjectSchemaItem::SMember> paramsMembersMap;
+std::map<std::string, SMember> paramsMembersMap;
-paramsMembersMap[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = CObjectSchemaItem::SMember(TEnumSchemaItem<FunctionID::eType>::create(FunctionIDItems), true);
+paramsMembersMap[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = SMember(TEnumSchemaItem<FunctionID::eType>::create(FunctionIDItems), true);
-paramsMembersMap[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(TEnumSchemaItem<messageType::eType>::create(MessageTypeItems), true);
+paramsMembersMap[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = SMember(TEnumSchemaItem<messageType::eType>::create(MessageTypeItems), true);
-paramsMembersMap[ns_smart_device_link::ns_json_handler::strings::S_CORRELATION_ID] = CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+paramsMembersMap[ns_smart_device_link::ns_json_handler::strings::S_CORRELATION_ID] = SMember(TNumberSchemaItem<int>::create(), true);
-paramsMembersMap[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(1, 2), true);
+paramsMembersMap[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = SMember(TNumberSchemaItem<int>::create(1, 2), true);
-paramsMembersMap[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+paramsMembersMap[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = SMember(TNumberSchemaItem<int>::create(), true);
-std::map<std::string, CObjectSchemaItem::SMember> rootMembersMap;
+std::map<std::string, SMember> rootMembersMap;
-rootMembersMap[ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS] = CObjectSchemaItem::SMember(CObjectSchemaItem::create(schemaMembersMap), true);
+rootMembersMap[ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS] = SMember(CObjectSchemaItem::create(schemaMembersMap), true);
-rootMembersMap[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = CObjectSchemaItem::SMember(CObjectSchemaItem::create(paramsMembersMap), true);
+rootMembersMap[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = SMember(CObjectSchemaItem::create(paramsMembersMap), true);
CSmartSchema(CObjectSchemaItem::create(rootMembersMap));
diff --git a/src/components/policy/policy_external/include/policy/cache_manager.h b/src/components/policy/policy_external/include/policy/cache_manager.h
index 05d423da83..acc7a7da51 100644
--- a/src/components/policy/policy_external/include/policy/cache_manager.h
+++ b/src/components/policy/policy_external/include/policy/cache_manager.h
@@ -154,17 +154,25 @@ class CacheManager : public CacheManagerInterface {
*/
virtual bool SecondsBetweenRetries(std::vector<int>& seconds);
- /**
- * @brief Gets information about vehicle
- */
- virtual const VehicleInfo GetVehicleInfo() const;
-
const boost::optional<bool> LockScreenDismissalEnabledState() const OVERRIDE;
const boost::optional<std::string> LockScreenDismissalWarningMessage(
const std::string& language) const OVERRIDE;
/**
+ * @brief Gets vehicle data items
+ * @return Structure with vehicle data items
+ */
+ virtual const std::vector<policy_table::VehicleDataItem> GetVehicleDataItems()
+ const OVERRIDE;
+
+ /**
+ * @brief Gets copy of current policy table data
+ * @return policy_table as json object
+ */
+ virtual Json::Value GetPolicyTableData() const OVERRIDE;
+
+ /**
* @brief Get a list of enabled cloud applications
* @param enabled_apps List filled with the policy app id of each enabled
* cloud application
@@ -859,6 +867,14 @@ class CacheManager : public CacheManagerInterface {
void OnDeviceSwitching(const std::string& device_id_from,
const std::string& device_id_to) OVERRIDE;
+ /**
+ * @brief Method for separate standard vehicle data items from custom
+ * @param full vehicle data items during PTU
+ * @return array with only custom vehicle items
+ */
+ static policy_table::VehicleDataItems CollectCustomVDItems(
+ const policy_table::VehicleDataItems& vd_items);
+
private:
std::string currentDateTime();
struct AppHMITypeToString {
@@ -1043,6 +1059,24 @@ class CacheManager : public CacheManagerInterface {
void MergeCFM(const policy_table::PolicyTable& new_pt,
policy_table::PolicyTable& pt);
+ /**
+ * @brief MergeVD allows to merge VehicleDataItems section by
+ *definite rules.
+ *
+ * The rules are:
+ * 1. If vehicle_data_items key is not presented in the updated PolicyTable,
+ * update for VehicleDataItems should be ignored.
+ * 2. If vehicle_data_items presented in updated PolicyTable, the
+ * VehicleDataItems in the database (LocalPT) should be overwritten with
+ * updated data.
+ *
+ * @param new_pt the policy table loaded from updated preload JSON file.
+ *
+ * @param pt the exists database
+ */
+ void MergeVD(const policy_table::PolicyTable& new_pt,
+ policy_table::PolicyTable& pt);
+
void InitBackupThread();
/**
diff --git a/src/components/policy/policy_external/include/policy/cache_manager_interface.h b/src/components/policy/policy_external/include/policy/cache_manager_interface.h
index 4eb1f2167d..ff09ed608d 100644
--- a/src/components/policy/policy_external/include/policy/cache_manager_interface.h
+++ b/src/components/policy/policy_external/include/policy/cache_manager_interface.h
@@ -162,9 +162,17 @@ class CacheManagerInterface {
virtual bool SecondsBetweenRetries(std::vector<int>& seconds) = 0;
/**
- * @brief Get information about vehicle
+ * @brief Gets copy of current policy table data
+ * @return policy_table as json object
*/
- virtual const VehicleInfo GetVehicleInfo() const = 0;
+ virtual Json::Value GetPolicyTableData() const = 0;
+
+ /**
+ * @brief Gets vehicle data items
+ * @return Structure with vehicle data items
+ */
+ virtual const std::vector<policy_table::VehicleDataItem> GetVehicleDataItems()
+ const = 0;
/**
* @brief Get a list of enabled cloud applications
diff --git a/src/components/policy/policy_external/include/policy/policy_helper.h b/src/components/policy/policy_external/include/policy/policy_helper.h
index 0918f9e1c3..2054485ef5 100644
--- a/src/components/policy/policy_external/include/policy/policy_helper.h
+++ b/src/components/policy/policy_external/include/policy/policy_helper.h
@@ -129,6 +129,15 @@ struct CheckAppPolicy {
bool HasNewGroups(const AppPoliciesValueType& app_policy,
policy_table::Strings* new_groups = NULL) const;
/**
+ * @brief Checks whether updated application policy contains group content
+ * update in compare to current one
+ * @param app_policy Reference to updated application policy
+ * @param updated_groups List of updated groups if any
+ * @return True if updated groups found, otherwise - false
+ */
+ bool HasUpdatedGroups(const policy::AppPoliciesValueType& app_policy,
+ policy_table::Strings* updated_groups = NULL) const;
+ /**
* @brief Checks whether updated policy has groups which require user consent
* @param app_policy Reference to updated application policy
* @return True if has groups requiring user consents, otherwise - false
diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h
index 1524e949ef..497394886f 100644
--- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h
+++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h
@@ -639,10 +639,17 @@ class PolicyManagerImpl : public PolicyManager {
const std::string& policy_app_id) const OVERRIDE;
/**
- * @brief Get information about vehicle
- * @return vehicle information
+ * @brief Gets copy of current policy table data
+ * @return policy_table as json object
*/
- const VehicleInfo GetVehicleInfo() const OVERRIDE;
+ Json::Value GetPolicyTableData() const OVERRIDE;
+
+ /**
+ * @brief Gets vehicle data items
+ * @return Structure with vehicle data items
+ */
+ const std::vector<policy_table::VehicleDataItem> GetVehicleDataItems()
+ const OVERRIDE;
/**
* @brief Get a list of enabled cloud applications
diff --git a/src/components/policy/policy_external/include/policy/policy_table/enums.h b/src/components/policy/policy_external/include/policy/policy_table/enums.h
index d3aee9dcf8..a74eb1f886 100644
--- a/src/components/policy/policy_external/include/policy/policy_table/enums.h
+++ b/src/components/policy/policy_external/include/policy/policy_table/enums.h
@@ -35,133 +35,12 @@
#include <string>
+#include "generated_HMI_API_policy_types.h"
+#include "generated_MOBILE_API_policy_types.h"
+
namespace rpc {
namespace policy_table_interface_base {
-enum Priority {
- P_EMERGENCY,
- P_NAVIGATION,
- P_VOICECOM,
- P_COMMUNICATION,
- P_NORMAL,
- P_PROJECTION,
- P_NONE,
-};
-
-bool IsValidEnum(Priority val);
-const char* EnumToJsonString(Priority val);
-bool EnumFromJsonString(const std::string& literal, Priority* result);
-
-enum HmiLevel {
- HL_BACKGROUND,
- HL_FULL,
- HL_LIMITED,
- HL_NONE,
-};
-bool IsValidEnum(HmiLevel val);
-const char* EnumToJsonString(HmiLevel val);
-bool EnumFromJsonString(const std::string& literal, HmiLevel* result);
-
-enum Parameter {
- P_GPS,
- P_SPEED,
- P_ENGINETORQUE,
- P_EXTERNALTEMPERATURE,
- P_TURNSIGNAL,
- P_FUELLEVEL,
- P_FUELLEVEL_STATE,
- P_HEADLAMPSTATUS,
- P_INSTANTFUELCONSUMPTION,
- P_FUELRANGE,
- P_ODOMETER,
- P_TIREPRESSURE,
- P_WIPERSTATUS,
- P_VIN,
- P_ACCPEDALPOSITION,
- P_BELTSTATUS,
- P_ELECTRONICPARKBRAKESTATUS,
- P_DRIVERBRAKING,
- P_PRNDL,
- P_RPM,
- P_STEERINGWHEELANGLE,
- P_ENGINEOILLIFE,
- P_MYKEY,
- P_AIRBAGSTATUS,
- P_BODYINFORMATION,
- P_CLUSTERMODESTATUS,
- P_DEVICESTATUS,
- P_EMERGENCYEVENT,
- P_ECALLINFO,
- P_ABS_STATE,
- P_FUEL_RANGE,
- P_TIRE_PRESSURE_VALUE,
- P_TPMS,
- P_CLOUD_APP_VEHICLE_ID,
- P_LONGTITUDE_DEGREES,
- P_LATITUDE_DEGREES,
- P_LOCATION_NAME,
- P_LOCATION_DESCRIPTION,
- P_ADDRESS_LINES,
- P_PHONE_NUMBER,
- P_LOCATION_IMAGE,
- P_DELIVERY_MODE,
- P_TIMESTAMP,
- P_ADDRESS,
- P_EMPTY // Added to allow empty parameters handling
-};
-
-bool IsValidEnum(Parameter val);
-const char* EnumToJsonString(Parameter val);
-bool EnumFromJsonString(const std::string& literal, Parameter* result);
-
-enum AppHMIType {
- AHT_DEFAULT,
- AHT_COMMUNICATION,
- AHT_MEDIA,
- AHT_MESSAGING,
- AHT_NAVIGATION,
- AHT_INFORMATION,
- AHT_SOCIAL,
- AHT_BACKGROUND_PROCESS,
- AHT_TESTING,
- AHT_SYSTEM,
- AHT_PROJECTION,
- AHT_REMOTE_CONTROL,
-};
-bool IsValidEnum(AppHMIType val);
-const char* EnumToJsonString(AppHMIType val);
-bool EnumFromJsonString(const std::string& literal, AppHMIType* result);
-
-enum RequestType {
- RT_HTTP,
- RT_FILE_RESUME,
- RT_AUTH_REQUEST,
- RT_AUTH_CHALLENGE,
- RT_AUTH_ACK,
- RT_PROPRIETARY,
- RT_QUERY_APPS,
- RT_LAUNCH_APP,
- RT_LOCK_SCREEN_ICON_URL,
- RT_TRAFFIC_MESSAGE_CHANNEL,
- RT_DRIVER_PROFILE,
- RT_VOICE_SEARCH,
- RT_NAVIGATION,
- RT_PHONE,
- RT_CLIMATE,
- RT_SETTINGS,
- RT_VEHICLE_DIAGNOSTICS,
- RT_EMERGENCY,
- RT_MEDIA,
- RT_FOTA,
- RT_OEM_SPECIFIC,
- RT_ICON_URL,
- RT_EMPTY // Added to allow empty Request Types handling
-};
-
-bool IsValidEnum(RequestType val);
-const char* EnumToJsonString(RequestType val);
-bool EnumFromJsonString(const std::string& literal, RequestType* result);
-
enum Input {
I_GUI,
I_VUI,
@@ -170,461 +49,6 @@ bool IsValidEnum(Input val);
const char* EnumToJsonString(Input val);
bool EnumFromJsonString(const std::string& literal, Input* result);
-enum ModuleType {
- MT_CLIMATE,
- MT_RADIO,
- MT_SEAT,
- MT_AUDIO,
- MT_LIGHT,
- MT_HMI_SETTINGS,
- MT_EMPTY
-};
-bool IsValidEnum(ModuleType val);
-const char* EnumToJsonString(ModuleType val);
-bool EnumFromJsonString(const std::string& literal, ModuleType* result);
-
-enum HybridAppPreference { HAP_MOBILE, HAP_CLOUD, HAP_BOTH };
-bool IsValidEnum(HybridAppPreference val);
-const char* EnumToJsonString(HybridAppPreference val);
-bool EnumFromJsonString(const std::string& literal,
- HybridAppPreference* result);
-
-/**
- * @brief Enumeration FunctionID.
- *
- * Enumeration linking function names with function IDs in AppLink protocol.
- * Assumes enumeration starts at value 0.
- */
-enum FunctionID {
- /**
- * @brief RESERVED.
- */
- RESERVED = 0,
-
- /**
- * @brief RegisterAppInterfaceID.
- */
- RegisterAppInterfaceID = 1,
-
- /**
- * @brief UnregisterAppInterfaceID.
- */
- UnregisterAppInterfaceID = 2,
-
- /**
- * @brief SetGlobalPropertiesID.
- */
- SetGlobalPropertiesID = 3,
-
- /**
- * @brief ResetGlobalPropertiesID.
- */
- ResetGlobalPropertiesID = 4,
-
- /**
- * @brief AddCommandID.
- */
- AddCommandID = 5,
-
- /**
- * @brief DeleteCommandID.
- */
- DeleteCommandID = 6,
-
- /**
- * @brief AddSubMenuID.
- */
- AddSubMenuID = 7,
-
- /**
- * @brief DeleteSubMenuID.
- */
- DeleteSubMenuID = 8,
-
- /**
- * @brief CreateInteractionChoiceSetID.
- */
- CreateInteractionChoiceSetID = 9,
-
- /**
- * @brief PerformInteractionID.
- */
- PerformInteractionID = 10,
-
- /**
- * @brief DeleteInteractionChoiceSetID.
- */
- DeleteInteractionChoiceSetID = 11,
-
- /**
- * @brief AlertID.
- */
- AlertID = 12,
-
- /**
- * @brief ShowID.
- */
- ShowID = 13,
-
- /**
- * @brief SpeakID.
- */
- SpeakID = 14,
-
- /**
- * @brief SetMediaClockTimerID.
- */
- SetMediaClockTimerID = 15,
-
- /**
- * @brief PerformAudioPassThruID.
- */
- PerformAudioPassThruID = 16,
-
- /**
- * @brief EndAudioPassThruID.
- */
- EndAudioPassThruID = 17,
-
- /**
- * @brief SubscribeButtonID.
- */
- SubscribeButtonID = 18,
-
- /**
- * @brief UnsubscribeButtonID.
- */
- UnsubscribeButtonID = 19,
-
- /**
- * @brief SubscribeVehicleDataID.
- */
- SubscribeVehicleDataID = 20,
-
- /**
- * @brief UnsubscribeVehicleDataID.
- */
- UnsubscribeVehicleDataID = 21,
-
- /**
- * @brief GetVehicleDataID.
- */
- GetVehicleDataID = 22,
-
- /**
- * @brief ReadDIDID.
- */
- ReadDIDID = 23,
-
- /**
- * @brief GetDTCsID.
- */
- GetDTCsID = 24,
-
- /**
- * @brief ScrollableMessageID.
- */
- ScrollableMessageID = 25,
-
- /**
- * @brief SliderID.
- */
- SliderID = 26,
-
- /**
- * @brief ShowConstantTBTID.
- */
- ShowConstantTBTID = 27,
-
- /**
- * @brief AlertManeuverID.
- */
- AlertManeuverID = 28,
-
- /**
- * @brief UpdateTurnListID.
- */
- UpdateTurnListID = 29,
-
- /**
- * @brief ChangeRegistrationID.
- */
- ChangeRegistrationID = 30,
-
- /**
- * @brief GenericResponseID.
- */
- GenericResponseID = 31,
-
- /**
- * @brief PutFileID.
- */
- PutFileID = 32,
-
- /**
- * @brief DeleteFileID.
- */
- DeleteFileID = 33,
-
- /**
- * @brief ListFilesID.
- */
- ListFilesID = 34,
-
- /**
- * @brief SetAppIconID.
- */
- SetAppIconID = 35,
-
- /**
- * @brief SetDisplayLayoutID.
- */
- SetDisplayLayoutID = 36,
-
- /**
- * @brief DiagnosticMessageID.
- */
- DiagnosticMessageID = 37,
-
- /**
- * @brief SystemRequestID.
- */
- SystemRequestID = 38,
-
- /**
- * @brief SendLocationID.
- */
- SendLocationID = 39,
-
- /**
- * @brief DialNumberID.
- */
- DialNumberID = 40,
-
- /**
- * @brief ButtonPressID.
- */
- ButtonPressID = 41,
-
- /**
- * @brief GetInteriorVehicleDataID.
- */
- GetInteriorVehicleDataID = 43,
-
- /**
- * @brief SetInteriorVehicleDataID.
- */
- SetInteriorVehicleDataID = 44,
-
- /**
- * @brief GetWayPointsID.
- */
- GetWayPointsID = 45,
-
- /**
- * @brief SubscribeWayPointsID.
- */
- SubscribeWayPointsID = 46,
-
- /**
- * @brief UnsubscribeWayPointsID.
- */
- UnsubscribeWayPointsID = 47,
-
- /**
- * @brief GetSystemCapabilityID.
- */
- GetSystemCapabilityID = 48,
-
- /**
- * @brief SendHapticDataID.
- */
- SendHapticDataID = 49,
-
- /**
- * @brief SetCloudAppPropertiesID.
- */
- SetCloudAppPropertiesID = 50,
-
- /**
- * @brief GetCloudAppPropertiesID.
- */
- GetCloudAppPropertiesID = 51,
-
- /**
- * @brief PublishAppServiceID.
- */
- PublishAppServiceID = 52,
-
- /**
- * @brief GetAppServiceDataID.
- */
- GetAppServiceDataID = 53,
-
- /**
- * @brief GetFileID
- */
- GetFileID = 54,
-
- /**
- * @brief PerformAppServiceInteractionID.
- */
- PerformAppServiceInteractionID = 55,
-
- /**
- * @brief UnpublishAppServiceID.
- */
- UnpublishAppServiceID = 56,
-
- /**
- * @brief CancelInteractionID.
- */
- CancelInteractionID = 57,
-
- /**
- * @brief CloseApplicationID.
- */
- CloseApplicationID = 58,
-
- /**
- * @brief ShowAppMenuID.
- */
- ShowAppMenuID = 59,
-
- /**
- * @brief CreateWindowID.
- */
- CreateWindowID = 60,
-
- /**
- * @brief DeleteWindowID.
- */
- DeleteWindowID = 61,
-
- /**
- * @brief OnHMIStatusID.
- */
- OnHMIStatusID = 32768,
-
- /**
- * @brief OnAppInterfaceUnregisteredID.
- */
- OnAppInterfaceUnregisteredID = 32769,
-
- /**
- * @brief OnButtonEventID.
- */
- OnButtonEventID = 32770,
-
- /**
- * @brief OnButtonPressID.
- */
- OnButtonPressID = 32771,
-
- /**
- * @brief OnVehicleDataID.
- */
- OnVehicleDataID = 32772,
-
- /**
- * @brief OnCommandID.
- */
- OnCommandID = 32773,
-
- /**
- * @brief OnTBTClientStateID.
- */
- OnTBTClientStateID = 32774,
-
- /**
- * @brief OnDriverDistractionID.
- */
- OnDriverDistractionID = 32775,
-
- /**
- * @brief OnPermissionsChangeID.
- */
- OnPermissionsChangeID = 32776,
-
- /**
- * @brief OnAudioPassThruID.
- */
- OnAudioPassThruID = 32777,
-
- /**
- * @brief OnLanguageChangeID.
- */
- OnLanguageChangeID = 32778,
-
- /**
- * @brief OnKeyboardInputID.
- */
- OnKeyboardInputID = 32779,
-
- /**
- * @brief OnTouchEventID.
- */
- OnTouchEventID = 32780,
-
- /**
- * @brief OnSystemRequestID.
- */
- OnSystemRequestID = 32781,
-
- /**
- * @brief OnHashChangeID.
- */
- OnHashChangeID = 32782,
-
- /**
- * @brief OnInteriorVehicleDataID.
- */
- OnInteriorVehicleDataID = 32783,
-
- /**
- * @brief OnWayPointChangeID.
- */
- OnWayPointChangeID = 32784,
-
- /**
- * @brief OnRCStatusID.
- */
- OnRCStatusID = 32785,
-
- /**
- * @brief OnAppServiceDataID.
- */
- OnAppServiceDataID = 32786,
-
- /**
- * @brief OnSystemCapabilityUpdatedID
- */
- OnSystemCapabilityUpdatedID = 32787,
-
- /**
- * @brief EncodedSyncPDataID.
- */
- EncodedSyncPDataID = 65536,
-
- /**
- * @brief SyncPDataID.
- */
- SyncPDataID = 65537,
-
- /**
- * @brief OnEncodedSyncPDataID.
- */
- OnEncodedSyncPDataID = 98304,
-
- /**
- * @brief OnSyncPDataID.
- */
- OnSyncPDataID = 98305
-};
-bool IsValidEnum(FunctionID val);
-const char* EnumToJsonString(FunctionID val);
-bool EnumFromJsonString(const std::string& literal, FunctionID* result);
-
extern const std::string kDefaultApp;
extern const std::string kPreDataConsentApp;
extern const std::string kDeviceApp;
diff --git a/src/components/policy/policy_external/include/policy/policy_table/policy_enum_schema_factory.h b/src/components/policy/policy_external/include/policy/policy_table/policy_enum_schema_factory.h
new file mode 100644
index 0000000000..4871179342
--- /dev/null
+++ b/src/components/policy/policy_external/include/policy/policy_table/policy_enum_schema_factory.h
@@ -0,0 +1,62 @@
+/**
+ * Copyright (c) 2017, 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_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_POLICY_TABLE_POLICY_ENUM_SCHEMA_FACTORY_H
+#define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_POLICY_TABLE_POLICY_ENUM_SCHEMA_FACTORY_H
+
+#include <memory>
+#include <string>
+
+#include "smart_objects/smart_schema.h"
+
+namespace rpc {
+namespace policy_table_interface_base {
+
+class EnumSchemaItemFactory {
+ public:
+ /**
+ * @brief Get enum schema from enum name
+ * Implementation of this function should be generated from MOBILE_API.xml
+ * @param enum_name enum name to get schema factory for
+ * @return shared pointer to schema factory or empty shared pointer if
+ * enum_name is wrong
+ */
+ static std::shared_ptr<ns_smart_device_link::ns_smart_objects::ISchemaItem>
+ Get(const std::string& enum_name);
+
+ static bool IsRPCSpecVehicleDataType(const std::string& vd_name);
+};
+
+} // namespace policy_table_interface_base
+} // namespace rpc
+
+#endif // SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_POLICY_TABLE_POLICY_ENUM_SCHEMA_FACTORY_H
diff --git a/src/components/policy/policy_external/include/policy/policy_table/types.h b/src/components/policy/policy_external/include/policy/policy_table/types.h
index 7f59c17384..11c76bdd68 100644
--- a/src/components/policy/policy_external/include/policy/policy_table/types.h
+++ b/src/components/policy/policy_external/include/policy/policy_table/types.h
@@ -37,7 +37,9 @@
#include "utils/macro.h"
#include "policy/policy_table/enums.h"
+#include "policy/policy_table/policy_enum_schema_factory.h"
#include "rpc_base/rpc_message.h"
+#include "utils/helpers.h"
namespace Json {
class Value;
@@ -48,6 +50,7 @@ struct AppLevel;
struct ApplicationParams;
struct ConsentRecords;
struct DeviceParams;
+struct EndpointProperty;
struct MessageLanguages;
struct MessageString;
struct RpcParameters;
@@ -69,16 +72,18 @@ typedef Array<Enum<AppHMIType>, 0, 255> AppHMITypes;
typedef Array<Enum<HmiLevel>, 0, 4> HmiLevels;
-typedef Array<Enum<Parameter>, 0, 100> Parameters;
+typedef Array<String<0, 255>, 0, 100> Parameters;
typedef Map<RpcParameters, 0, UINT_MAX> Rpc;
-typedef Array<String<10, 255>, 1, 3> URL;
+typedef Array<String<10, INT_MAX>, 1, 3> URL;
typedef Map<URL, 1, 255> URLList;
typedef Map<URLList, 1, 255> ServiceEndpoints;
+typedef Map<EndpointProperty, 0, 255> ServiceEndpointProperties;
+
typedef uint8_t NumberOfNotificationsType;
typedef Map<Integer<NumberOfNotificationsType, 0, 255>, 0, 7>
NumberOfNotificationsPerMinute;
@@ -349,6 +354,24 @@ struct Rpcs : CompositeType {
bool Validate() const;
};
+struct EndpointProperty : CompositeType {
+ public:
+ Optional<String<0, 100> > version;
+
+ EndpointProperty();
+ ~EndpointProperty();
+ explicit EndpointProperty(const Json::Value* value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport* report__) const;
+ void SetPolicyTableType(PolicyTableType pt_type) OVERRIDE;
+
+ private:
+ bool Validate() const;
+};
+
struct ModuleConfig : CompositeType {
public:
Integer<uint8_t, 0, 255> exchange_after_x_ignition_cycles;
@@ -357,6 +380,7 @@ struct ModuleConfig : CompositeType {
Integer<uint16_t, 0, 65535> timeout_after_x_seconds;
SecondsBetweenRetries seconds_between_retries;
ServiceEndpoints endpoints;
+ Optional<ServiceEndpointProperties> endpoint_properties;
NumberOfNotificationsPerMinute notifications_per_minute_by_priority;
Optional<String<0, 100> > vehicle_make;
Optional<String<0, 100> > vehicle_model;
@@ -367,6 +391,8 @@ struct ModuleConfig : CompositeType {
Optional<Boolean> full_app_id_supported;
Optional<Boolean> lock_screen_dismissal_enabled;
+ static const std::string kDefaultOemMappingServiceName;
+
public:
ModuleConfig();
ModuleConfig(uint8_t exchange_after_x_ignition_cycles,
@@ -375,6 +401,7 @@ struct ModuleConfig : CompositeType {
uint16_t timeout_after_x_seconds,
const SecondsBetweenRetries& seconds_between_retries,
const ServiceEndpoints& endpoints,
+ const ServiceEndpointProperties& endpoint_properties,
const NumberOfNotificationsPerMinute&
notifications_per_minute_by_priority);
~ModuleConfig();
@@ -601,6 +628,88 @@ struct DeviceParams : CompositeType {
bool Validate() const;
};
+struct VehicleDataItem : CompositeType {
+ public:
+ static const std::vector<std::string> kPODTypes;
+
+ static const std::string kInteger;
+ static const std::string kStruct;
+ static const std::string kString;
+ static const std::string kFloat;
+ static const std::string kDouble;
+ static const std::string kBoolean;
+ static const std::string kName;
+ static const std::string kParams;
+
+ String<1, 255> name;
+ String<0, 255> type;
+ String<1, 255> key;
+ Boolean mandatory;
+ Optional<Array<VehicleDataItem, 0, 255> > params;
+
+ Optional<Boolean> array;
+ Optional<String<0, 255> > since;
+ Optional<String<0, 255> > until;
+ Optional<Boolean> removed;
+ Optional<Boolean> deprecated;
+ Optional<Float<-INT32_MAX, INT32_MAX> > minvalue;
+ Optional<Float<-INT32_MAX, INT32_MAX> > maxvalue;
+ Optional<Integer<uint32_t, 0, UINT32_MAX> > minsize;
+ Optional<Integer<uint32_t, 0, UINT32_MAX> > maxsize;
+ Optional<Integer<uint32_t, 0, UINT32_MAX> > minlength;
+ Optional<Integer<uint32_t, 0, UINT_MAX> > maxlength;
+
+ VehicleDataItem();
+ VehicleDataItem(const VehicleDataItem& policy_table);
+ explicit VehicleDataItem(const Json::Value* value__);
+
+ bool operator==(const VehicleDataItem& vd);
+
+ ~VehicleDataItem();
+
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_not_empty() const;
+ void ReportErrors(rpc::ValidationReport* report__) const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+
+ /**
+ * @brief Validates type of vehicle data item according to
+ * POD types and generated from API enums.
+ * @return true if type is valid.
+ */
+ bool ValidateTypes() const;
+ bool IsPrimitiveType() const;
+ bool ValidateNaming(std::string str) const;
+
+ private:
+ bool Validate() const;
+};
+
+typedef Array<VehicleDataItem, 0, 255> VehicleDataItems;
+
+struct VehicleData : CompositeType {
+ public:
+ Optional<String<0, 100> > schema_version;
+ Optional<VehicleDataItems> schema_items;
+
+ VehicleData();
+ VehicleData(const VehicleData& vehicle_data);
+ VehicleData(const Json::Value* value__);
+ ~VehicleData();
+
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport* report__) const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+
+ private:
+ bool Validate() const;
+};
+
struct PolicyTable : CompositeType {
public:
ApplicationPoliciesSection app_policies_section;
@@ -610,6 +719,7 @@ struct PolicyTable : CompositeType {
Optional<ModuleMeta> module_meta;
Optional<UsageAndErrorCounts> usage_and_error_counts;
Optional<DeviceData> device_data;
+ Optional<VehicleData> vehicle_data;
public:
PolicyTable();
diff --git a/src/components/policy/policy_external/include/policy/policy_types.h b/src/components/policy/policy_external/include/policy/policy_types.h
index fe63ae3479..ee2d806ba5 100644
--- a/src/components/policy/policy_external/include/policy/policy_types.h
+++ b/src/components/policy/policy_external/include/policy/policy_types.h
@@ -511,7 +511,7 @@ enum PermissionsCheckResult {
RESULT_NICKNAME_MISMATCH,
RESULT_PERMISSIONS_REVOKED,
RESULT_CONSENT_NEEDED,
- RESULT_CONSENT_NOT_REQIURED,
+ RESULT_CONSENT_NOT_REQUIRED,
RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED,
RESULT_REQUEST_TYPE_CHANGED,
RESULT_REQUEST_SUBTYPE_CHANGED,
diff --git a/src/components/policy/policy_external/include/policy/pt_representation.h b/src/components/policy/policy_external/include/policy/pt_representation.h
index 6eaa718cf0..d233bbf268 100644
--- a/src/components/policy/policy_external/include/policy/pt_representation.h
+++ b/src/components/policy/policy_external/include/policy/pt_representation.h
@@ -134,11 +134,6 @@ class PTRepresentation {
virtual bool SecondsBetweenRetries(std::vector<int>* seconds) = 0;
/**
- * @brief Get information about vehicle
- */
- virtual const VehicleInfo GetVehicleInfo() const = 0;
-
- /**
* @brief Allows to update 'vin' field in module_meta table.
*
* @param new 'vin' value.
diff --git a/src/components/policy/policy_external/include/policy/sql_pt_queries.h b/src/components/policy/policy_external/include/policy/sql_pt_queries.h
index 5382ff2d6b..c613cec0d6 100644
--- a/src/components/policy/policy_external/include/policy/sql_pt_queries.h
+++ b/src/components/policy/policy_external/include/policy/sql_pt_queries.h
@@ -142,6 +142,21 @@ extern const std::string kDeleteModuleTypes;
extern const std::string kDeleteAllDevices;
extern const std::string kSelectDBVersion;
extern const std::string kUpdateDBVersion;
+extern const std::string kSelectVehicleDataItem;
+extern const std::string kInsertVehicleDataItem;
+extern const std::string kDeleteVehicleDataItems;
+extern const std::string kInsertVehicleDataItemParams;
+extern const std::string kSelectVehicleDataItemParams;
+extern const std::string kDeleteVehicleDataItemParams;
+extern const std::string kSelectVehicleDataItemWithVersion;
+extern const std::string kSelectPrimitiveVehicleDataItems;
+extern const std::string kSelectCompositeVehicleDataItemsKey;
+extern const std::string kSelectOEMMappingVersion;
+extern const std::string kSelectVehicleDataSchemaVersion;
+extern const std::string kInsertVehicleDataSchemaVersion;
+extern const std::string kSelectEndpointProperties;
+extern const std::string kInsertEndpointVersion;
+
} // namespace sql_pt
} // namespace policy
diff --git a/src/components/policy/policy_external/include/policy/sql_pt_representation.h b/src/components/policy/policy_external/include/policy/sql_pt_representation.h
index 826c9b3b6e..5d2d63a8bd 100644
--- a/src/components/policy/policy_external/include/policy/sql_pt_representation.h
+++ b/src/components/policy/policy_external/include/policy/sql_pt_representation.h
@@ -44,6 +44,7 @@ namespace policy_table = rpc::policy_table_interface_base;
namespace utils {
namespace dbms {
class SQLDatabase;
+class SQLQuery;
} // namespace dbms
} // namespace utils
@@ -70,8 +71,6 @@ class SQLPTRepresentation : public virtual PTRepresentation {
virtual int TimeoutResponse();
virtual bool SecondsBetweenRetries(std::vector<int>* seconds);
virtual bool RefreshDB();
- virtual const VehicleInfo GetVehicleInfo() const;
-
virtual std::vector<UserFriendlyMessage> GetUserFriendlyMsg(
const std::vector<std::string>& msg_codes, const std::string& language);
@@ -124,6 +123,9 @@ class SQLPTRepresentation : public virtual PTRepresentation {
policy_table::ConsumerFriendlyMessages* messages) const;
virtual bool GatherApplicationPoliciesSection(
policy_table::ApplicationPoliciesSection* policies) const;
+ virtual bool GatherVehicleDataItems(
+ policy_table::VehicleDataItems* vehicle_data_items) const;
+ virtual bool GatherVehicleData(policy_table::VehicleData* vehicle_data) const;
bool GatherAppGroup(const std::string& app_id,
policy_table::Strings* app_groups) const;
@@ -159,6 +161,9 @@ class SQLPTRepresentation : public virtual PTRepresentation {
virtual bool SaveSpecificAppPolicy(
const policy_table::ApplicationPolicies::value_type& app);
virtual bool SaveDevicePolicy(const policy_table::DevicePolicy& device);
+ virtual bool SaveVehicleDataItems(
+ const policy_table::VehicleDataItems& vehicle_data_items);
+ virtual bool SaveVehicleData(const policy_table::VehicleData& vehicle_data);
virtual bool SaveMessageString(const std::string& type,
const std::string& lang,
@@ -203,6 +208,26 @@ class SQLPTRepresentation : public virtual PTRepresentation {
virtual bool IsDBVersionActual() const OVERRIDE;
virtual bool UpdateDBVersion() const OVERRIDE;
+ policy_table::VehicleDataItems GetVehicleDataItem(
+ const std::string& name, const std::string& key) const;
+ bool InsertVehicleDataItem(
+ const policy_table::VehicleDataItem& vehicle_data_item);
+ bool VehicleDataItemExists(
+ const policy_table::VehicleDataItem& vehicle_data_item) const;
+
+ /**
+ * @brief Retrieves vehicle data items of type Struct (which contains params)
+ * from the database including these parameters.
+ * @return Array of parameterized VehicleDataItems (including params)
+ */
+ policy_table::VehicleDataItems SelectCompositeVehicleDataItems() const;
+
+ /**
+ * @brief Retrieves vehicle data items of non Struct type from the database.
+ * @return Array of primitive VehicleDataItems
+ */
+ policy_table::VehicleDataItems SelectPrimitiveVehicleDataItems() const;
+
private:
utils::dbms::SQLDatabase* db_;
@@ -220,12 +245,17 @@ class SQLPTRepresentation : public virtual PTRepresentation {
const int32_t GetDBVersion() const;
bool SaveRpcs(int64_t group_id, const policy_table::Rpc& rpcs);
bool SaveServiceEndpoints(const policy_table::ServiceEndpoints& endpoints);
+ bool SaveServiceEndpointProperties(
+ const policy_table::ServiceEndpointProperties& endpoint_properties);
bool SaveSecondsBetweenRetries(
const policy_table::SecondsBetweenRetries& seconds);
bool SaveNumberOfNotificationsPerMinute(
const policy_table::NumberOfNotificationsPerMinute& notifications);
bool SaveMessageType(const std::string& type);
bool SaveLanguage(const std::string& code);
+ policy_table::VehicleDataItem PopulateVDIFromQuery(
+ const utils::dbms::SQLQuery& query) const;
+ bool DeleteVehicleDataItems() const;
bool is_in_memory;
bool SaveExternalConsentEntities(
diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc
index 965b91c9f4..3e1538ab04 100644
--- a/src/components/policy/policy_external/src/cache_manager.cc
+++ b/src/components/policy/policy_external/src/cache_manager.cc
@@ -33,6 +33,7 @@
#include "policy/cache_manager.h"
#include <algorithm>
+#include <boost/algorithm/string.hpp>
#include <cmath>
#include <ctime>
#include <functional>
@@ -752,6 +753,26 @@ bool CacheManager::ApplyUpdate(const policy_table::Table& update_pt) {
pt_->policy_table.consumer_friendly_messages.assign_if_valid(
update_pt.policy_table.consumer_friendly_messages);
+ pt_->policy_table.module_config.endpoint_properties =
+ update_pt.policy_table.module_config.endpoint_properties;
+
+ // Apply update for vehicle data
+ if (update_pt.policy_table.vehicle_data.is_initialized()) {
+ if (!update_pt.policy_table.vehicle_data->schema_items.is_initialized() ||
+ update_pt.policy_table.vehicle_data->schema_items->empty()) {
+ pt_->policy_table.vehicle_data->schema_items =
+ rpc::Optional<policy_table::VehicleDataItems>();
+ } else {
+ policy_table::VehicleDataItems custom_items = CollectCustomVDItems(
+ *update_pt.policy_table.vehicle_data->schema_items);
+
+ pt_->policy_table.vehicle_data->schema_version =
+ update_pt.policy_table.vehicle_data->schema_version;
+ pt_->policy_table.vehicle_data->schema_items =
+ rpc::Optional<policy_table::VehicleDataItems>(custom_items);
+ }
+ }
+
ResetCalculatedPermissions();
Backup();
@@ -762,6 +783,21 @@ bool CacheManager::ApplyUpdate(const policy_table::Table& update_pt) {
return true;
}
+policy_table::VehicleDataItems CacheManager::CollectCustomVDItems(
+ const policy_table::VehicleDataItems& vd_items) {
+ policy_table::VehicleDataItems result_items;
+ for (auto& item : vd_items) {
+ const std::string i_name = "VEHICLEDATA_" + std::string(item.name);
+ const std::string vd_name = boost::to_upper_copy<std::string>(i_name);
+ const bool is_standard =
+ policy_table::EnumSchemaItemFactory::IsRPCSpecVehicleDataType(vd_name);
+ if (!is_standard) {
+ result_items.push_back(item);
+ }
+ }
+ return result_items;
+}
+
void CacheManager::GetHMIAppTypeAfterUpdate(
std::map<std::string, StringArray>& app_hmi_types) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -1231,14 +1267,8 @@ void CacheManager::CheckPermissions(const PTString& app_id,
if (rpc_param.hmi_levels.end() != hmi_iter) {
result.hmi_level_permitted = PermitResult::kRpcAllowed;
- policy_table::Parameters::const_iterator params_iter =
- rpc_param.parameters->begin();
- policy_table::Parameters::const_iterator params_iter_end =
- rpc_param.parameters->end();
-
- for (; params_iter != params_iter_end; ++params_iter) {
- result.list_of_allowed_params.insert(
- policy_table::EnumToJsonString(*params_iter));
+ for (const auto& param : *rpc_param.parameters) {
+ result.list_of_allowed_params.insert(std::string(param));
}
}
}
@@ -1387,20 +1417,21 @@ bool CacheManager::SecondsBetweenRetries(std::vector<int>& seconds) {
return true;
}
-const policy::VehicleInfo CacheManager::GetVehicleInfo() const {
- CACHE_MANAGER_CHECK(VehicleInfo());
+const std::vector<policy_table::VehicleDataItem>
+CacheManager::GetVehicleDataItems() const {
+ CACHE_MANAGER_CHECK(std::vector<policy_table::VehicleDataItem>());
sync_primitives::AutoLock auto_lock(cache_lock_);
- policy_table::ModuleConfig& module_config = pt_->policy_table.module_config;
- VehicleInfo vehicle_info;
- vehicle_info.vehicle_make = *module_config.vehicle_make;
- vehicle_info.vehicle_model = *module_config.vehicle_model;
- vehicle_info.vehicle_year = *module_config.vehicle_year;
- LOG4CXX_DEBUG(
- logger_,
- "Vehicle info (make, model, year):" << vehicle_info.vehicle_make << ","
- << vehicle_info.vehicle_model << ","
- << vehicle_info.vehicle_year);
- return vehicle_info;
+
+ if (pt_->policy_table.vehicle_data.is_initialized() &&
+ pt_->policy_table.vehicle_data->schema_items.is_initialized()) {
+ return *(pt_->policy_table.vehicle_data->schema_items);
+ }
+
+ return std::vector<policy_table::VehicleDataItem>();
+}
+
+Json::Value CacheManager::GetPolicyTableData() const {
+ return pt_->policy_table.ToJsonValue();
}
void CacheManager::GetEnabledCloudApps(
@@ -1669,11 +1700,19 @@ std::vector<UserFriendlyMessage> CacheManager::GetUserFriendlyMsg(
void CacheManager::GetUpdateUrls(const uint32_t service_type,
EndpointUrls& out_end_points) {
- std::stringstream service_type_stream;
- service_type_stream << (service_type <= 9 ? "0x0" : "0x") << service_type;
-
- const std::string service_type_str = service_type_stream.str();
- GetUpdateUrls(service_type_str, out_end_points);
+ auto find_hexademical =
+ [service_type](policy_table::ServiceEndpoints::value_type end_point) {
+ uint32_t decimal;
+ std::istringstream(end_point.first) >> std::hex >> decimal;
+ return end_point.first.compare(0, 2, "0x") == 0 &&
+ decimal == service_type;
+ };
+ auto& end_points = pt_->policy_table.module_config.endpoints;
+ const auto end_point =
+ std::find_if(end_points.begin(), end_points.end(), find_hexademical);
+ if (end_point != end_points.end()) {
+ GetUpdateUrls(end_point->first, out_end_points);
+ }
}
void CacheManager::GetUpdateUrls(const std::string& service_type,
@@ -2014,6 +2053,14 @@ std::shared_ptr<policy_table::Table> CacheManager::GenerateSnapshot() {
sync_primitives::AutoLock auto_lock(cache_lock_);
snapshot_->policy_table = pt_->policy_table;
+ if (pt_->policy_table.vehicle_data.is_initialized()) {
+ snapshot_->policy_table.vehicle_data =
+ rpc::Optional<policy_table::VehicleData>();
+ snapshot_->policy_table.vehicle_data->mark_initialized();
+ snapshot_->policy_table.vehicle_data->schema_version =
+ pt_->policy_table.vehicle_data->schema_version;
+ }
+
snapshot_->SetPolicyTableType(policy_table::PT_SNAPSHOT);
CheckSnapshotInitialization();
@@ -2531,6 +2578,8 @@ bool CacheManager::Init(const std::string& file_name,
} else {
rpc::ValidationReport report("policy_table");
snapshot->ReportErrors(&report);
+ LOG4CXX_DEBUG(logger_,
+ "Validation report: " << rpc::PrettyFormat(report));
ex_backup_->RemoveDB();
}
} break;
@@ -2595,7 +2644,6 @@ bool CacheManager::LoadFromFile(const std::string& file_name,
LOG4CXX_FATAL(logger_, "Failed to read policy table source file.");
return false;
}
-
Json::Value value;
Json::Reader reader(Json::Features::strictMode());
std::string json(json_string.begin(), json_string.end());
@@ -2934,6 +2982,7 @@ bool CacheManager::MergePreloadPT(const std::string& file_name) {
MergeFG(new_table, current);
MergeAP(new_table, current);
MergeCFM(new_table, current);
+ MergeVD(new_table, current);
Backup();
}
return true;
@@ -3001,6 +3050,12 @@ void CacheManager::MergeCFM(const policy_table::PolicyTable& new_pt,
}
}
+void CacheManager::MergeVD(const policy_table::PolicyTable& new_pt,
+ policy_table::PolicyTable& pt) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ pt.vehicle_data.assign_if_valid(new_pt.vehicle_data);
+}
+
void CacheManager::InitBackupThread() {
LOG4CXX_AUTO_TRACE(logger_);
backuper_ = new BackgroundBackuper(this);
diff --git a/src/components/policy/policy_external/src/policy_helper.cc b/src/components/policy/policy_external/src/policy_helper.cc
index bb0a36df68..99e4450065 100644
--- a/src/components/policy/policy_external/src/policy_helper.cc
+++ b/src/components/policy/policy_external/src/policy_helper.cc
@@ -46,7 +46,8 @@ namespace {
CREATE_LOGGERPTR_GLOBAL(logger_, "Policy")
-bool Compare(const StringsValueType& first, const StringsValueType& second) {
+bool CompareStrings(const StringsValueType& first,
+ const StringsValueType& second) {
const std::string& first_str = first;
const std::string& second_str = second;
return (strcasecmp(first_str.c_str(), second_str.c_str()) < 0);
@@ -137,10 +138,10 @@ bool policy::CheckAppPolicy::HasRevokedGroups(
snapshot_->policy_table.app_policies_section.apps.find(app_policy.first);
policy_table::Strings groups_new = app_policy.second.groups;
- std::sort(groups_new.begin(), groups_new.end(), Compare);
+ std::sort(groups_new.begin(), groups_new.end(), CompareStrings);
policy_table::Strings groups_curr = (*it).second.groups;
- std::sort(groups_curr.begin(), groups_curr.end(), Compare);
+ std::sort(groups_curr.begin(), groups_curr.end(), CompareStrings);
StringsConstItr it_groups_new = groups_new.begin();
StringsConstItr it_groups_new_end = groups_new.end();
@@ -154,7 +155,7 @@ bool policy::CheckAppPolicy::HasRevokedGroups(
it_groups_new,
it_groups_new_end,
std::back_inserter(revoked_group_list),
- Compare);
+ CompareStrings);
// Remove groups which are not required user consent
policy_table::Strings::iterator it_revoked = revoked_group_list.begin();
@@ -174,6 +175,76 @@ bool policy::CheckAppPolicy::HasRevokedGroups(
return !revoked_group_list.empty();
}
+bool policy::CheckAppPolicy::HasUpdatedGroups(
+ const policy::AppPoliciesValueType& app_policy,
+ policy_table::Strings* updated_groups) const {
+ AppPoliciesConstItr it =
+ snapshot_->policy_table.app_policies_section.apps.find(app_policy.first);
+
+ policy_table::Strings groups_new = app_policy.second.groups;
+ std::sort(groups_new.begin(), groups_new.end(), CompareStrings);
+
+ policy_table::Strings groups_curr = (*it).second.groups;
+ std::sort(groups_curr.begin(), groups_curr.end(), CompareStrings);
+
+ policy_table::Strings intersection_list;
+ std::set_intersection(groups_new.begin(),
+ groups_new.end(),
+ groups_curr.begin(),
+ groups_curr.end(),
+ std::back_inserter(intersection_list));
+
+ auto IsGroupContentUpdated =
+ [this](const StringsValueType& groupName) -> bool {
+ const auto& func_group_from_update =
+ update_->policy_table.functional_groupings.find(groupName);
+ const auto& func_group_from_snapshot =
+ snapshot_->policy_table.functional_groupings.find(groupName);
+
+ const auto& update_fg_rpcs = func_group_from_update->second.rpcs;
+ const auto& snapshot_fg_rpcs = func_group_from_snapshot->second.rpcs;
+
+ if (update_fg_rpcs.is_null() || snapshot_fg_rpcs.is_null()) {
+ return !(update_fg_rpcs.is_null() && snapshot_fg_rpcs.is_null());
+ }
+
+ if (update_fg_rpcs.size() != snapshot_fg_rpcs.size()) {
+ return true;
+ }
+
+ for (const auto& rpc : update_fg_rpcs) {
+ const auto& old_rpc = snapshot_fg_rpcs.find(rpc.first);
+ if (snapshot_fg_rpcs.end() == old_rpc) {
+ return true;
+ }
+
+ const bool hmi_levels_same =
+ old_rpc->second.hmi_levels == rpc.second.hmi_levels;
+ const bool parameters_same =
+ *(old_rpc->second.parameters) == *(rpc.second.parameters);
+
+ if (!hmi_levels_same || !parameters_same) {
+ return true;
+ }
+ }
+
+ return false;
+ };
+
+ policy_table::Strings updated_group_list;
+ for (const auto& item : intersection_list) {
+ if (IsGroupContentUpdated(item)) {
+ updated_group_list.push_back(item);
+ }
+ }
+
+ if (updated_groups) {
+ *updated_groups = updated_group_list;
+ }
+
+ return !updated_group_list.empty();
+}
+
bool policy::CheckAppPolicy::HasNewGroups(
const policy::AppPoliciesValueType& app_policy,
policy_table::Strings* new_groups) const {
@@ -181,10 +252,10 @@ bool policy::CheckAppPolicy::HasNewGroups(
snapshot_->policy_table.app_policies_section.apps.find(app_policy.first);
policy_table::Strings groups_new = app_policy.second.groups;
- std::sort(groups_new.begin(), groups_new.end(), Compare);
+ std::sort(groups_new.begin(), groups_new.end(), CompareStrings);
policy_table::Strings groups_curr = (*it).second.groups;
- std::sort(groups_curr.begin(), groups_curr.end(), Compare);
+ std::sort(groups_curr.begin(), groups_curr.end(), CompareStrings);
StringsConstItr it_groups_new = groups_new.begin();
StringsConstItr it_groups_new_end = groups_new.end();
@@ -192,13 +263,55 @@ bool policy::CheckAppPolicy::HasNewGroups(
StringsConstItr it_groups_curr = groups_curr.begin();
StringsConstItr it_groups_curr_end = groups_curr.end();
+ auto CompareGroupContent =
+ [this](const StringsValueType& update_group_name,
+ const StringsValueType& snapshot_group_name) -> bool {
+ if (CompareStrings(update_group_name, snapshot_group_name)) {
+ return true;
+ }
+
+ const auto& func_group_from_update =
+ update_->policy_table.functional_groupings.find(update_group_name);
+ const auto& func_group_from_snapshot =
+ snapshot_->policy_table.functional_groupings.find(snapshot_group_name);
+
+ const auto& update_fg_rpcs = func_group_from_update->second.rpcs;
+ const auto& snapshot_fg_rpcs = func_group_from_snapshot->second.rpcs;
+
+ if (update_fg_rpcs.is_null() || snapshot_fg_rpcs.is_null()) {
+ return !(update_fg_rpcs.is_null() && snapshot_fg_rpcs.is_null());
+ }
+
+ if (update_fg_rpcs.size() != snapshot_fg_rpcs.size()) {
+ return true;
+ }
+
+ for (const auto& rpc : update_fg_rpcs) {
+ const auto& old_rpc = snapshot_fg_rpcs.find(rpc.first);
+ if (snapshot_fg_rpcs.end() == old_rpc) {
+ return true;
+ }
+
+ const bool hmi_levels_same =
+ old_rpc->second.hmi_levels == rpc.second.hmi_levels;
+ const bool parameters_same =
+ *(old_rpc->second.parameters) == *(rpc.second.parameters);
+
+ if (!hmi_levels_same || !parameters_same) {
+ return true;
+ }
+ }
+
+ return false;
+ };
+
policy_table::Strings new_group_list;
std::set_difference(it_groups_new,
it_groups_new_end,
it_groups_curr,
it_groups_curr_end,
std::back_inserter(new_group_list),
- Compare);
+ CompareGroupContent);
if (new_groups) {
*new_groups = new_group_list;
@@ -210,14 +323,23 @@ bool policy::CheckAppPolicy::HasNewGroups(
bool policy::CheckAppPolicy::HasConsentNeededGroups(
const policy::AppPoliciesValueType& app_policy) const {
policy_table::Strings new_groups;
- if (!HasNewGroups(app_policy, &new_groups)) {
+ policy_table::Strings updated_groups;
+ if (!HasNewGroups(app_policy, &new_groups) &&
+ !HasUpdatedGroups(app_policy, &updated_groups)) {
return false;
}
- StringsConstItr it_new = new_groups.begin();
- StringsConstItr it_new_end = new_groups.end();
- for (; it_new != it_new_end; ++it_new) {
- if (IsConsentRequired(app_policy.first, *it_new)) {
+ policy_table::Strings groups_to_check_consent;
+ std::set_union(new_groups.begin(),
+ new_groups.end(),
+ updated_groups.begin(),
+ updated_groups.end(),
+ std::back_inserter(groups_to_check_consent));
+
+ StringsConstItr it = groups_to_check_consent.begin();
+ StringsConstItr it_end = groups_to_check_consent.end();
+ for (; it != it_end; ++it) {
+ if (IsConsentRequired(app_policy.first, *it)) {
return true;
}
}
@@ -454,14 +576,16 @@ PermissionsCheckResult CheckAppPolicy::CheckPermissionsChanges(
const bool encryption_required_flag_changed =
IsEncryptionRequiredFlagChanged(app_policy);
+ bool has_updated_groups = HasUpdatedGroups(app_policy);
+
if (has_revoked_groups && has_consent_needed_groups) {
return RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED;
} else if (has_revoked_groups) {
return RESULT_PERMISSIONS_REVOKED;
} else if (has_consent_needed_groups) {
return RESULT_CONSENT_NEEDED;
- } else if (has_new_groups) {
- return RESULT_CONSENT_NOT_REQIURED;
+ } else if (has_new_groups || has_updated_groups) {
+ return RESULT_CONSENT_NOT_REQUIRED;
} else if (encryption_required_flag_changed) {
return RESULT_ENCRYPTION_REQUIRED_FLAG_CHANGED;
}
@@ -654,7 +778,7 @@ void FillActionsForAppPolicies::operator()(
case RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED:
actions_[app_id].is_consent_needed = true;
break;
- case RESULT_CONSENT_NOT_REQIURED:
+ case RESULT_CONSENT_NOT_REQUIRED:
case RESULT_PERMISSIONS_REVOKED:
case RESULT_REQUEST_TYPE_CHANGED:
case RESULT_REQUEST_SUBTYPE_CHANGED:
@@ -762,8 +886,7 @@ void FillNotificationData::UpdateParameters(
}
for (; it_parameters != it_parameters_end; ++it_parameters) {
- out_parameter[current_key_].insert(
- policy_table::EnumToJsonString(*it_parameters));
+ out_parameter[current_key_].insert(*it_parameters);
}
// We should reset ALL DISALLOWED flags if at least one parameter is allowed
diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc
index 0629fea022..92be87a9fc 100644
--- a/src/components/policy/policy_external/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_external/src/policy_manager_impl.cc
@@ -302,7 +302,9 @@ void FilterInvalidFunctions(policy_table::Rpc& rpcs) {
* schema
* @param rpc_parameters parameters to filter
*/
-void FilterInvalidRPCParameters(policy_table::RpcParameters& rpc_parameters) {
+void FilterInvalidRPCParameters(
+ policy_table::RpcParameters& rpc_parameters,
+ const std::vector<policy_table::VehicleDataItem>& vehicle_data_items) {
policy_table::HmiLevels valid_hmi_levels;
for (const auto& hmi_level : rpc_parameters.hmi_levels) {
if (hmi_level.is_valid()) {
@@ -311,10 +313,31 @@ void FilterInvalidRPCParameters(policy_table::RpcParameters& rpc_parameters) {
}
rpc_parameters.hmi_levels.swap(valid_hmi_levels);
+ auto ParamExists =
+ [&vehicle_data_items](const rpc::String<0, 255>& param_name) {
+ policy_table::Parameter parameter_enum;
+ if (policy_table::EnumFromJsonString(param_name, &parameter_enum)) {
+ return true;
+ }
+
+ // In case when this collection is empty that means collection is not
+ // initialized
+ if (vehicle_data_items.empty()) {
+ return false;
+ }
+
+ for (const auto& vdi : vehicle_data_items) {
+ if (param_name == vdi.name) {
+ return true;
+ }
+ }
+ return false;
+ };
+
policy_table::Parameters valid_params;
const policy_table::Parameters& params = *(rpc_parameters.parameters);
for (const auto& param : params) {
- if (param.is_valid()) {
+ if (param.is_valid() && ParamExists(param)) {
valid_params.push_back(param);
}
}
@@ -404,7 +427,9 @@ void FilterInvalidApplicationParameters(
* @brief FilterPolicyTable filter values that not present in schema
* @param pt policy table to filter
*/
-void FilterPolicyTable(policy_table::PolicyTable& pt) {
+void FilterPolicyTable(
+ policy_table::PolicyTable& pt,
+ const std::vector<policy_table::VehicleDataItem>& current_vd_items) {
policy_table::ModuleConfig& module_config = pt.module_config;
if (module_config.is_initialized() &&
module_config.notifications_per_minute_by_priority.is_initialized()) {
@@ -423,8 +448,18 @@ void FilterPolicyTable(policy_table::PolicyTable& pt) {
policy_table::Rpc& rpcs = group.second.rpcs;
FilterInvalidFunctions(rpcs);
+ policy_table::VehicleDataItems vehicle_data_items;
+
+ if (!pt.vehicle_data->struct_empty()) {
+ vehicle_data_items =
+ pt.vehicle_data.is_initialized() &&
+ pt.vehicle_data->schema_items.is_initialized()
+ ? *pt.vehicle_data->schema_items
+ : current_vd_items;
+ }
+
for (auto& func : rpcs) {
- FilterInvalidRPCParameters(func.second);
+ FilterInvalidRPCParameters(func.second, vehicle_data_items);
}
}
}
@@ -445,7 +480,9 @@ bool PolicyManagerImpl::LoadPT(const std::string& file,
}
file_system::DeleteFile(file);
- FilterPolicyTable(pt_update->policy_table);
+ auto current_vd_items = GetVehicleDataItems();
+
+ FilterPolicyTable(pt_update->policy_table, current_vd_items);
if (!IsPTValid(pt_update, policy_table::PT_UPDATE)) {
wrong_ptu_update_received_ = true;
update_status_manager_.OnWrongUpdateReceived();
@@ -469,13 +506,9 @@ bool PolicyManagerImpl::LoadPT(const std::string& file,
return false;
}
- // Checking of difference between PTU and current policy state
- // Must to be done before PTU applying since it is possible, that functional
- // groups, which had been present before are absent in PTU and will be
- // removed after update. So in case of revoked groups system has to know
- // names and ids of revoked groups before they will be removed.
- CheckAppPolicyResults results =
- CheckPermissionsChanges(pt_update, policy_table_snapshot);
+ // Replace predefined policies with its actual setting, e.g. "123":"default"
+ // to actual values of default section
+ UnwrapAppPolicies(pt_update->policy_table.app_policies_section.apps);
// Replace current data with updated
if (!cache_->ApplyUpdate(*pt_update)) {
@@ -486,6 +519,14 @@ bool PolicyManagerImpl::LoadPT(const std::string& file,
return false;
}
+ // Checking of difference between PTU and current policy state
+ // Must to be done before PTU applying since it is possible, that functional
+ // groups, which had been present before are absent in PTU and will be
+ // removed after update. So in case of revoked groups system has to know
+ // names and ids of revoked groups before they will be removed.
+ CheckAppPolicyResults results =
+ CheckPermissionsChanges(pt_update, policy_table_snapshot);
+
ExternalConsentStatus status = cache_->GetExternalConsentStatus();
GroupsByExternalConsentStatus groups_by_status =
cache_->GetGroupsWithSameEntities(status);
@@ -533,10 +574,6 @@ CheckAppPolicyResults PolicyManagerImpl::CheckPermissionsChanges(
const std::shared_ptr<policy_table::Table> snapshot) {
LOG4CXX_AUTO_TRACE(logger_);
- // Replace predefined policies with its actual setting, e.g. "123":"default"
- // to actual values of default section
- UnwrapAppPolicies(pt_update->policy_table.app_policies_section.apps);
-
CheckAppPolicyResults out_results;
std::for_each(pt_update->policy_table.app_policies_section.apps.begin(),
pt_update->policy_table.app_policies_section.apps.end(),
@@ -753,8 +790,13 @@ const std::vector<std::string> PolicyManagerImpl::GetAppRequestSubTypes(
return request_subtypes;
}
-const VehicleInfo PolicyManagerImpl::GetVehicleInfo() const {
- return cache_->GetVehicleInfo();
+const std::vector<policy_table::VehicleDataItem>
+PolicyManagerImpl::GetVehicleDataItems() const {
+ return cache_->GetVehicleDataItems();
+}
+
+Json::Value PolicyManagerImpl::GetPolicyTableData() const {
+ return cache_->GetPolicyTableData();
}
void PolicyManagerImpl::GetEnabledCloudApps(
@@ -986,7 +1028,12 @@ void PolicyManagerImpl::CheckPermissions(const PTString& device_id,
result.hmi_level_permitted = kRpcUserDisallowed;
} else if (!result.IsAnyAllowed(rpc_params)) {
LOG4CXX_DEBUG(logger_, "There are no parameters allowed.");
- result.hmi_level_permitted = kRpcDisallowed;
+
+ if (!result.list_of_undefined_params.empty()) {
+ result.hmi_level_permitted = kRpcAllowed;
+ } else {
+ result.hmi_level_permitted = kRpcDisallowed;
+ }
}
}
diff --git a/src/components/policy/policy_external/src/policy_table/enums.cc b/src/components/policy/policy_external/src/policy_table/enums.cc
index c7dfe98271..8f5d58aad2 100644
--- a/src/components/policy/policy_external/src/policy_table/enums.cc
+++ b/src/components/policy/policy_external/src/policy_table/enums.cc
@@ -3,555 +3,6 @@
namespace rpc {
namespace policy_table_interface_base {
-bool IsValidEnum(Priority val) {
- switch (val) {
- case P_EMERGENCY:
- return true;
- case P_NAVIGATION:
- return true;
- case P_VOICECOM:
- return true;
- case P_COMMUNICATION:
- return true;
- case P_NORMAL:
- return true;
- case P_PROJECTION:
- return true;
- case P_NONE:
- return true;
- default:
- return false;
- }
-}
-const char* EnumToJsonString(Priority val) {
- switch (val) {
- case P_EMERGENCY:
- return "EMERGENCY";
- case P_NAVIGATION:
- return "NAVIGATION";
- case P_VOICECOM:
- return "VOICECOM";
- case P_COMMUNICATION:
- return "COMMUNICATION";
- case P_NORMAL:
- return "NORMAL";
- case P_PROJECTION:
- return "PROJECTION";
- case P_NONE:
- return "NONE";
- default:
- return "";
- }
-}
-bool EnumFromJsonString(const std::string& literal, Priority* result) {
- if ("EMERGENCY" == literal) {
- *result = P_EMERGENCY;
- return true;
- } else if ("NAVIGATION" == literal) {
- *result = P_NAVIGATION;
- return true;
- } else if ("VOICECOM" == literal) {
- *result = P_VOICECOM;
- return true;
- } else if ("COMMUNICATION" == literal) {
- *result = P_COMMUNICATION;
- return true;
- } else if ("NORMAL" == literal) {
- *result = P_NORMAL;
- return true;
- } else if ("PROJECTION" == literal) {
- *result = P_PROJECTION;
- return true;
- } else if ("NONE" == literal) {
- *result = P_NONE;
- return true;
- } else {
- return false;
- }
-}
-
-bool IsValidEnum(HmiLevel val) {
- switch (val) {
- case HL_BACKGROUND:
- return true;
- case HL_FULL:
- return true;
- case HL_LIMITED:
- return true;
- case HL_NONE:
- return true;
- default:
- return false;
- }
-}
-const char* EnumToJsonString(HmiLevel val) {
- switch (val) {
- case HL_BACKGROUND:
- return "BACKGROUND";
- case HL_FULL:
- return "FULL";
- case HL_LIMITED:
- return "LIMITED";
- case HL_NONE:
- return "NONE";
- default:
- return "";
- }
-}
-bool EnumFromJsonString(const std::string& literal, HmiLevel* result) {
- if ("BACKGROUND" == literal) {
- *result = HL_BACKGROUND;
- return true;
- } else if ("FULL" == literal) {
- *result = HL_FULL;
- return true;
- } else if ("LIMITED" == literal) {
- *result = HL_LIMITED;
- return true;
- } else if ("NONE" == literal) {
- *result = HL_NONE;
- return true;
- } else {
- return false;
- }
-}
-
-bool IsValidEnum(Parameter val) {
- switch (val) {
- case P_GPS:
- return true;
- case P_SPEED:
- return true;
- case P_ENGINETORQUE:
- return true;
- case P_EXTERNALTEMPERATURE:
- return true;
- case P_TURNSIGNAL:
- return true;
- case P_FUELLEVEL:
- return true;
- case P_FUELLEVEL_STATE:
- return true;
- case P_HEADLAMPSTATUS:
- return true;
- case P_INSTANTFUELCONSUMPTION:
- return true;
- case P_FUELRANGE:
- return true;
- case P_CLOUD_APP_VEHICLE_ID:
- return true;
- case P_ODOMETER:
- return true;
- case P_TIREPRESSURE:
- return true;
- case P_WIPERSTATUS:
- return true;
- case P_VIN:
- return true;
- case P_ACCPEDALPOSITION:
- return true;
- case P_BELTSTATUS:
- return true;
- case P_ELECTRONICPARKBRAKESTATUS:
- return true;
- case P_DRIVERBRAKING:
- return true;
- case P_PRNDL:
- return true;
- case P_RPM:
- return true;
- case P_STEERINGWHEELANGLE:
- return true;
- case P_ENGINEOILLIFE:
- return true;
- case P_MYKEY:
- return true;
- case P_AIRBAGSTATUS:
- return true;
- case P_BODYINFORMATION:
- return true;
- case P_CLUSTERMODESTATUS:
- return true;
- case P_DEVICESTATUS:
- return true;
- case P_EMERGENCYEVENT:
- return true;
- case P_ECALLINFO:
- return true;
- case P_ABS_STATE:
- return true;
- case P_FUEL_RANGE:
- return true;
- case P_TIRE_PRESSURE_VALUE:
- return true;
- case P_TPMS:
- return true;
- case P_LONGTITUDE_DEGREES:
- return true;
- case P_LATITUDE_DEGREES:
- return true;
- case P_LOCATION_NAME:
- return true;
- case P_LOCATION_DESCRIPTION:
- return true;
- case P_ADDRESS_LINES:
- return true;
- case P_PHONE_NUMBER:
- return true;
- case P_LOCATION_IMAGE:
- return true;
- case P_DELIVERY_MODE:
- return true;
- case P_TIMESTAMP:
- return true;
- case P_ADDRESS:
- return true;
- case P_EMPTY:
- return true;
- default:
- return false;
- }
-}
-
-const char* EnumToJsonString(Parameter val) {
- switch (val) {
- case P_GPS:
- return "gps";
- case P_SPEED:
- return "speed";
- case P_ENGINETORQUE:
- return "engineTorque";
- case P_EXTERNALTEMPERATURE:
- return "externalTemperature";
- case P_TURNSIGNAL:
- return "turnSignal";
- case P_FUELLEVEL:
- return "fuelLevel";
- case P_FUELLEVEL_STATE:
- return "fuelLevel_State";
- case P_HEADLAMPSTATUS:
- return "headLampStatus";
- case P_INSTANTFUELCONSUMPTION:
- return "instantFuelConsumption";
- case P_FUELRANGE:
- return "fuelRange";
- case P_CLOUD_APP_VEHICLE_ID:
- return "cloudAppVehicleID";
- case P_ODOMETER:
- return "odometer";
- case P_TIREPRESSURE:
- return "tirePressure";
- case P_WIPERSTATUS:
- return "wiperStatus";
- case P_VIN:
- return "vin";
- case P_ACCPEDALPOSITION:
- return "accPedalPosition";
- case P_BELTSTATUS:
- return "beltStatus";
- case P_ELECTRONICPARKBRAKESTATUS:
- return "electronicParkBrakeStatus";
- case P_DRIVERBRAKING:
- return "driverBraking";
- case P_PRNDL:
- return "prndl";
- case P_RPM:
- return "rpm";
- case P_STEERINGWHEELANGLE:
- return "steeringWheelAngle";
- case P_ENGINEOILLIFE:
- return "engineOilLife";
- case P_MYKEY:
- return "myKey";
- case P_AIRBAGSTATUS:
- return "airbagStatus";
- case P_BODYINFORMATION:
- return "bodyInformation";
- case P_CLUSTERMODESTATUS:
- return "clusterModeStatus";
- case P_DEVICESTATUS:
- return "deviceStatus";
- case P_EMERGENCYEVENT:
- return "emergencyEvent";
- case P_ECALLINFO:
- return "eCallInfo";
- case P_ABS_STATE:
- return "abs_State";
- case P_FUEL_RANGE:
- return "fuelRange";
- case P_TIRE_PRESSURE_VALUE:
- return "tirePressureValue";
- case P_TPMS:
- return "tpms";
- case P_LONGTITUDE_DEGREES:
- return "longitudeDegrees";
- case P_LATITUDE_DEGREES:
- return "latitudeDegrees";
- case P_LOCATION_NAME:
- return "locationName";
- case P_LOCATION_DESCRIPTION:
- return "locationDescription";
- case P_ADDRESS_LINES:
- return "addressLines";
- case P_PHONE_NUMBER:
- return "phoneNumber";
- case P_LOCATION_IMAGE:
- return "locationImage";
- case P_DELIVERY_MODE:
- return "deliveryMode";
- case P_TIMESTAMP:
- return "timeStamp";
- case P_ADDRESS:
- return "address";
- case P_EMPTY:
- return "EMPTY";
- default:
- return "";
- }
-}
-
-bool EnumFromJsonString(const std::string& literal, Parameter* result) {
- if ("gps" == literal) {
- *result = P_GPS;
- return true;
- } else if ("speed" == literal) {
- *result = P_SPEED;
- return true;
- } else if ("engineTorque" == literal) {
- *result = P_ENGINETORQUE;
- return true;
- } else if ("externalTemperature" == literal) {
- *result = P_EXTERNALTEMPERATURE;
- return true;
- } else if ("turnSignal" == literal) {
- *result = P_TURNSIGNAL;
- return true;
- } else if ("fuelLevel" == literal) {
- *result = P_FUELLEVEL;
- return true;
- } else if ("fuelLevel_State" == literal) {
- *result = P_FUELLEVEL_STATE;
- return true;
- } else if ("headLampStatus" == literal) {
- *result = P_HEADLAMPSTATUS;
- return true;
- } else if ("instantFuelConsumption" == literal) {
- *result = P_INSTANTFUELCONSUMPTION;
- return true;
- } else if ("fuelRange" == literal) {
- *result = P_FUELRANGE;
- return true;
- } else if ("cloudAppVehicleID" == literal) {
- *result = P_CLOUD_APP_VEHICLE_ID;
- return true;
- } else if ("odometer" == literal) {
- *result = P_ODOMETER;
- return true;
- } else if ("tirePressure" == literal) {
- *result = P_TIREPRESSURE;
- return true;
- } else if ("wiperStatus" == literal) {
- *result = P_WIPERSTATUS;
- return true;
- } else if ("vin" == literal) {
- *result = P_VIN;
- return true;
- } else if ("accPedalPosition" == literal) {
- *result = P_ACCPEDALPOSITION;
- return true;
- } else if ("beltStatus" == literal) {
- *result = P_BELTSTATUS;
- return true;
- } else if ("electronicParkBrakeStatus" == literal) {
- *result = P_ELECTRONICPARKBRAKESTATUS;
- return true;
- } else if ("driverBraking" == literal) {
- *result = P_DRIVERBRAKING;
- return true;
- } else if ("prndl" == literal) {
- *result = P_PRNDL;
- return true;
- } else if ("rpm" == literal) {
- *result = P_RPM;
- return true;
- } else if ("steeringWheelAngle" == literal) {
- *result = P_STEERINGWHEELANGLE;
- return true;
- } else if ("engineOilLife" == literal) {
- *result = P_ENGINEOILLIFE;
- return true;
- } else if ("myKey" == literal) {
- *result = P_MYKEY;
- return true;
- } else if ("airbagStatus" == literal) {
- *result = P_AIRBAGSTATUS;
- return true;
- } else if ("bodyInformation" == literal) {
- *result = P_BODYINFORMATION;
- return true;
- } else if ("clusterModeStatus" == literal) {
- *result = P_CLUSTERMODESTATUS;
- return true;
- } else if ("deviceStatus" == literal) {
- *result = P_DEVICESTATUS;
- return true;
- } else if ("emergencyEvent" == literal) {
- *result = P_EMERGENCYEVENT;
- return true;
- } else if ("eCallInfo" == literal) {
- *result = P_ECALLINFO;
- return true;
- } else if ("abs_State" == literal) {
- *result = P_ABS_STATE;
- return true;
- } else if ("fuelRange" == literal) {
- *result = P_FUEL_RANGE;
- return true;
- } else if ("tirePressureValue" == literal) {
- *result = P_TIRE_PRESSURE_VALUE;
- return true;
- } else if ("tpms" == literal) {
- *result = P_TPMS;
- return true;
- } else if ("longitudeDegrees" == literal) {
- *result = P_LONGTITUDE_DEGREES;
- return true;
- } else if ("latitudeDegrees" == literal) {
- *result = P_LATITUDE_DEGREES;
- return true;
- } else if ("locationName" == literal) {
- *result = P_LOCATION_NAME;
- return true;
- } else if ("locationDescription" == literal) {
- *result = P_LOCATION_DESCRIPTION;
- return true;
- } else if ("addressLines" == literal) {
- *result = P_ADDRESS_LINES;
- return true;
- } else if ("phoneNumber" == literal) {
- *result = P_PHONE_NUMBER;
- return true;
- } else if ("locationImage" == literal) {
- *result = P_LOCATION_IMAGE;
- return true;
- } else if ("deliveryMode" == literal) {
- *result = P_DELIVERY_MODE;
- return true;
- } else if ("timeStamp" == literal) {
- *result = P_TIMESTAMP;
- return true;
- } else if ("address" == literal) {
- *result = P_ADDRESS;
- return true;
- } else if ("EMPTY" == literal) {
- *result = P_EMPTY;
- return true;
- } else {
- return false;
- }
-}
-
-bool IsValidEnum(AppHMIType val) {
- switch (val) {
- case AHT_DEFAULT:
- return true;
- case AHT_COMMUNICATION:
- return true;
- case AHT_MEDIA:
- return true;
- case AHT_MESSAGING:
- return true;
- case AHT_NAVIGATION:
- return true;
- case AHT_INFORMATION:
- return true;
- case AHT_SOCIAL:
- return true;
- case AHT_BACKGROUND_PROCESS:
- return true;
- case AHT_TESTING:
- return true;
- case AHT_SYSTEM:
- return true;
- case AHT_PROJECTION:
- return true;
- case AHT_REMOTE_CONTROL:
- return true;
- default:
- return false;
- }
-}
-const char* EnumToJsonString(AppHMIType val) {
- switch (val) {
- case AHT_DEFAULT:
- return "DEFAULT";
- case AHT_COMMUNICATION:
- return "COMMUNICATION";
- case AHT_MEDIA:
- return "MEDIA";
- case AHT_MESSAGING:
- return "MESSAGING";
- case AHT_NAVIGATION:
- return "NAVIGATION";
- case AHT_INFORMATION:
- return "INFORMATION";
- case AHT_SOCIAL:
- return "SOCIAL";
- case AHT_BACKGROUND_PROCESS:
- return "BACKGROUND_PROCESS";
- case AHT_TESTING:
- return "TESTING";
- case AHT_SYSTEM:
- return "SYSTEM";
- case AHT_PROJECTION:
- return "PROJECTION";
- case AHT_REMOTE_CONTROL:
- return "REMOTE_CONTROL";
- default:
- return "";
- }
-}
-bool EnumFromJsonString(const std::string& literal, AppHMIType* result) {
- if ("DEFAULT" == literal) {
- *result = AHT_DEFAULT;
- return true;
- } else if ("COMMUNICATION" == literal) {
- *result = AHT_COMMUNICATION;
- return true;
- } else if ("MEDIA" == literal) {
- *result = AHT_MEDIA;
- return true;
- } else if ("MESSAGING" == literal) {
- *result = AHT_MESSAGING;
- return true;
- } else if ("NAVIGATION" == literal) {
- *result = AHT_NAVIGATION;
- return true;
- } else if ("INFORMATION" == literal) {
- *result = AHT_INFORMATION;
- return true;
- } else if ("SOCIAL" == literal) {
- *result = AHT_SOCIAL;
- return true;
- } else if ("BACKGROUND_PROCESS" == literal) {
- *result = AHT_BACKGROUND_PROCESS;
- return true;
- } else if ("TESTING" == literal) {
- *result = AHT_TESTING;
- return true;
- } else if ("SYSTEM" == literal) {
- *result = AHT_SYSTEM;
- return true;
- } else if ("PROJECTION" == literal) {
- *result = AHT_PROJECTION;
- return true;
- } else if ("REMOTE_CONTROL" == literal) {
- *result = AHT_REMOTE_CONTROL;
- return true;
- } else {
- return false;
- }
-}
bool IsValidEnum(Input val) {
switch (val) {
@@ -563,6 +14,7 @@ bool IsValidEnum(Input val) {
return false;
}
}
+
const char* EnumToJsonString(Input val) {
switch (val) {
case I_GUI:
@@ -585,895 +37,6 @@ bool EnumFromJsonString(const std::string& literal, Input* result) {
}
}
-bool IsValidEnum(RequestType val) {
- switch (val) {
- case RT_HTTP:
- return true;
- case RT_FILE_RESUME:
- return true;
- case RT_AUTH_REQUEST:
- return true;
- case RT_AUTH_CHALLENGE:
- return true;
- case RT_AUTH_ACK:
- return true;
- case RT_PROPRIETARY:
- return true;
- case RT_QUERY_APPS:
- return true;
- case RT_LAUNCH_APP:
- return true;
- case RT_LOCK_SCREEN_ICON_URL:
- return true;
- case RT_TRAFFIC_MESSAGE_CHANNEL:
- return true;
- case RT_DRIVER_PROFILE:
- return true;
- case RT_VOICE_SEARCH:
- return true;
- case RT_NAVIGATION:
- return true;
- case RT_PHONE:
- return true;
- case RT_CLIMATE:
- return true;
- case RT_SETTINGS:
- return true;
- case RT_VEHICLE_DIAGNOSTICS:
- return true;
- case RT_EMERGENCY:
- return true;
- case RT_MEDIA:
- return true;
- case RT_FOTA:
- return true;
- case RT_OEM_SPECIFIC:
- return true;
- case RT_ICON_URL:
- return true;
- case RT_EMPTY:
- return true;
- default:
- return false;
- }
-}
-
-const char* EnumToJsonString(RequestType val) {
- switch (val) {
- case RT_HTTP:
- return "HTTP";
- case RT_FILE_RESUME:
- return "FILE_RESUME";
- case RT_AUTH_REQUEST:
- return "AUTH_REQUEST";
- case RT_AUTH_CHALLENGE:
- return "AUTH_CHALLENGE";
- case RT_AUTH_ACK:
- return "AUTH_ACK";
- case RT_PROPRIETARY:
- return "PROPRIETARY";
- case RT_QUERY_APPS:
- return "QUERY_APPS";
- case RT_LAUNCH_APP:
- return "LAUNCH_APP";
- case RT_LOCK_SCREEN_ICON_URL:
- return "LOCK_SCREEN_ICON_URL";
- case RT_TRAFFIC_MESSAGE_CHANNEL:
- return "TRAFFIC_MESSAGE_CHANNEL";
- case RT_DRIVER_PROFILE:
- return "DRIVER_PROFILE";
- case RT_VOICE_SEARCH:
- return "VOICE_SEARCH";
- case RT_NAVIGATION:
- return "NAVIGATION";
- case RT_PHONE:
- return "PHONE";
- case RT_CLIMATE:
- return "CLIMATE";
- case RT_SETTINGS:
- return "SETTINGS";
- case RT_VEHICLE_DIAGNOSTICS:
- return "VEHICLE_DIAGNOSTICS";
- case RT_EMERGENCY:
- return "EMERGENCY";
- case RT_MEDIA:
- return "MEDIA";
- case RT_FOTA:
- return "FOTA";
- case RT_OEM_SPECIFIC:
- return "OEM_SPECIFIC";
- case RT_ICON_URL:
- return "ICON_URL";
- case RT_EMPTY:
- return "EMPTY";
- default:
- return "";
- }
-}
-
-bool EnumFromJsonString(const std::string& literal, RequestType* result) {
- if ("HTTP" == literal) {
- *result = RT_HTTP;
- return true;
- }
- if ("FILE_RESUME" == literal) {
- *result = RT_FILE_RESUME;
- return true;
- }
- if ("AUTH_REQUEST" == literal) {
- *result = RT_AUTH_REQUEST;
- return true;
- }
- if ("AUTH_CHALLENGE" == literal) {
- *result = RT_AUTH_CHALLENGE;
- return true;
- }
- if ("AUTH_ACK" == literal) {
- *result = RT_AUTH_ACK;
- return true;
- }
- if ("PROPRIETARY" == literal) {
- *result = RT_PROPRIETARY;
- return true;
- }
- if ("QUERY_APPS" == literal) {
- *result = RT_QUERY_APPS;
- return true;
- }
- if ("LAUNCH_APP" == literal) {
- *result = RT_LAUNCH_APP;
- return true;
- }
- if ("LOCK_SCREEN_ICON_URL" == literal) {
- *result = RT_LOCK_SCREEN_ICON_URL;
- return true;
- }
- if ("TRAFFIC_MESSAGE_CHANNEL" == literal) {
- *result = RT_TRAFFIC_MESSAGE_CHANNEL;
- return true;
- }
- if ("DRIVER_PROFILE" == literal) {
- *result = RT_DRIVER_PROFILE;
- return true;
- }
- if ("VOICE_SEARCH" == literal) {
- *result = RT_VOICE_SEARCH;
- return true;
- }
- if ("NAVIGATION" == literal) {
- *result = RT_NAVIGATION;
- return true;
- }
- if ("PHONE" == literal) {
- *result = RT_PHONE;
- return true;
- }
- if ("CLIMATE" == literal) {
- *result = RT_CLIMATE;
- return true;
- }
- if ("SETTINGS" == literal) {
- *result = RT_SETTINGS;
- return true;
- }
- if ("VEHICLE_DIAGNOSTICS" == literal) {
- *result = RT_VEHICLE_DIAGNOSTICS;
- return true;
- }
- if ("EMERGENCY" == literal) {
- *result = RT_EMERGENCY;
- return true;
- }
- if ("MEDIA" == literal) {
- *result = RT_MEDIA;
- return true;
- }
- if ("FOTA" == literal) {
- *result = RT_FOTA;
- return true;
- }
- if ("OEM_SPECIFIC" == literal) {
- *result = RT_OEM_SPECIFIC;
- return true;
- }
- if ("ICON_URL" == literal) {
- *result = RT_ICON_URL;
- return true;
- }
- if ("EMPTY" == literal) {
- *result = RT_EMPTY;
- return true;
- } else {
- return false;
- }
-}
-
-bool IsValidEnum(ModuleType val) {
- switch (val) {
- case MT_CLIMATE:
- return true;
- case MT_RADIO:
- return true;
- case MT_AUDIO:
- return true;
- case MT_LIGHT:
- return true;
- case MT_HMI_SETTINGS:
- return true;
- case MT_SEAT:
- return true;
- case MT_EMPTY:
- return true;
- default:
- return false;
- }
-}
-const char* EnumToJsonString(ModuleType val) {
- switch (val) {
- case MT_CLIMATE:
- return "CLIMATE";
- case MT_RADIO:
- return "RADIO";
- case MT_AUDIO:
- return "AUDIO";
- case MT_LIGHT:
- return "LIGHT";
- case MT_HMI_SETTINGS:
- return "HMI_SETTINGS";
- case MT_SEAT:
- return "SEAT";
- case MT_EMPTY:
- return "EMPTY";
- default:
- return "";
- }
-}
-
-bool EnumFromJsonString(const std::string& literal, ModuleType* result) {
- if ("CLIMATE" == literal) {
- *result = MT_CLIMATE;
- return true;
- } else if ("RADIO" == literal) {
- *result = MT_RADIO;
- return true;
- } else if ("SEAT" == literal) {
- *result = MT_SEAT;
- return true;
- } else if ("AUDIO" == literal) {
- *result = MT_AUDIO;
- return true;
- } else if ("LIGHT" == literal) {
- *result = MT_LIGHT;
- return true;
- } else if ("HMI_SETTINGS" == literal) {
- *result = MT_HMI_SETTINGS;
- return true;
- } else if ("EMPTY" == literal) {
- *result = MT_EMPTY;
- return true;
- } else {
- return false;
- }
-}
-
-bool IsValidEnum(HybridAppPreference val) {
- return strlen(EnumToJsonString(val)) > 0;
-}
-
-const char* EnumToJsonString(HybridAppPreference val) {
- switch (val) {
- case HAP_MOBILE:
- return "MOBILE";
- case HAP_CLOUD:
- return "CLOUD";
- case HAP_BOTH:
- return "BOTH";
- default:
- return "";
- }
-}
-
-bool EnumFromJsonString(const std::string& literal,
- HybridAppPreference* result) {
- if ("MOBILE" == literal) {
- *result = HAP_MOBILE;
- return true;
- } else if ("CLOUD" == literal) {
- *result = HAP_CLOUD;
- return true;
- } else if ("BOTH" == literal) {
- *result = HAP_BOTH;
- return true;
- }
- return false;
-}
-
-const char* EnumToJsonString(FunctionID val) {
- switch (val) {
- case RegisterAppInterfaceID:
- return "RegisterAppInterface";
- case UnregisterAppInterfaceID:
- return "UnregisterAppInterface";
- case SetGlobalPropertiesID:
- return "SetGlobalProperties";
- case ResetGlobalPropertiesID:
- return "ResetGlobalProperties";
- case AddCommandID:
- return "AddCommand";
- case DeleteCommandID:
- return "DeleteCommand";
- case AddSubMenuID:
- return "AddSubMenu";
- case DeleteSubMenuID:
- return "DeleteSubMenu";
- case CreateInteractionChoiceSetID:
- return "CreateInteractionChoiceSet";
- case PerformInteractionID:
- return "PerformInteraction";
- case DeleteInteractionChoiceSetID:
- return "DeleteInteractionChoiceSet";
- case AlertID:
- return "Alert";
- case ShowID:
- return "Show";
- case SpeakID:
- return "Speak";
- case SetMediaClockTimerID:
- return "SetMediaClockTimer";
- case PerformAudioPassThruID:
- return "PerformAudioPassThru";
- case EndAudioPassThruID:
- return "EndAudioPassThru";
- case SubscribeButtonID:
- return "SubscribeButton";
- case UnsubscribeButtonID:
- return "UnsubscribeButton";
- case SubscribeVehicleDataID:
- return "SubscribeVehicleData";
- case UnsubscribeVehicleDataID:
- return "UnsubscribeVehicleData";
- case GetVehicleDataID:
- return "GetVehicleData";
- case ReadDIDID:
- return "ReadDID";
- case GetDTCsID:
- return "GetDTCs";
- case ScrollableMessageID:
- return "ScrollableMessage";
- case SliderID:
- return "Slider";
- case ShowConstantTBTID:
- return "ShowConstantTBT";
- case AlertManeuverID:
- return "AlertManeuver";
- case UpdateTurnListID:
- return "UpdateTurnList";
- case ChangeRegistrationID:
- return "ChangeRegistration";
- case GenericResponseID:
- return "GenericResponse";
- case PutFileID:
- return "PutFile";
- case DeleteFileID:
- return "DeleteFile";
- case ListFilesID:
- return "ListFiles";
- case SetAppIconID:
- return "SetAppIcon";
- case SetDisplayLayoutID:
- return "SetDisplayLayout";
- case DiagnosticMessageID:
- return "DiagnosticMessage";
- case SystemRequestID:
- return "SystemRequest";
- case SendLocationID:
- return "SendLocation";
- case DialNumberID:
- return "DialNumber";
- case ButtonPressID:
- return "ButtonPress";
- case GetInteriorVehicleDataID:
- return "GetInteriorVehicleData";
- case SetInteriorVehicleDataID:
- return "SetInteriorVehicleData";
- case GetWayPointsID:
- return "GetWayPoints";
- case SubscribeWayPointsID:
- return "SubscribeWayPoints";
- case UnsubscribeWayPointsID:
- return "UnsubscribeWayPoints";
- case GetSystemCapabilityID:
- return "GetSystemCapability";
- case SendHapticDataID:
- return "SendHapticData";
- case SetCloudAppPropertiesID:
- return "SetCloudAppProperties";
- case GetCloudAppPropertiesID:
- return "GetCloudAppProperties";
- case PublishAppServiceID:
- return "PublishAppService";
- case GetFileID:
- return "GetFile";
- case GetAppServiceDataID:
- return "GetAppServiceData";
- case PerformAppServiceInteractionID:
- return "PerformAppServiceInteraction";
- case OnHMIStatusID:
- return "OnHMIStatus";
- case OnAppInterfaceUnregisteredID:
- return "OnAppInterfaceUnregistered";
- case OnButtonEventID:
- return "OnButtonEvent";
- case OnButtonPressID:
- return "OnButtonPress";
- case OnVehicleDataID:
- return "OnVehicleData";
- case OnCommandID:
- return "OnCommand";
- case OnTBTClientStateID:
- return "OnTBTClientState";
- case OnDriverDistractionID:
- return "OnDriverDistraction";
- case OnPermissionsChangeID:
- return "OnPermissionsChange";
- case OnAudioPassThruID:
- return "OnAudioPassThru";
- case OnLanguageChangeID:
- return "OnLanguageChange";
- case OnKeyboardInputID:
- return "OnKeyboardInput";
- case OnTouchEventID:
- return "OnTouchEvent";
- case OnSystemRequestID:
- return "OnSystemRequest";
- case OnHashChangeID:
- return "OnHashChange";
- case OnInteriorVehicleDataID:
- return "OnInteriorVehicleData";
- case OnWayPointChangeID:
- return "OnWayPointChange";
- case OnRCStatusID:
- return "OnRCStatus";
- case OnAppServiceDataID:
- return "OnAppServiceData";
- case EncodedSyncPDataID:
- return "EncodedSyncPData";
- case SyncPDataID:
- return "SyncPData";
- case OnEncodedSyncPDataID:
- return "OnEncodedSyncPData";
- case OnSyncPDataID:
- return "OnSyncPData";
- case OnSystemCapabilityUpdatedID:
- return "OnSystemCapabilityUpdated";
- default:
- return "";
- }
-};
-
-bool EnumFromJsonString(const std::string& literal, FunctionID* result) {
- if ("RegisterAppInterface" == literal) {
- *result = RegisterAppInterfaceID;
- return true;
- }
-
- if ("UnregisterAppInterface" == literal) {
- *result = UnregisterAppInterfaceID;
- return true;
- }
-
- if ("SetGlobalProperties" == literal) {
- *result = SetGlobalPropertiesID;
- return true;
- }
-
- if ("ResetGlobalProperties" == literal) {
- *result = ResetGlobalPropertiesID;
- return true;
- }
-
- if ("AddCommand" == literal) {
- *result = AddCommandID;
- return true;
- }
-
- if ("DeleteCommand" == literal) {
- *result = DeleteCommandID;
- return true;
- }
-
- if ("AddSubMenu" == literal) {
- *result = AddSubMenuID;
- return true;
- }
-
- if ("DeleteSubMenu" == literal) {
- *result = DeleteSubMenuID;
- return true;
- }
-
- if ("CreateInteractionChoiceSet" == literal) {
- *result = CreateInteractionChoiceSetID;
- return true;
- }
-
- if ("PerformInteraction" == literal) {
- *result = PerformInteractionID;
- return true;
- }
-
- if ("DeleteInteractionChoiceSet" == literal) {
- *result = DeleteInteractionChoiceSetID;
- return true;
- }
-
- if ("Alert" == literal) {
- *result = AlertID;
- return true;
- }
-
- if ("Show" == literal) {
- *result = ShowID;
- return true;
- }
-
- if ("Speak" == literal) {
- *result = SpeakID;
- return true;
- }
-
- if ("SetMediaClockTimer" == literal) {
- *result = SetMediaClockTimerID;
- return true;
- }
-
- if ("PerformAudioPassThru" == literal) {
- *result = PerformAudioPassThruID;
- return true;
- }
-
- if ("EndAudioPassThru" == literal) {
- *result = EndAudioPassThruID;
- return true;
- }
-
- if ("SubscribeButton" == literal) {
- *result = SubscribeButtonID;
- return true;
- }
-
- if ("UnsubscribeButton" == literal) {
- *result = UnsubscribeButtonID;
- return true;
- }
-
- if ("SubscribeVehicleData" == literal) {
- *result = SubscribeVehicleDataID;
- return true;
- }
-
- if ("UnsubscribeVehicleData" == literal) {
- *result = UnsubscribeVehicleDataID;
- return true;
- }
-
- if ("GetVehicleData" == literal) {
- *result = GetVehicleDataID;
- return true;
- }
-
- if ("ReadDID" == literal) {
- *result = ReadDIDID;
- return true;
- }
-
- if ("GetDTCs" == literal) {
- *result = GetDTCsID;
- return true;
- }
-
- if ("ScrollableMessage" == literal) {
- *result = ScrollableMessageID;
- return true;
- }
-
- if ("Slider" == literal) {
- *result = SliderID;
- return true;
- }
-
- if ("ShowConstantTBT" == literal) {
- *result = ShowConstantTBTID;
- return true;
- }
-
- if ("AlertManeuver" == literal) {
- *result = AlertManeuverID;
- return true;
- }
-
- if ("UpdateTurnList" == literal) {
- *result = UpdateTurnListID;
- return true;
- }
-
- if ("ChangeRegistration" == literal) {
- *result = ChangeRegistrationID;
- return true;
- }
-
- if ("GenericResponse" == literal) {
- *result = GenericResponseID;
- return true;
- }
-
- if ("PutFile" == literal) {
- *result = PutFileID;
- return true;
- }
-
- if ("DeleteFile" == literal) {
- *result = DeleteFileID;
- return true;
- }
-
- if ("ListFiles" == literal) {
- *result = ListFilesID;
- return true;
- }
-
- if ("SetAppIcon" == literal) {
- *result = SetAppIconID;
- return true;
- }
-
- if ("SetDisplayLayout" == literal) {
- *result = SetDisplayLayoutID;
- return true;
- }
-
- if ("DiagnosticMessage" == literal) {
- *result = DiagnosticMessageID;
- return true;
- }
-
- if ("SystemRequest" == literal) {
- *result = SystemRequestID;
- return true;
- }
-
- if ("SendLocation" == literal) {
- *result = SendLocationID;
- return true;
- }
-
- if ("DialNumber" == literal) {
- *result = DialNumberID;
- return true;
- }
-
- if ("ButtonPress" == literal) {
- *result = ButtonPressID;
- return true;
- }
-
- if ("GetInteriorVehicleData" == literal) {
- *result = GetInteriorVehicleDataID;
- return true;
- }
-
- if ("SetInteriorVehicleData" == literal) {
- *result = SetInteriorVehicleDataID;
- return true;
- }
-
- if ("GetWayPoints" == literal) {
- *result = GetWayPointsID;
- return true;
- }
-
- if ("SubscribeWayPoints" == literal) {
- *result = SubscribeWayPointsID;
- return true;
- }
-
- if ("UnsubscribeWayPoints" == literal) {
- *result = UnsubscribeWayPointsID;
- return true;
- }
-
- if ("GetSystemCapability" == literal) {
- *result = GetSystemCapabilityID;
- return true;
- }
-
- if ("SendHapticData" == literal) {
- *result = SendHapticDataID;
- return true;
- }
-
- if ("SetCloudAppProperties" == literal) {
- *result = SetCloudAppPropertiesID;
- return true;
- }
-
- if ("GetCloudAppProperties" == literal) {
- *result = GetCloudAppPropertiesID;
- return true;
- }
-
- if ("PublishAppService" == literal) {
- *result = PublishAppServiceID;
- return true;
- }
-
- if ("GetFile" == literal) {
- *result = GetFileID;
- return true;
- }
-
- if ("GetAppServiceData" == literal) {
- *result = GetAppServiceDataID;
- return true;
- }
-
- if ("PerformAppServiceInteraction" == literal) {
- *result = PerformAppServiceInteractionID;
- return true;
- }
-
- if ("UnpublishAppService" == literal) {
- *result = UnpublishAppServiceID;
- return true;
- }
-
- if ("CancelInteraction" == literal) {
- *result = CancelInteractionID;
- return true;
- }
-
- if ("CreateWindow" == literal) {
- *result = CreateWindowID;
- return true;
- }
-
- if ("DeleteWindow" == literal) {
- *result = DeleteWindowID;
- return true;
- }
-
- if ("CloseApplication" == literal) {
- *result = CloseApplicationID;
- return true;
- }
-
- if ("ShowAppMenu" == literal) {
- *result = ShowAppMenuID;
- return true;
- }
-
- if ("OnHMIStatus" == literal) {
- *result = OnHMIStatusID;
- return true;
- }
-
- if ("OnAppInterfaceUnregistered" == literal) {
- *result = OnAppInterfaceUnregisteredID;
- return true;
- }
-
- if ("OnButtonEvent" == literal) {
- *result = OnButtonEventID;
- return true;
- }
-
- if ("OnButtonPress" == literal) {
- *result = OnButtonPressID;
- return true;
- }
-
- if ("OnVehicleData" == literal) {
- *result = OnVehicleDataID;
- return true;
- }
-
- if ("OnCommand" == literal) {
- *result = OnCommandID;
- return true;
- }
-
- if ("OnTBTClientState" == literal) {
- *result = OnTBTClientStateID;
- return true;
- }
-
- if ("OnDriverDistraction" == literal) {
- *result = OnDriverDistractionID;
- return true;
- }
-
- if ("OnPermissionsChange" == literal) {
- *result = OnPermissionsChangeID;
- return true;
- }
-
- if ("OnAudioPassThru" == literal) {
- *result = OnAudioPassThruID;
- return true;
- }
-
- if ("OnLanguageChange" == literal) {
- *result = OnLanguageChangeID;
- return true;
- }
-
- if ("OnKeyboardInput" == literal) {
- *result = OnKeyboardInputID;
- return true;
- }
-
- if ("OnTouchEvent" == literal) {
- *result = OnTouchEventID;
- return true;
- }
-
- if ("OnSystemRequest" == literal) {
- *result = OnSystemRequestID;
- return true;
- }
-
- if ("OnHashChange" == literal) {
- *result = OnHashChangeID;
- return true;
- }
-
- if ("OnInteriorVehicleData" == literal) {
- *result = OnInteriorVehicleDataID;
- return true;
- }
-
- if ("OnWayPointChange" == literal) {
- *result = OnWayPointChangeID;
- return true;
- }
-
- if ("OnRCStatus" == literal) {
- *result = OnRCStatusID;
- return true;
- }
-
- if ("OnAppServiceData" == literal) {
- *result = OnAppServiceDataID;
- return true;
- }
-
- if ("OnSystemCapabilityUpdated" == literal) {
- *result = OnSystemCapabilityUpdatedID;
- return true;
- }
-
- if ("EncodedSyncPData" == literal) {
- *result = EncodedSyncPDataID;
- return true;
- }
-
- if ("SyncPData" == literal) {
- *result = SyncPDataID;
- return true;
- }
-
- if ("OnEncodedSyncPData" == literal) {
- *result = OnEncodedSyncPDataID;
- return true;
- }
-
- if ("OnSyncPData" == literal) {
- *result = OnSyncPDataID;
- return true;
- }
- return false;
-};
-
const std::string kDefaultApp = "default";
const std::string kPreDataConsentApp = "pre_DataConsent";
const std::string kDeviceApp = "device";
diff --git a/src/components/policy/policy_external/src/policy_table/types.cc b/src/components/policy/policy_external/src/policy_table/types.cc
index cfe5ceed30..73b2002056 100644
--- a/src/components/policy/policy_external/src/policy_table/types.cc
+++ b/src/components/policy/policy_external/src/policy_table/types.cc
@@ -768,9 +768,60 @@ void Rpcs::SetPolicyTableType(PolicyTableType pt_type) {
disallowed_by_external_consent_entities_on.SetPolicyTableType(pt_type);
}
+// EndpointProperties methods
+EndpointProperty::EndpointProperty() : CompositeType(kUninitialized) {}
+
+EndpointProperty::~EndpointProperty() {}
+
+EndpointProperty::EndpointProperty(const Json::Value* value__)
+ : CompositeType(InitHelper(value__, &Json::Value::isObject))
+ , version(impl::ValueMember(value__, "version")) {}
+
+Json::Value EndpointProperty::ToJsonValue() const {
+ Json::Value result__(Json::objectValue);
+ impl::WriteJsonField("version", version, &result__);
+ return result__;
+}
+
+bool EndpointProperty::is_valid() const {
+ if (!version.is_valid()) {
+ return false;
+ }
+ return Validate();
+}
+
+bool EndpointProperty::is_initialized() const {
+ return (initialization_state__ != kUninitialized) || (!struct_empty());
+}
+
+bool EndpointProperty::struct_empty() const {
+ if (version.is_initialized()) {
+ return false;
+ }
+
+ return true;
+}
+
+void EndpointProperty::ReportErrors(rpc::ValidationReport* report__) const {
+ if (struct_empty()) {
+ rpc::CompositeType::ReportErrors(report__);
+ }
+ if (!version.is_valid()) {
+ version.ReportErrors(&report__->ReportSubobject("version"));
+ }
+}
+
+void EndpointProperty::SetPolicyTableType(PolicyTableType pt_type) {
+ CompositeType::SetPolicyTableType(pt_type);
+ version.SetPolicyTableType(pt_type);
+}
+
// ModuleConfig methods
ModuleConfig::ModuleConfig() : CompositeType(kUninitialized) {}
+const std::string ModuleConfig::kDefaultOemMappingServiceName =
+ "custom_vehicle_data_mapping_url";
+
ModuleConfig::ModuleConfig(
uint8_t exchange_after_x_ignition_cycles,
int64_t exchange_after_x_kilometers,
@@ -778,6 +829,7 @@ ModuleConfig::ModuleConfig(
uint16_t timeout_after_x_seconds,
const SecondsBetweenRetries& seconds_between_retries,
const ServiceEndpoints& endpoints,
+ const ServiceEndpointProperties& endpoint_properties,
const NumberOfNotificationsPerMinute& notifications_per_minute_by_priority)
: CompositeType(kUninitialized)
, exchange_after_x_ignition_cycles(exchange_after_x_ignition_cycles)
@@ -786,6 +838,7 @@ ModuleConfig::ModuleConfig(
, timeout_after_x_seconds(timeout_after_x_seconds)
, seconds_between_retries(seconds_between_retries)
, endpoints(endpoints)
+ , endpoint_properties(endpoint_properties)
, notifications_per_minute_by_priority(
notifications_per_minute_by_priority) {}
@@ -803,6 +856,7 @@ ModuleConfig::ModuleConfig(const Json::Value* value__)
, seconds_between_retries(
impl::ValueMember(value__, "seconds_between_retries"))
, endpoints(impl::ValueMember(value__, "endpoints"))
+ , endpoint_properties(impl::ValueMember(value__, "endpoint_properties"))
, notifications_per_minute_by_priority(
impl::ValueMember(value__, "notifications_per_minute_by_priority"))
, vehicle_make(impl::ValueMember(value__, "vehicle_make"))
@@ -823,6 +877,7 @@ void ModuleConfig::SafeCopyFrom(const ModuleConfig& from) {
timeout_after_x_seconds = from.timeout_after_x_seconds;
seconds_between_retries = from.seconds_between_retries;
endpoints = from.endpoints;
+ endpoint_properties = from.endpoint_properties;
notifications_per_minute_by_priority =
from.notifications_per_minute_by_priority;
lock_screen_dismissal_enabled = from.lock_screen_dismissal_enabled;
@@ -851,6 +906,7 @@ Json::Value ModuleConfig::ToJsonValue() const {
impl::WriteJsonField(
"seconds_between_retries", seconds_between_retries, &result__);
impl::WriteJsonField("endpoints", endpoints, &result__);
+ impl::WriteJsonField("endpoint_properties", endpoint_properties, &result__);
impl::WriteJsonField("notifications_per_minute_by_priority",
notifications_per_minute_by_priority,
&result__);
@@ -893,6 +949,9 @@ bool ModuleConfig::is_valid() const {
if (!endpoints.is_valid()) {
return false;
}
+ if (!endpoint_properties.is_valid()) {
+ return false;
+ }
if (!notifications_per_minute_by_priority.is_valid()) {
return false;
}
@@ -953,6 +1012,10 @@ bool ModuleConfig::struct_empty() const {
return false;
}
+ if (endpoint_properties.is_initialized()) {
+ return false;
+ }
+
if (notifications_per_minute_by_priority.is_initialized()) {
return false;
}
@@ -1009,6 +1072,10 @@ void ModuleConfig::ReportErrors(rpc::ValidationReport* report__) const {
if (!endpoints.is_valid()) {
endpoints.ReportErrors(&report__->ReportSubobject("endpoints"));
}
+ if (!endpoint_properties.is_valid()) {
+ endpoint_properties.ReportErrors(
+ &report__->ReportSubobject("endpoint_properties"));
+ }
if (!notifications_per_minute_by_priority.is_valid()) {
notifications_per_minute_by_priority.ReportErrors(
&report__->ReportSubobject("notifications_per_minute_by_priority"));
@@ -1074,6 +1141,7 @@ void ModuleConfig::SetPolicyTableType(PolicyTableType pt_type) {
timeout_after_x_seconds.SetPolicyTableType(pt_type);
seconds_between_retries.SetPolicyTableType(pt_type);
endpoints.SetPolicyTableType(pt_type);
+ endpoint_properties.SetPolicyTableType(pt_type);
notifications_per_minute_by_priority.SetPolicyTableType(pt_type);
lock_screen_dismissal_enabled.SetPolicyTableType(pt_type);
vehicle_make.SetPolicyTableType(pt_type);
@@ -2115,6 +2183,421 @@ void DeviceParams::SetPolicyTableType(PolicyTableType pt_type) {
connection_type.SetPolicyTableType(pt_type);
}
+// VehicleDataItem methods
+VehicleDataItem::VehicleDataItem() : CompositeType(kUninitialized) {}
+
+VehicleDataItem::VehicleDataItem(const VehicleDataItem& vehicle_data)
+ : CompositeType(vehicle_data.initialization_state__)
+ , name(vehicle_data.name)
+ , type(vehicle_data.type)
+ , key(vehicle_data.key)
+ , mandatory(vehicle_data.mandatory)
+ , params(vehicle_data.params)
+ , array(vehicle_data.array)
+ , since(vehicle_data.since)
+ , until(vehicle_data.until)
+ , removed(vehicle_data.removed)
+ , deprecated(vehicle_data.deprecated)
+ , minvalue(vehicle_data.minvalue)
+ , maxvalue(vehicle_data.maxvalue)
+ , minsize(vehicle_data.minsize)
+ , maxsize(vehicle_data.maxsize)
+ , minlength(vehicle_data.minlength)
+ , maxlength(vehicle_data.maxlength) {}
+
+VehicleDataItem::VehicleDataItem(const Json::Value* value__)
+ : CompositeType(InitHelper(value__, &Json::Value::isObject))
+ , name(impl::ValueMember(value__, "name"))
+ , type(impl::ValueMember(value__, "type"))
+ , key(impl::ValueMember(value__, "key"))
+ , mandatory(impl::ValueMember(value__, "mandatory"))
+ , params(impl::ValueMember(value__, "params"))
+ , array(impl::ValueMember(value__, "array"))
+ , since(impl::ValueMember(value__, "since"))
+ , until(impl::ValueMember(value__, "until"))
+ , removed(impl::ValueMember(value__, "removed"))
+ , deprecated(impl::ValueMember(value__, "deprecated"))
+ , minvalue(impl::ValueMember(value__, "minvalue"))
+ , maxvalue(impl::ValueMember(value__, "maxvalue"))
+ , minsize(impl::ValueMember(value__, "minsize"))
+ , maxsize(impl::ValueMember(value__, "maxsize"))
+ , minlength(impl::ValueMember(value__, "minlength"))
+ , maxlength(impl::ValueMember(value__, "maxlength")) {}
+
+VehicleDataItem::~VehicleDataItem() {}
+
+const std::string VehicleDataItem::kInteger = "Integer";
+const std::string VehicleDataItem::kStruct = "Struct";
+const std::string VehicleDataItem::kString = "String";
+const std::string VehicleDataItem::kFloat = "Float";
+const std::string VehicleDataItem::kDouble = "Double";
+const std::string VehicleDataItem::kBoolean = "Boolean";
+
+const std::vector<std::string> VehicleDataItem::kPODTypes = {
+ kInteger, kFloat, kDouble, kString, kBoolean};
+
+Json::Value VehicleDataItem::ToJsonValue() const {
+ Json::Value ret(Json::objectValue);
+ impl::WriteJsonField("name", name, &ret);
+ impl::WriteJsonField("type", type, &ret);
+ impl::WriteJsonField("key", key, &ret);
+ impl::WriteJsonField("array", array, &ret);
+ impl::WriteJsonField("mandatory", mandatory, &ret);
+ impl::WriteJsonField("params", params, &ret);
+ impl::WriteJsonField("since", since, &ret);
+ impl::WriteJsonField("until", until, &ret);
+ impl::WriteJsonField("removed", removed, &ret);
+ impl::WriteJsonField("deprecated", deprecated, &ret);
+ impl::WriteJsonField("minvalue", minvalue, &ret);
+ impl::WriteJsonField("maxvalue", maxvalue, &ret);
+ impl::WriteJsonField("minsize", minsize, &ret);
+ impl::WriteJsonField("maxsize", maxsize, &ret);
+ impl::WriteJsonField("minlength", minlength, &ret);
+ impl::WriteJsonField("maxlength", maxlength, &ret);
+ return ret;
+}
+
+bool VehicleDataItem::operator==(const VehicleDataItem& vd) {
+ return (name == vd.name && type == vd.type && key == vd.key &&
+ mandatory == vd.mandatory && params == vd.params &&
+ array == vd.array && since == vd.since && until == vd.until &&
+ removed == vd.removed && deprecated == vd.deprecated &&
+ minvalue == vd.minvalue && maxvalue == vd.maxvalue &&
+ minsize == vd.minsize && maxsize == vd.maxsize &&
+ minlength == vd.minlength && maxlength == vd.maxlength);
+}
+
+bool VehicleDataItem::is_valid() const {
+ if (!name.is_valid()) {
+ return false;
+ }
+ if (!type.is_valid()) {
+ return false;
+ }
+ if (!key.is_valid()) {
+ return false;
+ }
+ if (!array.is_valid()) {
+ return false;
+ }
+ if (!mandatory.is_valid()) {
+ return false;
+ }
+ if (!params.is_valid()) {
+ return false;
+ }
+ if (!since.is_valid()) {
+ return false;
+ }
+ if (!until.is_valid()) {
+ return false;
+ }
+ if (!removed.is_valid()) {
+ return false;
+ }
+ if (!deprecated.is_valid()) {
+ return false;
+ }
+ if (!minvalue.is_valid()) {
+ return false;
+ }
+ if (!maxvalue.is_valid()) {
+ return false;
+ }
+ if (!minsize.is_valid()) {
+ return false;
+ }
+ if (!maxsize.is_valid()) {
+ return false;
+ }
+ if (!minlength.is_valid()) {
+ return false;
+ }
+ if (!maxlength.is_valid()) {
+ return false;
+ }
+ return Validate();
+}
+
+bool VehicleDataItem::is_initialized() const {
+ return (initialization_state__ != kUninitialized) || (struct_not_empty());
+}
+
+bool VehicleDataItem::struct_not_empty() const {
+ if (!name.is_initialized()) {
+ return false;
+ }
+ if (!type.is_initialized()) {
+ return false;
+ }
+ if (!key.is_initialized()) {
+ return false;
+ }
+ if (!array.is_initialized()) {
+ return false;
+ }
+ if (!mandatory.is_initialized()) {
+ return false;
+ }
+ if (!params.is_initialized()) {
+ return false;
+ }
+ if (!since.is_initialized()) {
+ return false;
+ }
+ if (!until.is_initialized()) {
+ return false;
+ }
+ if (!removed.is_initialized()) {
+ return false;
+ }
+ if (!deprecated.is_initialized()) {
+ return false;
+ }
+ if (!minvalue.is_initialized()) {
+ return false;
+ }
+ if (!maxvalue.is_initialized()) {
+ return false;
+ }
+ if (!minsize.is_initialized()) {
+ return false;
+ }
+ if (!maxsize.is_initialized()) {
+ return false;
+ }
+ if (!minlength.is_initialized()) {
+ return false;
+ }
+ if (!maxlength.is_initialized()) {
+ return false;
+ }
+ return true;
+}
+
+void VehicleDataItem::ReportErrors(rpc::ValidationReport* report__) const {
+ if (!struct_not_empty()) {
+ rpc::CompositeType::ReportErrors(report__);
+ }
+ if (!name.is_valid()) {
+ name.ReportErrors(&report__->ReportSubobject("name"));
+ }
+
+ if (!ValidateNaming(std::string(name))) {
+ report__->set_validation_info(
+ "Invalid name values [" + std::string(name) +
+ "]. It should not contain spaces or invalid chars.");
+ }
+ if (!type.is_valid()) {
+ type.ReportErrors(&report__->ReportSubobject("type"));
+ }
+ if (type.is_initialized() && !ValidateTypes()) {
+ report__->set_validation_info("Unknown type [" + std::string(name) +
+ "]: '" + std::string(type) + "'.");
+ }
+ if (!key.is_valid()) {
+ key.ReportErrors(&report__->ReportSubobject("key"));
+ }
+ if (!ValidateNaming(std::string(key))) {
+ report__->set_validation_info(
+ "Invalid key values [" + std::string(key) +
+ "]. It should not contain spaces or invalid chars.");
+ }
+ if (!array.is_valid()) {
+ array.ReportErrors(&report__->ReportSubobject("array"));
+ }
+ if (!mandatory.is_valid()) {
+ mandatory.ReportErrors(&report__->ReportSubobject("mandatory"));
+ }
+ if (!params.is_valid()) {
+ params.ReportErrors(&report__->ReportSubobject("params"));
+ }
+ if (!since.is_valid()) {
+ since.ReportErrors(&report__->ReportSubobject("since"));
+ }
+ if (!until.is_valid()) {
+ until.ReportErrors(&report__->ReportSubobject("until"));
+ }
+ if (!removed.is_valid()) {
+ removed.ReportErrors(&report__->ReportSubobject("removed"));
+ }
+ if (!deprecated.is_valid()) {
+ deprecated.ReportErrors(&report__->ReportSubobject("deprecated"));
+ }
+ if (!minvalue.is_valid()) {
+ minvalue.ReportErrors(&report__->ReportSubobject("minvalue"));
+ }
+ if (!maxvalue.is_valid()) {
+ maxvalue.ReportErrors(&report__->ReportSubobject("maxvalue"));
+ }
+ if (!minsize.is_valid()) {
+ minsize.ReportErrors(&report__->ReportSubobject("minsize"));
+ }
+ if (!maxsize.is_valid()) {
+ maxsize.ReportErrors(&report__->ReportSubobject("maxsize"));
+ }
+ if (!minlength.is_valid()) {
+ minlength.ReportErrors(&report__->ReportSubobject("minlength"));
+ }
+ if (!maxlength.is_valid()) {
+ maxlength.ReportErrors(&report__->ReportSubobject("maxlength"));
+ }
+}
+
+void VehicleDataItem::SetPolicyTableType(PolicyTableType pt_type) {
+ CompositeType::SetPolicyTableType(pt_type);
+ name.SetPolicyTableType(pt_type);
+ type.SetPolicyTableType(pt_type);
+ key.SetPolicyTableType(pt_type);
+ array.SetPolicyTableType(pt_type);
+ mandatory.SetPolicyTableType(pt_type);
+ params.SetPolicyTableType(pt_type);
+ since.SetPolicyTableType(pt_type);
+ until.SetPolicyTableType(pt_type);
+ removed.SetPolicyTableType(pt_type);
+ deprecated.SetPolicyTableType(pt_type);
+ minvalue.SetPolicyTableType(pt_type);
+ maxvalue.SetPolicyTableType(pt_type);
+ minsize.SetPolicyTableType(pt_type);
+ maxsize.SetPolicyTableType(pt_type);
+ minlength.SetPolicyTableType(pt_type);
+ maxlength.SetPolicyTableType(pt_type);
+}
+
+bool VehicleDataItem::ValidateNaming(std::string str) const {
+ auto contains_spec_chars = [](std::string str) {
+ const auto invalid_chars = "!@#$%^&*";
+ return str.npos != str.find_first_of(invalid_chars);
+ };
+
+ auto contains_spaces = [](std::string str) {
+ const auto found_space =
+ std::find_if(str.begin(), str.end(), [](unsigned char ch) {
+ return std::isspace(ch);
+ });
+
+ return found_space != str.end();
+ };
+
+ auto empty_string = [](std::string str) {
+ str.erase(std::remove_if(str.begin(),
+ str.end(),
+ [](unsigned char ch) { return std::isspace(ch); }),
+ str.end());
+ return str.length() < 1;
+ };
+
+ return !empty_string(str) && !contains_spaces(str) &&
+ !contains_spec_chars(str);
+}
+
+bool VehicleDataItem::ValidateTypes() const {
+ if (IsPrimitiveType() || NULL != EnumSchemaItemFactory::Get(type)) {
+ // params should be empty for POD types
+ // and for enum values, generated from API
+ return (!(params.is_initialized()) || params->empty());
+ }
+
+ if (VehicleDataItem::kStruct == std::string(type)) {
+ return params.is_initialized() && !(params->empty()) && params.is_valid();
+ }
+ return false;
+}
+
+bool VehicleDataItem::IsPrimitiveType() const {
+ return helpers::in_range(kPODTypes, std::string(type));
+}
+
+// VehicleData methods
+VehicleData::VehicleData() : CompositeType(kUninitialized) {}
+
+VehicleData::VehicleData(const VehicleData& vehicle_data)
+ : CompositeType(vehicle_data.initialization_state__)
+ , schema_version(vehicle_data.schema_version)
+ , schema_items(vehicle_data.schema_items) {}
+
+VehicleData::VehicleData(const Json::Value* value__)
+ : CompositeType(InitHelper(value__, &Json::Value::isObject))
+ , schema_version(impl::ValueMember(value__, "schema_version"))
+ , schema_items(impl::ValueMember(value__, "schema_items")) {}
+
+VehicleData::~VehicleData() {}
+
+bool VehicleData::is_valid() const {
+ if (!schema_version.is_valid()) {
+ return false;
+ }
+ if (!schema_items.is_valid()) {
+ return false;
+ }
+ return Validate();
+}
+
+bool VehicleData::is_initialized() const {
+ return (initialization_state__ != kUninitialized) || (!struct_empty());
+}
+
+bool VehicleData::struct_empty() const {
+ if (schema_version.is_initialized()) {
+ return false;
+ }
+ if (schema_items.is_initialized()) {
+ return false;
+ }
+ return true;
+}
+
+Json::Value VehicleData::ToJsonValue() const {
+ Json::Value ret(Json::objectValue);
+ impl::WriteJsonField("schema_version", schema_version, &ret);
+ impl::WriteJsonField("schema_items", schema_items, &ret);
+ return ret;
+}
+
+void VehicleData::ReportErrors(rpc::ValidationReport* report__) const {
+ if (struct_empty()) {
+ rpc::CompositeType::ReportErrors(report__);
+ }
+ const auto pt_type = GetPolicyTableType();
+ const auto pt_type_str = PolicyTableTypeToString(pt_type);
+ std::string validation_info = "";
+
+ if (PT_SNAPSHOT == pt_type) {
+ if (schema_items.is_initialized()) {
+ validation_info +=
+ "; schema_items " + omitted_validation_info + pt_type_str;
+ }
+ if (!schema_version.is_initialized()) {
+ validation_info +=
+ "; schema_version " + required_validation_info + pt_type_str;
+ }
+ report__->set_validation_info(validation_info);
+ }
+ if (PT_UPDATE == pt_type || PT_PRELOADED == pt_type) {
+ if ((schema_version.is_initialized() && !schema_items.is_initialized()) ||
+ (!schema_version.is_initialized() && schema_items.is_initialized())) {
+ validation_info +=
+ "; if schema_version exist, schema_items should "
+ "also exist in " +
+ pt_type_str;
+ }
+ report__->set_validation_info(validation_info);
+ }
+
+ if (!schema_version.is_valid()) {
+ schema_version.ReportErrors(&report__->ReportSubobject("schema_version"));
+ }
+ if (!schema_items.is_valid()) {
+ schema_items.ReportErrors(&report__->ReportSubobject("schema_items"));
+ }
+}
+
+void VehicleData::SetPolicyTableType(PolicyTableType pt_type) {
+ CompositeType::SetPolicyTableType(pt_type);
+ schema_version.SetPolicyTableType(pt_type);
+ schema_items.SetPolicyTableType(pt_type);
+}
+
// PolicyTable methods
PolicyTable::PolicyTable() : CompositeType(kUninitialized) {}
@@ -2141,7 +2624,8 @@ PolicyTable::PolicyTable(const Json::Value* value__)
, module_meta(impl::ValueMember(value__, "module_meta"))
, usage_and_error_counts(
impl::ValueMember(value__, "usage_and_error_counts"))
- , device_data(impl::ValueMember(value__, "device_data")) {}
+ , device_data(impl::ValueMember(value__, "device_data"))
+ , vehicle_data(impl::ValueMember(value__, "vehicle_data")) {}
Json::Value PolicyTable::ToJsonValue() const {
Json::Value result__(Json::objectValue);
@@ -2154,6 +2638,7 @@ Json::Value PolicyTable::ToJsonValue() const {
impl::WriteJsonField(
"usage_and_error_counts", usage_and_error_counts, &result__);
impl::WriteJsonField("device_data", device_data, &result__);
+ impl::WriteJsonField("vehicle_data", vehicle_data, &result__);
return result__;
}
@@ -2179,6 +2664,9 @@ bool PolicyTable::is_valid() const {
if (!device_data.is_valid()) {
return false;
}
+ if (!vehicle_data.is_valid()) {
+ return false;
+ }
return Validate();
}
@@ -2211,6 +2699,10 @@ bool PolicyTable::struct_empty() const {
if (device_data.is_initialized()) {
return false;
}
+
+ if (vehicle_data.is_initialized()) {
+ return false;
+ }
return true;
}
@@ -2253,6 +2745,9 @@ void PolicyTable::ReportErrors(rpc::ValidationReport* report__) const {
if (!device_data.is_valid()) {
device_data.ReportErrors(&report__->ReportSubobject("device_data"));
}
+ if (!vehicle_data.is_valid()) {
+ vehicle_data.ReportErrors(&report__->ReportSubobject("vehicle_data"));
+ }
}
void PolicyTable::SetPolicyTableType(PolicyTableType pt_type) {
@@ -2264,6 +2759,7 @@ void PolicyTable::SetPolicyTableType(PolicyTableType pt_type) {
module_meta.SetPolicyTableType(pt_type);
usage_and_error_counts.SetPolicyTableType(pt_type);
device_data.SetPolicyTableType(pt_type);
+ vehicle_data.SetPolicyTableType(pt_type);
}
// Table methods
diff --git a/src/components/policy/policy_external/src/policy_table/validation.cc b/src/components/policy/policy_external/src/policy_table/validation.cc
index f9c3f82793..12a79748d7 100644
--- a/src/components/policy/policy_external/src/policy_table/validation.cc
+++ b/src/components/policy/policy_external/src/policy_table/validation.cc
@@ -221,6 +221,15 @@ bool RpcParameters::Validate() const {
bool Rpcs::Validate() const {
return true;
}
+
+bool EndpointProperty::Validate() const {
+ if (!version.is_valid()) {
+ return false;
+ }
+
+ return true;
+}
+
bool ModuleConfig::Validate() const {
switch (GetPolicyTableType()) {
case PT_PRELOADED: {
@@ -258,6 +267,14 @@ bool ModuleConfig::Validate() const {
}
}
+ if (endpoint_properties.is_initialized()) {
+ const auto& endpoint_property =
+ endpoint_properties->find(kDefaultOemMappingServiceName);
+ if (endpoint_properties->end() != endpoint_property) {
+ return (*endpoint_property).second.version.is_initialized();
+ }
+ }
+
return true;
}
@@ -304,6 +321,40 @@ bool ConsentRecords::Validate() const {
bool DeviceParams::Validate() const {
return true;
}
+
+bool VehicleDataItem::Validate() const {
+ if (!ValidateNaming(std::string(name))) {
+ return false;
+ };
+
+ if (!ValidateNaming(std::string(key))) {
+ return false;
+ };
+
+ if (!ValidateTypes()) {
+ LOG4CXX_ERROR(
+ logger_,
+ "Unknown type: " << std::string(type) << " of " << std::string(key));
+ return false;
+ }
+ return true;
+}
+
+bool VehicleData::Validate() const {
+ const PolicyTableType policy_table_type = GetPolicyTableType();
+ bool result = true;
+ if (PT_SNAPSHOT == policy_table_type) {
+ result =
+ (!schema_items.is_initialized()) && schema_version.is_initialized();
+ }
+ if (PT_UPDATE == policy_table_type || PT_PRELOADED == policy_table_type) {
+ result =
+ (schema_version.is_initialized() && schema_items.is_initialized()) ||
+ (!schema_version.is_initialized() && !schema_items.is_initialized());
+ }
+ return result;
+}
+
bool PolicyTable::Validate() const {
PolicyTableType policy_table_type = GetPolicyTableType();
diff --git a/src/components/policy/policy_external/src/sql_pt_queries.cc b/src/components/policy/policy_external/src/sql_pt_queries.cc
index 5e89d0b372..e5fde1abf9 100644
--- a/src/components/policy/policy_external/src/sql_pt_queries.cc
+++ b/src/components/policy/policy_external/src/sql_pt_queries.cc
@@ -386,6 +386,11 @@ const std::string kCreateSchema =
"); "
"CREATE INDEX IF NOT EXISTS `endpoint.fk_endpoint_application1_idx` "
" ON `endpoint`(`application_id` COLLATE NOCASE); "
+ /*endpoint properties*/
+ "CREATE TABLE IF NOT EXISTS `endpoint_properties`( "
+ " `service` VARCHAR(100) NOT NULL, "
+ " `version` VARCHAR(100) NOT NULL "
+ ");"
"CREATE TABLE IF NOT EXISTS `message`( "
" `id` INTEGER PRIMARY KEY NOT NULL, "
" `tts` TEXT, "
@@ -449,6 +454,40 @@ const std::string kCreateSchema =
" `entity_id` INTEGER NOT NULL, "
" `on_off` TEXT NOT NULL "
" ); "
+ /*vehicle data*/
+ "CREATE TABLE IF NOT EXISTS `vehicle_data`( "
+ " `schema_version` VARCHAR(100) NOT NULL "
+ ");"
+ /* vehicle data item definition*/
+ "CREATE TABLE IF NOT EXISTS `vehicle_data_item_definition`( "
+ " `name` VARCHAR(255) NOT NULL, "
+ " `type` VARCHAR(255) NOT NULL, "
+ " `key` VARCHAR(255) NOT NULL, "
+ " `mandatory` BOOL NOT NULL, "
+ " `array` BOOL, "
+ " `since` VARCHAR(45), "
+ " `until` VARCHAR(45), "
+ " `removed` BOOL, "
+ " `deprecated` BOOL, "
+ " `minvalue` INTEGER, "
+ " `maxvalue` INTEGER, "
+ " `minsize` INTEGER, "
+ " `maxsize` INTEGER, "
+ " `minlength` INTEGER, "
+ " `maxlength` INTEGER "
+ "); "
+ "CREATE TABLE IF NOT EXISTS `vehicle_data_item_parameters`( "
+ " `parent_name` VARCHAR(255) NOT NULL, "
+ " `parent_key` VARCHAR(255) NOT NULL, "
+ " `param_name` VARCHAR(255) NOT NULL, "
+ " `param_key` VARCHAR(255) NOT NULL, "
+ " CONSTRAINT `fk_vdi_id` "
+ " FOREIGN KEY(`parent_name`, `parent_key`) "
+ " REFERENCES `vehicle_data_item_definition`(`name`, `key`), "
+ " CONSTRAINT `fk_vdi_param_id` "
+ " FOREIGN KEY(`param_name`, `param_key`) "
+ " REFERENCES `vehicle_data_item_definition`(`name`, `key`) "
+ "); "
"COMMIT;";
const std::string kInsertInitData =
@@ -464,6 +503,8 @@ const std::string kInsertInitData =
" `exchange_after_x_ignition_cycles`, `exchange_after_x_kilometers`, "
" `exchange_after_x_days`, `timeout_after_x_seconds`)"
" VALUES(1, 0, 0, 0, 0, 0); "
+ "INSERT OR IGNORE INTO `vehicle_data` ("
+ " `schema_version`) VALUES('0'); "
"INSERT OR IGNORE INTO `priority`(`value`) VALUES ('EMERGENCY'); "
"INSERT OR IGNORE INTO `priority`(`value`) VALUES ('NAVIGATION'); "
"INSERT OR IGNORE INTO `priority`(`value`) VALUES ('VOICECOMMUNICATION'); "
@@ -528,6 +569,7 @@ const std::string kDropSchema =
"DROP TABLE IF EXISTS `message`; "
"DROP INDEX IF EXISTS `endpoint.fk_endpoint_application1_idx`; "
"DROP TABLE IF EXISTS `endpoint`; "
+ "DROP TABLE IF EXISTS `endpoint_properties`; "
"DROP INDEX IF EXISTS `consent_group.fk_consent_group_device1_idx`; "
"DROP INDEX IF EXISTS "
"`consent_group.fk_consent_group_functional_group1_idx`; "
@@ -593,6 +635,9 @@ const std::string kDropSchema =
"DROP TABLE IF EXISTS `device`; "
"DROP TABLE IF EXISTS `_internal_data`; "
"DROP TABLE IF EXISTS `_internal_external_consent_status`; "
+ "DROP TABLE IF EXISTS `vehicle_data`; "
+ "DROP TABLE IF EXISTS `vehicle_data_item_definition`; "
+ "DROP TABLE IF EXISTS `vehicle_data_item_parameters`; "
"COMMIT; "
"VACUUM;";
@@ -601,6 +646,7 @@ const std::string kDeleteData =
"DELETE FROM `message`; "
"DELETE FROM `module_type`; "
"DELETE FROM `endpoint`; "
+ "DELETE FROM `endpoint_properties`; "
"DELETE FROM `consent_group`; "
"DELETE FROM `external_consent_status_group`; "
"DELETE FROM `external_consent_entities`; "
@@ -627,6 +673,9 @@ const std::string kDeleteData =
"DELETE FROM `usage_and_error_count`; "
"DELETE FROM `device`; "
"DELETE FROM `request_type`; "
+ "DELETE FROM `vehicle_data`; "
+ "DELETE FROM `vehicle_data_item_definition`; "
+ "DELETE FROM `vehicle_data_item_parameters`; "
"COMMIT; "
"VACUUM;";
@@ -634,6 +683,82 @@ const std::string kCheckDBIntegrity = "PRAGMA integrity_check";
const std::string kCheckPgNumber = "PRAGMA page_count";
+const std::string kSelectEndpointProperties =
+ "SELECT `service`, `version` FROM `endpoint_properties`";
+
+const std::string kSelectVehicleDataSchemaVersion =
+ "SELECT `schema_version` FROM `vehicle_data` ";
+
+const std::string kSelectVehicleDataItem =
+ "SELECT * FROM `vehicle_data_item_definition` "
+ "WHERE `key` = ? AND `name` = ?";
+
+const std::string kSelectVehicleDataItemWithVersion =
+ "SELECT * FROM `vehicle_data_item_definition` "
+ "WHERE `name` IS ? AND `key` IS ? AND `since` IS ? AND `until` IS ?";
+
+const std::string kSelectVehicleDataItemParams =
+ "SELECT * FROM `vehicle_data_item_parameters` "
+ "WHERE `parent_name` = ? AND `parent_key` = ?";
+
+const std::string kSelectCompositeVehicleDataItemsKey =
+ "SELECT DISTINCT `parent_name`, `parent_key` FROM "
+ "`vehicle_data_item_parameters` "
+ "LEFT JOIN "
+ "(SELECT DISTINCT `param_name`, `param_key` FROM "
+ "`vehicle_data_item_parameters`) `vdi_params` ON "
+ "`vehicle_data_item_parameters`.`parent_name` = `vdi_params`.`param_name` "
+ "AND "
+ "`vehicle_data_item_parameters`.`parent_key` = `vdi_params`.`param_key` "
+ "WHERE `vdi_params`.`param_key` IS NULL";
+
+const std::string kSelectPrimitiveVehicleDataItems =
+ "SELECT * FROM `vehicle_data_item_definition` "
+ "LEFT JOIN ( "
+ "SELECT `parent_name`, `parent_key` FROM `vehicle_data_item_parameters` "
+ "UNION "
+ "SELECT `param_name`, `param_key` FROM `vehicle_data_item_parameters`) "
+ "`vdi_params` ON "
+ "`vehicle_data_item_definition`.`name` = `vdi_params`.`parent_name` "
+ "AND "
+ "`vehicle_data_item_definition`.`key` = `vdi_params`.`parent_key` "
+ "WHERE `vdi_params`.`parent_key` IS NULL";
+
+const std::string kInsertVehicleDataSchemaVersion =
+ "UPDATE `vehicle_data` SET `schema_version` = ?";
+
+const std::string kInsertEndpointVersion =
+ "INSERT OR REPLACE INTO `endpoint_properties`(`service`, "
+ "`version`) "
+ "VALUES(?, ?)";
+
+const std::string kInsertVehicleDataItem =
+ "INSERT INTO `vehicle_data_item_definition` ("
+ " `name`, "
+ " `type`, "
+ " `key`, "
+ " `mandatory`, "
+ " `array`, "
+ " `since`, "
+ " `until`, "
+ " `removed`, "
+ " `deprecated`, "
+ " `minvalue`, "
+ " `maxvalue`, "
+ " `minsize`, "
+ " `maxsize`, "
+ " `minlength`, "
+ " `maxlength`) "
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ";
+
+const std::string kInsertVehicleDataItemParams =
+ "INSERT INTO `vehicle_data_item_parameters` ("
+ " `parent_name`, "
+ " `parent_key`, "
+ " `param_name`, "
+ " `param_key`) "
+ "VALUES (?, ?, ?, ?) ";
+
const std::string kSelectRpc =
"SELECT DISTINCT `rpc`.`parameter` FROM `rpc` "
" JOIN `app_group` AS `g` ON (`g`.`functional_group_id` = "
@@ -924,6 +1049,12 @@ const std::string kDeleteAppServiceNames = "DELETE FROM `app_service_names`";
const std::string kDeleteAppServiceHandledRpcs =
"DELETE FROM `app_service_handled_rpcs`";
+const std::string kDeleteVehicleDataItems =
+ "DELETE FROM `vehicle_data_item_definition`";
+
+const std::string kDeleteVehicleDataItemParams =
+ "DELETE FROM `vehicle_data_item_parameters`";
+
const std::string kSelectApplicationRevoked =
"SELECT `is_revoked` FROM `application` WHERE `id` = ?";
diff --git a/src/components/policy/policy_external/src/sql_pt_representation.cc b/src/components/policy/policy_external/src/sql_pt_representation.cc
index f2a2d34145..7874abc4ee 100644
--- a/src/components/policy/policy_external/src/sql_pt_representation.cc
+++ b/src/components/policy/policy_external/src/sql_pt_representation.cc
@@ -451,16 +451,6 @@ bool SQLPTRepresentation::Close() {
return db_->LastError().number() == utils::dbms::OK;
}
-const VehicleInfo SQLPTRepresentation::GetVehicleInfo() const {
- policy_table::ModuleConfig module_config;
- GatherModuleConfig(&module_config);
- VehicleInfo vehicle_info;
- vehicle_info.vehicle_make = *module_config.vehicle_make;
- vehicle_info.vehicle_model = *module_config.vehicle_model;
- vehicle_info.vehicle_year = *module_config.vehicle_year;
- return vehicle_info;
-}
-
bool SQLPTRepresentation::Drop() {
utils::dbms::SQLQuery query(db());
if (!query.Exec(sql_pt::kDropSchema)) {
@@ -525,6 +515,11 @@ std::shared_ptr<policy_table::Table> SQLPTRepresentation::GenerateSnapshot()
GatherConsumerFriendlyMessages(
&*table->policy_table.consumer_friendly_messages);
GatherApplicationPoliciesSection(&table->policy_table.app_policies_section);
+ GatherVehicleData(&*table->policy_table.vehicle_data);
+ if (!table->policy_table.vehicle_data.is_initialized()) {
+ rpc::Optional<rpc::String<0, 100> > null_version;
+ table->policy_table.vehicle_data->schema_version = null_version;
+ }
return table;
}
@@ -569,6 +564,18 @@ void SQLPTRepresentation::GatherModuleConfig(
}
}
+ utils::dbms::SQLQuery endpoint_properties(db());
+ if (!endpoint_properties.Prepare(sql_pt::kSelectEndpointProperties)) {
+ LOG4CXX_ERROR(logger_, "Incorrect statement for Endpoint properties");
+ } else {
+ while (endpoint_properties.Next()) {
+ const std::string& service = endpoint_properties.GetString(0);
+ const std::string& version = endpoint_properties.GetString(1);
+ auto& ep_properties = (*config->endpoint_properties);
+ *ep_properties[service].version = version;
+ }
+ }
+
utils::dbms::SQLQuery notifications(db());
if (!notifications.Prepare(sql_pt::kSelectNotificationsPerMin)) {
LOG4CXX_WARN(logger_, "Incorrect select statement for notifications");
@@ -664,16 +671,15 @@ bool SQLPTRepresentation::GatherFunctionalGroupings(
}
}
if (!rpcs.IsNull(2)) {
- policy_table::Parameter param;
- if (policy_table::EnumFromJsonString(rpcs.GetString(2), &param)) {
- // EMPTY is a special mark to specify that 'parameters' section is
- // present, but has no parameters. It is not valid parameter value.
- if (policy_table::P_EMPTY == param) {
- (*rpcs_tbl.rpcs[rpcs.GetString(0)].parameters).mark_initialized();
- continue;
- }
- InsertUnique(param, &(*rpcs_tbl.rpcs[rpcs.GetString(0)].parameters));
+ std::string param = rpcs.GetString(2);
+ // EMPTY is a special mark to specify that 'parameters' section is
+ // present, but has no parameters. It is not valid parameter value.
+ if (policy_table::EnumToJsonString(policy_table::P_EMPTY) == param) {
+ (*rpcs_tbl.rpcs[rpcs.GetString(0)].parameters).mark_initialized();
+ continue;
}
+ InsertUnique(rpcs.GetString(2),
+ &(*rpcs_tbl.rpcs[rpcs.GetString(0)].parameters));
}
}
@@ -832,6 +838,43 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection(
return true;
}
+bool SQLPTRepresentation::GatherVehicleData(
+ policy_table::VehicleData* vehicle_data) const {
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kSelectVehicleDataSchemaVersion) ||
+ !query.Next()) {
+ LOG4CXX_ERROR(logger_,
+ "Incorrect statement for vehicle data schema version");
+ return false;
+ }
+ *vehicle_data->schema_version = query.GetString(0);
+
+ vehicle_data->mark_initialized();
+ return GatherVehicleDataItems(&*vehicle_data->schema_items);
+}
+
+bool SQLPTRepresentation::GatherVehicleDataItems(
+ policy_table::VehicleDataItems* vehicle_data_items) const {
+ auto parameterized_vdi = SelectCompositeVehicleDataItems();
+ if (!parameterized_vdi.is_initialized()) {
+ return false;
+ }
+
+ auto non_parameterized_vdi = SelectPrimitiveVehicleDataItems();
+ if (!non_parameterized_vdi.is_initialized()) {
+ return false;
+ }
+
+ vehicle_data_items->insert(vehicle_data_items->end(),
+ parameterized_vdi.begin(),
+ parameterized_vdi.end());
+ vehicle_data_items->insert(vehicle_data_items->end(),
+ non_parameterized_vdi.begin(),
+ non_parameterized_vdi.end());
+
+ return true;
+}
+
bool SQLPTRepresentation::Save(const policy_table::Table& table) {
LOG4CXX_AUTO_TRACE(logger_);
db_->BeginTransaction();
@@ -866,6 +909,10 @@ bool SQLPTRepresentation::Save(const policy_table::Table& table) {
db_->RollbackTransaction();
return false;
}
+ if (!SaveVehicleData(*table.policy_table.vehicle_data)) {
+ db_->RollbackTransaction();
+ return false;
+ }
db_->CommitTransaction();
return true;
}
@@ -966,8 +1013,7 @@ bool SQLPTRepresentation::SaveRpcs(int64_t group_id,
query_parameter.Bind(0, it->first);
query_parameter.Bind(
1, std::string(policy_table::EnumToJsonString(*hmi_it)));
- query_parameter.Bind(
- 2, std::string(policy_table::EnumToJsonString(*ps_it)));
+ query_parameter.Bind(2, std::string(*ps_it));
query_parameter.Bind(3, group_id);
if (!query_parameter.Exec() || !query_parameter.Reset()) {
LOG4CXX_WARN(logger_, "Incorrect insert into rpc with parameter");
@@ -1185,6 +1231,44 @@ bool policy::SQLPTRepresentation::SaveDevicePolicy(
return true;
}
+bool SQLPTRepresentation::SaveVehicleDataItems(
+ const policy_table::VehicleDataItems& vehicle_data_items) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ DeleteVehicleDataItems();
+ for (const auto& item : vehicle_data_items) {
+ if (!InsertVehicleDataItem(item)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+bool SQLPTRepresentation::SaveVehicleData(
+ const policy_table::VehicleData& vehicle_data) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (vehicle_data.is_initialized() &&
+ vehicle_data.schema_version.is_initialized()) {
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kInsertVehicleDataSchemaVersion)) {
+ LOG4CXX_WARN(logger_,
+ "Incorrect insert of schema_version to vehicle_data.");
+ return false;
+ }
+ query.Bind(0, *vehicle_data.schema_version);
+ if (!query.Exec() || !query.Reset()) {
+ LOG4CXX_WARN(logger_, "Failed to insert schema_version to vehicle_data.");
+ return false;
+ }
+ }
+
+ auto vehicle_data_items = vehicle_data.is_initialized() &&
+ vehicle_data.schema_items.is_initialized()
+ ? *(vehicle_data.schema_items)
+ : policy_table::VehicleDataItems();
+
+ return SaveVehicleDataItems(vehicle_data_items);
+}
+
bool SQLPTRepresentation::SaveAppGroup(
const std::string& app_id, const policy_table::Strings& app_groups) {
utils::dbms::SQLQuery query(db());
@@ -1308,7 +1392,9 @@ bool SQLPTRepresentation::SaveRequestSubType(
} else if (request_subtypes.is_initialized()) {
LOG4CXX_WARN(logger_, "Request subtypes empty.");
query.Bind(0, app_id);
- query.Bind(1, std::string("EMPTY"));
+ query.Bind(1,
+ std::string(policy_table::EnumToJsonString(
+ policy_table::RequestType::RT_EMPTY)));
if (!query.Exec() || !query.Reset()) {
LOG4CXX_WARN(logger_, "Incorrect insert into request subtypes.");
return false;
@@ -1451,6 +1537,10 @@ bool SQLPTRepresentation::SaveModuleConfig(
return false;
}
+ if (!SaveServiceEndpointProperties(*config.endpoint_properties)) {
+ return false;
+ }
+
return true;
}
@@ -1489,6 +1579,31 @@ bool SQLPTRepresentation::SaveServiceEndpoints(
return true;
}
+bool SQLPTRepresentation::SaveServiceEndpointProperties(
+ const policy_table::ServiceEndpointProperties& endpoint_properties) {
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kInsertEndpointVersion)) {
+ LOG4CXX_WARN(
+ logger_,
+ "Incorrect insert of endpoint property to endpoint_properties.");
+ return false;
+ }
+
+ for (auto& endpoint_property : endpoint_properties) {
+ query.Bind(0, endpoint_property.first);
+ query.Bind(1, endpoint_property.second.version);
+
+ if (!query.Exec() || !query.Reset()) {
+ LOG4CXX_WARN(
+ logger_,
+ "Failed to insert endpoint property into endpoint_properties.");
+ return false;
+ }
+ }
+
+ return true;
+}
+
bool SQLPTRepresentation::SaveConsumerFriendlyMessages(
const policy_table::ConsumerFriendlyMessages& messages) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -1575,6 +1690,120 @@ bool SQLPTRepresentation::SaveLanguage(const std::string& code) {
return true;
}
+policy_table::VehicleDataItem SQLPTRepresentation::PopulateVDIFromQuery(
+ const utils::dbms::SQLQuery& query) const {
+ policy_table::VehicleDataItem result;
+
+ result.name = query.GetString(0);
+ result.type = query.GetString(1);
+ result.key = query.GetString(2);
+ result.mandatory = query.GetBoolean(3);
+
+ if (!query.IsNull(4)) {
+ *result.array = query.GetBoolean(4);
+ }
+ if (!query.IsNull(5)) {
+ *result.since = query.GetString(5);
+ }
+ if (!query.IsNull(6)) {
+ *result.until = query.GetString(6);
+ }
+ if (!query.IsNull(7)) {
+ *result.removed = query.GetBoolean(7);
+ }
+ if (!query.IsNull(8)) {
+ *result.deprecated = query.GetBoolean(8);
+ }
+ if (!query.IsNull(9)) {
+ *result.minvalue = query.GetInteger(9);
+ }
+ if (!query.IsNull(10)) {
+ *result.maxvalue = query.GetInteger(10);
+ }
+ if (!query.IsNull(11)) {
+ *result.minsize = query.GetUInteger(11);
+ }
+ if (!query.IsNull(12)) {
+ *result.maxsize = query.GetUInteger(12);
+ }
+ if (!query.IsNull(13)) {
+ *result.minlength = query.GetUInteger(13);
+ }
+ if (!query.IsNull(14)) {
+ *result.maxlength = query.GetUInteger(14);
+ }
+ result.params->mark_initialized();
+
+ result.mark_initialized();
+ return result;
+}
+
+policy_table::VehicleDataItems
+SQLPTRepresentation::SelectCompositeVehicleDataItems() const {
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kSelectCompositeVehicleDataItemsKey)) {
+ LOG4CXX_ERROR(logger_,
+ "Incorrect statement for parameterized vehicle data items");
+ return policy_table::VehicleDataItems();
+ }
+
+ policy_table::VehicleDataItems result;
+ result.mark_initialized();
+
+ while (query.Next()) {
+ const auto vdi = GetVehicleDataItem(query.GetString(0), query.GetString(1));
+ if (!vdi.is_initialized()) {
+ return policy_table::VehicleDataItems();
+ }
+ for (const auto& item : vdi) {
+ result.push_back(item);
+ }
+ }
+
+ return result;
+}
+
+policy_table::VehicleDataItems
+SQLPTRepresentation::SelectPrimitiveVehicleDataItems() const {
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kSelectPrimitiveVehicleDataItems)) {
+ LOG4CXX_ERROR(
+ logger_,
+ "Incorrect statement for non parameterized vehicle data items");
+ return policy_table::VehicleDataItems();
+ }
+
+ auto result = policy_table::VehicleDataItems();
+ result.mark_initialized();
+
+ while (query.Next()) {
+ const auto vdi = PopulateVDIFromQuery(query);
+ if (!vdi.is_initialized()) {
+ return policy_table::VehicleDataItems();
+ }
+ result.push_back(vdi);
+ }
+ return result;
+}
+
+bool SQLPTRepresentation::DeleteVehicleDataItems() const {
+ utils::dbms::SQLQuery query(db());
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ if (!query.Exec(sql_pt::kDeleteVehicleDataItems)) {
+ LOG4CXX_ERROR(logger_,
+ "Failed clearing database: " << query.LastError().text());
+ return false;
+ }
+
+ if (!query.Exec(sql_pt::kDeleteVehicleDataItemParams)) {
+ LOG4CXX_ERROR(logger_,
+ "Failed clearing database: " << query.LastError().text());
+ return false;
+ }
+ return true;
+}
+
bool SQLPTRepresentation::SaveMessageString(
const std::string& type,
const std::string& lang,
@@ -1817,7 +2046,8 @@ bool SQLPTRepresentation::GatherRequestSubType(
query.Bind(0, app_id);
while (query.Next()) {
const std::string request_subtype = query.GetString(0);
- if ("EMPTY" == request_subtype) {
+ if (policy_table::EnumToJsonString(policy_table::RequestType::RT_EMPTY) ==
+ request_subtype) {
request_subtypes->mark_initialized();
continue;
}
@@ -2306,6 +2536,190 @@ bool SQLPTRepresentation::UpdateDBVersion() const {
return true;
}
+policy_table::VehicleDataItems SQLPTRepresentation::GetVehicleDataItem(
+ const std::string& name, const std::string& key) const {
+ policy_table::VehicleDataItems result;
+ utils::dbms::SQLQuery query(db());
+
+ if (!query.Prepare(sql_pt::kSelectVehicleDataItem)) {
+ LOG4CXX_ERROR(logger_,
+ "Incorrent select statement of vehicle data item. "
+ << query.LastError().text());
+ return result;
+ }
+
+ query.Bind(0, key);
+ query.Bind(1, name);
+
+ while (query.Next()) {
+ auto vdi = PopulateVDIFromQuery(query);
+ if (!vdi.is_initialized()) {
+ return policy_table::VehicleDataItems();
+ }
+
+ utils::dbms::SQLQuery param_query(db());
+ if (policy_table::VehicleDataItem::kStruct ==
+ static_cast<std::string>(vdi.type)) {
+ if (!param_query.Prepare(sql_pt::kSelectVehicleDataItemParams)) {
+ LOG4CXX_ERROR(logger_,
+ "Incorrent select statement of vehicle data item. "
+ << param_query.LastError().text());
+ return policy_table::VehicleDataItems();
+ }
+
+ param_query.Bind(0, name);
+ param_query.Bind(1, key);
+
+ while (param_query.Next()) {
+ const auto param_with_diff_versions = GetVehicleDataItem(
+ param_query.GetString(2), param_query.GetString(3));
+ if (!param_with_diff_versions.is_initialized()) {
+ return policy_table::VehicleDataItems();
+ }
+ for (const auto& param : param_with_diff_versions) {
+ vdi.params->push_back(param);
+ }
+ }
+ }
+ result.push_back(vdi);
+ }
+ if (!result.empty()) {
+ result.mark_initialized();
+ }
+
+ return result;
+}
+
+bool SQLPTRepresentation::InsertVehicleDataItem(
+ const policy_table::VehicleDataItem& vehicle_data_item) {
+ utils::dbms::SQLQuery query(db());
+
+ if (!vehicle_data_item.is_initialized() || !vehicle_data_item.is_valid()) {
+ LOG4CXX_ERROR(logger_, "Vehicle data item is not initialized.");
+ return false;
+ }
+
+ if (VehicleDataItemExists(vehicle_data_item)) {
+ LOG4CXX_INFO(logger_,
+ static_cast<std::string>(vehicle_data_item.key)
+ << " is already stored.");
+ return true;
+ }
+
+ if (!query.Prepare(sql_pt::kInsertVehicleDataItem)) {
+ LOG4CXX_ERROR(logger_,
+ "Incorrent select statement of vehicle data item. "
+ << query.LastError().text());
+ return false;
+ }
+
+ query.Bind(0, vehicle_data_item.name);
+ query.Bind(1, vehicle_data_item.type);
+ query.Bind(2, vehicle_data_item.key);
+ query.Bind(3, vehicle_data_item.mandatory);
+ vehicle_data_item.array.is_initialized()
+ ? query.Bind(4, *vehicle_data_item.array)
+ : query.Bind(4);
+ vehicle_data_item.since.is_initialized()
+ ? query.Bind(5, *vehicle_data_item.since)
+ : query.Bind(5);
+ vehicle_data_item.until.is_initialized()
+ ? query.Bind(6, *vehicle_data_item.until)
+ : query.Bind(6);
+ vehicle_data_item.removed.is_initialized()
+ ? query.Bind(7, *vehicle_data_item.removed)
+ : query.Bind(7);
+ vehicle_data_item.deprecated.is_initialized()
+ ? query.Bind(8, *vehicle_data_item.deprecated)
+ : query.Bind(8);
+ vehicle_data_item.minvalue.is_initialized()
+ ? query.Bind(9, *vehicle_data_item.minvalue)
+ : query.Bind(9);
+ vehicle_data_item.maxvalue.is_initialized()
+ ? query.Bind(10, *vehicle_data_item.maxvalue)
+ : query.Bind(10);
+ vehicle_data_item.minsize.is_initialized()
+ ? query.Bind(11, static_cast<int64_t>(*vehicle_data_item.minsize))
+ : query.Bind(11);
+ vehicle_data_item.maxsize.is_initialized()
+ ? query.Bind(12, static_cast<int64_t>(*vehicle_data_item.maxsize))
+ : query.Bind(12);
+ vehicle_data_item.minlength.is_initialized()
+ ? query.Bind(13, static_cast<int64_t>(*vehicle_data_item.minlength))
+ : query.Bind(13);
+ vehicle_data_item.maxlength.is_initialized()
+ ? query.Bind(14, static_cast<int64_t>(*vehicle_data_item.maxlength))
+ : query.Bind(14);
+
+ if (!query.Exec() || !query.Reset()) {
+ LOG4CXX_ERROR(logger_,
+ "Failed to insert vehicle data item: "
+ << static_cast<std::string>(vehicle_data_item.key)
+ << ". Error: " << query.LastError().text());
+ return false;
+ }
+
+ if (vehicle_data_item.params->is_initialized()) {
+ for (const auto& param : *(vehicle_data_item.params)) {
+ if (!InsertVehicleDataItem(param)) {
+ return false;
+ }
+
+ if (!query.Prepare(sql_pt::kInsertVehicleDataItemParams)) {
+ LOG4CXX_ERROR(logger_,
+ "Incorrent select statement of vehicle data item. "
+ << query.LastError().text());
+ return false;
+ }
+
+ query.Bind(0, vehicle_data_item.name);
+ query.Bind(1, vehicle_data_item.key);
+ query.Bind(2, param.name);
+ query.Bind(3, param.key);
+
+ if (!query.Exec() || !query.Reset()) {
+ LOG4CXX_ERROR(
+ logger_,
+ "Failed to insert to vehicle data item relations helper table: "
+ << static_cast<std::string>(param.key)
+ << ". Error: " << query.LastError().text());
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+bool SQLPTRepresentation::VehicleDataItemExists(
+ const policy_table::VehicleDataItem& vehicle_data_item) const {
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kSelectVehicleDataItemWithVersion)) {
+ LOG4CXX_ERROR(logger_,
+ "Incorrent select statement for vehicle data item. "
+ << query.LastError().text());
+ return false;
+ }
+
+ query.Bind(0, vehicle_data_item.name);
+ query.Bind(1, vehicle_data_item.key);
+ vehicle_data_item.since.is_initialized()
+ ? query.Bind(2, std::string(*vehicle_data_item.since))
+ : query.Bind(2);
+ vehicle_data_item.until.is_initialized()
+ ? query.Bind(3, std::string(*vehicle_data_item.until))
+ : query.Bind(3);
+
+ if (!query.Exec()) {
+ LOG4CXX_ERROR(logger_,
+ "Failed to retrieve vehicle data item: "
+ << std::string(vehicle_data_item.key)
+ << ". Error: " << query.LastError().text());
+ return false;
+ }
+ return !query.IsNull(0);
+}
+
const int32_t SQLPTRepresentation::GetDBVersion() const {
return utils::Djb2HashFromString(sql_pt::kCreateSchema);
}
diff --git a/src/components/policy/policy_external/test/include/policy/mock_pt_representation.h b/src/components/policy/policy_external/test/include/policy/mock_pt_representation.h
index 33d4c46e64..0b3fe7aef7 100644
--- a/src/components/policy/policy_external/test/include/policy/mock_pt_representation.h
+++ b/src/components/policy/policy_external/test/include/policy/mock_pt_representation.h
@@ -66,7 +66,6 @@ class MockPTRepresentation : virtual public ::policy::PTRepresentation {
MOCK_METHOD1(SecondsBetweenRetries, bool(std::vector<int>* seconds));
MOCK_METHOD2(GetPriority,
bool(const std::string& app_id, std::string* priority));
- MOCK_CONST_METHOD0(GetVehicleInfo, const ::policy::VehicleInfo());
MOCK_METHOD1(SetVINValue, bool(const std::string& value));
MOCK_METHOD2(GetUserFriendlyMsg,
std::vector< ::policy::UserFriendlyMessage>(
diff --git a/src/components/policy/policy_external/test/include/policy/policy_manager_impl_test_base.h b/src/components/policy/policy_external/test/include/policy/policy_manager_impl_test_base.h
index 2ab6caf15d..816b99cc2f 100644
--- a/src/components/policy/policy_external/test/include/policy/policy_manager_impl_test_base.h
+++ b/src/components/policy/policy_external/test/include/policy/policy_manager_impl_test_base.h
@@ -113,7 +113,7 @@ class PolicyManagerImplTest : public ::testing::Test {
const std::string unpaired_device_id_;
PolicyManagerImpl* policy_manager_;
- MockCacheManagerInterface* cache_manager_;
+ NiceMock<MockCacheManagerInterface>* cache_manager_;
MockUpdateStatusManager update_manager_;
NiceMock<MockPolicyListener> listener_;
NiceMock<MockPTURetryHandler> ptu_retry_handler_;
diff --git a/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc
index bb8c6fc12a..49390b3aa1 100644
--- a/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc
+++ b/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc
@@ -972,14 +972,18 @@ TEST_F(PolicyManagerImplTest, LoadPT_SetInvalidUpdatePT_PTIsNotLoaded) {
std::string json = table.toStyledString();
::policy::BinaryMessage msg(json.begin(), json.end());
+ auto pt = std::make_shared<policy_table::Table>();
+ *pt = update;
+
// Assert
- EXPECT_CALL(*cache_manager_, GenerateSnapshot()).Times(0);
EXPECT_CALL(*cache_manager_, ApplyUpdate(_)).Times(0);
EXPECT_CALL(listener_, GetAppName(_)).Times(0);
EXPECT_CALL(listener_, OnUpdateStatusChanged(_)).Times(1);
EXPECT_CALL(*cache_manager_, SaveUpdateRequired(false)).Times(0);
EXPECT_CALL(*cache_manager_, TimeoutResponse()).Times(0);
EXPECT_CALL(*cache_manager_, SecondsBetweenRetries(_)).Times(0);
+ EXPECT_CALL(*cache_manager_, GetVehicleDataItems())
+ .WillOnce(Return(std::vector<policy_table::VehicleDataItem>()));
EXPECT_FALSE(policy_manager_->LoadPT(kFilePtUpdateJson, msg));
EXPECT_CALL(*cache_manager_, IsPTPreloaded());
EXPECT_FALSE(policy_manager_->GetCache()->IsPTPreloaded());
@@ -1169,24 +1173,6 @@ TEST_F(PolicyManagerImplTest2,
EXPECT_TRUE(policy_manager_->CanAppKeepContext(app_id_2_));
}
-TEST_F(PolicyManagerImplTest2,
- GetVehicleInfo_SetVehicleInfo_ExpectReceivedInfoCorrect) {
- // Arrange
- CreateLocalPT(preloaded_pt_filename_);
- GetPTU(kValidSdlPtUpdateJson);
- std::shared_ptr<policy_table::Table> pt =
- (policy_manager_->GetCache())->GetPT();
- policy_table::ModuleConfig& module_config = pt->policy_table.module_config;
- ::policy::VehicleInfo vehicle_info = policy_manager_->GetVehicleInfo();
-
- EXPECT_EQ(static_cast<std::string>(*module_config.vehicle_make),
- vehicle_info.vehicle_make);
- EXPECT_EQ(static_cast<std::string>(*module_config.vehicle_model),
- vehicle_info.vehicle_model);
- EXPECT_EQ(static_cast<std::string>(*module_config.vehicle_year),
- vehicle_info.vehicle_year);
-}
-
TEST_F(
PolicyManagerImplTest2,
GetPermissionsForApp_SetUserConsentForApp_ExpectReceivedPermissionsCorrect) {
diff --git a/src/components/policy/policy_external/test/policy_manager_impl_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_test.cc
index 1a7500c954..ef5e3e98bc 100644
--- a/src/components/policy/policy_external/test/policy_manager_impl_test.cc
+++ b/src/components/policy/policy_external/test/policy_manager_impl_test.cc
@@ -125,16 +125,19 @@ TEST_F(PolicyManagerImplTest, LoadPT_SetPT_PTIsLoaded) {
std::shared_ptr<policy_table::Table> snapshot =
std::make_shared<policy_table::Table>(update.policy_table);
+ ON_CALL(*cache_manager_, GenerateSnapshot()).WillByDefault(Return(snapshot));
+
// Assert
- EXPECT_CALL(*cache_manager_, GenerateSnapshot()).WillOnce(Return(snapshot));
EXPECT_CALL(*cache_manager_, ApplyUpdate(_)).WillOnce(Return(true));
- EXPECT_CALL(listener_, GetAppName("1234"))
- .WillOnce(Return(custom_str::CustomString("")));
+ EXPECT_CALL(listener_, GetDevicesIds("1234"))
+ .WillRepeatedly(Return(transport_manager::DeviceList()));
EXPECT_CALL(listener_, OnUpdateStatusChanged(_));
EXPECT_CALL(*cache_manager_, SaveUpdateRequired(false));
EXPECT_CALL(*cache_manager_, TimeoutResponse());
EXPECT_CALL(*cache_manager_, SecondsBetweenRetries(_));
+ EXPECT_CALL(*cache_manager_, GetVehicleDataItems())
+ .WillOnce(Return(std::vector<policy_table::VehicleDataItem>()));
EXPECT_TRUE(policy_manager_->LoadPT(kFilePtUpdateJson, msg));
EXPECT_CALL(*cache_manager_, IsPTPreloaded());
EXPECT_FALSE(policy_manager_->GetCache()->IsPTPreloaded());
diff --git a/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc b/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc
index be7f25dabb..81e5c77ff0 100644
--- a/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc
+++ b/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc
@@ -207,7 +207,7 @@ PolicyManagerImplTest::PolicyManagerImplTest()
void PolicyManagerImplTest::SetUp() {
policy_manager_ = new PolicyManagerImpl();
- cache_manager_ = new MockCacheManagerInterface();
+ cache_manager_ = new NiceMock<MockCacheManagerInterface>();
policy_manager_->set_cache_manager(cache_manager_);
policy_manager_->set_listener(&listener_);
@@ -264,7 +264,7 @@ void PolicyManagerImplTest2::SetUp() {
ON_CALL(policy_settings_, app_storage_folder())
.WillByDefault(ReturnRef(app_storage_folder_));
policy_manager_->set_listener(&listener_);
- const char* levels[] = {"BACKGROUND", "FULL", "LIMITED", "NONE"};
+ const char* levels[] = {"FULL", "LIMITED", "BACKGROUND", "NONE"};
hmi_level_.assign(levels, levels + sizeof(levels) / sizeof(levels[0]));
srand(time(NULL));
index_ = rand() % 3;
diff --git a/src/components/policy/policy_external/test/sql_pt_ext_representation_test.cc b/src/components/policy/policy_external/test/sql_pt_ext_representation_test.cc
index a9c7667ba6..7d40210ba4 100644
--- a/src/components/policy/policy_external/test/sql_pt_ext_representation_test.cc
+++ b/src/components/policy/policy_external/test/sql_pt_ext_representation_test.cc
@@ -1541,8 +1541,8 @@ TEST_F(SQLPTExtRepresentationTest, SaveFunctionalGroupings_ExpectedSaved) {
const HmiLevel test_level_1 = HL_FULL;
const HmiLevel test_level_2 = HL_LIMITED;
- const policy_table::Parameter test_parameter_1 = P_GPS;
- const policy_table::Parameter test_parameter_2 = P_SPEED;
+ const std::string test_parameter_1 = "P_GPS";
+ const std::string test_parameter_2 = "P_SPEED";
Rpcs rpcs;
@@ -1578,7 +1578,7 @@ TEST_F(SQLPTExtRepresentationTest, SaveFunctionalGroupings_ExpectedSaved) {
*another_rpcs.user_consent_prompt = another_user_consent_prompt;
const HmiLevel test_level_3 = HL_BACKGROUND;
- const policy_table::Parameter test_parameter_3 = P_BELTSTATUS;
+ const std::string test_parameter_3 = "P_BELTSTATUS";
RpcParameters another_parameters;
another_parameters.hmi_levels.push_back(test_level_3);
@@ -1615,10 +1615,10 @@ TEST_F(SQLPTExtRepresentationTest, SaveFunctionalGroupings_ExpectedSaved) {
EXPECT_TRUE(
(IsKeyExist<HmiLevels>(loaded_parameters.hmi_levels, test_level_2)));
- EXPECT_TRUE((
- IsKeyExist<Parameters>(*loaded_parameters.parameters, test_parameter_1)));
- EXPECT_TRUE((
- IsKeyExist<Parameters>(*loaded_parameters.parameters, test_parameter_2)));
+ EXPECT_TRUE((IsKeyExist<Parameters, std::string>(
+ *loaded_parameters.parameters, test_parameter_1)));
+ EXPECT_TRUE((IsKeyExist<Parameters, std::string>(
+ *loaded_parameters.parameters, test_parameter_2)));
Rpcs another_loaded_rpcs = GetKeyData<FunctionalGroupings, Rpcs>(
loaded_groupings, another_group_name);
@@ -1637,8 +1637,8 @@ TEST_F(SQLPTExtRepresentationTest, SaveFunctionalGroupings_ExpectedSaved) {
EXPECT_TRUE((IsKeyExist<HmiLevels>(another_loaded_parameters.hmi_levels,
test_level_3)));
- EXPECT_TRUE((IsKeyExist<Parameters>(*another_loaded_parameters.parameters,
- test_parameter_3)));
+ EXPECT_TRUE((IsKeyExist<Parameters, std::string>(
+ *another_loaded_parameters.parameters, test_parameter_3)));
}
TEST_F(SQLPTExtRepresentationTest, JsonContentsExternalConsent_ExpectParsed) {
diff --git a/src/components/policy/policy_external/test/sql_pt_representation_test.cc b/src/components/policy/policy_external/test/sql_pt_representation_test.cc
index 9e6e18b77d..67702ab4d2 100644
--- a/src/components/policy/policy_external/test/sql_pt_representation_test.cc
+++ b/src/components/policy/policy_external/test/sql_pt_representation_test.cc
@@ -176,7 +176,7 @@ class SQLPTRepresentationTest : public SQLPTRepresentation,
policy_table::Strings& temp_groups = apps_iter->second.groups;
StringsCompare(groups, temp_groups);
EXPECT_EQ(0u, (*(apps_iter->second.nicknames)).size());
- EXPECT_EQ(prio, apps_iter->second.priority);
+ EXPECT_EQ(prio, (apps_iter->second).priority);
EXPECT_EQ(0u, (*(apps_iter->second.AppHMIType)).size());
EXPECT_EQ(memory_kb, (*(apps_iter->second.memory_kb)));
EXPECT_EQ(heart_beat_timeout_ms,
@@ -376,6 +376,99 @@ class SQLPTRepresentationTest2 : public ::testing::Test {
const uint16_t kAttemptsToOpenPolicyDB = 2u;
};
+TEST_F(SQLPTRepresentationTest, VehicleDataItem_Store_Item) {
+ policy_table::VehicleDataItem rpm;
+ rpm.mark_initialized();
+ rpm.name = "rpm";
+ rpm.type = "Integer";
+ rpm.key = "OEM_REF_RPM";
+ rpm.mandatory = false;
+ *rpm.array = false;
+ rpm.params->mark_initialized();
+ ASSERT_FALSE(reps->VehicleDataItemExists(rpm));
+ ASSERT_TRUE(reps->InsertVehicleDataItem(rpm));
+ ASSERT_TRUE(reps->VehicleDataItemExists(rpm));
+
+ auto rpm_retrieved = reps->GetVehicleDataItem(rpm.name, rpm.key);
+
+ std::cout << rpm.ToJsonValue().toStyledString() << std::endl;
+ std::cout << rpm_retrieved.ToJsonValue().toStyledString() << std::endl;
+
+ ASSERT_EQ(rpm.ToJsonValue(), rpm_retrieved.begin()->ToJsonValue());
+}
+
+TEST_F(SQLPTRepresentationTest, VehicleDataItem_Store_Complete_Item) {
+ policy_table::VehicleDataItem message;
+ message.name = "messsageName";
+ message.type = "String";
+ message.key = "OEM_REF_MSG";
+ message.mandatory = false;
+ *message.array = false;
+ *message.since = "1.0";
+ *message.until = "5.0";
+ *message.removed = false;
+ *message.deprecated = false;
+ *message.minvalue = 0;
+ *message.maxvalue = 255;
+ *message.minsize = 0;
+ *message.maxsize = 255;
+ *message.minlength = 0;
+ *message.maxlength = 255;
+ message.params->mark_initialized();
+ ASSERT_TRUE(reps->InsertVehicleDataItem(message));
+
+ auto message_retrieved = reps->GetVehicleDataItem(message.name, message.key);
+ ASSERT_EQ(message.ToJsonValue(), message_retrieved.begin()->ToJsonValue());
+}
+
+TEST_F(SQLPTRepresentationTest, VehicleDataItem_Store_Struct) {
+ 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);
+ ASSERT_TRUE(reps->InsertVehicleDataItem(alss));
+ ASSERT_TRUE(reps->InsertVehicleDataItem(hls));
+
+ auto hls_retrieved = reps->GetVehicleDataItem(hls.name, hls.key);
+ ASSERT_EQ(hls.ToJsonValue(), hls_retrieved.begin()->ToJsonValue());
+}
+
TEST_F(SQLPTRepresentationTest2,
CheckActualAttemptsToOpenDB_ExpectCorrectNumber) {
EXPECT_EQ(::policy::FAIL, reps->Init(&policy_settings_));
@@ -406,8 +499,8 @@ TEST_F(SQLPTRepresentationTest,
query.Prepare(query_select);
query.Next();
- // 37 - is current total tables number created by schema
- const int policy_tables_number = 37;
+ // 41 - is current total tables number created by schema
+ const int policy_tables_number = 41;
ASSERT_EQ(policy_tables_number, query.GetInteger(0));
const std::string query_select_count_of_iap_buffer_full =
@@ -965,25 +1058,6 @@ TEST_F(
ASSERT_EQ(0, query.GetInteger(0));
}
-TEST_F(
- SQLPTRepresentationTest,
- GetVehicleInfo_ManuallySetVehcleInfoThenCallGetVehicleInfo_ExpectValuesReceived) {
- // Check
- const std::string query_insert_module_config =
- "UPDATE `module_config` SET `preloaded_pt` = 1, "
- " `exchange_after_x_ignition_cycles` = 50,"
- " `exchange_after_x_kilometers` = 2000, `exchange_after_x_days` = 30,"
- " `timeout_after_x_seconds` = 5, `vehicle_make` = 'FORD', "
- " `vehicle_model` = 'MUSTANG', `vehicle_year` = '2003', "
- "`preloaded_date` = '25.04.2015'";
- ASSERT_TRUE(query_wrapper_->Exec(query_insert_module_config));
- VehicleInfo info = reps->GetVehicleInfo();
-
- ASSERT_EQ("FORD", info.vehicle_make);
- ASSERT_EQ("MUSTANG", info.vehicle_model);
- ASSERT_EQ("2003", info.vehicle_year);
-}
-
TEST_F(SQLPTRepresentationTest,
GetUserFriendlyMsg_SetMsg_ExpectReceivedMsgSetInParams) {
// Arrange
@@ -1695,9 +1769,8 @@ TEST_F(SQLPTRepresentationTest,
const ::policy_table::Parameters& parameters = *(rpc_iter->second.parameters);
EXPECT_EQ(1u, parameters.size());
- EXPECT_TRUE(parameters.end() != std::find(parameters.begin(),
- parameters.end(),
- policy_table::Parameter::P_SPEED));
+ EXPECT_TRUE(parameters.end() !=
+ std::find(parameters.begin(), parameters.end(), "P_SPEED"));
// Check Application Policies Section
GatherApplicationPoliciesSection(&policies);
const uint32_t apps_size = 3u;
diff --git a/src/components/policy/policy_regular/CMakeLists.txt b/src/components/policy/policy_regular/CMakeLists.txt
index f7f34564b6..e14057ec89 100644
--- a/src/components/policy/policy_regular/CMakeLists.txt
+++ b/src/components/policy/policy_regular/CMakeLists.txt
@@ -30,27 +30,81 @@
include(${CMAKE_SOURCE_DIR}/tools/cmake/helpers/platform.cmake)
include(${CMAKE_SOURCE_DIR}/tools/cmake/helpers/sources.cmake)
+include(${CMAKE_SOURCE_DIR}/tools/cmake/helpers/generators.cmake)
include_directories (
- ${POLICY_PATH}/include
- ${POLICY_GLOBAL_INCLUDE_PATH}/
- ${COMPONENTS_DIR}/rpc_base/include
- ${JSONCPP_INCLUDE_DIRECTORY}
+ ${POLICY_PATH}/include/
+ ${COMPONENTS_DIR}/
${COMPONENTS_DIR}/utils/include/
${COMPONENTS_DIR}/config_profile/include
${COMPONENTS_DIR}/connection_handler/include/
${COMPONENTS_DIR}/protocol_handler/include/
- ${LOG4CXX_INCLUDE_DIRECTORY}
- ${BOOST_INCLUDE_DIR}
+ ${COMPONENTS_DIR}/config_profile/include/
+ ${COMPONENTS_DIR}/smart_objects/include/
+ ${COMPONENTS_DIR}/rpc_base/include/
+ ${CMAKE_BINARY_DIR}/src/components/
+ ${POLICY_GLOBAL_INCLUDE_PATH}/
+ ${BOOST_INCLUDE_DIR}/
+ ${JSONCPP_INCLUDE_DIRECTORY}/
+ ${LOG4CXX_INCLUDE_DIRECTORY}/
)
+set(GENERATED_MOBILE_POLICY_TYPES_CPP
+ "${CMAKE_CURRENT_BINARY_DIR}/generated_MOBILE_API_policy_types.cc"
+ "${CMAKE_CURRENT_BINARY_DIR}/generated_MOBILE_API_enum_schema_factory.cc")
+
+set(GENERATED_MOBILE_POLICY_TYPES_HPP
+ "${CMAKE_CURRENT_BINARY_DIR}/generated_MOBILE_API_policy_types.h")
+
+set(GENERATED_MOBILE_POLICY_TYPES
+ ${GENERATED_MOBILE_POLICY_TYPES_HPP}
+ ${GENERATED_MOBILE_POLICY_TYPES_CPP})
+
+generate_policy_types("${GENERATED_MOBILE_POLICY_TYPES}"
+ "${COMPONENTS_DIR}/interfaces/MOBILE_API.xml"
+ "rpc::policy_table_interface_base"
+ "mobile-policy-types")
+
+
+set(GENERATED_HMI_POLICY_TYPES_CPP
+ "${CMAKE_CURRENT_BINARY_DIR}/generated_HMI_API_policy_types.cc")
+
+set(GENERATED_HMI_POLICY_TYPES_HPP
+ "${CMAKE_CURRENT_BINARY_DIR}/generated_HMI_API_policy_types.h")
+
+set(GENERATED_HMI_POLICY_TYPES
+ ${GENERATED_HMI_POLICY_TYPES_HPP}
+ ${GENERATED_HMI_POLICY_TYPES_CPP})
+
+
+generate_policy_types("${GENERATED_HMI_POLICY_TYPES}"
+ "${COMPONENTS_DIR}/interfaces/HMI_API.xml"
+ "rpc::policy_table_interface_base"
+ "hmi-policy-types")
+
set(POLICY_TABLE_PATHS
${CMAKE_CURRENT_SOURCE_DIR}/include/policy/policy_table
${CMAKE_CURRENT_SOURCE_DIR}/src/policy_table
+ ${CMAKE_CURRENT_BINARY_DIR}/
)
-collect_sources(POLICY_TABLE_SOURCES "${POLICY_TABLE_PATHS}")
+
+set(POLICY_TABLE_SOURCES
+ ${GENERATED_MOBILE_POLICY_TYPES_CPP}
+ ${GENERATED_HMI_POLICY_TYPES_CPP}
+ ${POLICY_PATH}/src/policy_table/enums.cc
+ ${POLICY_PATH}/src/policy_table/types.cc
+ ${POLICY_PATH}/src/policy_table/validation.cc
+)
+
add_library(policy_struct ${POLICY_TABLE_SOURCES})
-target_link_libraries(policy_struct Utils)
+target_link_libraries(policy_struct
+ MOBILE_API
+ HMI_API
+ Utils
+ SmartObjects
+ formatters
+ jsoncpp
+)
set(USAGE_STATISTICS_PATHS
${CMAKE_CURRENT_SOURCE_DIR}/include/policy/usage_statistics
@@ -76,7 +130,6 @@ set(LIBRARIES
ConfigProfile
policy_struct
dbms
- jsoncpp
Utils
)
diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h
index 1773347af7..9b0413d7ce 100644
--- a/src/components/policy/policy_regular/include/policy/cache_manager.h
+++ b/src/components/policy/policy_regular/include/policy/cache_manager.h
@@ -142,9 +142,17 @@ class CacheManager : public CacheManagerInterface {
virtual bool SecondsBetweenRetries(std::vector<int>& seconds);
/**
- * @brief Get information about vehicle
+ * @brief Gets copy of current policy table data
+ * @return policy_table as json object
*/
- virtual const VehicleInfo GetVehicleInfo() const;
+ virtual Json::Value GetPolicyTableData() const OVERRIDE;
+
+ /**
+ * @brief Gets vehicle data items
+ * @return Structure with vehicle data items
+ */
+ virtual const std::vector<policy_table::VehicleDataItem> GetVehicleDataItems()
+ const;
const boost::optional<bool> LockScreenDismissalEnabledState() const OVERRIDE;
@@ -841,6 +849,24 @@ class CacheManager : public CacheManagerInterface {
void MergeCFM(const policy_table::PolicyTable& new_pt,
policy_table::PolicyTable& pt);
+ /**
+ * @brief MergeVD allows to merge VehicleDataItems section by
+ *definite rules.
+ *
+ * The rules are:
+ * 1. If vehicle_data_items key is not presented in the updated PolicyTable,
+ * update for VehicleDataItems should be ignored.
+ * 2. If vehicle_data_items presented in updated PolicyTable, the
+ * VehicleDataItems in the database (LocalPT) should be overwritten with
+ * updated data.
+ *
+ * @param new_pt the policy table loaded from updated preload JSON file.
+ *
+ * @param pt the exists database
+ */
+ void MergeVD(const policy_table::PolicyTable& new_pt,
+ policy_table::PolicyTable& pt);
+
const PolicySettings& get_settings() const;
std::shared_ptr<policy_table::Table> pt() const {
@@ -866,6 +892,14 @@ class CacheManager : public CacheManagerInterface {
const std::string& application_name,
policy_table::ApplicationParams& application_policies) const OVERRIDE;
+ /**
+ * @brief Method for separate RPCSpec vehicle data items from custom
+ * @param full vehicle data items during PTU
+ * @return array with only custom vehicle items
+ */
+ static policy_table::VehicleDataItems CollectCustomVDItems(
+ const policy_table::VehicleDataItems& vd_items);
+
private:
std::string currentDateTime();
struct AppHMITypeToString {
diff --git a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h
index 374db728c7..bd03896bfb 100644
--- a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h
+++ b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h
@@ -149,9 +149,17 @@ class CacheManagerInterface {
virtual bool SecondsBetweenRetries(std::vector<int>& seconds) = 0;
/**
- * @brief Get information about vehicle
+ * @brief Gets copy of current policy table data
+ * @return policy_table as json object
*/
- virtual const VehicleInfo GetVehicleInfo() const = 0;
+ virtual Json::Value GetPolicyTableData() const = 0;
+
+ /**
+ * @brief Gets vehicle data items
+ * @return Structure with vehicle data items
+ */
+ virtual const std::vector<policy_table::VehicleDataItem> GetVehicleDataItems()
+ const = 0;
/**
* @brief Get a list of enabled cloud applications
diff --git a/src/components/policy/policy_regular/include/policy/policy_helper.h b/src/components/policy/policy_regular/include/policy/policy_helper.h
index adedd8786f..628a8c49d1 100644
--- a/src/components/policy/policy_regular/include/policy/policy_helper.h
+++ b/src/components/policy/policy_regular/include/policy/policy_helper.h
@@ -96,6 +96,8 @@ struct CheckAppPolicy {
policy_table::Strings* revoked_groups = NULL) const;
bool HasNewGroups(const AppPoliciesValueType& app_policy,
policy_table::Strings* new_groups = NULL) const;
+ bool HasUpdatedGroups(const policy::AppPoliciesValueType& app_policy,
+ policy_table::Strings* updated_groups = NULL) const;
bool HasConsentNeededGroups(const AppPoliciesValueType& app_policy) const;
std::vector<FunctionalGroupPermission> GetRevokedGroups(
const AppPoliciesValueType& app_policy) const;
diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h
index 92ef67176a..c6066a9ae9 100644
--- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h
+++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h
@@ -643,12 +643,18 @@ class PolicyManagerImpl : public PolicyManager {
const std::string& policy_app_id) const OVERRIDE;
/**
- * @brief Get information about vehicle
- * @return vehicle information
+ * @brief Gets vehicle data items
+ * @return Structure with vehicle data items
*/
- const VehicleInfo GetVehicleInfo() const OVERRIDE;
+ const std::vector<policy_table::VehicleDataItem> GetVehicleDataItems()
+ const OVERRIDE;
/**
+ * @brief Gets copy of current policy table data
+ * @return policy_table as json object
+ */
+ Json::Value GetPolicyTableData() const OVERRIDE;
+ /**
* @brief Get a list of enabled cloud applications
* @param enabled_apps List filled with the policy app id of each enabled
* cloud application
diff --git a/src/components/policy/policy_regular/include/policy/policy_table/enums.h b/src/components/policy/policy_regular/include/policy/policy_table/enums.h
index 899e40993e..05b39a0082 100644
--- a/src/components/policy/policy_regular/include/policy/policy_table/enums.h
+++ b/src/components/policy/policy_regular/include/policy/policy_table/enums.h
@@ -34,582 +34,12 @@
#define SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_POLICY_TABLE_ENUMS_H_
#include <string>
+#include "generated_HMI_API_policy_types.h"
+#include "generated_MOBILE_API_policy_types.h"
namespace rpc {
namespace policy_table_interface_base {
-enum Priority {
- P_EMERGENCY,
- P_NAVIGATION,
- P_VOICECOM,
- P_COMMUNICATION,
- P_NORMAL,
- P_PROJECTION,
- P_NONE,
-};
-
-bool IsValidEnum(Priority val);
-const char* EnumToJsonString(Priority val);
-bool EnumFromJsonString(const std::string& literal, Priority* result);
-
-enum HmiLevel {
- HL_BACKGROUND,
- HL_FULL,
- HL_LIMITED,
- HL_NONE,
-};
-bool IsValidEnum(HmiLevel val);
-const char* EnumToJsonString(HmiLevel val);
-bool EnumFromJsonString(const std::string& literal, HmiLevel* result);
-
-enum Parameter {
- P_GPS,
- P_SPEED,
- P_ENGINETORQUE,
- P_EXTERNALTEMPERATURE,
- P_TURNSIGNAL,
- P_FUELLEVEL,
- P_FUELLEVEL_STATE,
- P_HEADLAMPSTATUS,
- P_INSTANTFUELCONSUMPTION,
- P_FUELRANGE,
- P_ODOMETER,
- P_TIREPRESSURE,
- P_WIPERSTATUS,
- P_VIN,
- P_ACCPEDALPOSITION,
- P_BELTSTATUS,
- P_ELECTRONICPARKBRAKESTATUS,
- P_DRIVERBRAKING,
- P_PRNDL,
- P_RPM,
- P_STEERINGWHEELANGLE,
- P_ENGINEOILLIFE,
- P_MYKEY,
- P_CLOUD_APP_VEHICLE_ID,
- P_AIRBAGSTATUS,
- P_BODYINFORMATION,
- P_CLUSTERMODESTATUS,
- P_DEVICESTATUS,
- P_EMERGENCYEVENT,
- P_ECALLINFO,
- P_EMPTY // Added to allow empty parameters handling
-};
-
-bool IsValidEnum(Parameter val);
-const char* EnumToJsonString(Parameter val);
-bool EnumFromJsonString(const std::string& literal, Parameter* result);
-
-enum AppHMIType {
- AHT_DEFAULT,
- AHT_COMMUNICATION,
- AHT_MEDIA,
- AHT_MESSAGING,
- AHT_NAVIGATION,
- AHT_INFORMATION,
- AHT_SOCIAL,
- AHT_BACKGROUND_PROCESS,
- AHT_TESTING,
- AHT_SYSTEM,
- AHT_PROJECTION,
- AHT_REMOTE_CONTROL
-};
-bool IsValidEnum(AppHMIType val);
-const char* EnumToJsonString(AppHMIType val);
-bool EnumFromJsonString(const std::string& literal, AppHMIType* result);
-
-enum RequestType {
- RT_HTTP,
- RT_FILE_RESUME,
- RT_AUTH_REQUEST,
- RT_AUTH_CHALLENGE,
- RT_AUTH_ACK,
- RT_PROPRIETARY,
- RT_QUERY_APPS,
- RT_LAUNCH_APP,
- RT_LOCK_SCREEN_ICON_URL,
- RT_TRAFFIC_MESSAGE_CHANNEL,
- RT_DRIVER_PROFILE,
- RT_VOICE_SEARCH,
- RT_NAVIGATION,
- RT_PHONE,
- RT_CLIMATE,
- RT_SETTINGS,
- RT_VEHICLE_DIAGNOSTICS,
- RT_EMERGENCY,
- RT_MEDIA,
- RT_FOTA,
- RT_OEM_SPECIFIC,
- RT_EMPTY // Added to allow empty Request Types handling
-};
-
-bool IsValidEnum(RequestType val);
-const char* EnumToJsonString(RequestType val);
-bool EnumFromJsonString(const std::string& literal, RequestType* result);
-
-enum Input {
- I_GUI,
- I_VUI,
-};
-bool IsValidEnum(Input val);
-const char* EnumToJsonString(Input val);
-bool EnumFromJsonString(const std::string& literal, Input* result);
-
-enum ModuleType {
- MT_CLIMATE,
- MT_RADIO,
- MT_SEAT,
- MT_AUDIO,
- MT_LIGHT,
- MT_HMI_SETTINGS,
- MT_EMPTY
-};
-bool IsValidEnum(ModuleType val);
-const char* EnumToJsonString(ModuleType val);
-bool EnumFromJsonString(const std::string& literal, ModuleType* result);
-
-enum HybridAppPreference { HAP_MOBILE, HAP_CLOUD, HAP_BOTH };
-bool IsValidEnum(HybridAppPreference val);
-const char* EnumToJsonString(HybridAppPreference val);
-bool EnumFromJsonString(const std::string& literal,
- HybridAppPreference* result);
-
-/**
- * @brief Enumeration FunctionID.
- *
- * Enumeration linking function names with function IDs in AppLink protocol.
- * Assumes enumeration starts at value 0.
- */
-enum FunctionID {
- /**
- * @brief RESERVED.
- */
- RESERVED = 0,
-
- /**
- * @brief RegisterAppInterfaceID.
- */
- RegisterAppInterfaceID = 1,
-
- /**
- * @brief UnregisterAppInterfaceID.
- */
- UnregisterAppInterfaceID = 2,
-
- /**
- * @brief SetGlobalPropertiesID.
- */
- SetGlobalPropertiesID = 3,
-
- /**
- * @brief ResetGlobalPropertiesID.
- */
- ResetGlobalPropertiesID = 4,
-
- /**
- * @brief AddCommandID.
- */
- AddCommandID = 5,
-
- /**
- * @brief DeleteCommandID.
- */
- DeleteCommandID = 6,
-
- /**
- * @brief AddSubMenuID.
- */
- AddSubMenuID = 7,
-
- /**
- * @brief DeleteSubMenuID.
- */
- DeleteSubMenuID = 8,
-
- /**
- * @brief CreateInteractionChoiceSetID.
- */
- CreateInteractionChoiceSetID = 9,
-
- /**
- * @brief PerformInteractionID.
- */
- PerformInteractionID = 10,
-
- /**
- * @brief DeleteInteractionChoiceSetID.
- */
- DeleteInteractionChoiceSetID = 11,
-
- /**
- * @brief AlertID.
- */
- AlertID = 12,
-
- /**
- * @brief ShowID.
- */
- ShowID = 13,
-
- /**
- * @brief SpeakID.
- */
- SpeakID = 14,
-
- /**
- * @brief SetMediaClockTimerID.
- */
- SetMediaClockTimerID = 15,
-
- /**
- * @brief PerformAudioPassThruID.
- */
- PerformAudioPassThruID = 16,
-
- /**
- * @brief EndAudioPassThruID.
- */
- EndAudioPassThruID = 17,
-
- /**
- * @brief SubscribeButtonID.
- */
- SubscribeButtonID = 18,
-
- /**
- * @brief UnsubscribeButtonID.
- */
- UnsubscribeButtonID = 19,
-
- /**
- * @brief SubscribeVehicleDataID.
- */
- SubscribeVehicleDataID = 20,
-
- /**
- * @brief UnsubscribeVehicleDataID.
- */
- UnsubscribeVehicleDataID = 21,
-
- /**
- * @brief GetVehicleDataID.
- */
- GetVehicleDataID = 22,
-
- /**
- * @brief ReadDIDID.
- */
- ReadDIDID = 23,
-
- /**
- * @brief GetDTCsID.
- */
- GetDTCsID = 24,
-
- /**
- * @brief ScrollableMessageID.
- */
- ScrollableMessageID = 25,
-
- /**
- * @brief SliderID.
- */
- SliderID = 26,
-
- /**
- * @brief ShowConstantTBTID.
- */
- ShowConstantTBTID = 27,
-
- /**
- * @brief AlertManeuverID.
- */
- AlertManeuverID = 28,
-
- /**
- * @brief UpdateTurnListID.
- */
- UpdateTurnListID = 29,
-
- /**
- * @brief ChangeRegistrationID.
- */
- ChangeRegistrationID = 30,
-
- /**
- * @brief GenericResponseID.
- */
- GenericResponseID = 31,
-
- /**
- * @brief PutFileID.
- */
- PutFileID = 32,
-
- /**
- * @brief DeleteFileID.
- */
- DeleteFileID = 33,
-
- /**
- * @brief ListFilesID.
- */
- ListFilesID = 34,
-
- /**
- * @brief SetAppIconID.
- */
- SetAppIconID = 35,
-
- /**
- * @brief SetDisplayLayoutID.
- */
- SetDisplayLayoutID = 36,
-
- /**
- * @brief DiagnosticMessageID.
- */
- DiagnosticMessageID = 37,
-
- /**
- * @brief SystemRequestID.
- */
- SystemRequestID = 38,
-
- /**
- * @brief SendLocationID.
- */
- SendLocationID = 39,
-
- /**
- * @brief DialNumberID.
- */
- DialNumberID = 40,
-
- /**
- * @brief ButtonPressID.
- */
- ButtonPressID = 41,
-
- /**
- * @brief GetInteriorVehicleDataID.
- */
- GetInteriorVehicleDataID = 43,
-
- /**
- * @brief SetInteriorVehicleDataID.
- */
- SetInteriorVehicleDataID = 44,
-
- /**
- * @brief GetWayPointsID.
- */
- GetWayPointsID = 45,
-
- /**
- * @brief SubscribeWayPointsID.
- */
- SubscribeWayPointsID = 46,
-
- /**
- * @brief UnsubscribeWayPointsID.
- */
- UnsubscribeWayPointsID = 47,
-
- /**
- * @brief GetSystemCapabilityID.
- */
- GetSystemCapabilityID = 48,
-
- /**
- * @brief SendHapticDataID.
- */
- SendHapticDataID = 49,
-
- /**
- * @brief SetCloudAppPropertiesID.
- */
- SetCloudAppPropertiesID = 50,
-
- /**
- * @brief GetCloudAppPropertiesID.
- */
- GetCloudAppPropertiesID = 51,
-
- /**
- * @brief PublishAppServiceID.
- */
- PublishAppServiceID = 52,
-
- /**
- * @brief GetAppServiceDataID.
- */
- GetAppServiceDataID = 53,
-
- /**
- * @brief GetFileID
- */
- GetFileID = 54,
-
- /**
- * @brief PerformAppServiceInteractionID.
- */
- PerformAppServiceInteractionID = 55,
-
- /**
- * @brief UnpublishAppServiceID.
- */
- UnpublishAppServiceID = 56,
-
- /**
- * @brief CancelInteractionID.
- */
- CancelInteractionID = 57,
-
- /**
- * @brief CloseApplicationID.
- */
- CloseApplicationID = 58,
-
- /**
- * @brief ShowAppMenuID.
- */
- ShowAppMenuID = 59,
-
- /**
- * @brief CreateWindowID.
- */
- CreateWindowID = 60,
-
- /**
- * @brief DeleteWindowID.
- */
- DeleteWindowID = 61,
-
- /**
- * @brief OnHMIStatusID.
- */
- OnHMIStatusID = 32768,
-
- /**
- * @brief OnAppInterfaceUnregisteredID.
- */
- OnAppInterfaceUnregisteredID = 32769,
-
- /**
- * @brief OnButtonEventID.
- */
- OnButtonEventID = 32770,
-
- /**
- * @brief OnButtonPressID.
- */
- OnButtonPressID = 32771,
-
- /**
- * @brief OnVehicleDataID.
- */
- OnVehicleDataID = 32772,
-
- /**
- * @brief OnCommandID.
- */
- OnCommandID = 32773,
-
- /**
- * @brief OnTBTClientStateID.
- */
- OnTBTClientStateID = 32774,
-
- /**
- * @brief OnDriverDistractionID.
- */
- OnDriverDistractionID = 32775,
-
- /**
- * @brief OnPermissionsChangeID.
- */
- OnPermissionsChangeID = 32776,
-
- /**
- * @brief OnAudioPassThruID.
- */
- OnAudioPassThruID = 32777,
-
- /**
- * @brief OnLanguageChangeID.
- */
- OnLanguageChangeID = 32778,
-
- /**
- * @brief OnKeyboardInputID.
- */
- OnKeyboardInputID = 32779,
-
- /**
- * @brief OnTouchEventID.
- */
- OnTouchEventID = 32780,
-
- /**
- * @brief OnSystemRequestID.
- */
- OnSystemRequestID = 32781,
-
- /**
- * @brief OnHashChangeID.
- */
- OnHashChangeID = 32782,
-
- /**
- * @brief OnInteriorVehicleDataID.
- */
- OnInteriorVehicleDataID = 32783,
-
- /**
- * @brief OnWayPointChangeID.
- */
- OnWayPointChangeID = 32784,
-
- /**
- * @brief OnRCStatusID.
- */
- OnRCStatusID = 32785,
-
- /**
- * @brief OnAppServiceDataID.
- */
- OnAppServiceDataID = 32786,
-
- /**
- * @brief OnSystemCapabilityUpdatedID
- */
- OnSystemCapabilityUpdatedID = 32787,
-
- /**
- * @brief EncodedSyncPDataID.
- */
- EncodedSyncPDataID = 65536,
-
- /**
- * @brief SyncPDataID.
- */
- SyncPDataID = 65537,
-
- /**
- * @brief OnEncodedSyncPDataID.
- */
- OnEncodedSyncPDataID = 98304,
-
- /**
- * @brief OnSyncPDataID.
- */
- OnSyncPDataID = 98305
-};
-bool IsValidEnum(FunctionID val);
-const char* EnumToJsonString(FunctionID val);
-bool EnumFromJsonString(const std::string& literal, FunctionID* result);
-
extern const std::string kDefaultApp;
extern const std::string kPreDataConsentApp;
extern const std::string kDeviceApp;
diff --git a/src/components/policy/policy_regular/include/policy/policy_table/policy_enum_schema_factory.h b/src/components/policy/policy_regular/include/policy/policy_table/policy_enum_schema_factory.h
new file mode 100644
index 0000000000..2053923cfe
--- /dev/null
+++ b/src/components/policy/policy_regular/include/policy/policy_table/policy_enum_schema_factory.h
@@ -0,0 +1,60 @@
+/**
+ * Copyright (c) 2017, 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_POLICY_POLICY_REGULAR_INCLUDE_POLICY_POLICY_TABLE_POLICY_ENUM_SCHEMA_FACTORY_H
+#define SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_POLICY_TABLE_POLICY_ENUM_SCHEMA_FACTORY_H
+#include <memory>
+#include <string>
+
+#include "smart_objects/smart_schema.h"
+
+namespace rpc {
+namespace policy_table_interface_base {
+
+class EnumSchemaItemFactory {
+ public:
+ /**
+ * @brief Get enum schema from enum name
+ * Implementation of this function should be generated from MOBILE_API.xml
+ * @param enum_name enum name to get schema factory for
+ * @return shared pointer to schema factory or empty shared pointer if
+ * enum_name is wrong
+ */
+ static std::shared_ptr<ns_smart_device_link::ns_smart_objects::ISchemaItem>
+ Get(const std::string& enum_name);
+
+ static bool IsRPCSpecVehicleDataType(const std::string& vd_name);
+};
+
+} // namespace policy_table_interface_base
+} // namespace rpc
+#endif // SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_POLICY_TABLE_POLICY_ENUM_SCHEMA_FACTORY_H
diff --git a/src/components/policy/policy_regular/include/policy/policy_table/types.h b/src/components/policy/policy_regular/include/policy/policy_table/types.h
index cb7b689317..2ffbf2e7ec 100644
--- a/src/components/policy/policy_regular/include/policy/policy_table/types.h
+++ b/src/components/policy/policy_regular/include/policy/policy_table/types.h
@@ -36,7 +36,9 @@
#include <climits>
#include "policy/policy_table/enums.h"
+#include "policy/policy_table/policy_enum_schema_factory.h"
#include "rpc_base/rpc_message.h"
+#include "utils/helpers.h"
namespace Json {
class Value;
@@ -46,6 +48,7 @@ namespace policy_table_interface_base {
struct AppLevel;
struct ApplicationParams;
struct DeviceParams;
+struct EndpointProperty;
struct MessageLanguages;
struct MessageString;
struct RpcParameters;
@@ -67,16 +70,18 @@ typedef Array<Enum<AppHMIType>, 0, 255> AppHMITypes;
typedef Array<Enum<HmiLevel>, 0, 4> HmiLevels;
-typedef Array<Enum<Parameter>, 0, 255> Parameters;
+typedef Array<String<0, 255>, 0, 255> Parameters;
typedef Map<RpcParameters, 0, UINT_MAX> Rpc;
-typedef Array<String<10, 255>, 1, 3> URL;
+typedef Array<String<10, INT_MAX>, 1, 3> URL;
typedef Map<URL, 1, 255> URLList;
typedef Map<URLList, 1, 255> ServiceEndpoints;
+typedef Map<EndpointProperty, 0, 255> ServiceEndpointProperties;
+
typedef uint8_t NumberOfNotificationsType;
typedef Map<Integer<NumberOfNotificationsType, 0, 255>, 0, 7>
NumberOfNotificationsPerMinute;
@@ -287,6 +292,24 @@ struct Rpcs : CompositeType {
bool Validate() const;
};
+struct EndpointProperty : CompositeType {
+ public:
+ Optional<String<0, 100> > version;
+
+ EndpointProperty();
+ ~EndpointProperty();
+ explicit EndpointProperty(const Json::Value* value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport* report__) const;
+ void SetPolicyTableType(PolicyTableType pt_type) OVERRIDE;
+
+ private:
+ bool Validate() const;
+};
+
struct ModuleConfig : CompositeType {
public:
Optional<Map<String<0, 100>, 0, 255> > device_certificates;
@@ -298,6 +321,7 @@ struct ModuleConfig : CompositeType {
Integer<uint16_t, 0, 65535> timeout_after_x_seconds;
SecondsBetweenRetries seconds_between_retries;
ServiceEndpoints endpoints;
+ Optional<ServiceEndpointProperties> endpoint_properties;
NumberOfNotificationsPerMinute notifications_per_minute_by_priority;
Optional<String<1, 100> > vehicle_make;
Optional<String<1, 100> > vehicle_model;
@@ -306,6 +330,8 @@ struct ModuleConfig : CompositeType {
Optional<String<0, 65535> > certificate;
Optional<Boolean> lock_screen_dismissal_enabled;
+ static const std::string kDefaultOemMappingServiceName;
+
public:
ModuleConfig();
ModuleConfig(uint8_t exchange_after_x_ignition_cycles,
@@ -314,6 +340,7 @@ struct ModuleConfig : CompositeType {
uint16_t timeout_after_x_seconds,
const SecondsBetweenRetries& seconds_between_retries,
const ServiceEndpoints& endpoints,
+ const ServiceEndpointProperties& endpoint_properties,
const NumberOfNotificationsPerMinute&
notifications_per_minute_by_priority);
~ModuleConfig();
@@ -497,6 +524,88 @@ struct DeviceParams : CompositeType {
bool Validate() const;
};
+struct VehicleDataItem : CompositeType {
+ public:
+ static const std::vector<std::string> kPODTypes;
+
+ static const std::string kInteger;
+ static const std::string kStruct;
+ static const std::string kString;
+ static const std::string kFloat;
+ static const std::string kDouble;
+ static const std::string kBoolean;
+ static const std::string kName;
+ static const std::string kParams;
+
+ String<1, 255> name;
+ String<0, 255> type;
+ String<1, 255> key;
+ Boolean mandatory;
+ Optional<Array<VehicleDataItem, 0, 255> > params;
+
+ Optional<Boolean> array;
+ Optional<String<0, 255> > since;
+ Optional<String<0, 255> > until;
+ Optional<Boolean> removed;
+ Optional<Boolean> deprecated;
+ Optional<Float<-INT32_MAX, INT32_MAX> > minvalue;
+ Optional<Float<-INT32_MAX, INT32_MAX> > maxvalue;
+ Optional<Integer<uint32_t, 0, UINT32_MAX> > minsize;
+ Optional<Integer<uint32_t, 0, UINT32_MAX> > maxsize;
+ Optional<Integer<uint32_t, 0, UINT32_MAX> > minlength;
+ Optional<Integer<uint32_t, 0, UINT32_MAX> > maxlength;
+
+ VehicleDataItem();
+ VehicleDataItem(const VehicleDataItem& policy_table);
+ explicit VehicleDataItem(const Json::Value* value__);
+
+ bool operator==(const VehicleDataItem& vd);
+
+ ~VehicleDataItem();
+
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_not_empty() const;
+ void ReportErrors(rpc::ValidationReport* report__) const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+
+ /**
+ * @brief Validates type of vehicle data item according to
+ * POD types and generated from API enums.
+ * @return true if type is valid.
+ */
+ bool ValidateTypes() const;
+ bool IsPrimitiveType() const;
+ bool ValidateNaming(std::string str) const;
+
+ private:
+ bool Validate() const;
+};
+
+typedef Array<VehicleDataItem, 0, 255> VehicleDataItems;
+
+struct VehicleData : CompositeType {
+ public:
+ Optional<String<0, 100> > schema_version;
+ Optional<VehicleDataItems> schema_items;
+
+ VehicleData();
+ VehicleData(const VehicleData& vehicle_data);
+ VehicleData(const Json::Value* value__);
+ ~VehicleData();
+
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport* report__) const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+
+ private:
+ bool Validate() const;
+};
+
struct PolicyTable : CompositeType {
public:
ApplicationPoliciesSection app_policies_section;
@@ -506,6 +615,7 @@ struct PolicyTable : CompositeType {
Optional<ModuleMeta> module_meta;
Optional<UsageAndErrorCounts> usage_and_error_counts;
Optional<DeviceData> device_data;
+ Optional<VehicleData> vehicle_data;
public:
PolicyTable();
diff --git a/src/components/policy/policy_regular/include/policy/policy_types.h b/src/components/policy/policy_regular/include/policy/policy_types.h
index 08ff9b4285..9fddb9761b 100644
--- a/src/components/policy/policy_regular/include/policy/policy_types.h
+++ b/src/components/policy/policy_regular/include/policy/policy_types.h
@@ -503,7 +503,7 @@ enum PermissionsCheckResult {
RESULT_NICKNAME_MISMATCH,
RESULT_PERMISSIONS_REVOKED,
RESULT_CONSENT_NEEDED,
- RESULT_CONSENT_NOT_REQIURED,
+ RESULT_CONSENT_NOT_REQUIRED,
RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED,
RESULT_REQUEST_TYPE_CHANGED,
RESULT_REQUEST_SUBTYPE_CHANGED,
diff --git a/src/components/policy/policy_regular/include/policy/pt_representation.h b/src/components/policy/policy_regular/include/policy/pt_representation.h
index 0534b27093..1adf24ed19 100644
--- a/src/components/policy/policy_regular/include/policy/pt_representation.h
+++ b/src/components/policy/policy_regular/include/policy/pt_representation.h
@@ -123,11 +123,6 @@ class PTRepresentation {
virtual bool SecondsBetweenRetries(std::vector<int>* seconds) = 0;
/**
- * @brief Get information about vehicle
- */
- virtual const VehicleInfo GetVehicleInfo() const = 0;
-
- /**
* @brief Allows to update 'vin' field in module_meta table.
*
* @param new 'vin' value.
diff --git a/src/components/policy/policy_regular/include/policy/sql_pt_queries.h b/src/components/policy/policy_regular/include/policy/sql_pt_queries.h
index bada9a003a..66637b7812 100644
--- a/src/components/policy/policy_regular/include/policy/sql_pt_queries.h
+++ b/src/components/policy/policy_regular/include/policy/sql_pt_queries.h
@@ -143,6 +143,19 @@ extern const std::string kSelectDBVersion;
extern const std::string kUpdateDBVersion;
extern const std::string kSaveModuleMeta;
extern const std::string kSelectModuleMeta;
+extern const std::string kInsertVehicleDataItem;
+extern const std::string kSelectVehicleDataItem;
+extern const std::string kDeleteVehicleDataItems;
+extern const std::string kInsertVehicleDataItemParams;
+extern const std::string kSelectVehicleDataItemParams;
+extern const std::string kDeleteVehicleDataItemParams;
+extern const std::string kSelectVehicleDataItemWithVersion;
+extern const std::string kSelectPrimitiveVehicleDataItems;
+extern const std::string kSelectCompositeVehicleDataItemsKey;
+extern const std::string kSelectVehicleDataSchemaVersion;
+extern const std::string kInsertVehicleDataSchemaVersion;
+extern const std::string kSelectEndpointProperties;
+extern const std::string kInsertEndpointVersion;
} // namespace sql_pt
} // namespace policy
diff --git a/src/components/policy/policy_regular/include/policy/sql_pt_representation.h b/src/components/policy/policy_regular/include/policy/sql_pt_representation.h
index e95620fbc2..216598850e 100644
--- a/src/components/policy/policy_regular/include/policy/sql_pt_representation.h
+++ b/src/components/policy/policy_regular/include/policy/sql_pt_representation.h
@@ -44,6 +44,7 @@ namespace policy_table = rpc::policy_table_interface_base;
namespace utils {
namespace dbms {
class SQLDatabase;
+class SQLQuery;
} // namespace dbms
} // namespace utils
@@ -69,7 +70,6 @@ class SQLPTRepresentation : public virtual PTRepresentation {
virtual int TimeoutResponse();
virtual bool SecondsBetweenRetries(std::vector<int>* seconds);
virtual bool RefreshDB();
- virtual const VehicleInfo GetVehicleInfo() const;
virtual std::vector<UserFriendlyMessage> GetUserFriendlyMsg(
const std::vector<std::string>& msg_codes, const std::string& language);
@@ -123,6 +123,9 @@ class SQLPTRepresentation : public virtual PTRepresentation {
policy_table::ConsumerFriendlyMessages* messages) const;
virtual bool GatherApplicationPoliciesSection(
policy_table::ApplicationPoliciesSection* policies) const;
+ virtual bool GatherVehicleDataItems(
+ policy_table::VehicleDataItems* vehicle_data_items) const;
+ virtual bool GatherVehicleData(policy_table::VehicleData* vehicle_data) const;
bool GatherAppGroup(const std::string& app_id,
policy_table::Strings* app_groups) const;
@@ -159,6 +162,9 @@ class SQLPTRepresentation : public virtual PTRepresentation {
virtual bool SaveSpecificAppPolicy(
const policy_table::ApplicationPolicies::value_type& app);
virtual bool SaveDevicePolicy(const policy_table::DevicePolicy& device);
+ virtual bool SaveVehicleDataItems(
+ const policy_table::VehicleDataItems& vehicle_data_items);
+ virtual bool SaveVehicleData(const policy_table::VehicleData& vehicle_data);
virtual bool SaveMessageString(const std::string& type,
const std::string& lang,
@@ -202,6 +208,26 @@ class SQLPTRepresentation : public virtual PTRepresentation {
virtual bool IsDBVersionActual() const OVERRIDE;
virtual bool UpdateDBVersion() const OVERRIDE;
+ policy_table::VehicleDataItems GetVehicleDataItem(
+ const std::string& name, const std::string& key) const;
+ bool InsertVehicleDataItem(
+ const policy_table::VehicleDataItem& vehicle_data_item);
+ bool VehicleDataItemExists(
+ const policy_table::VehicleDataItem& vehicle_data_item) const;
+
+ /**
+ * @brief Retrieves vehicle data items of type Struct (which contains
+ * params) from the database including these parameters.
+ * @return Array of composite VehicleDataItems
+ */
+ policy_table::VehicleDataItems SelectCompositeVehicleDataItems() const;
+
+ /**
+ * @brief Retrieves vehicle data items of non Struct type from the database.
+ * @return Array of primitive VehicleDataItems
+ */
+ policy_table::VehicleDataItems SelectPrimitiveVehicleDataItems() const;
+
private:
static const std::string kDatabaseName;
utils::dbms::SQLDatabase* db_;
@@ -217,12 +243,17 @@ class SQLPTRepresentation : public virtual PTRepresentation {
const int32_t GetDBVersion() const;
bool SaveRpcs(int64_t group_id, const policy_table::Rpc& rpcs);
bool SaveServiceEndpoints(const policy_table::ServiceEndpoints& endpoints);
+ bool SaveServiceEndpointProperties(
+ const policy_table::ServiceEndpointProperties& endpoint_properties);
bool SaveSecondsBetweenRetries(
const policy_table::SecondsBetweenRetries& seconds);
bool SaveNumberOfNotificationsPerMinute(
const policy_table::NumberOfNotificationsPerMinute& notifications);
bool SaveMessageType(const std::string& type);
bool SaveLanguage(const std::string& code);
+ policy_table::VehicleDataItem PopulateVDIFromQuery(
+ const utils::dbms::SQLQuery& query) const;
+ bool DeleteVehicleDataItems() const;
bool is_in_memory;
};
diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc
index b13770282f..166a79b89d 100644
--- a/src/components/policy/policy_regular/src/cache_manager.cc
+++ b/src/components/policy/policy_regular/src/cache_manager.cc
@@ -33,14 +33,17 @@
#include "policy/cache_manager.h"
#include <algorithm>
+#include <boost/algorithm/string.hpp>
#include <cmath>
#include <ctime>
#include <functional>
#include <sstream>
+#include "interfaces/MOBILE_API.h"
#include "json/features.h"
#include "json/reader.h"
#include "json/writer.h"
+#include "smart_objects/enum_schema_item.h"
#include "utils/date_time.h"
#include "utils/file_system.h"
#include "utils/gen_hash.h"
@@ -296,11 +299,49 @@ bool CacheManager::ApplyUpdate(const policy_table::Table& update_pt) {
pt_->policy_table.consumer_friendly_messages.assign_if_valid(
update_pt.policy_table.consumer_friendly_messages);
+ pt_->policy_table.module_config.endpoint_properties =
+ update_pt.policy_table.module_config.endpoint_properties;
+
+ // Apply update for vehicle data
+ if (update_pt.policy_table.vehicle_data.is_initialized()) {
+ if (!update_pt.policy_table.vehicle_data->schema_items.is_initialized() ||
+ update_pt.policy_table.vehicle_data->schema_items->empty()) {
+ pt_->policy_table.vehicle_data->schema_items =
+ rpc::Optional<policy_table::VehicleDataItems>();
+ } else {
+ policy_table::VehicleDataItems custom_items = CollectCustomVDItems(
+ *update_pt.policy_table.vehicle_data->schema_items);
+
+ pt_->policy_table.vehicle_data->schema_version =
+ update_pt.policy_table.vehicle_data->schema_version;
+ pt_->policy_table.vehicle_data->schema_items =
+ rpc::Optional<policy_table::VehicleDataItems>(custom_items);
+ }
+ if (update_pt.policy_table.vehicle_data->schema_version.is_initialized() &&
+ update_pt.policy_table.vehicle_data->schema_items.is_initialized()) {
+ }
+ }
+
ResetCalculatedPermissions();
Backup();
return true;
}
+policy_table::VehicleDataItems CacheManager::CollectCustomVDItems(
+ const policy_table::VehicleDataItems& vd_items) {
+ policy_table::VehicleDataItems result_items;
+ for (auto& item : vd_items) {
+ const std::string i_name = "VEHICLEDATA_" + std::string(item.name);
+ const std::string vd_name = boost::to_upper_copy<std::string>(i_name);
+ const bool is_rpc_spec =
+ policy_table::EnumSchemaItemFactory::IsRPCSpecVehicleDataType(vd_name);
+ if (!is_rpc_spec) {
+ result_items.push_back(item);
+ }
+ }
+ return result_items;
+}
+
void CacheManager::GetHMIAppTypeAfterUpdate(
std::map<std::string, StringArray>& app_hmi_types) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -526,14 +567,8 @@ void CacheManager::CheckPermissions(const policy_table::Strings& groups,
if (rpc_param.hmi_levels.end() != hmi_iter) {
result.hmi_level_permitted = PermitResult::kRpcAllowed;
- policy_table::Parameters::const_iterator params_iter =
- rpc_param.parameters->begin();
- policy_table::Parameters::const_iterator params_iter_end =
- rpc_param.parameters->end();
-
- for (; params_iter != params_iter_end; ++params_iter) {
- result.list_of_allowed_params.insert(
- policy_table::EnumToJsonString(*params_iter));
+ for (const auto& param : *rpc_param.parameters) {
+ result.list_of_allowed_params.insert(std::string(param));
}
}
}
@@ -680,20 +715,20 @@ bool CacheManager::SecondsBetweenRetries(std::vector<int>& seconds) {
return true;
}
-const policy::VehicleInfo CacheManager::GetVehicleInfo() const {
- CACHE_MANAGER_CHECK(VehicleInfo());
+const std::vector<policy_table::VehicleDataItem>
+CacheManager::GetVehicleDataItems() const {
+ CACHE_MANAGER_CHECK(std::vector<policy_table::VehicleDataItem>());
sync_primitives::AutoLock auto_lock(cache_lock_);
- policy_table::ModuleConfig& module_config = pt_->policy_table.module_config;
- VehicleInfo vehicle_info;
- vehicle_info.vehicle_make = *module_config.vehicle_make;
- vehicle_info.vehicle_model = *module_config.vehicle_model;
- vehicle_info.vehicle_year = *module_config.vehicle_year;
- LOG4CXX_DEBUG(
- logger_,
- "Vehicle info (make, model, year):" << vehicle_info.vehicle_make << ","
- << vehicle_info.vehicle_model << ","
- << vehicle_info.vehicle_year);
- return vehicle_info;
+ if (pt_->policy_table.vehicle_data.is_initialized() &&
+ pt_->policy_table.vehicle_data->schema_items.is_initialized()) {
+ return *(pt_->policy_table.vehicle_data->schema_items);
+ }
+
+ return std::vector<policy_table::VehicleDataItem>();
+}
+
+Json::Value CacheManager::GetPolicyTableData() const {
+ return pt_->policy_table.ToJsonValue();
}
void CacheManager::GetEnabledCloudApps(
@@ -969,11 +1004,19 @@ std::vector<UserFriendlyMessage> CacheManager::GetUserFriendlyMsg(
void CacheManager::GetUpdateUrls(const uint32_t service_type,
EndpointUrls& out_end_points) {
- std::stringstream service_type_stream;
- service_type_stream << (service_type <= 9 ? "0x0" : "0x") << service_type;
-
- const std::string service_type_str = service_type_stream.str();
- GetUpdateUrls(service_type_str, out_end_points);
+ auto find_hexademical =
+ [service_type](policy_table::ServiceEndpoints::value_type end_point) {
+ uint32_t decimal;
+ std::istringstream(end_point.first) >> std::hex >> decimal;
+ return end_point.first.compare(0, 2, "0x") == 0 &&
+ decimal == service_type;
+ };
+ auto& end_points = pt_->policy_table.module_config.endpoints;
+ const auto end_point =
+ std::find_if(end_points.begin(), end_points.end(), find_hexademical);
+ if (end_point != end_points.end()) {
+ GetUpdateUrls(end_point->first, out_end_points);
+ }
}
void CacheManager::GetUpdateUrls(const std::string& service_type,
@@ -1301,6 +1344,14 @@ std::shared_ptr<policy_table::Table> CacheManager::GenerateSnapshot() {
pt_->policy_table.usage_and_error_counts;
snapshot_->policy_table.device_data = pt_->policy_table.device_data;
+ if (pt_->policy_table.vehicle_data.is_initialized()) {
+ snapshot_->policy_table.vehicle_data =
+ rpc::Optional<policy_table::VehicleData>();
+ snapshot_->policy_table.vehicle_data->mark_initialized();
+ snapshot_->policy_table.vehicle_data->schema_version =
+ pt_->policy_table.vehicle_data->schema_version;
+ }
+
// Set policy table type to Snapshot
snapshot_->SetPolicyTableType(
rpc::policy_table_interface_base::PolicyTableType::PT_SNAPSHOT);
@@ -1684,6 +1735,8 @@ bool CacheManager::Init(const std::string& file_name,
if (!result) {
rpc::ValidationReport report("policy_table");
snapshot->ReportErrors(&report);
+ LOG4CXX_DEBUG(logger_,
+ "Validation report: " << rpc::PrettyFormat(report));
return result;
}
@@ -1934,6 +1987,7 @@ bool CacheManager::MergePreloadPT(const std::string& file_name) {
MergeFG(new_table, current);
MergeAP(new_table, current);
MergeCFM(new_table, current);
+ MergeVD(new_table, current);
Backup();
}
return true;
@@ -2001,6 +2055,12 @@ void CacheManager::MergeCFM(const policy_table::PolicyTable& new_pt,
}
}
+void CacheManager::MergeVD(const policy_table::PolicyTable& new_pt,
+ policy_table::PolicyTable& pt) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ pt.vehicle_data.assign_if_valid(new_pt.vehicle_data);
+}
+
const PolicySettings& CacheManager::get_settings() const {
DCHECK(settings_);
diff --git a/src/components/policy/policy_regular/src/policy_helper.cc b/src/components/policy/policy_regular/src/policy_helper.cc
index 7ebb66bf2b..7338e98cff 100644
--- a/src/components/policy/policy_regular/src/policy_helper.cc
+++ b/src/components/policy/policy_regular/src/policy_helper.cc
@@ -46,7 +46,8 @@ namespace {
CREATE_LOGGERPTR_GLOBAL(logger_, "Policy")
-bool Compare(const StringsValueType& first, const StringsValueType& second) {
+bool CompareStrings(const StringsValueType& first,
+ const StringsValueType& second) {
const std::string& first_str = first;
const std::string& second_str = second;
return (strcasecmp(first_str.c_str(), second_str.c_str()) < 0);
@@ -136,10 +137,10 @@ bool policy::CheckAppPolicy::HasRevokedGroups(
snapshot_->policy_table.app_policies_section.apps.find(app_policy.first);
policy_table::Strings groups_new = app_policy.second.groups;
- std::sort(groups_new.begin(), groups_new.end(), Compare);
+ std::sort(groups_new.begin(), groups_new.end(), CompareStrings);
policy_table::Strings groups_curr = (*it).second.groups;
- std::sort(groups_curr.begin(), groups_curr.end(), Compare);
+ std::sort(groups_curr.begin(), groups_curr.end(), CompareStrings);
StringsConstItr it_groups_new = groups_new.begin();
StringsConstItr it_groups_new_end = groups_new.end();
@@ -153,18 +154,7 @@ bool policy::CheckAppPolicy::HasRevokedGroups(
it_groups_new,
it_groups_new_end,
std::back_inserter(revoked_group_list),
- Compare);
-
- // Remove groups which are not required user consent
- policy_table::Strings::iterator it_revoked = revoked_group_list.begin();
- for (; revoked_group_list.end() != it_revoked;) {
- if (!IsConsentRequired(app_policy.first, std::string(*it_revoked))) {
- revoked_group_list.erase(it_revoked);
- it_revoked = revoked_group_list.begin();
- } else {
- ++it_revoked;
- }
- }
+ CompareStrings);
if (revoked_groups) {
*revoked_groups = revoked_group_list;
@@ -173,6 +163,76 @@ bool policy::CheckAppPolicy::HasRevokedGroups(
return !revoked_group_list.empty();
}
+bool policy::CheckAppPolicy::HasUpdatedGroups(
+ const policy::AppPoliciesValueType& app_policy,
+ policy_table::Strings* updated_groups) const {
+ AppPoliciesConstItr it =
+ snapshot_->policy_table.app_policies_section.apps.find(app_policy.first);
+
+ policy_table::Strings groups_new = app_policy.second.groups;
+ std::sort(groups_new.begin(), groups_new.end(), CompareStrings);
+
+ policy_table::Strings groups_curr = (*it).second.groups;
+ std::sort(groups_curr.begin(), groups_curr.end(), CompareStrings);
+
+ policy_table::Strings intersection_list;
+ std::set_intersection(groups_new.begin(),
+ groups_new.end(),
+ groups_curr.begin(),
+ groups_curr.end(),
+ std::back_inserter(intersection_list));
+
+ auto IsGroupContentUpdated =
+ [this](const StringsValueType& groupName) -> bool {
+ const auto& func_group_from_update =
+ update_->policy_table.functional_groupings.find(groupName);
+ const auto& func_group_from_snapshot =
+ snapshot_->policy_table.functional_groupings.find(groupName);
+
+ const auto& update_fg_rpcs = func_group_from_update->second.rpcs;
+ const auto& snapshot_fg_rpcs = func_group_from_snapshot->second.rpcs;
+
+ if (update_fg_rpcs.is_null() || snapshot_fg_rpcs.is_null()) {
+ return !(update_fg_rpcs.is_null() && snapshot_fg_rpcs.is_null());
+ }
+
+ if (update_fg_rpcs.size() != snapshot_fg_rpcs.size()) {
+ return true;
+ }
+
+ for (const auto& rpc : update_fg_rpcs) {
+ const auto& old_rpc = snapshot_fg_rpcs.find(rpc.first);
+ if (snapshot_fg_rpcs.end() == old_rpc) {
+ return true;
+ }
+
+ const bool hmi_levels_same =
+ old_rpc->second.hmi_levels == rpc.second.hmi_levels;
+ const bool parameters_same =
+ *(old_rpc->second.parameters) == *(rpc.second.parameters);
+
+ if (!hmi_levels_same || !parameters_same) {
+ return true;
+ }
+ }
+
+ return false;
+ };
+
+ policy_table::Strings updated_group_list;
+ for (const auto& item : intersection_list) {
+ if (IsGroupContentUpdated(item)) {
+ updated_group_list.push_back(item);
+ }
+ }
+
+ if (updated_groups) {
+ *updated_groups = updated_group_list;
+ }
+
+ return !updated_group_list.empty();
+}
+
bool policy::CheckAppPolicy::HasNewGroups(
const policy::AppPoliciesValueType& app_policy,
policy_table::Strings* new_groups) const {
@@ -180,10 +240,10 @@ bool policy::CheckAppPolicy::HasNewGroups(
snapshot_->policy_table.app_policies_section.apps.find(app_policy.first);
policy_table::Strings groups_new = app_policy.second.groups;
- std::sort(groups_new.begin(), groups_new.end(), Compare);
+ std::sort(groups_new.begin(), groups_new.end(), CompareStrings);
policy_table::Strings groups_curr = (*it).second.groups;
- std::sort(groups_curr.begin(), groups_curr.end(), Compare);
+ std::sort(groups_curr.begin(), groups_curr.end(), CompareStrings);
StringsConstItr it_groups_new = groups_new.begin();
StringsConstItr it_groups_new_end = groups_new.end();
@@ -197,7 +257,7 @@ bool policy::CheckAppPolicy::HasNewGroups(
it_groups_curr,
it_groups_curr_end,
std::back_inserter(new_group_list),
- Compare);
+ CompareStrings);
if (new_groups) {
*new_groups = new_group_list;
@@ -209,14 +269,23 @@ bool policy::CheckAppPolicy::HasNewGroups(
bool policy::CheckAppPolicy::HasConsentNeededGroups(
const policy::AppPoliciesValueType& app_policy) const {
policy_table::Strings new_groups;
- if (!HasNewGroups(app_policy, &new_groups)) {
+ policy_table::Strings updated_groups;
+ if (!HasNewGroups(app_policy, &new_groups) &&
+ !HasUpdatedGroups(app_policy, &updated_groups)) {
return false;
}
- StringsConstItr it_new = new_groups.begin();
- StringsConstItr it_new_end = new_groups.end();
- for (; it_new != it_new_end; ++it_new) {
- if (IsConsentRequired(app_policy.first, *it_new)) {
+ policy_table::Strings groups_to_check_consent;
+ std::set_union(new_groups.begin(),
+ new_groups.end(),
+ updated_groups.begin(),
+ updated_groups.end(),
+ std::back_inserter(groups_to_check_consent));
+
+ StringsConstItr it = groups_to_check_consent.begin();
+ StringsConstItr it_end = groups_to_check_consent.end();
+ for (; it != it_end; ++it) {
+ if (IsConsentRequired(app_policy.first, *it)) {
return true;
}
}
@@ -391,32 +460,32 @@ bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) {
"Permissions for application:" << app_id << " have been changed.");
if (IsPredefinedApp(app_policy)) {
- LOG4CXX_DEBUG(logger_, "app id: " << app_id << " is predefined app");
- for (const policy_table::ApplicationPolicies::value_type& app :
- snapshot_->policy_table.app_policies_section.apps) {
- if (app_policy.first == app.second.get_string()) {
- if (RESULT_CONSENT_NOT_REQIURED != result) {
- SetPendingPermissions(app, result);
- AddResult(app_id, RESULT_CONSENT_NEEDED);
- }
- LOG4CXX_DEBUG(logger_, "Sending permissions for app: " << app_id);
- }
+ const auto& snapshot_app_policy_begin =
+ snapshot_->policy_table.app_policies_section.apps.begin();
+ const auto& snapshot_app_policy_end =
+ snapshot_->policy_table.app_policies_section.apps.end();
+
+ auto find_app = [&app_id](AppPoliciesValueType app) {
+ return app_id == app.second.get_string();
+ };
+
+ const auto& app = std::find_if(
+ snapshot_app_policy_begin, snapshot_app_policy_end, find_app);
+
+ if ((snapshot_app_policy_end != app) &&
+ (RESULT_CONSENT_NOT_REQUIRED != result)) {
+ SetPendingPermissions(*app, result);
+ AddResult(app_id, RESULT_CONSENT_NEEDED);
}
return true;
}
- if (!IsPredefinedApp(app_policy) && RESULT_CONSENT_NOT_REQIURED != result) {
- LOG4CXX_DEBUG(logger_, "Sending permissions for app: " << app_id);
+ if (RESULT_CONSENT_NOT_REQUIRED != result) {
SetPendingPermissions(app_policy, result);
AddResult(app_id, RESULT_CONSENT_NEEDED);
}
- // Don't sent notification for predefined apps (e.g. default, device etc.)
- if (!IsPredefinedApp(app_policy)) {
- LOG4CXX_DEBUG(logger_, "Sending permissions for app: " << app_id);
- SetPendingPermissions(app_policy, result);
- AddResult(app_id, result);
- }
+ SendPermissionsToApp(app_policy.first, app_policy.second.groups);
return true;
}
@@ -485,14 +554,16 @@ policy::PermissionsCheckResult policy::CheckAppPolicy::CheckPermissionsChanges(
const bool encryption_required_flag_changed =
IsEncryptionRequiredFlagChanged(app_policy);
+ bool has_updated_groups = HasUpdatedGroups(app_policy);
+
if (has_revoked_groups && has_consent_needed_groups) {
return RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED;
} else if (has_revoked_groups) {
return RESULT_PERMISSIONS_REVOKED;
} else if (has_consent_needed_groups) {
return RESULT_CONSENT_NEEDED;
- } else if (has_new_groups) {
- return RESULT_CONSENT_NOT_REQIURED;
+ } else if (has_new_groups || has_updated_groups) {
+ return RESULT_CONSENT_NOT_REQUIRED;
} else if (encryption_required_flag_changed) {
return RESULT_ENCRYPTION_REQUIRED_FLAG_CHANGED;
}
@@ -672,7 +743,7 @@ void FillActionsForAppPolicies::operator()(
case RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED:
actions_[app_id].is_consent_needed = true;
break;
- case RESULT_CONSENT_NOT_REQIURED:
+ case RESULT_CONSENT_NOT_REQUIRED:
case RESULT_PERMISSIONS_REVOKED:
case RESULT_REQUEST_TYPE_CHANGED:
case RESULT_REQUEST_SUBTYPE_CHANGED:
@@ -752,7 +823,7 @@ void FillNotificationData::UpdateParameters(
ParametersConstItr it_parameters_end = in_parameters.end();
for (; it_parameters != it_parameters_end; ++it_parameters) {
- out_parameter.insert(policy_table::EnumToJsonString(*it_parameters));
+ out_parameter.insert(*it_parameters);
}
}
diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc
index ee4c991183..7e3b7ccbe9 100644
--- a/src/components/policy/policy_regular/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc
@@ -167,7 +167,9 @@ void FilterInvalidFunctions(policy_table::Rpc& rpcs) {
* schema
* @param rpc_parameters parameters to filter
*/
-void FilterInvalidRPCParameters(policy_table::RpcParameters& rpc_parameters) {
+void FilterInvalidRPCParameters(
+ policy_table::RpcParameters& rpc_parameters,
+ const std::vector<policy_table::VehicleDataItem>& vehicle_data_items) {
policy_table::HmiLevels valid_hmi_levels;
for (const auto& hmi_level : rpc_parameters.hmi_levels) {
if (hmi_level.is_valid()) {
@@ -176,10 +178,31 @@ void FilterInvalidRPCParameters(policy_table::RpcParameters& rpc_parameters) {
}
rpc_parameters.hmi_levels.swap(valid_hmi_levels);
+ auto ParamExists =
+ [&vehicle_data_items](const rpc::String<0, 255>& param_name) {
+ policy_table::Parameter parameter_enum;
+ if (policy_table::EnumFromJsonString(param_name, &parameter_enum)) {
+ return true;
+ }
+
+ // In case when this collection is empty that means collection is not
+ // initialized
+ if (vehicle_data_items.empty()) {
+ return false;
+ }
+
+ for (const auto& vdi : vehicle_data_items) {
+ if (param_name == vdi.name) {
+ return true;
+ }
+ }
+ return false;
+ };
+
policy_table::Parameters valid_params;
const policy_table::Parameters& params = *(rpc_parameters.parameters);
for (const auto& param : params) {
- if (param.is_valid()) {
+ if (param.is_valid() && ParamExists(param)) {
valid_params.push_back(param);
}
}
@@ -264,7 +287,9 @@ void FilterInvalidApplicationParameters(
* @brief FilterPolicyTable filter values that not present in schema
* @param pt policy table to filter
*/
-void FilterPolicyTable(policy_table::PolicyTable& pt) {
+void FilterPolicyTable(
+ policy_table::PolicyTable& pt,
+ const std::vector<policy_table::VehicleDataItem>& current_vd_items) {
policy_table::ModuleConfig& module_config = pt.module_config;
if (module_config.is_initialized() &&
module_config.notifications_per_minute_by_priority.is_initialized()) {
@@ -283,8 +308,18 @@ void FilterPolicyTable(policy_table::PolicyTable& pt) {
policy_table::Rpc& rpcs = group.second.rpcs;
FilterInvalidFunctions(rpcs);
+ policy_table::VehicleDataItems vehicle_data_items;
+
+ if (!pt.vehicle_data->struct_empty()) {
+ vehicle_data_items =
+ pt.vehicle_data.is_initialized() &&
+ pt.vehicle_data->schema_items.is_initialized()
+ ? *pt.vehicle_data->schema_items
+ : current_vd_items;
+ }
+
for (auto& func : rpcs) {
- FilterInvalidRPCParameters(func.second);
+ FilterInvalidRPCParameters(func.second, vehicle_data_items);
}
}
}
@@ -314,10 +349,11 @@ bool PolicyManagerImpl::LoadPT(const std::string& file,
file_system::DeleteFile(file);
- FilterPolicyTable(pt_update->policy_table);
+ auto current_vd_items = GetVehicleDataItems();
+
+ FilterPolicyTable(pt_update->policy_table, current_vd_items);
if (!IsPTValid(pt_update, policy_table::PT_UPDATE)) {
wrong_ptu_update_received_ = true;
- ResetRetrySequence(ResetRetryCountType::kResetInternally);
update_status_manager_.OnWrongUpdateReceived();
return false;
}
@@ -345,13 +381,9 @@ bool PolicyManagerImpl::LoadPT(const std::string& file,
return false;
}
- // Checking of difference between PTU and current policy state
- // Must to be done before PTU applying since it is possible, that functional
- // groups, which had been present before are absent in PTU and will be
- // removed after update. So in case of revoked groups system has to know
- // names and ids of revoked groups before they will be removed.
- const auto results =
- CheckPermissionsChanges(pt_update, policy_table_snapshot);
+ // Replace predefined policies with its actual setting, e.g. "123":"default"
+ // to actual values of default section
+ UnwrapAppPolicies(pt_update->policy_table.app_policies_section.apps);
// Replace current data with updated
if (!cache_->ApplyUpdate(*pt_update)) {
@@ -363,6 +395,14 @@ bool PolicyManagerImpl::LoadPT(const std::string& file,
}
CheckPermissionsChangesAfterUpdate(*pt_update, *policy_table_snapshot);
+ // Checking of difference between PTU and current policy state
+ // Must to be done before PTU applying since it is possible, that functional
+ // groups, which had been present before are absent in PTU and will be
+ // removed after update. So in case of revoked groups system has to know
+ // names and ids of revoked groups before they will be removed.
+ const auto results =
+ CheckPermissionsChanges(pt_update, policy_table_snapshot);
+
ProcessAppPolicyCheckResults(
results, pt_update->policy_table.app_policies_section.apps);
@@ -650,9 +690,13 @@ const std::vector<std::string> PolicyManagerImpl::GetAppRequestSubTypes(
cache_->GetAppRequestSubTypes(policy_app_id, request_subtypes);
return request_subtypes;
}
+const std::vector<policy_table::VehicleDataItem>
+PolicyManagerImpl::GetVehicleDataItems() const {
+ return cache_->GetVehicleDataItems();
+}
-const VehicleInfo PolicyManagerImpl::GetVehicleInfo() const {
- return cache_->GetVehicleInfo();
+Json::Value PolicyManagerImpl::GetPolicyTableData() const {
+ return cache_->GetPolicyTableData();
}
void PolicyManagerImpl::GetEnabledCloudApps(
diff --git a/src/components/policy/policy_regular/src/policy_table/enums.cc b/src/components/policy/policy_regular/src/policy_table/enums.cc
index 56bbd53762..8aabf54c5d 100644
--- a/src/components/policy/policy_regular/src/policy_table/enums.cc
+++ b/src/components/policy/policy_regular/src/policy_table/enums.cc
@@ -3,1524 +3,6 @@
namespace rpc {
namespace policy_table_interface_base {
-bool IsValidEnum(Priority val) {
- switch (val) {
- case P_EMERGENCY:
- return true;
- case P_NAVIGATION:
- return true;
- case P_VOICECOM:
- return true;
- case P_COMMUNICATION:
- return true;
- case P_NORMAL:
- return true;
- case P_PROJECTION:
- return true;
- case P_NONE:
- return true;
- default:
- return false;
- }
-}
-const char* EnumToJsonString(Priority val) {
- switch (val) {
- case P_EMERGENCY:
- return "EMERGENCY";
- case P_NAVIGATION:
- return "NAVIGATION";
- case P_VOICECOM:
- return "VOICECOM";
- case P_COMMUNICATION:
- return "COMMUNICATION";
- case P_NORMAL:
- return "NORMAL";
- case P_PROJECTION:
- return "PROJECTION";
- case P_NONE:
- return "NONE";
- default:
- return "";
- }
-}
-bool EnumFromJsonString(const std::string& literal, Priority* result) {
- if ("EMERGENCY" == literal) {
- *result = P_EMERGENCY;
- return true;
- } else if ("NAVIGATION" == literal) {
- *result = P_NAVIGATION;
- return true;
- } else if ("VOICECOM" == literal) {
- *result = P_VOICECOM;
- return true;
- } else if ("COMMUNICATION" == literal) {
- *result = P_COMMUNICATION;
- return true;
- } else if ("NORMAL" == literal) {
- *result = P_NORMAL;
- return true;
- } else if ("PROJECTION" == literal) {
- *result = P_PROJECTION;
- return true;
- } else if ("NONE" == literal) {
- *result = P_NONE;
- return true;
- } else {
- return false;
- }
-}
-
-bool IsValidEnum(HmiLevel val) {
- switch (val) {
- case HL_BACKGROUND:
- return true;
- case HL_FULL:
- return true;
- case HL_LIMITED:
- return true;
- case HL_NONE:
- return true;
- default:
- return false;
- }
-}
-const char* EnumToJsonString(HmiLevel val) {
- switch (val) {
- case HL_BACKGROUND:
- return "BACKGROUND";
- case HL_FULL:
- return "FULL";
- case HL_LIMITED:
- return "LIMITED";
- case HL_NONE:
- return "NONE";
- default:
- return "";
- }
-}
-bool EnumFromJsonString(const std::string& literal, HmiLevel* result) {
- if ("BACKGROUND" == literal) {
- *result = HL_BACKGROUND;
- return true;
- } else if ("FULL" == literal) {
- *result = HL_FULL;
- return true;
- } else if ("LIMITED" == literal) {
- *result = HL_LIMITED;
- return true;
- } else if ("NONE" == literal) {
- *result = HL_NONE;
- return true;
- } else {
- return false;
- }
-}
-
-bool IsValidEnum(Parameter val) {
- switch (val) {
- case P_GPS:
- return true;
- case P_SPEED:
- return true;
- case P_ENGINETORQUE:
- return true;
- case P_EXTERNALTEMPERATURE:
- return true;
- case P_TURNSIGNAL:
- return true;
- case P_FUELLEVEL:
- return true;
- case P_FUELLEVEL_STATE:
- return true;
- case P_HEADLAMPSTATUS:
- return true;
- case P_INSTANTFUELCONSUMPTION:
- return true;
- case P_FUELRANGE:
- return true;
- case P_CLOUD_APP_VEHICLE_ID:
- return true;
- case P_ODOMETER:
- return true;
- case P_TIREPRESSURE:
- return true;
- case P_WIPERSTATUS:
- return true;
- case P_VIN:
- return true;
- case P_ACCPEDALPOSITION:
- return true;
- case P_BELTSTATUS:
- return true;
- case P_ELECTRONICPARKBRAKESTATUS:
- return true;
- case P_DRIVERBRAKING:
- return true;
- case P_PRNDL:
- return true;
- case P_RPM:
- return true;
- case P_STEERINGWHEELANGLE:
- return true;
- case P_ENGINEOILLIFE:
- return true;
- case P_MYKEY:
- return true;
- case P_AIRBAGSTATUS:
- return true;
- case P_BODYINFORMATION:
- return true;
- case P_CLUSTERMODESTATUS:
- return true;
- case P_DEVICESTATUS:
- return true;
- case P_EMERGENCYEVENT:
- return true;
- case P_ECALLINFO:
- return true;
- case P_EMPTY:
- return true;
- default:
- return false;
- }
-}
-const char* EnumToJsonString(Parameter val) {
- switch (val) {
- case P_GPS:
- return "gps";
- case P_SPEED:
- return "speed";
- case P_ENGINETORQUE:
- return "engineTorque";
- case P_EXTERNALTEMPERATURE:
- return "externalTemperature";
- case P_TURNSIGNAL:
- return "turnSignal";
- case P_FUELLEVEL:
- return "fuelLevel";
- case P_FUELLEVEL_STATE:
- return "fuelLevel_State";
- case P_HEADLAMPSTATUS:
- return "headLampStatus";
- case P_INSTANTFUELCONSUMPTION:
- return "instantFuelConsumption";
- case P_FUELRANGE:
- return "fuelRange";
- case P_CLOUD_APP_VEHICLE_ID:
- return "cloudAppVehicleID";
- case P_ODOMETER:
- return "odometer";
- case P_TIREPRESSURE:
- return "tirePressure";
- case P_WIPERSTATUS:
- return "wiperStatus";
- case P_VIN:
- return "vin";
- case P_ACCPEDALPOSITION:
- return "accPedalPosition";
- case P_BELTSTATUS:
- return "beltStatus";
- case P_ELECTRONICPARKBRAKESTATUS:
- return "electronicParkBrakeStatus";
- case P_DRIVERBRAKING:
- return "driverBraking";
- case P_PRNDL:
- return "prndl";
- case P_RPM:
- return "rpm";
- case P_STEERINGWHEELANGLE:
- return "steeringWheelAngle";
- case P_ENGINEOILLIFE:
- return "engineOilLife";
- case P_MYKEY:
- return "myKey";
- case P_AIRBAGSTATUS:
- return "airbagStatus";
- case P_BODYINFORMATION:
- return "bodyInformation";
- case P_CLUSTERMODESTATUS:
- return "clusterModeStatus";
- case P_DEVICESTATUS:
- return "deviceStatus";
- case P_EMERGENCYEVENT:
- return "emergencyEvent";
- case P_ECALLINFO:
- return "eCallInfo";
- case P_EMPTY:
- return "EMPTY";
- default:
- return "";
- }
-}
-
-bool EnumFromJsonString(const std::string& literal, Parameter* result) {
- if ("gps" == literal) {
- *result = P_GPS;
- return true;
- } else if ("speed" == literal) {
- *result = P_SPEED;
- return true;
- } else if ("engineTorque" == literal) {
- *result = P_ENGINETORQUE;
- return true;
- } else if ("externalTemperature" == literal) {
- *result = P_EXTERNALTEMPERATURE;
- return true;
- } else if ("turnSignal" == literal) {
- *result = P_TURNSIGNAL;
- return true;
- } else if ("fuelLevel" == literal) {
- *result = P_FUELLEVEL;
- return true;
- } else if ("fuelLevel_State" == literal) {
- *result = P_FUELLEVEL_STATE;
- return true;
- } else if ("headLampStatus" == literal) {
- *result = P_HEADLAMPSTATUS;
- return true;
- } else if ("instantFuelConsumption" == literal) {
- *result = P_INSTANTFUELCONSUMPTION;
- return true;
- } else if ("fuelRange" == literal) {
- *result = P_FUELRANGE;
- return true;
- } else if ("cloudAppVehicleID" == literal) {
- *result = P_CLOUD_APP_VEHICLE_ID;
- return true;
- } else if ("odometer" == literal) {
- *result = P_ODOMETER;
- return true;
- } else if ("tirePressure" == literal) {
- *result = P_TIREPRESSURE;
- return true;
- } else if ("wiperStatus" == literal) {
- *result = P_WIPERSTATUS;
- return true;
- } else if ("vin" == literal) {
- *result = P_VIN;
- return true;
- } else if ("accPedalPosition" == literal) {
- *result = P_ACCPEDALPOSITION;
- return true;
- } else if ("beltStatus" == literal) {
- *result = P_BELTSTATUS;
- return true;
- } else if ("electronicParkBrakeStatus" == literal) {
- *result = P_ELECTRONICPARKBRAKESTATUS;
- return true;
- } else if ("driverBraking" == literal) {
- *result = P_DRIVERBRAKING;
- return true;
- } else if ("prndl" == literal) {
- *result = P_PRNDL;
- return true;
- } else if ("rpm" == literal) {
- *result = P_RPM;
- return true;
- } else if ("steeringWheelAngle" == literal) {
- *result = P_STEERINGWHEELANGLE;
- return true;
- } else if ("engineOilLife" == literal) {
- *result = P_ENGINEOILLIFE;
- return true;
- } else if ("myKey" == literal) {
- *result = P_MYKEY;
- return true;
- } else if ("airbagStatus" == literal) {
- *result = P_AIRBAGSTATUS;
- return true;
- } else if ("bodyInformation" == literal) {
- *result = P_BODYINFORMATION;
- return true;
- } else if ("clusterModeStatus" == literal) {
- *result = P_CLUSTERMODESTATUS;
- return true;
- } else if ("deviceStatus" == literal) {
- *result = P_DEVICESTATUS;
- return true;
- } else if ("emergencyEvent" == literal) {
- *result = P_EMERGENCYEVENT;
- return true;
- } else if ("eCallInfo" == literal) {
- *result = P_ECALLINFO;
- return true;
- } else if ("EMPTY" == literal) {
- *result = P_EMPTY;
- return true;
- } else {
- return false;
- }
-}
-
-bool IsValidEnum(AppHMIType val) {
- switch (val) {
- case AHT_DEFAULT:
- return true;
- case AHT_COMMUNICATION:
- return true;
- case AHT_MEDIA:
- return true;
- case AHT_MESSAGING:
- return true;
- case AHT_NAVIGATION:
- return true;
- case AHT_INFORMATION:
- return true;
- case AHT_SOCIAL:
- return true;
- case AHT_BACKGROUND_PROCESS:
- return true;
- case AHT_TESTING:
- return true;
- case AHT_SYSTEM:
- return true;
- case AHT_PROJECTION:
- return true;
- case AHT_REMOTE_CONTROL:
- return true;
- default:
- return false;
- }
-}
-const char* EnumToJsonString(AppHMIType val) {
- switch (val) {
- case AHT_DEFAULT:
- return "DEFAULT";
- case AHT_COMMUNICATION:
- return "COMMUNICATION";
- case AHT_MEDIA:
- return "MEDIA";
- case AHT_MESSAGING:
- return "MESSAGING";
- case AHT_NAVIGATION:
- return "NAVIGATION";
- case AHT_INFORMATION:
- return "INFORMATION";
- case AHT_SOCIAL:
- return "SOCIAL";
- case AHT_BACKGROUND_PROCESS:
- return "BACKGROUND_PROCESS";
- case AHT_TESTING:
- return "TESTING";
- case AHT_SYSTEM:
- return "SYSTEM";
- case AHT_PROJECTION:
- return "PROJECTION";
- case AHT_REMOTE_CONTROL:
- return "REMOTE_CONTROL";
- default:
- return "";
- }
-}
-bool EnumFromJsonString(const std::string& literal, AppHMIType* result) {
- if ("DEFAULT" == literal) {
- *result = AHT_DEFAULT;
- return true;
- } else if ("COMMUNICATION" == literal) {
- *result = AHT_COMMUNICATION;
- return true;
- } else if ("MEDIA" == literal) {
- *result = AHT_MEDIA;
- return true;
- } else if ("MESSAGING" == literal) {
- *result = AHT_MESSAGING;
- return true;
- } else if ("NAVIGATION" == literal) {
- *result = AHT_NAVIGATION;
- return true;
- } else if ("INFORMATION" == literal) {
- *result = AHT_INFORMATION;
- return true;
- } else if ("SOCIAL" == literal) {
- *result = AHT_SOCIAL;
- return true;
- } else if ("BACKGROUND_PROCESS" == literal) {
- *result = AHT_BACKGROUND_PROCESS;
- return true;
- } else if ("TESTING" == literal) {
- *result = AHT_TESTING;
- return true;
- } else if ("SYSTEM" == literal) {
- *result = AHT_SYSTEM;
- return true;
- } else if ("PROJECTION" == literal) {
- *result = AHT_PROJECTION;
- return true;
- } else if ("REMOTE_CONTROL" == literal) {
- *result = AHT_REMOTE_CONTROL;
- return true;
- } else {
- return false;
- }
-}
-
-bool IsValidEnum(RequestType val) {
- switch (val) {
- case RT_HTTP:
- return true;
- case RT_FILE_RESUME:
- return true;
- case RT_AUTH_REQUEST:
- return true;
- case RT_AUTH_CHALLENGE:
- return true;
- case RT_AUTH_ACK:
- return true;
- case RT_PROPRIETARY:
- return true;
- case RT_QUERY_APPS:
- return true;
- case RT_LAUNCH_APP:
- return true;
- case RT_LOCK_SCREEN_ICON_URL:
- return true;
- case RT_TRAFFIC_MESSAGE_CHANNEL:
- return true;
- case RT_DRIVER_PROFILE:
- return true;
- case RT_VOICE_SEARCH:
- return true;
- case RT_NAVIGATION:
- return true;
- case RT_PHONE:
- return true;
- case RT_CLIMATE:
- return true;
- case RT_SETTINGS:
- return true;
- case RT_VEHICLE_DIAGNOSTICS:
- return true;
- case RT_EMERGENCY:
- return true;
- case RT_MEDIA:
- return true;
- case RT_FOTA:
- return true;
- case RT_OEM_SPECIFIC:
- return true;
- case RT_EMPTY:
- return true;
- default:
- return false;
- }
-}
-
-const char* EnumToJsonString(RequestType val) {
- switch (val) {
- case RT_HTTP:
- return "HTTP";
- case RT_FILE_RESUME:
- return "FILE_RESUME";
- case RT_AUTH_REQUEST:
- return "AUTH_REQUEST";
- case RT_AUTH_CHALLENGE:
- return "AUTH_CHALLENGE";
- case RT_AUTH_ACK:
- return "AUTH_ACK";
- case RT_PROPRIETARY:
- return "PROPRIETARY";
- case RT_QUERY_APPS:
- return "QUERY_APPS";
- case RT_LAUNCH_APP:
- return "LAUNCH_APP";
- case RT_LOCK_SCREEN_ICON_URL:
- return "LOCK_SCREEN_ICON_URL";
- case RT_TRAFFIC_MESSAGE_CHANNEL:
- return "TRAFFIC_MESSAGE_CHANNEL";
- case RT_DRIVER_PROFILE:
- return "DRIVER_PROFILE";
- case RT_VOICE_SEARCH:
- return "VOICE_SEARCH";
- case RT_NAVIGATION:
- return "NAVIGATION";
- case RT_PHONE:
- return "PHONE";
- case RT_CLIMATE:
- return "CLIMATE";
- case RT_SETTINGS:
- return "SETTINGS";
- case RT_VEHICLE_DIAGNOSTICS:
- return "VEHICLE_DIAGNOSTICS";
- case RT_EMERGENCY:
- return "EMERGENCY";
- case RT_MEDIA:
- return "MEDIA";
- case RT_FOTA:
- return "FOTA";
- case RT_OEM_SPECIFIC:
- return "OEM_SPECIFIC";
- case RT_EMPTY:
- return "EMPTY";
- default:
- return "";
- }
-}
-
-bool EnumFromJsonString(const std::string& literal, RequestType* result) {
- if ("HTTP" == literal) {
- *result = RT_HTTP;
- return true;
- }
- if ("FILE_RESUME" == literal) {
- *result = RT_FILE_RESUME;
- return true;
- }
- if ("AUTH_REQUEST" == literal) {
- *result = RT_AUTH_REQUEST;
- return true;
- }
- if ("AUTH_CHALLENGE" == literal) {
- *result = RT_AUTH_CHALLENGE;
- return true;
- }
- if ("AUTH_ACK" == literal) {
- *result = RT_AUTH_ACK;
- return true;
- }
- if ("PROPRIETARY" == literal) {
- *result = RT_PROPRIETARY;
- return true;
- }
- if ("QUERY_APPS" == literal) {
- *result = RT_QUERY_APPS;
- return true;
- }
- if ("LAUNCH_APP" == literal) {
- *result = RT_LAUNCH_APP;
- return true;
- }
- if ("LOCK_SCREEN_ICON_URL" == literal) {
- *result = RT_LOCK_SCREEN_ICON_URL;
- return true;
- }
- if ("TRAFFIC_MESSAGE_CHANNEL" == literal) {
- *result = RT_TRAFFIC_MESSAGE_CHANNEL;
- return true;
- }
- if ("DRIVER_PROFILE" == literal) {
- *result = RT_DRIVER_PROFILE;
- return true;
- }
- if ("VOICE_SEARCH" == literal) {
- *result = RT_VOICE_SEARCH;
- return true;
- }
- if ("NAVIGATION" == literal) {
- *result = RT_NAVIGATION;
- return true;
- }
- if ("PHONE" == literal) {
- *result = RT_PHONE;
- return true;
- }
- if ("CLIMATE" == literal) {
- *result = RT_CLIMATE;
- return true;
- }
- if ("SETTINGS" == literal) {
- *result = RT_SETTINGS;
- return true;
- }
- if ("VEHICLE_DIAGNOSTICS" == literal) {
- *result = RT_VEHICLE_DIAGNOSTICS;
- return true;
- }
- if ("EMERGENCY" == literal) {
- *result = RT_EMERGENCY;
- return true;
- }
- if ("MEDIA" == literal) {
- *result = RT_MEDIA;
- return true;
- }
- if ("FOTA" == literal) {
- *result = RT_FOTA;
- return true;
- }
- if ("OEM_SPECIFIC" == literal) {
- *result = RT_OEM_SPECIFIC;
- return true;
- }
- if ("EMPTY" == literal) {
- *result = RT_EMPTY;
- return true;
- } else {
- return false;
- }
-}
-
-bool IsValidEnum(ModuleType val) {
- switch (val) {
- case MT_CLIMATE:
- return true;
- case MT_RADIO:
- return true;
- case MT_SEAT:
- return true;
- case MT_AUDIO:
- return true;
- case MT_LIGHT:
- return true;
- case MT_HMI_SETTINGS:
- return true;
- case MT_EMPTY:
- return true;
- default:
- return false;
- }
-}
-
-const char* EnumToJsonString(ModuleType val) {
- switch (val) {
- case MT_CLIMATE:
- return "CLIMATE";
- case MT_RADIO:
- return "RADIO";
- case MT_SEAT:
- return "SEAT";
- case MT_AUDIO:
- return "AUDIO";
- case MT_LIGHT:
- return "LIGHT";
- case MT_HMI_SETTINGS:
- return "HMI_SETTINGS";
- case MT_EMPTY:
- return "EMPTY";
- default:
- return "";
- }
-}
-
-bool EnumFromJsonString(const std::string& literal, ModuleType* result) {
- if ("CLIMATE" == literal) {
- *result = MT_CLIMATE;
- return true;
- } else if ("RADIO" == literal) {
- *result = MT_RADIO;
- return true;
- } else if ("SEAT" == literal) {
- *result = MT_SEAT;
- return true;
- } else if ("AUDIO" == literal) {
- *result = MT_AUDIO;
- return true;
- } else if ("LIGHT" == literal) {
- *result = MT_LIGHT;
- return true;
- } else if ("HMI_SETTINGS" == literal) {
- *result = MT_HMI_SETTINGS;
- return true;
- } else if ("EMPTY" == literal) {
- *result = MT_EMPTY;
- return true;
- }
- return false;
-}
-
-bool IsValidEnum(HybridAppPreference val) {
- return strlen(EnumToJsonString(val)) > 0;
-}
-
-const char* EnumToJsonString(HybridAppPreference val) {
- switch (val) {
- case HAP_MOBILE:
- return "MOBILE";
- case HAP_CLOUD:
- return "CLOUD";
- case HAP_BOTH:
- return "BOTH";
- default:
- return "";
- }
-}
-
-bool EnumFromJsonString(const std::string& literal,
- HybridAppPreference* result) {
- if ("MOBILE" == literal) {
- *result = HAP_MOBILE;
- return true;
- } else if ("CLOUD" == literal) {
- *result = HAP_CLOUD;
- return true;
- } else if ("BOTH" == literal) {
- *result = HAP_BOTH;
- return true;
- }
- return false;
-}
-
-bool IsValidEnum(FunctionID val) {
- switch (val) {
- case RegisterAppInterfaceID:
- return true;
- case UnregisterAppInterfaceID:
- return true;
- case SetGlobalPropertiesID:
- return true;
- case ResetGlobalPropertiesID:
- return true;
- case AddCommandID:
- return true;
- case DeleteCommandID:
- return true;
- case AddSubMenuID:
- return true;
- case DeleteSubMenuID:
- return true;
- case CreateInteractionChoiceSetID:
- return true;
- case PerformInteractionID:
- return true;
- case DeleteInteractionChoiceSetID:
- return true;
- case AlertID:
- return true;
- case ShowID:
- return true;
- case SpeakID:
- return true;
- case SetMediaClockTimerID:
- return true;
- case PerformAudioPassThruID:
- return true;
- case EndAudioPassThruID:
- return true;
- case SubscribeButtonID:
- return true;
- case UnsubscribeButtonID:
- return true;
- case SubscribeVehicleDataID:
- return true;
- case UnsubscribeVehicleDataID:
- return true;
- case GetVehicleDataID:
- return true;
- case ReadDIDID:
- return true;
- case GetDTCsID:
- return true;
- case ScrollableMessageID:
- return true;
- case SliderID:
- return true;
- case ShowConstantTBTID:
- return true;
- case AlertManeuverID:
- return true;
- case UpdateTurnListID:
- return true;
- case ChangeRegistrationID:
- return true;
- case GenericResponseID:
- return true;
- case PutFileID:
- return true;
- case DeleteFileID:
- return true;
- case ListFilesID:
- return true;
- case SetAppIconID:
- return true;
- case SetDisplayLayoutID:
- return true;
- case DiagnosticMessageID:
- return true;
- case SystemRequestID:
- return true;
- case SendLocationID:
- return true;
- case DialNumberID:
- return true;
- case ButtonPressID:
- return true;
- case GetInteriorVehicleDataID:
- return true;
- case SetInteriorVehicleDataID:
- return true;
- case GetWayPointsID:
- return true;
- case SubscribeWayPointsID:
- return true;
- case UnsubscribeWayPointsID:
- return true;
- case GetSystemCapabilityID:
- return true;
- case SendHapticDataID:
- return true;
- case SetCloudAppPropertiesID:
- return true;
- case GetCloudAppPropertiesID:
- return true;
- case PublishAppServiceID:
- return true;
- case GetFileID:
- return true;
- case GetAppServiceDataID:
- return true;
- case PerformAppServiceInteractionID:
- return true;
- case UnpublishAppServiceID:
- return true;
- case CancelInteractionID:
- return true;
- case CreateWindowID:
- return true;
- case DeleteWindowID:
- return true;
- case CloseApplicationID:
- return true;
- case ShowAppMenuID:
- return true;
- case OnHMIStatusID:
- return true;
- case OnAppInterfaceUnregisteredID:
- return true;
- case OnButtonEventID:
- return true;
- case OnButtonPressID:
- return true;
- case OnVehicleDataID:
- return true;
- case OnCommandID:
- return true;
- case OnTBTClientStateID:
- return true;
- case OnDriverDistractionID:
- return true;
- case OnPermissionsChangeID:
- return true;
- case OnAudioPassThruID:
- return true;
- case OnLanguageChangeID:
- return true;
- case OnKeyboardInputID:
- return true;
- case OnTouchEventID:
- return true;
- case OnSystemRequestID:
- return true;
- case OnHashChangeID:
- return true;
- case OnInteriorVehicleDataID:
- return true;
- case OnWayPointChangeID:
- return true;
- case OnRCStatusID:
- return true;
- case OnAppServiceDataID:
- return true;
- case EncodedSyncPDataID:
- return true;
- case SyncPDataID:
- return true;
- case OnEncodedSyncPDataID:
- return true;
- case OnSyncPDataID:
- return true;
- case OnSystemCapabilityUpdatedID:
- return true;
- default:
- return false;
- }
-};
-
-const char* EnumToJsonString(FunctionID val) {
- switch (val) {
- case RegisterAppInterfaceID:
- return "RegisterAppInterface";
- case UnregisterAppInterfaceID:
- return "UnregisterAppInterface";
- case SetGlobalPropertiesID:
- return "SetGlobalProperties";
- case ResetGlobalPropertiesID:
- return "ResetGlobalProperties";
- case AddCommandID:
- return "AddCommand";
- case DeleteCommandID:
- return "DeleteCommand";
- case AddSubMenuID:
- return "AddSubMenu";
- case DeleteSubMenuID:
- return "DeleteSubMenu";
- case CreateInteractionChoiceSetID:
- return "CreateInteractionChoiceSet";
- case PerformInteractionID:
- return "PerformInteraction";
- case DeleteInteractionChoiceSetID:
- return "DeleteInteractionChoiceSet";
- case AlertID:
- return "Alert";
- case ShowID:
- return "Show";
- case SpeakID:
- return "Speak";
- case SetMediaClockTimerID:
- return "SetMediaClockTimer";
- case PerformAudioPassThruID:
- return "PerformAudioPassThru";
- case EndAudioPassThruID:
- return "EndAudioPassThru";
- case SubscribeButtonID:
- return "SubscribeButton";
- case UnsubscribeButtonID:
- return "UnsubscribeButton";
- case SubscribeVehicleDataID:
- return "SubscribeVehicleData";
- case UnsubscribeVehicleDataID:
- return "UnsubscribeVehicleData";
- case GetVehicleDataID:
- return "GetVehicleData";
- case ReadDIDID:
- return "ReadDID";
- case GetDTCsID:
- return "GetDTCs";
- case ScrollableMessageID:
- return "ScrollableMessage";
- case SliderID:
- return "Slider";
- case ShowConstantTBTID:
- return "ShowConstantTBT";
- case AlertManeuverID:
- return "AlertManeuver";
- case UpdateTurnListID:
- return "UpdateTurnList";
- case ChangeRegistrationID:
- return "ChangeRegistration";
- case GenericResponseID:
- return "GenericResponse";
- case PutFileID:
- return "PutFile";
- case DeleteFileID:
- return "DeleteFile";
- case ListFilesID:
- return "ListFiles";
- case SetAppIconID:
- return "SetAppIcon";
- case SetDisplayLayoutID:
- return "SetDisplayLayout";
- case DiagnosticMessageID:
- return "DiagnosticMessage";
- case SystemRequestID:
- return "SystemRequest";
- case SendLocationID:
- return "SendLocation";
- case DialNumberID:
- return "DialNumber";
- case ButtonPressID:
- return "ButtonPress";
- case GetInteriorVehicleDataID:
- return "GetInteriorVehicleData";
- case SetInteriorVehicleDataID:
- return "SetInteriorVehicleData";
- case GetWayPointsID:
- return "GetWayPoints";
- case SubscribeWayPointsID:
- return "SubscribeWayPoints";
- case UnsubscribeWayPointsID:
- return "UnsubscribeWayPoints";
- case GetSystemCapabilityID:
- return "GetSystemCapability";
- case SendHapticDataID:
- return "SendHapticData";
- case SetCloudAppPropertiesID:
- return "SetCloudAppProperties";
- case GetCloudAppPropertiesID:
- return "GetCloudAppProperties";
- case PublishAppServiceID:
- return "PublishAppService";
- case GetFileID:
- return "GetFile";
- case GetAppServiceDataID:
- return "GetAppServiceData";
- case PerformAppServiceInteractionID:
- return "PerformAppServiceInteraction";
- case UnpublishAppServiceID:
- return "UnpublishAppService";
- case CancelInteractionID:
- return "CancelInteraction";
- case CreateWindowID:
- return "CreateWindow";
- case DeleteWindowID:
- return "DeleteWindow";
- case CloseApplicationID:
- return "CloseApplication";
- case ShowAppMenuID:
- return "ShowAppMenu";
- case OnHMIStatusID:
- return "OnHMIStatus";
- case OnAppInterfaceUnregisteredID:
- return "OnAppInterfaceUnregistered";
- case OnButtonEventID:
- return "OnButtonEvent";
- case OnButtonPressID:
- return "OnButtonPress";
- case OnVehicleDataID:
- return "OnVehicleData";
- case OnCommandID:
- return "OnCommand";
- case OnTBTClientStateID:
- return "OnTBTClientState";
- case OnDriverDistractionID:
- return "OnDriverDistraction";
- case OnPermissionsChangeID:
- return "OnPermissionsChange";
- case OnAudioPassThruID:
- return "OnAudioPassThru";
- case OnLanguageChangeID:
- return "OnLanguageChange";
- case OnKeyboardInputID:
- return "OnKeyboardInput";
- case OnTouchEventID:
- return "OnTouchEvent";
- case OnSystemRequestID:
- return "OnSystemRequest";
- case OnHashChangeID:
- return "OnHashChange";
- case OnInteriorVehicleDataID:
- return "OnInteriorVehicleData";
- case OnWayPointChangeID:
- return "OnWayPointChange";
- case OnRCStatusID:
- return "OnRCStatus";
- case OnAppServiceDataID:
- return "OnAppServiceData";
- case EncodedSyncPDataID:
- return "EncodedSyncPData";
- case SyncPDataID:
- return "SyncPData";
- case OnEncodedSyncPDataID:
- return "OnEncodedSyncPData";
- case OnSyncPDataID:
- return "OnSyncPData";
- case OnSystemCapabilityUpdatedID:
- return "OnSystemCapabilityUpdated";
- default:
- return "";
- }
-};
-
-bool EnumFromJsonString(const std::string& literal, FunctionID* result) {
- if ("RegisterAppInterface" == literal) {
- *result = RegisterAppInterfaceID;
- return true;
- }
-
- if ("UnregisterAppInterface" == literal) {
- *result = UnregisterAppInterfaceID;
- return true;
- }
-
- if ("SetGlobalProperties" == literal) {
- *result = SetGlobalPropertiesID;
- return true;
- }
-
- if ("ResetGlobalProperties" == literal) {
- *result = ResetGlobalPropertiesID;
- return true;
- }
-
- if ("AddCommand" == literal) {
- *result = AddCommandID;
- return true;
- }
-
- if ("DeleteCommand" == literal) {
- *result = DeleteCommandID;
- return true;
- }
-
- if ("AddSubMenu" == literal) {
- *result = AddSubMenuID;
- return true;
- }
-
- if ("DeleteSubMenu" == literal) {
- *result = DeleteSubMenuID;
- return true;
- }
-
- if ("CreateInteractionChoiceSet" == literal) {
- *result = CreateInteractionChoiceSetID;
- return true;
- }
-
- if ("PerformInteraction" == literal) {
- *result = PerformInteractionID;
- return true;
- }
-
- if ("DeleteInteractionChoiceSet" == literal) {
- *result = DeleteInteractionChoiceSetID;
- return true;
- }
-
- if ("Alert" == literal) {
- *result = AlertID;
- return true;
- }
-
- if ("Show" == literal) {
- *result = ShowID;
- return true;
- }
-
- if ("Speak" == literal) {
- *result = SpeakID;
- return true;
- }
-
- if ("SetMediaClockTimer" == literal) {
- *result = SetMediaClockTimerID;
- return true;
- }
-
- if ("PerformAudioPassThru" == literal) {
- *result = PerformAudioPassThruID;
- return true;
- }
-
- if ("EndAudioPassThru" == literal) {
- *result = EndAudioPassThruID;
- return true;
- }
-
- if ("SubscribeButton" == literal) {
- *result = SubscribeButtonID;
- return true;
- }
-
- if ("UnsubscribeButton" == literal) {
- *result = UnsubscribeButtonID;
- return true;
- }
-
- if ("SubscribeVehicleData" == literal) {
- *result = SubscribeVehicleDataID;
- return true;
- }
-
- if ("UnsubscribeVehicleData" == literal) {
- *result = UnsubscribeVehicleDataID;
- return true;
- }
-
- if ("GetVehicleData" == literal) {
- *result = GetVehicleDataID;
- return true;
- }
-
- if ("ReadDID" == literal) {
- *result = ReadDIDID;
- return true;
- }
-
- if ("GetDTCs" == literal) {
- *result = GetDTCsID;
- return true;
- }
-
- if ("ScrollableMessage" == literal) {
- *result = ScrollableMessageID;
- return true;
- }
-
- if ("Slider" == literal) {
- *result = SliderID;
- return true;
- }
-
- if ("ShowConstantTBT" == literal) {
- *result = ShowConstantTBTID;
- return true;
- }
-
- if ("AlertManeuver" == literal) {
- *result = AlertManeuverID;
- return true;
- }
-
- if ("UpdateTurnList" == literal) {
- *result = UpdateTurnListID;
- return true;
- }
-
- if ("ChangeRegistration" == literal) {
- *result = ChangeRegistrationID;
- return true;
- }
-
- if ("GenericResponse" == literal) {
- *result = GenericResponseID;
- return true;
- }
-
- if ("PutFile" == literal) {
- *result = PutFileID;
- return true;
- }
-
- if ("DeleteFile" == literal) {
- *result = DeleteFileID;
- return true;
- }
-
- if ("ListFiles" == literal) {
- *result = ListFilesID;
- return true;
- }
-
- if ("SetAppIcon" == literal) {
- *result = SetAppIconID;
- return true;
- }
-
- if ("SetDisplayLayout" == literal) {
- *result = SetDisplayLayoutID;
- return true;
- }
-
- if ("DiagnosticMessage" == literal) {
- *result = DiagnosticMessageID;
- return true;
- }
-
- if ("SystemRequest" == literal) {
- *result = SystemRequestID;
- return true;
- }
-
- if ("SendLocation" == literal) {
- *result = SendLocationID;
- return true;
- }
-
- if ("DialNumber" == literal) {
- *result = DialNumberID;
- return true;
- }
-
- if ("ButtonPress" == literal) {
- *result = ButtonPressID;
- return true;
- }
-
- if ("GetInteriorVehicleData" == literal) {
- *result = GetInteriorVehicleDataID;
- return true;
- }
-
- if ("SetInteriorVehicleData" == literal) {
- *result = SetInteriorVehicleDataID;
- return true;
- }
-
- if ("GetWayPoints" == literal) {
- *result = GetWayPointsID;
- return true;
- }
-
- if ("SubscribeWayPoints" == literal) {
- *result = SubscribeWayPointsID;
- return true;
- }
-
- if ("UnsubscribeWayPoints" == literal) {
- *result = UnsubscribeWayPointsID;
- return true;
- }
-
- if ("GetSystemCapability" == literal) {
- *result = GetSystemCapabilityID;
- return true;
- }
-
- if ("SendHapticData" == literal) {
- *result = SendHapticDataID;
- return true;
- }
-
- if ("SetCloudAppProperties" == literal) {
- *result = SetCloudAppPropertiesID;
- return true;
- }
-
- if ("GetCloudAppProperties" == literal) {
- *result = GetCloudAppPropertiesID;
- return true;
- }
-
- if ("PublishAppService" == literal) {
- *result = PublishAppServiceID;
- return true;
- }
-
- if ("GetFile" == literal) {
- *result = GetFileID;
- return true;
- }
-
- if ("GetAppServiceData" == literal) {
- *result = GetAppServiceDataID;
- return true;
- }
-
- if ("PerformAppServiceInteraction" == literal) {
- *result = PerformAppServiceInteractionID;
- return true;
- }
-
- if ("UnpublishAppService" == literal) {
- *result = UnpublishAppServiceID;
- return true;
- }
-
- if ("CancelInteraction" == literal) {
- *result = CancelInteractionID;
- return true;
- }
-
- if ("CreateWindow" == literal) {
- *result = CreateWindowID;
- return true;
- }
-
- if ("DeleteWindow" == literal) {
- *result = DeleteWindowID;
- return true;
- }
-
- if ("CloseApplication" == literal) {
- *result = CloseApplicationID;
- return true;
- }
-
- if ("ShowAppMenu" == literal) {
- *result = ShowAppMenuID;
- return true;
- }
-
- if ("OnHMIStatus" == literal) {
- *result = OnHMIStatusID;
- return true;
- }
-
- if ("OnAppInterfaceUnregistered" == literal) {
- *result = OnAppInterfaceUnregisteredID;
- return true;
- }
-
- if ("OnButtonEvent" == literal) {
- *result = OnButtonEventID;
- return true;
- }
-
- if ("OnButtonPress" == literal) {
- *result = OnButtonPressID;
- return true;
- }
-
- if ("OnVehicleData" == literal) {
- *result = OnVehicleDataID;
- return true;
- }
-
- if ("OnCommand" == literal) {
- *result = OnCommandID;
- return true;
- }
-
- if ("OnTBTClientState" == literal) {
- *result = OnTBTClientStateID;
- return true;
- }
-
- if ("OnDriverDistraction" == literal) {
- *result = OnDriverDistractionID;
- return true;
- }
-
- if ("OnPermissionsChange" == literal) {
- *result = OnPermissionsChangeID;
- return true;
- }
-
- if ("OnAudioPassThru" == literal) {
- *result = OnAudioPassThruID;
- return true;
- }
-
- if ("OnLanguageChange" == literal) {
- *result = OnLanguageChangeID;
- return true;
- }
-
- if ("OnKeyboardInput" == literal) {
- *result = OnKeyboardInputID;
- return true;
- }
-
- if ("OnTouchEvent" == literal) {
- *result = OnTouchEventID;
- return true;
- }
-
- if ("OnSystemRequest" == literal) {
- *result = OnSystemRequestID;
- return true;
- }
-
- if ("OnHashChange" == literal) {
- *result = OnHashChangeID;
- return true;
- }
-
- if ("OnInteriorVehicleData" == literal) {
- *result = OnInteriorVehicleDataID;
- return true;
- }
-
- if ("OnWayPointChange" == literal) {
- *result = OnWayPointChangeID;
- return true;
- }
-
- if ("OnRCStatus" == literal) {
- *result = OnRCStatusID;
- return true;
- }
-
- if ("OnAppServiceData" == literal) {
- *result = OnAppServiceDataID;
- return true;
- }
-
- if ("OnSystemCapabilityUpdated" == literal) {
- *result = OnSystemCapabilityUpdatedID;
- return true;
- }
-
- if ("EncodedSyncPData" == literal) {
- *result = EncodedSyncPDataID;
- return true;
- }
-
- if ("SyncPData" == literal) {
- *result = SyncPDataID;
- return true;
- }
-
- if ("OnEncodedSyncPData" == literal) {
- *result = OnEncodedSyncPDataID;
- return true;
- }
-
- if ("OnSyncPData" == literal) {
- *result = OnSyncPDataID;
- return true;
- }
- return false;
-};
const std::string kDefaultApp = "default";
const std::string kPreDataConsentApp = "pre_DataConsent";
diff --git a/src/components/policy/policy_regular/src/policy_table/types.cc b/src/components/policy/policy_regular/src/policy_table/types.cc
index 704cbacf4c..4032f27f99 100644
--- a/src/components/policy/policy_regular/src/policy_table/types.cc
+++ b/src/components/policy/policy_regular/src/policy_table/types.cc
@@ -658,9 +658,60 @@ void Rpcs::SetPolicyTableType(PolicyTableType pt_type) {
rpcs.SetPolicyTableType(pt_type);
}
+// EndpointProperties methods
+EndpointProperty::EndpointProperty() : CompositeType(kUninitialized) {}
+
+EndpointProperty::~EndpointProperty() {}
+
+EndpointProperty::EndpointProperty(const Json::Value* value__)
+ : CompositeType(InitHelper(value__, &Json::Value::isObject))
+ , version(impl::ValueMember(value__, "version")) {}
+
+Json::Value EndpointProperty::ToJsonValue() const {
+ Json::Value result__(Json::objectValue);
+ impl::WriteJsonField("version", version, &result__);
+ return result__;
+}
+
+bool EndpointProperty::is_valid() const {
+ if (!version.is_valid()) {
+ return false;
+ }
+ return Validate();
+}
+
+bool EndpointProperty::is_initialized() const {
+ return (initialization_state__ != kUninitialized) || (!struct_empty());
+}
+
+bool EndpointProperty::struct_empty() const {
+ if (version.is_initialized()) {
+ return false;
+ }
+
+ return true;
+}
+
+void EndpointProperty::ReportErrors(rpc::ValidationReport* report__) const {
+ if (struct_empty()) {
+ rpc::CompositeType::ReportErrors(report__);
+ }
+ if (!version.is_valid()) {
+ version.ReportErrors(&report__->ReportSubobject("version"));
+ }
+}
+
+void EndpointProperty::SetPolicyTableType(PolicyTableType pt_type) {
+ CompositeType::SetPolicyTableType(pt_type);
+ version.SetPolicyTableType(pt_type);
+}
+
// ModuleConfig methods
ModuleConfig::ModuleConfig() : CompositeType(kUninitialized) {}
+const std::string ModuleConfig::kDefaultOemMappingServiceName =
+ "custom_vehicle_data_mapping_url";
+
ModuleConfig::ModuleConfig(
uint8_t exchange_after_x_ignition_cycles,
int64_t exchange_after_x_kilometers,
@@ -668,6 +719,7 @@ ModuleConfig::ModuleConfig(
uint16_t timeout_after_x_seconds,
const SecondsBetweenRetries& seconds_between_retries,
const ServiceEndpoints& endpoints,
+ const ServiceEndpointProperties& endpoint_properties,
const NumberOfNotificationsPerMinute& notifications_per_minute_by_priority)
: CompositeType(kUninitialized)
, exchange_after_x_ignition_cycles(exchange_after_x_ignition_cycles)
@@ -676,6 +728,7 @@ ModuleConfig::ModuleConfig(
, timeout_after_x_seconds(timeout_after_x_seconds)
, seconds_between_retries(seconds_between_retries)
, endpoints(endpoints)
+ , endpoint_properties(endpoint_properties)
, notifications_per_minute_by_priority(
notifications_per_minute_by_priority) {}
@@ -696,6 +749,7 @@ ModuleConfig::ModuleConfig(const Json::Value* value__)
, seconds_between_retries(
impl::ValueMember(value__, "seconds_between_retries"))
, endpoints(impl::ValueMember(value__, "endpoints"))
+ , endpoint_properties(impl::ValueMember(value__, "endpoint_properties"))
, notifications_per_minute_by_priority(
impl::ValueMember(value__, "notifications_per_minute_by_priority"))
, vehicle_make(impl::ValueMember(value__, "vehicle_make"))
@@ -715,6 +769,7 @@ void ModuleConfig::SafeCopyFrom(const ModuleConfig& from) {
timeout_after_x_seconds = from.timeout_after_x_seconds;
seconds_between_retries = from.seconds_between_retries;
endpoints = from.endpoints;
+ endpoint_properties = from.endpoint_properties;
notifications_per_minute_by_priority =
from.notifications_per_minute_by_priority;
@@ -743,6 +798,7 @@ Json::Value ModuleConfig::ToJsonValue() const {
impl::WriteJsonField(
"seconds_between_retries", seconds_between_retries, &result__);
impl::WriteJsonField("endpoints", endpoints, &result__);
+ impl::WriteJsonField("endpoint_properties", endpoint_properties, &result__);
impl::WriteJsonField("notifications_per_minute_by_priority",
notifications_per_minute_by_priority,
&result__);
@@ -782,6 +838,9 @@ bool ModuleConfig::is_valid() const {
if (!endpoints.is_valid()) {
return false;
}
+ if (!endpoint_properties.is_valid()) {
+ return false;
+ }
if (!notifications_per_minute_by_priority.is_valid()) {
return false;
}
@@ -835,10 +894,15 @@ bool ModuleConfig::struct_empty() const {
if (seconds_between_retries.is_initialized()) {
return false;
}
+
if (endpoints.is_initialized()) {
return false;
}
+ if (endpoint_properties.is_initialized()) {
+ return false;
+ }
+
if (notifications_per_minute_by_priority.is_initialized()) {
return false;
}
@@ -896,6 +960,10 @@ void ModuleConfig::ReportErrors(rpc::ValidationReport* report__) const {
if (!endpoints.is_valid()) {
endpoints.ReportErrors(&report__->ReportSubobject("endpoints"));
}
+ if (!endpoint_properties.is_valid()) {
+ endpoint_properties.ReportErrors(
+ &report__->ReportSubobject("endpoint_properties"));
+ }
if (!notifications_per_minute_by_priority.is_valid()) {
notifications_per_minute_by_priority.ReportErrors(
&report__->ReportSubobject("notifications_per_minute_by_priority"));
@@ -942,6 +1010,7 @@ void ModuleConfig::SetPolicyTableType(PolicyTableType pt_type) {
timeout_after_x_seconds.SetPolicyTableType(pt_type);
seconds_between_retries.SetPolicyTableType(pt_type);
endpoints.SetPolicyTableType(pt_type);
+ endpoint_properties.SetPolicyTableType(pt_type);
notifications_per_minute_by_priority.SetPolicyTableType(pt_type);
lock_screen_dismissal_enabled.SetPolicyTableType(pt_type);
vehicle_make.SetPolicyTableType(pt_type);
@@ -1563,6 +1632,419 @@ void DeviceParams::ReportErrors(rpc::ValidationReport* report__) const {
}
}
+// VehicleDataItem methods
+VehicleDataItem::VehicleDataItem() : CompositeType(kUninitialized) {}
+
+VehicleDataItem::VehicleDataItem(const VehicleDataItem& vehicle_data)
+ : CompositeType(vehicle_data.initialization_state__)
+ , name(vehicle_data.name)
+ , type(vehicle_data.type)
+ , key(vehicle_data.key)
+ , mandatory(vehicle_data.mandatory)
+ , params(vehicle_data.params)
+ , array(vehicle_data.array)
+ , since(vehicle_data.since)
+ , until(vehicle_data.until)
+ , removed(vehicle_data.removed)
+ , deprecated(vehicle_data.deprecated)
+ , minvalue(vehicle_data.minvalue)
+ , maxvalue(vehicle_data.maxvalue)
+ , minsize(vehicle_data.minsize)
+ , maxsize(vehicle_data.maxsize)
+ , minlength(vehicle_data.minlength)
+ , maxlength(vehicle_data.maxlength) {}
+
+VehicleDataItem::VehicleDataItem(const Json::Value* value__)
+ : CompositeType(InitHelper(value__, &Json::Value::isObject))
+ , name(impl::ValueMember(value__, "name"))
+ , type(impl::ValueMember(value__, "type"))
+ , key(impl::ValueMember(value__, "key"))
+ , mandatory(impl::ValueMember(value__, "mandatory"))
+ , params(impl::ValueMember(value__, "params"))
+ , array(impl::ValueMember(value__, "array"))
+ , since(impl::ValueMember(value__, "since"))
+ , until(impl::ValueMember(value__, "until"))
+ , removed(impl::ValueMember(value__, "removed"))
+ , deprecated(impl::ValueMember(value__, "deprecated"))
+ , minvalue(impl::ValueMember(value__, "minvalue"))
+ , maxvalue(impl::ValueMember(value__, "maxvalue"))
+ , minsize(impl::ValueMember(value__, "minsize"))
+ , maxsize(impl::ValueMember(value__, "maxsize"))
+ , minlength(impl::ValueMember(value__, "minlength"))
+ , maxlength(impl::ValueMember(value__, "maxlength")) {}
+
+VehicleDataItem::~VehicleDataItem() {}
+
+const std::string VehicleDataItem::kInteger = "Integer";
+const std::string VehicleDataItem::kStruct = "Struct";
+const std::string VehicleDataItem::kString = "String";
+const std::string VehicleDataItem::kFloat = "Float";
+const std::string VehicleDataItem::kDouble = "Double";
+const std::string VehicleDataItem::kBoolean = "Boolean";
+
+const std::vector<std::string> VehicleDataItem::kPODTypes = {
+ kInteger, kFloat, kDouble, kString, kBoolean};
+
+Json::Value VehicleDataItem::ToJsonValue() const {
+ Json::Value ret(Json::objectValue);
+ impl::WriteJsonField("name", name, &ret);
+ impl::WriteJsonField("type", type, &ret);
+ impl::WriteJsonField("key", key, &ret);
+ impl::WriteJsonField("array", array, &ret);
+ impl::WriteJsonField("mandatory", mandatory, &ret);
+ impl::WriteJsonField("params", params, &ret);
+ impl::WriteJsonField("since", since, &ret);
+ impl::WriteJsonField("until", until, &ret);
+ impl::WriteJsonField("removed", removed, &ret);
+ impl::WriteJsonField("deprecated", deprecated, &ret);
+ impl::WriteJsonField("minvalue", minvalue, &ret);
+ impl::WriteJsonField("maxvalue", maxvalue, &ret);
+ impl::WriteJsonField("minsize", minsize, &ret);
+ impl::WriteJsonField("maxsize", maxsize, &ret);
+ impl::WriteJsonField("minlength", minlength, &ret);
+ impl::WriteJsonField("maxlength", maxlength, &ret);
+ return ret;
+}
+
+bool VehicleDataItem::operator==(const VehicleDataItem& vd) {
+ return (name == vd.name && type == vd.type && key == vd.key &&
+ mandatory == vd.mandatory && params == vd.params &&
+ array == vd.array && since == vd.since && until == vd.until &&
+ removed == vd.removed && deprecated == vd.deprecated &&
+ minvalue == vd.minvalue && maxvalue == vd.maxvalue &&
+ minsize == vd.minsize && maxsize == vd.maxsize &&
+ minlength == vd.minlength && maxlength == vd.maxlength);
+}
+
+bool VehicleDataItem::is_valid() const {
+ if (!name.is_valid()) {
+ return false;
+ }
+ if (!type.is_valid()) {
+ return false;
+ }
+ if (!key.is_valid()) {
+ return false;
+ }
+ if (!array.is_valid()) {
+ return false;
+ }
+ if (!mandatory.is_valid()) {
+ return false;
+ }
+ if (!params.is_valid()) {
+ return false;
+ }
+ if (!since.is_valid()) {
+ return false;
+ }
+ if (!until.is_valid()) {
+ return false;
+ }
+ if (!removed.is_valid()) {
+ return false;
+ }
+ if (!deprecated.is_valid()) {
+ return false;
+ }
+ if (!minvalue.is_valid()) {
+ return false;
+ }
+ if (!maxvalue.is_valid()) {
+ return false;
+ }
+ if (!minsize.is_valid()) {
+ return false;
+ }
+ if (!maxsize.is_valid()) {
+ return false;
+ }
+ if (!minlength.is_valid()) {
+ return false;
+ }
+ if (!maxlength.is_valid()) {
+ return false;
+ }
+ return Validate();
+}
+
+bool VehicleDataItem::is_initialized() const {
+ return (initialization_state__ != kUninitialized) || (struct_not_empty());
+}
+
+bool VehicleDataItem::struct_not_empty() const {
+ if (!name.is_initialized()) {
+ return false;
+ }
+ if (!type.is_initialized()) {
+ return false;
+ }
+ if (!key.is_initialized()) {
+ return false;
+ }
+ if (!array.is_initialized()) {
+ return false;
+ }
+ if (!mandatory.is_initialized()) {
+ return false;
+ }
+ if (!params.is_initialized()) {
+ return false;
+ }
+ if (!since.is_initialized()) {
+ return false;
+ }
+ if (!until.is_initialized()) {
+ return false;
+ }
+ if (!removed.is_initialized()) {
+ return false;
+ }
+ if (!deprecated.is_initialized()) {
+ return false;
+ }
+ if (!minvalue.is_initialized()) {
+ return false;
+ }
+ if (!maxvalue.is_initialized()) {
+ return false;
+ }
+ if (!minsize.is_initialized()) {
+ return false;
+ }
+ if (!maxsize.is_initialized()) {
+ return false;
+ }
+ if (!minlength.is_initialized()) {
+ return false;
+ }
+ if (!maxlength.is_initialized()) {
+ return false;
+ }
+ return true;
+}
+
+void VehicleDataItem::ReportErrors(rpc::ValidationReport* report__) const {
+ if (!struct_not_empty()) {
+ rpc::CompositeType::ReportErrors(report__);
+ }
+ if (!name.is_valid()) {
+ name.ReportErrors(&report__->ReportSubobject("name"));
+ }
+ if (!ValidateNaming(std::string(name))) {
+ report__->set_validation_info(
+ "Invalid name values [" + std::string(name) +
+ "]. It should not contain spaces or invalid chars.");
+ }
+ if (!type.is_valid()) {
+ type.ReportErrors(&report__->ReportSubobject("type"));
+ }
+ if (type.is_initialized() && !ValidateTypes()) {
+ report__->set_validation_info("Unknown type [" + std::string(name) +
+ "]: '" + std::string(type) + "'.");
+ }
+ if (!key.is_valid()) {
+ key.ReportErrors(&report__->ReportSubobject("key"));
+ }
+ if (!ValidateNaming(std::string(key))) {
+ report__->set_validation_info(
+ "Invalid key values [" + std::string(key) +
+ "]. It should not contain spaces or invalid chars.");
+ }
+ if (!array.is_valid()) {
+ array.ReportErrors(&report__->ReportSubobject("array"));
+ }
+ if (!mandatory.is_valid()) {
+ mandatory.ReportErrors(&report__->ReportSubobject("mandatory"));
+ }
+ if (!params.is_valid()) {
+ params.ReportErrors(&report__->ReportSubobject("params"));
+ }
+ if (!since.is_valid()) {
+ since.ReportErrors(&report__->ReportSubobject("since"));
+ }
+ if (!until.is_valid()) {
+ until.ReportErrors(&report__->ReportSubobject("until"));
+ }
+ if (!removed.is_valid()) {
+ removed.ReportErrors(&report__->ReportSubobject("removed"));
+ }
+ if (!deprecated.is_valid()) {
+ deprecated.ReportErrors(&report__->ReportSubobject("deprecated"));
+ }
+ if (!minvalue.is_valid()) {
+ minvalue.ReportErrors(&report__->ReportSubobject("minvalue"));
+ }
+ if (!maxvalue.is_valid()) {
+ maxvalue.ReportErrors(&report__->ReportSubobject("maxvalue"));
+ }
+ if (!minsize.is_valid()) {
+ minsize.ReportErrors(&report__->ReportSubobject("minsize"));
+ }
+ if (!maxsize.is_valid()) {
+ maxsize.ReportErrors(&report__->ReportSubobject("maxsize"));
+ }
+ if (!minlength.is_valid()) {
+ minlength.ReportErrors(&report__->ReportSubobject("minlength"));
+ }
+ if (!maxlength.is_valid()) {
+ maxlength.ReportErrors(&report__->ReportSubobject("maxlength"));
+ }
+}
+
+void VehicleDataItem::SetPolicyTableType(PolicyTableType pt_type) {
+ CompositeType::SetPolicyTableType(pt_type);
+ name.SetPolicyTableType(pt_type);
+ type.SetPolicyTableType(pt_type);
+ key.SetPolicyTableType(pt_type);
+ array.SetPolicyTableType(pt_type);
+ mandatory.SetPolicyTableType(pt_type);
+ params.SetPolicyTableType(pt_type);
+ since.SetPolicyTableType(pt_type);
+ until.SetPolicyTableType(pt_type);
+ removed.SetPolicyTableType(pt_type);
+ deprecated.SetPolicyTableType(pt_type);
+ minvalue.SetPolicyTableType(pt_type);
+ maxvalue.SetPolicyTableType(pt_type);
+ minsize.SetPolicyTableType(pt_type);
+ maxsize.SetPolicyTableType(pt_type);
+ minlength.SetPolicyTableType(pt_type);
+ maxlength.SetPolicyTableType(pt_type);
+}
+
+bool VehicleDataItem::ValidateNaming(std::string str) const {
+ auto contains_spec_chars = [](std::string str) {
+ const auto invalid_chars = "!@#$%^&*";
+ return str.npos != str.find_first_of(invalid_chars);
+ };
+
+ auto contains_spaces = [](std::string str) {
+ const auto found_space =
+ std::find_if(str.begin(), str.end(), [](unsigned char ch) {
+ return std::isspace(ch);
+ });
+
+ return found_space != str.end();
+ };
+
+ auto empty_string = [](std::string str) {
+ str.erase(std::remove_if(str.begin(),
+ str.end(),
+ [](unsigned char ch) { return std::isspace(ch); }),
+ str.end());
+ return str.length() < 1;
+ };
+
+ return !empty_string(str) && !contains_spaces(str) &&
+ !contains_spec_chars(str);
+}
+
+bool VehicleDataItem::ValidateTypes() const {
+ if (IsPrimitiveType() || NULL != EnumSchemaItemFactory::Get(type)) {
+ // params should be empty for POD types
+ // and for enum values, generated from API
+ return (!(params.is_initialized()) || params->empty());
+ }
+
+ if ("Struct" == std::string(type)) {
+ return params.is_initialized() && !(params->empty()) && params.is_valid();
+ }
+ return false;
+}
+
+bool VehicleDataItem::IsPrimitiveType() const {
+ return helpers::in_range(kPODTypes, std::string(type));
+}
+
+// VehicleData methods
+VehicleData::VehicleData() : CompositeType(kUninitialized) {}
+
+VehicleData::VehicleData(const VehicleData& vehicle_data)
+ : CompositeType(vehicle_data.initialization_state__)
+ , schema_version(vehicle_data.schema_version)
+ , schema_items(vehicle_data.schema_items) {}
+
+VehicleData::VehicleData(const Json::Value* value__)
+ : CompositeType(InitHelper(value__, &Json::Value::isObject))
+ , schema_version(impl::ValueMember(value__, "schema_version"))
+ , schema_items(impl::ValueMember(value__, "schema_items")) {}
+
+VehicleData::~VehicleData() {}
+
+bool VehicleData::is_valid() const {
+ if (!schema_version.is_valid()) {
+ return false;
+ }
+ if (!schema_items.is_valid()) {
+ return false;
+ }
+ return Validate();
+}
+
+bool VehicleData::is_initialized() const {
+ return (initialization_state__ != kUninitialized) || (!struct_empty());
+}
+
+bool VehicleData::struct_empty() const {
+ if (schema_version.is_initialized()) {
+ return false;
+ }
+ if (schema_items.is_initialized()) {
+ return false;
+ }
+ return true;
+}
+
+Json::Value VehicleData::ToJsonValue() const {
+ Json::Value ret(Json::objectValue);
+ impl::WriteJsonField("schema_version", schema_version, &ret);
+ impl::WriteJsonField("schema_items", schema_items, &ret);
+ return ret;
+}
+
+void VehicleData::ReportErrors(rpc::ValidationReport* report__) const {
+ if (struct_empty()) {
+ rpc::CompositeType::ReportErrors(report__);
+ }
+ const auto pt_type = GetPolicyTableType();
+ const auto pt_type_str = PolicyTableTypeToString(pt_type);
+ std::string validation_info = "";
+
+ if (PT_SNAPSHOT == pt_type) {
+ if (schema_items.is_initialized()) {
+ validation_info +=
+ "; schema_items " + omitted_validation_info + pt_type_str;
+ }
+ if (!schema_version.is_initialized()) {
+ validation_info +=
+ "; schema_version " + required_validation_info + pt_type_str;
+ }
+ report__->set_validation_info(validation_info);
+ }
+
+ if (PT_UPDATE == pt_type || PT_PRELOADED == pt_type) {
+ if ((schema_version.is_initialized() && !schema_items.is_initialized()) ||
+ (!schema_version.is_initialized() && schema_items.is_initialized())) {
+ validation_info += "; schema_version and schema_items " +
+ required_validation_info + pt_type_str;
+ }
+ report__->set_validation_info(validation_info);
+ }
+
+ if (!schema_version.is_valid()) {
+ schema_version.ReportErrors(&report__->ReportSubobject("schema_version"));
+ }
+ if (!schema_items.is_valid()) {
+ schema_items.ReportErrors(&report__->ReportSubobject("schema_items"));
+ }
+}
+
+void VehicleData::SetPolicyTableType(PolicyTableType pt_type) {
+ CompositeType::SetPolicyTableType(pt_type);
+ schema_version.SetPolicyTableType(pt_type);
+ schema_items.SetPolicyTableType(pt_type);
+}
+
// PolicyTable methods
PolicyTable::PolicyTable() : CompositeType(kUninitialized) {}
@@ -1589,7 +2071,8 @@ PolicyTable::PolicyTable(const Json::Value* value__)
, module_meta(impl::ValueMember(value__, "module_meta"))
, usage_and_error_counts(
impl::ValueMember(value__, "usage_and_error_counts"))
- , device_data(impl::ValueMember(value__, "device_data")) {}
+ , device_data(impl::ValueMember(value__, "device_data"))
+ , vehicle_data(impl::ValueMember(value__, "vehicle_data")) {}
Json::Value PolicyTable::ToJsonValue() const {
Json::Value result__(Json::objectValue);
@@ -1602,6 +2085,7 @@ Json::Value PolicyTable::ToJsonValue() const {
impl::WriteJsonField(
"usage_and_error_counts", usage_and_error_counts, &result__);
impl::WriteJsonField("device_data", device_data, &result__);
+ impl::WriteJsonField("vehicle_data", vehicle_data, &result__);
return result__;
}
@@ -1627,6 +2111,9 @@ bool PolicyTable::is_valid() const {
if (!device_data.is_valid()) {
return false;
}
+ if (!vehicle_data.is_valid()) {
+ return false;
+ }
return Validate();
}
@@ -1659,6 +2146,9 @@ bool PolicyTable::struct_empty() const {
if (device_data.is_initialized()) {
return false;
}
+ if (vehicle_data.is_initialized()) {
+ return false;
+ }
return true;
}
@@ -1701,6 +2191,9 @@ void PolicyTable::ReportErrors(rpc::ValidationReport* report__) const {
if (!device_data.is_valid()) {
device_data.ReportErrors(&report__->ReportSubobject("device_data"));
}
+ if (!vehicle_data.is_valid()) {
+ vehicle_data.ReportErrors(&report__->ReportSubobject("vehicle_data"));
+ }
}
void PolicyTable::SetPolicyTableType(PolicyTableType pt_type) {
@@ -1712,6 +2205,7 @@ void PolicyTable::SetPolicyTableType(PolicyTableType pt_type) {
module_meta.SetPolicyTableType(pt_type);
usage_and_error_counts.SetPolicyTableType(pt_type);
device_data.SetPolicyTableType(pt_type);
+ vehicle_data.SetPolicyTableType(pt_type);
}
// Table methods
diff --git a/src/components/policy/policy_regular/src/policy_table/validation.cc b/src/components/policy/policy_regular/src/policy_table/validation.cc
index 059c18d00e..14b6d657c2 100644
--- a/src/components/policy/policy_regular/src/policy_table/validation.cc
+++ b/src/components/policy/policy_regular/src/policy_table/validation.cc
@@ -196,6 +196,14 @@ bool Rpcs::Validate() const {
return true;
}
+bool EndpointProperty::Validate() const {
+ if (!version.is_valid()) {
+ return false;
+ }
+
+ return true;
+}
+
bool ModuleConfig::Validate() const {
if (PT_PRELOADED == GetPolicyTableType()) {
if (vehicle_make.is_initialized()) {
@@ -221,6 +229,14 @@ bool ModuleConfig::Validate() const {
}
}
+ if (endpoint_properties.is_initialized()) {
+ const auto& endpoint_property =
+ endpoint_properties->find(kDefaultOemMappingServiceName);
+ if (endpoint_properties->end() != endpoint_property) {
+ return (*endpoint_property).second.version.is_initialized();
+ }
+ }
+
return true;
}
@@ -268,6 +284,39 @@ bool DeviceParams::Validate() const {
return true;
}
+bool VehicleDataItem::Validate() const {
+ if (!ValidateNaming(std::string(name))) {
+ return false;
+ };
+
+ if (!ValidateNaming(std::string(key))) {
+ return false;
+ };
+
+ if (!ValidateTypes()) {
+ LOG4CXX_ERROR(
+ logger_,
+ "Unknown type: " << std::string(type) << " of " << std::string(key));
+ return false;
+ }
+ return true;
+}
+
+bool VehicleData::Validate() const {
+ const PolicyTableType policy_table_type = GetPolicyTableType();
+ bool result = true;
+ if (PT_SNAPSHOT == policy_table_type) {
+ result =
+ (!schema_items.is_initialized()) && schema_version.is_initialized();
+ }
+ if (PT_UPDATE == policy_table_type || PT_PRELOADED == policy_table_type) {
+ result =
+ (schema_version.is_initialized() && schema_items.is_initialized()) ||
+ (!schema_version.is_initialized() && !schema_items.is_initialized());
+ }
+ return result;
+}
+
bool PolicyTable::Validate() const {
const PolicyTableType policy_table_type = GetPolicyTableType();
diff --git a/src/components/policy/policy_regular/src/sql_pt_queries.cc b/src/components/policy/policy_regular/src/sql_pt_queries.cc
index 760a647853..6c961a8db3 100644
--- a/src/components/policy/policy_regular/src/sql_pt_queries.cc
+++ b/src/components/policy/policy_regular/src/sql_pt_queries.cc
@@ -352,6 +352,13 @@ const std::string kCreateSchema =
"); "
"CREATE INDEX IF NOT EXISTS `endpoint.fk_endpoint_application1_idx` "
" ON `endpoint`(`application_id` COLLATE NOCASE); "
+
+ /*endpoint properties*/
+ "CREATE TABLE IF NOT EXISTS `endpoint_properties`( "
+ " `service` VARCHAR(100) NOT NULL, "
+ " `version` VARCHAR(100) NOT NULL "
+ ");"
+
"CREATE TABLE IF NOT EXISTS `message`( "
" `id` INTEGER PRIMARY KEY NOT NULL, "
" `tts` TEXT, "
@@ -409,6 +416,42 @@ const std::string kCreateSchema =
"CREATE TABLE IF NOT EXISTS `_internal_data`( "
" `db_version_hash` INTEGER "
" ); "
+
+ /*vehicle data*/
+ "CREATE TABLE IF NOT EXISTS `vehicle_data`( "
+ " `schema_version` VARCHAR(100) NOT NULL "
+ ");"
+
+ /* vehicle data item definition*/
+ "CREATE TABLE IF NOT EXISTS `vehicle_data_item_definition`( "
+ " `name` VARCHAR(255) NOT NULL, "
+ " `type` VARCHAR(255) NOT NULL, "
+ " `key` VARCHAR(255) NOT NULL, "
+ " `mandatory` BOOL NOT NULL, "
+ " `array` BOOL, "
+ " `since` VARCHAR(45), "
+ " `until` VARCHAR(45), "
+ " `removed` BOOL, "
+ " `deprecated` BOOL, "
+ " `minvalue` INTEGER, "
+ " `maxvalue` INTEGER, "
+ " `minsize` INTEGER, "
+ " `maxsize` INTEGER, "
+ " `minlength` INTEGER, "
+ " `maxlength` INTEGER "
+ "); "
+ "CREATE TABLE IF NOT EXISTS `vehicle_data_item_parameters`( "
+ " `parent_name` VARCHAR(255) NOT NULL, "
+ " `parent_key` VARCHAR(255) NOT NULL, "
+ " `param_name` VARCHAR(255) NOT NULL, "
+ " `param_key` VARCHAR(255) NOT NULL, "
+ " CONSTRAINT `fk_vdi_id` "
+ " FOREIGN KEY(`parent_name`, `parent_key`) "
+ " REFERENCES `vehicle_data_item_definition`(`name`, `key`), "
+ " CONSTRAINT `fk_vdi_param_id` "
+ " FOREIGN KEY(`param_name`, `param_key`) "
+ " REFERENCES `vehicle_data_item_definition`(`name`, `key`) "
+ "); "
"COMMIT;";
const std::string kInsertInitData =
@@ -424,6 +467,8 @@ const std::string kInsertInitData =
" `exchange_after_x_ignition_cycles`, `exchange_after_x_kilometers`, "
" `exchange_after_x_days`, `timeout_after_x_seconds`)"
" VALUES(1, 0, 0, 0, 0, 0); "
+ "INSERT OR IGNORE INTO `vehicle_data` (`schema_version`) "
+ "VALUES('0'); "
"INSERT OR IGNORE INTO `priority`(`value`) VALUES ('EMERGENCY'); "
"INSERT OR IGNORE INTO `priority`(`value`) VALUES ('NAVIGATION'); "
"INSERT OR IGNORE INTO `priority`(`value`) VALUES ('VOICECOMMUNICATION'); "
@@ -488,6 +533,7 @@ const std::string kDropSchema =
"DROP TABLE IF EXISTS `message`; "
"DROP INDEX IF EXISTS `endpoint.fk_endpoint_application1_idx`; "
"DROP TABLE IF EXISTS `endpoint`; "
+ "DROP TABLE IF EXISTS `endpoint_properties`; "
"DROP INDEX IF EXISTS `consent_group.fk_consent_group_device1_idx`; "
"DROP INDEX IF EXISTS "
"`consent_group.fk_consent_group_functional_group1_idx`; "
@@ -550,6 +596,9 @@ const std::string kDropSchema =
"DROP TABLE IF EXISTS `usage_and_error_count`; "
"DROP TABLE IF EXISTS `device`; "
"DROP TABLE IF EXISTS `_internal_data`; "
+ "DROP TABLE IF EXISTS `vehicle_data`; "
+ "DROP TABLE IF EXISTS `vehicle_data_item_definition`; "
+ "DROP TABLE IF EXISTS `vehicle_data_item_parameters`; "
"COMMIT; "
"VACUUM;";
@@ -558,6 +607,7 @@ const std::string kDeleteData =
"DELETE FROM `message`; "
"DELETE FROM `module_type`; "
"DELETE FROM `endpoint`; "
+ "DELETE FROM `endpoint_properties`; "
"DELETE FROM `consent_group`; "
"DELETE FROM `app_type`; "
"DELETE FROM `nickname`; "
@@ -581,6 +631,9 @@ const std::string kDeleteData =
"DELETE FROM `remote_rpc`; "
"DELETE FROM `usage_and_error_count`; "
"DELETE FROM `device`; "
+ "DELETE FROM `vehicle_data`; "
+ "DELETE FROM `vehicle_data_item_definition`; "
+ "DELETE FROM `vehicle_data_item_parameters`; "
"COMMIT; "
"VACUUM;";
@@ -588,6 +641,82 @@ const std::string kCheckDBIntegrity = "PRAGMA integrity_check";
const std::string kCheckPgNumber = "PRAGMA page_count";
+const std::string kSelectEndpointProperties =
+ "SELECT `service`, `version` FROM `endpoint_properties`";
+
+const std::string kSelectVehicleDataSchemaVersion =
+ "SELECT `schema_version` FROM `vehicle_data` ";
+
+const std::string kSelectVehicleDataItem =
+ "SELECT * FROM `vehicle_data_item_definition` "
+ "WHERE `name` IS ? AND `key` IS ?";
+
+const std::string kSelectVehicleDataItemWithVersion =
+ "SELECT * FROM `vehicle_data_item_definition` "
+ "WHERE `name` IS ? AND `key` IS ? AND `since` IS ? AND `until` IS ?";
+
+const std::string kSelectVehicleDataItemParams =
+ "SELECT * FROM `vehicle_data_item_parameters` "
+ "WHERE `parent_name` IS ? AND `parent_key` IS ?";
+
+const std::string kSelectCompositeVehicleDataItemsKey =
+ "SELECT DISTINCT `parent_name`, `parent_key` FROM "
+ "`vehicle_data_item_parameters` "
+ "LEFT JOIN "
+ "(SELECT DISTINCT `param_name`, `param_key` FROM "
+ "`vehicle_data_item_parameters`) `vdi_params` ON "
+ "`vehicle_data_item_parameters`.`parent_name` = `vdi_params`.`param_name` "
+ "AND "
+ "`vehicle_data_item_parameters`.`parent_key` = `vdi_params`.`param_key` "
+ "where `vdi_params`.`param_key` is null";
+
+const std::string kSelectPrimitiveVehicleDataItems =
+ "SELECT * FROM `vehicle_data_item_definition` "
+ "LEFT JOIN ( "
+ "SELECT `parent_name`, `parent_key` FROM `vehicle_data_item_parameters` "
+ "UNION "
+ "SELECT `param_name`, `param_key` FROM `vehicle_data_item_parameters`) "
+ "`vdi_params` ON "
+ "`vehicle_data_item_definition`.`name` = `vdi_params`.`parent_name` "
+ "AND "
+ "`vehicle_data_item_definition`.`key` = `vdi_params`.`parent_key` "
+ "WHERE `vdi_params`.`parent_key` IS NULL";
+
+const std::string kInsertVehicleDataSchemaVersion =
+ "UPDATE `vehicle_data` SET `schema_version` = ?";
+
+const std::string kInsertEndpointVersion =
+ "INSERT OR REPLACE INTO `endpoint_properties`(`service`, "
+ "`version`) "
+ "VALUES(?, ?)";
+
+const std::string kInsertVehicleDataItem =
+ "INSERT INTO `vehicle_data_item_definition` ("
+ " `name`, "
+ " `type`, "
+ " `key`, "
+ " `mandatory`, "
+ " `array`, "
+ " `since`, "
+ " `until`, "
+ " `removed`, "
+ " `deprecated`, "
+ " `minvalue`, "
+ " `maxvalue`, "
+ " `minsize`, "
+ " `maxsize`, "
+ " `minlength`, "
+ " `maxlength`) "
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ";
+
+const std::string kInsertVehicleDataItemParams =
+ "INSERT INTO `vehicle_data_item_parameters` ("
+ " `parent_name`, "
+ " `parent_key`, "
+ " `param_name`, "
+ " `param_key`) "
+ "VALUES (?, ?, ?, ?) ";
+
const std::string kSelectRpc =
"SELECT DISTINCT `rpc`.`parameter` FROM `rpc` "
" JOIN `app_group` AS `g` ON (`g`.`functional_group_id` = "
@@ -860,6 +989,12 @@ const std::string kDeleteAppServiceNames = "DELETE FROM `app_service_names`";
const std::string kDeleteAppServiceHandledRpcs =
"DELETE FROM `app_service_handled_rpcs`";
+const std::string kDeleteVehicleDataItems =
+ "DELETE FROM `vehicle_data_item_definition`";
+
+const std::string kDeleteVehicleDataItemParams =
+ "DELETE FROM `vehicle_data_item_parameters`";
+
const std::string kSelectApplicationRevoked =
"SELECT `is_revoked` FROM `application` WHERE `id` = ?";
diff --git a/src/components/policy/policy_regular/src/sql_pt_representation.cc b/src/components/policy/policy_regular/src/sql_pt_representation.cc
index 50d5e282e1..ce0527600a 100644
--- a/src/components/policy/policy_regular/src/sql_pt_representation.cc
+++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc
@@ -421,16 +421,6 @@ bool SQLPTRepresentation::Close() {
return db_->LastError().number() == utils::dbms::OK;
}
-const VehicleInfo SQLPTRepresentation::GetVehicleInfo() const {
- policy_table::ModuleConfig module_config;
- GatherModuleConfig(&module_config);
- VehicleInfo vehicle_info;
- vehicle_info.vehicle_make = *module_config.vehicle_make;
- vehicle_info.vehicle_model = *module_config.vehicle_model;
- vehicle_info.vehicle_year = *module_config.vehicle_year;
- return vehicle_info;
-}
-
bool SQLPTRepresentation::Drop() {
utils::dbms::SQLQuery query(db());
if (!query.Exec(sql_pt::kDropSchema)) {
@@ -495,6 +485,11 @@ std::shared_ptr<policy_table::Table> SQLPTRepresentation::GenerateSnapshot()
GatherConsumerFriendlyMessages(
&*table->policy_table.consumer_friendly_messages);
GatherApplicationPoliciesSection(&table->policy_table.app_policies_section);
+ GatherVehicleData(&*table->policy_table.vehicle_data);
+ if (!table->policy_table.vehicle_data.is_initialized()) {
+ rpc::Optional<rpc::String<0, 100> > null_version;
+ table->policy_table.vehicle_data->schema_version = null_version;
+ }
return table;
}
@@ -542,6 +537,18 @@ void SQLPTRepresentation::GatherModuleConfig(
}
}
+ utils::dbms::SQLQuery endpoint_properties(db());
+ if (!endpoint_properties.Prepare(sql_pt::kSelectEndpointProperties)) {
+ LOG4CXX_ERROR(logger_, "Incorrect statement for Endpoint properties");
+ } else {
+ while (endpoint_properties.Next()) {
+ const std::string& service = endpoint_properties.GetString(0);
+ const std::string& version = endpoint_properties.GetString(1);
+ auto& ep_properties = (*config->endpoint_properties);
+ *ep_properties[service].version = version;
+ }
+ }
+
utils::dbms::SQLQuery notifications(db());
if (!notifications.Prepare(sql_pt::kSelectNotificationsPerMin)) {
LOG4CXX_WARN(logger_, "Incorrect select statement for notifications");
@@ -633,18 +640,17 @@ bool SQLPTRepresentation::GatherFunctionalGroupings(
}
}
if (!rpcs.IsNull(2)) {
- policy_table::Parameter param;
- if (EnumFromJsonString(rpcs.GetString(2), &param)) {
- // EMPTY is a special mark to specify that 'parameters' section is
- // present, but has no parameters. It is not valid parameter value.
- if (policy_table::P_EMPTY == param) {
- (*rpcs_structure.rpcs[rpcs.GetString(0)].parameters)
- .mark_initialized();
- continue;
- }
- InsertUnique(param,
- &(*rpcs_structure.rpcs[rpcs.GetString(0)].parameters));
+ std::string param = rpcs.GetString(2);
+ // EMPTY is a special mark to specify that 'parameters' section is
+ // present, but has no parameters. It is not valid parameter value.
+ if (policy_table::EnumToJsonString(policy_table::P_EMPTY) == param) {
+ (*rpcs_structure.rpcs[rpcs.GetString(0)].parameters)
+ .mark_initialized();
+ continue;
}
+
+ InsertUnique(param,
+ &(*rpcs_structure.rpcs[rpcs.GetString(0)].parameters));
}
}
@@ -789,6 +795,44 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection(
return true;
}
+bool SQLPTRepresentation::GatherVehicleData(
+ policy_table::VehicleData* vehicle_data) const {
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kSelectVehicleDataSchemaVersion) ||
+ !query.Next()) {
+ LOG4CXX_ERROR(logger_,
+ "Incorrect statement for vehicle data schema version");
+ return false;
+ }
+ *vehicle_data->schema_version = query.GetString(0);
+
+ vehicle_data->mark_initialized();
+ return GatherVehicleDataItems(&*vehicle_data->schema_items);
+}
+
+bool SQLPTRepresentation::GatherVehicleDataItems(
+ policy_table::VehicleDataItems* vehicle_data_items) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ auto parameterized_vdi = SelectCompositeVehicleDataItems();
+ if (!parameterized_vdi.is_initialized()) {
+ return false;
+ }
+
+ auto non_parameterized_vdi = SelectPrimitiveVehicleDataItems();
+ if (!non_parameterized_vdi.is_initialized()) {
+ return false;
+ }
+
+ vehicle_data_items->insert(vehicle_data_items->end(),
+ parameterized_vdi.begin(),
+ parameterized_vdi.end());
+ vehicle_data_items->insert(vehicle_data_items->end(),
+ non_parameterized_vdi.begin(),
+ non_parameterized_vdi.end());
+
+ return true;
+}
+
bool SQLPTRepresentation::Save(const policy_table::Table& table) {
LOG4CXX_AUTO_TRACE(logger_);
db_->BeginTransaction();
@@ -823,6 +867,10 @@ bool SQLPTRepresentation::Save(const policy_table::Table& table) {
db_->RollbackTransaction();
return false;
}
+ if (!SaveVehicleData(*table.policy_table.vehicle_data)) {
+ db_->RollbackTransaction();
+ return false;
+ }
db_->CommitTransaction();
return true;
}
@@ -901,8 +949,7 @@ bool SQLPTRepresentation::SaveRpcs(int64_t group_id,
query_parameter.Bind(0, it->first);
query_parameter.Bind(
1, std::string(policy_table::EnumToJsonString(*hmi_it)));
- query_parameter.Bind(
- 2, std::string(policy_table::EnumToJsonString(*ps_it)));
+ query_parameter.Bind(2, std::string(*ps_it));
query_parameter.Bind(3, group_id);
if (!query_parameter.Exec() || !query_parameter.Reset()) {
LOG4CXX_WARN(logger_, "Incorrect insert into rpc with parameter");
@@ -1249,7 +1296,9 @@ bool SQLPTRepresentation::SaveRequestSubType(
} else if (request_subtypes.is_initialized()) {
LOG4CXX_WARN(logger_, "Request subtypes empty.");
query.Bind(0, app_id);
- query.Bind(1, std::string("EMPTY"));
+ query.Bind(1,
+ std::string(policy_table::EnumToJsonString(
+ policy_table::RequestType::RT_EMPTY)));
if (!query.Exec() || !query.Reset()) {
LOG4CXX_WARN(logger_, "Incorrect insert into request subtypes.");
return false;
@@ -1402,6 +1451,10 @@ bool SQLPTRepresentation::SaveModuleConfig(
return false;
}
+ if (!SaveServiceEndpointProperties(*config.endpoint_properties)) {
+ return false;
+ }
+
return true;
}
@@ -1440,6 +1493,31 @@ bool SQLPTRepresentation::SaveServiceEndpoints(
return true;
}
+bool SQLPTRepresentation::SaveServiceEndpointProperties(
+ const policy_table::ServiceEndpointProperties& endpoint_properties) {
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kInsertEndpointVersion)) {
+ LOG4CXX_WARN(
+ logger_,
+ "Incorrect insert of endpoint property to endpoint_properties.");
+ return false;
+ }
+
+ for (auto& endpoint_property : endpoint_properties) {
+ query.Bind(0, endpoint_property.first);
+ query.Bind(1, endpoint_property.second.version);
+
+ if (!query.Exec() || !query.Reset()) {
+ LOG4CXX_WARN(
+ logger_,
+ "Failed to insert endpoint property into endpoint_properties.");
+ return false;
+ }
+ }
+
+ return true;
+}
+
bool SQLPTRepresentation::SaveConsumerFriendlyMessages(
const policy_table::ConsumerFriendlyMessages& messages) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -1659,6 +1737,44 @@ bool SQLPTRepresentation::SaveUsageAndErrorCounts(
return true;
}
+bool SQLPTRepresentation::SaveVehicleData(
+ const policy_table::VehicleData& vehicle_data) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (vehicle_data.is_initialized() &&
+ vehicle_data.schema_version.is_initialized()) {
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kInsertVehicleDataSchemaVersion)) {
+ LOG4CXX_WARN(logger_,
+ "Incorrect insert of schema_version to vehicle_data.");
+ return false;
+ }
+ query.Bind(0, (*vehicle_data.schema_version));
+ if (!query.Exec() || !query.Reset()) {
+ LOG4CXX_WARN(logger_, "Failed to insert schema_version to vehicle_data.");
+ return false;
+ }
+ }
+
+ auto vehicle_data_items = vehicle_data.is_initialized() &&
+ vehicle_data.schema_items.is_initialized()
+ ? *(vehicle_data.schema_items)
+ : policy_table::VehicleDataItems();
+
+ return SaveVehicleDataItems(vehicle_data_items);
+}
+
+bool SQLPTRepresentation::SaveVehicleDataItems(
+ const policy_table::VehicleDataItems& vehicle_data_items) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ DeleteVehicleDataItems();
+ for (const auto& item : vehicle_data_items) {
+ if (!InsertVehicleDataItem(item)) {
+ return false;
+ }
+ }
+ return true;
+}
+
void SQLPTRepresentation::IncrementIgnitionCycles() {
utils::dbms::SQLQuery query(db());
if (!query.Exec(sql_pt::kIncrementIgnitionCycles)) {
@@ -1788,7 +1904,8 @@ bool SQLPTRepresentation::GatherRequestSubType(
query.Bind(0, app_id);
while (query.Next()) {
const std::string request_subtype = query.GetString(0);
- if ("EMPTY" == request_subtype) {
+ if (policy_table::EnumToJsonString(policy_table::RT_EMPTY) ==
+ request_subtype) {
request_subtypes->mark_initialized();
continue;
}
@@ -2368,4 +2485,306 @@ bool SQLPTRepresentation::SetVINValue(const std::string& value) {
return true;
}
+bool SQLPTRepresentation::VehicleDataItemExists(
+ const policy_table::VehicleDataItem& vehicle_data_item) const {
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kSelectVehicleDataItemWithVersion)) {
+ LOG4CXX_ERROR(logger_,
+ "Incorrent select statement for vehicle data item. "
+ << query.LastError().text());
+ return false;
+ }
+
+ query.Bind(0, vehicle_data_item.name);
+ query.Bind(1, vehicle_data_item.key);
+ vehicle_data_item.since.is_initialized()
+ ? query.Bind(2, std::string(*vehicle_data_item.since))
+ : query.Bind(2);
+ vehicle_data_item.until.is_initialized()
+ ? query.Bind(3, std::string(*vehicle_data_item.until))
+ : query.Bind(3);
+
+ if (!query.Exec()) {
+ LOG4CXX_ERROR(logger_,
+ "Failed to retrieve vehicle data item: "
+ << std::string(vehicle_data_item.key)
+ << ". Error: " << query.LastError().text());
+ return false;
+ }
+ return !query.IsNull(0);
+}
+
+policy_table::VehicleDataItems SQLPTRepresentation::GetVehicleDataItem(
+ const std::string& name, const std::string& key) const {
+ policy_table::VehicleDataItems result;
+ utils::dbms::SQLQuery query(db());
+
+ if (!query.Prepare(sql_pt::kSelectVehicleDataItem)) {
+ LOG4CXX_ERROR(logger_,
+ "Incorrent select statement of vehicle data item. "
+ << query.LastError().text());
+ return result;
+ }
+
+ query.Bind(0, name);
+ query.Bind(1, key);
+
+ while (query.Next()) {
+ auto vdi = PopulateVDIFromQuery(query);
+ if (!vdi.is_initialized()) {
+ return policy_table::VehicleDataItems();
+ }
+
+ utils::dbms::SQLQuery param_query(db());
+ if (policy_table::VehicleDataItem::kStruct ==
+ static_cast<std::string>(vdi.type)) {
+ if (!param_query.Prepare(sql_pt::kSelectVehicleDataItemParams)) {
+ LOG4CXX_ERROR(logger_,
+ "Incorrent select statement of vehicle data item. "
+ << param_query.LastError().text());
+ return policy_table::VehicleDataItems();
+ }
+
+ param_query.Bind(0, name);
+ param_query.Bind(1, key);
+
+ while (param_query.Next()) {
+ const auto param_with_diff_versions = GetVehicleDataItem(
+ param_query.GetString(2), param_query.GetString(3));
+ if (!param_with_diff_versions.is_initialized()) {
+ return policy_table::VehicleDataItems();
+ }
+ for (const auto& param : param_with_diff_versions) {
+ vdi.params->push_back(param);
+ }
+ }
+ }
+
+ result.push_back(vdi);
+ }
+ if (!result.empty()) {
+ result.mark_initialized();
+ }
+
+ return result;
+}
+
+policy_table::VehicleDataItem SQLPTRepresentation::PopulateVDIFromQuery(
+ const utils::dbms::SQLQuery& query) const {
+ policy_table::VehicleDataItem result;
+
+ result.name = query.GetString(0);
+ result.type = query.GetString(1);
+ result.key = query.GetString(2);
+ result.mandatory = query.GetBoolean(3);
+
+ if (!query.IsNull(4)) {
+ *result.array = query.GetBoolean(4);
+ }
+ if (!query.IsNull(5)) {
+ *result.since = query.GetString(5);
+ }
+ if (!query.IsNull(6)) {
+ *result.until = query.GetString(6);
+ }
+ if (!query.IsNull(7)) {
+ *result.removed = query.GetBoolean(7);
+ }
+ if (!query.IsNull(8)) {
+ *result.deprecated = query.GetBoolean(8);
+ }
+ if (!query.IsNull(9)) {
+ *result.minvalue = query.GetInteger(9);
+ }
+ if (!query.IsNull(10)) {
+ *result.maxvalue = query.GetInteger(10);
+ }
+ if (!query.IsNull(11)) {
+ *result.minsize = query.GetUInteger(11);
+ }
+ if (!query.IsNull(12)) {
+ *result.maxsize = query.GetUInteger(12);
+ }
+ if (!query.IsNull(13)) {
+ *result.minlength = query.GetUInteger(13);
+ }
+ if (!query.IsNull(14)) {
+ *result.maxlength = query.GetUInteger(14);
+ }
+ result.params->mark_initialized();
+
+ result.mark_initialized();
+ return result;
+}
+
+bool SQLPTRepresentation::InsertVehicleDataItem(
+ const policy_table::VehicleDataItem& vehicle_data_item) {
+ utils::dbms::SQLQuery query(db());
+
+ if (!vehicle_data_item.is_initialized() || !vehicle_data_item.is_valid()) {
+ LOG4CXX_ERROR(logger_, "Vehicle data item is not initialized.");
+ return false;
+ }
+
+ if (VehicleDataItemExists(vehicle_data_item)) {
+ LOG4CXX_INFO(logger_,
+ static_cast<std::string>(vehicle_data_item.key)
+ << " is already stored.");
+ return true;
+ }
+
+ if (!query.Prepare(sql_pt::kInsertVehicleDataItem)) {
+ LOG4CXX_ERROR(logger_,
+ "Incorrent select statement of vehicle data item. "
+ << query.LastError().text());
+ return false;
+ }
+
+ query.Bind(0, vehicle_data_item.name);
+ query.Bind(1, vehicle_data_item.type);
+ query.Bind(2, vehicle_data_item.key);
+ query.Bind(3, vehicle_data_item.mandatory);
+ vehicle_data_item.array.is_initialized()
+ ? query.Bind(4, *vehicle_data_item.array)
+ : query.Bind(4);
+ vehicle_data_item.since.is_initialized()
+ ? query.Bind(5, *vehicle_data_item.since)
+ : query.Bind(5);
+ vehicle_data_item.until.is_initialized()
+ ? query.Bind(6, *vehicle_data_item.until)
+ : query.Bind(6);
+ vehicle_data_item.removed.is_initialized()
+ ? query.Bind(7, *vehicle_data_item.removed)
+ : query.Bind(7);
+ vehicle_data_item.deprecated.is_initialized()
+ ? query.Bind(8, *vehicle_data_item.deprecated)
+ : query.Bind(8);
+ vehicle_data_item.minvalue.is_initialized()
+ ? query.Bind(9, *vehicle_data_item.minvalue)
+ : query.Bind(9);
+ vehicle_data_item.maxvalue.is_initialized()
+ ? query.Bind(10, *vehicle_data_item.maxvalue)
+ : query.Bind(10);
+ vehicle_data_item.minsize.is_initialized()
+ ? query.Bind(11, static_cast<int64_t>(*vehicle_data_item.minsize))
+ : query.Bind(11);
+ vehicle_data_item.maxsize.is_initialized()
+ ? query.Bind(12, static_cast<int64_t>(*vehicle_data_item.maxsize))
+ : query.Bind(12);
+ vehicle_data_item.minlength.is_initialized()
+ ? query.Bind(13, static_cast<int64_t>(*vehicle_data_item.minlength))
+ : query.Bind(13);
+ vehicle_data_item.maxlength.is_initialized()
+ ? query.Bind(14, static_cast<int64_t>(*vehicle_data_item.maxlength))
+ : query.Bind(14);
+
+ if (!query.Exec() || !query.Reset()) {
+ LOG4CXX_ERROR(logger_,
+ "Failed to insert vehicle data item: "
+ << static_cast<std::string>(vehicle_data_item.key)
+ << ". Error: " << query.LastError().text());
+ return false;
+ }
+
+ if (vehicle_data_item.params->is_initialized()) {
+ for (const auto& param : *(vehicle_data_item.params)) {
+ if (!InsertVehicleDataItem(param)) {
+ return false;
+ }
+
+ if (!query.Prepare(sql_pt::kInsertVehicleDataItemParams)) {
+ LOG4CXX_ERROR(logger_,
+ "Incorrent select statement of vehicle data item. "
+ << query.LastError().text());
+ return false;
+ }
+
+ query.Bind(0, vehicle_data_item.name);
+ query.Bind(1, vehicle_data_item.key);
+ query.Bind(2, param.name);
+ query.Bind(3, param.key);
+
+ if (!query.Exec() || !query.Reset()) {
+ LOG4CXX_ERROR(
+ logger_,
+ "Failed to insert to vehicle data item relations helper table: "
+ << static_cast<std::string>(param.key)
+ << ". Error: " << query.LastError().text());
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+policy_table::VehicleDataItems
+SQLPTRepresentation::SelectCompositeVehicleDataItems() const {
+ utils::dbms::SQLQuery query(db());
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (!query.Prepare(sql_pt::kSelectCompositeVehicleDataItemsKey)) {
+ LOG4CXX_ERROR(logger_,
+ "Incorrect statement for parameterized vehicle data items");
+ return policy_table::VehicleDataItems();
+ }
+
+ policy_table::VehicleDataItems result;
+ result.mark_initialized();
+
+ while (query.Next()) {
+ const auto vdi = GetVehicleDataItem(query.GetString(0), query.GetString(1));
+ if (!vdi.is_initialized()) {
+ return policy_table::VehicleDataItems();
+ }
+ for (const auto& item : vdi) {
+ result.push_back(item);
+ }
+ }
+
+ return result;
+}
+
+policy_table::VehicleDataItems
+SQLPTRepresentation::SelectPrimitiveVehicleDataItems() const {
+ utils::dbms::SQLQuery query(db());
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (!query.Prepare(sql_pt::kSelectPrimitiveVehicleDataItems)) {
+ LOG4CXX_ERROR(
+ logger_,
+ "Incorrect statement for non parameterized vehicle data items");
+ return policy_table::VehicleDataItems();
+ }
+
+ auto result = policy_table::VehicleDataItems();
+ result.mark_initialized();
+
+ while (query.Next()) {
+ const auto vdi = PopulateVDIFromQuery(query);
+ if (!vdi.is_initialized()) {
+ return policy_table::VehicleDataItems();
+ }
+ result.push_back(vdi);
+ }
+ return result;
+}
+
+bool SQLPTRepresentation::DeleteVehicleDataItems() const {
+ utils::dbms::SQLQuery query(db());
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ if (!query.Exec(sql_pt::kDeleteVehicleDataItems)) {
+ LOG4CXX_ERROR(logger_,
+ "Failed clearing database: " << query.LastError().text());
+ return false;
+ }
+
+ if (!query.Exec(sql_pt::kDeleteVehicleDataItemParams)) {
+ LOG4CXX_ERROR(logger_,
+ "Failed clearing database: " << query.LastError().text());
+ return false;
+ }
+
+ return true;
+}
+
} // namespace policy
diff --git a/src/components/policy/policy_regular/test/include/policy/mock_pt_representation.h b/src/components/policy/policy_regular/test/include/policy/mock_pt_representation.h
index 44f7733985..8cf3884c11 100644
--- a/src/components/policy/policy_regular/test/include/policy/mock_pt_representation.h
+++ b/src/components/policy/policy_regular/test/include/policy/mock_pt_representation.h
@@ -64,7 +64,6 @@ class MockPTRepresentation : virtual public PTRepresentation {
MOCK_METHOD1(SecondsBetweenRetries, bool(std::vector<int>* seconds));
MOCK_METHOD2(GetPriority,
bool(const std::string& app_id, std::string* priority));
- MOCK_CONST_METHOD0(GetVehicleInfo, const VehicleInfo());
MOCK_METHOD1(SetVINValue, bool(const std::string& value));
MOCK_METHOD2(
GetUserFriendlyMsg,
diff --git a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc
index ed80e904b4..ce0d3f5941 100644
--- a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc
+++ b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc
@@ -51,10 +51,10 @@
#include "utils/date_time.h"
#include "utils/file_system.h"
+#include "utils/gen_hash.h"
#include "utils/macro.h"
#include "policy/mock_access_remote.h"
-#include "utils/gen_hash.h"
using ::testing::_;
using ::testing::AtLeast;
@@ -77,6 +77,12 @@ namespace custom_str = utils::custom_string;
typedef std::multimap<std::string, policy_table::Rpcs&>
UserConsentPromptToRpcsConnections;
+namespace {
+std::string kSpeed = "speed";
+std::string kRPM = "rpm";
+std::string kFuelLevel = "fuelLevel";
+} // namespace
+
template <typename T>
std::string NumberToString(T Number) {
std::ostringstream ss;
@@ -142,17 +148,18 @@ class PolicyManagerImplTest : public ::testing::Test {
protected:
PolicyManagerImpl* manager;
- MockCacheManagerInterface* cache_manager;
+ NiceMock<MockCacheManagerInterface>* cache_manager;
NiceMock<MockPolicyListener> listener;
+ NiceMock<MockUpdateStatusManager> update_status_manager;
const std::string device_id;
std::shared_ptr<access_remote_test::MockAccessRemote> access_remote;
void SetUp() OVERRIDE {
manager = new PolicyManagerImpl();
manager->set_listener(&listener);
- cache_manager = new MockCacheManagerInterface();
+ cache_manager = new NiceMock<MockCacheManagerInterface>();
manager->set_cache_manager(cache_manager);
- access_remote = std::shared_ptr<access_remote_test::MockAccessRemote>();
+ access_remote = std::make_shared<access_remote_test::MockAccessRemote>();
manager->set_access_remote(access_remote);
}
@@ -169,6 +176,78 @@ class PolicyManagerImplTest : public ::testing::Test {
return ::testing::AssertionFailure() << ::rpc::PrettyFormat(report);
}
}
+
+ void PrepareUpdateWithFunctionalGroupingContent(policy_table::Table& update) {
+ using namespace application_manager;
+
+ update.SetPolicyTableType(rpc::policy_table_interface_base::PT_UPDATE);
+
+ policy_table::Rpcs rpcs;
+ rpcs.mark_initialized();
+
+ policy_table::Rpc rpc;
+ rpc.mark_initialized();
+
+ policy_table::RpcParameters rpc_params;
+ rpc_params.mark_initialized();
+ rpc_params.hmi_levels.push_back(
+ rpc::policy_table_interface_base::HmiLevel::HL_FULL);
+ rpc_params.hmi_levels.push_back(
+ rpc::policy_table_interface_base::HmiLevel::HL_BACKGROUND);
+
+ (*rpc_params.parameters).push_back(kRPM);
+ (*rpc_params.parameters).push_back(kSpeed);
+
+ rpc["GetVehicleData"] = rpc_params;
+ rpcs.rpcs = rpc;
+
+ policy_table::FunctionalGroupings fg;
+ fg["TestGroup1"] = rpcs;
+
+ update.policy_table.functional_groupings = fg;
+
+ policy_table::ApplicationParams app_params;
+ app_params.mark_initialized();
+ app_params.priority =
+ rpc::policy_table_interface_base::Priority::P_COMMUNICATION;
+ app_params.groups.push_back("TestGroup1");
+ update.policy_table.app_policies_section.apps["1234"] = app_params;
+ }
+
+ void ExpectOnPermissionsUpdated() {
+ std::string dev_id_1 = "dev_id_1";
+ std::string app_id = "1234";
+
+ EXPECT_CALL(*cache_manager, IsDefaultPolicy(app_id)).WillOnce(Return(true));
+ EXPECT_CALL(*access_remote, IsAppRemoteControl(_)).WillOnce(Return(true));
+
+ FunctionalGroupNames fg_names;
+ fg_names[0] =
+ std::make_pair<std::string, std::string>("fg_name_1", "fg_name_2");
+ EXPECT_CALL(*cache_manager, GetFunctionalGroupNames(_))
+ .WillOnce(DoAll(SetArgReferee<0>(fg_names), Return(true)));
+
+ std::vector<std::string> device_ids;
+ device_ids.push_back(dev_id_1);
+ EXPECT_CALL(listener, GetDevicesIds(app_id))
+ .WillRepeatedly(Return(device_ids));
+
+ int32_t group_id = 0;
+ FunctionalGroupIDs group_ids;
+ group_ids.push_back(group_id);
+ FunctionalIdType group_types;
+ group_types[GroupType::kTypeGeneral] = group_ids;
+ EXPECT_CALL(*access_remote, GetPermissionsForApp(dev_id_1, app_id, _))
+ .WillRepeatedly(DoAll(SetArgReferee<2>(group_types), Return(true)));
+
+ EXPECT_CALL(listener, OnPermissionsUpdated(dev_id_1, app_id, _, _))
+ .Times(1);
+
+ EXPECT_CALL(listener, GetAppName(_))
+ .WillOnce(Return(custom_str::CustomString("")));
+
+ EXPECT_CALL(listener, OnUpdateStatusChanged(_)).Times(1);
+ }
};
class PolicyManagerImplTest2 : public ::testing::Test {
@@ -208,7 +287,7 @@ class PolicyManagerImplTest2 : public ::testing::Test {
.WillByDefault(ReturnRef(kAppStorageFolder));
ON_CALL(policy_settings_, use_full_app_id()).WillByDefault(Return(true));
manager->set_listener(&listener);
- const char* levels[] = {"BACKGROUND", "FULL", "LIMITED", "NONE"};
+ const char* levels[] = {"FULL", "LIMITED", "BACKGROUND", "NONE"};
hmi_level.assign(levels, levels + sizeof(levels) / sizeof(levels[0]));
srand(time(NULL));
index = rand() % 3;
@@ -899,13 +978,207 @@ TEST_F(PolicyManagerImplTest, LoadPT_SetPT_PTIsLoaded) {
std::make_shared<policy_table::Table>(update.policy_table);
// Assert
EXPECT_CALL(*cache_manager, GenerateSnapshot()).WillOnce(Return(snapshot));
+ EXPECT_CALL(*cache_manager, GetVehicleDataItems())
+ .WillOnce(Return(std::vector<policy_table::VehicleDataItem>()));
EXPECT_CALL(*cache_manager, ApplyUpdate(_)).WillOnce(Return(true));
- EXPECT_CALL(listener, GetAppName("1234"))
- .WillOnce(Return(custom_str::CustomString("")));
- EXPECT_CALL(listener, OnUpdateStatusChanged(_));
+ EXPECT_CALL(listener, GetDevicesIds("1234"))
+ .WillRepeatedly(Return(transport_manager::DeviceList()));
EXPECT_CALL(*cache_manager, SaveUpdateRequired(false));
EXPECT_CALL(*cache_manager, TimeoutResponse());
EXPECT_CALL(*cache_manager, SecondsBetweenRetries(_));
+ EXPECT_TRUE(manager->LoadPT("file_pt_update.json", msg));
+}
+
+TEST_F(PolicyManagerImplTest, LoadPT_FunctionalGroup_removeRPC_SendUpdate) {
+ // Arrange
+ manager->ForcePTExchange();
+ manager->OnUpdateStarted();
+ Json::Value table = CreatePTforLoad();
+ policy_table::Table update(&table);
+
+ PrepareUpdateWithFunctionalGroupingContent(update);
+
+ std::shared_ptr<policy_table::Table> snapshot =
+ std::make_shared<policy_table::Table>(update.policy_table);
+
+ const auto& fg_found =
+ update.policy_table.functional_groupings.find("TestGroup1");
+ fg_found->second.rpcs.erase("GetVehicleData");
+
+ ASSERT_TRUE(IsValid(update));
+
+ const std::string json = update.ToJsonValue().toStyledString();
+ ::policy::BinaryMessage msg(json.begin(), json.end());
+
+ // Assert
+ EXPECT_CALL(*cache_manager, GetVehicleDataItems())
+ .WillOnce(Return(std::vector<policy_table::VehicleDataItem>()));
+ EXPECT_CALL(*cache_manager, GenerateSnapshot()).WillOnce(Return(snapshot));
+ EXPECT_CALL(*cache_manager, ApplyUpdate(_)).WillOnce(Return(true));
+ ExpectOnPermissionsUpdated();
+
+ EXPECT_TRUE(manager->LoadPT("file_pt_update.json", msg));
+}
+
+TEST_F(PolicyManagerImplTest,
+ LoadPT_FunctionalGroup_removeRPCParams_SendUpdate) {
+ // Arrange
+ manager->ForcePTExchange();
+ manager->OnUpdateStarted();
+ Json::Value table = CreatePTforLoad();
+ policy_table::Table update(&table);
+
+ PrepareUpdateWithFunctionalGroupingContent(update);
+
+ std::shared_ptr<policy_table::Table> snapshot =
+ std::make_shared<policy_table::Table>(update.policy_table);
+
+ const auto& fg_found =
+ update.policy_table.functional_groupings.find("TestGroup1");
+ policy_table::RpcParameters& new_rpc_params =
+ fg_found->second.rpcs["GetVehicleData"];
+ new_rpc_params.parameters->erase(new_rpc_params.parameters->begin());
+
+ ASSERT_TRUE(IsValid(update));
+
+ const std::string json = update.ToJsonValue().toStyledString();
+ ::policy::BinaryMessage msg(json.begin(), json.end());
+
+ // Assert
+ EXPECT_CALL(*cache_manager, GenerateSnapshot()).WillOnce(Return(snapshot));
+ EXPECT_CALL(*cache_manager, GetVehicleDataItems())
+ .WillOnce(Return(std::vector<policy_table::VehicleDataItem>()));
+ EXPECT_CALL(*cache_manager, ApplyUpdate(_)).WillOnce(Return(true));
+ ExpectOnPermissionsUpdated();
+
+ EXPECT_TRUE(manager->LoadPT("file_pt_update.json", msg));
+}
+
+TEST_F(PolicyManagerImplTest,
+ LoadPT_FunctionalGroup_removeRPC_HMILevels_SendUpdate) {
+ // Arrange
+ manager->ForcePTExchange();
+ manager->OnUpdateStarted();
+ Json::Value table = CreatePTforLoad();
+ policy_table::Table update(&table);
+
+ PrepareUpdateWithFunctionalGroupingContent(update);
+
+ std::shared_ptr<policy_table::Table> snapshot =
+ std::make_shared<policy_table::Table>(update.policy_table);
+
+ const auto& fg_found =
+ update.policy_table.functional_groupings.find("TestGroup1");
+ policy_table::RpcParameters& new_rpc_params =
+ fg_found->second.rpcs["GetVehicleData"];
+ new_rpc_params.hmi_levels.erase(new_rpc_params.hmi_levels.begin());
+
+ ASSERT_TRUE(IsValid(update));
+
+ const std::string json = update.ToJsonValue().toStyledString();
+ ::policy::BinaryMessage msg(json.begin(), json.end());
+
+ // Assert
+ EXPECT_CALL(*cache_manager, GenerateSnapshot()).WillOnce(Return(snapshot));
+ EXPECT_CALL(*cache_manager, GetVehicleDataItems())
+ .WillOnce(Return(std::vector<policy_table::VehicleDataItem>()));
+ EXPECT_CALL(*cache_manager, ApplyUpdate(_)).WillOnce(Return(true));
+ ExpectOnPermissionsUpdated();
+
+ EXPECT_TRUE(manager->LoadPT("file_pt_update.json", msg));
+}
+
+TEST_F(PolicyManagerImplTest,
+ LoadPT_FunctionalGroup_addRPC_HMILevels_SendUpdate) {
+ // Arrange
+ manager->ForcePTExchange();
+ manager->OnUpdateStarted();
+ Json::Value table = CreatePTforLoad();
+ policy_table::Table update(&table);
+
+ PrepareUpdateWithFunctionalGroupingContent(update);
+
+ std::shared_ptr<policy_table::Table> snapshot =
+ std::make_shared<policy_table::Table>(update.policy_table);
+
+ const auto& fg_found =
+ update.policy_table.functional_groupings.find("TestGroup1");
+ policy_table::RpcParameters& new_rpc_params =
+ fg_found->second.rpcs["GetVehicleData"];
+ new_rpc_params.hmi_levels.push_back(
+ rpc::policy_table_interface_base::HmiLevel::HL_LIMITED);
+
+ ASSERT_TRUE(IsValid(update));
+
+ const std::string json = update.ToJsonValue().toStyledString();
+ ::policy::BinaryMessage msg(json.begin(), json.end());
+
+ // Assert
+ EXPECT_CALL(*cache_manager, GenerateSnapshot()).WillOnce(Return(snapshot));
+ EXPECT_CALL(*cache_manager, GetVehicleDataItems())
+ .WillOnce(Return(std::vector<policy_table::VehicleDataItem>()));
+ EXPECT_CALL(*cache_manager, ApplyUpdate(_)).WillOnce(Return(true));
+ ExpectOnPermissionsUpdated();
+
+ EXPECT_TRUE(manager->LoadPT("file_pt_update.json", msg));
+}
+
+TEST_F(PolicyManagerImplTest, LoadPT_FunctionalGroup_addRPCParams_SendUpdate) {
+ using namespace application_manager;
+ // Arrange
+ manager->ForcePTExchange();
+ manager->OnUpdateStarted();
+ Json::Value table = CreatePTforLoad();
+ policy_table::Table update(&table);
+
+ PrepareUpdateWithFunctionalGroupingContent(update);
+
+ std::shared_ptr<policy_table::Table> snapshot =
+ std::make_shared<policy_table::Table>(update.policy_table);
+
+ const auto& fg_found =
+ update.policy_table.functional_groupings.find("TestGroup1");
+ policy_table::RpcParameters& new_rpc_params =
+ fg_found->second.rpcs["GetVehicleData"];
+ (*new_rpc_params.parameters).push_back(kFuelLevel);
+
+ ASSERT_TRUE(IsValid(update));
+
+ const std::string json = update.ToJsonValue().toStyledString();
+ ::policy::BinaryMessage msg(json.begin(), json.end());
+
+ // Assert
+ EXPECT_CALL(*cache_manager, GenerateSnapshot()).WillOnce(Return(snapshot));
+ EXPECT_CALL(*cache_manager, GetVehicleDataItems())
+ .WillOnce(Return(std::vector<policy_table::VehicleDataItem>()));
+ EXPECT_CALL(*cache_manager, ApplyUpdate(_)).WillOnce(Return(true));
+ ExpectOnPermissionsUpdated();
+
+ EXPECT_TRUE(manager->LoadPT("file_pt_update.json", msg));
+}
+
+TEST_F(PolicyManagerImplTest, LoadPT_FunctionalGroup_NoUpdate_DONT_SendUpdate) {
+ // Arrange
+ manager->ForcePTExchange();
+ manager->OnUpdateStarted();
+ Json::Value table = CreatePTforLoad();
+ policy_table::Table update(&table);
+
+ PrepareUpdateWithFunctionalGroupingContent(update);
+
+ std::shared_ptr<policy_table::Table> snapshot =
+ std::make_shared<policy_table::Table>(update.policy_table);
+
+ ASSERT_TRUE(IsValid(update));
+
+ const std::string json = update.ToJsonValue().toStyledString();
+ ::policy::BinaryMessage msg(json.begin(), json.end());
+
+ // Assert
+ EXPECT_CALL(*cache_manager, GenerateSnapshot()).WillOnce(Return(snapshot));
+ EXPECT_CALL(*cache_manager, GetVehicleDataItems())
+ .WillOnce(Return(std::vector<policy_table::VehicleDataItem>()));
+ EXPECT_CALL(*cache_manager, ApplyUpdate(_)).WillOnce(Return(true));
EXPECT_TRUE(manager->LoadPT("file_pt_update.json", msg));
}
@@ -926,8 +1199,13 @@ TEST_F(PolicyManagerImplTest, LoadPT_SetInvalidUpdatePT_PTIsNotLoaded) {
std::string json = table.toStyledString();
::policy::BinaryMessage msg(json.begin(), json.end());
+ std::shared_ptr<policy_table::Table> snapshot =
+ std::make_shared<policy_table::Table>(update.policy_table);
+ ON_CALL(*cache_manager, GenerateSnapshot()).WillByDefault(Return(snapshot));
+ ON_CALL(*cache_manager, GetVehicleDataItems())
+ .WillByDefault(Return(std::vector<policy_table::VehicleDataItem>()));
+
// Assert
- EXPECT_CALL(*cache_manager, GenerateSnapshot()).Times(0);
EXPECT_CALL(*cache_manager, ApplyUpdate(_)).Times(0);
EXPECT_CALL(listener, GetAppName(_)).Times(0);
EXPECT_CALL(listener, OnUpdateStatusChanged(_)).Times(1);
@@ -1476,23 +1754,6 @@ TEST_F(PolicyManagerImplTest2, GetCurrentDeviceId) {
EXPECT_EQ("", manager->GetCurrentDeviceId(dev_handle2, app_id2));
}
-TEST_F(PolicyManagerImplTest2,
- GetVehicleInfo_SetVehicleInfo_ExpectReceivedInfoCorrect) {
- // Arrange
- CreateLocalPT("sdl_preloaded_pt.json");
- GetPTU("valid_sdl_pt_update.json");
- std::shared_ptr<policy_table::Table> pt = (manager->GetCache())->pt();
- policy_table::ModuleConfig& module_config = pt->policy_table.module_config;
- ::policy::VehicleInfo vehicle_info = manager->GetVehicleInfo();
-
- EXPECT_EQ(static_cast<std::string>(*module_config.vehicle_make),
- vehicle_info.vehicle_make);
- EXPECT_EQ(static_cast<std::string>(*module_config.vehicle_model),
- vehicle_info.vehicle_model);
- EXPECT_EQ(static_cast<std::string>(*module_config.vehicle_year),
- vehicle_info.vehicle_year);
-}
-
TEST_F(
PolicyManagerImplTest2,
GetPermissionsForApp_SetUserConsentForApp_ExpectReceivedPermissionsCorrect) {
@@ -1602,6 +1863,80 @@ TEST_F(
EXPECT_EQ(heart_beat_timeout.asUInt(), result);
}
+TEST_F(PolicyManagerImplTest2, CacheManager_RemoveRPCSpecVehicleDataItems) {
+ policy_table::VehicleDataItems init;
+ policy_table::VehicleDataItem test_item;
+ test_item.name = "headLampStatus";
+ init.push_back(test_item);
+
+ const auto ret = CacheManager::CollectCustomVDItems(init);
+
+ EXPECT_EQ(0u, ret.size());
+}
+
+TEST_F(PolicyManagerImplTest2,
+ CacheManager_RemoveRPCSpecVehicleDataItemsAndRemainCustom) {
+ policy_table::VehicleDataItems init;
+ policy_table::VehicleDataItem rpc_spec_item;
+ rpc_spec_item.name = "headLampStatus";
+ policy_table::VehicleDataItem custom_item;
+ custom_item.name = "Custom";
+ init.push_back(rpc_spec_item);
+ init.push_back(custom_item);
+
+ EXPECT_EQ(2u, init.size());
+
+ const auto ret = CacheManager::CollectCustomVDItems(init);
+
+ EXPECT_EQ(1u, ret.size());
+ EXPECT_EQ(ret.at(0).name, "Custom");
+}
+
+TEST_F(PolicyManagerImplTest2, CacheManager_RemainCustomVehicleDataItems) {
+ policy_table::VehicleDataItems init;
+ policy_table::VehicleDataItem custom_item;
+ custom_item.name = "Custom";
+ init.push_back(custom_item);
+
+ EXPECT_EQ(1u, init.size());
+
+ const auto& ret = CacheManager::CollectCustomVDItems(init);
+
+ EXPECT_EQ(1u, ret.size());
+}
+
+TEST_F(PolicyManagerImplTest2,
+ CacheManager_CollectCustomItemWithRemainingRPCSpecItem) {
+ policy_table::VehicleDataItems init;
+ policy_table::VehicleDataItem rpc_spec_item;
+ rpc_spec_item.name = "headLampStatus";
+ policy_table::VehicleDataItem custom_item;
+ custom_item.name = "Custom";
+ init.push_back(rpc_spec_item);
+ init.push_back(custom_item);
+
+ EXPECT_EQ(2u, init.size());
+
+ const auto& ret = CacheManager::CollectCustomVDItems(init);
+
+ EXPECT_EQ(1u, ret.size());
+ EXPECT_EQ(ret.at(0).name, custom_item.name);
+}
+
+TEST_F(PolicyManagerImplTest2,
+ CacheManager_RemainRPCSpecVehicleDataItemsNoCustomItems) {
+ policy_table::VehicleDataItems init;
+ policy_table::VehicleDataItem custom_item;
+ custom_item.name = "headLampStatus";
+ init.push_back(custom_item);
+
+ EXPECT_EQ(1u, init.size());
+
+ const auto& ret = CacheManager::CollectCustomVDItems(init);
+
+ EXPECT_EQ(0u, ret.size());
+}
+
} // namespace policy_test
} // namespace components
} // namespace test
diff --git a/src/components/policy/policy_regular/test/sql_pt_representation_test.cc b/src/components/policy/policy_regular/test/sql_pt_representation_test.cc
index d456aa26e4..8bb0fb22c6 100644
--- a/src/components/policy/policy_regular/test/sql_pt_representation_test.cc
+++ b/src/components/policy/policy_regular/test/sql_pt_representation_test.cc
@@ -69,7 +69,7 @@ namespace policy_test {
using policy_handler_test::MockPolicySettings;
-class SQLPTRepresentationTest : public SQLPTRepresentation,
+class SQLPTRepresentationTest : protected SQLPTRepresentation,
public ::testing::Test {
protected:
DBMS* dbms;
@@ -398,7 +398,7 @@ class SQLPTRepresentationTest2 : public ::testing::Test {
}
void TearDown() OVERRIDE {
- file_system::RemoveDirectory(kAppStorageFolder, true);
+ ASSERT_TRUE(file_system::RemoveDirectory(kAppStorageFolder, true));
delete reps;
}
@@ -428,6 +428,148 @@ class SQLPTRepresentationTest3 : public ::testing::Test {
const std::string kAppStorageFolder;
};
+TEST_F(SQLPTRepresentationTest, VehicleDataItem_Store_Item) {
+ policy_table::VehicleDataItem rpm;
+ rpm.mark_initialized();
+ rpm.name = "rpm";
+ rpm.type = "Integer";
+ rpm.key = "OEM_REF_RPM";
+ rpm.mandatory = false;
+ *rpm.array = false;
+ rpm.params->mark_initialized();
+ ASSERT_FALSE(reps->VehicleDataItemExists(rpm));
+ ASSERT_TRUE(reps->InsertVehicleDataItem(rpm));
+ ASSERT_TRUE(reps->VehicleDataItemExists(rpm));
+
+ auto rpm_retrieved = reps->GetVehicleDataItem(rpm.name, rpm.key);
+ ASSERT_EQ(rpm.ToJsonValue(), rpm_retrieved.begin()->ToJsonValue());
+}
+
+TEST_F(SQLPTRepresentationTest, VehicleDataItem_Store_Complete_Item) {
+ policy_table::VehicleDataItem message;
+ message.mark_initialized();
+ message.name = "messsageName";
+ message.type = "String";
+ message.key = "OEM_REF_MSG";
+ message.mandatory = false;
+ *message.array = false;
+ message.params->mark_initialized();
+ *message.since = "1.0";
+ *message.until = "5.0";
+ *message.removed = false;
+ *message.deprecated = false;
+ *message.minvalue = 0;
+ *message.maxvalue = 255;
+ *message.minsize = 0;
+ *message.maxsize = 255;
+ *message.minlength = 0;
+ *message.maxlength = 255;
+ ASSERT_TRUE(reps->InsertVehicleDataItem(message));
+
+ auto message_retrieved = reps->GetVehicleDataItem(message.name, message.key);
+ ASSERT_EQ(message.ToJsonValue(), message_retrieved.begin()->ToJsonValue());
+}
+
+TEST_F(SQLPTRepresentationTest, VehicleDataItem_Store_Struct) {
+ 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);
+ ASSERT_TRUE(reps->InsertVehicleDataItem(alss));
+ ASSERT_TRUE(reps->InsertVehicleDataItem(hls));
+
+ auto hls_retrieved = reps->GetVehicleDataItem(hls.name, hls.key);
+ ASSERT_EQ(hls.ToJsonValue(), hls_retrieved.begin()->ToJsonValue());
+}
+
+TEST_F(SQLPTRepresentationTest, VehicleDataItem_Select_NonParameterizedVDI) {
+ policy_table::VehicleDataItems non_parameterized_vdis;
+ policy_table::VehicleDataItem rpm;
+ rpm.mark_initialized();
+ rpm.name = "rpm";
+ rpm.type = "Integer";
+ rpm.key = "OEM_REF_RPM";
+ rpm.mandatory = false;
+ *rpm.array = false;
+ rpm.params->mark_initialized();
+ ASSERT_TRUE(reps->InsertVehicleDataItem(rpm));
+ policy_table::VehicleDataItem message;
+ message.mark_initialized();
+ message.name = "rpm";
+ message.type = "String";
+ message.key = "OEM_REF_MSG";
+ message.mandatory = false;
+ *message.array = false;
+ message.params->mark_initialized();
+ ASSERT_TRUE(reps->InsertVehicleDataItem(message));
+ non_parameterized_vdis.push_back(rpm);
+ non_parameterized_vdis.push_back(message);
+
+ policy_table::VehicleDataItems parameterized_vdis;
+ 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);
+ ASSERT_TRUE(reps->InsertVehicleDataItem(lss));
+ parameterized_vdis.push_back(lss);
+
+ auto non_param_vdi_retrieved = reps->SelectPrimitiveVehicleDataItems();
+
+ ASSERT_EQ(non_parameterized_vdis.ToJsonValue(),
+ non_param_vdi_retrieved.ToJsonValue());
+
+ auto param_vdi_retrieved = reps->SelectCompositeVehicleDataItems();
+ ASSERT_EQ(parameterized_vdis.ToJsonValue(),
+ param_vdi_retrieved.ToJsonValue());
+}
+
// {AKozoriz} : Unknown behavior (must try 8 times, tried 2 and opened)
TEST_F(SQLPTRepresentationTest2,
DISABLED_OpenAttemptTimeOut_ExpectCorrectNumber) {
@@ -450,8 +592,8 @@ TEST_F(SQLPTRepresentationTest,
ASSERT_TRUE(reps->RefreshDB());
// Check PT structure destroyed and tables number is 0
- // There are 33 tables in the database, now.
- const int32_t total_tables_number = 33;
+ // There are 35 tables in the database, now.
+ const int32_t total_tables_number = 37;
ASSERT_EQ(total_tables_number, dbms->FetchOneInt(query_select));
const char* query_select_count_of_iap_buffer_full =
"SELECT `count_of_iap_buffer_full` FROM `usage_and_error_count`";
@@ -1644,9 +1786,11 @@ TEST_F(SQLPTRepresentationTest, Save_SetPolicyTableThenSave_ExpectSavedToPT) {
const ::policy_table::Parameters& parameters = *(rpc_iter->second.parameters);
EXPECT_EQ(1u, parameters.size());
- EXPECT_TRUE(parameters.end() != std::find(parameters.begin(),
- parameters.end(),
- policy_table::Parameter::P_SPEED));
+ EXPECT_TRUE(parameters.end() !=
+ std::find(parameters.begin(),
+ parameters.end(),
+ policy_table::EnumToJsonString(
+ policy_table::Parameter::P_SPEED)));
// Check Application Policies Section
GatherApplicationPoliciesSection(&policies);
const uint32_t apps_size = 3u;
diff --git a/src/components/policy/policy_regular/test/vehicle_data_item_type_test.cc b/src/components/policy/policy_regular/test/vehicle_data_item_type_test.cc
new file mode 100644
index 0000000000..a2f7757936
--- /dev/null
+++ b/src/components/policy/policy_regular/test/vehicle_data_item_type_test.cc
@@ -0,0 +1,250 @@
+/*
+ * 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 "gtest/gtest.h"
+#include "json/reader.h"
+#include "policy/policy_table/types.h"
+
+#include <type_traits>
+
+namespace test {
+namespace vehicle_info_plugin_test {
+
+using namespace rpc::policy_table_interface_base;
+
+namespace {
+/*
+ * class TestString should be used for compact string creation with json value
+ */
+class TestString {
+ /**
+ * @brief Field contains json structure
+ */
+ std::string text_;
+ /**
+ * @brief Need for validate should not be returned closed json or empty string
+ */
+ bool is_initialized_;
+
+ public:
+ TestString() : is_initialized_(false) {}
+
+ /**
+ * @brief This method handling all types except string
+ * the name:value will be added to json string
+ * @param std::string& name - name of json filed
+ * @param const T& value - value of json filed
+ */
+ template <class T>
+ void AddField(const std::string& name, const T& value) {
+ const bool is_bool = std::is_same<T, bool>::value;
+ // Should be writed to json true/false not 1/0
+ const std::string text_value =
+ (is_bool ? (value ? "true" : "false") : std::to_string(value));
+ if (text_.empty()) {
+ is_initialized_ = true;
+ text_ = "{\"" + name + "\":" + text_value;
+ return;
+ }
+ text_ += ",\"" + name + "\":" + text_value;
+ }
+
+ /**
+ * @brief This method handling only string values
+ * the name:"value" will be added to json string
+ * this method is coverring value in quotes
+ * @param std::string& name - name of json filed
+ * @param const T& value - value of json filed
+ */
+ void AddField(const std::string& name, const char* value) {
+ if (text_.empty()) {
+ is_initialized_ = true;
+ text_ = "{\"" + name + "\":";
+ } else {
+ text_ += ",\"" + name + "\":";
+ }
+
+ text_ += value[0] == '{' || value[0] == '['
+ ? std::string(value)
+ : "\"" + std::string(value) + "\"";
+ }
+
+ /**
+ * @brief This method close json string before return
+ * @return all string and close json form by right bracket "}"
+ * or empty string if json structure is empty
+ */
+ std::string GetValue() {
+ return is_initialized_ ? text_ + "}" : "";
+ }
+};
+
+} // namespace
+
+class VehicleDataItemTypeTest : public ::testing::Test {
+ public:
+ std::string GetFullJsonString(const std::string& params_array = "") {
+ TestString str;
+ str.AddField("name", "VehicleDataItem");
+ str.AddField("type", "String");
+ str.AddField("key", "OEMDataRef");
+ str.AddField("array", true);
+ str.AddField("mandatory", true);
+ str.AddField("params", ("[" + params_array + "]").c_str());
+ str.AddField("since", "4.0");
+ str.AddField("until", "5.0");
+ str.AddField("removed", true);
+ str.AddField("deprecated", true);
+ str.AddField("minvalue", 1);
+ str.AddField("maxvalue", 2);
+ str.AddField("minsize", 10);
+ str.AddField("maxsize", 20);
+ str.AddField("minlength", 100);
+ str.AddField("maxlength", 200);
+
+ return str.GetValue();
+ }
+
+ protected:
+ virtual void TearDown() {
+ json_.clear();
+ }
+
+ Json::Value json_;
+ Json::Reader reader_;
+};
+
+TEST_F(VehicleDataItemTypeTest, Initialize_Success) {
+ reader_.parse(GetFullJsonString(), json_);
+ VehicleDataItem vdi(&json_);
+
+ EXPECT_TRUE(vdi.is_initialized());
+}
+
+TEST_F(VehicleDataItemTypeTest, Initialize_Failed) {
+ VehicleDataItem vdi;
+
+ EXPECT_FALSE(vdi.is_initialized());
+}
+
+TEST_F(VehicleDataItemTypeTest, CheckConvertFromJsonToVehicleDataItem_Success) {
+ reader_.parse(GetFullJsonString(), json_);
+ VehicleDataItem vdi(&json_);
+
+ EXPECT_TRUE((std::string)vdi.name == "VehicleDataItem");
+ EXPECT_TRUE((std::string)vdi.type == "String");
+ EXPECT_TRUE((std::string)vdi.key == "OEMDataRef");
+ EXPECT_TRUE(*vdi.array == true);
+ EXPECT_TRUE(vdi.mandatory == true);
+ EXPECT_TRUE(vdi.params->empty());
+ EXPECT_TRUE((std::string)*vdi.since == "4.0");
+ EXPECT_TRUE((std::string)*vdi.until == "5.0");
+ EXPECT_TRUE(*vdi.removed == true);
+ EXPECT_TRUE(*vdi.deprecated == true);
+ EXPECT_TRUE(*vdi.minvalue == 1);
+ EXPECT_TRUE(*vdi.maxvalue == 2);
+ EXPECT_TRUE(*vdi.minsize == 10);
+ EXPECT_TRUE(*vdi.maxsize == 20);
+ EXPECT_TRUE(*vdi.minlength == 100);
+ EXPECT_TRUE(*vdi.maxlength == 200);
+}
+
+TEST_F(VehicleDataItemTypeTest, CheckConvertFromVehicleDataItemToJson_Success) {
+ reader_.parse(GetFullJsonString(), json_);
+ VehicleDataItem vdi(&json_);
+
+ auto jsonFrom = vdi.ToJsonValue();
+ VehicleDataItem vdi2(&jsonFrom);
+ EXPECT_TRUE(vdi == vdi2);
+}
+
+TEST_F(VehicleDataItemTypeTest, CheckIsValid_Failed) {
+ VehicleDataItem vdi;
+
+ EXPECT_FALSE(vdi.is_valid());
+}
+
+TEST_F(VehicleDataItemTypeTest, CheckIsValid_Struct_Success) {
+ reader_.parse(GetFullJsonString(GetFullJsonString()), json_);
+ VehicleDataItem vdi(&json_);
+
+ vdi.type = "Struct";
+ EXPECT_TRUE(vdi.is_valid());
+}
+
+TEST_F(VehicleDataItemTypeTest, CheckIsValid_Struct_EmptyParams_Failed) {
+ reader_.parse(GetFullJsonString(), json_);
+ VehicleDataItem vdi(&json_);
+
+ vdi.type = "Struct";
+ EXPECT_FALSE(vdi.is_valid());
+}
+
+TEST_F(VehicleDataItemTypeTest, CheckIsValid_PODTypes_Success) {
+ reader_.parse(GetFullJsonString(), json_);
+ VehicleDataItem vdi(&json_);
+
+ vdi.type = "Integer";
+ EXPECT_TRUE(vdi.is_valid());
+
+ vdi.type = "Float";
+ EXPECT_TRUE(vdi.is_valid());
+
+ vdi.type = "String";
+ EXPECT_TRUE(vdi.is_valid());
+
+ vdi.type = "Boolean";
+ EXPECT_TRUE(vdi.is_valid());
+}
+
+TEST_F(VehicleDataItemTypeTest, CheckEmptiness_True) {
+ VehicleDataItem vdi;
+ EXPECT_FALSE(vdi.struct_not_empty());
+}
+
+TEST_F(VehicleDataItemTypeTest, CheckEmptiness_False) {
+ reader_.parse(GetFullJsonString(), json_);
+
+ VehicleDataItem vdi(&json_);
+ EXPECT_TRUE(vdi.struct_not_empty());
+}
+
+TEST_F(VehicleDataItemTypeTest, CheckCopyConstructor) {
+ reader_.parse(GetFullJsonString(), json_);
+
+ VehicleDataItem vdi1(&json_);
+ VehicleDataItem vdi2(vdi1);
+
+ EXPECT_TRUE(vdi1 == vdi2);
+}
+
+} // namespace vehicle_info_plugin_test
+} // namespace test
diff --git a/src/components/rpc_base/include/rpc_base/rpc_base.h b/src/components/rpc_base/include/rpc_base/rpc_base.h
index 611c333e4d..6e06d61a7c 100644
--- a/src/components/rpc_base/include/rpc_base/rpc_base.h
+++ b/src/components/rpc_base/include/rpc_base/rpc_base.h
@@ -172,6 +172,7 @@ class Boolean : public PrimitiveType {
Boolean& operator=(bool new_val);
operator bool() const;
Json::Value ToJsonValue() const;
+ bool operator==(const Boolean& that);
private:
// Fields
@@ -233,6 +234,9 @@ class String : public PrimitiveType {
String& operator=(const std::string& new_val);
String& operator=(const String& new_val);
bool operator==(const String& rhs) const;
+ bool operator==(const std::string& rhs) const;
+ bool operator!=(const String& rhs) const;
+ bool operator!=(const std::string& rhs) const;
operator const std::string&() const;
Json::Value ToJsonValue() const;
@@ -282,6 +286,7 @@ class Array : public std::vector<T>, public CompositeType {
template <typename U>
void push_back(const U& value);
Json::Value ToJsonValue() const;
+ bool operator==(const Array& that);
virtual bool is_valid() const;
bool is_initialized() const;
@@ -395,6 +400,8 @@ class Optional {
// casted to integral types
operator const void*() const;
+ bool operator==(const Optional<T>& that);
+
bool is_valid() const;
bool is_initialized() const;
void ReportErrors(ValidationReport* report) const;
diff --git a/src/components/rpc_base/include/rpc_base/rpc_base_inl.h b/src/components/rpc_base/include/rpc_base/rpc_base_inl.h
index 985e244235..a7b477c009 100644
--- a/src/components/rpc_base/include/rpc_base/rpc_base_inl.h
+++ b/src/components/rpc_base/include/rpc_base/rpc_base_inl.h
@@ -138,6 +138,10 @@ inline Boolean::Boolean() : PrimitiveType(kUninitialized), value_(false) {}
inline Boolean::Boolean(bool value) : PrimitiveType(kValid), value_(value) {}
+inline bool Boolean::operator==(const Boolean& that) {
+ return value_ == that.value_;
+}
+
inline Boolean& Boolean::operator=(bool new_val) {
value_ = new_val;
value_state_ = kValid;
@@ -280,6 +284,21 @@ bool String<minlen, maxlen>::operator==(const String& rhs) const {
}
template <size_t minlen, size_t maxlen>
+bool String<minlen, maxlen>::operator==(const std::string& rhs) const {
+ return value_ == rhs;
+}
+
+template <size_t minlen, size_t maxlen>
+bool String<minlen, maxlen>::operator!=(const String& rhs) const {
+ return value_ != rhs.value_;
+}
+
+template <size_t minlen, size_t maxlen>
+bool String<minlen, maxlen>::operator!=(const std::string& rhs) const {
+ return value_ != rhs;
+}
+
+template <size_t minlen, size_t maxlen>
String<minlen, maxlen>::operator const std::string&() const {
return value_;
}
@@ -365,6 +384,20 @@ bool Array<T, minsize, maxsize>::is_initialized() const {
}
template <typename T, size_t minsize, size_t maxsize>
+bool Array<T, minsize, maxsize>::operator==(const Array& that) {
+ if (this->size() != that.size())
+ return false;
+
+ for (auto i = std::begin(*this), j = std::begin(that); i != std::end(*this);
+ ++i, ++j) {
+ if (!(*i == *j)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+template <typename T, size_t minsize, size_t maxsize>
void Array<T, minsize, maxsize>::ReportErrors(ValidationReport* report) const {
if (this->empty()) {
CompositeType::ReportErrors(report);
@@ -571,6 +604,11 @@ const T* Optional<T>::operator->() const {
}
template <typename T>
+bool Optional<T>::operator==(const Optional<T>& that) {
+ return value_ == that.value_;
+}
+
+template <typename T>
void Optional<T>::assign_if_valid(const Optional<T>& value) {
if (value.is_initialized()) {
value_ = value.value_;
diff --git a/src/components/rpc_base/include/rpc_base/rpc_base_json_inl.h b/src/components/rpc_base/include/rpc_base/rpc_base_json_inl.h
index 871778b29a..80e11994f1 100644
--- a/src/components/rpc_base/include/rpc_base/rpc_base_json_inl.h
+++ b/src/components/rpc_base/include/rpc_base/rpc_base_json_inl.h
@@ -164,7 +164,7 @@ Json::Value Integer<T, minval, maxval>::ToJsonValue() const {
template <int64_t minnum, int64_t maxnum, int64_t minden, int64_t maxden>
Float<minnum, maxnum, minden, maxden>::Float(const Json::Value* value)
- : PrimitiveType(InitHelper(value, &Json::Value::isDouble)), value_() {
+ : PrimitiveType(InitHelper(value, &Json::Value::isNumeric)), value_() {
if (is_valid()) {
value_ = value->asDouble();
value_state_ = range_.Includes(value_) ? kValid : kInvalid;
@@ -174,7 +174,7 @@ Float<minnum, maxnum, minden, maxden>::Float(const Json::Value* value)
template <int64_t minnum, int64_t maxnum, int64_t minden, int64_t maxden>
Float<minnum, maxnum, minden, maxden>::Float(const Json::Value* value,
double def_value)
- : PrimitiveType(InitHelper(value, &Json::Value::isDouble))
+ : PrimitiveType(InitHelper(value, &Json::Value::isNumeric))
, value_(def_value) {
if (!is_initialized()) {
value_state_ = kValid;
diff --git a/src/components/smart_objects/include/smart_objects/object_schema_item.h b/src/components/smart_objects/include/smart_objects/object_schema_item.h
index 7f51ae5678..ee42b36620 100644
--- a/src/components/smart_objects/include/smart_objects/object_schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/object_schema_item.h
@@ -45,55 +45,57 @@
namespace ns_smart_device_link {
namespace ns_smart_objects {
+
/**
- * @brief Object schema item.
+ * @brief Object member.
**/
-class CObjectSchemaItem : public ISchemaItem {
- public:
+struct SMember {
/**
- * @brief Object member.
+ * @brief Default constructor.
+ **/
+ SMember();
+ /**
+ * @brief Constructor.
+ * @param SchemaItem Member schema item.
+ * @param IsMandatory true if member is mandatory, false
+ * otherwise. Defaults to true.
**/
- struct SMember {
- /**
- * @brief Default constructor.
- **/
- SMember();
- /**
- * @brief Constructor.
- * @param SchemaItem Member schema item.
- * @param IsMandatory true if member is mandatory, false
- * otherwise. Defaults to true.
- **/
- SMember(const ISchemaItemPtr SchemaItem,
- const bool IsMandatory = true,
- const std::string& Since = "",
- const std::string& Until = "",
- const bool IsDeprecated = false,
- const bool IsRemoved = false,
- const std::vector<CObjectSchemaItem::SMember>& history_vector = {});
- /**
- * @brief Checks the version a parameter was removed (until)
- * If the mobile's msg version is greater than or
- **/
- bool CheckHistoryFieldVersion(
- const utils::SemanticVersion& MessageVersion) const;
+ SMember(const ISchemaItemPtr SchemaItem,
+ const bool IsMandatory = true,
+ const std::string& Since = "",
+ const std::string& Until = "",
+ const bool IsDeprecated = false,
+ const bool IsRemoved = false,
+ const std::vector<SMember>& history_vector = {});
+ /**
+ * @brief Checks the version a parameter was removed (until)
+ * If the mobile's msg version is greater than or
+ **/
+ bool CheckHistoryFieldVersion(
+ const utils::SemanticVersion& MessageVersion) const;
+
+ /**
+ * @brief Member schema item.
+ **/
+ ISchemaItemPtr mSchemaItem;
+ /**
+ * @brief true if member is mandatory, false otherwise.
+ **/
+ bool mIsMandatory;
+ boost::optional<utils::SemanticVersion> mSince;
+ boost::optional<utils::SemanticVersion> mUntil;
+ bool mIsDeprecated;
+ bool mIsRemoved;
+ std::vector<SMember> mHistoryVector;
+};
+typedef std::map<std::string, SMember> Members;
- /**
- * @brief Member schema item.
- **/
- ISchemaItemPtr mSchemaItem;
- /**
- * @brief true if member is mandatory, false otherwise.
- **/
- bool mIsMandatory;
- boost::optional<utils::SemanticVersion> mSince;
- boost::optional<utils::SemanticVersion> mUntil;
- bool mIsDeprecated;
- bool mIsRemoved;
- std::vector<CObjectSchemaItem::SMember> mHistoryVector;
- };
- typedef std::map<std::string, SMember> Members;
+/**
+ * @brief Object schema item.
+ **/
+class CObjectSchemaItem : public ISchemaItem {
+ public:
/**
* @brief Create a new schema item.
*
@@ -153,6 +155,12 @@ class CObjectSchemaItem : public ISchemaItem {
*/
size_t GetMemberSize() OVERRIDE;
+ boost::optional<SMember&> GetMemberSchemaItem(
+ const std::string& member_key) OVERRIDE;
+
+ void AddMemberSchemaItem(const std::string& member_key,
+ SMember& member) OVERRIDE;
+
protected:
/**
* @brief Constructor.
@@ -173,14 +181,14 @@ class CObjectSchemaItem : public ISchemaItem {
* @param member Schema member
* @param MmessageVersion Semantic Version of mobile message.
**/
- const CObjectSchemaItem::SMember& GetCorrectMember(
- const SMember& member, const utils::SemanticVersion& messageVersion);
+ const SMember& GetCorrectMember(const SMember& member,
+ const utils::SemanticVersion& messageVersion);
/**
* @brief Map of member name to SMember structure describing the object
*member.
**/
- const Members mMembers;
+ Members mMembers;
DISALLOW_COPY_AND_ASSIGN(CObjectSchemaItem);
};
} // namespace ns_smart_objects
diff --git a/src/components/smart_objects/include/smart_objects/schema_item.h b/src/components/smart_objects/include/smart_objects/schema_item.h
index fa5f6d3adc..9c29e66f36 100644
--- a/src/components/smart_objects/include/smart_objects/schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/schema_item.h
@@ -40,12 +40,14 @@
#include <memory>
#include <vector>
+#include "boost/optional/optional.hpp"
#include "utils/macro.h"
#include "utils/semantic_version.h"
namespace ns_smart_device_link {
namespace ns_smart_objects {
class SmartObject;
+class SMember;
/**
* @brief Base schema item.
@@ -123,6 +125,17 @@ class ISchemaItem {
virtual void BuildObjectBySchema(const SmartObject& pattern_object,
SmartObject& result_object);
+ virtual boost::optional<SMember&> GetMemberSchemaItem(
+ const std::string& member_key) {
+ UNUSED(member_key);
+ return boost::optional<SMember&>();
+ }
+
+ virtual void AddMemberSchemaItem(const std::string& member_key,
+ SMember& member) {
+ UNUSED(member_key);
+ UNUSED(member);
+ }
/**
* @brief Get value param, depends of children
*
diff --git a/src/components/smart_objects/include/smart_objects/smart_schema.h b/src/components/smart_objects/include/smart_objects/smart_schema.h
index 936f49c11e..8cbafa53b2 100644
--- a/src/components/smart_objects/include/smart_objects/smart_schema.h
+++ b/src/components/smart_objects/include/smart_objects/smart_schema.h
@@ -86,6 +86,13 @@ class CSmartSchema FINAL {
void setSchemaItem(const ISchemaItemPtr SchemaItem);
/**
+ * @brief Set new root schema item.
+ *
+ * @param SchemaItem Root schema item.
+ */
+ ISchemaItemPtr getSchemaItem();
+
+ /**
* @brief Apply schema.
*
* @param Object Object to apply schema.
diff --git a/src/components/smart_objects/src/object_schema_item.cc b/src/components/smart_objects/src/object_schema_item.cc
index be1c73fb85..01e4ec46e0 100644
--- a/src/components/smart_objects/src/object_schema_item.cc
+++ b/src/components/smart_objects/src/object_schema_item.cc
@@ -44,20 +44,19 @@ const char app_id[] = "appID";
namespace ns_smart_device_link {
namespace ns_smart_objects {
-CObjectSchemaItem::SMember::SMember()
+SMember::SMember()
: mSchemaItem(CAlwaysFalseSchemaItem::create())
, mIsMandatory(true)
, mIsDeprecated(false)
, mIsRemoved(false) {}
-CObjectSchemaItem::SMember::SMember(
- const ISchemaItemPtr SchemaItem,
- const bool IsMandatory,
- const std::string& Since,
- const std::string& Until,
- const bool IsDeprecated,
- const bool IsRemoved,
- const std::vector<CObjectSchemaItem::SMember>& history_vector)
+SMember::SMember(const ISchemaItemPtr SchemaItem,
+ const bool IsMandatory,
+ const std::string& Since,
+ const std::string& Until,
+ const bool IsDeprecated,
+ const bool IsRemoved,
+ const std::vector<SMember>& history_vector)
: mSchemaItem(SchemaItem), mIsMandatory(IsMandatory) {
if (Since.size() > 0) {
utils::SemanticVersion since_struct(Since);
@@ -76,7 +75,7 @@ CObjectSchemaItem::SMember::SMember(
mHistoryVector = history_vector;
}
-bool CObjectSchemaItem::SMember::CheckHistoryFieldVersion(
+bool SMember::CheckHistoryFieldVersion(
const utils::SemanticVersion& MessageVersion) const {
if (MessageVersion.isValid()) {
if (mSince != boost::none) {
@@ -153,6 +152,7 @@ errors::eType CObjectSchemaItem::validate(
}
object_keys.erase(key_it);
}
+
return errors::OK;
}
@@ -169,10 +169,10 @@ void CObjectSchemaItem::applySchema(
}
SmartObject default_value;
- for (Members::const_iterator it = mMembers.begin(); it != mMembers.end();
- ++it) {
- const std::string& key = it->first;
- const SMember& member = it->second;
+
+ for (const auto& item : mMembers) {
+ const std::string& key = item.first;
+ const SMember& member = item.second;
if (!Object.keyExists(key)) {
if (member.mSchemaItem->setDefaultValue(default_value)) {
Object[key] = default_value;
@@ -201,7 +201,6 @@ void CObjectSchemaItem::unapplySchema(SmartObject& Object,
Object.erase(key);
}
}
-
for (Members::const_iterator it = mMembers.begin(); it != mMembers.end();
++it) {
const std::string& key = it->first;
@@ -232,6 +231,21 @@ size_t CObjectSchemaItem::GetMemberSize() {
return mMembers.size();
}
+boost::optional<SMember&> CObjectSchemaItem::GetMemberSchemaItem(
+ const std::string& member_key) {
+ auto it = mMembers.find(member_key);
+
+ if (it != mMembers.end()) {
+ return boost::optional<SMember&>(it->second);
+ }
+ return boost::optional<SMember&>();
+}
+
+void CObjectSchemaItem::AddMemberSchemaItem(const std::string& member_key,
+ SMember& member) {
+ mMembers[member_key] = member;
+}
+
CObjectSchemaItem::CObjectSchemaItem(const Members& members)
: mMembers(members) {}
@@ -260,7 +274,7 @@ void CObjectSchemaItem::RemoveFakeParams(
}
}
-const CObjectSchemaItem::SMember& CObjectSchemaItem::GetCorrectMember(
+const SMember& CObjectSchemaItem::GetCorrectMember(
const SMember& member, const utils::SemanticVersion& messageVersion) {
// Check if member is the correct version
if (member.CheckHistoryFieldVersion(messageVersion)) {
diff --git a/src/components/smart_objects/src/smart_schema.cc b/src/components/smart_objects/src/smart_schema.cc
index 4ab5e5ff23..6107d19266 100644
--- a/src/components/smart_objects/src/smart_schema.cc
+++ b/src/components/smart_objects/src/smart_schema.cc
@@ -53,6 +53,10 @@ void CSmartSchema::setSchemaItem(const ISchemaItemPtr schemaItem) {
mSchemaItem = schemaItem;
}
+ISchemaItemPtr CSmartSchema::getSchemaItem() {
+ return mSchemaItem;
+}
+
void CSmartSchema::applySchema(SmartObject& Object,
const bool remove_unknown_parameters,
const utils::SemanticVersion& MessageVersion) {
diff --git a/src/components/smart_objects/test/CObjectSchemaItem_test.cc b/src/components/smart_objects/test/CObjectSchemaItem_test.cc
index 51085040c5..8a7d09f31e 100644
--- a/src/components/smart_objects/test/CObjectSchemaItem_test.cc
+++ b/src/components/smart_objects/test/CObjectSchemaItem_test.cc
@@ -117,28 +117,27 @@ class ObjectSchemaItemTest : public ::testing::Test {
resultCode_values.insert(ResultType::GENERIC_ERROR);
resultCode_values.insert(ResultType::DISALLOWED);
- CObjectSchemaItem::Members paramsMembersMap;
- paramsMembersMap[S_FUNCTION_ID] = CObjectSchemaItem::SMember(
+ Members paramsMembersMap;
+ paramsMembersMap[S_FUNCTION_ID] = SMember(
TEnumSchemaItem<FunctionID::eType>::create(function_values), true);
paramsMembersMap[S_CORRELATION_ID] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
- paramsMembersMap[S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(TSchemaItemParameter<int>(1),
- TSchemaItemParameter<int>(2)),
- true);
-
- CObjectSchemaItem::Members schemaMembersMap;
- schemaMembersMap[Keys::RESULT_CODE] = CObjectSchemaItem::SMember(
+ SMember(TNumberSchemaItem<int>::create(), true);
+ paramsMembersMap[S_PROTOCOL_VERSION] =
+ SMember(TNumberSchemaItem<int>::create(TSchemaItemParameter<int>(1),
+ TSchemaItemParameter<int>(2)),
+ true);
+
+ Members schemaMembersMap;
+ schemaMembersMap[Keys::RESULT_CODE] = SMember(
TEnumSchemaItem<ResultType::eType>::create(resultCode_values), false);
- schemaMembersMap[Keys::INFO] = CObjectSchemaItem::SMember(
- CStringSchemaItem::create(TSchemaItemParameter<size_t>(0),
- TSchemaItemParameter<size_t>(10)),
- false);
- schemaMembersMap[Keys::SUCCESS] =
- CObjectSchemaItem::SMember(CBoolSchemaItem::create(), false);
+ schemaMembersMap[Keys::INFO] =
+ SMember(CStringSchemaItem::create(TSchemaItemParameter<size_t>(0),
+ TSchemaItemParameter<size_t>(10)),
+ false);
+ schemaMembersMap[Keys::SUCCESS] = SMember(CBoolSchemaItem::create(), false);
// Create fake param that has breaking history changes
- std::vector<CObjectSchemaItem::SMember> fake_param_history_vector;
+ std::vector<SMember> fake_param_history_vector;
std::shared_ptr<ISchemaItem> fake_param_SchemaItem =
CArraySchemaItem::create(
@@ -156,22 +155,21 @@ class ObjectSchemaItemTest : public ::testing::Test {
TSchemaItemParameter<size_t>(1),
TSchemaItemParameter<size_t>(100));
- fake_param_history_vector.push_back(CObjectSchemaItem::SMember(
+ fake_param_history_vector.push_back(SMember(
fake_param_history_v1_SchemaItem, true, "", "4.5.0", false, false));
- schemaMembersMap["fakeParam"] =
- CObjectSchemaItem::SMember(fake_param_SchemaItem,
- false,
- "4.5.0",
- "",
- false,
- false,
- fake_param_history_vector);
-
- CObjectSchemaItem::Members rootMembersMap;
- rootMembersMap[S_PARAMS] = CObjectSchemaItem::SMember(
- CObjectSchemaItem::create(paramsMembersMap), true);
- rootMembersMap[S_MSG_PARAMS] = CObjectSchemaItem::SMember(
- CObjectSchemaItem::create(schemaMembersMap), true);
+ schemaMembersMap["fakeParam"] = SMember(fake_param_SchemaItem,
+ false,
+ "4.5.0",
+ "",
+ false,
+ false,
+ fake_param_history_vector);
+
+ Members rootMembersMap;
+ rootMembersMap[S_PARAMS] =
+ SMember(CObjectSchemaItem::create(paramsMembersMap), true);
+ rootMembersMap[S_MSG_PARAMS] =
+ SMember(CObjectSchemaItem::create(schemaMembersMap), true);
schema_item = CObjectSchemaItem::create(rootMembersMap);
}
diff --git a/src/components/smart_objects/test/SmartObjectConvertionTime_test.cc b/src/components/smart_objects/test/SmartObjectConvertionTime_test.cc
index edcb09c604..555239c489 100644
--- a/src/components/smart_objects/test/SmartObjectConvertionTime_test.cc
+++ b/src/components/smart_objects/test/SmartObjectConvertionTime_test.cc
@@ -252,21 +252,20 @@ class SmartObjectConvertionTimeTest : public ::testing::Test {
TEnumSchemaItem<MessageTypeTest::eType>::create(
messageType_allowedEnumSubsetValues);
- CObjectSchemaItem::Members paramsMembersMap;
+ Members paramsMembersMap;
paramsMembersMap
[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] =
- CObjectSchemaItem::SMember(functionId_SchemaItem, true);
+ SMember(functionId_SchemaItem, true);
paramsMembersMap
[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] =
- CObjectSchemaItem::SMember(messageType_SchemaItem, true);
+ SMember(messageType_SchemaItem, true);
paramsMembersMap
[ns_smart_device_link::ns_json_handler::strings::S_CORRELATION_ID] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ SMember(TNumberSchemaItem<int>::create(), true);
- std::map<std::string, CObjectSchemaItem::SMember> rootMembersMap;
+ std::map<std::string, SMember> rootMembersMap;
rootMembersMap[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] =
- CObjectSchemaItem::SMember(CObjectSchemaItem::create(paramsMembersMap),
- true);
+ SMember(CObjectSchemaItem::create(paramsMembersMap), true);
return CSmartSchema(CObjectSchemaItem::create(rootMembersMap));
}
@@ -318,51 +317,43 @@ class SmartObjectConvertionTimeTest : public ::testing::Test {
TSchemaItemParameter<int>(2000000000),
TSchemaItemParameter<int>());
- std::map<std::string, CObjectSchemaItem::SMember> schemaMembersMap;
+ std::map<std::string, SMember> schemaMembersMap;
- schemaMembersMap["success"] =
- CObjectSchemaItem::SMember(success_SchemaItem, true);
- schemaMembersMap["resultCode"] =
- CObjectSchemaItem::SMember(resultCode_SchemaItem, true);
- schemaMembersMap["info"] =
- CObjectSchemaItem::SMember(info_SchemaItem, false);
- schemaMembersMap["tryAgainTime"] =
- CObjectSchemaItem::SMember(tryAgainTime_SchemaItem, true);
+ schemaMembersMap["success"] = SMember(success_SchemaItem, true);
+ schemaMembersMap["resultCode"] = SMember(resultCode_SchemaItem, true);
+ schemaMembersMap["info"] = SMember(info_SchemaItem, false);
+ schemaMembersMap["tryAgainTime"] = SMember(tryAgainTime_SchemaItem, true);
- std::map<std::string, CObjectSchemaItem::SMember> paramsMembersMap;
+ std::map<std::string, SMember> paramsMembersMap;
paramsMembersMap
[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] =
- CObjectSchemaItem::SMember(
- TEnumSchemaItem<FunctionIdTest::eType>::create(
- functionId_allowedEnumSubsetValues),
- true);
+ SMember(TEnumSchemaItem<FunctionIdTest::eType>::create(
+ functionId_allowedEnumSubsetValues),
+ true);
paramsMembersMap
[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] =
- CObjectSchemaItem::SMember(
- TEnumSchemaItem<MessageTypeTest::eType>::create(
- messageType_allowedEnumSubsetValues),
- true);
+ SMember(TEnumSchemaItem<MessageTypeTest::eType>::create(
+ messageType_allowedEnumSubsetValues),
+ true);
paramsMembersMap
[ns_smart_device_link::ns_json_handler::strings::S_CORRELATION_ID] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ SMember(TNumberSchemaItem<int>::create(), true);
paramsMembersMap
[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] =
- CObjectSchemaItem::SMember(
+ SMember(
TNumberSchemaItem<int>::create(TSchemaItemParameter<int>(1),
TSchemaItemParameter<int>(2)),
true);
paramsMembersMap
[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ SMember(TNumberSchemaItem<int>::create(), true);
- std::map<std::string, CObjectSchemaItem::SMember> rootMembersMap;
+ std::map<std::string, SMember> rootMembersMap;
rootMembersMap
[ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS] =
- CObjectSchemaItem::SMember(
- CObjectSchemaItem::create(schemaMembersMap), true);
+ SMember(CObjectSchemaItem::create(schemaMembersMap), true);
rootMembersMap[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] =
- CObjectSchemaItem::SMember(CObjectSchemaItem::create(paramsMembersMap),
- true);
+ SMember(CObjectSchemaItem::create(paramsMembersMap), true);
return CSmartSchema(CObjectSchemaItem::create(rootMembersMap));
}
};
diff --git a/tools/InterfaceGenerator/Generator.py b/tools/InterfaceGenerator/Generator.py
index 932620c153..905b0754b3 100755
--- a/tools/InterfaceGenerator/Generator.py
+++ b/tools/InterfaceGenerator/Generator.py
@@ -26,6 +26,7 @@ import generator.parsers.SDLRPCV2
import generator.parsers.JSONRPC
import generator.generators.SmartFactorySDLRPC
import generator.generators.SmartFactoryJSONRPC
+import generator.generators.PolicyTypes
import MsgVersionGenerate
from generator.parsers.RPCBase import ParseError
@@ -37,7 +38,11 @@ SUPPORTED_FORMATS = {
"sdlrpcv2": (generator.parsers.SDLRPCV2.Parser,
generator.generators.SmartFactorySDLRPC.CodeGenerator),
"jsonrpc": (generator.parsers.JSONRPC.Parser,
- generator.generators.SmartFactoryJSONRPC.CodeGenerator)
+ generator.generators.SmartFactoryJSONRPC.CodeGenerator),
+ "mobile-policy-types": (generator.parsers.SDLRPCV2.Parser,
+ generator.generators.PolicyTypes.CodeGenerator),
+ "hmi-policy-types": (generator.parsers.JSONRPC.Parser,
+ generator.generators.PolicyTypes.CodeGenerator)
}
diff --git a/tools/InterfaceGenerator/generator/generators/PolicyTypes.py b/tools/InterfaceGenerator/generator/generators/PolicyTypes.py
new file mode 100644
index 0000000000..2621950e7a
--- /dev/null
+++ b/tools/InterfaceGenerator/generator/generators/PolicyTypes.py
@@ -0,0 +1,691 @@
+"""SmartFactory code generator base.
+
+Base of code generator for SmartFactory that provides SmartSchema object in
+accordance with given internal model.
+
+"""
+# pylint: disable=W0402
+# pylint: disable=C0302
+import codecs
+import collections
+import os
+import string
+import uuid
+import re
+
+from generator import Model
+
+
+class GenerateError(Exception):
+
+ """Generate error.
+
+ This exception is raised when generator is unable to create
+ output from given model.
+
+ """
+
+ pass
+
+def to_camel_case(snake_str):
+ components = snake_str.split('_')
+ return components[0].lower() + "".join(x.title() for x in components[1:])
+
+def to_snake_case(camel_str):
+ s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', camel_str)
+ return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1)
+
+class CodeGenerator(object):
+
+ """Base PolicyTypes generator.
+
+ This class provides service which allows to generate *.h files with types required for Policy
+
+ """
+
+ def __init__(self):
+ """Construct new object."""
+
+ self._generated_structs = []
+ self._structs_add_code = u""
+
+ def generate_vehicledatatype_names(self, enum):
+ template = string.Template('''static std::set<std::string> ${enum_name}_enum_names = { \n${values}\n};\n''')
+ enum_element_name = lambda enum_element: enum_element.internal_name if enum_element.internal_name else enum_element.name
+ values = ", \n".join([" \"{}\"".format(enum_element_name(enum_element)) for enum_element in enum.elements.values()])
+ return template.substitute(enum_name=enum.name, values = values)
+
+ def generate_all_enum_values(self, enum):
+ template = string.Template('''static std::set<mobile_apis::${enum_name}::eType> ${enum_name}_all_enum_values = { \n${values}\n};\n''')
+ enum_element_name = lambda enum_element: enum_element.internal_name if enum_element.internal_name else enum_element.name
+ values = ", \n".join([" mobile_apis::{}::{}".format(enum.name, enum_element_name(enum_element)) for enum_element in enum.elements.values()])
+ return template.substitute(enum_name=enum.name, values = values)
+
+ def generate_enums_schema_factory_content(self, enums):
+ return "\n".join([self._enum_factory_element_template.substitute(enum_name = enum.name) for enum in enums])
+
+ def generate_enums_schema_factory_impl(self, enums):
+ enums_values = ""
+ for enum in enums:
+ enums_values += "\n".join([self.generate_all_enum_values(enum)])
+ if enum.name == "VehicleDataType":
+ enums_values += "\n".join([self.generate_vehicledatatype_names(enum)])
+ return self._enum_factory_template.substitute(enums_values = enums_values,
+ enum_factory_content = self.generate_enums_schema_factory_content(enums))
+
+ def generate_POD_types_schema_factory_impl(self, enums):
+ pod_types = {
+ "Integer" : "int32_t",
+ "Float" : "double",
+ }
+ '''if (enum_name == "DriverDistractionState") {
+ return Get<mobile_apis::DriverDistractionState::eType>(DriverDistractionState_all_enum_values);
+ }'''
+ enums_values = "\n".join([self.generate_all_enum_values(enum) for enum in enums])
+ return self._enum_factory_template.substitute(enums_values = enums_values,
+ enum_factory_content = self.generate_enums_schema_factory_content(enums))
+
+ def generate(self, interface, filename, namespace, destination_dir):
+ """ Generate SmartFactory source files.
+
+ Generates source code files at destination directory in
+ accordance with given model in specified namespace.
+
+ Keyword arguments:
+ interface -- model of the interface to generate source code for.
+ filename -- name of initial XML file.
+ namespace -- name of destination namespace.
+ destination_dir -- directory to create source files.
+
+ """
+
+ if interface is None:
+ raise GenerateError("Given interface is None.")
+
+ params_set = set()
+ for func in interface.functions.values():
+ for param in func.params:
+ params_set.add(param)
+ parameter_enum = Model.Enum('Parameter')
+
+ for item in params_set:
+ parameter_enum.elements[item.upper()] = Model.EnumElement(item)
+
+
+ required_enums_for_policy = [
+ "HMILevel",
+ "FunctionID",
+ "HybridAppPreference",
+ "AppHMIType",
+ "RequestType",
+ "ModuleType",
+ "Common_AppPriority",
+ "Parameter"
+ ]
+
+ self.required_empty_value = [
+ "RequestType",
+ "ModuleType",
+ "Parameter"
+ ]
+
+ self.enum_items_naming_conversion_ = {
+ "HMILevel" : lambda item_name : "HL_" + item_name.replace("HMI_", ""),
+ "AppHMIType" : lambda item_name : "AHT_" + item_name,
+ "FunctionID" : lambda item_name : item_name,
+ "HybridAppPreference" : lambda item_name : item_name,
+ "RequestType" : lambda item_name : "RT_" + item_name,
+ "ModuleType" : lambda item_name : "MT_" + item_name,
+ "Common_AppPriority" : lambda item_name : "P_" + item_name if not item_name == "VOICE_COMMUNICATION" else "P_VOICECOM",
+ "Parameter" : lambda item_name : "P_" + to_snake_case(item_name).upper()
+ }
+
+ self.enum_items_string_naming_conversion_ = {
+ "HMILevel" : lambda item_name : item_name,
+ "AppHMIType" : lambda item_name : item_name,
+ "FunctionID" : lambda item_name : item_name[:item_name.rfind("ID")],
+ "HybridAppPreference" : lambda item_name : item_name,
+ "RequestType" : lambda item_name : item_name,
+ "ModuleType" : lambda item_name : item_name,
+ "Common_AppPriority" : lambda item_name : item_name if not item_name == "VOICE_COMMUNICATION" else "VOICECOM",
+ "Parameter" : lambda item_name : item_name
+ }
+
+ self.enum_naming_conversion_ = {
+ "HMILevel" : "HmiLevel",
+ "AppHMIType" : "AppHMIType",
+ "FunctionID" : "FunctionID",
+ "HybridAppPreference" : "HybridAppPreference",
+ "RequestType" : "RequestType",
+ "ModuleType" : "ModuleType",
+ "Common_AppPriority" : "Priority",
+ "Parameter" : "Parameter"
+ }
+
+ get_first_enum_value_name = lambda enum : enum.elements.values()[0].name
+ enum_required_for_policy = lambda enum : enum.name in required_enums_for_policy and "." not in get_first_enum_value_name(enum)
+
+ # In case if "." is in FunctionID name this is HMI_API function ID and should not be included in Policy enums
+
+ required_enum_values = [val for val in interface.enums.values()
+ if enum_required_for_policy(val)]
+
+ if filename == "MOBILE_API":
+ self._write_cc_with_enum_schema_factory(filename, namespace, destination_dir, interface.enums.values())
+
+ # Params should be generated as enum for MOBILE_API to validate RPCSpec parameters
+ required_enum_values.append(parameter_enum)
+
+ self._write_header_with_enums(filename, namespace, destination_dir, required_enum_values)
+ self._write_cc_with_enums(filename, namespace, destination_dir, required_enum_values)
+
+ def _write_cc_with_enum_schema_factory(self,filename, namespace, destination_dir, required_enum_values):
+ class_name = u"generated_{0}_enum_schema_factory".format(filename)
+ header_file_name = '''policy/policy_table/policy_enum_schema_factory.h'''
+ cc_file_name = u"".join("{0}.cc".format(class_name))
+ if not os.path.exists(destination_dir):
+ os.makedirs(destination_dir)
+ print(os.path.join(destination_dir, cc_file_name))
+ with codecs.open(os.path.join(destination_dir, cc_file_name),
+ encoding="utf-8",
+ mode="w") as f_cc:
+ guard = u"_{0}_{1}_CC__".format( class_name.upper(),
+ unicode(uuid.uuid1().hex.capitalize()))
+ namespace_open, namespace_close = self._namespaces_strings(namespace)
+ includes = '''#include <set>\n'''\
+ '''#include "interfaces/MOBILE_API.h"\n'''\
+ '''#include "smart_objects/enum_schema_item.h"\n'''
+ f_cc.write(self._cc_file_template.substitute(
+ class_name=class_name,
+ header_file=header_file_name,
+ includes = includes,
+ namespace_open=namespace_open,
+ enums_content=self.generate_enums_schema_factory_impl(required_enum_values),
+ namespace_close=namespace_close))
+
+ def _write_header_with_enums(self,filename, namespace, destination_dir, required_enum_values):
+ class_name = u"generated_{0}_policy_types".format(filename)
+ header_file_name = u"".join("{0}.h".format(class_name))
+ if not os.path.exists(destination_dir):
+ os.makedirs(destination_dir)
+ with codecs.open(os.path.join(destination_dir, header_file_name),
+ encoding="utf-8",
+ mode="w") as f_h:
+ guard = u"_{0}_{1}_H__".format( class_name.upper(),
+ unicode(uuid.uuid1().hex.capitalize()))
+ namespace_open, namespace_close = self._namespaces_strings(namespace)
+ f_h.write(self._h_file_template.substitute(
+ class_name=class_name,
+ guard=guard,
+ includes="",
+ namespace_open=namespace_open,
+ enums_content=self._gen_enums(required_enum_values
+ ),
+ namespace_close=namespace_close))
+
+ def _write_cc_with_enums(self,filename, namespace, destination_dir, required_enum_values):
+ class_name = u"generated_{0}_policy_types".format(filename)
+ header_file_name = u"".join("{0}.h".format(class_name))
+ cc_file_name = u"".join("{0}.cc".format(class_name))
+ if not os.path.exists(destination_dir):
+ os.makedirs(destination_dir)
+ with codecs.open(os.path.join(destination_dir, cc_file_name),
+ encoding="utf-8",
+ mode="w") as f_cc:
+ guard = u"_{0}_{1}_CC__".format( class_name.upper(),
+ unicode(uuid.uuid1().hex.capitalize()))
+ namespace_open, namespace_close = self._namespaces_strings(namespace)
+ f_cc.write(self._cc_file_template.substitute(
+ class_name=class_name,
+ header_file=header_file_name,
+ includes="",
+ namespace_open=namespace_open,
+ enums_content=self.gen_enums_processing(required_enum_values
+ ),
+ namespace_close=namespace_close))
+
+ def _namespaces_strings(self, namespace):
+
+ """ Generate open and close namespaces strings
+
+ Generates source code for opening and close namespaces
+
+ Keyword arguments:
+ namespace -- name of destination namespace.
+
+ Returns:
+ Tuple with namespace open string and namespace close string
+ """
+
+ namespace = unicode(namespace)
+ namespace_open = u""
+ namespace_close = u""
+ if namespace:
+ parts = namespace.split(u"::")
+ for part in parts:
+ namespace_open = u"".join(
+ [namespace_open,
+ self._namespace_open_template.substitute(name=part)])
+ namespace_close = u"".join(
+ [namespace_close,
+ "}} // {0}\n".format(part)])
+
+ return namespace_open, namespace_close
+
+
+ def _gen_enums(self, enums):
+ """Generate enums for header file.
+
+ Generates declaration of enumerations for the header file.
+
+ Keyword arguments:
+ enums -- list of enums to generate.
+
+ Returns:
+ String with enums declaration source code.
+
+ """
+
+ if enums is None:
+ raise GenerateError("Enums is None")
+
+ return u"\n".join([self._gen_enum(x) for x in enums])
+
+ def _gen_enum(self, enum):
+ """Generate enum for header file.
+
+ Generates declaration of enumeration for the header file.
+
+ Keyword arguments:
+ enum -- enum to generate.
+
+ Returns:
+ String with enum declaration source code.
+
+ """
+
+ enum_elements = enum.elements.values()
+ return self._enum_template.substitute(
+ comment=self._gen_comment(enum),
+ name=self.enum_naming_conversion_[enum.name],
+ enum_items=self._indent_code(self._gen_enum_elements(
+ enum_elements, enum.name), 1))
+
+ def _gen_enum_elements(self, enum_elements, enum_name):
+ """Generate enum elements for header file.
+
+ Generates declaration of enumeration elements for the header file.
+
+ Keyword arguments:
+ enum_elements -- list of enum elements to generate.
+
+ Returns:
+ String with enum elements declaration source code.
+
+ """
+ enum_elements = [self._gen_enum_element(x, enum_name)
+ for x in enum_elements]
+ if (enum_name in self.required_empty_value):
+ enum_elements.append(self._gen_empty_enum_element(enum_name))
+ return u",\n\n".join(enum_elements)
+
+ def _gen_empty_enum_element(self, enum_name) :
+ return self._enum_element_with_value_template.substitute(
+ comment="",
+ name=self.enum_items_naming_conversion_[enum_name]("EMPTY"),
+ value=-1)
+
+ def _gen_enum_element(self, enum_element, enum_name):
+ """Generate enum element for header file.
+
+ Generates declaration of enumeration element for the header file.
+
+ Keyword arguments:
+ enum_element -- enum element to generate.
+
+ Returns:
+ String with enum element declaration source code.
+
+ """
+
+ if enum_element.value is not None:
+ return self._enum_element_with_value_template.substitute(
+ comment=self._gen_comment(enum_element),
+ name=self.enum_items_naming_conversion_[enum_name](enum_element.primary_name),
+ value=enum_element.value)
+ else:
+ return self._enum_element_with_no_value_template.substitute(
+ comment=self._gen_comment(enum_element),
+ name=self.enum_items_naming_conversion_[enum_name](enum_element.primary_name))
+
+ def gen_enums_processing(self, enums):
+ validation = "\n".join([self._gen_enum_validation(enum) for enum in enums])
+ to_json = "\n".join([self._gen_enum_to_json(enum) for enum in enums])
+ from_json = "\n".join([self._gen_enum_from_json(enum) for enum in enums])
+ return "\n".join([validation, to_json, from_json])
+
+ def _gen_enum_validation(self, enum):
+ return self._valiation_enum_template.substitute(
+ name = self.enum_naming_conversion_[enum.name],
+ enum_items = "\n".join([self._gen_enum_item_validation(enum_item.name, enum.name) for enum_item in enum.elements.values()])
+ )
+
+ def _gen_enum_item_validation(self, item_name, enum_name):
+ return self._valiation_enum_item_template.substitute(
+ name = self.enum_items_naming_conversion_[enum_name](item_name))
+
+ def _gen_enum_to_json(self, enum):
+ name = self.enum_naming_conversion_[enum.name]
+ enum_items = "\n".join([self._gen_enum_item_to_json(enum_item.name, enum.name) for enum_item in enum.elements.values()])
+ if (enum.name in self.required_empty_value):
+ enum_items+= "\n" + self._gen_enum_item_to_json("EMPTY", enum.name)
+ return self._enum_to_json_template.substitute(
+ name = name,
+ enum_items = enum_items
+ )
+
+ def _gen_enum_item_to_json(self, item_name, enum_name):
+ return self._enum_to_json_item_template.substitute(
+ name = self.enum_items_naming_conversion_[enum_name](item_name),
+ string_name = self.enum_items_string_naming_conversion_[enum_name](item_name)
+ )
+
+
+ def _gen_enum_from_json(self, enum):
+ name = self.enum_naming_conversion_[enum.name]
+ enum_items = "\n".join([self._gen_enum_item_from_json(enum_item.name, enum.name) for enum_item in enum.elements.values()])
+ if (enum.name in self.required_empty_value):
+ enum_items += "\n" + self._gen_enum_item_from_json("EMPTY", enum.name)
+ return self._enum_from_json_template.substitute(
+ name = name,
+ enum_items = enum_items
+ )
+
+ def _gen_enum_item_from_json(self, item_name, enum_name):
+ return self._enum_from_json_item_template.substitute(
+ name = self.enum_items_naming_conversion_[enum_name](item_name),
+ string_name = self.enum_items_string_naming_conversion_[enum_name](item_name)
+ )
+
+ def _gen_comment(self, interface_item_base, use_doxygen=True):
+ """Generate doxygen comment for iterface_item_base for header file.
+
+ Generates doxygen comment for any iterface_item_base for the header
+ file.
+
+ Keyword arguments:
+ interface_item_base -- object to generate doxygen comment for.
+ use_doxygen -- Flag that indicates does function uses doxygen or not.
+
+ Returns:
+ String with generated doxygen comment.
+
+ """
+
+ brief_type_title = None
+ interface_item_base_classname = interface_item_base.__class__.__name__
+ if interface_item_base_classname in self._model_types_briefs:
+ brief_type_title = \
+ self._model_types_briefs[interface_item_base_classname]
+ else:
+ raise GenerateError("Unable to create comment for unknown type " +
+ interface_item_base_classname)
+
+ name = interface_item_base.primary_name if \
+ type(interface_item_base) is Model.EnumElement else \
+ interface_item_base.name
+ brief_description = (u" * @brief {0}{1}.\n" if use_doxygen is
+ True else u"// {0}{1}.\n").format(
+ brief_type_title,
+ name)
+
+ description = u"".join([(u" * {0}\n" if use_doxygen
+ is True else u"// {0}\n").format(x)
+ for x in self._normalize_multiline_comments(
+ interface_item_base.description)])
+ if description is not u"":
+ description = u"".join([u" *\n" if use_doxygen
+ is True else u"//\n", description])
+
+ design_description = u"".join([(u" * {0}\n" if use_doxygen is
+ True else u"// {0}\n").format(x)
+ for x in
+ self._normalize_multiline_comments(
+ interface_item_base.
+ design_description)])
+ if design_description is not u"":
+ design_description = u"".join([u" *\n" if use_doxygen is
+ True else "//\n",
+ design_description])
+
+ issues = u"".join([(u" * @note {0}\n" if use_doxygen is
+ True else u"// Note: {0}\n").format(x)
+ for x in self._normalize_multiline_comments(
+ [x.value for x in interface_item_base.issues])])
+ if issues is not u"":
+ issues = u"".join([u" *\n" if use_doxygen is
+ True else u"//\n", issues])
+
+ todos = u"".join([(u" * @todo {0}\n" if use_doxygen is
+ True else u"// ToDo: {0}\n").format(x)
+ for x in self._normalize_multiline_comments(
+ interface_item_base.todos)])
+ if todos is not u"":
+ todos = u"".join([u" *\n" if use_doxygen is
+ True else u"//\n", todos])
+
+ returns = u""
+ if type(interface_item_base) is Model.Function:
+ returns = u"".join([u" *\n", self._function_return_comment])
+
+ template = self._comment_doxygen_template if use_doxygen is \
+ True else self._comment_cc_template
+
+ return template.substitute(
+ brief_description=brief_description,
+ description=description,
+ design_description=design_description,
+ issues=issues,
+ todos=todos,
+ returns=returns)
+
+ def _indent_code(self, code, indent_level):
+ """Indent given source code.
+
+ Indents given source code right by given indentation level.
+
+ Keyword arguments:
+ code -- given source code.
+ indent_level -- desired indentation level.
+
+ Returns:
+ String with processed code.
+
+ """
+
+ code_lines = code.split("\n")
+ return u"".join(
+ [u"{0}{1}\n".format(
+ self._indent_template * indent_level,
+ x) if x is not u"" else u"\n" for x in code_lines])
+
+ @staticmethod
+ def _normalize_multiline_comments(initial_strings):
+ """Normalize multiline comments.
+
+ Makes multiline comment clean of any line breaks creating additional
+ strings for the comment.
+
+ Keyword arguments:
+ initial_strings -- initial list of strings to process.
+
+ Returns:
+ New list of the strings (with contains no strings with line breaks).
+
+ """
+
+ result = []
+ for initial_string in initial_strings:
+ result = result + initial_string.splitlines()
+ return result
+
+ _model_types_briefs = dict(
+ {u"EnumElement": u"",
+ u"Enum": u"Enumeration ",
+ u"Function": u"Method that generates schema for function ",
+ u"Struct": u"Method that generates schema item for structure ",
+ u"Param": u"Struct member ",
+ u"FunctionParam": u"Function parameter "})
+
+ _cc_file_template = string.Template(
+ u'''/**\n'''
+ u''' * @file ${class_name}.h\n'''
+ u''' * @brief Generated class ${class_name} source file.\n'''
+ u''' *\n'''
+ u'''*/\n'''
+ u'''#include "${header_file}"\n'''
+ u'''${includes}'''
+ u'''\n\n'''
+ u'''$namespace_open'''
+ u'''\n'''
+ u'''$enums_content'''
+ u'''\n'''
+ u'''$namespace_close'''
+ u'''\n\n''')
+
+
+ _h_file_template = string.Template(
+ u'''/**\n'''
+ u''' * @file ${class_name}.h\n'''
+ u''' * @brief Generated class ${class_name} header file.\n'''
+ u''' *\n'''
+ u'''* Copyright (c) 2017, Ford Motor Company\n'''
+ u'''* All rights reserved.\n'''
+ u'''*\n'''
+ u'''* Redistribution and use in source and binary forms, with or without\n'''
+ u'''* modification, are permitted provided that the following conditions are met:\n'''
+ u'''*\n'''
+ u'''* Redistributions of source code must retain the above copyright notice, this\n'''
+ u'''* list of conditions and the following disclaimer.\n'''
+ u'''*\n'''
+ u'''* Redistributions in binary form must reproduce the above copyright notice,\n'''
+ u'''* this list of conditions and the following\n'''
+ u'''* disclaimer in the documentation and/or other materials provided with the\n'''
+ u'''* distribution.\n'''
+ u'''*\n'''
+ u'''* Neither the name of the Ford Motor Company nor the names of its contributors\n'''
+ u'''* may be used to endorse or promote products derived from this software\n'''
+ u'''* without specific prior written permission.\n'''
+ u'''*\n'''
+ u'''* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\n'''
+ u'''* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n'''
+ u'''* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n'''
+ u'''* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\n'''
+ u'''* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n'''
+ u'''* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n'''
+ u'''* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n'''
+ u'''* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n'''
+ u'''* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n'''
+ u'''* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n'''
+ u'''* POSSIBILITY OF SUCH DAMAGE.\n'''
+ u'''*/\n'''
+ u'''\n'''
+ u'''#ifndef $guard\n'''
+ u'''#define $guard\n'''
+ u'''#include <string>\n'''
+ u'''${includes}'''
+ u'''\n'''
+ u'''$namespace_open'''
+ u'''$enums_content'''
+ u'''$namespace_close'''
+ u'''#endif //$guard\n'''
+ u'''\n\n''')
+
+
+ _namespace_open_template = string.Template(
+ u'''namespace $name {\n''')
+
+ _comment_doxygen_template = string.Template(
+ u'''/**\n'''
+ u'''$brief_description'''
+ u'''$description'''
+ u'''$design_description'''
+ u'''$issues'''
+ u'''$todos'''
+ u'''$returns */''')
+
+ _enum_template = string.Template(
+ u'''$comment\n'''
+ u'''enum $name {\n'''
+ u'''$enum_items};\n'''
+ u'''bool IsValidEnum($name val);\n'''
+ u'''const char* EnumToJsonString($name val);\n'''
+ u'''bool EnumFromJsonString(const std::string& literal, $name* result);\n'''
+ )
+ _valiation_enum_template = string.Template(
+ u'''bool IsValidEnum($name val) {\n'''
+ u''' return !(std::string(EnumToJsonString(val)).empty());\n'''
+ u'''};\n''')
+
+ _valiation_enum_item_template = string.Template(
+ u''' case $name: return true;''')
+
+ _enum_to_json_template = string.Template(
+ u'''const char* EnumToJsonString($name val) {\n'''
+ u''' switch (val) {\n'''
+ u'''$enum_items\n'''
+ u''' default: return "";\n'''
+ u''' }\n'''
+ u'''};\n''')
+
+ _enum_to_json_item_template = string.Template(
+ u''' case $name: return "$string_name";''')
+
+ _enum_from_json_template = string.Template(
+ u'''bool EnumFromJsonString(const std::string& literal, $name* result) {\n'''
+ u'''$enum_items'''
+ u''' return false;\n'''
+ u'''};\n''')
+
+ _enum_from_json_item_template = string.Template(
+ u''' if ("$string_name" == literal) {\n'''
+ u''' *result = $name;\n'''
+ u''' return true;\n'''
+ u''' }\n''')
+
+ _enum_element_with_value_template = string.Template(
+ u'''$comment\n'''
+ u'''$name = $value''')
+
+ _enum_element_with_no_value_template = string.Template(
+ u'''$comment\n'''
+ u'''$name''')
+ _enum_factory_template = string.Template(
+ '''${enums_values}\n'''
+ '''template<typename EnumType>\n'''
+ '''std::shared_ptr<smart_objects::ISchemaItem> Create(const std::set<EnumType>& all_enum_values) {\n'''
+ '''using namespace smart_objects;\n'''
+ ''' static auto schemaItem = TEnumSchemaItem<EnumType>::create(all_enum_values, TSchemaItemParameter<EnumType>());\n'''
+ ''' return schemaItem;\n'''
+ '''}\n\n'''
+ '''std::shared_ptr<smart_objects::ISchemaItem> EnumSchemaItemFactory::Get(const std::string & enum_name) {\n'''
+ '''${enum_factory_content}\n'''
+ ''' return std::shared_ptr<smart_objects::ISchemaItem>();\n'''
+ '''}\n\n'''
+ '''bool EnumSchemaItemFactory::IsRPCSpecVehicleDataType(const std::string& vd_name) {\n'''
+ ''' for(auto& item_name : VehicleDataType_enum_names) {\n'''
+ ''' if (vd_name == item_name) {\n'''
+ ''' return true;\n'''
+ ''' }\n'''
+ ''' }\n'''
+ ''' return false;\n'''
+ '''}\n''')
+ _enum_factory_element_template = string.Template(
+ ''' if (enum_name == "${enum_name}") {\n'''
+ ''' return Create<mobile_apis::${enum_name}::eType>(${enum_name}_all_enum_values);\n'''
+ ''' }''')
+ _POD_type_factory_element_template = string.Template(
+ ''' if (typename == "${type_name}") {\n'''
+ ''' return TNumberSchemaItem<${cpp_type}>::create(TSchemaItemParameter<double>(${min_val}), TSchemaItemParameter<double>(${${max_val}}), TSchemaItemParameter<${cpp_type}>());'''
+ ''' }''')
+ _indent_template = u" "
diff --git a/tools/InterfaceGenerator/generator/generators/SmartFactoryBase.py b/tools/InterfaceGenerator/generator/generators/SmartFactoryBase.py
index c6a0145ac6..86d238ef69 100755
--- a/tools/InterfaceGenerator/generator/generators/SmartFactoryBase.py
+++ b/tools/InterfaceGenerator/generator/generators/SmartFactoryBase.py
@@ -93,7 +93,7 @@ class CodeGenerator(object):
with codecs.open(os.path.join(destination_dir, header_file_name),
encoding="utf-8",
mode="w") as f_h:
- f_h.write(self._h_file_tempalte.substitute(
+ f_h.write(self._h_file_template.substitute(
class_name=class_name,
guard=guard,
namespace_open=namespace_open,
@@ -131,7 +131,7 @@ class CodeGenerator(object):
with codecs.open(os.path.join(destination_dir, header_file_name),
encoding="utf-8",
mode="w") as f_h:
- f_h.write(self._hpp_schema_file_tempalte.substitute(
+ f_h.write(self._hpp_schema_file_template.substitute(
class_name=class_name,
guard=guard,
header_file_name=unicode("".join("{0}.h".format(class_name))),
@@ -157,6 +157,8 @@ class CodeGenerator(object):
interface.functions.values()),
function_schemas=self._gen_function_schemas(
interface.functions.values()),
+ function_schemas_switch=self._gen_function_schema_switch(
+ interface.functions.values()),
init_function_impls=self._gen_function_impls(
interface.functions.values(),
namespace,
@@ -450,6 +452,48 @@ class CodeGenerator(object):
self._gen_function_schema(x), 1)
for x in functions])
+ def _gen_function_schema_switch(self, functions):
+ """Generate initialization code of each function for source file.
+
+ Generates function schema initialization code that should be used
+ in the source file.
+
+ Keyword arguments:
+ function -- function to generate method for.
+
+ Returns:
+ String with switch for functions initialization source code.
+
+ """
+
+ if functions is None:
+ raise GenerateError("Functions is None")
+
+ def function_id_switch(self, message_type, functions):
+ case_list = [self._function_id_case_template.substitute(
+ function_id=x.function_id.primary_name,
+ message_type=x.message_type.primary_name)
+ for x in functions if x.message_type.primary_name == message_type ]
+ case_list.append("default:\n break;\n")
+ switch_function_id_cases = self._indent_code(u"".join(case_list), 1)[:-1]
+
+ return self._indent_code(self._function_switch_template.substitute(
+ switchable="function_id",
+ cases=switch_function_id_cases
+ ), 1)[:-1]
+
+ message_type_case_list = [self._message_type_case_template.substitute(
+ message_type = message_type,
+ case_body = function_id_switch(self, message_type, functions)
+ ) for message_type in set([x.message_type.primary_name for x in functions])]
+ message_type_case_list.append("default:\n break;\n")
+ message_type_cases = self._indent_code(u"".join(message_type_case_list), 1)[:-1]
+
+ return self._indent_code(self._function_switch_template.substitute(
+ switchable="message_type",
+ cases=message_type_cases
+ ), 1)[:-1]
+
def _gen_function_schema(self, function):
"""Generate function initialization code for source file.
@@ -1361,7 +1405,7 @@ class CodeGenerator(object):
u"Param": u"Struct member ",
u"FunctionParam": u"Function parameter "})
- _h_file_tempalte = string.Template(
+ _h_file_template = string.Template(
u'''/**\n'''
u''' * @file ${class_name}.h\n'''
u''' * @brief Generated class ${class_name} header file.\n'''
@@ -1426,7 +1470,7 @@ class CodeGenerator(object):
u'''#endif //$guard\n'''
u'''\n\n''')
- _hpp_schema_file_tempalte = string.Template(
+ _hpp_schema_file_template = string.Template(
u'''/**\n'''
u''' * @file ${class_name}.h\n'''
u''' * @brief Generated class ${class_name} header file.\n'''
@@ -1488,6 +1532,7 @@ class CodeGenerator(object):
u'''#include "formatters/CSmartFactory.h"\n'''
u'''#include "smart_objects/smart_schema.h"\n'''
u'''#include "smart_objects/schema_item.h"\n'''
+ u'''#include "smart_objects/object_schema_item.h"\n'''
u'''#include "$header_file_name"\n'''
u'''\n'''
u'''$namespace_open'''
@@ -1604,6 +1649,32 @@ class CodeGenerator(object):
u'''CAlwaysFalseSchemaItem::create();\n'''
u'''}\n'''
u'''\n'''
+ u'''bool $namespace::$class_name::AddCustomMember(FunctionID::eType function_id,\n'''
+ u''' messageType::eType message_type,\n'''
+ u''' std::string member_key, ns_smart_device_link::ns_smart_objects::SMember member) {\n'''
+ u''' using namespace ns_smart_device_link::ns_json_handler;\n'''
+ u''' using namespace ns_smart_device_link::ns_smart_objects;\n'''
+ u''' SmartSchemaKey<FunctionID::eType, messageType::eType> shema_key(function_id, message_type);\n'''
+ u''' auto function_schema = functions_schemes_.find(shema_key);\n'''
+ u''' if (functions_schemes_.end() == function_schema){\n'''
+ u''' return false;\n'''
+ u''' }\n'''
+ u'''\n'''
+ u''' auto schema = function_schema->second.getSchemaItem();\n'''
+ u''' auto msg_params_schema_item = schema->GetMemberSchemaItem(ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS);\n'''
+ u''' if (!msg_params_schema_item.is_initialized()){\n'''
+ u''' return false;\n'''
+ u''' }\n'''
+ u'''\n'''
+ u''' msg_params_schema_item->mSchemaItem->AddMemberSchemaItem(member_key, member);\n'''
+ u''' return true;\n'''
+ u'''}\n'''
+ u'''\n'''
+ u'''void $namespace::$class_name::ResetFunctionSchema(FunctionID::eType function_id,\n'''
+ u''' messageType::eType message_type) {\n'''
+ u''' InitFunctionSchema(function_id, message_type);\n'''
+ u'''}\n'''
+ u'''\n'''
u'''void $namespace::$class_name::InitStructSchemes(\n'''
u''' TStructsSchemaItems &struct_schema_items) {'''
u'''$struct_schema_items'''
@@ -1617,6 +1688,19 @@ class CodeGenerator(object):
u'''$function_schemas'''
u'''}\n'''
u'''\n'''
+ u'''void $namespace::$class_name::InitFunctionSchema(\n'''
+ u''' const FunctionID::eType &function_id,\n'''
+ u''' const messageType::eType &message_type) {\n'''
+ u'''\n'''
+ u''' TStructsSchemaItems struct_schema_items;\n'''
+ u''' InitStructSchemes(struct_schema_items);\n'''
+ u'''\n'''
+ u''' std::set<FunctionID::eType> function_id_items { function_id };\n'''
+ u''' std::set<messageType::eType> message_type_items { message_type };\n'''
+ u'''\n'''
+ u'''$function_schemas_switch'''
+ u'''}\n'''
+ u'''\n'''
u'''//------------- Functions schemes initialization -------------\n'''
u'''\n'''
u'''$init_function_impls'''
@@ -1668,6 +1752,26 @@ class CodeGenerator(object):
u'''};\n'''
u'''\n''')
+ _function_switch_template = string.Template(
+ u'''switch(${switchable}) {\n'''
+ u'''${cases}'''
+ u'''}\n''')
+
+ _message_type_case_template = string.Template(
+ u'''case messageType::${message_type}: {\n'''
+ u'''${case_body}'''
+ u''' break;\n'''
+ u'''}\n''')
+
+ _function_id_case_template = string.Template(
+ u'''case FunctionID::${function_id}: {\n'''
+ u''' ns_smart_device_link::ns_json_handler::SmartSchemaKey<FunctionID::eType, messageType::eType> shema_key(function_id, message_type);\n'''
+ u''' functions_schemes_[shema_key] = '''
+ u'''InitFunction_${function_id}_${message_type}('''
+ u'''struct_schema_items, function_id_items, message_type_items);\n'''
+ u''' break;\n'''
+ u'''}\n''')
+
_struct_schema_item_template = string.Template(
u'''std::shared_ptr<ISchemaItem> struct_schema_item_${name} = '''
u'''InitStructSchemaItem_${name}(struct_schema_items);\n'''
@@ -1695,7 +1799,7 @@ class CodeGenerator(object):
_struct_impl_code_tempate = string.Template(
u'''${schema_loc_decl}'''
u'''${schema_items_decl}'''
- u'''CObjectSchemaItem::Members '''
+ u'''Members '''
u'''schema_members;\n\n'''
u'''${schema_item_fill}'''
u'''return CObjectSchemaItem::create(schema_members);''')
@@ -1724,10 +1828,10 @@ class CodeGenerator(object):
u'''std::shared_ptr<ISchemaItem> ${var_name} = ${item_decl};''')
_impl_code_shared_ptr_vector_template = string.Template(
- u'''std::vector<CObjectSchemaItem::SMember> ${var_name}_history_vector;''')
+ u'''std::vector<SMember> ${var_name}_history_vector;''')
_impl_code_append_history_vector_template = string.Template(
- u'''${vector_name}_history_vector.push_back(CObjectSchemaItem::SMember(${name}_SchemaItem, ${mandatory}, "${since}", "${until}", ${deprecated}, ${removed}));''')
+ u'''${vector_name}_history_vector.push_back(SMember(${name}_SchemaItem, ${mandatory}, "${since}", "${until}", ${deprecated}, ${removed}));''')
_impl_code_integer_item_template = string.Template(
u'''TNumberSchemaItem<${type}>::create(${params})''')
@@ -1755,16 +1859,13 @@ class CodeGenerator(object):
u'''TSchemaItemParameter<$type>($value)''')
_impl_code_item_fill_template = string.Template(
- u'''schema_members["${name}"] = CObjectSchemaItem::'''
- u'''SMember(${var_name}, ${is_mandatory});''')
+ u'''schema_members["${name}"] = SMember(${var_name}, ${is_mandatory});''')
_impl_code_item_fill_template_with_version = string.Template(
- u'''schema_members["${name}"] = CObjectSchemaItem::'''
- u'''SMember(${var_name}, ${is_mandatory}, "${since}", "${until}", ${deprecated}, ${removed});''')
+ u'''schema_members["${name}"] = SMember(${var_name}, ${is_mandatory}, "${since}", "${until}", ${deprecated}, ${removed});''')
_impl_code_item_fill_template_with_version_and_history_vector = string.Template(
- u'''schema_members["${name}"] = CObjectSchemaItem::'''
- u'''SMember(${var_name}, ${is_mandatory}, "${since}", "${until}", ${deprecated}, ${removed}, ${vector_name}_history_vector);''')
+ u'''schema_members["${name}"] = SMember(${var_name}, ${is_mandatory}, "${since}", "${until}", ${deprecated}, ${removed}, ${vector_name}_history_vector);''')
_function_impl_template = string.Template(
u'''CSmartSchema $namespace::$class_name::'''
@@ -1778,22 +1879,22 @@ class CodeGenerator(object):
_function_impl_code_tempate = string.Template(
u'''${schema_loc_decl}'''
u'''${schema_items_decl}'''
- u'''CObjectSchemaItem::Members '''
+ u'''Members '''
u'''schema_members;\n\n'''
u'''${schema_item_fill}'''
- u'''CObjectSchemaItem::Members '''
+ u'''Members '''
u'''params_members;\n'''
u'''${schema_params_fill}'''
u'''\n'''
- u'''CObjectSchemaItem::Members '''
+ u'''Members '''
u'''root_members_map;\n'''
u'''root_members_map[ns_smart_device_link::ns_json_handler::'''
u'''strings::S_MSG_PARAMS] = '''
- u'''CObjectSchemaItem::SMember(CObjectSchemaItem::'''
+ u'''SMember(CObjectSchemaItem::'''
u'''create(schema_members), true);\n'''
u'''root_members_map[ns_smart_device_link::ns_json_handler::'''
u'''strings::S_PARAMS] = '''
- u'''CObjectSchemaItem::SMember(CObjectSchemaItem::'''
+ u'''SMember(CObjectSchemaItem::'''
u'''create(params_members), true);\n\n'''
u'''return CSmartSchema(CObjectSchemaItem::'''
u'''create(root_members_map));''')
@@ -1809,7 +1910,19 @@ class CodeGenerator(object):
u''' */\n'''
u''' $class_name();\n'''
u'''\n'''
- u''' protected:\n'''
+ u''' /**\n'''
+ u''' * @brief Adds custom members to existing list of params.\n'''
+ u''' */\n'''
+ u''' bool AddCustomMember(FunctionID::eType function_id,\n'''
+ u''' messageType::eType message_type,\n'''
+ u''' std::string member_key, ns_smart_device_link::ns_smart_objects::SMember member);\n'''
+ u'''\n'''
+ u''' /**\n'''
+ u''' * @brief Reset function schema to state defined in API.\n'''
+ u''' */\n'''
+ u''' void ResetFunctionSchema(FunctionID::eType function_id,\n'''
+ u''' messageType::eType message_type);\n'''
+ u'''\n'''
u''' /**\n'''
u''' * @brief Type that maps of struct IDs to schema items.\n'''
u''' */\n'''
@@ -1817,6 +1930,7 @@ class CodeGenerator(object):
u'''std::shared_ptr<ns_smart_device_link::ns_smart_objects::'''
u'''ISchemaItem> > TStructsSchemaItems;\n'''
u'''\n'''
+ u''' protected:\n'''
u''' /**\n'''
u''' * @brief Helper that allows to make reference to struct\n'''
u''' *\n'''
@@ -1852,8 +1966,19 @@ class CodeGenerator(object):
u''' const std::set<messageType::eType> '''
u'''&message_type_items);\n'''
u'''\n'''
+ u''' /**\n'''
+ u''' * @brief Initializes single function schema.\n'''
+ u''' *\n'''
+ u''' * @param function_id Function ID of schema to be initialized.\n'''
+ u''' * @param message_type Message type of schema to be initialized.\n'''
+ u''' */\n'''
+ u''' void InitFunctionSchema(\n'''
+ u''' const FunctionID::eType &function_id,\n'''
+ u''' const messageType::eType &message_type);\n'''
+ u'''\n'''
u'''$init_function_decls'''
u'''\n'''
+ u''' public:\n'''
u'''$init_struct_decls'''
u'''};''')
diff --git a/tools/InterfaceGenerator/generator/generators/SmartFactoryJSONRPC.py b/tools/InterfaceGenerator/generator/generators/SmartFactoryJSONRPC.py
index 6924ec67aa..07b55382a6 100755
--- a/tools/InterfaceGenerator/generator/generators/SmartFactoryJSONRPC.py
+++ b/tools/InterfaceGenerator/generator/generators/SmartFactoryJSONRPC.py
@@ -100,35 +100,35 @@ class CodeGenerator(SmartFactoryBase.CodeGenerator):
u'''error_response_schema));\n''')
_error_response_schema_template = (
- u'''CObjectSchemaItem::Members '''
+ u'''Members '''
u'''params_members;\n'''
u'''params_members[ns_smart_device_link::ns_json_handler::'''
- u'''strings::S_FUNCTION_ID] = CObjectSchemaItem::SMember('''
+ u'''strings::S_FUNCTION_ID] = SMember('''
u'''TEnumSchemaItem<FunctionID::eType>::create('''
u'''function_id_items), true);\n'''
u'''params_members[ns_smart_device_link::ns_json_handler::'''
- u'''strings::S_MESSAGE_TYPE] = CObjectSchemaItem::SMember('''
+ u'''strings::S_MESSAGE_TYPE] = SMember('''
u'''TEnumSchemaItem<messageType::eType>::create('''
u'''message_type_items), true);\n'''
u'''params_members[ns_smart_device_link::ns_json_handler::'''
- u'''strings::S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember('''
+ u'''strings::S_PROTOCOL_VERSION] = SMember('''
u'''TNumberSchemaItem<int>::create(), true);\n'''
u'''params_members[ns_smart_device_link::ns_json_handler::'''
- u'''strings::S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember('''
+ u'''strings::S_PROTOCOL_TYPE] = SMember('''
u'''TNumberSchemaItem<int>::create(), true);\n'''
u'''params_members[ns_smart_device_link::ns_json_handler::'''
- u'''strings::S_CORRELATION_ID] = CObjectSchemaItem::SMember('''
+ u'''strings::S_CORRELATION_ID] = SMember('''
u'''TNumberSchemaItem<int>::create(), true);\n'''
u'''params_members[ns_smart_device_link::ns_json_handler::'''
- u'''strings::kCode] = CObjectSchemaItem::SMember('''
+ u'''strings::kCode] = SMember('''
u'''TNumberSchemaItem<int>::create(), true);\n'''
u'''params_members[ns_smart_device_link::ns_json_handler::'''
- u'''strings::kMessage] = CObjectSchemaItem::SMember('''
+ u'''strings::kMessage] = SMember('''
u'''CStringSchemaItem::create(), true);\n'''
u'''\n'''
- u'''CObjectSchemaItem::Members root_members_map;\n'''
+ u'''Members root_members_map;\n'''
u'''root_members_map[ns_smart_device_link::ns_json_handler::'''
- u'''strings::S_PARAMS] = CObjectSchemaItem::SMember('''
+ u'''strings::S_PARAMS] = SMember('''
u'''CObjectSchemaItem::create(params_members), true);\n'''
u'''\n'''
u'''CSmartSchema error_response_schema('''
@@ -137,29 +137,23 @@ class CodeGenerator(SmartFactoryBase.CodeGenerator):
_base_params = (
u'''params_members[ns_smart_device_link::ns_json_handler::'''
- u'''strings::S_FUNCTION_ID] = CObjectSchemaItem::'''
- u'''SMember(TEnumSchemaItem<FunctionID::eType>::'''
+ u'''strings::S_FUNCTION_ID] = SMember(TEnumSchemaItem<FunctionID::eType>::'''
u'''create(function_id_items), true);\n'''
u'''params_members[ns_smart_device_link::ns_json_handler::'''
- u'''strings::S_MESSAGE_TYPE] = CObjectSchemaItem::'''
- u'''SMember(TEnumSchemaItem<messageType::eType>::'''
+ u'''strings::S_MESSAGE_TYPE] = SMember(TEnumSchemaItem<messageType::eType>::'''
u'''create(message_type_items), true);\n'''
u'''params_members[ns_smart_device_link::ns_json_handler::'''
- u'''strings::S_PROTOCOL_VERSION] = CObjectSchemaItem::'''
- u'''SMember(TNumberSchemaItem<int>::create(), true);\n'''
+ u'''strings::S_PROTOCOL_VERSION] = SMember(TNumberSchemaItem<int>::create(), true);\n'''
u'''params_members[ns_smart_device_link::ns_json_handler::'''
- u'''strings::S_PROTOCOL_TYPE] = CObjectSchemaItem::'''
- u'''SMember(TNumberSchemaItem<int>::create(), true);\n'''
+ u'''strings::S_PROTOCOL_TYPE] = SMember(TNumberSchemaItem<int>::create(), true);\n'''
)
_correlation_id_param = (
u'''params_members[ns_smart_device_link::ns_json_handler::'''
- u'''strings::S_CORRELATION_ID] = CObjectSchemaItem::'''
- u'''SMember(TNumberSchemaItem<int>::create(), true);\n'''
+ u'''strings::S_CORRELATION_ID] = SMember(TNumberSchemaItem<int>::create(), true);\n'''
)
_additional_response_params = (
u'''params_members[ns_smart_device_link::ns_json_handler::'''
- u'''strings::kCode] = CObjectSchemaItem::'''
- u'''SMember(TNumberSchemaItem<int>::create(), true);\n'''
+ u'''strings::kCode] = SMember(TNumberSchemaItem<int>::create(), true);\n'''
)
diff --git a/tools/InterfaceGenerator/generator/generators/SmartFactorySDLRPC.py b/tools/InterfaceGenerator/generator/generators/SmartFactorySDLRPC.py
index c3244f7e95..f82c7bb808 100755
--- a/tools/InterfaceGenerator/generator/generators/SmartFactorySDLRPC.py
+++ b/tools/InterfaceGenerator/generator/generators/SmartFactorySDLRPC.py
@@ -68,24 +68,19 @@ class CodeGenerator(SmartFactoryBase.CodeGenerator):
base_params = \
u'''params_members[ns_smart_device_link::ns_json_handler::''' \
- u'''strings::S_FUNCTION_ID] = CObjectSchemaItem::''' \
- u'''SMember(TEnumSchemaItem<FunctionID::eType>::''' \
+ u'''strings::S_FUNCTION_ID] = SMember(TEnumSchemaItem<FunctionID::eType>::''' \
u'''create(function_id_items), true);\n''' \
u'''params_members[ns_smart_device_link::ns_json_handler::''' \
- u'''strings::S_MESSAGE_TYPE] = CObjectSchemaItem::''' \
- u'''SMember(TEnumSchemaItem<messageType::eType>::''' \
+ u'''strings::S_MESSAGE_TYPE] = SMember(TEnumSchemaItem<messageType::eType>::''' \
u'''create(message_type_items), true);\n''' \
u'''params_members[ns_smart_device_link::ns_json_handler::''' \
- u'''strings::S_PROTOCOL_VERSION] = CObjectSchemaItem::''' \
- u'''SMember(TNumberSchemaItem<int>::create(), true);\n''' \
+ u'''strings::S_PROTOCOL_VERSION] = SMember(TNumberSchemaItem<int>::create(), true);\n''' \
u'''params_members[ns_smart_device_link::ns_json_handler::''' \
- u'''strings::S_PROTOCOL_TYPE] = CObjectSchemaItem::''' \
- u'''SMember(TNumberSchemaItem<int>::create(), true);\n'''
+ u'''strings::S_PROTOCOL_TYPE] = SMember(TNumberSchemaItem<int>::create(), true);\n'''
correlation_id_param = \
u'''params_members[ns_smart_device_link::ns_json_handler::''' \
- u'''strings::S_CORRELATION_ID] = CObjectSchemaItem::''' \
- u'''SMember(TNumberSchemaItem<int>::create(), true);\n'''
+ u'''strings::S_CORRELATION_ID] = SMember(TNumberSchemaItem<int>::create(), true);\n'''
return u"".join([base_params, correlation_id_param
if unicode(message_type_name) !=
diff --git a/tools/InterfaceGenerator/generator/parsers/JSONRPC.py b/tools/InterfaceGenerator/generator/parsers/JSONRPC.py
index 092f41ec17..52aa5a1048 100755
--- a/tools/InterfaceGenerator/generator/parsers/JSONRPC.py
+++ b/tools/InterfaceGenerator/generator/parsers/JSONRPC.py
@@ -4,8 +4,9 @@ Contains parser for JSON RPC XML format.
"""
+from generator import Model
from generator.parsers import RPCBase
-
+import xml.etree.ElementTree as ET
class Parser(RPCBase.Parser):
@@ -42,6 +43,17 @@ class Parser(RPCBase.Parser):
self._interface_name = element.attrib["name"]
self._parse_interface(element, self._interface_name + "_")
+ def _check_enum_name(self, enum):
+ """Check enum name.
+
+ This method is called to check whether the newly parsed enum's name
+ conflicts with some predefined enum.
+ As SDLRPCV2 has no predefined enums this implementation does nothing.
+
+ """
+
+ pass
+
def _provide_enum_element_for_function(self, enum_name, element_name):
"""Provide enum element for functions.
diff --git a/tools/InterfaceGenerator/generator/parsers/RPCBase.py b/tools/InterfaceGenerator/generator/parsers/RPCBase.py
index 955de31dc7..d11b9e8d0d 100755
--- a/tools/InterfaceGenerator/generator/parsers/RPCBase.py
+++ b/tools/InterfaceGenerator/generator/parsers/RPCBase.py
@@ -865,8 +865,6 @@ class Parser(object):
"""
if name in attrib:
del attrib[name]
- print ("Ignoring attribute '" +
- name + "'")
return True
def _parse_version(self, version):
diff --git a/tools/InterfaceGenerator/generator/parsers/SDLRPCV2.py b/tools/InterfaceGenerator/generator/parsers/SDLRPCV2.py
index 3d67c6e4c6..24974a5527 100755
--- a/tools/InterfaceGenerator/generator/parsers/SDLRPCV2.py
+++ b/tools/InterfaceGenerator/generator/parsers/SDLRPCV2.py
@@ -8,6 +8,7 @@ import collections
from generator import Model
from generator.parsers import RPCBase
+import xml.etree.ElementTree as ET
class Parser(RPCBase.Parser):
@@ -31,6 +32,7 @@ class Parser(RPCBase.Parser):
As SDLRPCV2 has no predefined enums this implementation does nothing.
"""
+
pass
def _parse_function_id_type(self, function_name, attrib):
diff --git a/tools/InterfaceGenerator/test/generator/generators/test_SmartFactoryJSONRPC.py b/tools/InterfaceGenerator/test/generator/generators/test_SmartFactoryJSONRPC.py
index c4813d00a8..533fe92eb5 100755
--- a/tools/InterfaceGenerator/test/generator/generators/test_SmartFactoryJSONRPC.py
+++ b/tools/InterfaceGenerator/test/generator/generators/test_SmartFactoryJSONRPC.py
@@ -18,95 +18,95 @@ from generator import Model
EXPECTED_RESULT_REQUEST = (
u"""params_members[ns_smart_device_link::ns_json_handler::"""
- u"""strings::S_FUNCTION_ID] = CObjectSchemaItem::SMember("""
+ u"""strings::S_FUNCTION_ID] = SMember("""
u"""TEnumSchemaItem<FunctionID::eType>::create("""
u"""function_id_items), true);\n"""
u"""params_members[ns_smart_device_link::ns_json_handler::"""
- u"""strings::S_MESSAGE_TYPE] = CObjectSchemaItem::SMember("""
+ u"""strings::S_MESSAGE_TYPE] = SMember("""
u"""TEnumSchemaItem<messageType::eType>::create("""
u"""message_type_items), true);\n"""
u"""params_members[ns_smart_device_link::ns_json_handler::"""
- u"""strings::S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember("""
+ u"""strings::S_PROTOCOL_VERSION] = SMember("""
u"""TNumberSchemaItem<int>::create(), true);\n"""
u"""params_members[ns_smart_device_link::ns_json_handler::"""
- u"""strings::S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember("""
+ u"""strings::S_PROTOCOL_TYPE] = SMember("""
u"""TNumberSchemaItem<int>::create(), true);\n"""
u"""params_members[ns_smart_device_link::ns_json_handler::"""
- u"""strings::S_CORRELATION_ID] = CObjectSchemaItem::SMember("""
+ u"""strings::S_CORRELATION_ID] = SMember("""
u"""TNumberSchemaItem<int>::create(), true);\n"""
)
EXPECTED_RESULT_RESPONSE = (
u"""params_members[ns_smart_device_link::ns_json_handler::"""
- u"""strings::S_FUNCTION_ID] = CObjectSchemaItem::SMember("""
+ u"""strings::S_FUNCTION_ID] = SMember("""
u"""TEnumSchemaItem<FunctionID::eType>::create("""
u"""function_id_items), true);\n"""
u"""params_members[ns_smart_device_link::ns_json_handler::"""
- u"""strings::S_MESSAGE_TYPE] = CObjectSchemaItem::SMember("""
+ u"""strings::S_MESSAGE_TYPE] = SMember("""
u"""TEnumSchemaItem<messageType::eType>::create("""
u"""message_type_items), true);\n"""
u"""params_members[ns_smart_device_link::ns_json_handler::"""
- u"""strings::S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember("""
+ u"""strings::S_PROTOCOL_VERSION] = SMember("""
u"""TNumberSchemaItem<int>::create(), true);\n"""
u"""params_members[ns_smart_device_link::ns_json_handler::"""
- u"""strings::S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember("""
+ u"""strings::S_PROTOCOL_TYPE] = SMember("""
u"""TNumberSchemaItem<int>::create(), true);\n"""
u"""params_members[ns_smart_device_link::ns_json_handler::"""
- u"""strings::S_CORRELATION_ID] = CObjectSchemaItem::SMember("""
+ u"""strings::S_CORRELATION_ID] = SMember("""
u"""TNumberSchemaItem<int>::create(), true);\n"""
u"""params_members[ns_smart_device_link::ns_json_handler::"""
- u"""strings::kCode] = CObjectSchemaItem::SMember("""
+ u"""strings::kCode] = SMember("""
u"""TNumberSchemaItem<int>::create(), true);\n"""
)
EXPECTED_RESULT_NOTIFICATION = (
u"""params_members[ns_smart_device_link::ns_json_handler::"""
- u"""strings::S_FUNCTION_ID] = CObjectSchemaItem::SMember("""
+ u"""strings::S_FUNCTION_ID] = SMember("""
u"""TEnumSchemaItem<FunctionID::eType>::create("""
u"""function_id_items), true);\n"""
u"""params_members[ns_smart_device_link::ns_json_handler::"""
- u"""strings::S_MESSAGE_TYPE] = CObjectSchemaItem::SMember("""
+ u"""strings::S_MESSAGE_TYPE] = SMember("""
u"""TEnumSchemaItem<messageType::eType>::create("""
u"""message_type_items), true);\n"""
u"""params_members[ns_smart_device_link::ns_json_handler::"""
- u"""strings::S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember("""
+ u"""strings::S_PROTOCOL_VERSION] = SMember("""
u"""TNumberSchemaItem<int>::create(), true);\n"""
u"""params_members[ns_smart_device_link::ns_json_handler::"""
- u"""strings::S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember("""
+ u"""strings::S_PROTOCOL_TYPE] = SMember("""
u"""TNumberSchemaItem<int>::create(), true);\n"""
)
EXPECTED_PRE_FUNCTION_CODE = (
- u""" std::map<std::string, CObjectSchemaItem::SMember> """
+ u""" std::map<std::string, SMember> """
u"""params_members;\n"""
u""" params_members[ns_smart_device_link::ns_json_handler::"""
- u"""strings::S_FUNCTION_ID] = CObjectSchemaItem::SMember("""
+ u"""strings::S_FUNCTION_ID] = SMember("""
u"""TEnumSchemaItem<FunctionID::eType>::create("""
u"""function_id_items), true);\n"""
u""" params_members[ns_smart_device_link::ns_json_handler::"""
- u"""strings::S_MESSAGE_TYPE] = CObjectSchemaItem::SMember("""
+ u"""strings::S_MESSAGE_TYPE] = SMember("""
u"""TEnumSchemaItem<messageType::eType>::create("""
u"""message_type_items), true);\n"""
u""" params_members[ns_smart_device_link::ns_json_handler::"""
- u"""strings::S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember("""
+ u"""strings::S_PROTOCOL_VERSION] = SMember("""
u"""TNumberSchemaItem<int>::create(), true);\n"""
u""" params_members[ns_smart_device_link::ns_json_handler::"""
- u"""strings::S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember("""
+ u"""strings::S_PROTOCOL_TYPE] = SMember("""
u"""TNumberSchemaItem<int>::create(), true);\n"""
u""" params_members[ns_smart_device_link::ns_json_handler::"""
- u"""strings::S_CORRELATION_ID] = CObjectSchemaItem::SMember("""
+ u"""strings::S_CORRELATION_ID] = SMember("""
u"""TNumberSchemaItem<int>::create(), true);\n"""
u""" params_members[ns_smart_device_link::ns_json_handler"""
- u"""::strings::kCode] = CObjectSchemaItem::SMember("""
+ u"""::strings::kCode] = SMember("""
u"""TNumberSchemaItem<int>::create(), true);\n"""
u""" params_members[ns_smart_device_link::ns_json_handler::"""
- u"""strings::kMessage] = CObjectSchemaItem::SMember("""
+ u"""strings::kMessage] = SMember("""
u"""CStringSchemaItem::create(), true);\n"""
u"""\n"""
- u""" std::map<std::string, CObjectSchemaItem::SMember> """
+ u""" std::map<std::string, SMember> """
u"""root_members_map;\n"""
u""" root_members_map[ns_smart_device_link::ns_json_handler::"""
- u"""strings::S_PARAMS] = CObjectSchemaItem::SMember("""
+ u"""strings::S_PARAMS] = SMember("""
u"""CObjectSchemaItem::create(params_members), true);\n"""
u"""\n"""
u""" CSmartSchema error_response_schema(CObjectSchemaItem::create("""
diff --git a/tools/InterfaceGenerator/test/generator/generators/test_SmartFactorySDLRPC.py b/tools/InterfaceGenerator/test/generator/generators/test_SmartFactorySDLRPC.py
index 35e4aeb6ce..3c354cd34b 100755
--- a/tools/InterfaceGenerator/test/generator/generators/test_SmartFactorySDLRPC.py
+++ b/tools/InterfaceGenerator/test/generator/generators/test_SmartFactorySDLRPC.py
@@ -18,23 +18,23 @@ from generator import Model
EXPECTED_NOTIFICATION_RESULT = (
u"""params_members[ns_smart_device_link::ns_json_handler::"""
- u"""strings::S_FUNCTION_ID] = CObjectSchemaItem::SMember("""
+ u"""strings::S_FUNCTION_ID] = SMember("""
u"""TEnumSchemaItem<FunctionID::eType>::create("""
u"""function_id_items), true);\n"""
u"""params_members[ns_smart_device_link::ns_json_handler::"""
- u"""strings::S_MESSAGE_TYPE] = CObjectSchemaItem::SMember("""
+ u"""strings::S_MESSAGE_TYPE] = SMember("""
u"""TEnumSchemaItem<messageType::eType>::create("""
u"""message_type_items), true);\n"""
u"""params_members[ns_smart_device_link::ns_json_handler::"""
- u"""strings::S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember("""
+ u"""strings::S_PROTOCOL_VERSION] = SMember("""
u"""TNumberSchemaItem<int>::create(), true);\n"""
u"""params_members[ns_smart_device_link::ns_json_handler::"""
- u"""strings::S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember("""
+ u"""strings::S_PROTOCOL_TYPE] = SMember("""
u"""TNumberSchemaItem<int>::create(), true);\n""")
EXPECTED_REQ_RESP_RESULT = "".join([EXPECTED_NOTIFICATION_RESULT, (
u"""params_members[ns_smart_device_link::ns_json_handler::"""
- u"""strings::S_CORRELATION_ID] = CObjectSchemaItem::SMember("""
+ u"""strings::S_CORRELATION_ID] = SMember("""
u"""TNumberSchemaItem<int>::create(), true);\n""")])
DESCRIPTION = [u"Description Line1", u"Description Line2"]
diff --git a/tools/InterfaceGenerator/test/generator/generators/test_expected_jsonrpc.cc b/tools/InterfaceGenerator/test/generator/generators/test_expected_jsonrpc.cc
index 49369d2559..05795ecf3b 100644
--- a/tools/InterfaceGenerator/test/generator/generators/test_expected_jsonrpc.cc
+++ b/tools/InterfaceGenerator/test/generator/generators/test_expected_jsonrpc.cc
@@ -95,17 +95,17 @@ void XXX::YYY::ZZZ::Test::InitFunctionSchemes(
const TStructsSchemaItems &struct_schema_items,
const std::set<FunctionID::eType> &function_id_items,
const std::set<messageType::eType> &message_type_items) {
- std::map<std::string, CObjectSchemaItem::SMember> params_members;
- params_members[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = CObjectSchemaItem::SMember(TEnumSchemaItem<FunctionID::eType>::create(function_id_items), true);
- params_members[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(TEnumSchemaItem<messageType::eType>::create(message_type_items), true);
- params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
- params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
- params_members[ns_smart_device_link::ns_json_handler::strings::S_CORRELATION_ID] = CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
- params_members[ns_smart_device_link::ns_json_handler::strings::kCode] = CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
- params_members[ns_smart_device_link::ns_json_handler::strings::kMessage] = CObjectSchemaItem::SMember(CStringSchemaItem::create(), true);
-
- std::map<std::string, CObjectSchemaItem::SMember> root_members_map;
- root_members_map[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = CObjectSchemaItem::SMember(CObjectSchemaItem::create(params_members), true);
+ std::map<std::string, SMember> params_members;
+ params_members[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = SMember(TEnumSchemaItem<FunctionID::eType>::create(function_id_items), true);
+ params_members[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = SMember(TEnumSchemaItem<messageType::eType>::create(message_type_items), true);
+ params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[ns_smart_device_link::ns_json_handler::strings::S_CORRELATION_ID] = SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[ns_smart_device_link::ns_json_handler::strings::kCode] = SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[ns_smart_device_link::ns_json_handler::strings::kMessage] = SMember(CStringSchemaItem::create(), true);
+
+ std::map<std::string, SMember> root_members_map;
+ root_members_map[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = SMember(CObjectSchemaItem::create(params_members), true);
CSmartSchema error_response_schema(CObjectSchemaItem::create(root_members_map));
@@ -147,21 +147,21 @@ CSmartSchema XXX::YYY::ZZZ::Test::InitFunction_name1_request(
// Function parameter param2.
TSharedPtr<ISchemaItem> param2_SchemaItem = TEnumSchemaItem<Enum1::eType>::create(param2_allowed_enum_subset_values, TSchemaItemParameter<Enum1::eType>(name1));
- std::map<std::string, CObjectSchemaItem::SMember> schema_members;
+ std::map<std::string, SMember> schema_members;
- schema_members["param1"] = CObjectSchemaItem::SMember(param1_SchemaItem, true);
- schema_members["param2"] = CObjectSchemaItem::SMember(param2_SchemaItem, true);
+ schema_members["param1"] = SMember(param1_SchemaItem, true);
+ schema_members["param2"] = SMember(param2_SchemaItem, true);
- std::map<std::string, CObjectSchemaItem::SMember> params_members;
- params_members[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = CObjectSchemaItem::SMember(TEnumSchemaItem<FunctionID::eType>::create(function_id_items), true);
- params_members[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(TEnumSchemaItem<messageType::eType>::create(message_type_items), true);
- params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
- params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
- params_members[ns_smart_device_link::ns_json_handler::strings::S_CORRELATION_ID] = CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ std::map<std::string, SMember> params_members;
+ params_members[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = SMember(TEnumSchemaItem<FunctionID::eType>::create(function_id_items), true);
+ params_members[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = SMember(TEnumSchemaItem<messageType::eType>::create(message_type_items), true);
+ params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[ns_smart_device_link::ns_json_handler::strings::S_CORRELATION_ID] = SMember(TNumberSchemaItem<int>::create(), true);
- std::map<std::string, CObjectSchemaItem::SMember> root_members_map;
- root_members_map[ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS] = CObjectSchemaItem::SMember(CObjectSchemaItem::create(schema_members), true);
- root_members_map[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = CObjectSchemaItem::SMember(CObjectSchemaItem::create(params_members), true);
+ std::map<std::string, SMember> root_members_map;
+ root_members_map[ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS] = SMember(CObjectSchemaItem::create(schema_members), true);
+ root_members_map[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = SMember(CObjectSchemaItem::create(params_members), true);
return CSmartSchema(CObjectSchemaItem::create(root_members_map));
}
@@ -170,19 +170,19 @@ CSmartSchema XXX::YYY::ZZZ::Test::InitFunction_val_1_response(
const TStructsSchemaItems &struct_schema_items,
const std::set<FunctionID::eType> &function_id_items,
const std::set<messageType::eType> &message_type_items) {
- std::map<std::string, CObjectSchemaItem::SMember> schema_members;
+ std::map<std::string, SMember> schema_members;
- std::map<std::string, CObjectSchemaItem::SMember> params_members;
- params_members[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = CObjectSchemaItem::SMember(TEnumSchemaItem<FunctionID::eType>::create(function_id_items), true);
- params_members[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(TEnumSchemaItem<messageType::eType>::create(message_type_items), true);
- params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
- params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
- params_members[ns_smart_device_link::ns_json_handler::strings::S_CORRELATION_ID] = CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
- params_members[ns_smart_device_link::ns_json_handler::strings::kCode] = CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ std::map<std::string, SMember> params_members;
+ params_members[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = SMember(TEnumSchemaItem<FunctionID::eType>::create(function_id_items), true);
+ params_members[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = SMember(TEnumSchemaItem<messageType::eType>::create(message_type_items), true);
+ params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[ns_smart_device_link::ns_json_handler::strings::S_CORRELATION_ID] = SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[ns_smart_device_link::ns_json_handler::strings::kCode] = SMember(TNumberSchemaItem<int>::create(), true);
- std::map<std::string, CObjectSchemaItem::SMember> root_members_map;
- root_members_map[ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS] = CObjectSchemaItem::SMember(CObjectSchemaItem::create(schema_members), true);
- root_members_map[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = CObjectSchemaItem::SMember(CObjectSchemaItem::create(params_members), true);
+ std::map<std::string, SMember> root_members_map;
+ root_members_map[ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS] = SMember(CObjectSchemaItem::create(schema_members), true);
+ root_members_map[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = SMember(CObjectSchemaItem::create(params_members), true);
return CSmartSchema(CObjectSchemaItem::create(root_members_map));
}
@@ -191,17 +191,17 @@ CSmartSchema XXX::YYY::ZZZ::Test::InitFunction_val_2_notification(
const TStructsSchemaItems &struct_schema_items,
const std::set<FunctionID::eType> &function_id_items,
const std::set<messageType::eType> &message_type_items) {
- std::map<std::string, CObjectSchemaItem::SMember> schema_members;
+ std::map<std::string, SMember> schema_members;
- std::map<std::string, CObjectSchemaItem::SMember> params_members;
- params_members[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = CObjectSchemaItem::SMember(TEnumSchemaItem<FunctionID::eType>::create(function_id_items), true);
- params_members[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(TEnumSchemaItem<messageType::eType>::create(message_type_items), true);
- params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
- params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ std::map<std::string, SMember> params_members;
+ params_members[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = SMember(TEnumSchemaItem<FunctionID::eType>::create(function_id_items), true);
+ params_members[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = SMember(TEnumSchemaItem<messageType::eType>::create(message_type_items), true);
+ params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = SMember(TNumberSchemaItem<int>::create(), true);
- std::map<std::string, CObjectSchemaItem::SMember> root_members_map;
- root_members_map[ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS] = CObjectSchemaItem::SMember(CObjectSchemaItem::create(schema_members), true);
- root_members_map[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = CObjectSchemaItem::SMember(CObjectSchemaItem::create(params_members), true);
+ std::map<std::string, SMember> root_members_map;
+ root_members_map[ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS] = SMember(CObjectSchemaItem::create(schema_members), true);
+ root_members_map[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = SMember(CObjectSchemaItem::create(params_members), true);
return CSmartSchema(CObjectSchemaItem::create(root_members_map));
}
@@ -270,28 +270,28 @@ TSharedPtr<ISchemaItem> XXX::YYY::ZZZ::Test::InitStructSchemaItem_Struct1(
// Struct member arrayOfEnum6.
TSharedPtr<ISchemaItem> arrayOfEnum6_SchemaItem = CArraySchemaItem::create(TEnumSchemaItem<Enum_new4::eType>::create(sub3_allowed_enum_subset_values, TSchemaItemParameter<Enum_new4::eType>()), TSchemaItemParameter<size_t>(10), TSchemaItemParameter<size_t>(43));
- std::map<std::string, CObjectSchemaItem::SMember> schema_members;
-
- schema_members["intParam"] = CObjectSchemaItem::SMember(intParam_SchemaItem, true);
- schema_members["doubleParam"] = CObjectSchemaItem::SMember(doubleParam_SchemaItem, false);
- schema_members["boolParam"] = CObjectSchemaItem::SMember(boolParam_SchemaItem, true);
- schema_members["structParam"] = CObjectSchemaItem::SMember(structParam_SchemaItem, true);
- schema_members["enumParam"] = CObjectSchemaItem::SMember(enumParam_SchemaItem, true);
- schema_members["enumParam1"] = CObjectSchemaItem::SMember(enumParam1_SchemaItem, true);
- schema_members["enumSubset1"] = CObjectSchemaItem::SMember(enumSubset1_SchemaItem, false);
- schema_members["arrayOfInt"] = CObjectSchemaItem::SMember(arrayOfInt_SchemaItem, false);
- schema_members["arrayOfEnum1"] = CObjectSchemaItem::SMember(arrayOfEnum1_SchemaItem, false);
- schema_members["arrayOfEnum3"] = CObjectSchemaItem::SMember(arrayOfEnum3_SchemaItem, true);
- schema_members["arrayOfEnum4"] = CObjectSchemaItem::SMember(arrayOfEnum4_SchemaItem, true);
- schema_members["arrayOfEnum5"] = CObjectSchemaItem::SMember(arrayOfEnum5_SchemaItem, true);
- schema_members["arrayOfEnum6"] = CObjectSchemaItem::SMember(arrayOfEnum6_SchemaItem, true);
+ std::map<std::string, SMember> schema_members;
+
+ schema_members["intParam"] = SMember(intParam_SchemaItem, true);
+ schema_members["doubleParam"] = SMember(doubleParam_SchemaItem, false);
+ schema_members["boolParam"] = SMember(boolParam_SchemaItem, true);
+ schema_members["structParam"] = SMember(structParam_SchemaItem, true);
+ schema_members["enumParam"] = SMember(enumParam_SchemaItem, true);
+ schema_members["enumParam1"] = SMember(enumParam1_SchemaItem, true);
+ schema_members["enumSubset1"] = SMember(enumSubset1_SchemaItem, false);
+ schema_members["arrayOfInt"] = SMember(arrayOfInt_SchemaItem, false);
+ schema_members["arrayOfEnum1"] = SMember(arrayOfEnum1_SchemaItem, false);
+ schema_members["arrayOfEnum3"] = SMember(arrayOfEnum3_SchemaItem, true);
+ schema_members["arrayOfEnum4"] = SMember(arrayOfEnum4_SchemaItem, true);
+ schema_members["arrayOfEnum5"] = SMember(arrayOfEnum5_SchemaItem, true);
+ schema_members["arrayOfEnum6"] = SMember(arrayOfEnum6_SchemaItem, true);
return CObjectSchemaItem::create(schema_members);
}
TSharedPtr<ISchemaItem> XXX::YYY::ZZZ::Test::InitStructSchemaItem_Struct2(
const TStructsSchemaItems &struct_schema_items) {
- std::map<std::string, CObjectSchemaItem::SMember> schema_members;
+ std::map<std::string, SMember> schema_members;
return CObjectSchemaItem::create(schema_members);
}
diff --git a/tools/InterfaceGenerator/test/generator/generators/test_expected_sdlrpc.cc b/tools/InterfaceGenerator/test/generator/generators/test_expected_sdlrpc.cc
index a62f485eb9..30b9b645ab 100644
--- a/tools/InterfaceGenerator/test/generator/generators/test_expected_sdlrpc.cc
+++ b/tools/InterfaceGenerator/test/generator/generators/test_expected_sdlrpc.cc
@@ -130,21 +130,21 @@ CSmartSchema XXX::YYY::ZZZ::Test::InitFunction_name1_request(
// Function parameter param2.
TSharedPtr<ISchemaItem> param2_SchemaItem = TEnumSchemaItem<Enum1::eType>::create(param2_allowed_enum_subset_values, TSchemaItemParameter<Enum1::eType>(name1));
- std::map<std::string, CObjectSchemaItem::SMember> schema_members;
+ std::map<std::string, SMember> schema_members;
- schema_members["param1"] = CObjectSchemaItem::SMember(param1_SchemaItem, true);
- schema_members["param2"] = CObjectSchemaItem::SMember(param2_SchemaItem, true);
+ schema_members["param1"] = SMember(param1_SchemaItem, true);
+ schema_members["param2"] = SMember(param2_SchemaItem, true);
- std::map<std::string, CObjectSchemaItem::SMember> params_members;
- params_members[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = CObjectSchemaItem::SMember(TEnumSchemaItem<FunctionID::eType>::create(function_id_items), true);
- params_members[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(TEnumSchemaItem<messageType::eType>::create(message_type_items), true);
- params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
- params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
- params_members[ns_smart_device_link::ns_json_handler::strings::S_CORRELATION_ID] = CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ std::map<std::string, SMember> params_members;
+ params_members[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = SMember(TEnumSchemaItem<FunctionID::eType>::create(function_id_items), true);
+ params_members[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = SMember(TEnumSchemaItem<messageType::eType>::create(message_type_items), true);
+ params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[ns_smart_device_link::ns_json_handler::strings::S_CORRELATION_ID] = SMember(TNumberSchemaItem<int>::create(), true);
- std::map<std::string, CObjectSchemaItem::SMember> root_members_map;
- root_members_map[ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS] = CObjectSchemaItem::SMember(CObjectSchemaItem::create(schema_members), true);
- root_members_map[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = CObjectSchemaItem::SMember(CObjectSchemaItem::create(params_members), true);
+ std::map<std::string, SMember> root_members_map;
+ root_members_map[ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS] = SMember(CObjectSchemaItem::create(schema_members), true);
+ root_members_map[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = SMember(CObjectSchemaItem::create(params_members), true);
return CSmartSchema(CObjectSchemaItem::create(root_members_map));
}
@@ -153,18 +153,18 @@ CSmartSchema XXX::YYY::ZZZ::Test::InitFunction_val_1_response(
const TStructsSchemaItems &struct_schema_items,
const std::set<FunctionID::eType> &function_id_items,
const std::set<messageType::eType> &message_type_items) {
- std::map<std::string, CObjectSchemaItem::SMember> schema_members;
+ std::map<std::string, SMember> schema_members;
- std::map<std::string, CObjectSchemaItem::SMember> params_members;
- params_members[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = CObjectSchemaItem::SMember(TEnumSchemaItem<FunctionID::eType>::create(function_id_items), true);
- params_members[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(TEnumSchemaItem<messageType::eType>::create(message_type_items), true);
- params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
- params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
- params_members[ns_smart_device_link::ns_json_handler::strings::S_CORRELATION_ID] = CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ std::map<std::string, SMember> params_members;
+ params_members[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = SMember(TEnumSchemaItem<FunctionID::eType>::create(function_id_items), true);
+ params_members[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = SMember(TEnumSchemaItem<messageType::eType>::create(message_type_items), true);
+ params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[ns_smart_device_link::ns_json_handler::strings::S_CORRELATION_ID] = SMember(TNumberSchemaItem<int>::create(), true);
- std::map<std::string, CObjectSchemaItem::SMember> root_members_map;
- root_members_map[ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS] = CObjectSchemaItem::SMember(CObjectSchemaItem::create(schema_members), true);
- root_members_map[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = CObjectSchemaItem::SMember(CObjectSchemaItem::create(params_members), true);
+ std::map<std::string, SMember> root_members_map;
+ root_members_map[ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS] = SMember(CObjectSchemaItem::create(schema_members), true);
+ root_members_map[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = SMember(CObjectSchemaItem::create(params_members), true);
return CSmartSchema(CObjectSchemaItem::create(root_members_map));
}
@@ -173,17 +173,17 @@ CSmartSchema XXX::YYY::ZZZ::Test::InitFunction_val_2_notification(
const TStructsSchemaItems &struct_schema_items,
const std::set<FunctionID::eType> &function_id_items,
const std::set<messageType::eType> &message_type_items) {
- std::map<std::string, CObjectSchemaItem::SMember> schema_members;
+ std::map<std::string, SMember> schema_members;
- std::map<std::string, CObjectSchemaItem::SMember> params_members;
- params_members[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = CObjectSchemaItem::SMember(TEnumSchemaItem<FunctionID::eType>::create(function_id_items), true);
- params_members[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(TEnumSchemaItem<messageType::eType>::create(message_type_items), true);
- params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
- params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ std::map<std::string, SMember> params_members;
+ params_members[ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = SMember(TEnumSchemaItem<FunctionID::eType>::create(function_id_items), true);
+ params_members[ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = SMember(TEnumSchemaItem<messageType::eType>::create(message_type_items), true);
+ params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = SMember(TNumberSchemaItem<int>::create(), true);
- std::map<std::string, CObjectSchemaItem::SMember> root_members_map;
- root_members_map[ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS] = CObjectSchemaItem::SMember(CObjectSchemaItem::create(schema_members), true);
- root_members_map[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = CObjectSchemaItem::SMember(CObjectSchemaItem::create(params_members), true);
+ std::map<std::string, SMember> root_members_map;
+ root_members_map[ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS] = SMember(CObjectSchemaItem::create(schema_members), true);
+ root_members_map[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = SMember(CObjectSchemaItem::create(params_members), true);
return CSmartSchema(CObjectSchemaItem::create(root_members_map));
}
@@ -252,28 +252,28 @@ TSharedPtr<ISchemaItem> XXX::YYY::ZZZ::Test::InitStructSchemaItem_Struct1(
// Struct member arrayOfEnum6.
TSharedPtr<ISchemaItem> arrayOfEnum6_SchemaItem = CArraySchemaItem::create(TEnumSchemaItem<Enum_new4::eType>::create(sub3_allowed_enum_subset_values, TSchemaItemParameter<Enum_new4::eType>()), TSchemaItemParameter<size_t>(10), TSchemaItemParameter<size_t>(43));
- std::map<std::string, CObjectSchemaItem::SMember> schema_members;
-
- schema_members["intParam"] = CObjectSchemaItem::SMember(intParam_SchemaItem, true);
- schema_members["doubleParam"] = CObjectSchemaItem::SMember(doubleParam_SchemaItem, false);
- schema_members["boolParam"] = CObjectSchemaItem::SMember(boolParam_SchemaItem, true);
- schema_members["structParam"] = CObjectSchemaItem::SMember(structParam_SchemaItem, true);
- schema_members["enumParam"] = CObjectSchemaItem::SMember(enumParam_SchemaItem, true);
- schema_members["enumParam1"] = CObjectSchemaItem::SMember(enumParam1_SchemaItem, true);
- schema_members["enumSubset1"] = CObjectSchemaItem::SMember(enumSubset1_SchemaItem, false);
- schema_members["arrayOfInt"] = CObjectSchemaItem::SMember(arrayOfInt_SchemaItem, false);
- schema_members["arrayOfEnum1"] = CObjectSchemaItem::SMember(arrayOfEnum1_SchemaItem, false);
- schema_members["arrayOfEnum3"] = CObjectSchemaItem::SMember(arrayOfEnum3_SchemaItem, true);
- schema_members["arrayOfEnum4"] = CObjectSchemaItem::SMember(arrayOfEnum4_SchemaItem, true);
- schema_members["arrayOfEnum5"] = CObjectSchemaItem::SMember(arrayOfEnum5_SchemaItem, true);
- schema_members["arrayOfEnum6"] = CObjectSchemaItem::SMember(arrayOfEnum6_SchemaItem, true);
+ std::map<std::string, SMember> schema_members;
+
+ schema_members["intParam"] = SMember(intParam_SchemaItem, true);
+ schema_members["doubleParam"] = SMember(doubleParam_SchemaItem, false);
+ schema_members["boolParam"] = SMember(boolParam_SchemaItem, true);
+ schema_members["structParam"] = SMember(structParam_SchemaItem, true);
+ schema_members["enumParam"] = SMember(enumParam_SchemaItem, true);
+ schema_members["enumParam1"] = SMember(enumParam1_SchemaItem, true);
+ schema_members["enumSubset1"] = SMember(enumSubset1_SchemaItem, false);
+ schema_members["arrayOfInt"] = SMember(arrayOfInt_SchemaItem, false);
+ schema_members["arrayOfEnum1"] = SMember(arrayOfEnum1_SchemaItem, false);
+ schema_members["arrayOfEnum3"] = SMember(arrayOfEnum3_SchemaItem, true);
+ schema_members["arrayOfEnum4"] = SMember(arrayOfEnum4_SchemaItem, true);
+ schema_members["arrayOfEnum5"] = SMember(arrayOfEnum5_SchemaItem, true);
+ schema_members["arrayOfEnum6"] = SMember(arrayOfEnum6_SchemaItem, true);
return CObjectSchemaItem::create(schema_members);
}
TSharedPtr<ISchemaItem> XXX::YYY::ZZZ::Test::InitStructSchemaItem_Struct2(
const TStructsSchemaItems &struct_schema_items) {
- std::map<std::string, CObjectSchemaItem::SMember> schema_members;
+ std::map<std::string, SMember> schema_members;
return CObjectSchemaItem::create(schema_members);
}
diff --git a/tools/cmake/helpers/generators.cmake b/tools/cmake/helpers/generators.cmake
index 64f7c1f670..dbdb725e49 100644
--- a/tools/cmake/helpers/generators.cmake
+++ b/tools/cmake/helpers/generators.cmake
@@ -41,6 +41,19 @@ set(INTEFRACE_GENERATOR "${CMAKE_SOURCE_DIR}/tools/InterfaceGenerator/Generator.
set(INTEFRACE_GENERATOR_CMD ${PYTHON_EXECUTABLE} -B ${INTEFRACE_GENERATOR})
file(GLOB_RECURSE INTERFACE_GENERATOR_DEPENDENCIES "${CMAKE_SOURCE_DIR}/tools/InterfaceGenerator/*.*")
+macro(generate_policy_types GENERATED_FILES
+ ARG_FULL_XML_NAME
+ ARG_NAMESPACE
+ PARSER_TYPE)
+ add_custom_command(
+ OUTPUT ${GENERATED_FILES}
+ COMMAND ${INTEFRACE_GENERATOR_CMD} ${ARG_FULL_XML_NAME} ${ARG_NAMESPACE} ${CMAKE_CURRENT_BINARY_DIR} "--parser-type" "${PARSER_TYPE}"
+ DEPENDS ${INTERFACE_GENERATOR_DEPENDENCIES} ${ARG_FULL_XML_NAME}
+ COMMENT "Generating files:\n\t${GENERATED_FILES}\nfrom:\n\t${ARG_FULL_XML_NAME}\n\
+ ${INTEFRACE_GENERATOR_CMD} ${ARG_FULL_XML_NAME} ${ARG_NAMESPACE} ${CMAKE_CURRENT_BINARY_DIR} --parser-type ${PARSER_TYPE}"
+ VERBATIM)
+endmacro()
+
macro(generate_interface ARG_XML_NAME ARG_NAMESPACE PARSER_TYPE)
string(REGEX MATCH "^[a-zA-Z_0-9]*[^.]" FILE_NAME ${ARG_XML_NAME}) # TODO: make expression more robust
diff --git a/tools/policy_table_validator/CMakeLists.txt b/tools/policy_table_validator/CMakeLists.txt
index eabe4cfd5c..d1928810f8 100644
--- a/tools/policy_table_validator/CMakeLists.txt
+++ b/tools/policy_table_validator/CMakeLists.txt
@@ -3,14 +3,17 @@
include_directories(
${CMAKE_SOURCE_DIR}/src/components/rpc_base/include/
${CMAKE_SOURCE_DIR}/src/components/utils/include/
- ${JSONCPP_INCLUDE_DIRECTORY}
+ ${COMPONENTS_DIR}/smart_objects/include/
+ ${JSONCPP_INCLUDE_DIRECTORY}
)
message(STATUS "Using ${EXTENDED_POLICY} policy mode")
if (${EXTENDED_POLICY} STREQUAL "EXTERNAL_PROPRIETARY")
include_directories(${CMAKE_SOURCE_DIR}/src/components/policy/policy_external/include/)
+ include_directories(${CMAKE_BINARY_DIR}/src/components/policy/policy_external/)
else()
include_directories(${CMAKE_SOURCE_DIR}/src/components/policy/policy_regular/include/)
+ include_directories(${CMAKE_BINARY_DIR}/src/components/policy/policy_regular/)
endif()
link_directories (