summaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/components')
-rw-r--r--src/components/CMakeLists.txt6
-rw-r--r--src/components/application_manager/CMakeLists.txt30
-rw-r--r--src/components/application_manager/include/application_manager/app_extension.h58
-rw-r--r--src/components/application_manager/include/application_manager/application.h79
-rw-r--r--src/components/application_manager/include/application_manager/application_impl.h78
-rw-r--r--src/components/application_manager/include/application_manager/application_manager_impl.h147
-rw-r--r--src/components/application_manager/include/application_manager/commands/command_request_impl.h60
-rw-r--r--src/components/application_manager/include/application_manager/commands/hmi/navi_set_video_config_request.h85
-rw-r--r--src/components/application_manager/include/application_manager/commands/hmi/navi_set_video_config_response.h74
-rw-r--r--src/components/application_manager/include/application_manager/commands/hmi/rc_get_capabilities_request.h73
-rw-r--r--src/components/application_manager/include/application_manager/commands/hmi/rc_get_capabilities_response.h73
-rw-r--r--src/components/application_manager/include/application_manager/commands/hmi/rc_is_ready_request.h90
-rw-r--r--src/components/application_manager/include/application_manager/commands/hmi/rc_is_ready_response.h73
-rw-r--r--src/components/application_manager/include/application_manager/commands/hmi/ui_send_haptic_data_request.h74
-rw-r--r--src/components/application_manager/include/application_manager/commands/hmi/ui_send_haptic_data_response.h74
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/add_command_request.h13
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/add_sub_menu_request.h11
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/create_interaction_choice_set_request.h19
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/delete_command_request.h11
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/delete_interaction_choice_set_request.h9
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/delete_sub_menu_request.h11
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/get_system_capability_request.h61
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/get_system_capability_response.h60
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/reset_global_properties_request.h11
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/send_haptic_data_request.h84
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/send_haptic_data_response.h73
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/set_global_properties_request.h11
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/subscribe_button_request.h15
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/subscribe_vehicle_data_request.h11
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/subscribe_way_points_request.h11
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/unsubscribe_button_request.h9
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/unsubscribe_vehicle_data_request.h16
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/unsubscribe_way_points_request.h12
-rw-r--r--src/components/application_manager/include/application_manager/core_service.h214
-rw-r--r--src/components/application_manager/include/application_manager/hmi_capabilities_impl.h78
-rw-r--r--src/components/application_manager/include/application_manager/hmi_interfaces.h3
-rw-r--r--src/components/application_manager/include/application_manager/hmi_state.h2
-rw-r--r--src/components/application_manager/include/application_manager/message.h41
-rw-r--r--src/components/application_manager/include/application_manager/message_helper.h37
-rw-r--r--src/components/application_manager/include/application_manager/policies/policy_handler.h102
-rw-r--r--src/components/application_manager/include/application_manager/request_info.h13
-rw-r--r--src/components/application_manager/include/application_manager/service.h183
-rw-r--r--src/components/application_manager/include/application_manager/smart_object_keys.h29
-rw-r--r--src/components/application_manager/src/app_launch/apps_launcher.cc3
-rw-r--r--src/components/application_manager/src/application_impl.cc119
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc778
-rw-r--r--src/components/application_manager/src/commands/command_request_impl.cc91
-rw-r--r--src/components/application_manager/src/commands/hmi/get_urls.cc38
-rw-r--r--src/components/application_manager/src/commands/hmi/navi_set_video_config_request.cc147
-rw-r--r--src/components/application_manager/src/commands/hmi/navi_set_video_config_response.cc55
-rw-r--r--src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc8
-rw-r--r--src/components/application_manager/src/commands/hmi/rc_get_capabilities_request.cc53
-rw-r--r--src/components/application_manager/src/commands/hmi/rc_get_capabilities_response.cc55
-rw-r--r--src/components/application_manager/src/commands/hmi/rc_is_ready_request.cc95
-rw-r--r--src/components/application_manager/src/commands/hmi/rc_is_ready_response.cc53
-rw-r--r--src/components/application_manager/src/commands/hmi/sdl_activate_app_request.cc5
-rw-r--r--src/components/application_manager/src/commands/hmi/ui_get_capabilities_response.cc26
-rw-r--r--src/components/application_manager/src/commands/hmi/ui_send_haptic_data_request.cc52
-rw-r--r--src/components/application_manager/src/commands/hmi/ui_send_haptic_data_response.cc56
-rw-r--r--src/components/application_manager/src/commands/mobile/add_command_request.cc9
-rw-r--r--src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc8
-rw-r--r--src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc15
-rw-r--r--src/components/application_manager/src/commands/mobile/delete_command_request.cc8
-rw-r--r--src/components/application_manager/src/commands/mobile/delete_file_request.cc7
-rw-r--r--src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_request.cc8
-rw-r--r--src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc8
-rw-r--r--src/components/application_manager/src/commands/mobile/get_system_capability_request.cc98
-rw-r--r--src/components/application_manager/src/commands/mobile/get_system_capability_response.cc22
-rw-r--r--src/components/application_manager/src/commands/mobile/get_way_points_request.cc10
-rw-r--r--src/components/application_manager/src/commands/mobile/list_files_request.cc23
-rw-r--r--src/components/application_manager/src/commands/mobile/on_hmi_status_notification_from_mobile.cc15
-rw-r--r--src/components/application_manager/src/commands/mobile/on_system_request_notification.cc4
-rw-r--r--src/components/application_manager/src/commands/mobile/on_touch_event_notification.cc25
-rw-r--r--src/components/application_manager/src/commands/mobile/put_file_request.cc11
-rw-r--r--src/components/application_manager/src/commands/mobile/register_app_interface_request.cc25
-rw-r--r--src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc18
-rw-r--r--src/components/application_manager/src/commands/mobile/send_haptic_data_request.cc84
-rw-r--r--src/components/application_manager/src/commands/mobile/send_haptic_data_response.cc53
-rw-r--r--src/components/application_manager/src/commands/mobile/set_app_icon_request.cc14
-rw-r--r--src/components/application_manager/src/commands/mobile/set_global_properties_request.cc12
-rw-r--r--src/components/application_manager/src/commands/mobile/subscribe_button_request.cc35
-rw-r--r--src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc9
-rw-r--r--src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc9
-rw-r--r--src/components/application_manager/src/commands/mobile/system_request.cc21
-rw-r--r--src/components/application_manager/src/commands/mobile/unregister_app_interface_request.cc1
-rw-r--r--src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc20
-rw-r--r--src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc23
-rw-r--r--src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc8
-rw-r--r--src/components/application_manager/src/core_service.cc231
-rw-r--r--src/components/application_manager/src/event_engine/event_dispatcher_impl.cc3
-rw-r--r--src/components/application_manager/src/hmi_capabilities_impl.cc184
-rw-r--r--src/components/application_manager/src/hmi_command_factory.cc54
-rw-r--r--src/components/application_manager/src/hmi_interfaces_impl.cc12
-rw-r--r--src/components/application_manager/src/hmi_state.cc8
-rw-r--r--src/components/application_manager/src/message.cc60
-rw-r--r--src/components/application_manager/src/message_helper/message_helper.cc122
-rw-r--r--src/components/application_manager/src/mobile_command_factory.cc31
-rw-r--r--src/components/application_manager/src/mobile_message_handler.cc26
-rw-r--r--src/components/application_manager/src/policies/delegates/statistics_delegate.cc12
-rw-r--r--src/components/application_manager/src/policies/policy_handler.cc218
-rw-r--r--src/components/application_manager/src/request_controller.cc10
-rw-r--r--src/components/application_manager/src/resumption/resume_ctrl_impl.cc8
-rw-r--r--src/components/application_manager/src/smart_object_keys.cc24
-rw-r--r--src/components/application_manager/src/state_controller_impl.cc13
-rw-r--r--src/components/application_manager/test/CMakeLists.txt12
-rw-r--r--src/components/application_manager/test/application_impl_test.cc53
-rw-r--r--src/components/application_manager/test/application_manager_impl_test.cc444
-rw-r--r--src/components/application_manager/test/commands/CMakeLists.txt2
-rw-r--r--src/components/application_manager/test/commands/command_request_impl_test.cc193
-rw-r--r--src/components/application_manager/test/commands/hmi/hmi_notifications/hmi_notifications_test.cc21
-rw-r--r--src/components/application_manager/test/commands/hmi/navi_audio_start_stream_request_test.cc3
-rw-r--r--src/components/application_manager/test/commands/hmi/navi_is_ready_request_test.cc3
-rw-r--r--src/components/application_manager/test/commands/hmi/navi_set_video_config_request_test.cc216
-rw-r--r--src/components/application_manager/test/commands/hmi/navi_set_video_config_response_test.cc79
-rw-r--r--src/components/application_manager/test/commands/hmi/navi_start_stream_request_test.cc3
-rw-r--r--src/components/application_manager/test/commands/hmi/navi_stop_stream_requests_test.cc1
-rw-r--r--src/components/application_manager/test/commands/hmi/rc_get_capabilities_response_test.cc108
-rw-r--r--src/components/application_manager/test/commands/hmi/rc_is_ready_request_test.cc172
-rw-r--r--src/components/application_manager/test/commands/hmi/rc_is_ready_response_test.cc79
-rw-r--r--src/components/application_manager/test/commands/hmi/sdl_activate_app_request_test.cc18
-rw-r--r--src/components/application_manager/test/commands/hmi/simple_requests_to_hmi_test.cc9
-rw-r--r--src/components/application_manager/test/commands/hmi/simple_response_from_hmi_test.cc11
-rw-r--r--src/components/application_manager/test/commands/hmi/ui_get_capabilities_response_test.cc125
-rw-r--r--src/components/application_manager/test/commands/hmi/ui_is_ready_request_test.cc1
-rw-r--r--src/components/application_manager/test/commands/hmi/vi_is_ready_request_test.cc1
-rw-r--r--src/components/application_manager/test/commands/hmi/vr_is_ready_request_test.cc1
-rw-r--r--src/components/application_manager/test/commands/mobile/add_command_request_test.cc4
-rw-r--r--src/components/application_manager/test/commands/mobile/add_sub_menu_request_test.cc9
-rw-r--r--src/components/application_manager/test/commands/mobile/alert_maneuver_request_test.cc13
-rw-r--r--src/components/application_manager/test/commands/mobile/alert_request_test.cc11
-rw-r--r--src/components/application_manager/test/commands/mobile/change_registration_test.cc52
-rw-r--r--src/components/application_manager/test/commands/mobile/create_interaction_choice_set_test.cc120
-rw-r--r--src/components/application_manager/test/commands/mobile/delete_command_request_test.cc20
-rw-r--r--src/components/application_manager/test/commands/mobile/delete_file_test.cc2
-rw-r--r--src/components/application_manager/test/commands/mobile/delete_interaction_choice_set_test.cc22
-rw-r--r--src/components/application_manager/test/commands/mobile/delete_sub_menu_test.cc28
-rw-r--r--src/components/application_manager/test/commands/mobile/dial_number_request_test.cc18
-rw-r--r--src/components/application_manager/test/commands/mobile/end_audio_pass_thru_request_test.cc10
-rw-r--r--src/components/application_manager/test/commands/mobile/get_dtcs_request_test.cc14
-rw-r--r--src/components/application_manager/test/commands/mobile/get_way_points_request_test.cc56
-rw-r--r--src/components/application_manager/test/commands/mobile/list_files_request_test.cc17
-rw-r--r--src/components/application_manager/test/commands/mobile/on_hmi_status_notification_from_mobile_test.cc20
-rw-r--r--src/components/application_manager/test/commands/mobile/on_hmi_status_notification_test.cc2
-rw-r--r--src/components/application_manager/test/commands/mobile/on_touch_event_notification_test.cc20
-rw-r--r--src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc62
-rw-r--r--src/components/application_manager/test/commands/mobile/perform_interaction_test.cc16
-rw-r--r--src/components/application_manager/test/commands/mobile/read_did_request_test.cc3
-rw-r--r--src/components/application_manager/test/commands/mobile/register_app_interface_request_test.cc6
-rw-r--r--src/components/application_manager/test/commands/mobile/reset_global_properties_test.cc25
-rw-r--r--src/components/application_manager/test/commands/mobile/scrollable_message_test.cc11
-rw-r--r--src/components/application_manager/test/commands/mobile/send_haptic_data_test.cc142
-rw-r--r--src/components/application_manager/test/commands/mobile/send_location_request_test.cc8
-rw-r--r--src/components/application_manager/test/commands/mobile/set_app_icon_test.cc17
-rw-r--r--src/components/application_manager/test/commands/mobile/set_display_layout_test.cc20
-rw-r--r--src/components/application_manager/test/commands/mobile/set_global_properties_test.cc120
-rw-r--r--src/components/application_manager/test/commands/mobile/set_media_clock_timer_test.cc17
-rw-r--r--src/components/application_manager/test/commands/mobile/show_test.cc24
-rw-r--r--src/components/application_manager/test/commands/mobile/slider_test.cc6
-rw-r--r--src/components/application_manager/test/commands/mobile/speak_request_test.cc7
-rw-r--r--src/components/application_manager/test/commands/mobile/subscribe_way_points_request_test.cc2
-rw-r--r--src/components/application_manager/test/commands/mobile/unregister_app_interface_request_test.cc2
-rw-r--r--src/components/application_manager/test/commands/mobile/unsubscribe_button_request_test.cc65
-rw-r--r--src/components/application_manager/test/commands/mobile/unsubscribe_vehicle_request_test.cc17
-rw-r--r--src/components/application_manager/test/commands/mobile/unsubscribe_way_points_request_test.cc2
-rw-r--r--src/components/application_manager/test/hmi_capabilities.json1056
-rw-r--r--src/components/application_manager/test/hmi_capabilities_test.cc118
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_application.h39
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_hmi_capabilities.h24
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_message_helper.h13
-rwxr-xr-xsrc/components/application_manager/test/message_helper/CMakeLists.txt7
-rw-r--r--src/components/application_manager/test/message_helper/message_helper_test.cc40
-rw-r--r--src/components/application_manager/test/mobile_message_handler_test.cc8
-rw-r--r--src/components/application_manager/test/mobile_message_handler_v1_test.cc6
-rw-r--r--src/components/application_manager/test/mock_message_helper.cc30
-rw-r--r--src/components/application_manager/test/policy_handler_test.cc45
-rw-r--r--src/components/application_manager/test/rc_policy_handler_test.cc400
-rw-r--r--src/components/config_profile/include/config_profile/profile.h49
-rw-r--r--src/components/config_profile/src/ini_file.cc10
-rw-r--r--src/components/config_profile/src/profile.cc106
-rw-r--r--src/components/connection_handler/include/connection_handler/connection.h2
-rw-r--r--src/components/connection_handler/include/connection_handler/connection_handler_impl.h111
-rw-r--r--src/components/connection_handler/src/connection.cc3
-rw-r--r--src/components/connection_handler/src/connection_handler_impl.cc187
-rw-r--r--src/components/connection_handler/test/connection_handler_impl_test.cc481
-rw-r--r--src/components/connection_handler/test/connection_test.cc26
-rw-r--r--src/components/formatters/test/meta_formatter_test.cc43
-rw-r--r--src/components/formatters/test/src/create_smartSchema.cc1
-rw-r--r--src/components/formatters/test/src/meta_formatter_test_helper.cc27
-rw-r--r--src/components/functional_module/CMakeLists.txt58
-rw-r--r--src/components/functional_module/include/functional_module/function_ids.h63
-rw-r--r--src/components/functional_module/include/functional_module/generic_module.h179
-rw-r--r--src/components/functional_module/include/functional_module/module_observer.h54
-rw-r--r--src/components/functional_module/include/functional_module/plugin_manager.h158
-rw-r--r--src/components/functional_module/include/functional_module/timer/module_timer.h246
-rw-r--r--src/components/functional_module/include/functional_module/timer/timer_director.h92
-rw-r--r--src/components/functional_module/src/generic_module.cc54
-rw-r--r--src/components/functional_module/src/plugin_manager.cc393
-rw-r--r--src/components/functional_module/src/timer/timer_director.cc156
-rw-r--r--src/components/functional_module/test/CMakeLists.txt53
-rw-r--r--src/components/functional_module/test/include/driver_generic_module_test.h80
-rw-r--r--src/components/functional_module/test/include/mock_application.h248
-rw-r--r--src/components/functional_module/test/include/mock_module_observer.h50
-rw-r--r--src/components/functional_module/test/include/mock_service.h76
-rw-r--r--src/components/functional_module/test/include/module_timer_test.h56
-rw-r--r--src/components/functional_module/test/plugins/CMakeLists.txt17
-rw-r--r--src/components/functional_module/test/plugins/mock_generic_module.cc23
-rw-r--r--src/components/functional_module/test/plugins/mock_generic_module.h71
-rw-r--r--src/components/functional_module/test/src/generic_module_test.cc106
-rw-r--r--src/components/functional_module/test/src/module_timer_test.cc123
-rw-r--r--src/components/functional_module/test/src/plugin_manager_test.cc146
-rw-r--r--src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_adapter_impl.h2
-rw-r--r--src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_handler_impl.h19
-rw-r--r--src/components/hmi_message_handler/src/dbus_message_adapter.cc3
-rw-r--r--src/components/hmi_message_handler/src/hmi_message_handler_impl.cc3
-rw-r--r--src/components/hmi_message_handler/src/messagebroker_adapter.cc7
-rw-r--r--src/components/hmi_message_handler/test/hmi_message_adapter_test.cc4
-rw-r--r--src/components/hmi_message_handler/test/hmi_message_handler_impl_test.cc6
-rw-r--r--src/components/include/application_manager/application_manager.h68
-rw-r--r--src/components/include/application_manager/application_manager_settings.h1
-rw-r--r--src/components/include/application_manager/hmi_capabilities.h76
-rw-r--r--src/components/include/application_manager/policies/policy_handler_interface.h82
-rw-r--r--src/components/include/connection_handler/connection_handler.h16
-rw-r--r--src/components/include/connection_handler/connection_handler_observer.h18
-rw-r--r--src/components/include/hmi_message_handler/hmi_message_adapter.h6
-rw-r--r--src/components/include/hmi_message_handler/hmi_message_handler_settings.h2
-rw-r--r--src/components/include/hmi_message_handler/hmi_message_observer.h1
-rw-r--r--src/components/include/hmi_message_handler/hmi_message_sender.h1
-rw-r--r--src/components/include/policy/policy_external/policy/policy_listener.h78
-rw-r--r--src/components/include/policy/policy_external/policy/policy_manager.h183
-rw-r--r--src/components/include/policy/policy_external/policy/usage_statistics/app_stopwatch.h8
-rw-r--r--src/components/include/policy/policy_external/policy/usage_statistics/statistics_manager.h42
-rw-r--r--src/components/include/policy/policy_regular/policy/policy_listener.h (renamed from src/components/policy/policy_regular/include/policy/policy_listener.h)45
-rw-r--r--src/components/include/policy/policy_regular/policy/policy_manager.h174
-rw-r--r--src/components/include/policy/policy_regular/policy/usage_statistics/app_stopwatch.h (renamed from src/components/policy/policy_regular/include/policy/usage_statistics/app_stopwatch.h)6
-rw-r--r--src/components/include/policy/policy_regular/policy/usage_statistics/statistics_manager.h42
-rw-r--r--src/components/include/protocol/bson_object_keys.h48
-rw-r--r--src/components/include/protocol/common.h11
-rw-r--r--src/components/include/protocol_handler/protocol_handler.h21
-rw-r--r--src/components/include/protocol_handler/protocol_handler_settings.h8
-rw-r--r--src/components/include/protocol_handler/session_observer.h40
-rw-r--r--src/components/include/test/application_manager/mock_application_manager.h32
-rw-r--r--src/components/include/test/application_manager/mock_application_manager_settings.h1
-rw-r--r--src/components/include/test/application_manager/policies/mock_policy_handler_interface.h34
-rw-r--r--src/components/include/test/connection_handler/mock_connection_handler.h4
-rw-r--r--src/components/include/test/connection_handler/mock_connection_handler_observer.h6
-rw-r--r--src/components/include/test/hmi_message_handler/mock_hmi_message_handler_settings.h2
-rw-r--r--src/components/include/test/policy/policy_external/policy/mock_cache_manager.h (renamed from src/components/policy/policy_external/test/include/policy/mock_cache_manager.h)6
-rw-r--r--src/components/include/test/policy/policy_external/policy/mock_policy_listener.h16
-rw-r--r--src/components/include/test/policy/policy_external/policy/mock_policy_manager.h25
-rw-r--r--src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h (renamed from src/components/policy/policy_regular/test/include/policy/mock_cache_manager.h)10
-rw-r--r--src/components/include/test/policy/policy_regular/policy/mock_policy_listener.h (renamed from src/components/policy/policy_regular/test/include/policy/mock_policy_listener.h)43
-rw-r--r--src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h24
-rw-r--r--src/components/include/test/protocol_handler/mock_protocol_handler.h7
-rw-r--r--src/components/include/test/protocol_handler/mock_protocol_handler_settings.h4
-rw-r--r--src/components/include/test/protocol_handler/mock_session_observer.h13
-rw-r--r--src/components/include/utils/macro.h11
-rw-r--r--src/components/interfaces/HMI_API.xml734
-rw-r--r--src/components/interfaces/MOBILE_API.xml1232
-rw-r--r--src/components/interfaces/QT_HMI_API.xml30
-rw-r--r--src/components/interfaces/v4_protocol_v1_2_no_extra.xml186
-rw-r--r--src/components/media_manager/CMakeLists.txt7
-rw-r--r--src/components/media_manager/include/media_manager/media_manager_impl.h7
-rw-r--r--src/components/media_manager/src/audio/audio_stream_sender_thread.cc1
-rw-r--r--src/components/media_manager/src/audio/from_mic_recorder_listener.cc5
-rw-r--r--src/components/media_manager/src/media_manager_impl.cc8
-rw-r--r--src/components/media_manager/test/media_manager_impl_test.cc423
-rw-r--r--src/components/policy/policy_external/CMakeLists.txt4
-rw-r--r--src/components/policy/policy_external/include/policy/access_remote.h139
-rw-r--r--src/components/policy/policy_external/include/policy/access_remote_impl.h174
-rw-r--r--src/components/policy/policy_external/include/policy/cache_manager.h8
-rw-r--r--src/components/policy/policy_external/include/policy/cache_manager_interface.h4
-rw-r--r--src/components/policy/policy_external/include/policy/policy_helper.h3
-rw-r--r--src/components/policy/policy_external/include/policy/policy_manager_impl.h802
-rw-r--r--src/components/policy/policy_external/include/policy/policy_table/enums.h4
-rw-r--r--src/components/policy/policy_external/include/policy/policy_table/types.h16
-rw-r--r--src/components/policy/policy_external/include/policy/policy_types.h4
-rw-r--r--src/components/policy/policy_external/include/policy/sql_pt_queries.h12
-rw-r--r--src/components/policy/policy_external/include/policy/sql_pt_representation.h17
-rw-r--r--src/components/policy/policy_external/include/policy/status.h3
-rw-r--r--src/components/policy/policy_external/src/access_remote_impl.cc261
-rw-r--r--src/components/policy/policy_external/src/cache_manager.cc4
-rw-r--r--src/components/policy/policy_external/src/policy_helper.cc61
-rw-r--r--src/components/policy/policy_external/src/policy_manager_impl.cc168
-rw-r--r--src/components/policy/policy_external/src/policy_table/enums.cc50
-rw-r--r--src/components/policy/policy_external/src/policy_table/types.cc32
-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.cc136
-rw-r--r--src/components/policy/policy_external/src/sql_pt_representation.cc225
-rw-r--r--src/components/policy/policy_external/src/update_status_manager.cc2
-rw-r--r--src/components/policy/policy_external/test/CMakeLists.txt6
-rw-r--r--src/components/policy/policy_external/test/include/policy/mock_access_remote.h73
-rw-r--r--src/components/policy/policy_external/test/include/policy/mock_app_stopwatch.h53
-rw-r--r--src/components/policy/policy_external/test/policy_manager_impl_test_base.cc2
-rw-r--r--src/components/policy/policy_external/test/sql_pt_representation_test.cc4
-rw-r--r--src/components/policy/policy_regular/CMakeLists.txt9
-rw-r--r--src/components/policy/policy_regular/include/policy/access_remote.h122
-rw-r--r--src/components/policy/policy_regular/include/policy/access_remote_impl.h169
-rw-r--r--src/components/policy/policy_regular/include/policy/cache_manager.h18
-rw-r--r--src/components/policy/policy_regular/include/policy/cache_manager_interface.h14
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_manager_impl.h796
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_table/enums.h3
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_table/types.h18
-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.h17
-rw-r--r--src/components/policy/policy_regular/include/policy/status.h3
-rw-r--r--src/components/policy/policy_regular/include/policy/update_status_manager.h21
-rw-r--r--src/components/policy/policy_regular/include/policy/update_status_manager_interface.h3
-rw-r--r--src/components/policy/policy_regular/src/access_remote_impl.cc247
-rw-r--r--src/components/policy/policy_regular/src/cache_manager.cc17
-rw-r--r--src/components/policy/policy_regular/src/policy_manager_impl.cc187
-rw-r--r--src/components/policy/policy_regular/src/policy_table/enums.cc49
-rw-r--r--src/components/policy/policy_regular/src/policy_table/types.cc29
-rw-r--r--src/components/policy/policy_regular/src/policy_table/validation.cc74
-rw-r--r--src/components/policy/policy_regular/src/sql_pt_queries.cc82
-rw-r--r--src/components/policy/policy_regular/src/sql_pt_representation.cc226
-rw-r--r--src/components/policy/policy_regular/src/update_status_manager.cc78
-rw-r--r--src/components/policy/policy_regular/test/CMakeLists.txt6
-rw-r--r--src/components/policy/policy_regular/test/access_remote_impl_test.cc95
-rw-r--r--src/components/policy/policy_regular/test/include/policy/mock_access_remote.h73
-rw-r--r--src/components/policy/policy_regular/test/include/policy/mock_policy_manager.h185
-rw-r--r--src/components/policy/policy_regular/test/include/policy/mock_update_status_manager.h2
-rw-r--r--src/components/policy/policy_regular/test/policy_manager_impl_test.cc24
-rw-r--r--src/components/policy/policy_regular/test/sql_pt_representation_test.cc39
-rw-r--r--src/components/policy/policy_regular/test/update_status_manager_test.cc4
-rw-r--r--src/components/protocol/src/bson_object_keys.cc18
-rw-r--r--src/components/protocol_handler/CMakeLists.txt4
-rw-r--r--src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h106
-rw-r--r--src/components/protocol_handler/include/protocol_handler/protocol_packet.h65
-rw-r--r--src/components/protocol_handler/src/incoming_data_handler.cc1
-rw-r--r--src/components/protocol_handler/src/protocol_handler_impl.cc566
-rw-r--r--src/components/protocol_handler/src/protocol_packet.cc134
-rw-r--r--src/components/protocol_handler/test/incoming_data_handler_test.cc2
-rw-r--r--src/components/protocol_handler/test/protocol_handler_tm_test.cc447
-rw-r--r--src/components/protocol_handler/test/protocol_header_validator_test.cc91
-rw-r--r--src/components/protocol_handler/test/protocol_packet_test.cc12
-rw-r--r--src/components/remote_control/CMakeLists.txt83
-rw-r--r--src/components/remote_control/include/remote_control/commands/base_command_notification.h110
-rw-r--r--src/components/remote_control/include/remote_control/commands/base_command_request.h293
-rw-r--r--src/components/remote_control/include/remote_control/commands/button_press_request.h104
-rw-r--r--src/components/remote_control/include/remote_control/commands/command.h84
-rw-r--r--src/components/remote_control/include/remote_control/commands/get_interior_vehicle_data_request.h101
-rw-r--r--src/components/remote_control/include/remote_control/commands/on_interior_vehicle_data_notification.h75
-rw-r--r--src/components/remote_control/include/remote_control/commands/on_remote_control_settings_notification.h79
-rw-r--r--src/components/remote_control/include/remote_control/commands/set_interior_vehicle_data_request.h127
-rw-r--r--src/components/remote_control/include/remote_control/event_engine/event.h127
-rw-r--r--src/components/remote_control/include/remote_control/event_engine/event_dispatcher.h203
-rw-r--r--src/components/remote_control/include/remote_control/event_engine/event_observer.h96
-rw-r--r--src/components/remote_control/include/remote_control/message_helper.h122
-rw-r--r--src/components/remote_control/include/remote_control/module_helper.h0
-rw-r--r--src/components/remote_control/include/remote_control/rc_app_extension.h82
-rw-r--r--src/components/remote_control/include/remote_control/rc_command_factory.h66
-rw-r--r--src/components/remote_control/include/remote_control/rc_module_constants.h233
-rw-r--r--src/components/remote_control/include/remote_control/rc_module_timer.h70
-rw-r--r--src/components/remote_control/include/remote_control/remote_control_event.h82
-rw-r--r--src/components/remote_control/include/remote_control/remote_control_plugin.h163
-rw-r--r--src/components/remote_control/include/remote_control/remote_plugin_interface.h118
-rw-r--r--src/components/remote_control/include/remote_control/request_controller.h110
-rw-r--r--src/components/remote_control/include/remote_control/resource_allocation_manager.h114
-rw-r--r--src/components/remote_control/include/remote_control/resource_allocation_manager_impl.h136
-rw-r--r--src/components/remote_control/src/commands/base_command_notification.cc154
-rw-r--r--src/components/remote_control/src/commands/base_command_request.cc564
-rw-r--r--src/components/remote_control/src/commands/button_press_request.cc264
-rw-r--r--src/components/remote_control/src/commands/get_interior_vehicle_data_request.cc224
-rw-r--r--src/components/remote_control/src/commands/on_interior_vehicle_data_notification.cc103
-rw-r--r--src/components/remote_control/src/commands/on_remote_control_settings_notification.cc122
-rw-r--r--src/components/remote_control/src/commands/set_interior_vehicle_data_request.cc350
-rw-r--r--src/components/remote_control/src/message_helper.cc154
-rw-r--r--src/components/remote_control/src/module_helper.cc0
-rw-r--r--src/components/remote_control/src/rc_app_extension.cc62
-rw-r--r--src/components/remote_control/src/rc_command_factory.cc86
-rw-r--r--src/components/remote_control/src/remote_control_event.cc56
-rw-r--r--src/components/remote_control/src/remote_control_plugin.cc334
-rw-r--r--src/components/remote_control/src/request_controller.cc96
-rw-r--r--src/components/remote_control/src/resource_allocation_manager_impl.cc373
-rw-r--r--src/components/remote_control/test/CMakeLists.txt67
-rw-r--r--src/components/remote_control/test/commands/CMakeLists.txt62
-rw-r--r--src/components/remote_control/test/commands/button_press_request_test.cc344
-rw-r--r--src/components/remote_control/test/commands/get_interior_vehicle_data_request_test.cc291
-rw-r--r--src/components/remote_control/test/commands/on_interior_vehicle_data_notification_test.cc182
-rw-r--r--src/components/remote_control/test/commands/on_remote_control_settings_test.cc326
-rw-r--r--src/components/remote_control/test/commands/set_interior_vehicle_data_request_test.cc433
-rw-r--r--src/components/remote_control/test/include/mock_application.h335
-rw-r--r--src/components/remote_control/test/include/mock_remote_control_plugin.h54
-rw-r--r--src/components/remote_control/test/include/mock_resource_allocation_manager.h40
-rw-r--r--src/components/remote_control/test/src/rc_app_extension_test.cc43
-rw-r--r--src/components/remote_control/test/src/rc_library_test.cc92
-rw-r--r--src/components/remote_control/test/src/rc_module_test.cc263
-rw-r--r--src/components/remote_control/test/src/resource_allocation_manager_impl_test.cc470
-rw-r--r--src/components/rpc_base/include/rpc_base/rpc_base_inl.h6
-rw-r--r--src/components/rpc_base/include/rpc_base/rpc_base_json_inl.h3
-rw-r--r--src/components/security_manager/include/security_manager/crypto_manager_impl.h9
-rw-r--r--src/components/security_manager/src/crypto_manager_impl.cc35
-rw-r--r--src/components/security_manager/src/ssl_context_impl.cc92
-rw-r--r--src/components/security_manager/test/crypto_manager_impl_test.cc26
-rw-r--r--src/components/security_manager/test/ssl_certificate_handshake_test.cc8
-rw-r--r--src/components/security_manager/test/ssl_context_test.cc4
-rw-r--r--src/components/telemetry_monitor/CMakeLists.txt2
-rw-r--r--src/components/telemetry_monitor/include/telemetry_monitor/telemetry_monitor.h1
-rw-r--r--src/components/telemetry_monitor/src/telemetry_monitor.cc64
-rw-r--r--src/components/telemetry_monitor/test/telemetry_monitor_test.cc8
-rw-r--r--src/components/transport_manager/src/bluetooth/bluetooth_device_scanner.cc4
-rw-r--r--src/components/transport_manager/src/bluetooth/bluetooth_socket_connection.cc14
-rw-r--r--src/components/transport_manager/src/tcp/tcp_client_listener.cc47
-rw-r--r--src/components/transport_manager/src/transport_adapter/threaded_socket_connection.cc2
-rw-r--r--src/components/transport_manager/test/transport_manager_impl_test.cc8
-rw-r--r--src/components/utils/include/utils/file_system.h9
-rw-r--r--src/components/utils/include/utils/log_message_loop_thread.h2
-rw-r--r--src/components/utils/src/file_system.cc59
-rw-r--r--src/components/utils/src/log_message_loop_thread.cc4
-rw-r--r--src/components/utils/src/threads/thread_delegate.cc1
-rw-r--r--src/components/utils/src/timer.cc2
-rw-r--r--src/components/utils/test/async_runner_test.cc112
-rw-r--r--src/components/utils/test/conditional_variable_test.cc2
-rw-r--r--src/components/utils/test/messagemeter_test.cc10
-rw-r--r--src/components/utils/test/scope_guard_test.cc18
-rw-r--r--src/components/utils/test/shared_ptr_test.cc2
-rw-r--r--src/components/utils/test/sqlite_wrapper/sql_query_test.cc4
417 files changed, 29532 insertions, 3403 deletions
diff --git a/src/components/CMakeLists.txt b/src/components/CMakeLists.txt
index 0304ce986f..e1071e826f 100644
--- a/src/components/CMakeLists.txt
+++ b/src/components/CMakeLists.txt
@@ -86,6 +86,12 @@ add_subdirectory(./config_profile)
# --- Media Manager
add_subdirectory(./media_manager)
+if(REMOTE_CONTROL)
+ # --- CAN Module
+ add_subdirectory(./remote_control)
+ # --- Functional module
+ add_subdirectory(./functional_module)
+endif()
# --- Telemetry Monitor
if(TELEMETRY_MONITOR)
add_subdirectory(./telemetry_monitor)
diff --git a/src/components/application_manager/CMakeLists.txt b/src/components/application_manager/CMakeLists.txt
index 0cfb80ed64..7a49ce6b81 100644
--- a/src/components/application_manager/CMakeLists.txt
+++ b/src/components/application_manager/CMakeLists.txt
@@ -1,6 +1,9 @@
# Copyright (c) 2016, Ford Motor Company
# All rights reserved.
#
+# Copyright (c) 2017 Xevo Inc.
+# All rights reserved.
+#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
@@ -12,7 +15,7 @@
# 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
+# Neither the name of the copyright holders nor the names of their contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
@@ -38,6 +41,7 @@ set (AM_MOCK_DIR ${AM_TEST_DIR}/mock)
include_directories (
include/
${COMPONENTS_DIR}
+ ${COMPONENTS_DIR}/functional_module/include/
${COMPONENTS_DIR}/utils/include/
${COMPONENTS_DIR}/formatters/include/
${COMPONENTS_DIR}/protocol_handler/include/
@@ -57,6 +61,7 @@ include_directories (
${ENCRYPTION_INCLUDE_DIRECTORY}
${MESSAGE_BROKER_INCLUDE_DIRECTORY}
${LOG4CXX_INCLUDE_DIRECTORY}
+ ${BSON_INCLUDE_DIRECTORY}
)
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
@@ -306,6 +311,8 @@ set (HMI_COMMANDS_SOURCES
${COMMANDS_SOURCE_DIR}/hmi/navi_audio_stop_stream_response.cc
${COMMANDS_SOURCE_DIR}/hmi/navi_get_way_points_request.cc
${COMMANDS_SOURCE_DIR}/hmi/navi_get_way_points_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/navi_set_video_config_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/navi_set_video_config_response.cc
${COMMANDS_SOURCE_DIR}/hmi/on_system_request_notification.cc
${COMMANDS_SOURCE_DIR}/hmi/on_put_file_notification.cc
${COMMANDS_SOURCE_DIR}/hmi/on_resume_audio_source_notification.cc
@@ -331,6 +338,12 @@ set (HMI_COMMANDS_SOURCES
${COMMANDS_SOURCE_DIR}/hmi/decrypt_certificate_request.cc
${COMMANDS_SOURCE_DIR}/hmi/decrypt_certificate_response.cc
${COMMANDS_SOURCE_DIR}/hmi/ui_set_icon_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/rc_is_ready_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/rc_is_ready_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/rc_get_capabilities_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/rc_get_capabilities_response.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_send_haptic_data_request.cc
+ ${COMMANDS_SOURCE_DIR}/hmi/ui_send_haptic_data_response.cc
)
set (HMI_COMMANDS_SOURCES_JSON
@@ -386,6 +399,11 @@ set(PATHS
)
collect_sources(SOURCES "${PATHS}" "${EXCLUDE_PATHS}")
+if (NOT REMOTE_CONTROL)
+ list(REMOVE_ITEM SOURCES
+ ${COMPONENTS_DIR}/application_manager/src/core_service.cc)
+endif()
+
set(LIBRARIES
HMI_API
MOBILE_API
@@ -397,8 +415,17 @@ set(LIBRARIES
formatters
dbms
Utils
+ bson -L${BSON_LIBS_DIRECTORY}
+ emhashmap -L${EMHASHMAP_LIBS_DIRECTORY}
)
+if(REMOTE_CONTROL)
+ SET (LIBRARIES
+ ${LIBRARIES}
+ FunctionalModule
+ )
+endif(REMOTE_CONTROL)
+
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
list(APPEND LIBRARIES sqlite3)
endif ()
@@ -435,6 +462,7 @@ if(ENABLE_LOG)
list(APPEND LIBRARIES log4cxx -L${LOG4CXX_LIBS_DIRECTORY})
endif()
+add_dependencies("ApplicationManager" libbson)
target_link_libraries("ApplicationManager" ${LIBRARIES})
if(BUILD_TESTS)
diff --git a/src/components/application_manager/include/application_manager/app_extension.h b/src/components/application_manager/include/application_manager/app_extension.h
new file mode 100644
index 0000000000..221601a307
--- /dev/null
+++ b/src/components/application_manager/include/application_manager/app_extension.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2013, 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_INCLUDE_APPLICATION_MANAGER_APP_EXTENSION_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_EXTENSION_H_
+
+#include "utils/shared_ptr.h"
+
+namespace application_manager {
+
+typedef int AppExtensionUID;
+
+class AppExtension {
+ public:
+ explicit AppExtension(AppExtensionUID uid) : kUid_(uid) {}
+ virtual ~AppExtension() {}
+ AppExtensionUID uid() const {
+ return kUid_;
+ }
+
+ private:
+ const AppExtensionUID kUid_;
+};
+
+typedef utils::SharedPtr<AppExtension> AppExtensionPtr;
+
+} // namespace application_manager
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_EXTENSION_H_
diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h
index 08581b43c1..3a03cb5343 100644
--- a/src/components/application_manager/include/application_manager/application.h
+++ b/src/components/application_manager/include/application_manager/application.h
@@ -37,10 +37,12 @@
#include <map>
#include <set>
#include <list>
+#include <vector>
#include "utils/shared_ptr.h"
#include "utils/data_accessor.h"
#include "interfaces/MOBILE_API.h"
#include "connection_handler/device.h"
+#include "application_manager/app_extension.h"
#include "application_manager/message.h"
#include "application_manager/hmi_state.h"
#include "application_manager/application_state.h"
@@ -78,7 +80,10 @@ struct Version {
struct AppFile {
// need to use in std::map;
- AppFile() {}
+ AppFile()
+ : is_persistent(false)
+ , is_download_complete(false)
+ , file_type(mobile_apis::FileType::INVALID_ENUM) {}
AppFile(const std::string& name,
bool persistent,
bool download_complete,
@@ -380,7 +385,6 @@ class Application : public virtual InitialApplicationData,
public:
enum ApplicationRegisterState { kRegistered = 0, kWaitingForRegistration };
- public:
Application() : is_greyed_out_(false) {}
virtual ~Application() {}
@@ -424,6 +428,9 @@ class Application : public virtual InitialApplicationData,
virtual bool is_navi() const = 0;
virtual void set_is_navi(bool allow) = 0;
+ virtual void set_mobile_projection_enabled(bool option) = 0;
+ virtual bool mobile_projection_enabled() const = 0;
+
virtual bool video_streaming_approved() const = 0;
virtual void set_video_streaming_approved(bool state) = 0;
virtual bool audio_streaming_approved() const = 0;
@@ -435,6 +442,15 @@ class Application : public virtual InitialApplicationData,
virtual void set_audio_streaming_allowed(bool state) = 0;
/**
+ * @brief Sends SetVideoConfig request to HMI to configure streaming
+ * @param service_type Type of streaming service, should be kMobileNav
+ * @param params parameters of video streaming in key-value format
+ * @return true if SetVideoConfig is sent, false otherwise
+ */
+ virtual bool SetVideoConfig(protocol_handler::ServiceType service_type,
+ const smart_objects::SmartObject& params) = 0;
+
+ /**
* @brief Starts streaming service for application
* @param service_type Type of streaming service
*/
@@ -536,8 +552,8 @@ class Application : public virtual InitialApplicationData,
virtual void set_grammar_id(uint32_t value) = 0;
virtual void set_protocol_version(
- const ProtocolVersion& protocol_version) = 0;
- virtual ProtocolVersion protocol_version() const = 0;
+ const protocol_handler::MajorProtocolVersion& protocol_version) = 0;
+ virtual protocol_handler::MajorProtocolVersion protocol_version() const = 0;
virtual void set_is_resuming(bool is_resuming) = 0;
virtual bool is_resuming() const = 0;
@@ -770,6 +786,60 @@ class Application : public virtual InitialApplicationData,
*/
virtual uint32_t GetAvailableDiskSpace() = 0;
+#ifdef SDL_REMOTE_CONTROL
+ /**
+ * @brief set_system_context Set system context for application
+ * @param system_context Current context
+ */
+ virtual void set_system_context(
+ const mobile_api::SystemContext::eType& system_context) = 0;
+
+ /**
+ * @brief set_audio_streaming_state Set audio streaming state for application
+ * @param state Current audio streaming state
+ */
+ virtual void set_audio_streaming_state(
+ const mobile_api::AudioStreamingState::eType& state) = 0;
+
+ /**
+ * @brief set_hmi_level Set HMI level for application
+ * @param hmi_level Current HMI level
+ */
+ virtual void set_hmi_level(const mobile_api::HMILevel::eType& hmi_level) = 0;
+
+ /**
+ * @brief Return pointer to extension by uid
+ * @param uid uid of extension
+ * @return Pointer to extension, if extension was initialized, otherwise NULL
+ */
+ virtual AppExtensionPtr QueryInterface(AppExtensionUID uid) = 0;
+
+ /**
+ * @brief Add extension to application
+ * @param extension pointer to extension
+ * @return true if success, false if extension already initialized
+ */
+ virtual bool AddExtension(AppExtensionPtr extention) = 0;
+
+ /**
+ * @brief Remove extension from application
+ * @param uid uid of extension
+ * @return true if success, false if extension is not present
+ */
+ virtual bool RemoveExtension(AppExtensionUID uid) = 0;
+
+ /**
+ * @brief Removes all extensions
+ */
+ virtual void RemoveExtensions() = 0;
+
+ /**
+ * @brief Get list of subscriptions to vehicle info notifications
+ * @return list of subscriptions to vehicle info notifications
+ */
+ virtual const std::set<uint32_t>& SubscribesIVI() const = 0;
+#endif // SDL_REMOTE_CONTROL
+
protected:
mutable sync_primitives::Lock hmi_states_lock_;
@@ -784,6 +854,7 @@ class Application : public virtual InitialApplicationData,
typedef utils::SharedPtr<Application> ApplicationSharedPtr;
typedef utils::SharedPtr<const Application> ApplicationConstSharedPtr;
+typedef uint32_t ApplicationId;
} // namespace application_manager
diff --git a/src/components/application_manager/include/application_manager/application_impl.h b/src/components/application_manager/include/application_manager/application_impl.h
index ae63a2f8ae..dc2d8ce528 100644
--- a/src/components/application_manager/include/application_manager/application_impl.h
+++ b/src/components/application_manager/include/application_manager/application_impl.h
@@ -38,6 +38,7 @@
#include <vector>
#include <utility>
#include <list>
+#include <forward_list>
#include <stdint.h>
#include "utils/date_time.h"
@@ -64,7 +65,8 @@ using namespace timer;
namespace mobile_api = mobile_apis;
namespace custom_str = custom_string;
-class ApplicationImpl : public virtual InitialApplicationDataImpl,
+class ApplicationImpl : public virtual Application,
+ public virtual InitialApplicationDataImpl,
public virtual DynamicApplicationDataImpl {
public:
ApplicationImpl(
@@ -96,6 +98,10 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl,
}
void set_is_navi(bool allow);
+ void set_mobile_projection_enabled(bool option);
+
+ bool mobile_projection_enabled() const;
+
bool video_streaming_approved() const;
void set_video_streaming_approved(bool state);
bool audio_streaming_approved() const;
@@ -106,6 +112,8 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl,
bool audio_streaming_allowed() const;
void set_audio_streaming_allowed(bool state);
+ bool SetVideoConfig(protocol_handler::ServiceType service_type,
+ const smart_objects::SmartObject& params);
void StartStreaming(protocol_handler::ServiceType service_type);
void StopStreamingForce(protocol_handler::ServiceType service_type);
void StopStreaming(protocol_handler::ServiceType service_type);
@@ -158,8 +166,9 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl,
virtual void set_grammar_id(uint32_t value);
bool is_audio() const OVERRIDE;
- virtual void set_protocol_version(const ProtocolVersion& protocol_version);
- virtual ProtocolVersion protocol_version() const;
+ virtual void set_protocol_version(
+ const protocol_handler::MajorProtocolVersion& protocol_version);
+ virtual protocol_handler::MajorProtocolVersion protocol_version() const;
virtual void set_is_resuming(bool is_resuming);
virtual bool is_resuming() const;
@@ -184,7 +193,7 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl,
/**
* @brief ResetDataInNone reset data counters in NONE
*/
- virtual void ResetDataInNone();
+ virtual void ResetDataInNone() OVERRIDE;
virtual DataAccessor<ButtonSubscriptions> SubscribedButtons() const OVERRIDE;
@@ -299,6 +308,39 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl,
*/
uint32_t GetAvailableDiskSpace() OVERRIDE;
+#ifdef SDL_REMOTE_CONTROL
+ /**
+ * @brief Sets current system context
+ * @param system_context new system context
+ */
+ void set_system_context(
+ const mobile_api::SystemContext::eType& system_context) OVERRIDE;
+ /**
+ * @brief Sets current audio streaming state
+ * @param state new audio streaming state
+ */
+ void set_audio_streaming_state(
+ const mobile_api::AudioStreamingState::eType& state) OVERRIDE;
+ /**
+ * @brief Sets current HMI level
+ * @param hmi_level new HMI level
+ */
+ void set_hmi_level(const mobile_api::HMILevel::eType& hmi_level) OVERRIDE;
+
+ /**
+ * @brief Get list of subscriptions to vehicle info notifications
+ * @return list of subscriptions to vehicle info notifications
+ */
+ const std::set<uint32_t>& SubscribesIVI() const OVERRIDE;
+
+ /**
+ * @brief Return pointer to extension by uid
+ * @param uid uid of extension
+ * @return Pointer to extension, if extension was initialized, otherwise NULL
+ */
+ AppExtensionPtr QueryInterface(AppExtensionUID uid) OVERRIDE;
+#endif
+
protected:
/**
* @brief Clean up application folder. Persistent files will stay
@@ -328,6 +370,27 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl,
*/
void OnAudioStreamSuspend();
+#ifdef SDL_REMOTE_CONTROL
+ /**
+ * @brief Add extension to application
+ * @param extension pointer to extension
+ * @return true if success, false if extension already initialized
+ */
+ bool AddExtension(AppExtensionPtr extention) OVERRIDE;
+
+ /**
+ * @brief Remove extension from application
+ * @param uid uid of extension
+ * @return true if success, false if extension is not present
+ */
+ bool RemoveExtension(AppExtensionUID uid) OVERRIDE;
+
+ /**
+ * @brief Removes all extensions
+ */
+ void RemoveExtensions() OVERRIDE;
+#endif // SDL_REMOTE_CONTROL
+
std::string hash_val_;
uint32_t grammar_id_;
@@ -338,6 +401,7 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl,
smart_objects::SmartObject* active_message_;
bool is_media_;
bool is_navi_;
+ bool mobile_projection_enabled_;
bool video_streaming_approved_;
bool audio_streaming_approved_;
@@ -365,7 +429,7 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl,
std::set<mobile_apis::ButtonName::eType> subscribed_buttons_;
VehicleInfoSubscriptions subscribed_vehicle_info_;
UsageStatistics usage_report_;
- ProtocolVersion protocol_version_;
+ protocol_handler::MajorProtocolVersion protocol_version_;
bool is_voice_communication_application_;
sync_primitives::atomic_bool is_resuming_;
@@ -376,6 +440,10 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl,
Timer video_stream_suspend_timer_;
Timer audio_stream_suspend_timer_;
+#ifdef SDL_REMOTE_CONTROL
+ std::list<AppExtensionPtr> extensions_;
+#endif // SDL_REMOTE_CONTROL
+
/**
* @brief Defines number per time in seconds limits
*/
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 c38141bf7f..7a26501afc 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
@@ -59,6 +59,7 @@
#include "protocol_handler/protocol_handler.h"
#include "hmi_message_handler/hmi_message_observer.h"
#include "hmi_message_handler/hmi_message_sender.h"
+#include "application_manager/policies/policy_handler_interface.h"
#include "application_manager/policies/policy_handler_observer.h"
#include "connection_handler/connection_handler.h"
#include "connection_handler/connection_handler_observer.h"
@@ -93,6 +94,8 @@
#include "utils/timer.h"
#include "smart_objects/smart_object.h"
+struct BsonObject;
+
namespace threads {
class Thread;
}
@@ -243,10 +246,14 @@ class ApplicationManagerImpl
std::vector<ApplicationSharedPtr> applications_by_button(
uint32_t button) OVERRIDE;
std::vector<ApplicationSharedPtr> applications_with_navi() OVERRIDE;
+ std::vector<ApplicationSharedPtr> applications_with_mobile_projection()
+ OVERRIDE;
ApplicationSharedPtr get_limited_media_application() const OVERRIDE;
ApplicationSharedPtr get_limited_navi_application() const OVERRIDE;
ApplicationSharedPtr get_limited_voice_application() const OVERRIDE;
+ ApplicationSharedPtr get_limited_mobile_projection_application()
+ const OVERRIDE;
uint32_t application_id(const int32_t correlation_id) OVERRIDE;
void set_application_id(const int32_t correlation_id,
@@ -258,6 +265,40 @@ class ApplicationManagerImpl
void SendHMIStatusNotification(
const utils::SharedPtr<Application> app) OVERRIDE;
+
+#ifdef SDL_REMOTE_CONTROL
+ ApplicationSharedPtr application(
+ const std::string& device_id,
+ const std::string& policy_app_id) const OVERRIDE;
+
+ /**
+ * @brief ChangeAppsHMILevel the function that will change application's
+ * hmi level.
+ *
+ * @param app_id id of the application whose hmi level should be changed.
+ *
+ * @param level new hmi level for certain application.
+ */
+ void ChangeAppsHMILevel(uint32_t app_id, mobile_apis::HMILevel::eType level);
+
+ void Erase(ApplicationSharedPtr app_to_remove) {
+ DCHECK(app_to_remove);
+ app_to_remove->RemoveExtensions();
+ applications_.erase(app_to_remove);
+ }
+
+ virtual functional_modules::PluginManager& GetPluginManager() OVERRIDE {
+ return plugin_manager_;
+ }
+
+ std::vector<std::string> devices(
+ const std::string& policy_app_id) const OVERRIDE;
+
+ virtual void SendPostMessageToMobile(const MessagePtr& message) OVERRIDE;
+
+ virtual void SendPostMessageToHMI(const MessagePtr& message) OVERRIDE;
+#endif // SDL_REMOTE_CONTROL
+
/**
* @brief Checks if application with the same HMI type
* (media, voice communication or navi) exists
@@ -694,6 +735,12 @@ class ApplicationManagerImpl
void OnUpdateHMIAppType(
std::map<std::string, std::vector<std::string> > app_hmi_types) OVERRIDE;
+ /**
+ * @brief OnPTUFinished is called on policy table update coming
+ * @param ptu_result True if PTU is succeeded, otherwise - false
+ */
+ void OnPTUFinished(const bool ptu_result) FINAL;
+
/*
* @brief Starts audio pass thru thread
*
@@ -757,6 +804,9 @@ class ApplicationManagerImpl
void SendMessageToHMI(const commands::MessageSharedPtr message) OVERRIDE;
+ void RemoveHMIFakeParameters(
+ application_manager::MessagePtr& message) OVERRIDE;
+
bool ManageMobileCommand(const commands::MessageSharedPtr message,
commands::Command::CommandOrigin origin) OVERRIDE;
bool ManageHMICommand(const commands::MessageSharedPtr message) OVERRIDE;
@@ -788,10 +838,16 @@ class ApplicationManagerImpl
void OnFindNewApplicationsRequest() OVERRIDE;
void RemoveDevice(
const connection_handler::DeviceHandle& device_handle) OVERRIDE;
+ // DEPRECATED
bool OnServiceStartedCallback(
const connection_handler::DeviceHandle& device_handle,
const int32_t& session_key,
const protocol_handler::ServiceType& type) OVERRIDE;
+ void OnServiceStartedCallback(
+ const connection_handler::DeviceHandle& device_handle,
+ const int32_t& session_key,
+ const protocol_handler::ServiceType& type,
+ const BsonObject* params) OVERRIDE;
void OnServiceEndedCallback(
const int32_t& session_key,
const protocol_handler::ServiceType& type,
@@ -882,6 +938,20 @@ class ApplicationManagerImpl
void ForbidStreaming(uint32_t app_id) OVERRIDE;
/**
+ * @brief Called when application completes streaming configuration
+ * @param app_id Streaming application id
+ * @param service_type Streaming service type
+ * @param result true if configuration is successful, false otherwise
+ * @param rejected_params list of rejected parameters' name. Valid
+ * only when result is false.
+ */
+ void OnStreamingConfigured(
+ uint32_t app_id,
+ protocol_handler::ServiceType service_type,
+ bool result,
+ std::vector<std::string>& rejected_params) OVERRIDE;
+
+ /**
* @brief Callback calls when application starts/stops data streaming
* @param app_id Streaming application id
* @param service_type Streaming service type
@@ -1082,7 +1152,10 @@ class ApplicationManagerImpl
bool operator()(const ApplicationSharedPtr app) const {
return app
? handle_ == app->device() &&
- ProtocolVersion::kV4 == app->protocol_version()
+ Message::is_sufficient_version(
+ protocol_handler::MajorProtocolVersion::
+ PROTOCOL_VERSION_4,
+ app->protocol_version())
: false;
}
};
@@ -1192,6 +1265,10 @@ class ApplicationManagerImpl
smart_objects::SmartObject& output);
bool ConvertSOtoMessage(const smart_objects::SmartObject& message,
Message& output);
+
+ MessageValidationResult ValidateMessageBySchema(
+ const Message& message) OVERRIDE;
+
utils::SharedPtr<Message> ConvertRawMsgToMessage(
const ::protocol_handler::RawMessagePtr message);
@@ -1325,10 +1402,23 @@ class ApplicationManagerImpl
* @param service_type Type of service to start
* @return True on success, false on fail
*/
+ // DEPRECATED
bool StartNaviService(uint32_t app_id,
protocol_handler::ServiceType service_type);
/**
+ * @brief Starts specified navi service for application
+ * @param app_id Application to proceed
+ * @param service_type Type of service to start
+ * @param params configuration parameters specified by mobile
+ * @return True if service is immediately started or configuration
+ * parameters are sent to HMI, false on other cases
+ */
+ bool StartNaviService(uint32_t app_id,
+ protocol_handler::ServiceType service_type,
+ const BsonObject* params);
+
+ /**
* @brief Stops specified navi service for application
* @param app_id Application to proceed
* @param service_type Type of service to stop
@@ -1354,7 +1444,7 @@ class ApplicationManagerImpl
* @brief Function returns supported SDL Protocol Version
* @return protocol version depends on parameters from smartDeviceLink.ini.
*/
- ProtocolVersion SupportedSDLVersion() const;
+ protocol_handler::MajorProtocolVersion SupportedSDLVersion() const;
/**
* @brief Types of directories used by Application Manager
@@ -1397,6 +1487,24 @@ class ApplicationManagerImpl
void ClearTTSGlobalPropertiesList();
+ /**
+ * @brief Converts BSON object containing video parameters to
+ * smart object's map object
+ * @param output the smart object to add video parameters
+ * @param input BSON object to read parameters from
+ */
+ static void ConvertVideoParamsToSO(smart_objects::SmartObject& output,
+ const BsonObject* input);
+
+ /**
+ * @brief Converts rejected parameters' names acquired from HMI to
+ * SDL protocol's parameter names
+ * @param list of rejected parameters' names
+ * @return converted parameters' names
+ */
+ static std::vector<std::string> ConvertRejectedParamList(
+ const std::vector<std::string>& input);
+
private:
const ApplicationManagerSettings& settings_;
/**
@@ -1444,6 +1552,28 @@ class ApplicationManagerImpl
protocol_handler::ProtocolHandler* protocol_handler_;
request_controller::RequestController request_ctrl_;
+#ifdef SDL_REMOTE_CONTROL
+ functional_modules::PluginManager plugin_manager_;
+
+ /**
+ * @brief Map contains apps with HMI state before incoming call
+ * After incoming call ends previous HMI state must restore
+ *
+ */
+ struct AppState {
+ AppState(const mobile_apis::HMILevel::eType& level,
+ const mobile_apis::AudioStreamingState::eType& streaming_state,
+ const mobile_apis::SystemContext::eType& context)
+ : hmi_level(level)
+ , audio_streaming_state(streaming_state)
+ , system_context(context) {}
+
+ mobile_apis::HMILevel::eType hmi_level;
+ mobile_apis::AudioStreamingState::eType audio_streaming_state;
+ mobile_apis::SystemContext::eType system_context;
+ };
+#endif // SDL_REMOTE_CONTROL
+
hmi_apis::HMI_API* hmi_so_factory_;
mobile_apis::MOBILE_API* mobile_so_factory_;
@@ -1477,6 +1607,7 @@ class ApplicationManagerImpl
HmiInterfacesImpl hmi_interfaces_;
NaviServiceStatusMap navi_service_status_;
+ sync_primitives::Lock navi_service_status_lock_;
std::deque<uint32_t> navi_app_to_stop_;
std::deque<uint32_t> navi_app_to_end_stream_;
uint32_t navi_close_app_timeout_;
@@ -1503,6 +1634,18 @@ class ApplicationManagerImpl
volatile bool is_stopping_;
+#ifdef BUILD_TESTS
+ public:
+ /**
+ * @brief register a mock application without going through the formal
+ * registration process. Only for unit testing.
+ * @param mock_app the mock app to be registered
+ */
+ void AddMockApplication(ApplicationSharedPtr mock_app);
+
+ private:
+#endif
+
DISALLOW_COPY_AND_ASSIGN(ApplicationManagerImpl);
};
diff --git a/src/components/application_manager/include/application_manager/commands/command_request_impl.h b/src/components/application_manager/include/application_manager/commands/command_request_impl.h
index f585410e97..aa3c216d4d 100644
--- a/src/components/application_manager/include/application_manager/commands/command_request_impl.h
+++ b/src/components/application_manager/include/application_manager/commands/command_request_impl.h
@@ -112,13 +112,36 @@ class CommandRequestImpl : public CommandImpl,
public:
enum RequestState { kAwaitingHMIResponse = 0, kTimedOut, kCompleted };
+ /**
+ * @brief The HashUpdateMode enum defines whether request has to update
+ * hash after its execution is finished
+ */
+ enum HashUpdateMode { kSkipHashUpdate, kDoHashUpdate };
+
CommandRequestImpl(const MessageSharedPtr& message,
ApplicationManager& application_manager);
- virtual ~CommandRequestImpl();
- virtual bool CheckPermissions();
- virtual bool Init();
- virtual bool CleanUp();
- virtual void Run();
+
+ ~CommandRequestImpl();
+
+ /**
+ * @brief Checks command permissions according to policy table
+ */
+ bool CheckPermissions() OVERRIDE;
+
+ /**
+ * @brief Init sets hash update mode for request
+ */
+ bool Init() OVERRIDE;
+
+ /**
+ * @brief Cleanup all resources used by command
+ **/
+ bool CleanUp() OVERRIDE;
+
+ /**
+ * @brief Execute corresponding command by calling the action on reciever
+ **/
+ void Run() OVERRIDE;
/*
* @brief Function is called by RequestController when request execution time
@@ -193,6 +216,14 @@ class CommandRequestImpl : public CommandImpl,
bool CheckAllowedParameters();
/**
+ * @brief Checks HMI capabilities for specified button support
+ * @param button Button to check
+ * @return true if button is present in HMI capabilities
+ * otherwise returns false
+ */
+ bool CheckHMICapabilities(const mobile_apis::ButtonName::eType button) const;
+
+ /**
* @brief Remove from current message parameters disallowed by policy table
*/
void RemoveDisallowedParameters();
@@ -271,6 +302,12 @@ class CommandRequestImpl : public CommandImpl,
CommandParametersPermissions parameters_permissions_;
CommandParametersPermissions removed_parameters_permissions_;
+ /**
+ * @brief hash_update_mode_ Defines whether request must update hash value of
+ * application or not
+ */
+ HashUpdateMode hash_update_mode_;
+
private:
DISALLOW_COPY_AND_ASSIGN(CommandRequestImpl);
@@ -292,6 +329,19 @@ class CommandRequestImpl : public CommandImpl,
bool ProcessHMIInterfacesAvailability(
const uint32_t hmi_correlation_id,
const hmi_apis::FunctionID::eType& function_id);
+
+ /**
+ * @brief UpdateHash updates hash field for application and sends
+ * OnHashChanged notification to mobile side in case of approriate hash mode
+ * is set
+ */
+ void UpdateHash();
+
+ /**
+ * @brief is_success_result_ Defines whether request succeded, at the moment
+ * it is value of 'success' field of appropriate response sent to mobile
+ */
+ bool is_success_result_;
};
} // namespace commands
diff --git a/src/components/application_manager/include/application_manager/commands/hmi/navi_set_video_config_request.h b/src/components/application_manager/include/application_manager/commands/hmi/navi_set_video_config_request.h
new file mode 100644
index 0000000000..0788a5595e
--- /dev/null
+++ b/src/components/application_manager/include/application_manager/commands/hmi/navi_set_video_config_request.h
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2017 Xevo Inc.
+ * 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 names of the copyright holders 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_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_NAVI_SET_VIDEO_CONFIG_REQUEST_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_NAVI_SET_VIDEO_CONFIG_REQUEST_H_
+
+#include "application_manager/commands/hmi/request_to_hmi.h"
+
+namespace application_manager {
+
+namespace commands {
+
+/**
+ * @brief NaviSetVideoConfigRequest command class
+ **/
+class NaviSetVideoConfigRequest : public RequestToHMI,
+ public event_engine::EventObserver {
+ public:
+ /**
+ * @brief NaviSetVideoConfigRequest class constructor
+ *
+ * @param message Incoming SmartObject message
+ * @param application_manager Reference of application manager
+ **/
+ NaviSetVideoConfigRequest(const MessageSharedPtr& message,
+ ApplicationManager& application_manager);
+
+ /**
+ * @brief NaviSetVideoConfigRequest class destructor
+ **/
+ virtual ~NaviSetVideoConfigRequest();
+
+ /**
+ * @brief Execute command
+ **/
+ void Run() OVERRIDE;
+
+ /**
+ * @brief On event callback
+ **/
+ void on_event(const event_engine::Event& event) OVERRIDE;
+
+ /**
+ * @brief onTimeOut callback
+ */
+ void onTimeOut() OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(NaviSetVideoConfigRequest);
+};
+
+} // namespace commands
+
+} // namespace application_manager
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_NAVI_SET_VIDEO_CONFIG_REQUEST_H_
diff --git a/src/components/application_manager/include/application_manager/commands/hmi/navi_set_video_config_response.h b/src/components/application_manager/include/application_manager/commands/hmi/navi_set_video_config_response.h
new file mode 100644
index 0000000000..3c53687a93
--- /dev/null
+++ b/src/components/application_manager/include/application_manager/commands/hmi/navi_set_video_config_response.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2017 Xevo Inc.
+ * 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 names of the copyright holders 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_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_NAVI_SET_VIDEO_CONFIG_RESPONSE_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_NAVI_SET_VIDEO_CONFIG_RESPONSE_H_
+
+#include "application_manager/commands/hmi/response_from_hmi.h"
+
+namespace application_manager {
+
+namespace commands {
+
+/**
+ * @brief NaviSetVideoConfigResponse command class
+ **/
+class NaviSetVideoConfigResponse : public ResponseFromHMI {
+ public:
+ /**
+ * @brief NaviSetVideoConfigResponse class constructor
+ *
+ * @param message Incoming SmartObject message
+ * @param application_manager Reference of application manager
+ **/
+ NaviSetVideoConfigResponse(const MessageSharedPtr& message,
+ ApplicationManager& application_manager);
+
+ /**
+ * @brief NaviSetVideoConfigResponse class destructor
+ **/
+ virtual ~NaviSetVideoConfigResponse();
+
+ /**
+ * @brief Execute command
+ **/
+ void Run() OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(NaviSetVideoConfigResponse);
+};
+
+} // namespace commands
+
+} // namespace application_manager
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_NAVI_SET_VIDEO_CONFIG_RESPONSE_H_
diff --git a/src/components/application_manager/include/application_manager/commands/hmi/rc_get_capabilities_request.h b/src/components/application_manager/include/application_manager/commands/hmi/rc_get_capabilities_request.h
new file mode 100644
index 0000000000..58654d81d9
--- /dev/null
+++ b/src/components/application_manager/include/application_manager/commands/hmi/rc_get_capabilities_request.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2013, 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_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_RC_GET_CAPABILITIES_REQUEST_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_RC_GET_CAPABILITIES_REQUEST_H_
+
+#include "application_manager/commands/hmi/request_to_hmi.h"
+
+namespace application_manager {
+
+namespace commands {
+
+/**
+ * @brief RCGetCapabilitiesRequest command class
+ **/
+class RCGetCapabilitiesRequest : public RequestToHMI {
+ public:
+ /**
+ * @brief RCGetCapabilitiesRequest class constructor
+ *
+ * @param message Incoming SmartObject message
+ **/
+ RCGetCapabilitiesRequest(const MessageSharedPtr& message,
+ ApplicationManager& application_manager);
+
+ /**
+ * @brief RCGetCapabilitiesRequest class destructor
+ **/
+ virtual ~RCGetCapabilitiesRequest();
+
+ /**
+ * @brief Execute command
+ **/
+ virtual void Run();
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(RCGetCapabilitiesRequest);
+};
+
+} // namespace commands
+
+} // namespace application_manager
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_RC_GET_CAPABILITIES_REQUEST_H_
diff --git a/src/components/application_manager/include/application_manager/commands/hmi/rc_get_capabilities_response.h b/src/components/application_manager/include/application_manager/commands/hmi/rc_get_capabilities_response.h
new file mode 100644
index 0000000000..006f38cbb5
--- /dev/null
+++ b/src/components/application_manager/include/application_manager/commands/hmi/rc_get_capabilities_response.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2013, 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_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_RC_GET_CAPABILITIES_RESPONSE_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_RC_GET_CAPABILITIES_RESPONSE_H_
+
+#include "application_manager/commands/hmi/response_from_hmi.h"
+
+namespace application_manager {
+
+namespace commands {
+
+/**
+ * @brief RCGetCapabilitiesResponse command class
+ **/
+class RCGetCapabilitiesResponse : public ResponseFromHMI {
+ public:
+ /**
+ * @brief RCGetCapabilitiesResponse class constructor
+ *
+ * @param message Incoming SmartObject message
+ **/
+ RCGetCapabilitiesResponse(const MessageSharedPtr& message,
+ ApplicationManager& application_manager);
+
+ /**
+ * @brief RCGetCapabilitiesResponse class destructor
+ **/
+ virtual ~RCGetCapabilitiesResponse();
+
+ /**
+ * @brief Execute command
+ **/
+ virtual void Run();
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(RCGetCapabilitiesResponse);
+};
+
+} // namespace commands
+
+} // namespace application_manager
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_RC_GET_CAPABILITIES_RESPONSE_H_
diff --git a/src/components/application_manager/include/application_manager/commands/hmi/rc_is_ready_request.h b/src/components/application_manager/include/application_manager/commands/hmi/rc_is_ready_request.h
new file mode 100644
index 0000000000..40e05c2b1f
--- /dev/null
+++ b/src/components/application_manager/include/application_manager/commands/hmi/rc_is_ready_request.h
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2013, 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_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_RC_IS_READY_REQUEST_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_RC_IS_READY_REQUEST_H_
+
+#include "application_manager/commands/hmi/request_to_hmi.h"
+#include "application_manager/message_helper.h"
+
+namespace application_manager {
+
+namespace commands {
+
+/**
+ * @brief RCIsReadyRequest command class
+ **/
+class RCIsReadyRequest : public RequestToHMI,
+ public event_engine::EventObserver {
+ public:
+ /**
+ * @brief RCIsReadyRequest class constructor
+ *
+ * @param message Incoming SmartObject message
+ **/
+ RCIsReadyRequest(const MessageSharedPtr& message,
+ ApplicationManager& application_manager);
+
+ /**
+ * @brief RCIsReadyRequest class destructor
+ **/
+ virtual ~RCIsReadyRequest();
+
+ /**
+ * @brief Execute command
+ **/
+ void Run() OVERRIDE;
+
+ /**
+ * @brief On event callback
+ **/
+ void on_event(const event_engine::Event& event) OVERRIDE;
+
+ /**
+ * @brief onTimeOut from requrst Controller
+ */
+ void onTimeOut() OVERRIDE;
+
+ /**
+ * @brief Send request to HMI for fetching of cappabilities
+ */
+ void SendMessageToHMI();
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(RCIsReadyRequest);
+};
+
+} // namespace commands
+
+} // namespace application_manager
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_RC_IS_READY_REQUEST_H_
diff --git a/src/components/application_manager/include/application_manager/commands/hmi/rc_is_ready_response.h b/src/components/application_manager/include/application_manager/commands/hmi/rc_is_ready_response.h
new file mode 100644
index 0000000000..547b89a30d
--- /dev/null
+++ b/src/components/application_manager/include/application_manager/commands/hmi/rc_is_ready_response.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2013, 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_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_RC_IS_READY_RESPONSE_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_RC_IS_READY_RESPONSE_H_
+
+#include "application_manager/commands/hmi/response_from_hmi.h"
+
+namespace application_manager {
+
+namespace commands {
+
+/**
+ * @brief RCIsReadyResponse command class
+ **/
+class RCIsReadyResponse : public ResponseFromHMI {
+ public:
+ /**
+ * @brief RCIsReadyResponse class constructor
+ *
+ * @param message Incoming SmartObject message
+ **/
+ RCIsReadyResponse(const MessageSharedPtr& message,
+ ApplicationManager& application_manager);
+
+ /**
+ * @brief RCIsReadyResponse class destructor
+ **/
+ virtual ~RCIsReadyResponse();
+
+ /**
+ * @brief Execute command
+ **/
+ virtual void Run();
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(RCIsReadyResponse);
+};
+
+} // namespace commands
+
+} // namespace application_manager
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_RC_IS_READY_RESPONSE_H_
diff --git a/src/components/application_manager/include/application_manager/commands/hmi/ui_send_haptic_data_request.h b/src/components/application_manager/include/application_manager/commands/hmi/ui_send_haptic_data_request.h
new file mode 100644
index 0000000000..b697176a36
--- /dev/null
+++ b/src/components/application_manager/include/application_manager/commands/hmi/ui_send_haptic_data_request.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2017 Xevo Inc.
+ * 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 Xevo Inc. 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_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_UI_SEND_HAPTIC_DATA_REQUEST_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_UI_SEND_HAPTIC_DATA_REQUEST_H_
+
+#include "application_manager/commands/hmi/request_to_hmi.h"
+
+namespace application_manager {
+
+namespace commands {
+
+/**
+ * @brief UISendHapticDataRequest command class
+ **/
+class UISendHapticDataRequest : public RequestToHMI {
+ public:
+ /**
+ * @brief UISendHapticDataRequest class constructor
+ *
+ * @param message Incoming SmartObject message
+ * @param application_manager Reference of application manager
+ **/
+ UISendHapticDataRequest(const MessageSharedPtr& message,
+ ApplicationManager& application_manager);
+
+ /**
+ * @brief UISendHapticDataRequest class destructor
+ **/
+ ~UISendHapticDataRequest() OVERRIDE;
+
+ /**
+ * @brief Execute command
+ **/
+ void Run() OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(UISendHapticDataRequest);
+};
+
+} // namespace commands
+
+} // namespace application_manager
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_UI_SEND_HAPTIC_DATA_REQUEST_H_
diff --git a/src/components/application_manager/include/application_manager/commands/hmi/ui_send_haptic_data_response.h b/src/components/application_manager/include/application_manager/commands/hmi/ui_send_haptic_data_response.h
new file mode 100644
index 0000000000..96abe4665d
--- /dev/null
+++ b/src/components/application_manager/include/application_manager/commands/hmi/ui_send_haptic_data_response.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2017 Xevo Inc.
+ * 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 Xevo Inc. 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_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_UI_SEND_HAPTIC_DATA_RESPONSE_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_UI_SEND_HAPTIC_DATA_RESPONSE_H_
+
+#include "application_manager/commands/hmi/response_from_hmi.h"
+
+namespace application_manager {
+
+namespace commands {
+
+/**
+ * @brief UISendHapticDataResponse command class
+ **/
+class UISendHapticDataResponse : public ResponseFromHMI {
+ public:
+ /**
+ * @brief UISendHapticDataResponse class constructor
+ *
+ * @param message Incoming SmartObject message
+ * @param application_manager Reference of application manager
+ **/
+ UISendHapticDataResponse(const MessageSharedPtr& message,
+ ApplicationManager& application_manager);
+
+ /**
+ * @brief UISendHapticDataResponse class destructor
+ **/
+ ~UISendHapticDataResponse() OVERRIDE;
+
+ /**
+ * @brief Execute command
+ **/
+ void Run() OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(UISendHapticDataResponse);
+};
+
+} // namespace commands
+
+} // namespace application_manager
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_UI_SEND_HAPTIC_DATA_RESPONSE_H_
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/add_command_request.h b/src/components/application_manager/include/application_manager/commands/mobile/add_command_request.h
index 854ea7f21f..2aed94c448 100644
--- a/src/components/application_manager/include/application_manager/commands/mobile/add_command_request.h
+++ b/src/components/application_manager/include/application_manager/commands/mobile/add_command_request.h
@@ -60,25 +60,30 @@ class AddCommandRequest : public CommandRequestImpl {
/**
* @brief AddCommandRequest class destructor
**/
- virtual ~AddCommandRequest();
+ ~AddCommandRequest();
/**
* @brief Execute command
**/
- virtual void Run();
+ void Run() FINAL;
/**
* @brief Interface method that is called whenever new event received
*
* @param event The received event
*/
- void on_event(const event_engine::Event& event);
+ void on_event(const event_engine::Event& event) FINAL;
/**
* @brief Function is called by RequestController when request execution time
* has exceed it's limit
*/
- virtual void onTimeOut();
+ void onTimeOut() FINAL;
+
+ /**
+ * @brief Init sets hash update mode for request
+ */
+ bool Init() FINAL;
private:
/*
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/add_sub_menu_request.h b/src/components/application_manager/include/application_manager/commands/mobile/add_sub_menu_request.h
index 10e2628035..36b0b38464 100644
--- a/src/components/application_manager/include/application_manager/commands/mobile/add_sub_menu_request.h
+++ b/src/components/application_manager/include/application_manager/commands/mobile/add_sub_menu_request.h
@@ -57,19 +57,24 @@ class AddSubMenuRequest : public CommandRequestImpl {
/**
* @brief AddSubMenuRequest class destructor
**/
- virtual ~AddSubMenuRequest();
+ ~AddSubMenuRequest();
/**
* @brief Execute command
**/
- virtual void Run();
+ void Run() FINAL;
/**
* @brief Interface method that is called whenever new event received
*
* @param event The received event
*/
- void on_event(const event_engine::Event& event);
+ void on_event(const event_engine::Event& event) FINAL;
+
+ /**
+ * @brief Init sets hash update mode for request
+ */
+ bool Init() FINAL;
private:
/*
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/create_interaction_choice_set_request.h b/src/components/application_manager/include/application_manager/commands/mobile/create_interaction_choice_set_request.h
index fffbab567f..c00d310e7d 100644
--- a/src/components/application_manager/include/application_manager/commands/mobile/create_interaction_choice_set_request.h
+++ b/src/components/application_manager/include/application_manager/commands/mobile/create_interaction_choice_set_request.h
@@ -64,31 +64,36 @@ class CreateInteractionChoiceSetRequest : public CommandRequestImpl {
/**
* @brief CreateInteractionChoiceSetRequest class destructor
**/
- virtual ~CreateInteractionChoiceSetRequest();
+ ~CreateInteractionChoiceSetRequest();
/**
* @brief Execute command
**/
- virtual void Run();
+ void Run() FINAL;
/**
* @brief Interface method that is called whenever new event received
*
* @param event The received event
*/
- virtual void on_event(const event_engine::Event& event);
+ void on_event(const event_engine::Event& event) FINAL;
/**
* @brief Function is called by RequestController when request execution time
* has exceed it's limit
*/
- virtual void onTimeOut();
+ void onTimeOut() FINAL;
+
/**
- * @brief DeleteChoices allows to walk through the sent commands collection
- * in order to sent appropriate DeleteCommand request.
+ * @brief Init sets hash update mode for request
*/
+ bool Init() FINAL;
private:
+ /**
+ * @brief DeleteChoices allows to walk through the sent commands collection
+ * in order to sent appropriate DeleteCommand request.
+ */
void DeleteChoices();
/**
@@ -104,7 +109,7 @@ class CreateInteractionChoiceSetRequest : public CommandRequestImpl {
* processing deleting sent commands if error from HMI received
*/
struct VRCommandInfo {
- VRCommandInfo() {}
+ VRCommandInfo() : cmd_id_(0), succesful_response_received_(false) {}
VRCommandInfo(uint32_t cmd_id)
: cmd_id_(cmd_id), succesful_response_received_(false) {}
uint32_t cmd_id_;
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/delete_command_request.h b/src/components/application_manager/include/application_manager/commands/mobile/delete_command_request.h
index 3483aea1d6..afb2e226f6 100644
--- a/src/components/application_manager/include/application_manager/commands/mobile/delete_command_request.h
+++ b/src/components/application_manager/include/application_manager/commands/mobile/delete_command_request.h
@@ -59,19 +59,24 @@ class DeleteCommandRequest : public CommandRequestImpl {
/**
* @brief DeleteCommandRequest class destructor
**/
- virtual ~DeleteCommandRequest();
+ ~DeleteCommandRequest();
/**
* @brief Execute command
**/
- virtual void Run();
+ void Run() FINAL;
/**
* @brief Interface method that is called whenever new event received
*
* @param event The received event
*/
- void on_event(const event_engine::Event& event);
+ void on_event(const event_engine::Event& event) FINAL;
+
+ /**
+ * @brief Init sets hash update mode for request
+ */
+ bool Init() FINAL;
private:
DISALLOW_COPY_AND_ASSIGN(DeleteCommandRequest);
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/delete_interaction_choice_set_request.h b/src/components/application_manager/include/application_manager/commands/mobile/delete_interaction_choice_set_request.h
index 12c80138b4..ead60be1af 100644
--- a/src/components/application_manager/include/application_manager/commands/mobile/delete_interaction_choice_set_request.h
+++ b/src/components/application_manager/include/application_manager/commands/mobile/delete_interaction_choice_set_request.h
@@ -58,12 +58,17 @@ class DeleteInteractionChoiceSetRequest : public CommandRequestImpl {
/**
* @brief DeleteInteractionChoiceSetRequest class destructor
**/
- virtual ~DeleteInteractionChoiceSetRequest();
+ ~DeleteInteractionChoiceSetRequest();
/**
* @brief Execute command
**/
- virtual void Run();
+ void Run() FINAL;
+
+ /**
+ * @brief Init sets hash update mode for request
+ */
+ bool Init() FINAL;
private:
/*
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/delete_sub_menu_request.h b/src/components/application_manager/include/application_manager/commands/mobile/delete_sub_menu_request.h
index b9c27ba294..37863598ac 100644
--- a/src/components/application_manager/include/application_manager/commands/mobile/delete_sub_menu_request.h
+++ b/src/components/application_manager/include/application_manager/commands/mobile/delete_sub_menu_request.h
@@ -58,19 +58,24 @@ class DeleteSubMenuRequest : public CommandRequestImpl {
/**
* @brief DeleteSubMenuRequest class destructor
**/
- virtual ~DeleteSubMenuRequest();
+ ~DeleteSubMenuRequest();
/**
* @brief Execute command
**/
- virtual void Run();
+ void Run() FINAL;
/**
* @brief Interface method that is called whenever new event received
*
* @param event The received event
*/
- void on_event(const event_engine::Event& event);
+ void on_event(const event_engine::Event& event) FINAL;
+
+ /**
+ * @brief Init sets hash update mode for request
+ */
+ bool Init() FINAL;
private:
/*
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/get_system_capability_request.h b/src/components/application_manager/include/application_manager/commands/mobile/get_system_capability_request.h
new file mode 100644
index 0000000000..ba55a6b4cd
--- /dev/null
+++ b/src/components/application_manager/include/application_manager/commands/mobile/get_system_capability_request.h
@@ -0,0 +1,61 @@
+/*
+
+ Copyright (c) 2013, 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_INCLUDE_APPLICATION_MANAGER_COMMANDS_MOBILE_GET_SYSTEM_CAPABILITY_REQUEST_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_MOBILE_GET_SYSTEM_CAPABILITY_REQUEST_H_
+
+#include "application_manager/commands/command_request_impl.h"
+
+namespace application_manager {
+
+namespace commands {
+
+class GetSystemCapabilityRequest : public CommandRequestImpl {
+ public:
+ GetSystemCapabilityRequest(const MessageSharedPtr& message,
+ ApplicationManager& application_manager);
+
+ virtual ~GetSystemCapabilityRequest();
+
+ virtual void Run() OVERRIDE;
+
+ virtual void on_event(const event_engine::Event& event);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(GetSystemCapabilityRequest);
+
+}; // GetSystemCapabilityRequest
+} // commands
+} // application_manager
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_MOBILE_GET_SYSTEM_CAPABILITY_REQUEST_H_ \ No newline at end of file
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/get_system_capability_response.h b/src/components/application_manager/include/application_manager/commands/mobile/get_system_capability_response.h
new file mode 100644
index 0000000000..9fa6f9b5bb
--- /dev/null
+++ b/src/components/application_manager/include/application_manager/commands/mobile/get_system_capability_response.h
@@ -0,0 +1,60 @@
+/*
+
+ Copyright (c) 2013, 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_INCLUDE_APPLICATION_MANAGER_COMMANDS_MOBILE_GET_SYSTEM_CAPABILITY_RESPONSE_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_MOBILE_GET_SYSTEM_CAPABILITY_RESPONSE_H_
+
+#include "application_manager/commands/command_response_impl.h"
+#include "utils/macro.h"
+
+namespace application_manager {
+
+namespace commands {
+
+class GetSystemCapabilityResponse : public CommandResponseImpl {
+ public:
+ GetSystemCapabilityResponse(const MessageSharedPtr& message,
+ ApplicationManager& application_manager);
+
+ virtual ~GetSystemCapabilityResponse();
+
+ virtual void Run() OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(GetSystemCapabilityResponse);
+
+}; // GetSystemCapabilityResponse
+} // commands
+} // application_manager
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_MOBILE_GET_SYSTEM_CAPABILITY_RESPONSE_H_ \ No newline at end of file
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/reset_global_properties_request.h b/src/components/application_manager/include/application_manager/commands/mobile/reset_global_properties_request.h
index 49e5fe34ff..eb955df197 100644
--- a/src/components/application_manager/include/application_manager/commands/mobile/reset_global_properties_request.h
+++ b/src/components/application_manager/include/application_manager/commands/mobile/reset_global_properties_request.h
@@ -58,19 +58,24 @@ class ResetGlobalPropertiesRequest : public CommandRequestImpl {
/**
* @brief ResetGlobalPropertiesRequest class destructor
**/
- virtual ~ResetGlobalPropertiesRequest();
+ ~ResetGlobalPropertiesRequest();
/**
* @brief Execute command
**/
- virtual void Run();
+ void Run() FINAL;
/**
* @brief Interface method that is called whenever new event received
*
* @param event The received event
*/
- void on_event(const event_engine::Event& event);
+ void on_event(const event_engine::Event& event) FINAL;
+
+ /**
+ * @brief Init sets hash update mode for request
+ */
+ bool Init() FINAL;
private:
/*
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/send_haptic_data_request.h b/src/components/application_manager/include/application_manager/commands/mobile/send_haptic_data_request.h
new file mode 100644
index 0000000000..13ed06cce6
--- /dev/null
+++ b/src/components/application_manager/include/application_manager/commands/mobile/send_haptic_data_request.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2017 Xevo Inc.
+ * 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 Xevo Inc. 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_INCLUDE_APPLICATION_MANAGER_COMMANDS_MOBILE_SEND_HAPTIC_DATA_REQUEST_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_MOBILE_SEND_HAPTIC_DATA_REQUEST_H_
+
+#include <string>
+#include "application_manager/commands/command_request_impl.h"
+#include "application_manager/application_manager.h"
+#include "application_manager/event_engine/event.h"
+#include "smart_objects/smart_object.h"
+
+namespace application_manager {
+
+namespace commands {
+
+/**
+ * @brief SendHapticDataRequest command class
+ **/
+class SendHapticDataRequest : public CommandRequestImpl {
+ public:
+ /**
+ * @brief SendHapticDataRequest class constructor
+ *
+ * @param message Incoming SmartObject message
+ * @param application_manager Reference of application manager
+ **/
+ SendHapticDataRequest(const MessageSharedPtr& message,
+ ApplicationManager& application_manager);
+
+ /**
+ * @brief SendHapticDataRequest class destructor
+ **/
+ ~SendHapticDataRequest() OVERRIDE;
+
+ /**
+ * @brief Execute command
+ **/
+ void Run() OVERRIDE;
+
+ /**
+ * @brief Interface method that is called whenever new event received
+ *
+ * @param event The received event
+ */
+ void on_event(const event_engine::Event& event) OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(SendHapticDataRequest);
+};
+
+} // namespace commands
+} // namespace application_manager
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_MOBILE_SEND_HAPTIC_DATA_REQUEST_H_
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/send_haptic_data_response.h b/src/components/application_manager/include/application_manager/commands/mobile/send_haptic_data_response.h
new file mode 100644
index 0000000000..2a60746c61
--- /dev/null
+++ b/src/components/application_manager/include/application_manager/commands/mobile/send_haptic_data_response.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2017 Xevo Inc.
+ * 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 Xevo Inc. 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_INCLUDE_APPLICATION_MANAGER_COMMANDS_MOBILE_SEND_HAPTIC_DATA_RESPONSE_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_MOBILE_SEND_HAPTIC_DATA_RESPONSE_H_
+
+#include "application_manager/commands/command_response_impl.h"
+
+namespace application_manager {
+
+namespace commands {
+
+/**
+ * @brief SendHapticDataResponse command class
+ **/
+class SendHapticDataResponse : public CommandResponseImpl {
+ public:
+ /**
+ * @brief SendHapticDataResponse class constructor
+ *
+ * @param message Incoming SmartObject message
+ * @param application_manager Reference of application manager
+ **/
+ SendHapticDataResponse(const MessageSharedPtr& message,
+ ApplicationManager& application_manager);
+
+ /**
+ * @brief SendHapticDataResponse class destructor
+ **/
+ ~SendHapticDataResponse() OVERRIDE;
+
+ /**
+ * @brief Execute command
+ **/
+ void Run() OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(SendHapticDataResponse);
+};
+
+} // namespace commands
+} // namespace application_manager
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_MOBILE_SEND_HAPTIC_DATA_RESPONSE_H_
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/set_global_properties_request.h b/src/components/application_manager/include/application_manager/commands/mobile/set_global_properties_request.h
index 0300245af8..da28d33de8 100644
--- a/src/components/application_manager/include/application_manager/commands/mobile/set_global_properties_request.h
+++ b/src/components/application_manager/include/application_manager/commands/mobile/set_global_properties_request.h
@@ -57,19 +57,24 @@ class SetGlobalPropertiesRequest : public CommandRequestImpl {
/**
* @brief SetGlobalPropertiesRequest class destructor
**/
- virtual ~SetGlobalPropertiesRequest();
+ ~SetGlobalPropertiesRequest();
/**
* @brief Execute command
**/
- virtual void Run();
+ void Run() FINAL;
/**
* @brief Interface method that is called whenever new event received
*
* @param event The received event
*/
- void on_event(const event_engine::Event& event);
+ void on_event(const event_engine::Event& event) FINAL;
+
+ /**
+ * @brief Init sets hash update mode for request
+ */
+ bool Init() FINAL;
private:
// Verify correctness VrHelptitle value
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/subscribe_button_request.h b/src/components/application_manager/include/application_manager/commands/mobile/subscribe_button_request.h
index b5a22d40a9..cf65e2a6a4 100644
--- a/src/components/application_manager/include/application_manager/commands/mobile/subscribe_button_request.h
+++ b/src/components/application_manager/include/application_manager/commands/mobile/subscribe_button_request.h
@@ -58,12 +58,17 @@ class SubscribeButtonRequest : public CommandRequestImpl {
/**
* @brief SubscribeButtonRequest class destructor
**/
- virtual ~SubscribeButtonRequest();
+ ~SubscribeButtonRequest();
/**
* @brief Execute command
**/
- virtual void Run();
+ void Run() FINAL;
+
+ /**
+ * @brief Init sets hash update mode for request
+ */
+ bool Init() FINAL;
private:
/**
@@ -85,12 +90,6 @@ class SubscribeButtonRequest : public CommandRequestImpl {
*/
void SendSubscribeButtonNotification();
- /**
- * @brief Checks HMI capabilities for specified button support
- * @param button Button to check
- */
- bool CheckHMICapabilities(mobile_apis::ButtonName::eType button);
-
DISALLOW_COPY_AND_ASSIGN(SubscribeButtonRequest);
};
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/subscribe_vehicle_data_request.h b/src/components/application_manager/include/application_manager/commands/mobile/subscribe_vehicle_data_request.h
index fb21823b3a..eb360b50d8 100644
--- a/src/components/application_manager/include/application_manager/commands/mobile/subscribe_vehicle_data_request.h
+++ b/src/components/application_manager/include/application_manager/commands/mobile/subscribe_vehicle_data_request.h
@@ -58,19 +58,24 @@ class SubscribeVehicleDataRequest : public CommandRequestImpl {
/**
* @brief SubscribeButtonCommandRequest class destructor
**/
- virtual ~SubscribeVehicleDataRequest();
+ ~SubscribeVehicleDataRequest();
/**
* @brief Execute command
**/
- virtual void Run();
+ void Run() FINAL;
/**
* @brief Interface method that is called whenever new event received
*
* @param event The received event
*/
- virtual void on_event(const event_engine::Event& event);
+ void on_event(const event_engine::Event& event) FINAL;
+
+ /**
+ * @brief Init sets hash update mode for request
+ */
+ bool Init() FINAL;
#ifdef HMI_DBUS_API
private:
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/subscribe_way_points_request.h b/src/components/application_manager/include/application_manager/commands/mobile/subscribe_way_points_request.h
index 50b3a6f2cb..f392dd6dd1 100644
--- a/src/components/application_manager/include/application_manager/commands/mobile/subscribe_way_points_request.h
+++ b/src/components/application_manager/include/application_manager/commands/mobile/subscribe_way_points_request.h
@@ -53,18 +53,23 @@ class SubscribeWayPointsRequest : public CommandRequestImpl {
/**
* \brief SubscribeWayPointsRequest class destructor
**/
- virtual ~SubscribeWayPointsRequest();
+ ~SubscribeWayPointsRequest();
/**
* @brief Execute command
**/
- virtual void Run() OVERRIDE;
+ void Run() FINAL;
/**
* @brief Interface method that is called whenever new event received
*
* @param event The received event
*/
- virtual void on_event(const event_engine::Event& event);
+ void on_event(const event_engine::Event& event) FINAL;
+
+ /**
+ * @brief Init sets hash update mode for request
+ */
+ bool Init() FINAL;
private:
DISALLOW_COPY_AND_ASSIGN(SubscribeWayPointsRequest);
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/unsubscribe_button_request.h b/src/components/application_manager/include/application_manager/commands/mobile/unsubscribe_button_request.h
index 62600d51d7..b0206c4407 100644
--- a/src/components/application_manager/include/application_manager/commands/mobile/unsubscribe_button_request.h
+++ b/src/components/application_manager/include/application_manager/commands/mobile/unsubscribe_button_request.h
@@ -57,12 +57,17 @@ class UnsubscribeButtonRequest : public CommandRequestImpl {
/**
* @brief UnsubscribeButtonRequest class destructor
**/
- virtual ~UnsubscribeButtonRequest();
+ ~UnsubscribeButtonRequest() FINAL;
/**
* @brief Execute command
**/
- virtual void Run();
+ void Run() FINAL;
+
+ /**
+ * @brief Init sets hash update mode for request
+ */
+ bool Init() FINAL;
private:
/**
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/unsubscribe_vehicle_data_request.h b/src/components/application_manager/include/application_manager/commands/mobile/unsubscribe_vehicle_data_request.h
index a6bade2fd6..1c7d80797d 100644
--- a/src/components/application_manager/include/application_manager/commands/mobile/unsubscribe_vehicle_data_request.h
+++ b/src/components/application_manager/include/application_manager/commands/mobile/unsubscribe_vehicle_data_request.h
@@ -58,19 +58,24 @@ class UnsubscribeVehicleDataRequest : public CommandRequestImpl {
/**
* @brief UnsubscribeVehicleDataRequest class destructor
**/
- virtual ~UnsubscribeVehicleDataRequest();
+ ~UnsubscribeVehicleDataRequest();
/**
* @brief Execute command
**/
- virtual void Run();
+ void Run() FINAL;
/**
* @brief Interface method that is called whenever new event received
*
* @param event The received event
*/
- virtual void on_event(const event_engine::Event& event);
+ void on_event(const event_engine::Event& event) FINAL;
+
+ /**
+ * @brief Init sets hash update mode for request
+ */
+ bool Init() FINAL;
#ifdef HMI_DBUS_API
private:
@@ -103,11 +108,6 @@ class UnsubscribeVehicleDataRequest : public CommandRequestImpl {
void AddAlreadyUnsubscribedVI(smart_objects::SmartObject& response) const;
/**
- * @brief Allows to update hash after sending response to mobile.
- */
- void UpdateHash() const;
-
- /**
* @brief VI parameters which still being subscribed by another apps after
* particular app had been unsubscribed from these parameters
*/
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/unsubscribe_way_points_request.h b/src/components/application_manager/include/application_manager/commands/mobile/unsubscribe_way_points_request.h
index 2831551667..0b5462b7b5 100644
--- a/src/components/application_manager/include/application_manager/commands/mobile/unsubscribe_way_points_request.h
+++ b/src/components/application_manager/include/application_manager/commands/mobile/unsubscribe_way_points_request.h
@@ -50,18 +50,24 @@ class UnSubscribeWayPointsRequest : public CommandRequestImpl {
/**
* \brief UnSubscribeWayPointsRequest class destructor
**/
- virtual ~UnSubscribeWayPointsRequest();
+ ~UnSubscribeWayPointsRequest();
/**
* @brief Execute command
**/
- virtual void Run() OVERRIDE;
+ void Run() FINAL;
+
/**
* @brief Interface method that is called whenever new event received
*
* @param event The received event
*/
- virtual void on_event(const event_engine::Event& event);
+ void on_event(const event_engine::Event& event) FINAL;
+
+ /**
+ * @brief Init sets hash update mode for request
+ */
+ bool Init() FINAL;
private:
DISALLOW_COPY_AND_ASSIGN(UnSubscribeWayPointsRequest);
diff --git a/src/components/application_manager/include/application_manager/core_service.h b/src/components/application_manager/include/application_manager/core_service.h
new file mode 100644
index 0000000000..5e95ecd245
--- /dev/null
+++ b/src/components/application_manager/include/application_manager/core_service.h
@@ -0,0 +1,214 @@
+/**
+ * Copyright (c) 2013, 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_INCLUDE_APPLICATION_MANAGER_CORE_SERVICE_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_CORE_SERVICE_H_
+
+#include <string>
+#include <vector>
+#include "application_manager/service.h"
+#include "application_manager/application.h"
+#include "policy/policy_types.h"
+
+namespace Json {
+class Value;
+}
+
+namespace application_manager {
+
+struct CommandParametersPermissions;
+
+/**
+ * @brief Class through which the plug-in can interact with the core
+ */
+class CoreService : public Service {
+ public:
+ /**
+ * @brief CoreService class destructor
+ */
+ explicit CoreService(ApplicationManager& application_manager);
+
+ /**
+ * @brief CoreService class destructor
+ */
+ virtual ~CoreService();
+
+ /**
+ * @brief Checks message permissions and cuts parameters according
+ * to policy table permissions
+ * @param msg message to cut disallowed parameters
+ * @return result according by mobile API
+ */
+ mobile_apis::Result::eType CheckPolicyPermissions(MessagePtr msg) FINAL;
+
+ /**
+ * Checks if module for application is present in policy table
+ * @param app_id id of application
+ * @param module type
+ * @return true if module is present, otherwise - false
+ */
+ bool CheckModule(const ApplicationId& app_id,
+ const std::string& module) FINAL;
+
+ /**
+ * Checks if application has remote control functions
+ * @param app application
+ * @return true if application has remote control functions
+ */
+ bool IsRemoteControlApplication(ApplicationSharedPtr app) const FINAL;
+
+ /**
+ * @brief Gets current state of the specified interface
+ * @param interface which state to get
+ * @return true if specified interface available otherwise false
+ */
+ bool IsInterfaceAvailable(
+ const HmiInterfaces::InterfaceID interface) const FINAL;
+
+ /**
+ * Removes fake parameters from request to HMI
+ * @param message message to handle
+ */
+ void RemoveHMIFakeParameters(application_manager::MessagePtr& message) FINAL;
+
+ /**
+ * @brief Get pointer to application by application id
+ * @param app_id application id
+ * return pointer to application
+ */
+ ApplicationSharedPtr GetApplication(ApplicationId app_id) FINAL;
+
+ /**
+ * @brief Send message to HMI
+ * @param message Message to HMI
+ */
+ void SendMessageToHMI(const MessagePtr& message) FINAL;
+
+ /**
+ * @brief Send message to mobile device
+ * @param message Message to mobile
+ */
+ void SendMessageToMobile(const MessagePtr& message) FINAL;
+
+ /**
+ * @brief Returns unique correlation ID for next HMI request
+ *
+ * @return Unique correlation ID
+ */
+ uint32_t GetNextCorrelationID() FINAL;
+
+ /**
+ * @brief Returns all applications
+ *
+ * @return List with shared pointers to applications
+ */
+ std::vector<ApplicationSharedPtr> GetApplications(AppExtensionUID uid) FINAL;
+
+ /**
+ * @brief Change hmi level of app and notify it
+ * @param app Application to be changed and notified
+ * @param level New HMI level of app
+ */
+ void ChangeNotifyHMILevel(ApplicationSharedPtr app,
+ mobile_apis::HMILevel::eType level) FINAL;
+
+ const smart_objects::SmartObject* GetRCCapabilities() const FINAL;
+ /**
+ * @brief Notify HMI about app changing HMI Level
+ * only NONE, BACKGROUND and LIMITED levels are sent
+ * @param app Application to be changed and notified
+ * @param level New HMI level of app
+ */
+ void NotifyHMIAboutHMILevel(ApplicationSharedPtr app,
+ mobile_apis::HMILevel::eType level) FINAL;
+
+ /**
+ * Gets all allowed module types
+ * @param app_id unique identifier of application
+ * @param list of allowed module types
+ * @return true if application has allowed modules
+ */
+ bool GetModuleTypes(const std::string& policy_app_id,
+ std::vector<std::string>* modules) const FINAL;
+
+ /**
+ * @brief ValidateMessageBySchema Checks whether message is valid according
+ * to API
+ * @param message Message to check
+ * @return Check result
+ */
+ MessageValidationResult ValidateMessageBySchema(const Message& message) FINAL;
+
+ /**
+ * @brief Gets application manager settings structure
+ * @return reference to application manager settings structure
+ */
+ const ApplicationManagerSettings& GetSettings() const FINAL;
+
+ private:
+ /**
+ * @brief AreParametersAllowed Checks message parameters across current policy
+ * permissions
+ * @param msg Message having parameters
+ * @param params Parameters sorted by permissions
+ * @return True if allowed, otherwise - false
+ */
+ bool AreParametersAllowed(MessagePtr msg,
+ const CommandParametersPermissions& params);
+
+ /**
+ * @brief CheckParams Checks object params with allowed parameters received
+ * from policy
+ * @param object Message object
+ * @param allowed_params Parameters allowed by policy
+ * @return True if all parameters allowed, otherwise - false
+ */
+ bool CheckParams(const Json::Value& object,
+ const policy::RPCParams& allowed_params);
+
+ /**
+ * @brief IsAllowed Checks particular parameter among allowed list
+ * @param name Parameter name
+ * @param allowed_params List of allowed parameters
+ * @return True if found, otherwise - false
+ */
+ bool IsAllowed(const std::string& name,
+ const policy::RPCParams& allowed_params);
+
+ ApplicationManager& application_manager_;
+
+ DISALLOW_COPY_AND_ASSIGN(CoreService);
+};
+
+} // namespace application_manager
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_CORE_SERVICE_H_
diff --git a/src/components/application_manager/include/application_manager/hmi_capabilities_impl.h b/src/components/application_manager/include/application_manager/hmi_capabilities_impl.h
index 7a85c49027..cbab1fcc80 100644
--- a/src/components/application_manager/include/application_manager/hmi_capabilities_impl.h
+++ b/src/components/application_manager/include/application_manager/hmi_capabilities_impl.h
@@ -91,6 +91,9 @@ class HMICapabilitiesImpl : public HMICapabilities {
bool is_ivi_cooperating() const OVERRIDE;
void set_is_ivi_cooperating(const bool value) OVERRIDE;
+ bool is_rc_cooperating() const OVERRIDE;
+ void set_is_rc_cooperating(const bool value) OVERRIDE;
+
/*
* @brief Interface used to store information about software version of the
*target
@@ -407,6 +410,75 @@ class HMICapabilitiesImpl : public HMICapabilities {
*/
bool phone_call_supported() const OVERRIDE;
+ /*
+ * @brief Interface to store whether HMI supports video streaming
+ *
+ * @param supported Indicates whether video streaming is supported by HMI
+ */
+ void set_video_streaming_supported(const bool supported) OVERRIDE;
+
+ /*
+ * @brief Retrieves whether HMI supports video streaming
+ *
+ * @return TRUE if it supported, otherwise FALSE
+ */
+ bool video_streaming_supported() const OVERRIDE;
+
+ /*
+ * @brief Interface used to store information regarding
+ * the navigation "System Capability"
+ *
+ * @param navigation_capability contains information related
+ * to the navigation system capability.
+ */
+ void set_navigation_capability(
+ const smart_objects::SmartObject& navigation_capability) OVERRIDE;
+
+ /*
+ * @brief Retrieves information regarding the navigation system capability
+ *
+ * @return NAVIGATION system capability
+ */
+ const smart_objects::SmartObject* navigation_capability() const OVERRIDE;
+
+ /*
+ * @brief Interface used to store information regarding
+ * the phone "System Capability"
+ *
+ * @param phone_capability contains information related
+ * to the phone system capability.
+ */
+ void set_phone_capability(
+ const smart_objects::SmartObject& phone_capability) OVERRIDE;
+
+ /*
+ * @brief Retrieves information regarding the phone call system capability
+ *
+ * @return PHONE_CALL system capability
+ */
+
+ const smart_objects::SmartObject* phone_capability() const OVERRIDE;
+
+ /*
+ * @brief Sets HMI's video streaming related capability information
+ *
+ * @param video_streaming_capability the video streaming related capabilities
+ */
+ void set_video_streaming_capability(
+ const smart_objects::SmartObject& video_streaming_capability) OVERRIDE;
+
+ /*
+ * @brief Retrieves HMI's video streaming related capabilities
+ *
+ * @return HMI's video streaming related capability information
+ */
+ const smart_objects::SmartObject* video_streaming_capability() const OVERRIDE;
+
+ void set_rc_capability(
+ const smart_objects::SmartObject& rc_capability) OVERRIDE;
+
+ const smart_objects::SmartObject* rc_capability() const OVERRIDE;
+
void Init(resumption::LastState* last_state) OVERRIDE;
/*
@@ -462,6 +534,7 @@ class HMICapabilitiesImpl : public HMICapabilities {
bool is_ui_cooperating_;
bool is_navi_cooperating_;
bool is_ivi_cooperating_;
+ bool is_rc_cooperating_;
bool attenuated_supported_;
hmi_apis::Common_Language::eType ui_language_;
@@ -483,7 +556,12 @@ class HMICapabilitiesImpl : public HMICapabilities {
smart_objects::SmartObject* prerecorded_speech_;
bool is_navigation_supported_;
bool is_phone_call_supported_;
+ bool is_video_streaming_supported_;
std::string ccpu_version_;
+ smart_objects::SmartObject* navigation_capability_;
+ smart_objects::SmartObject* phone_capability_;
+ smart_objects::SmartObject* video_streaming_capability_;
+ smart_objects::SmartObject* rc_capability_;
ApplicationManager& app_mngr_;
HMILanguageHandler hmi_language_handler_;
diff --git a/src/components/application_manager/include/application_manager/hmi_interfaces.h b/src/components/application_manager/include/application_manager/hmi_interfaces.h
index df1e2a9067..59ec32694a 100644
--- a/src/components/application_manager/include/application_manager/hmi_interfaces.h
+++ b/src/components/application_manager/include/application_manager/hmi_interfaces.h
@@ -59,7 +59,8 @@ class HmiInterfaces {
HMI_INTERFACE_UI,
HMI_INTERFACE_Navigation,
HMI_INTERFACE_VehicleInfo,
- HMI_INTERFACE_SDL
+ HMI_INTERFACE_SDL,
+ HMI_INTERFACE_RC
};
/**
diff --git a/src/components/application_manager/include/application_manager/hmi_state.h b/src/components/application_manager/include/application_manager/hmi_state.h
index 799fdff67d..939b8b86d0 100644
--- a/src/components/application_manager/include/application_manager/hmi_state.h
+++ b/src/components/application_manager/include/application_manager/hmi_state.h
@@ -196,6 +196,8 @@ class HmiState {
*/
bool is_voice_communication_app(const uint32_t app_id) const;
+ bool is_mobile_projection_app(const uint32_t app_id) const;
+
private:
void operator=(const HmiState&);
};
diff --git a/src/components/application_manager/include/application_manager/message.h b/src/components/application_manager/include/application_manager/message.h
index fe903393fb..77ef5479ee 100644
--- a/src/components/application_manager/include/application_manager/message.h
+++ b/src/components/application_manager/include/application_manager/message.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Ford Motor Company
+ * Copyright (c) 2017, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -39,6 +39,7 @@
#include "utils/shared_ptr.h"
#include "protocol/message_priority.h"
#include "protocol/rpc_type.h"
+#include "protocol/common.h"
#include "smart_objects/smart_object.h"
namespace application_manager {
@@ -57,30 +58,24 @@ enum MessageType {
// Map PrcType to corresponding MessageType
MessageType MessageTypeFromRpcType(protocol_handler::RpcType rpc_type);
-enum ProtocolVersion {
- kUnknownProtocol = -1,
- kHMI = 0,
- kV1 = 1,
- kV2 = 2,
- kV3 = 3,
- kV4 = 4
-};
-
class Message {
public:
- Message(protocol_handler::MessagePriority priority);
+ explicit Message(protocol_handler::MessagePriority priority);
Message(const Message& message);
Message& operator=(const Message& message);
- bool operator==(const Message& message);
+ bool operator==(const Message& message) const;
~Message();
//! --------------------------------------------------------------------------
int32_t function_id() const;
+#ifdef SDL_REMOTE_CONTROL
+ std::string function_name() const;
+#endif // SDL_REMOTE_CONTROL
int32_t correlation_id() const;
int32_t connection_key() const;
MessageType type() const;
- ProtocolVersion protocol_version() const;
+ protocol_handler::MajorProtocolVersion protocol_version() const;
const std::string& json_message() const;
const BinaryData* binary_data() const;
@@ -89,18 +84,26 @@ class Message {
size_t payload_size() const;
const smart_objects::SmartObject& smart_object() const;
- //! --------------------------------------------------------------------------
+ //!
+ //--------------------------------------------------------------------------.
void set_function_id(int32_t id);
+#ifdef SDL_REMOTE_CONTROL
+ void set_function_name(const std::string& name);
+#endif // SDL_REMOTE_CONTROL
void set_correlation_id(int32_t id);
void set_connection_key(int32_t key);
void set_message_type(MessageType type);
void set_binary_data(BinaryData* data);
void set_json_message(const std::string& json_message);
- void set_protocol_version(ProtocolVersion version);
+ void set_protocol_version(protocol_handler::MajorProtocolVersion version);
void set_smart_object(const smart_objects::SmartObject& object);
void set_data_size(size_t data_size);
void set_payload_size(size_t payload_size);
+ static bool is_sufficient_version(
+ protocol_handler::MajorProtocolVersion minVersion,
+ protocol_handler::MajorProtocolVersion version);
+
protocol_handler::MessagePriority Priority() const {
return priority_;
}
@@ -109,6 +112,9 @@ class Message {
int32_t function_id_; // @remark protocol V2.
int32_t correlation_id_; // @remark protocol V2.
MessageType type_; // @remark protocol V2.
+#ifdef SDL_REMOTE_CONTROL
+ std::string function_name_;
+#endif // SDL_REMOTE_CONTROL
// Pre-calculated message priority, higher priority messages are
// Processed first
@@ -122,8 +128,11 @@ class Message {
BinaryData* binary_data_;
size_t data_size_;
size_t payload_size_;
- ProtocolVersion version_;
+ protocol_handler::MajorProtocolVersion version_;
};
+
+typedef utils::SharedPtr<application_manager::Message> MobileMessage;
+typedef utils::SharedPtr<application_manager::Message> MessagePtr;
} // namespace application_manager
#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_MESSAGE_H_
diff --git a/src/components/application_manager/include/application_manager/message_helper.h b/src/components/application_manager/include/application_manager/message_helper.h
index 8d10511d66..c0a3f37c34 100644
--- a/src/components/application_manager/include/application_manager/message_helper.h
+++ b/src/components/application_manager/include/application_manager/message_helper.h
@@ -381,6 +381,18 @@ class MessageHelper {
#endif // EXTERNAL_PROPRIETARY_MODE
/*
+ * @brief Sends SetVideoConfig request to HMI to negotiate video parameters
+ *
+ * @param app_id the application which will start video streaming
+ * @param app_mngr reference of application manager
+ * @param video_params parameters of video streaming, notified by mobile
+ */
+ static void SendNaviSetVideoConfig(
+ int32_t app_id,
+ ApplicationManager& app_mngr,
+ const smart_objects::SmartObject& video_params);
+
+ /*
* @brief Sends notification to HMI to start video streaming
*
* @param connection_key Application connection key
@@ -690,6 +702,31 @@ class MessageHelper {
int32_t connection_key,
mobile_api::AppInterfaceUnregisteredReason::eType reason);
+#ifdef SDL_REMOTE_CONTROL
+ /**
+ * @brief Sends HMI status notification to mobile
+ * @param application_impl application with changed HMI status
+ **/
+ static void SendHMIStatusNotification(
+ const Application& application_impl,
+ ApplicationManager& application_manager);
+
+ /**
+ * @brief SendActivateAppToHMI Sends BasicCommunication.ActivateApp request to
+ * HMI
+ * @param app_id Application id
+ * @param application_manager Application manager
+ * @param level Application HMI level
+ * @param send_policy_priority Defines whether to send "priority" field with
+ * request
+ */
+ static void SendActivateAppToHMI(
+ uint32_t const app_id,
+ ApplicationManager& application_manager,
+ hmi_apis::Common_HMILevel::eType level = hmi_apis::Common_HMILevel::FULL,
+ bool send_policy_priority = true);
+#endif // SDL_REMOTE_CONTROL
+
private:
/**
* @brief Creates new request object and fill its header
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 e2c4d73f5c..9de2d6af68 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
@@ -112,6 +112,73 @@ class PolicyHandler : public PolicyHandlerInterface,
uint32_t GetNotificationsNumber(const std::string& priority) const OVERRIDE;
virtual DeviceConsent GetUserConsentForDevice(
const std::string& device_id) const OVERRIDE;
+
+#ifdef SDL_REMOTE_CONTROL
+ /**
+ * @brief Sets HMI default type for specified application
+ * @param application_id ID application
+ * @param app_types list of HMI types
+ */
+ void SetDefaultHmiTypes(const std::string& application_id,
+ const smart_objects::SmartObject* app_types) OVERRIDE;
+
+ /**
+ * Checks if application has HMI type
+ * @param application_id ID application
+ * @param hmi HMI type to check
+ * @param app_types additional list of HMI type to search in it
+ * @return true if hmi is contained in policy or app_types
+ */
+ bool CheckHMIType(const std::string& application_id,
+ mobile_apis::AppHMIType::eType hmi,
+ const smart_objects::SmartObject* app_types) OVERRIDE;
+
+ /**
+ * Notifies about changing HMI level
+ * @param device_id unique identifier of device
+ * @param policy_app_id unique identifier of application in policy
+ * @param hmi_level default HMI level for this application
+ */
+ void OnUpdateHMILevel(const std::string& device_id,
+ const std::string& policy_app_id,
+ const std::string& hmi_level) OVERRIDE;
+
+ /**
+ * Checks if module for application is present in policy table
+ * @param app_id id of application
+ * @param module type
+ * @return true if module is present, otherwise - false
+ */
+ bool CheckModule(const PTString& app_id, const PTString& module) OVERRIDE;
+
+ /**
+ * @brief Notifies Remote apps about change in permissions
+ * @param device_id Device on which app is running
+ * @param application_id ID of app whose permissions are changed
+ */
+ void OnRemoteAppPermissionsChanged(
+ const std::string& device_id, const std::string& application_id) OVERRIDE;
+
+ /**
+ * @brief Notifies Remote apps about change in HMI status
+ * @param device_id Device on which app is running
+ * @param policy_app_id ID of application
+ * @param hmi_level new HMI level for this application
+ */
+ void OnUpdateHMIStatus(const std::string& device_id,
+ const std::string& policy_app_id,
+ const std::string& hmi_level) OVERRIDE;
+
+ /**
+ * Gets all allowed module types
+ * @param app_id unique identifier of application
+ * @param list of allowed module types
+ * @return true if application has allowed modules
+ */
+ bool GetModuleTypes(const std::string& policy_app_id,
+ std::vector<std::string>* modules) const OVERRIDE;
+#endif // SDL_REMOTE_CONTROL
+
bool GetDefaultHmi(const std::string& policy_app_id,
std::string* default_hmi) const OVERRIDE;
bool GetInitialAppData(const std::string& application_id,
@@ -123,8 +190,18 @@ class PolicyHandler : public PolicyHandlerInterface,
EndpointUrls& out_end_points) OVERRIDE;
virtual std::string GetLockScreenIconUrl() const OVERRIDE;
uint32_t NextRetryTimeout() OVERRIDE;
- uint32_t TimeoutExchangeSec() OVERRIDE;
- uint32_t TimeoutExchangeMSec() OVERRIDE;
+
+ /**
+ * Gets timeout to wait until receive response
+ * @return timeout in seconds
+ */
+ uint32_t TimeoutExchangeSec() const OVERRIDE;
+
+ /**
+ * Gets timeout to wait until receive response
+ * @return timeout in miliseconds
+ */
+ uint32_t TimeoutExchangeMSec() const OVERRIDE;
void OnExceededTimeout() OVERRIDE;
void OnSystemReady() OVERRIDE;
void PTUpdatedAt(Counters counter, int value) OVERRIDE;
@@ -348,7 +425,8 @@ class PolicyHandler : public PolicyHandlerInterface,
* @brief Allows to add new or update existed application during
* registration process
* @param application_id The policy aplication id.
- ** @return function that will notify update manager about new application
+ * @param hmi_types list of hmi types
+ * @return function that will notify update manager about new application
*/
StatusNotifier AddApplication(
const std::string& application_id,
@@ -445,10 +523,6 @@ class PolicyHandler : public PolicyHandlerInterface,
void SetPolicyManager(utils::SharedPtr<PolicyManager> pm) {
policy_manager_ = pm;
}
-
- AppIds& last_used_app_ids() {
- return last_used_app_ids_;
- }
#endif // BUILD_TESTS
#ifdef ENABLE_SECURITY
@@ -510,6 +584,18 @@ class PolicyHandler : public PolicyHandlerInterface,
PermissionConsent& out_permissions) OVERRIDE;
#endif
+#ifdef SDL_REMOTE_CONTROL
+ /**
+ * @brief Updates HMI level for specified application and send notification
+ * @param app application where HMI level was changed
+ * @param level new HMI level
+ */
+ void UpdateHMILevel(application_manager::ApplicationSharedPtr app,
+ mobile_apis::HMILevel::eType level);
+ std::vector<std::string> GetDevicesIds(
+ const std::string& policy_app_id) OVERRIDE;
+#endif // SDL_REMOTE_CONTROL
+
/**
* @brief Sets days after epoch on successful policy update
*/
@@ -609,7 +695,6 @@ class PolicyHandler : public PolicyHandlerInterface,
mutable sync_primitives::RWLock policy_manager_lock_;
utils::SharedPtr<PolicyManager> policy_manager_;
void* dl_handle_;
- AppIds last_used_app_ids_;
utils::SharedPtr<PolicyEventObserver> event_observer_;
uint32_t last_activated_app_id_;
@@ -649,7 +734,6 @@ class PolicyHandler : public PolicyHandlerInterface,
* otherwise FALSE
*/
bool IsUrlAppIdValid(const uint32_t app_idx, const EndpointUrls& urls) const;
-
DISALLOW_COPY_AND_ASSIGN(PolicyHandler);
};
diff --git a/src/components/application_manager/include/application_manager/request_info.h b/src/components/application_manager/include/application_manager/request_info.h
index 216eb86cc5..5ebcac71f8 100644
--- a/src/components/application_manager/include/application_manager/request_info.h
+++ b/src/components/application_manager/include/application_manager/request_info.h
@@ -55,15 +55,22 @@ namespace request_controller {
typedef utils::SharedPtr<commands::Command> RequestPtr;
struct RequestInfo {
- enum RequestType { MobileRequest, HMIRequest };
+ enum RequestType { RequestNone, MobileRequest, HMIRequest };
- RequestInfo() {}
+ RequestInfo()
+ : timeout_msec_(0)
+ , app_id_(0)
+ , requst_type_(RequestNone)
+ , correlation_id_(0) {
+ start_time_ = date_time::DateTime::getCurrentTime();
+ updateEndTime();
+ }
virtual ~RequestInfo() {}
RequestInfo(RequestPtr request,
const RequestType requst_type,
const uint64_t timeout_msec)
- : request_(request), timeout_msec_(timeout_msec) {
+ : request_(request), timeout_msec_(timeout_msec), correlation_id_(0) {
start_time_ = date_time::DateTime::getCurrentTime();
updateEndTime();
requst_type_ = requst_type;
diff --git a/src/components/application_manager/include/application_manager/service.h b/src/components/application_manager/include/application_manager/service.h
new file mode 100644
index 0000000000..da08957afa
--- /dev/null
+++ b/src/components/application_manager/include/application_manager/service.h
@@ -0,0 +1,183 @@
+/*
+ * 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_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_SERVICE_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_SERVICE_H_
+
+#include <string>
+#include <sstream>
+#include <vector>
+#include "application_manager/application.h"
+#include "application_manager/application_manager_settings.h"
+#include "application_manager/message.h"
+#include "application_manager/hmi_interfaces.h"
+
+namespace application_manager {
+
+enum TypeAccess { kDisallowed, kAllowed };
+
+enum MessageValidationResult {
+ SUCCESS = 0,
+ INVALID_JSON,
+ INVALID_METADATA,
+ SCHEMA_MISMATCH,
+ UNSUPPORTED_PROTOCOL
+};
+
+typedef std::string PluginFunctionID;
+
+/**
+ * @brief Interface to core service
+ */
+class Service {
+ public:
+ virtual ~Service() {}
+
+ /**
+ * @brief Checks message permissions and cuts parameters according
+ * to policy table permissions
+ * @param msg message to cut disallowed parameters
+ * @return result according by mobile API
+ */
+ virtual mobile_apis::Result::eType CheckPolicyPermissions(MessagePtr msg) = 0;
+
+ /**
+ * Checks if module for application is present in policy table
+ * @param app_id id of application
+ * @param module type
+ * @return true if module is present, otherwise - false
+ */
+ virtual bool CheckModule(const ApplicationId& app_id,
+ const std::string& module) = 0;
+
+ /**
+ * @brief Get pointer to application by application id
+ * @param app_id application id
+ * return pointer to application
+ */
+ virtual ApplicationSharedPtr GetApplication(ApplicationId app_id) = 0;
+
+ /**
+ * Removes parameters not listed in HMI API from HMI request
+ * @param message message to handle
+ */
+ virtual void RemoveHMIFakeParameters(
+ application_manager::MessagePtr& message) = 0;
+ /**
+ * @brief Send message to HMI
+ * @param message Message to HMI
+ */
+ virtual void SendMessageToHMI(const MessagePtr& message) = 0;
+
+ /**
+ * @brief Send message to mobile device
+ * @param message Message to mobile
+ */
+ virtual void SendMessageToMobile(const MessagePtr& message) = 0;
+
+ /**
+ * @brief Returns unique correlation ID for next HMI request
+ *
+ * @return Unique correlation ID
+ */
+ virtual uint32_t GetNextCorrelationID() = 0;
+
+ /**
+ * @brief Returns all applications related to plugin
+ * @param uid ID provided by plugin to its extension to app.
+ * @return List with shared pointers to applications
+ */
+ virtual std::vector<ApplicationSharedPtr> GetApplications(
+ AppExtensionUID uid) = 0;
+
+ /**
+ * @brief Change hmi level of app and notify it
+ * @param app Application to be changed and notified
+ * @param level New HMI level of app
+ */
+ virtual void ChangeNotifyHMILevel(ApplicationSharedPtr app,
+ mobile_apis::HMILevel::eType level) = 0;
+
+ /**
+ * @brief Notify HMI about app changing HMI Level
+ * only NONE, BACKGROUND and LIMITED levels are sent
+ * @param app Application to be changed and notified
+ * @param level New HMI level of app
+ */
+ virtual void NotifyHMIAboutHMILevel(ApplicationSharedPtr app,
+ mobile_apis::HMILevel::eType level) = 0;
+
+ virtual const smart_objects::SmartObject* GetRCCapabilities() const = 0;
+ /**
+ * Checks if application has remote control functions
+ * @param app application
+ * @return true if application has remote control functions
+ */
+ virtual bool IsRemoteControlApplication(ApplicationSharedPtr app) const = 0;
+
+ /**
+ * @brief Gets current state of the specified interface
+ * @param interface which state to get
+ * @return true if specified interface available otherwise false
+ */
+ virtual bool IsInterfaceAvailable(
+ const HmiInterfaces::InterfaceID interface) const = 0;
+
+ /**
+ * Gets all allowed module types
+ * @param app_id unique identifier of application
+ * @param list of allowed module types
+ * @return true if application has allowed modules
+ */
+ virtual bool GetModuleTypes(const std::string& policy_app_id,
+ std::vector<std::string>* modules) const = 0;
+
+ /**
+ * @brief ValidateMessageBySchema validates message by xml schema
+ * @param message message for validation
+ * @return true if message is valid according to schema, otherwise false
+ */
+ virtual MessageValidationResult ValidateMessageBySchema(
+ const Message& message) = 0;
+
+ /**
+ * @brief Gets application manager settings structure
+ * @return reference to application manager settings structure
+ */
+ virtual const ApplicationManagerSettings& GetSettings() const = 0;
+};
+
+typedef utils::SharedPtr<Service> ServicePtr;
+
+} // namespace application_manager
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_SERVICE_H_
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 38c1b1d9cc..ccac1ec67b 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
@@ -2,6 +2,9 @@
Copyright (c) 2013, Ford Motor Company
All rights reserved.
+ Copyright (c) 2017 Xevo Inc.
+ All rights reserved.
+
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -13,7 +16,7 @@
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
+ Neither the name of the copyright holders nor the names of their contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
@@ -167,6 +170,13 @@ extern const char* audio_pass_thru_capabilities;
extern const char* pcm_stream_capabilities;
extern const char* audio_pass_thru_icon;
extern const char* way_points;
+extern const char* system_capability;
+extern const char* system_capability_type;
+extern const char* system_capabilities;
+extern const char* navigation_capability;
+extern const char* phone_capability;
+extern const char* video_streaming_capability;
+extern const char* rc_capability;
// PutFile
extern const char* sync_file_name;
@@ -258,6 +268,7 @@ extern const char* supported_diag_modes;
extern const char* hmi_capabilities;
extern const char* navigation;
extern const char* phone_call;
+extern const char* video_streaming;
extern const char* sdl_version;
extern const char* system_software_version;
extern const char* priority;
@@ -332,6 +343,22 @@ extern const char* const status;
extern const char* const external_consent_status;
extern const char* const consented_functions;
extern const char* const source;
+extern const char* const config;
+extern const char* const protocol;
+extern const char* const codec;
+extern const char* const width;
+extern const char* const height;
+extern const char* const rejected_params;
+extern const char* const preferred_resolution;
+extern const char* const resolution_width;
+extern const char* const resolution_height;
+extern const char* const max_bitrate;
+extern const char* const supported_formats;
+extern const char* const haptic_spatial_data_supported;
+extern const char* const haptic_rect_data;
+extern const char* const rect;
+extern const char* const x;
+extern const char* const y;
} // namespace strings
namespace json {
diff --git a/src/components/application_manager/src/app_launch/apps_launcher.cc b/src/components/application_manager/src/app_launch/apps_launcher.cc
index 41465ae985..bf3ce1e0a9 100644
--- a/src/components/application_manager/src/app_launch/apps_launcher.cc
+++ b/src/components/application_manager/src/app_launch/apps_launcher.cc
@@ -95,7 +95,8 @@ AppsLauncher::Launcher::Launcher(
connection_handler::ConnectionHandler& connection_handler,
const uint16_t app_launch_max_retry_attempt,
const uint16_t app_launch_retry_wait_time)
- : retry_timer_(
+ : retry_index_(0)
+ , retry_timer_(
"AppsLauncherTimer",
new timer::TimerTaskImpl<Launcher>(this, &Launcher::LaunchNow))
, app_launch_max_retry_attempt_(app_launch_max_retry_attempt)
diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc
index 5f9c4386f5..4a752febf8 100644
--- a/src/components/application_manager/src/application_impl.cc
+++ b/src/components/application_manager/src/application_impl.cc
@@ -88,6 +88,7 @@ ApplicationImpl::ApplicationImpl(
, active_message_(NULL)
, is_media_(false)
, is_navi_(false)
+ , mobile_projection_enabled_(false)
, video_streaming_approved_(false)
, audio_streaming_approved_(false)
, video_streaming_allowed_(false)
@@ -106,7 +107,8 @@ ApplicationImpl::ApplicationImpl(
, device_(0)
, mac_address_(mac_address)
, usage_report_(mobile_app_id, statistics_manager)
- , protocol_version_(ProtocolVersion::kV3)
+ , protocol_version_(
+ protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_3)
, is_voice_communication_application_(false)
, is_resuming_(false)
, video_stream_retry_number_(0)
@@ -179,6 +181,7 @@ bool ApplicationImpl::is_audio() const {
void ApplicationImpl::ChangeSupportingAppHMIType() {
is_navi_ = false;
is_voice_communication_application_ = false;
+ mobile_projection_enabled_ = false;
const smart_objects::SmartObject& array_app_types = *app_types_;
uint32_t lenght_app_types = array_app_types.length();
@@ -193,6 +196,11 @@ void ApplicationImpl::ChangeSupportingAppHMIType() {
array_app_types[i].asUInt())) {
is_voice_communication_application_ = true;
}
+ if (mobile_apis::AppHMIType::PROJECTION ==
+ static_cast<mobile_apis::AppHMIType::eType>(
+ array_app_types[i].asUInt())) {
+ mobile_projection_enabled_ = true;
+ }
}
}
@@ -228,6 +236,15 @@ void ApplicationImpl::SetPostponedState(HmiStatePtr state) {
state_.AddState(state);
}
+void ApplicationImpl::set_mobile_projection_enabled(bool option) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ mobile_projection_enabled_ = option;
+}
+
+bool ApplicationImpl::mobile_projection_enabled() const {
+ return mobile_projection_enabled_;
+}
+
struct StateIDComparator {
HmiState::StateID state_id_;
StateIDComparator(HmiState::StateID state_id) : state_id_(state_id) {}
@@ -399,6 +416,24 @@ bool ApplicationImpl::audio_streaming_allowed() const {
return audio_streaming_allowed_;
}
+bool ApplicationImpl::SetVideoConfig(protocol_handler::ServiceType service_type,
+ const smart_objects::SmartObject& params) {
+ using namespace protocol_handler;
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ if (ServiceType::kMobileNav == service_type) {
+ // See StartStreaming(). We issue SetVideoConfig and StartStream
+ // only when streaming is not approved yet
+ if (!video_streaming_approved()) {
+ LOG4CXX_TRACE(logger_, "Video streaming not approved");
+ MessageHelper::SendNaviSetVideoConfig(
+ app_id(), application_manager_, params);
+ return true;
+ }
+ }
+ return false;
+}
+
void ApplicationImpl::StartStreaming(
protocol_handler::ServiceType service_type) {
using namespace protocol_handler;
@@ -601,11 +636,12 @@ bool ApplicationImpl::set_activated(bool is_active) {
}
void ApplicationImpl::set_protocol_version(
- const ProtocolVersion& protocol_version) {
+ const protocol_handler::MajorProtocolVersion& protocol_version) {
protocol_version_ = protocol_version;
}
-ProtocolVersion ApplicationImpl::protocol_version() const {
+protocol_handler::MajorProtocolVersion ApplicationImpl::protocol_version()
+ const {
return protocol_version_;
}
@@ -972,4 +1008,81 @@ void ApplicationImpl::UnsubscribeFromSoftButtons(int32_t cmd_id) {
}
}
+#ifdef SDL_REMOTE_CONTROL
+
+void ApplicationImpl::set_system_context(
+ const mobile_api::SystemContext::eType& system_context) {
+ const HmiStatePtr hmi_state = CurrentHmiState();
+ hmi_state->set_system_context(system_context);
+}
+
+void ApplicationImpl::set_audio_streaming_state(
+ const mobile_api::AudioStreamingState::eType& state) {
+ if (!(is_media_application() || is_navi()) &&
+ state != mobile_api::AudioStreamingState::NOT_AUDIBLE) {
+ LOG4CXX_WARN(logger_,
+ "Trying to set audio streaming state"
+ " for non-media application to different from NOT_AUDIBLE");
+ return;
+ }
+ CurrentHmiState()->set_audio_streaming_state(state);
+}
+
+void ApplicationImpl::set_hmi_level(
+ const mobile_api::HMILevel::eType& new_hmi_level) {
+ using namespace mobile_apis;
+ const HMILevel::eType current_hmi_level = hmi_level();
+ if (HMILevel::HMI_NONE != current_hmi_level &&
+ HMILevel::HMI_NONE == new_hmi_level) {
+ put_file_in_none_count_ = 0;
+ delete_file_in_none_count_ = 0;
+ list_files_in_none_count_ = 0;
+ }
+ ApplicationSharedPtr app = application_manager_.application(app_id());
+ DCHECK_OR_RETURN_VOID(app)
+ application_manager_.state_controller().SetRegularState(app, new_hmi_level);
+ LOG4CXX_INFO(logger_, "hmi_level = " << new_hmi_level);
+ usage_report_.RecordHmiStateChanged(new_hmi_level);
+}
+
+const std::set<uint32_t>& ApplicationImpl::SubscribesIVI() const {
+ return subscribed_vehicle_info_;
+}
+
+AppExtensionPtr ApplicationImpl::QueryInterface(AppExtensionUID uid) {
+ std::list<AppExtensionPtr>::const_iterator it = extensions_.begin();
+ for (; it != extensions_.end(); ++it) {
+ if ((*it)->uid() == uid) {
+ return (*it);
+ }
+ }
+
+ return AppExtensionPtr();
+}
+
+bool ApplicationImpl::AddExtension(AppExtensionPtr extension) {
+ if (!QueryInterface(extension->uid())) {
+ extensions_.push_back(extension);
+ return true;
+ }
+ return false;
+}
+
+bool ApplicationImpl::RemoveExtension(AppExtensionUID uid) {
+ for (std::list<AppExtensionPtr>::iterator it = extensions_.begin();
+ extensions_.end() != it;
+ ++it) {
+ if ((*it)->uid() == uid) {
+ extensions_.erase(it);
+ return true;
+ }
+ }
+ return false;
+}
+
+void ApplicationImpl::RemoveExtensions() {
+ application_manager_.GetPluginManager().RemoveAppExtension(app_id_);
+}
+#endif // SDL_REMOTE_CONTROL
+
} // namespace application_manager
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index 56a9ff6bcf..ab20222fcf 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -36,6 +36,7 @@
#include <string>
#include <fstream>
#include <utility>
+#include <bson_object.h>
#include "application_manager/application_manager_impl.h"
#include "application_manager/mobile_command_factory.h"
@@ -55,6 +56,7 @@
#include "formatters/formatter_json_rpc.h"
#include "formatters/CFormatterJsonSDLRPCv2.h"
#include "formatters/CFormatterJsonSDLRPCv1.h"
+#include "protocol/bson_object_keys.h"
#include "utils/threads/thread.h"
#include "utils/file_system.h"
@@ -69,6 +71,12 @@
#include "utils/custom_string.h"
#include <time.h>
+#ifdef SDL_REMOTE_CONTROL
+#include "policy/usage_statistics/counter.h"
+#include "functional_module/plugin_manager.h"
+#include "application_manager/core_service.h"
+#endif // SDL_REMOTE_CONTROL
+
namespace {
int get_rand_from_range(uint32_t from = 0, int to = RAND_MAX) {
return std::rand() % to + from;
@@ -291,6 +299,29 @@ ApplicationManagerImpl::applications_with_navi() {
DataAccessor<ApplicationSet> accessor = applications();
return FindAllApps(accessor, NaviAppPredicate);
}
+
+bool LimitedMobileProjectionPredicate(const ApplicationSharedPtr app) {
+ return app ? (app->mobile_projection_enabled() &&
+ app->hmi_level() == mobile_api::HMILevel::HMI_LIMITED)
+ : false;
+}
+
+ApplicationSharedPtr
+ApplicationManagerImpl::get_limited_mobile_projection_application() const {
+ DataAccessor<ApplicationSet> accessor = applications();
+ return FindApp(accessor, LimitedMobileProjectionPredicate);
+}
+
+bool MobileProjectionPredicate(const ApplicationSharedPtr app) {
+ return app ? app->mobile_projection_enabled() : false;
+}
+
+std::vector<ApplicationSharedPtr>
+ApplicationManagerImpl::applications_with_mobile_projection() {
+ DataAccessor<ApplicationSet> accessor = applications();
+ return FindAllApps(accessor, MobileProjectionPredicate);
+}
+
std::vector<ApplicationSharedPtr>
ApplicationManagerImpl::applications_by_button(uint32_t button) {
SubscribedToButtonPredicate finder(
@@ -308,6 +339,20 @@ struct SubscribedToIVIPredicate {
}
};
+struct IsApplication {
+ IsApplication(connection_handler::DeviceHandle device_handle,
+ const std::string& policy_app_id)
+ : device_handle_(device_handle), policy_app_id_(policy_app_id) {}
+ bool operator()(const ApplicationSharedPtr app) const {
+ return app && app->device() == device_handle_ &&
+ app->policy_app_id() == policy_app_id_;
+ }
+
+ private:
+ connection_handler::DeviceHandle device_handle_;
+ const std::string& policy_app_id_;
+};
+
std::vector<ApplicationSharedPtr> ApplicationManagerImpl::IviInfoUpdated(
VehicleDataType vehicle_info, int value) {
// Notify Policy Manager if available about info it's interested in,
@@ -353,6 +398,7 @@ bool ApplicationManagerImpl::IsAppTypeExistsInFullOrLimited(
bool voice_state = app->is_voice_communication_supported();
bool media_state = app->is_media_application();
bool navi_state = app->is_navi();
+ bool mobile_projection_state = app->mobile_projection_enabled();
ApplicationSharedPtr active_app = active_application();
// Check app in FULL level
if (active_app.valid()) {
@@ -374,6 +420,10 @@ bool ApplicationManagerImpl::IsAppTypeExistsInFullOrLimited(
if (navi_state && active_app->is_navi()) {
return true;
}
+
+ if (mobile_projection_state && active_app->mobile_projection_enabled()) {
+ return true;
+ }
}
// Check LIMITED apps
@@ -398,6 +448,14 @@ bool ApplicationManagerImpl::IsAppTypeExistsInFullOrLimited(
}
}
+ if (mobile_projection_state) {
+ if (get_limited_mobile_projection_application().valid() &&
+ (get_limited_mobile_projection_application()->app_id() !=
+ app->app_id())) {
+ return true;
+ }
+ }
+
return false;
}
@@ -510,15 +568,18 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication(
version.max_supported_api_version = static_cast<APIVersion>(max_version);
application->set_version(version);
- ProtocolVersion protocol_version = static_cast<ProtocolVersion>(
- message[strings::params][strings::protocol_version].asInt());
+ protocol_handler::MajorProtocolVersion protocol_version =
+ static_cast<protocol_handler::MajorProtocolVersion>(
+ message[strings::params][strings::protocol_version].asInt());
application->set_protocol_version(protocol_version);
- if (ProtocolVersion::kUnknownProtocol != protocol_version) {
+ if (protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_UNKNOWN !=
+ protocol_version) {
connection_handler().BindProtocolVersionWithSession(
connection_key, static_cast<uint8_t>(protocol_version));
}
- if ((protocol_version == ProtocolVersion::kV3) &&
+ if ((protocol_version ==
+ protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_3) &&
(get_settings().heart_beat_timeout() != 0)) {
connection_handler().StartSessionHeartBeat(connection_key);
}
@@ -664,6 +725,13 @@ void ApplicationManagerImpl::OnHMIStartedCooperation() {
hmi_apis::FunctionID::VehicleInfo_IsReady, *this));
ManageHMICommand(is_ivi_ready);
+#ifdef SDL_REMOTE_CONTROL
+ utils::SharedPtr<smart_objects::SmartObject> is_rc_ready(
+ MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::RC_IsReady,
+ *this));
+ ManageHMICommand(is_rc_ready);
+#endif
+
utils::SharedPtr<smart_objects::SmartObject> button_capabilities(
MessageHelper::CreateModuleInfoSO(
hmi_apis::FunctionID::Buttons_GetCapabilities, *this));
@@ -1098,6 +1166,7 @@ void ApplicationManagerImpl::ReplaceHMIByMobileAppId(
}
}
+// DEPRECATED
bool ApplicationManagerImpl::StartNaviService(
uint32_t app_id, protocol_handler::ServiceType service_type) {
using namespace protocol_handler;
@@ -1130,20 +1199,118 @@ bool ApplicationManagerImpl::StartNaviService(
return false;
}
+bool ApplicationManagerImpl::StartNaviService(
+ uint32_t app_id,
+ protocol_handler::ServiceType service_type,
+ const BsonObject* params) {
+ using namespace protocol_handler;
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ if (HMILevelAllowsStreaming(app_id, service_type)) {
+ {
+ sync_primitives::AutoLock lock(navi_service_status_lock_);
+
+ NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id);
+ if (navi_service_status_.end() == it) {
+ std::pair<NaviServiceStatusMap::iterator, bool> res =
+ navi_service_status_.insert(
+ std::pair<uint32_t, std::pair<bool, bool> >(
+ app_id, std::make_pair(false, false)));
+ if (!res.second) {
+ LOG4CXX_WARN(logger_, "Navi service refused");
+ return false;
+ }
+ it = res.first;
+ }
+ }
+
+ if (service_type == ServiceType::kMobileNav) {
+ smart_objects::SmartObject converted_params(smart_objects::SmartType_Map);
+ ConvertVideoParamsToSO(converted_params, params);
+
+ if (!converted_params.empty()) {
+ LOG4CXX_INFO(logger_, "Sending video configuration params");
+#ifdef DEBUG
+ MessageHelper::PrintSmartObject(converted_params);
+#endif
+ bool request_sent =
+ application(app_id)->SetVideoConfig(service_type, converted_params);
+ if (request_sent) {
+ return true;
+ }
+ }
+ }
+ // no configuration is needed, or SetVideoConfig is not sent
+ std::vector<std::string> empty;
+ OnStreamingConfigured(app_id, service_type, true, empty);
+ return true;
+
+ } else {
+ LOG4CXX_WARN(logger_, "Refused navi service by HMI level");
+ }
+ return false;
+}
+
+void ApplicationManagerImpl::OnStreamingConfigured(
+ uint32_t app_id,
+ protocol_handler::ServiceType service_type,
+ bool result,
+ std::vector<std::string>& rejected_params) {
+ using namespace protocol_handler;
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ LOG4CXX_INFO(logger_,
+ "OnStreamingConfigured called for service "
+ << service_type << ", result=" << result);
+
+ if (result) {
+ std::vector<std::string> empty;
+ {
+ sync_primitives::AutoLock lock(navi_service_status_lock_);
+
+ NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id);
+ if (navi_service_status_.end() == it) {
+ LOG4CXX_WARN(logger_, "Application not found in navi status map");
+ connection_handler().NotifyServiceStartedResult(app_id, false, empty);
+ return;
+ }
+
+ // Fill NaviServices map. Set true to first value of pair if
+ // we've started video service or to second value if we've
+ // started audio service
+ service_type == ServiceType::kMobileNav ? it->second.first = true
+ : it->second.second = true;
+ }
+
+ application(app_id)->StartStreaming(service_type);
+ connection_handler().NotifyServiceStartedResult(app_id, true, empty);
+ } else {
+ std::vector<std::string> converted_params =
+ ConvertRejectedParamList(rejected_params);
+ connection_handler().NotifyServiceStartedResult(
+ app_id, false, converted_params);
+ }
+}
+
void ApplicationManagerImpl::StopNaviService(
uint32_t app_id, protocol_handler::ServiceType service_type) {
using namespace protocol_handler;
LOG4CXX_AUTO_TRACE(logger_);
- NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id);
- if (navi_service_status_.end() == it) {
- LOG4CXX_WARN(logger_, "No Information about navi service " << service_type);
- } else {
- // Fill NaviServices map. Set false to first value of pair if
- // we've stopped video service or to second value if we've
- // stopped audio service
- service_type == ServiceType::kMobileNav ? it->second.first = false
- : it->second.second = false;
+ {
+ sync_primitives::AutoLock lock(navi_service_status_lock_);
+
+ NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id);
+ if (navi_service_status_.end() == it) {
+ LOG4CXX_WARN(logger_,
+ "No Information about navi service " << service_type);
+ } else {
+ // Fill NaviServices map. Set false to first value of pair if
+ // we've stopped video service or to second value if we've
+ // stopped audio service
+ service_type == ServiceType::kMobileNav ? it->second.first = false
+ : it->second.second = false;
+ }
}
ApplicationSharedPtr app = application(app_id);
@@ -1155,6 +1322,7 @@ void ApplicationManagerImpl::StopNaviService(
app->StopStreaming(service_type);
}
+// DEPRECATED
bool ApplicationManagerImpl::OnServiceStartedCallback(
const connection_handler::DeviceHandle& device_handle,
const int32_t& session_key,
@@ -1191,6 +1359,50 @@ bool ApplicationManagerImpl::OnServiceStartedCallback(
return false;
}
+void ApplicationManagerImpl::OnServiceStartedCallback(
+ const connection_handler::DeviceHandle& device_handle,
+ const int32_t& session_key,
+ const protocol_handler::ServiceType& type,
+ const BsonObject* params) {
+ using namespace helpers;
+ using namespace protocol_handler;
+ LOG4CXX_AUTO_TRACE(logger_);
+ LOG4CXX_DEBUG(logger_,
+ "ServiceType = " << type << ". Session = " << std::hex
+ << session_key);
+ std::vector<std::string> empty;
+
+ if (type == kRpc) {
+ LOG4CXX_DEBUG(logger_, "RPC service is about to be started.");
+ connection_handler().NotifyServiceStartedResult(session_key, true, empty);
+ return;
+ }
+ ApplicationSharedPtr app = application(session_key);
+ if (!app) {
+ LOG4CXX_WARN(logger_,
+ "The application with id:" << session_key
+ << " doesn't exists.");
+ connection_handler().NotifyServiceStartedResult(session_key, false, empty);
+ return;
+ }
+
+ if (Compare<ServiceType, EQ, ONE>(
+ type, ServiceType::kMobileNav, ServiceType::kAudio)) {
+ if (app->is_navi() || app->mobile_projection_enabled()) {
+ if (!StartNaviService(session_key, type, params)) {
+ connection_handler().NotifyServiceStartedResult(
+ session_key, false, empty);
+ }
+ return;
+ } else {
+ LOG4CXX_WARN(logger_, "Refuse not navi/projection application");
+ }
+ } else {
+ LOG4CXX_WARN(logger_, "Refuse unknown service");
+ }
+ connection_handler().NotifyServiceStartedResult(session_key, false, empty);
+}
+
void ApplicationManagerImpl::OnServiceEndedCallback(
const int32_t& session_key,
const protocol_handler::ServiceType& type,
@@ -1356,7 +1568,7 @@ void ApplicationManagerImpl::SendMessageToMobile(
((*message)[strings::msg_params][strings::result_code] ==
NsSmartDeviceLinkRPC::V1::Result::UNSUPPORTED_VERSION)) {
(*message)[strings::params][strings::protocol_version] =
- ProtocolVersion::kV1;
+ protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_1;
} else {
(*message)[strings::params][strings::protocol_version] =
SupportedSDLVersion();
@@ -1393,6 +1605,19 @@ void ApplicationManagerImpl::SendMessageToMobile(
msg_to_mobile[strings::params][strings::correlation_id].asUInt(),
msg_to_mobile[strings::params][strings::connection_key].asUInt(),
msg_to_mobile[strings::params][strings::function_id].asInt());
+#ifdef SDL_REMOTE_CONTROL
+ const mobile_apis::FunctionID::eType function_id =
+ static_cast<mobile_apis::FunctionID::eType>(
+ (*message)[strings::params][strings::function_id].asUInt());
+ if (function_id == mobile_apis::FunctionID::RegisterAppInterfaceID &&
+ (*message)[strings::msg_params][strings::success].asBool()) {
+ const bool is_for_plugin = plugin_manager_.IsAppForPlugins(app);
+ LOG4CXX_INFO(logger_,
+ "Registered app " << app->app_id() << " is "
+ << (is_for_plugin ? "" : "not ")
+ << "for plugins.");
+ }
+#endif // SDL_REMOTE_CONTROL
} else if (app) {
mobile_apis::FunctionID::eType function_id =
static_cast<mobile_apis::FunctionID::eType>(
@@ -1625,6 +1850,25 @@ bool ApplicationManagerImpl::ManageMobileCommand(
return false;
}
+void ApplicationManagerImpl::RemoveHMIFakeParameters(
+ application_manager::MessagePtr& message) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ using namespace NsSmartDeviceLink::NsSmartObjects;
+ using namespace NsSmartDeviceLink::NsJSONHandler;
+ SmartObject so;
+
+ Formatters::FormatterJsonRpc::FromString<hmi_apis::FunctionID::eType,
+ hmi_apis::messageType::eType>(
+ message->json_message(), so);
+
+ std::string formatted_message;
+ namespace Formatters = NsSmartDeviceLink::NsJSONHandler::Formatters;
+ hmi_apis::HMI_API factory;
+ factory.attachSchema(so, true);
+ Formatters::FormatterJsonRpc::ToString(so, formatted_message);
+ message->set_json_message(formatted_message);
+}
+
void ApplicationManagerImpl::SendMessageToHMI(
const commands::MessageSharedPtr message) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -1769,6 +2013,17 @@ bool ApplicationManagerImpl::Init(resumption::LastState& last_state,
app_launch_ctrl_.reset(new app_launch::AppLaunchCtrlImpl(
*app_launch_dto_.get(), *this, settings_));
+#ifdef SDL_REMOTE_CONTROL
+ if (!hmi_handler_) {
+ LOG4CXX_ERROR(logger_, "HMI message handler was not initialized");
+ return false;
+ }
+ plugin_manager_.SetServiceHandler(utils::MakeShared<CoreService>(*this));
+ plugin_manager_.LoadPlugins(settings_.plugins_folder());
+ plugin_manager_.OnServiceStateChanged(
+ functional_modules::ServiceState::HMI_ADAPTER_INITIALIZED);
+#endif // SDL_REMOTE_CONTROL
+
return true;
}
@@ -1802,9 +2057,10 @@ bool ApplicationManagerImpl::ConvertMessageToSO(
<< message.json_message());
switch (message.protocol_version()) {
- case ProtocolVersion::kV4:
- case ProtocolVersion::kV3:
- case ProtocolVersion::kV2: {
+ case protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5:
+ case protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_4:
+ case protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_3:
+ case protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_2: {
const bool conversion_result =
formatters::CFormatterJsonSDLRPCv2::fromString(
message.json_message(),
@@ -1856,7 +2112,7 @@ bool ApplicationManagerImpl::ConvertMessageToSO(
}
break;
}
- case ProtocolVersion::kHMI: {
+ case protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_HMI: {
#ifdef ENABLE_LOG
int32_t result =
#endif
@@ -1873,28 +2129,11 @@ bool ApplicationManagerImpl::ConvertMessageToSO(
}
if (output.validate() != smart_objects::Errors::OK) {
LOG4CXX_ERROR(logger_, "Incorrect parameter from HMI");
-
- if (application_manager::MessageType::kNotification ==
- output[strings::params][strings::message_type].asInt()) {
- LOG4CXX_ERROR(logger_, "Ignore wrong HMI notification");
- return false;
- }
-
- if (application_manager::MessageType::kRequest ==
- output[strings::params][strings::message_type].asInt()) {
- LOG4CXX_ERROR(logger_, "Ignore wrong HMI request");
- return false;
- }
-
- output.erase(strings::msg_params);
- output[strings::params][hmi_response::code] =
- hmi_apis::Common_Result::INVALID_DATA;
- output[strings::msg_params][strings::info] =
- std::string("Received invalid data on HMI response");
+ return false;
}
break;
}
- case ProtocolVersion::kV1: {
+ case protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_1: {
static NsSmartDeviceLinkRPC::V1::v4_protocol_v1_2_no_extra v1_shema;
if (message.function_id() == 0 || message.type() == kUnknownType) {
@@ -1932,8 +2171,6 @@ bool ApplicationManagerImpl::ConvertMessageToSO(
break;
}
default:
- // TODO(PV):
- // removed NOTREACHED() because some app can still have vesion 1.
LOG4CXX_WARN(logger_,
"Application used unsupported protocol :"
<< message.protocol_version() << ".");
@@ -1975,7 +2212,8 @@ bool ApplicationManagerImpl::ConvertSOtoMessage(
LOG4CXX_WARN(logger_, "Failed to serialize smart object");
return false;
}
- output.set_protocol_version(application_manager::kV1);
+ output.set_protocol_version(
+ protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_1);
} else {
if (!formatters::CFormatterJsonSDLRPCv2::toString(message,
output_string)) {
@@ -1983,7 +2221,8 @@ bool ApplicationManagerImpl::ConvertSOtoMessage(
return false;
}
output.set_protocol_version(
- static_cast<ProtocolVersion>(protocol_version));
+ static_cast<protocol_handler::MajorProtocolVersion>(
+ protocol_version));
}
break;
@@ -1993,7 +2232,8 @@ bool ApplicationManagerImpl::ConvertSOtoMessage(
LOG4CXX_WARN(logger_, "Failed to serialize smart object");
return false;
}
- output.set_protocol_version(application_manager::kHMI);
+ output.set_protocol_version(
+ protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_HMI);
break;
}
default:
@@ -2045,6 +2285,60 @@ bool ApplicationManagerImpl::ConvertSOtoMessage(
return true;
}
+MessageValidationResult ApplicationManagerImpl::ValidateMessageBySchema(
+ const Message& message) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ smart_objects::SmartObject so;
+ using namespace protocol_handler;
+ switch (message.protocol_version()) {
+ case MajorProtocolVersion::PROTOCOL_VERSION_5:
+ case MajorProtocolVersion::PROTOCOL_VERSION_4:
+ case MajorProtocolVersion::PROTOCOL_VERSION_3:
+ case MajorProtocolVersion::PROTOCOL_VERSION_2: {
+ const bool conversion_result =
+ formatters::CFormatterJsonSDLRPCv2::fromString(
+ message.json_message(),
+ so,
+ message.function_id(),
+ message.type(),
+ message.correlation_id());
+ if (!conversion_result) {
+ return INVALID_JSON;
+ }
+
+ if (!mobile_so_factory().attachSchema(so, true)) {
+ return INVALID_METADATA;
+ }
+
+ if (so.validate() != smart_objects::Errors::OK) {
+ return SCHEMA_MISMATCH;
+ }
+ break;
+ }
+ case MajorProtocolVersion::PROTOCOL_VERSION_HMI: {
+ const int32_t conversion_result = formatters::FormatterJsonRpc::
+ FromString<hmi_apis::FunctionID::eType, hmi_apis::messageType::eType>(
+ message.json_message(), so);
+ if (0 != conversion_result) {
+ LOG4CXX_WARN(logger_,
+ "Failed to parse json from HMI: " << conversion_result);
+ return INVALID_JSON;
+ }
+
+ if (!hmi_so_factory().attachSchema(so, true)) {
+ return INVALID_METADATA;
+ }
+
+ if (so.validate() != smart_objects::Errors::OK) {
+ return SCHEMA_MISMATCH;
+ }
+ break;
+ }
+ default: { return UNSUPPORTED_PROTOCOL; }
+ }
+ return SUCCESS;
+}
+
utils::SharedPtr<Message> ApplicationManagerImpl::ConvertRawMsgToMessage(
const ::protocol_handler::RawMessagePtr message) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -2120,8 +2414,17 @@ void ApplicationManagerImpl::ProcessMessageFromHMI(
*smart_object = message->smart_object();
#else
if (!ConvertMessageToSO(*message, *smart_object)) {
- LOG4CXX_ERROR(logger_, "Cannot create smart object from message");
- return;
+ if (application_manager::MessageType::kResponse ==
+ (*smart_object)[strings::params][strings::message_type].asInt()) {
+ (*smart_object).erase(strings::msg_params);
+ (*smart_object)[strings::params][hmi_response::code] =
+ hmi_apis::Common_Result::INVALID_DATA;
+ (*smart_object)[strings::msg_params][strings::info] =
+ std::string("Received invalid data on HMI response");
+ } else {
+ LOG4CXX_ERROR(logger_, "Cannot create smart object from message");
+ return;
+ }
}
#endif // HMI_DBUS_API
@@ -2617,9 +2920,13 @@ void ApplicationManagerImpl::UnregisterApplication(
MessageHelper::SendUnsubscribedWayPoints(*this);
}
- NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id);
- if (navi_service_status_.end() != it) {
- navi_service_status_.erase(it);
+ {
+ sync_primitives::AutoLock lock(navi_service_status_lock_);
+
+ NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id);
+ if (navi_service_status_.end() != it) {
+ navi_service_status_.erase(it);
+ }
}
// remove appID from tts_global_properties_app_list_
@@ -2702,6 +3009,11 @@ void ApplicationManagerImpl::UnregisterApplication(
MessageHelper::SendStopAudioPathThru(*this);
}
+#ifdef SDL_REMOTE_CONTROL
+ plugin_manager_.OnApplicationEvent(
+ functional_modules::ApplicationEvent::kApplicationUnregistered, app_id);
+#endif
+
MessageHelper::SendOnAppUnregNotificationToHMI(
app_to_remove, is_unexpected_disconnect, *this);
request_ctrl_.terminateAppRequests(app_id);
@@ -2725,6 +3037,15 @@ void ApplicationManagerImpl::Handle(const impl::MessageFromMobile message) {
LOG4CXX_INFO(logger_, "Application manager is stopping");
return;
}
+#ifdef SDL_REMOTE_CONTROL
+ if (plugin_manager_.IsMessageForPlugin(message)) {
+ if (functional_modules::ProcessResult::PROCESSED ==
+ plugin_manager_.ProcessMessage(message)) {
+ LOG4CXX_INFO(logger_, "Message is processed by plugin.");
+ return;
+ }
+ }
+#endif
ProcessMessageFromMobile(message);
}
@@ -2770,6 +3091,18 @@ void ApplicationManagerImpl::Handle(const impl::MessageFromHmi message) {
return;
}
+#ifdef SDL_REMOTE_CONTROL
+ if (plugin_manager_.IsHMIMessageForPlugin(message)) {
+ functional_modules::ProcessResult result =
+ plugin_manager_.ProcessHMIMessage(message);
+ if (functional_modules::ProcessResult::PROCESSED == result ||
+ functional_modules::ProcessResult::FAILED == result) {
+ LOG4CXX_INFO(logger_, "Message is processed by plugin.");
+ return;
+ }
+ }
+#endif
+
ProcessMessageFromHMI(message);
}
@@ -2818,9 +3151,10 @@ void ApplicationManagerImpl::Handle(const impl::AudioData message) {
return;
}
- command->Init();
- command->Run();
- command->CleanUp();
+ if (command->Init()) {
+ command->Run();
+ command->CleanUp();
+ }
}
mobile_apis::Result::eType ApplicationManagerImpl::CheckPolicyPermissions(
@@ -2942,8 +3276,10 @@ void ApplicationManagerImpl::ForbidStreaming(uint32_t app_id) {
LOG4CXX_AUTO_TRACE(logger_);
ApplicationSharedPtr app = application(app_id);
- if (!app || !app->is_navi()) {
- LOG4CXX_DEBUG(logger_, "There is no navi application with id: " << app_id);
+ if (!app || (!app->is_navi() && !app->mobile_projection_enabled())) {
+ LOG4CXX_DEBUG(
+ logger_,
+ "There is no navi or projection application with id: " << app_id);
return;
}
@@ -2957,9 +3293,17 @@ void ApplicationManagerImpl::ForbidStreaming(uint32_t app_id) {
return;
}
- NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id);
- if (navi_service_status_.end() == it ||
- (!it->second.first && !it->second.second)) {
+ bool unregister = false;
+ {
+ sync_primitives::AutoLock lock(navi_service_status_lock_);
+
+ NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id);
+ if (navi_service_status_.end() == it ||
+ (!it->second.first && !it->second.second)) {
+ unregister = true;
+ }
+ }
+ if (unregister) {
ManageMobileCommand(
MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile(
app_id, PROTOCOL_VIOLATION),
@@ -2976,8 +3320,10 @@ void ApplicationManagerImpl::OnAppStreaming(
LOG4CXX_AUTO_TRACE(logger_);
ApplicationSharedPtr app = application(app_id);
- if (!app || !app->is_navi()) {
- LOG4CXX_DEBUG(logger_, " There is no navi application with id: " << app_id);
+ if (!app || (!app->is_navi() && !app->mobile_projection_enabled())) {
+ LOG4CXX_DEBUG(
+ logger_,
+ " There is no navi or projection application with id: " << app_id);
return;
}
DCHECK_OR_RETURN_VOID(media_manager_);
@@ -2996,24 +3342,34 @@ void ApplicationManagerImpl::EndNaviServices(uint32_t app_id) {
LOG4CXX_AUTO_TRACE(logger_);
ApplicationSharedPtr app = application(app_id);
- if (!app || !app->is_navi()) {
- LOG4CXX_DEBUG(logger_, "There is no navi application with id: " << app_id);
+ if (!app || (!app->is_navi() && !app->mobile_projection_enabled())) {
+ LOG4CXX_DEBUG(
+ logger_,
+ "There is no navi or projection application with id: " << app_id);
return;
}
- NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id);
- if (navi_service_status_.end() == it) {
- LOG4CXX_ERROR(logger_, "No info about navi servicies for app");
- return;
+ bool end_video = false;
+ bool end_audio = false;
+ {
+ sync_primitives::AutoLock lock(navi_service_status_lock_);
+
+ NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id);
+ if (navi_service_status_.end() == it) {
+ LOG4CXX_ERROR(logger_, "No info about navi servicies for app");
+ return;
+ }
+ end_video = it->second.first;
+ end_audio = it->second.second;
}
if (connection_handler_) {
- if (it->second.first) {
+ if (end_video) {
LOG4CXX_DEBUG(logger_, "Going to end video service");
connection_handler().SendEndService(app_id, ServiceType::kMobileNav);
app->StopStreamingForce(ServiceType::kMobileNav);
}
- if (it->second.second) {
+ if (end_audio) {
LOG4CXX_DEBUG(logger_, "Going to end audio service");
connection_handler().SendEndService(app_id, ServiceType::kAudio);
app->StopStreamingForce(ServiceType::kAudio);
@@ -3047,8 +3403,8 @@ void ApplicationManagerImpl::OnHMILevelChanged(
}
ApplicationSharedPtr app = application(app_id);
- if (!app || !app->is_navi()) {
- LOG4CXX_ERROR(logger_, "Navi application not found");
+ if (!app || (!app->is_navi() && !app->mobile_projection_enabled())) {
+ LOG4CXX_ERROR(logger_, "Navi/Projection application not found");
return;
}
@@ -3135,18 +3491,26 @@ void ApplicationManagerImpl::CloseNaviApp() {
uint32_t app_id = navi_app_to_stop_.front();
navi_app_to_stop_.pop_front();
- NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id);
- if (navi_service_status_.end() != it) {
- if (it->second.first || it->second.second) {
- LOG4CXX_INFO(logger_,
- "App haven't answered for EndService. Unregister it.");
- ManageMobileCommand(
- MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile(
- app_id, PROTOCOL_VIOLATION),
- commands::Command::ORIGIN_SDL);
- UnregisterApplication(app_id, ABORTED);
+ bool unregister = false;
+ {
+ sync_primitives::AutoLock lock(navi_service_status_lock_);
+
+ NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id);
+ if (navi_service_status_.end() != it) {
+ if (it->second.first || it->second.second) {
+ unregister = true;
+ }
}
}
+ if (unregister) {
+ LOG4CXX_INFO(logger_,
+ "App haven't answered for EndService. Unregister it.");
+ ManageMobileCommand(
+ MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile(
+ app_id, PROTOCOL_VIOLATION),
+ commands::Command::ORIGIN_SDL);
+ UnregisterApplication(app_id, ABORTED);
+ }
}
void ApplicationManagerImpl::EndNaviStreaming() {
@@ -3170,18 +3534,22 @@ void ApplicationManagerImpl::DisallowStreaming(uint32_t app_id) {
LOG4CXX_AUTO_TRACE(logger_);
ApplicationSharedPtr app = application(app_id);
- if (!app || !app->is_navi()) {
- LOG4CXX_ERROR(logger_, "Navi application not found");
+ if (!app || (!app->is_navi() && !app->mobile_projection_enabled())) {
+ LOG4CXX_ERROR(logger_, "Navi/Projection application not found");
return;
}
- NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id);
- if (navi_service_status_.end() != it) {
- if (it->second.first) {
- app->set_video_streaming_allowed(false);
- }
- if (it->second.second) {
- app->set_audio_streaming_allowed(false);
+ {
+ sync_primitives::AutoLock lock(navi_service_status_lock_);
+
+ NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id);
+ if (navi_service_status_.end() != it) {
+ if (it->second.first) {
+ app->set_video_streaming_allowed(false);
+ }
+ if (it->second.second) {
+ app->set_audio_streaming_allowed(false);
+ }
}
}
}
@@ -3191,18 +3559,22 @@ void ApplicationManagerImpl::AllowStreaming(uint32_t app_id) {
LOG4CXX_AUTO_TRACE(logger_);
ApplicationSharedPtr app = application(app_id);
- if (!app || !app->is_navi()) {
- LOG4CXX_ERROR(logger_, "Navi application not found");
+ if (!app || (!app->is_navi() && !app->mobile_projection_enabled())) {
+ LOG4CXX_ERROR(logger_, "Navi/Projection application not found");
return;
}
- NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id);
- if (navi_service_status_.end() != it) {
- if (it->second.first) {
- app->set_video_streaming_allowed(true);
- }
- if (it->second.second) {
- app->set_audio_streaming_allowed(true);
+ {
+ sync_primitives::AutoLock lock(navi_service_status_lock_);
+
+ NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id);
+ if (navi_service_status_.end() != it) {
+ if (it->second.first) {
+ app->set_video_streaming_allowed(true);
+ }
+ if (it->second.second) {
+ app->set_audio_streaming_allowed(true);
+ }
}
}
}
@@ -3496,24 +3868,21 @@ void ApplicationManagerImpl::OnUpdateHMIAppType(
}
}
-ProtocolVersion ApplicationManagerImpl::SupportedSDLVersion() const {
- LOG4CXX_AUTO_TRACE(logger_);
- bool heart_beat_support = get_settings().heart_beat_timeout();
- bool sdl4_support = protocol_handler_->get_settings().enable_protocol_4();
-
- if (sdl4_support) {
- LOG4CXX_DEBUG(logger_,
- "SDL Supported protocol version " << ProtocolVersion::kV4);
- return ProtocolVersion::kV4;
- }
- if (heart_beat_support) {
- LOG4CXX_DEBUG(logger_,
- "SDL Supported protocol version " << ProtocolVersion::kV3);
- return ProtocolVersion::kV3;
+void ApplicationManagerImpl::OnPTUFinished(const bool ptu_result) {
+#ifdef SDL_REMOTE_CONTROL
+ if (!ptu_result) {
+ return;
}
- LOG4CXX_DEBUG(logger_,
- "SDL Supported protocol version " << ProtocolVersion::kV2);
- return ProtocolVersion::kV2;
+ plugin_manager_.OnPolicyEvent(
+ functional_modules::PolicyEvent::kApplicationPolicyUpdated);
+#endif // SDL_REMOTE_CONTROL
+}
+
+protocol_handler::MajorProtocolVersion
+ApplicationManagerImpl::SupportedSDLVersion() const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ return static_cast<protocol_handler::MajorProtocolVersion>(
+ get_settings().max_supported_protocol_version());
}
event_engine::EventDispatcher& ApplicationManagerImpl::event_dispatcher() {
@@ -3612,4 +3981,189 @@ const std::set<int32_t> ApplicationManagerImpl::GetAppsSubscribedForWayPoints()
return subscribed_way_points_apps_list_;
}
+static hmi_apis::Common_VideoStreamingProtocol::eType ConvertVideoProtocol(
+ const char* str) {
+ if (strcmp(str, "RAW") == 0) {
+ return hmi_apis::Common_VideoStreamingProtocol::RAW;
+ } else if (strcmp(str, "RTP") == 0) {
+ return hmi_apis::Common_VideoStreamingProtocol::RTP;
+ } else if (strcmp(str, "RTSP") == 0) {
+ return hmi_apis::Common_VideoStreamingProtocol::RTSP;
+ } else if (strcmp(str, "RTMP") == 0) {
+ return hmi_apis::Common_VideoStreamingProtocol::RTMP;
+ } else if (strcmp(str, "WEBM") == 0) {
+ return hmi_apis::Common_VideoStreamingProtocol::WEBM;
+ }
+ return hmi_apis::Common_VideoStreamingProtocol::INVALID_ENUM;
+}
+
+static hmi_apis::Common_VideoStreamingCodec::eType ConvertVideoCodec(
+ const char* str) {
+ if (strcmp(str, "H264") == 0) {
+ return hmi_apis::Common_VideoStreamingCodec::H264;
+ } else if (strcmp(str, "H265") == 0) {
+ return hmi_apis::Common_VideoStreamingCodec::H265;
+ } else if (strcmp(str, "Theora") == 0) {
+ return hmi_apis::Common_VideoStreamingCodec::Theora;
+ } else if (strcmp(str, "VP8") == 0) {
+ return hmi_apis::Common_VideoStreamingCodec::VP8;
+ } else if (strcmp(str, "VP9") == 0) {
+ return hmi_apis::Common_VideoStreamingCodec::VP9;
+ }
+ return hmi_apis::Common_VideoStreamingCodec::INVALID_ENUM;
+}
+
+// static
+void ApplicationManagerImpl::ConvertVideoParamsToSO(
+ smart_objects::SmartObject& output, const BsonObject* input) {
+ if (input == NULL) {
+ return;
+ }
+ BsonObject* obj = const_cast<BsonObject*>(input);
+
+ const char* protocol =
+ bson_object_get_string(obj, protocol_handler::strings::video_protocol);
+ if (protocol != NULL) {
+ hmi_apis::Common_VideoStreamingProtocol::eType protocol_enum =
+ ConvertVideoProtocol(protocol);
+ if (protocol_enum !=
+ hmi_apis::Common_VideoStreamingProtocol::INVALID_ENUM) {
+ output[strings::protocol] = protocol_enum;
+ }
+ }
+ const char* codec =
+ bson_object_get_string(obj, protocol_handler::strings::video_codec);
+ if (codec != NULL) {
+ hmi_apis::Common_VideoStreamingCodec::eType codec_enum =
+ ConvertVideoCodec(codec);
+ if (codec_enum != hmi_apis::Common_VideoStreamingCodec::INVALID_ENUM) {
+ output[strings::codec] = codec_enum;
+ }
+ }
+ BsonElement* element =
+ bson_object_get(obj, protocol_handler::strings::height);
+ if (element != NULL && element->type == TYPE_INT32) {
+ output[strings::height] =
+ bson_object_get_int32(obj, protocol_handler::strings::height);
+ }
+ element = bson_object_get(obj, protocol_handler::strings::width);
+ if (element != NULL && element->type == TYPE_INT32) {
+ output[strings::width] =
+ bson_object_get_int32(obj, protocol_handler::strings::width);
+ }
+}
+
+// static
+std::vector<std::string> ApplicationManagerImpl::ConvertRejectedParamList(
+ const std::vector<std::string>& input) {
+ std::vector<std::string> output;
+ for (std::vector<std::string>::const_iterator it = input.begin();
+ it != input.end();
+ ++it) {
+ if (*it == strings::protocol) {
+ output.push_back(protocol_handler::strings::video_protocol);
+ } else if (*it == strings::codec) {
+ output.push_back(protocol_handler::strings::video_codec);
+ } else if (*it == strings::height) {
+ output.push_back(protocol_handler::strings::height);
+ } else if (*it == strings::width) {
+ output.push_back(protocol_handler::strings::width);
+ }
+ // ignore unknown parameters
+ }
+ return output;
+}
+
+#ifdef BUILD_TESTS
+void ApplicationManagerImpl::AddMockApplication(ApplicationSharedPtr mock_app) {
+ applications_list_lock_.Acquire();
+ applications_.insert(mock_app);
+ apps_size_ = applications_.size();
+ applications_list_lock_.Release();
+}
+#endif // BUILD_TESTS
+#ifdef SDL_REMOTE_CONTROL
+struct MobileAppIdPredicate {
+ std::string policy_app_id_;
+ MobileAppIdPredicate(const std::string& policy_app_id)
+ : policy_app_id_(policy_app_id) {}
+ bool operator()(const ApplicationSharedPtr app) const {
+ return app ? policy_app_id_ == app->policy_app_id() : false;
+ }
+};
+
+struct TakeDeviceHandle {
+ public:
+ TakeDeviceHandle(const ApplicationManager& app_mngr) : app_mngr_(app_mngr) {}
+ std::string operator()(ApplicationSharedPtr& app) {
+ DCHECK_OR_RETURN(app, "");
+ return MessageHelper::GetDeviceMacAddressForHandle(app->device(),
+ app_mngr_);
+ }
+
+ private:
+ const ApplicationManager& app_mngr_;
+};
+
+ApplicationSharedPtr ApplicationManagerImpl::application(
+ const std::string& device_id, const std::string& policy_app_id) const {
+ connection_handler::DeviceHandle device_handle;
+ if (!connection_handler().GetDeviceID(device_id, &device_handle)) {
+ LOG4CXX_DEBUG(logger_, "No such device : " << device_id);
+ return ApplicationSharedPtr();
+ }
+
+ DataAccessor<ApplicationSet> accessor = applications();
+ ApplicationSharedPtr app =
+ FindApp(accessor, IsApplication(device_handle, policy_app_id));
+
+ LOG4CXX_DEBUG(logger_,
+ " policy_app_id << " << policy_app_id << "Found = " << app);
+ return app;
+}
+
+std::vector<std::string> ApplicationManagerImpl::devices(
+ const std::string& policy_app_id) const {
+ MobileAppIdPredicate matcher(policy_app_id);
+ AppSharedPtrs apps = FindAllApps(applications(), matcher);
+ std::vector<std::string> devices;
+ std::transform(apps.begin(),
+ apps.end(),
+ std::back_inserter(devices),
+ TakeDeviceHandle(*this));
+ return devices;
+}
+
+void ApplicationManagerImpl::ChangeAppsHMILevel(
+ uint32_t app_id, mobile_apis::HMILevel::eType level) {
+ using namespace mobile_apis::HMILevel;
+ LOG4CXX_AUTO_TRACE(logger_);
+ LOG4CXX_DEBUG(logger_, "AppID to change: " << app_id << " -> " << level);
+ ApplicationSharedPtr app = application(app_id);
+ if (!app) {
+ LOG4CXX_ERROR(logger_, "There is no app with id: " << app_id);
+ return;
+ }
+ eType old_level = app->hmi_level();
+ if (old_level != level) {
+ app->set_hmi_level(level);
+ OnHMILevelChanged(app_id, old_level, level);
+
+ plugin_manager_.OnAppHMILevelChanged(app, old_level);
+ } else {
+ LOG4CXX_WARN(logger_, "Redudant changing HMI level : " << level);
+ }
+}
+
+void ApplicationManagerImpl::SendPostMessageToMobile(
+ const MessagePtr& message) {
+ messages_to_mobile_.PostMessage(impl::MessageToMobile(message, false));
+}
+
+void ApplicationManagerImpl::SendPostMessageToHMI(const MessagePtr& message) {
+ messages_to_hmi_.PostMessage(impl::MessageToHmi(message));
+}
+
+#endif // SDL_REMOTE_CONTROL
+
} // namespace application_manager
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 cea5412587..3f9a1d13b3 100644
--- a/src/components/application_manager/src/commands/command_request_impl.cc
+++ b/src/components/application_manager/src/commands/command_request_impl.cc
@@ -89,6 +89,9 @@ const std::string CreateInfoForUnsupportedResult(
case (HmiInterfaces::InterfaceID::HMI_INTERFACE_VehicleInfo): {
return "VehicleInfo is not supported by system";
}
+ case (HmiInterfaces::InterfaceID::HMI_INTERFACE_RC): {
+ return "Remote control is not supported by system";
+ }
default:
#ifdef ENABLE_LOG
CREATE_LOGGERPTR_LOCAL(logger, "Commands");
@@ -147,9 +150,13 @@ CommandRequestImpl::CommandRequestImpl(const MessageSharedPtr& message,
ApplicationManager& application_manager)
: CommandImpl(message, application_manager)
, EventObserver(application_manager.event_dispatcher())
- , current_state_(kAwaitingHMIResponse) {}
+ , current_state_(kAwaitingHMIResponse)
+ , hash_update_mode_(kSkipHashUpdate)
+ , is_success_result_(false) {}
-CommandRequestImpl::~CommandRequestImpl() {}
+CommandRequestImpl::~CommandRequestImpl() {
+ UpdateHash();
+}
bool CommandRequestImpl::Init() {
return true;
@@ -249,6 +256,8 @@ void CommandRequestImpl::SendResponse(
response[strings::msg_params][strings::success] = success;
response[strings::msg_params][strings::result_code] = result_code;
+ is_success_result_ = success;
+
application_manager_.ManageMobileCommand(result, ORIGIN_SDL);
}
@@ -308,6 +317,46 @@ bool CommandRequestImpl::ProcessHMIInterfacesAvailability(
return true;
}
+void CommandRequestImpl::UpdateHash() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (hash_update_mode_ == kSkipHashUpdate) {
+ LOG4CXX_DEBUG(logger_, "Hash update is disabled for " << function_id());
+ return;
+ }
+
+ if (HmiInterfaces::InterfaceState::STATE_NOT_RESPONSE ==
+ application_manager_.hmi_interfaces().GetInterfaceState(
+ HmiInterfaces::InterfaceID::HMI_INTERFACE_UI)) {
+ LOG4CXX_ERROR(logger_,
+ "UI interface has not responded. Hash won't be updated.");
+ return;
+ }
+
+ if (!is_success_result_) {
+ LOG4CXX_WARN(logger_, "Command is not succeeded. Hash won't be updated.");
+ return;
+ }
+
+ ApplicationSharedPtr application =
+ application_manager_.application(connection_key());
+ if (!application) {
+ LOG4CXX_ERROR(logger_,
+ "Application with connection key "
+ << connection_key()
+ << " not found. Not able to update hash.");
+ return;
+ }
+
+ LOG4CXX_DEBUG(
+ logger_,
+ "Updating hash for application with connection key "
+ << connection_key() << " while processing function id "
+ << MessageHelper::StringifiedFunctionID(
+ static_cast<mobile_api::FunctionID::eType>(function_id())));
+
+ application->UpdateHash();
+}
+
uint32_t CommandRequestImpl::SendHMIRequest(
const hmi_apis::FunctionID::eType& function_id,
const smart_objects::SmartObject* msg_params,
@@ -550,6 +599,44 @@ bool CommandRequestImpl::CheckAllowedParameters() {
return true;
}
+bool CommandRequestImpl::CheckHMICapabilities(
+ const mobile_apis::ButtonName::eType button) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ using namespace smart_objects;
+ using namespace mobile_apis;
+
+ const HMICapabilities& hmi_capabilities =
+ application_manager_.hmi_capabilities();
+ if (!hmi_capabilities.is_ui_cooperating()) {
+ LOG4CXX_ERROR(logger_, "UI is not supported by HMI");
+ return false;
+ }
+
+ const SmartObject* button_capabilities_so =
+ hmi_capabilities.button_capabilities();
+ if (!button_capabilities_so) {
+ LOG4CXX_ERROR(logger_, "Invalid button capabilities object");
+ return false;
+ }
+
+ const SmartObject& button_capabilities = *button_capabilities_so;
+ for (size_t i = 0; i < button_capabilities.length(); ++i) {
+ const SmartObject& capabilities = button_capabilities[i];
+ const ButtonName::eType current_button = static_cast<ButtonName::eType>(
+ capabilities.getElement(hmi_response::button_name).asInt());
+ if (current_button == button) {
+ LOG4CXX_DEBUG(logger_,
+ "Button capabilities for " << button << " was found");
+ return true;
+ }
+ }
+
+ LOG4CXX_DEBUG(logger_,
+ "Button capabilities for " << button << " was not found");
+ return false;
+}
+
void CommandRequestImpl::RemoveDisallowedParameters() {
LOG4CXX_AUTO_TRACE(logger_);
diff --git a/src/components/application_manager/src/commands/hmi/get_urls.cc b/src/components/application_manager/src/commands/hmi/get_urls.cc
index a2e1878fac..bfcdf4985e 100644
--- a/src/components/application_manager/src/commands/hmi/get_urls.cc
+++ b/src/components/application_manager/src/commands/hmi/get_urls.cc
@@ -34,6 +34,7 @@
#include "application_manager/message.h"
#include "application_manager/application_manager.h"
#include "application_manager/policies/policy_handler.h"
+#include "utils/helpers.h"
namespace application_manager {
namespace commands {
@@ -194,32 +195,25 @@ void GetUrls::ProcessPolicyServiceURLs(const policy::EndpointUrls& endpoints) {
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();
- std::string default_url = "URL is not found";
- // Will use only one URL for particular application if it will be found
- // Otherwise URL from default section will used
- SmartObject service_info = SmartObject(SmartType_Map);
-
- for (size_t e = 0; e < endpoints.size(); ++e) {
- if (mobile_app_id == endpoints[e].app_id) {
- if (endpoints[e].url.size()) {
- service_info[url] = endpoints[e].url[0];
- SendResponseToHMI(Common_Result::SUCCESS);
- return;
- }
- }
- if (policy::kDefaultId == endpoints[e].app_id) {
- if (endpoints[e].url.size()) {
- default_url = endpoints[e].url[0];
+ 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;
}
}
}
-
- service_info[strings::app_id] = app->app_id();
- service_info[strings::url] = default_url;
- urls[0] = service_info;
- // TODO(AOleynik): Issue with absent policy_app_id. Need to fix later on.
- // Possibly related to smart schema
SendResponseToHMI(Common_Result::SUCCESS);
return;
}
diff --git a/src/components/application_manager/src/commands/hmi/navi_set_video_config_request.cc b/src/components/application_manager/src/commands/hmi/navi_set_video_config_request.cc
new file mode 100644
index 0000000000..d19db515ab
--- /dev/null
+++ b/src/components/application_manager/src/commands/hmi/navi_set_video_config_request.cc
@@ -0,0 +1,147 @@
+/*
+ * Copyright (c) 2017 Xevo Inc.
+ * 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 names of the copyright holders 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/commands/hmi/navi_set_video_config_request.h"
+#include <string>
+#include <vector>
+
+namespace application_manager {
+
+namespace commands {
+
+NaviSetVideoConfigRequest::NaviSetVideoConfigRequest(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : RequestToHMI(message, application_manager)
+ , EventObserver(application_manager.event_dispatcher()) {}
+
+NaviSetVideoConfigRequest::~NaviSetVideoConfigRequest() {}
+
+void NaviSetVideoConfigRequest::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (!CheckAvailabilityHMIInterfaces(
+ application_manager_, HmiInterfaces::HMI_INTERFACE_Navigation)) {
+ LOG4CXX_WARN(logger_, "HMI interface Navigation is not supported");
+ return;
+ }
+
+ ApplicationSharedPtr app =
+ application_manager_.application_by_hmi_app(application_id());
+ if (!app) {
+ LOG4CXX_ERROR(logger_,
+ "Application with hmi_app_id " << application_id()
+ << "does not exist");
+ return;
+ }
+
+ subscribe_on_event(hmi_apis::FunctionID::Navigation_SetVideoConfig,
+ correlation_id());
+ SendRequest();
+}
+
+void NaviSetVideoConfigRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ ApplicationSharedPtr app =
+ application_manager_.application_by_hmi_app(application_id());
+ if (!app) {
+ LOG4CXX_ERROR(logger_,
+ "Application is not found, abort NaviSetVideoConfigRequest");
+ return;
+ }
+
+ const smart_objects::SmartObject& message = event.smart_object();
+ switch (event.id()) {
+ case hmi_apis::FunctionID::Navigation_SetVideoConfig: {
+ const hmi_apis::Common_Result::eType code =
+ static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+ bool result = false;
+ std::vector<std::string> rejected_params;
+
+ if (code == hmi_apis::Common_Result::SUCCESS) {
+ LOG4CXX_DEBUG(logger_, "Received SetVideoConfig success response");
+ result = true;
+ } else {
+ LOG4CXX_DEBUG(logger_,
+ "Received SetVideoConfig failure response (" << event.id()
+ << ")");
+ result = false;
+ if (message[strings::msg_params].keyExists(strings::rejected_params)) {
+ const smart_objects::SmartArray* list =
+ message[strings::msg_params][strings::rejected_params].asArray();
+ if (list != NULL) {
+ for (unsigned int i = 0; i < list->size(); i++) {
+ const std::string& param = (*list)[i].asString();
+ // Make sure that we actually sent the parameter in the request
+ if ((*message_)[strings::msg_params].keyExists(strings::config) &&
+ (*message_)[strings::msg_params][strings::config].keyExists(
+ param)) {
+ rejected_params.push_back(param);
+ }
+ }
+ }
+ }
+ }
+ application_manager_.OnStreamingConfigured(
+ app->app_id(),
+ protocol_handler::ServiceType::kMobileNav,
+ result,
+ rejected_params);
+ break;
+ }
+ default:
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
+ break;
+ }
+}
+
+void NaviSetVideoConfigRequest::onTimeOut() {
+ LOG4CXX_WARN(logger_, "Timed out while waiting for SetVideoConfig response");
+
+ ApplicationSharedPtr app =
+ application_manager_.application_by_hmi_app(application_id());
+ if (!app) {
+ LOG4CXX_ERROR(logger_, "Application is not found");
+ return;
+ }
+
+ std::vector<std::string> empty;
+ application_manager_.OnStreamingConfigured(
+ app->app_id(), protocol_handler::ServiceType::kMobileNav, false, empty);
+
+ application_manager_.TerminateRequest(
+ connection_key(), correlation_id(), function_id());
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/hmi/navi_set_video_config_response.cc b/src/components/application_manager/src/commands/hmi/navi_set_video_config_response.cc
new file mode 100644
index 0000000000..03679eb3b1
--- /dev/null
+++ b/src/components/application_manager/src/commands/hmi/navi_set_video_config_response.cc
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2017 Xevo Inc.
+ * 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 names of the copyright holders 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/commands/hmi/navi_set_video_config_response.h"
+#include "application_manager/event_engine/event.h"
+
+namespace application_manager {
+
+namespace commands {
+
+NaviSetVideoConfigResponse::NaviSetVideoConfigResponse(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : ResponseFromHMI(message, application_manager) {}
+
+NaviSetVideoConfigResponse::~NaviSetVideoConfigResponse() {}
+
+void NaviSetVideoConfigResponse::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ event_engine::Event event(hmi_apis::FunctionID::Navigation_SetVideoConfig);
+ event.set_smart_object(*message_);
+ event.raise(application_manager_.event_dispatcher());
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc b/src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc
index 0553fbba94..9f4c6e5b5d 100644
--- a/src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc
+++ b/src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc
@@ -37,6 +37,9 @@
#include "application_manager/message_helper.h"
#include "interfaces/MOBILE_API.h"
#include "interfaces/HMI_API.h"
+#ifdef SDL_REMOTE_CONTROL
+#include "functional_module/plugin_manager.h"
+#endif // SDL_REMOTE_CONTROL
namespace application_manager {
@@ -62,6 +65,11 @@ void OnExitApplicationNotification::Run() {
return;
}
+#ifdef SDL_REMOTE_CONTROL
+ application_manager_.GetPluginManager().OnApplicationEvent(
+ functional_modules::ApplicationEvent::kApplicationExit, app_id);
+#endif // SDL_REMOTE_CONTROL
+
Common_ApplicationExitReason::eType reason;
reason = static_cast<Common_ApplicationExitReason::eType>(
(*message_)[strings::msg_params][strings::reason].asInt());
diff --git a/src/components/application_manager/src/commands/hmi/rc_get_capabilities_request.cc b/src/components/application_manager/src/commands/hmi/rc_get_capabilities_request.cc
new file mode 100644
index 0000000000..32b296a3b9
--- /dev/null
+++ b/src/components/application_manager/src/commands/hmi/rc_get_capabilities_request.cc
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2013, 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/commands/hmi/rc_get_capabilities_request.h"
+
+namespace application_manager {
+
+namespace commands {
+
+RCGetCapabilitiesRequest::RCGetCapabilitiesRequest(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : RequestToHMI(message, application_manager) {}
+
+RCGetCapabilitiesRequest::~RCGetCapabilitiesRequest() {}
+
+void RCGetCapabilitiesRequest::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ SendRequest();
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/hmi/rc_get_capabilities_response.cc b/src/components/application_manager/src/commands/hmi/rc_get_capabilities_response.cc
new file mode 100644
index 0000000000..3ff6edd125
--- /dev/null
+++ b/src/components/application_manager/src/commands/hmi/rc_get_capabilities_response.cc
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2013, 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/commands/hmi/rc_get_capabilities_response.h"
+
+namespace application_manager {
+
+namespace commands {
+
+RCGetCapabilitiesResponse::RCGetCapabilitiesResponse(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : ResponseFromHMI(message, application_manager) {}
+
+RCGetCapabilitiesResponse::~RCGetCapabilitiesResponse() {}
+
+void RCGetCapabilitiesResponse::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ HMICapabilities& hmi_capabilities = application_manager_.hmi_capabilities();
+
+ hmi_capabilities.set_rc_capability(
+ (*message_)[strings::msg_params][strings::rc_capability]);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/hmi/rc_is_ready_request.cc b/src/components/application_manager/src/commands/hmi/rc_is_ready_request.cc
new file mode 100644
index 0000000000..71b803d198
--- /dev/null
+++ b/src/components/application_manager/src/commands/hmi/rc_is_ready_request.cc
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2013, 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/commands/hmi/rc_is_ready_request.h"
+
+namespace application_manager {
+
+namespace commands {
+
+RCIsReadyRequest::RCIsReadyRequest(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : RequestToHMI(message, application_manager)
+ , EventObserver(application_manager.event_dispatcher()) {}
+
+RCIsReadyRequest::~RCIsReadyRequest() {}
+
+void RCIsReadyRequest::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ subscribe_on_event(hmi_apis::FunctionID::RC_IsReady, correlation_id());
+ SendRequest();
+}
+
+void RCIsReadyRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ const smart_objects::SmartObject& message = event.smart_object();
+ switch (event.id()) {
+ case hmi_apis::FunctionID::RC_IsReady: {
+ LOG4CXX_DEBUG(logger_, "Received RC_IsReady event");
+ unsubscribe_from_event(hmi_apis::FunctionID::RC_IsReady);
+ const bool is_available = ChangeInterfaceState(
+ application_manager_, message, HmiInterfaces::HMI_INTERFACE_RC);
+
+ HMICapabilities& hmi_capabilities =
+ application_manager_.hmi_capabilities();
+ hmi_capabilities.set_is_rc_cooperating(is_available);
+ if (!CheckAvailabilityHMIInterfaces(application_manager_,
+ HmiInterfaces::HMI_INTERFACE_RC)) {
+ LOG4CXX_INFO(logger_,
+ "HmiInterfaces::HMI_INTERFACE_VR isn't available");
+ return;
+ }
+ SendMessageToHMI();
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
+ return;
+ }
+ }
+}
+
+void RCIsReadyRequest::onTimeOut() {
+ // Note(dtrunov): According to new requirment APPLINK-27956
+ SendMessageToHMI();
+}
+
+void RCIsReadyRequest::SendMessageToHMI() {
+ utils::SharedPtr<smart_objects::SmartObject> get_capabilities(
+ MessageHelper::CreateModuleInfoSO(
+ hmi_apis::FunctionID::RC_GetCapabilities, application_manager_));
+ application_manager_.ManageHMICommand(get_capabilities);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/hmi/rc_is_ready_response.cc b/src/components/application_manager/src/commands/hmi/rc_is_ready_response.cc
new file mode 100644
index 0000000000..6756b294f3
--- /dev/null
+++ b/src/components/application_manager/src/commands/hmi/rc_is_ready_response.cc
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2013, 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/commands/hmi/rc_is_ready_response.h"
+
+namespace application_manager {
+
+namespace commands {
+
+RCIsReadyResponse::RCIsReadyResponse(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : ResponseFromHMI(message, application_manager) {}
+
+RCIsReadyResponse::~RCIsReadyResponse() {}
+
+void RCIsReadyResponse::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ event_engine::Event event(hmi_apis::FunctionID::RC_IsReady);
+ event.set_smart_object(*message_);
+ event.raise(application_manager_.event_dispatcher());
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/hmi/sdl_activate_app_request.cc b/src/components/application_manager/src/commands/hmi/sdl_activate_app_request.cc
index 3a5a8d25f9..6961c15f76 100644
--- a/src/components/application_manager/src/commands/hmi/sdl_activate_app_request.cc
+++ b/src/components/application_manager/src/commands/hmi/sdl_activate_app_request.cc
@@ -46,7 +46,10 @@ struct ProtoV4AppsOnDevice : std::unary_function<ApplicationSharedPtr, bool> {
bool operator()(const ApplicationSharedPtr app) const {
return app
? handle_ == app->device() &&
- ProtocolVersion::kV4 == app->protocol_version()
+ Message::is_sufficient_version(
+ protocol_handler::MajorProtocolVersion::
+ PROTOCOL_VERSION_4,
+ app->protocol_version())
: false;
}
};
diff --git a/src/components/application_manager/src/commands/hmi/ui_get_capabilities_response.cc b/src/components/application_manager/src/commands/hmi/ui_get_capabilities_response.cc
index de0a2f2157..3b5aeac639 100644
--- a/src/components/application_manager/src/commands/hmi/ui_get_capabilities_response.cc
+++ b/src/components/application_manager/src/commands/hmi/ui_get_capabilities_response.cc
@@ -78,6 +78,32 @@ void UIGetCapabilitiesResponse::Run() {
hmi_capabilities.set_phone_call_supported(
msg_params[strings::hmi_capabilities][strings::phone_call].asBool());
}
+ if (msg_params[strings::hmi_capabilities].keyExists(
+ strings::video_streaming)) {
+ hmi_capabilities.set_video_streaming_supported(
+ msg_params[strings::hmi_capabilities][strings::video_streaming]
+ .asBool());
+ }
+ }
+
+ if (msg_params.keyExists(strings::system_capabilities)) {
+ if (msg_params[strings::system_capabilities].keyExists(
+ strings::navigation_capability)) {
+ hmi_capabilities.set_navigation_capability(
+ msg_params[strings::system_capabilities]
+ [strings::navigation_capability]);
+ }
+ if (msg_params[strings::system_capabilities].keyExists(
+ strings::phone_capability)) {
+ hmi_capabilities.set_phone_capability(
+ msg_params[strings::system_capabilities][strings::phone_capability]);
+ }
+ if (msg_params[strings::system_capabilities].keyExists(
+ strings::video_streaming_capability)) {
+ hmi_capabilities.set_video_streaming_capability(
+ msg_params[strings::system_capabilities]
+ [strings::video_streaming_capability]);
+ }
}
}
diff --git a/src/components/application_manager/src/commands/hmi/ui_send_haptic_data_request.cc b/src/components/application_manager/src/commands/hmi/ui_send_haptic_data_request.cc
new file mode 100644
index 0000000000..9484906a17
--- /dev/null
+++ b/src/components/application_manager/src/commands/hmi/ui_send_haptic_data_request.cc
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2017 Xevo Inc.
+ * 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 Xevo Inc. 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/commands/hmi/ui_send_haptic_data_request.h"
+
+namespace application_manager {
+
+namespace commands {
+
+UISendHapticDataRequest::UISendHapticDataRequest(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : RequestToHMI(message, application_manager) {}
+
+UISendHapticDataRequest::~UISendHapticDataRequest() {}
+
+void UISendHapticDataRequest::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ SendRequest();
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/hmi/ui_send_haptic_data_response.cc b/src/components/application_manager/src/commands/hmi/ui_send_haptic_data_response.cc
new file mode 100644
index 0000000000..a8239a40e8
--- /dev/null
+++ b/src/components/application_manager/src/commands/hmi/ui_send_haptic_data_response.cc
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2017 Xevo Inc.
+ * 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 Xevo Inc. 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/commands/hmi/ui_send_haptic_data_response.h"
+#include "application_manager/event_engine/event.h"
+
+#include "interfaces/HMI_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+UISendHapticDataResponse::UISendHapticDataResponse(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : ResponseFromHMI(message, application_manager) {}
+
+UISendHapticDataResponse::~UISendHapticDataResponse() {}
+
+void UISendHapticDataResponse::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ event_engine::Event event(hmi_apis::FunctionID::UI_SendHapticData);
+ event.set_smart_object(*message_);
+ event.raise(application_manager_.event_dispatcher());
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/mobile/add_command_request.cc b/src/components/application_manager/src/commands/mobile/add_command_request.cc
index a76f537a24..c748ddcbb6 100644
--- a/src/components/application_manager/src/commands/mobile/add_command_request.cc
+++ b/src/components/application_manager/src/commands/mobile/add_command_request.cc
@@ -64,6 +64,11 @@ void AddCommandRequest::onTimeOut() {
CommandRequestImpl::onTimeOut();
}
+bool AddCommandRequest::Init() {
+ hash_update_mode_ = HashUpdateMode::kDoHashUpdate;
+ return true;
+}
+
void AddCommandRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
@@ -492,10 +497,6 @@ void AddCommandRequest::on_event(const event_engine::Event& event) {
result_code,
info.empty() ? NULL : info.c_str(),
&(message[strings::msg_params]));
-
- if (result) {
- application->UpdateHash();
- }
}
bool AddCommandRequest::IsPendingResponseExist() {
diff --git a/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc b/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc
index 6838d1af7d..a5491481dc 100644
--- a/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc
+++ b/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc
@@ -128,9 +128,6 @@ void AddSubMenuRequest::on_event(const event_engine::Event& event) {
MessageHelper::HMIToMobileResult(result_code),
response_info.empty() ? NULL : response_info.c_str(),
&(message[strings::msg_params]));
- if (result) {
- application->UpdateHash();
- }
break;
}
default: {
@@ -140,6 +137,11 @@ void AddSubMenuRequest::on_event(const event_engine::Event& event) {
}
}
+bool AddSubMenuRequest::Init() {
+ hash_update_mode_ = HashUpdateMode::kDoHashUpdate;
+ return true;
+}
+
bool AddSubMenuRequest::CheckSubMenuName() {
LOG4CXX_AUTO_TRACE(logger_);
const char* str = NULL;
diff --git a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc
index 8876ffa2e8..e1148bd126 100644
--- a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc
+++ b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc
@@ -49,9 +49,11 @@ namespace commands {
CreateInteractionChoiceSetRequest::CreateInteractionChoiceSetRequest(
const MessageSharedPtr& message, ApplicationManager& application_manager)
: CommandRequestImpl(message, application_manager)
+ , choice_set_id_(0)
, expected_chs_count_(0)
, received_chs_count_(0)
, error_from_hmi_(false)
+ , is_timed_out_(false)
, vr_commands_lock_(true) {}
CreateInteractionChoiceSetRequest::~CreateInteractionChoiceSetRequest() {
@@ -384,6 +386,11 @@ void CreateInteractionChoiceSetRequest::onTimeOut() {
connection_key(), correlation_id(), function_id());
}
+bool CreateInteractionChoiceSetRequest::Init() {
+ hash_update_mode_ = HashUpdateMode::kDoHashUpdate;
+ return true;
+}
+
void CreateInteractionChoiceSetRequest::DeleteChoices() {
LOG4CXX_AUTO_TRACE(logger_);
@@ -419,14 +426,6 @@ void CreateInteractionChoiceSetRequest::OnAllHMIResponsesReceived() {
if (!error_from_hmi_) {
SendResponse(true, mobile_apis::Result::SUCCESS);
-
- ApplicationSharedPtr application =
- application_manager_.application(connection_key());
- if (!application) {
- LOG4CXX_ERROR(logger_, "NULL pointer");
- return;
- }
- application->UpdateHash();
} else {
DeleteChoices();
}
diff --git a/src/components/application_manager/src/commands/mobile/delete_command_request.cc b/src/components/application_manager/src/commands/mobile/delete_command_request.cc
index 103e87fa00..cfc8e12144 100644
--- a/src/components/application_manager/src/commands/mobile/delete_command_request.cc
+++ b/src/components/application_manager/src/commands/mobile/delete_command_request.cc
@@ -201,9 +201,11 @@ void DeleteCommandRequest::on_event(const event_engine::Event& event) {
}
SendResponse(
result, result_code, info.empty() ? NULL : info.c_str(), &msg_params);
- if (result) {
- application->UpdateHash();
- }
+}
+
+bool DeleteCommandRequest::Init() {
+ hash_update_mode_ = HashUpdateMode::kDoHashUpdate;
+ return true;
}
bool DeleteCommandRequest::IsPendingResponseExist() {
diff --git a/src/components/application_manager/src/commands/mobile/delete_file_request.cc b/src/components/application_manager/src/commands/mobile/delete_file_request.cc
index 31ca29cb51..984c7a1725 100644
--- a/src/components/application_manager/src/commands/mobile/delete_file_request.cc
+++ b/src/components/application_manager/src/commands/mobile/delete_file_request.cc
@@ -73,6 +73,13 @@ void DeleteFileRequest::Run() {
const std::string& sync_file_name =
(*message_)[strings::msg_params][strings::sync_file_name].asString();
+ if (!file_system::IsFileNameValid(sync_file_name)) {
+ const std::string err_msg = "Sync file name contains forbidden symbols.";
+ LOG4CXX_ERROR(logger_, err_msg);
+ SendResponse(false, mobile_apis::Result::INVALID_DATA, err_msg.c_str());
+ return;
+ }
+
std::string full_file_path =
application_manager_.get_settings().app_storage_folder() + "/";
full_file_path += application->folder_name();
diff --git a/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_request.cc b/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_request.cc
index 6ef8e5d9da..bfbb2429ac 100644
--- a/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_request.cc
+++ b/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_request.cc
@@ -90,9 +90,11 @@ void DeleteInteractionChoiceSetRequest::Run() {
// Checking of HMI responses will be implemented with APPLINK-14600
const bool result = true;
SendResponse(result, mobile_apis::Result::SUCCESS);
- if (result) {
- app->UpdateHash();
- }
+}
+
+bool DeleteInteractionChoiceSetRequest::Init() {
+ hash_update_mode_ = HashUpdateMode::kDoHashUpdate;
+ return true;
}
bool DeleteInteractionChoiceSetRequest::ChoiceSetInUse(
diff --git a/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc b/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc
index 57748e6feb..21c7ecce90 100644
--- a/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc
+++ b/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc
@@ -171,9 +171,6 @@ void DeleteSubMenuRequest::on_event(const event_engine::Event& event) {
MessageHelper::HMIToMobileResult(result_code),
response_info.empty() ? NULL : response_info.c_str(),
&(message[strings::msg_params]));
- if (result) {
- application->UpdateHash();
- }
break;
}
default: {
@@ -183,6 +180,11 @@ void DeleteSubMenuRequest::on_event(const event_engine::Event& event) {
}
}
+bool DeleteSubMenuRequest::Init() {
+ hash_update_mode_ = HashUpdateMode::kDoHashUpdate;
+ return true;
+}
+
} // namespace commands
} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/mobile/get_system_capability_request.cc b/src/components/application_manager/src/commands/mobile/get_system_capability_request.cc
new file mode 100644
index 0000000000..d19e2ecbb0
--- /dev/null
+++ b/src/components/application_manager/src/commands/mobile/get_system_capability_request.cc
@@ -0,0 +1,98 @@
+#include "application_manager/commands/mobile/get_system_capability_request.h"
+
+namespace application_manager {
+
+namespace commands {
+
+GetSystemCapabilityRequest::GetSystemCapabilityRequest(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager) {}
+
+GetSystemCapabilityRequest::~GetSystemCapabilityRequest() {}
+
+void GetSystemCapabilityRequest::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
+
+ if (!app) {
+ LOG4CXX_ERROR(logger_, "Application is not registered");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+
+ if ((*message_)[strings::msg_params].empty()) {
+ LOG4CXX_ERROR(logger_, strings::msg_params << " is empty.");
+ SendResponse(false, mobile_apis::Result::INVALID_DATA);
+ return;
+ }
+ smart_objects::SmartObject response_params(smart_objects::SmartType_Map);
+ mobile_apis::SystemCapabilityType::eType response_type =
+ static_cast<mobile_apis::SystemCapabilityType::eType>(
+ (*message_)[strings::msg_params][strings::system_capability_type]
+ .asInt());
+ response_params[strings::system_capability][strings::system_capability_type] =
+ response_type;
+
+ const HMICapabilities& hmi_capabilities =
+ application_manager_.hmi_capabilities();
+
+ switch (response_type) {
+ case mobile_apis::SystemCapabilityType::NAVIGATION: {
+ if (hmi_capabilities.navigation_capability()) {
+ response_params[strings::system_capability]
+ [strings::navigation_capability] =
+ *hmi_capabilities.navigation_capability();
+ } else {
+ SendResponse(false, mobile_apis::Result::DATA_NOT_AVAILABLE);
+ return;
+ }
+ break;
+ }
+ case mobile_apis::SystemCapabilityType::PHONE_CALL: {
+ if (hmi_capabilities.phone_capability()) {
+ response_params[strings::system_capability][strings::phone_capability] =
+ *hmi_capabilities.phone_capability();
+ } else {
+ SendResponse(false, mobile_apis::Result::DATA_NOT_AVAILABLE);
+ return;
+ }
+ break;
+ }
+ case mobile_apis::SystemCapabilityType::REMOTE_CONTROL: {
+ if (hmi_capabilities.rc_capability()) {
+ response_params[strings::system_capability][strings::rc_capability] =
+ *hmi_capabilities.rc_capability();
+ } else {
+ SendResponse(false, mobile_apis::Result::DATA_NOT_AVAILABLE);
+ return;
+ }
+ break;
+ }
+ case mobile_apis::SystemCapabilityType::VIDEO_STREAMING:
+ if (hmi_capabilities.video_streaming_capability()) {
+ response_params[strings::system_capability]
+ [strings::video_streaming_capability] =
+ *hmi_capabilities.video_streaming_capability();
+ } else {
+ SendResponse(false, mobile_apis::Result::DATA_NOT_AVAILABLE);
+ return;
+ }
+ break;
+ case mobile_apis::SystemCapabilityType::AUDIO_STREAMING:
+ SendResponse(false, mobile_apis::Result::UNSUPPORTED_RESOURCE);
+ return;
+ default: // Return unsupported resource
+ SendResponse(false, mobile_apis::Result::UNSUPPORTED_RESOURCE);
+ return;
+ }
+ SendResponse(true, mobile_apis::Result::SUCCESS, NULL, &response_params);
+}
+
+void GetSystemCapabilityRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_INFO(logger_, "GetSystemCapabilityRequest on_event");
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/mobile/get_system_capability_response.cc b/src/components/application_manager/src/commands/mobile/get_system_capability_response.cc
new file mode 100644
index 0000000000..91c2562cd3
--- /dev/null
+++ b/src/components/application_manager/src/commands/mobile/get_system_capability_response.cc
@@ -0,0 +1,22 @@
+#include "application_manager/application_manager.h"
+#include "application_manager/commands/mobile/get_system_capability_response.h"
+
+namespace application_manager {
+
+namespace commands {
+
+GetSystemCapabilityResponse::GetSystemCapabilityResponse(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
+
+GetSystemCapabilityResponse::~GetSystemCapabilityResponse() {}
+
+void GetSystemCapabilityResponse::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ application_manager_.SendMessageToMobile(message_);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/mobile/get_way_points_request.cc b/src/components/application_manager/src/commands/mobile/get_way_points_request.cc
index 198964a333..c313d74d4b 100644
--- a/src/components/application_manager/src/commands/mobile/get_way_points_request.cc
+++ b/src/components/application_manager/src/commands/mobile/get_way_points_request.cc
@@ -8,7 +8,9 @@ namespace commands {
GetWayPointsRequest::GetWayPointsRequest(
const MessageSharedPtr& message, ApplicationManager& application_manager)
- : CommandRequestImpl(message, application_manager) {}
+ : CommandRequestImpl(message, application_manager) {
+ subscribe_on_event(hmi_apis::FunctionID::UI_OnResetTimeout);
+}
GetWayPointsRequest::~GetWayPointsRequest() {}
@@ -38,6 +40,12 @@ void GetWayPointsRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
const smart_objects::SmartObject& message = event.smart_object();
switch (event.id()) {
+ case hmi_apis::FunctionID::UI_OnResetTimeout: {
+ LOG4CXX_INFO(logger_, "Received UI_OnResetTimeout event");
+ application_manager_.updateRequestTimeout(
+ connection_key(), correlation_id(), default_timeout());
+ break;
+ }
case hmi_apis::FunctionID::Navigation_GetWayPoints: {
LOG4CXX_INFO(logger_, "Received Navigation_GetWayPoints event");
const hmi_apis::Common_Result::eType result_code =
diff --git a/src/components/application_manager/src/commands/mobile/list_files_request.cc b/src/components/application_manager/src/commands/mobile/list_files_request.cc
index 425f1ddb46..794fba631d 100644
--- a/src/components/application_manager/src/commands/mobile/list_files_request.cc
+++ b/src/components/application_manager/src/commands/mobile/list_files_request.cc
@@ -76,22 +76,21 @@ void ListFilesRequest::Run() {
(*message_)[strings::msg_params][strings::space_available] =
static_cast<int32_t>(application->GetAvailableDiskSpace());
+ // Enumarating through File system
uint32_t i = 0;
- const AppFilesMap& app_files = application->getAppFiles();
- for (AppFilesMap::const_iterator it = app_files.begin();
- it != app_files.end();
- ++it) {
- std::string filename = it->first.substr(it->first.find_last_of('/') + 1);
- // In AppFile to application stored full path to file. In message required
- // to write only name file.
- // Plus one required for move to next letter after '/'.
+ std::string directory_name =
+ application_manager_.get_settings().app_storage_folder();
+ directory_name += "/" + application->folder_name();
+ std::vector<std::string> persistent_files =
+ file_system::ListFiles(directory_name);
+ std::vector<std::string>::const_iterator it = persistent_files.begin();
+ for (; it != persistent_files.end(); ++it) {
if (i < application_manager_.get_settings().list_files_response_size()) {
- LOG4CXX_DEBUG(logger_,
- "File " + filename + " added to ListFiles response");
- (*message_)[strings::msg_params][strings::filenames][i++] = filename;
+ LOG4CXX_DEBUG(logger_, "File " + *it + " added to ListFiles response");
+ (*message_)[strings::msg_params][strings::filenames][i++] = *it;
} else {
LOG4CXX_DEBUG(logger_,
- "File " + filename + " not added to ListFiles response");
+ "File " + *it + " not added to ListFiles response");
}
}
(*message_)[strings::params][strings::message_type] =
diff --git a/src/components/application_manager/src/commands/mobile/on_hmi_status_notification_from_mobile.cc b/src/components/application_manager/src/commands/mobile/on_hmi_status_notification_from_mobile.cc
index 9b16bd3572..4bb6cfe9d5 100644
--- a/src/components/application_manager/src/commands/mobile/on_hmi_status_notification_from_mobile.cc
+++ b/src/components/application_manager/src/commands/mobile/on_hmi_status_notification_from_mobile.cc
@@ -75,10 +75,13 @@ void OnHMIStatusNotificationFromMobile::Run() {
<< connection_key() << " and handle: " << handle);
if (!is_apps_requested_before &&
- ProtocolVersion::kV4 == app->protocol_version() && app->is_foreground()) {
+ Message::is_sufficient_version(
+ protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_4,
+ app->protocol_version()) &&
+ app->is_foreground()) {
// In case this notification will be received from mobile side with
// foreground level for app on mobile, this should trigger remote
- // apps list query for SDL 4.0 app
+ // apps list query for SDL 4.0+ app
MessageHelper::SendQueryApps(connection_key(), application_manager_);
return;
}
@@ -89,7 +92,9 @@ void OnHMIStatusNotificationFromMobile::Run() {
" for handle: "
<< handle);
- if (ProtocolVersion::kV4 == app->protocol_version()) {
+ if (Message::is_sufficient_version(
+ protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_4,
+ app->protocol_version())) {
const ApplicationSet& accessor =
application_manager_.applications().GetData();
@@ -97,7 +102,9 @@ void OnHMIStatusNotificationFromMobile::Run() {
ApplicationSetConstIt it = accessor.begin();
for (; accessor.end() != it; ++it) {
if (connection_key() != (*it)->app_id() &&
- ProtocolVersion::kV4 == (*it)->protocol_version() &&
+ Message::is_sufficient_version(
+ protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_4,
+ (*it)->protocol_version()) &&
(*it)->is_foreground()) {
is_another_foreground_sdl4_app = true;
break;
diff --git a/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc b/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc
index a17c76d9c1..c29ff3e2d3 100644
--- a/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc
+++ b/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc
@@ -99,6 +99,10 @@ void OnSystemRequestNotification::Run() {
(*message_)[strings::msg_params][strings::file_type] = FileType::JSON;
} else if (RequestType::HTTP == request_type) {
(*message_)[strings::msg_params][strings::file_type] = FileType::BINARY;
+ if ((*message_)[strings::msg_params].keyExists(strings::url)) {
+ (*message_)[strings::msg_params][strings::timeout] =
+ policy_handler.TimeoutExchangeSec();
+ }
}
SendNotification();
diff --git a/src/components/application_manager/src/commands/mobile/on_touch_event_notification.cc b/src/components/application_manager/src/commands/mobile/on_touch_event_notification.cc
index c769194c95..2a9969eac4 100644
--- a/src/components/application_manager/src/commands/mobile/on_touch_event_notification.cc
+++ b/src/components/application_manager/src/commands/mobile/on_touch_event_notification.cc
@@ -50,17 +50,34 @@ OnTouchEventNotification::~OnTouchEventNotification() {}
void OnTouchEventNotification::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- const std::vector<ApplicationSharedPtr>& applications =
+ const std::vector<ApplicationSharedPtr>& applications_with_navi =
application_manager_.applications_with_navi();
- std::vector<ApplicationSharedPtr>::const_iterator it = applications.begin();
- for (; applications.end() != it; ++it) {
- ApplicationSharedPtr app = *it;
+ const std::vector<ApplicationSharedPtr>& projection_applications =
+ application_manager_.applications_with_mobile_projection();
+
+ std::vector<ApplicationSharedPtr>::const_iterator nav_it =
+ applications_with_navi.begin();
+
+ for (; applications_with_navi.end() != nav_it; ++nav_it) {
+ ApplicationSharedPtr app = *nav_it;
if (app->IsFullscreen()) {
(*message_)[strings::params][strings::connection_key] = app->app_id();
SendNotification();
}
}
+
+ std::vector<ApplicationSharedPtr>::const_iterator projection_it =
+ projection_applications.begin();
+
+ for (; projection_applications.end() != projection_it; ++projection_it) {
+ ApplicationSharedPtr projection_app = *projection_it;
+ if (projection_app->IsFullscreen()) {
+ (*message_)[strings::params][strings::connection_key] =
+ projection_app->app_id();
+ SendNotification();
+ }
+ }
}
} // namespace mobile
diff --git a/src/components/application_manager/src/commands/mobile/put_file_request.cc b/src/components/application_manager/src/commands/mobile/put_file_request.cc
index 68e7ad60d1..602b420ba0 100644
--- a/src/components/application_manager/src/commands/mobile/put_file_request.cc
+++ b/src/components/application_manager/src/commands/mobile/put_file_request.cc
@@ -110,6 +110,17 @@ void PutFileRequest::Run() {
}
sync_file_name_ =
(*message_)[strings::msg_params][strings::sync_file_name].asString();
+
+ if (!file_system::IsFileNameValid(sync_file_name_)) {
+ const std::string err_msg = "Sync file name contains forbidden symbols.";
+ LOG4CXX_ERROR(logger_, err_msg);
+ SendResponse(false,
+ mobile_apis::Result::INVALID_DATA,
+ err_msg.c_str(),
+ &response_params);
+ return;
+ }
+
file_type_ = static_cast<mobile_apis::FileType::eType>(
(*message_)[strings::msg_params][strings::file_type].asInt());
const std::vector<uint8_t> binary_data =
diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc
index 413aa1f669..74bc0c032e 100644
--- a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc
+++ b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc
@@ -74,6 +74,12 @@ mobile_apis::AppHMIType::eType StringToAppHMIType(const std::string& str) {
return mobile_apis::AppHMIType::TESTING;
} else if ("SYSTEM" == str) {
return mobile_apis::AppHMIType::SYSTEM;
+ } else if ("PROJECTION" == str) {
+ return mobile_apis::AppHMIType::PROJECTION;
+#ifdef SDL_REMOTE_CONTROL
+ } else if ("REMOTE_CONTROL" == str) {
+ return mobile_apis::AppHMIType::REMOTE_CONTROL;
+#endif
} else {
return mobile_apis::AppHMIType::INVALID_ENUM;
}
@@ -82,6 +88,9 @@ mobile_apis::AppHMIType::eType StringToAppHMIType(const std::string& str) {
std::string AppHMITypeToString(mobile_apis::AppHMIType::eType type) {
const std::map<mobile_apis::AppHMIType::eType, std::string> app_hmi_type_map =
{{mobile_apis::AppHMIType::DEFAULT, "DEFAULT"},
+#ifdef SDL_REMOTE_CONTROL
+ {mobile_apis::AppHMIType::REMOTE_CONTROL, "REMOTE_CONTROL"},
+#endif // SDL_REMOTE_CONTROL
{mobile_apis::AppHMIType::COMMUNICATION, "COMMUNICATION"},
{mobile_apis::AppHMIType::MEDIA, "MEDIA"},
{mobile_apis::AppHMIType::MESSAGING, "MESSAGING"},
@@ -90,7 +99,8 @@ std::string AppHMITypeToString(mobile_apis::AppHMIType::eType type) {
{mobile_apis::AppHMIType::SOCIAL, "SOCIAL"},
{mobile_apis::AppHMIType::BACKGROUND_PROCESS, "BACKGROUND_PROCESS"},
{mobile_apis::AppHMIType::TESTING, "TESTING"},
- {mobile_apis::AppHMIType::SYSTEM, "SYSTEM"}};
+ {mobile_apis::AppHMIType::SYSTEM, "SYSTEM"},
+ {mobile_apis::AppHMIType::PROJECTION, "PROJECTION"}};
std::map<mobile_apis::AppHMIType::eType, std::string>::const_iterator iter =
app_hmi_type_map.find(type);
@@ -319,6 +329,11 @@ void RegisterAppInterfaceRequest::Run() {
app_type.getElement(i).asUInt())) {
application->set_voice_communication_supported(true);
}
+ if (mobile_apis::AppHMIType::PROJECTION ==
+ static_cast<mobile_apis::AppHMIType::eType>(
+ app_type.getElement(i).asUInt())) {
+ application->set_mobile_projection_enabled(true);
+ }
}
}
@@ -477,6 +492,8 @@ void FillUIRelatedFields(smart_objects::SmartObject& response_params,
hmi_capabilities.navigation_supported();
response_params[strings::hmi_capabilities][strings::phone_call] =
hmi_capabilities.phone_call_supported();
+ response_params[strings::hmi_capabilities][strings::video_streaming] =
+ hmi_capabilities.video_streaming_supported();
}
void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() {
@@ -663,6 +680,12 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() {
SendResponse(true, result_code, add_info.c_str(), &response_params);
SendOnAppRegisteredNotificationToHMI(
*(application.get()), resumption, need_restore_vr);
+#ifdef SDL_REMOTE_CONTROL
+ if (msg_params.keyExists(strings::app_hmi_type)) {
+ GetPolicyHandler().SetDefaultHmiTypes(application->policy_app_id(),
+ &(msg_params[strings::app_hmi_type]));
+ }
+#endif // SDL_REMOTE_CONTROL
// Default HMI level should be set before any permissions validation, since it
// relies on HMI level.
diff --git a/src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc b/src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc
index ebc0e43838..713d50e190 100644
--- a/src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc
+++ b/src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc
@@ -242,9 +242,6 @@ void ResetGlobalPropertiesRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
const smart_objects::SmartObject& message = event.smart_object();
- ApplicationSharedPtr application =
- application_manager_.application(connection_key());
-
switch (event.id()) {
case hmi_apis::FunctionID::UI_SetGlobalProperties: {
LOG4CXX_INFO(logger_, "Received UI_SetGlobalProperties event");
@@ -281,15 +278,11 @@ void ResetGlobalPropertiesRequest::on_event(const event_engine::Event& event) {
static_cast<mobile_apis::Result::eType>(result_code),
response_info.empty() ? NULL : response_info.c_str(),
&(message[strings::msg_params]));
+}
- if (!application) {
- LOG4CXX_ERROR(logger_, "NULL pointer");
- return;
- }
-
- if (result) {
- application->UpdateHash();
- }
+bool ResetGlobalPropertiesRequest::Init() {
+ hash_update_mode_ = HashUpdateMode::kDoHashUpdate;
+ return true;
}
bool ResetGlobalPropertiesRequest::PrepareResponseParameters(
@@ -312,8 +305,7 @@ bool ResetGlobalPropertiesRequest::PrepareResponseParameters(
HmiInterfaces::STATE_AVAILABLE == tts_interface_state) {
result = true;
out_result_code = mobile_apis::Result::WARNINGS;
- out_response_info =
- std::string("Unsupported phoneme type sent in a prompt").c_str();
+ out_response_info = "Unsupported phoneme type sent in a prompt";
} else {
result =
PrepareResultForMobileResponse(ui_properties_info, tts_properties_info);
diff --git a/src/components/application_manager/src/commands/mobile/send_haptic_data_request.cc b/src/components/application_manager/src/commands/mobile/send_haptic_data_request.cc
new file mode 100644
index 0000000000..cabfef15f6
--- /dev/null
+++ b/src/components/application_manager/src/commands/mobile/send_haptic_data_request.cc
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2017 Xevo Inc.
+ * 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 Xevo Inc. 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/commands/mobile/send_haptic_data_request.h"
+#include "interfaces/MOBILE_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+namespace custom_str = utils::custom_string;
+
+SendHapticDataRequest::SendHapticDataRequest(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager) {}
+
+SendHapticDataRequest::~SendHapticDataRequest() {}
+
+void SendHapticDataRequest::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params];
+ SendHMIRequest(hmi_apis::FunctionID::UI_SendHapticData, &msg_params, true);
+}
+
+void SendHapticDataRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ using namespace helpers;
+
+ const smart_objects::SmartObject& message = event.smart_object();
+
+ switch (event.id()) {
+ case hmi_apis::FunctionID::UI_SendHapticData: {
+ mobile_apis::Result::eType result_code =
+ GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asUInt()));
+
+ const bool result = Compare<mobile_api::Result::eType, EQ, ONE>(
+ result_code,
+ mobile_api::Result::SUCCESS,
+ mobile_api::Result::WARNINGS);
+
+ SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
+ return;
+ }
+ }
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/mobile/send_haptic_data_response.cc b/src/components/application_manager/src/commands/mobile/send_haptic_data_response.cc
new file mode 100644
index 0000000000..c8649d34af
--- /dev/null
+++ b/src/components/application_manager/src/commands/mobile/send_haptic_data_response.cc
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2017 Xevo Inc.
+ * 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 Xevo Inc. 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/commands/mobile/send_haptic_data_response.h"
+
+namespace application_manager {
+
+namespace commands {
+
+SendHapticDataResponse::SendHapticDataResponse(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
+
+SendHapticDataResponse::~SendHapticDataResponse() {}
+
+void SendHapticDataResponse::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ application_manager_.SendMessageToMobile(message_);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc b/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc
index 5d70a2fb5b..5afddfb4d0 100644
--- a/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc
+++ b/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc
@@ -71,6 +71,13 @@ void SetAppIconRequest::Run() {
const std::string& sync_file_name =
(*message_)[strings::msg_params][strings::sync_file_name].asString();
+ if (!file_system::IsFileNameValid(sync_file_name)) {
+ const std::string err_msg = "Sync file name contains forbidden symbols.";
+ LOG4CXX_ERROR(logger_, err_msg);
+ SendResponse(false, mobile_apis::Result::INVALID_DATA, err_msg.c_str());
+ return;
+ }
+
std::string full_file_path =
application_manager_.get_settings().app_storage_folder() + "/";
full_file_path += app->folder_name();
@@ -113,9 +120,10 @@ void SetAppIconRequest::Run() {
void SetAppIconRequest::CopyToIconStorage(
const std::string& path_to_file) const {
- if (!application_manager_.protocol_handler()
- .get_settings()
- .enable_protocol_4()) {
+ if (!(application_manager_.protocol_handler()
+ .get_settings()
+ .max_supported_protocol_version() >=
+ protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_4)) {
LOG4CXX_WARN(logger_,
"Icon copying skipped, since protocol ver. 4 is not enabled.");
return;
diff --git a/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc b/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc
index fcfea5e744..096c4ed783 100644
--- a/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc
+++ b/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc
@@ -265,15 +265,11 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) {
result_code,
response_info.empty() ? NULL : response_info.c_str(),
&(message[strings::msg_params]));
+}
- if (!application) {
- LOG4CXX_DEBUG(logger_, "NULL pointer.");
- return;
- }
-
- if (result) {
- application->UpdateHash();
- }
+bool SetGlobalPropertiesRequest::Init() {
+ hash_update_mode_ = HashUpdateMode::kDoHashUpdate;
+ return true;
}
bool SetGlobalPropertiesRequest::PrepareResponseParameters(
diff --git a/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc b/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc
index eb6bbf545e..4d11467d2d 100644
--- a/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc
+++ b/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc
@@ -86,10 +86,11 @@ void SubscribeButtonRequest::Run() {
const bool is_succedeed = true;
SendResponse(is_succedeed, mobile_apis::Result::SUCCESS);
+}
- if (is_succedeed) {
- app->UpdateHash();
- }
+bool SubscribeButtonRequest::Init() {
+ hash_update_mode_ = HashUpdateMode::kDoHashUpdate;
+ return true;
}
bool SubscribeButtonRequest::IsSubscriptionAllowed(
@@ -104,34 +105,6 @@ bool SubscribeButtonRequest::IsSubscriptionAllowed(
return true;
}
-bool SubscribeButtonRequest::CheckHMICapabilities(
- mobile_apis::ButtonName::eType button) {
- using namespace smart_objects;
- using namespace mobile_apis;
- LOG4CXX_AUTO_TRACE(logger_);
-
- const HMICapabilities& hmi_caps = application_manager_.hmi_capabilities();
- if (!hmi_caps.is_ui_cooperating()) {
- LOG4CXX_ERROR(logger_, "UI is not supported by HMI.");
- return false;
- }
-
- const SmartObject* button_caps_ptr = hmi_caps.button_capabilities();
- if (button_caps_ptr) {
- const SmartObject& button_caps = *button_caps_ptr;
- const size_t length = button_caps.length();
- for (size_t i = 0; i < length; ++i) {
- const SmartObject& caps = button_caps[i];
- const ButtonName::eType name = static_cast<ButtonName::eType>(
- caps.getElement(hmi_response::button_name).asInt());
- if (name == button) {
- return true;
- }
- }
- }
- return false;
-}
-
void SubscribeButtonRequest::SendSubscribeButtonNotification() {
using namespace smart_objects;
using namespace hmi_apis;
diff --git a/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc b/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc
index 56027bacaf..fc839a43f4 100644
--- a/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc
+++ b/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc
@@ -264,13 +264,14 @@ void SubscribeVehicleDataRequest::on_event(const event_engine::Event& event) {
result_code,
response_info.empty() ? NULL : response_info.c_str(),
&(message[strings::msg_params]));
-
- if (is_succeeded) {
- app->UpdateHash();
- }
#endif // #ifdef HMI_DBUS_API
}
+bool SubscribeVehicleDataRequest::Init() {
+ hash_update_mode_ = HashUpdateMode::kDoHashUpdate;
+ return true;
+}
+
void SubscribeVehicleDataRequest::AddAlreadySubscribedVI(
smart_objects::SmartObject& msg_params) const {
LOG4CXX_AUTO_TRACE(logger_);
diff --git a/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc b/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc
index 29cc8e6541..0e0d760228 100644
--- a/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc
+++ b/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc
@@ -33,7 +33,6 @@ void SubscribeWayPointsRequest::Run() {
if (application_manager_.IsAnyAppSubscribedForWayPoints()) {
application_manager_.SubscribeAppForWayPoints(app->app_id());
SendResponse(true, mobile_apis::Result::SUCCESS);
- app->UpdateHash();
return;
}
@@ -62,9 +61,6 @@ void SubscribeWayPointsRequest::on_event(const event_engine::Event& event) {
MessageHelper::HMIToMobileResult(result_code),
response_info.empty() ? NULL : response_info.c_str(),
&(message[strings::msg_params]));
- if (result) {
- app->UpdateHash();
- }
break;
}
default: {
@@ -74,6 +70,11 @@ void SubscribeWayPointsRequest::on_event(const event_engine::Event& event) {
}
}
+bool SubscribeWayPointsRequest::Init() {
+ hash_update_mode_ = HashUpdateMode::kDoHashUpdate;
+ return true;
+}
+
} // namespace commands
} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/mobile/system_request.cc b/src/components/application_manager/src/commands/mobile/system_request.cc
index 74d25508e0..e4706441ef 100644
--- a/src/components/application_manager/src/commands/mobile/system_request.cc
+++ b/src/components/application_manager/src/commands/mobile/system_request.cc
@@ -118,8 +118,7 @@ class QueryAppsDataValidator {
smart_objects::SmartArray::iterator applications_iterator =
objects_array->begin();
- for (; applications_iterator != objects_array->end();
- ++applications_iterator) {
+ for (; applications_iterator != objects_array->end();) {
const smart_objects::SmartObject& app_data = *applications_iterator;
if (!app_data.isValid()) {
@@ -133,7 +132,8 @@ class QueryAppsDataValidator {
LOG4CXX_WARN(logger_,
"Application hasn`t some of mandatory parameters. "
"Application will be skipped.");
- objects_array->erase(applications_iterator);
+
+ applications_iterator = objects_array->erase(applications_iterator);
continue;
}
@@ -186,6 +186,7 @@ class QueryAppsDataValidator {
return false;
}
has_response_valid_application = true;
+ ++applications_iterator;
}
return has_response_valid_application;
}
@@ -466,6 +467,20 @@ void SystemRequest::Run() {
file_name = kSYNC;
}
+ if (!CheckSyntax(file_name)) {
+ LOG4CXX_ERROR(logger_,
+ "Incoming request contains \t\n \\t \\n or whitespace");
+ SendResponse(false, mobile_apis::Result::INVALID_DATA);
+ return;
+ }
+
+ if (!file_system::IsFileNameValid(file_name)) {
+ const std::string err_msg = "Sync file name contains forbidden symbols.";
+ LOG4CXX_ERROR(logger_, err_msg);
+ SendResponse(false, mobile_apis::Result::INVALID_DATA, err_msg.c_str());
+ return;
+ }
+
bool is_system_file = std::string::npos != file_name.find(kSYNC) ||
std::string::npos != file_name.find(kIVSU);
diff --git a/src/components/application_manager/src/commands/mobile/unregister_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/unregister_app_interface_request.cc
index d7056a624e..d40ad9c870 100644
--- a/src/components/application_manager/src/commands/mobile/unregister_app_interface_request.cc
+++ b/src/components/application_manager/src/commands/mobile/unregister_app_interface_request.cc
@@ -53,6 +53,7 @@ void UnregisterAppInterfaceRequest::Run() {
connection_key(),
mobile_api::AppInterfaceUnregisteredReason::INVALID_ENUM),
commands::Command::ORIGIN_SDL);
+ application_manager_.EndNaviServices(connection_key());
application_manager_.UnregisterApplication(connection_key(),
mobile_apis::Result::SUCCESS);
SendResponse(true, mobile_apis::Result::SUCCESS);
diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc
index e1bdba61a0..7e798bcb4e 100644
--- a/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc
+++ b/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc
@@ -58,8 +58,16 @@ void UnsubscribeButtonRequest::Run() {
return;
}
- const uint32_t btn_id =
- (*message_)[str::msg_params][str::button_name].asUInt();
+ const mobile_apis::ButtonName::eType btn_id =
+ static_cast<mobile_apis::ButtonName::eType>(
+ (*message_)[str::msg_params][str::button_name].asInt());
+
+ if (!CheckHMICapabilities(btn_id)) {
+ LOG4CXX_ERROR(logger_,
+ "Button " << btn_id << " isn't allowed by HMI capabilities");
+ SendResponse(false, mobile_apis::Result::UNSUPPORTED_RESOURCE);
+ return;
+ }
if (!app->UnsubscribeFromButton(
static_cast<mobile_apis::ButtonName::eType>(btn_id))) {
@@ -70,7 +78,11 @@ void UnsubscribeButtonRequest::Run() {
SendUnsubscribeButtonNotification();
SendResponse(true, mobile_apis::Result::SUCCESS);
- app->UpdateHash();
+}
+
+bool UnsubscribeButtonRequest::Init() {
+ hash_update_mode_ = HashUpdateMode::kDoHashUpdate;
+ return true;
}
void UnsubscribeButtonRequest::SendUnsubscribeButtonNotification() {
@@ -81,7 +93,7 @@ void UnsubscribeButtonRequest::SendUnsubscribeButtonNotification() {
SmartObject msg_params = SmartObject(SmartType_Map);
msg_params[strings::app_id] = connection_key();
msg_params[strings::name] = static_cast<Common_ButtonName::eType>(
- (*message_)[strings::msg_params][strings::button_name].asUInt());
+ (*message_)[strings::msg_params][strings::button_name].asInt());
msg_params[strings::is_suscribed] = false;
CreateHMINotification(FunctionID::Buttons_OnButtonSubscription, msg_params);
}
diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc
index 9b0c0a673f..fa3a9ad400 100644
--- a/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc
+++ b/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc
@@ -342,11 +342,17 @@ void UnsubscribeVehicleDataRequest::on_event(const event_engine::Event& event) {
response_info.empty() ? NULL : response_info.c_str(),
&(message[strings::msg_params]));
if (result) {
- UpdateHash();
+ application_manager_.TerminateRequest(
+ connection_key(), correlation_id(), function_id());
}
#endif // #ifdef HMI_DBUS_API
}
+bool UnsubscribeVehicleDataRequest::Init() {
+ hash_update_mode_ = HashUpdateMode::kDoHashUpdate;
+ return true;
+}
+
struct SubscribedToIVIPredicate {
int32_t vehicle_info_;
SubscribedToIVIPredicate(int32_t vehicle_info)
@@ -387,20 +393,5 @@ void UnsubscribeVehicleDataRequest::AddAlreadyUnsubscribedVI(
}
}
-void UnsubscribeVehicleDataRequest::UpdateHash() const {
- LOG4CXX_AUTO_TRACE(logger_);
- ApplicationSharedPtr application =
- application_manager_.application(connection_key());
- if (application) {
- application->UpdateHash();
- } else {
- LOG4CXX_ERROR(logger_,
- "Application with connection_key = " << connection_key()
- << " doesn't exist.");
- }
- application_manager_.TerminateRequest(
- connection_key(), correlation_id(), function_id());
-}
-
} // namespace commands
} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc
index 728209fcf2..953bbc7a12 100644
--- a/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc
+++ b/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc
@@ -55,9 +55,6 @@ void UnSubscribeWayPointsRequest::on_event(const event_engine::Event& event) {
MessageHelper::HMIToMobileResult(result_code),
response_info.empty() ? NULL : response_info.c_str(),
&(message[strings::msg_params]));
- if (result) {
- app->UpdateHash();
- }
break;
}
default: {
@@ -67,6 +64,11 @@ void UnSubscribeWayPointsRequest::on_event(const event_engine::Event& event) {
}
}
+bool UnSubscribeWayPointsRequest::Init() {
+ hash_update_mode_ = HashUpdateMode::kDoHashUpdate;
+ return true;
+}
+
} // namespace commands
} // namespace application_manager
diff --git a/src/components/application_manager/src/core_service.cc b/src/components/application_manager/src/core_service.cc
new file mode 100644
index 0000000000..2a96502cde
--- /dev/null
+++ b/src/components/application_manager/src/core_service.cc
@@ -0,0 +1,231 @@
+/**
+ * Copyright (c) 2013, 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 <vector>
+#include <algorithm>
+#include "application_manager/core_service.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/policies/policy_handler.h"
+#include "application_manager/message_helper.h"
+#include "json/json.h"
+#include "interfaces/HMI_API.h"
+
+namespace application_manager {
+
+namespace {
+struct AppExtensionPredicate {
+ AppExtensionUID uid;
+ bool operator()(const ApplicationSharedPtr app) {
+ return app ? app->QueryInterface(uid).valid() : false;
+ }
+};
+}
+
+CoreService::CoreService(ApplicationManager& application_manager)
+ : application_manager_(application_manager) {}
+
+CoreService::~CoreService() {}
+
+mobile_apis::Result::eType CoreService::CheckPolicyPermissions(MessagePtr msg) {
+ ApplicationSharedPtr app = GetApplication(msg->connection_key());
+ if (!app) {
+ return mobile_apis::Result::eType::APPLICATION_NOT_REGISTERED;
+ }
+
+#ifdef SDL_REMOTE_CONTROL
+ const RPCParams rpc_params;
+ CommandParametersPermissions params;
+ const mobile_apis::Result::eType ret =
+ application_manager_.CheckPolicyPermissions(
+ app, msg->function_name(), rpc_params, &params);
+
+ if (ret != mobile_apis::Result::eType::SUCCESS) {
+ return ret;
+ }
+
+ if (!AreParametersAllowed(msg, params)) {
+ return mobile_apis::Result::eType::DISALLOWED;
+ }
+
+ return ret;
+#else
+ return mobile_apis::Result::eType::SUCCESS;
+#endif // SDL_REMOTE_CONTROL
+}
+
+bool CoreService::CheckModule(const ApplicationId& app_id,
+ const std::string& module) {
+#ifdef SDL_REMOTE_CONTROL
+ ApplicationSharedPtr app = GetApplication(app_id);
+ if (app) {
+ return application_manager_.GetPolicyHandler().CheckModule(
+ app->policy_app_id(), module);
+ }
+#endif // SDL_REMOTE_CONTROL
+ return false;
+}
+
+bool CoreService::IsRemoteControlApplication(ApplicationSharedPtr app) const {
+#ifdef SDL_REMOTE_CONTROL
+ DCHECK_OR_RETURN(app, false);
+ return application_manager_.GetPolicyHandler().CheckHMIType(
+ app->policy_app_id(),
+ mobile_apis::AppHMIType::eType::REMOTE_CONTROL,
+ app->app_types());
+#endif // SDL_REMOTE_CONTROL
+ return false;
+}
+
+bool CoreService::IsInterfaceAvailable(
+ const HmiInterfaces::InterfaceID interface) const {
+#ifdef SDL_REMOTE_CONTROL
+ HmiInterfaces& hmi_interfaces = application_manager_.hmi_interfaces();
+ const HmiInterfaces::InterfaceState state =
+ hmi_interfaces.GetInterfaceState(interface);
+ return HmiInterfaces::STATE_NOT_AVAILABLE != state;
+#endif // SDL_REMOTE_CONTROL
+ return false;
+}
+
+void CoreService::RemoveHMIFakeParameters(
+ application_manager::MessagePtr& message) {
+ application_manager_.RemoveHMIFakeParameters(message);
+}
+
+ApplicationSharedPtr CoreService::GetApplication(ApplicationId app_id) {
+ return application_manager_.application(app_id);
+}
+
+void CoreService::SendMessageToHMI(const MessagePtr& message) {
+ application_manager_.SendPostMessageToHMI(message);
+}
+
+void CoreService::SendMessageToMobile(const MessagePtr& message) {
+ application_manager_.SendPostMessageToMobile(message);
+}
+
+uint32_t CoreService::GetNextCorrelationID() {
+ return application_manager_.GetNextHMICorrelationID();
+}
+
+std::vector<ApplicationSharedPtr> CoreService::GetApplications(
+ AppExtensionUID uid) {
+ ApplicationSet accessor = application_manager_.applications().GetData();
+ AppExtensionPredicate predicate;
+ predicate.uid = uid;
+
+ std::vector<ApplicationSharedPtr> result;
+ ApplicationSetConstIt it =
+ std::find_if(accessor.begin(), accessor.end(), predicate);
+ while (it != accessor.end()) {
+ result.push_back(*it);
+ it = std::find_if(++it, accessor.end(), predicate);
+ }
+ return result;
+}
+
+void CoreService::ChangeNotifyHMILevel(ApplicationSharedPtr app,
+ mobile_apis::HMILevel::eType level) {
+ DCHECK_OR_RETURN_VOID(app);
+ application_manager_.ChangeAppsHMILevel(app->app_id(), level);
+}
+
+const smart_objects::SmartObject* CoreService::GetRCCapabilities() const {
+ return application_manager_.hmi_capabilities().rc_capability();
+}
+
+void CoreService::NotifyHMIAboutHMILevel(ApplicationSharedPtr app,
+ mobile_apis::HMILevel::eType level) {
+ DCHECK_OR_RETURN_VOID(app);
+ if (app->hmi_level() != mobile_apis::HMILevel::eType::HMI_FULL) {
+ MessageHelper::SendActivateAppToHMI(
+ app->app_id(),
+ application_manager_,
+ static_cast<hmi_apis::Common_HMILevel::eType>(level),
+ true);
+ }
+}
+
+bool CoreService::AreParametersAllowed(
+ MessagePtr msg, const CommandParametersPermissions& params) {
+ Json::Reader reader;
+ Json::Value json;
+ bool ret = reader.parse(msg->json_message(), json);
+ if (ret) {
+ return CheckParams(json.get(strings::params, Json::Value(Json::nullValue)),
+ params.allowed_params);
+ }
+ return false;
+}
+
+bool CoreService::CheckParams(const Json::Value& object,
+ const RPCParams& allowed_params) {
+ if (!object.isObject()) {
+ return true;
+ }
+ for (Json::Value::iterator i = object.begin(); i != object.end(); ++i) {
+ std::string name = i.memberName();
+ if (!IsAllowed(name, allowed_params)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+bool CoreService::IsAllowed(const std::string& name,
+ const RPCParams& allowed_params) {
+ return std::find(allowed_params.begin(), allowed_params.end(), name) !=
+ allowed_params.end();
+}
+
+bool CoreService::GetModuleTypes(const std::string& policy_app_id,
+ std::vector<std::string>* modules) const {
+#ifdef SDL_REMOTE_CONTROL
+ return application_manager_.GetPolicyHandler().GetModuleTypes(policy_app_id,
+ modules);
+#endif // SDL_REMOTE_CONTROL
+ return false;
+}
+
+MessageValidationResult CoreService::ValidateMessageBySchema(
+ const Message& message) {
+ const MessageValidationResult result =
+ application_manager_.ValidateMessageBySchema(message);
+ LOG4CXX_DEBUG(logger_, "Validation result : " << result);
+ return result;
+}
+
+const ApplicationManagerSettings& CoreService::GetSettings() const {
+ return application_manager_.get_settings();
+}
+
+} // namespace application_manager
diff --git a/src/components/application_manager/src/event_engine/event_dispatcher_impl.cc b/src/components/application_manager/src/event_engine/event_dispatcher_impl.cc
index f8b8bc791d..d0bc0c41ef 100644
--- a/src/components/application_manager/src/event_engine/event_dispatcher_impl.cc
+++ b/src/components/application_manager/src/event_engine/event_dispatcher_impl.cc
@@ -63,9 +63,10 @@ void EventDispatcherImpl::raise_event(const Event& event) {
// Call observers
EventObserver* temp;
while (!observers_.empty()) {
- AutoLock auto_lock(observer_lock_);
+ observer_lock_.Acquire();
temp = *observers_.begin();
observers_.erase(observers_.begin());
+ observer_lock_.Release();
temp->on_event(event);
}
}
diff --git a/src/components/application_manager/src/hmi_capabilities_impl.cc b/src/components/application_manager/src/hmi_capabilities_impl.cc
index 9d52cc98db..1c6e439ee8 100644
--- a/src/components/application_manager/src/hmi_capabilities_impl.cc
+++ b/src/components/application_manager/src/hmi_capabilities_impl.cc
@@ -68,6 +68,10 @@ std::map<std::string, hmi_apis::Common_ImageFieldName::eType>
std::map<std::string, hmi_apis::Common_FileType::eType> file_type_enum;
std::map<std::string, hmi_apis::Common_DisplayType::eType> display_type_enum;
std::map<std::string, hmi_apis::Common_CharacterSet::eType> character_set_enum;
+std::map<std::string, hmi_apis::Common_VideoStreamingProtocol::eType>
+ video_streaming_protocol_enum;
+std::map<std::string, hmi_apis::Common_VideoStreamingCodec::eType>
+ video_streaming_codec_enum;
void InitCapabilities() {
vr_enum_capabilities.insert(std::make_pair(
@@ -333,6 +337,28 @@ void InitCapabilities() {
std::string("CID1SET"), hmi_apis::Common_CharacterSet::CID1SET));
character_set_enum.insert(std::make_pair(
std::string("CID2SET"), hmi_apis::Common_CharacterSet::CID2SET));
+
+ video_streaming_protocol_enum.insert(std::make_pair(
+ std::string("RAW"), hmi_apis::Common_VideoStreamingProtocol::RAW));
+ video_streaming_protocol_enum.insert(std::make_pair(
+ std::string("RTP"), hmi_apis::Common_VideoStreamingProtocol::RTP));
+ video_streaming_protocol_enum.insert(std::make_pair(
+ std::string("RTSP"), hmi_apis::Common_VideoStreamingProtocol::RTSP));
+ video_streaming_protocol_enum.insert(std::make_pair(
+ std::string("RTMP"), hmi_apis::Common_VideoStreamingProtocol::RTMP));
+ video_streaming_protocol_enum.insert(std::make_pair(
+ std::string("WEBM"), hmi_apis::Common_VideoStreamingProtocol::WEBM));
+
+ video_streaming_codec_enum.insert(std::make_pair(
+ std::string("H264"), hmi_apis::Common_VideoStreamingCodec::H264));
+ video_streaming_codec_enum.insert(std::make_pair(
+ std::string("H265"), hmi_apis::Common_VideoStreamingCodec::H265));
+ video_streaming_codec_enum.insert(std::make_pair(
+ std::string("Theora"), hmi_apis::Common_VideoStreamingCodec::Theora));
+ video_streaming_codec_enum.insert(std::make_pair(
+ std::string("VP8"), hmi_apis::Common_VideoStreamingCodec::VP8));
+ video_streaming_codec_enum.insert(std::make_pair(
+ std::string("VP9"), hmi_apis::Common_VideoStreamingCodec::VP9));
}
} // namespace
@@ -343,6 +369,7 @@ HMICapabilitiesImpl::HMICapabilitiesImpl(ApplicationManager& app_mngr)
, is_ui_cooperating_(false)
, is_navi_cooperating_(false)
, is_ivi_cooperating_(false)
+ , is_rc_cooperating_(false)
, attenuated_supported_(false)
, ui_language_(hmi_apis::Common_Language::INVALID_ENUM)
, vr_language_(hmi_apis::Common_Language::INVALID_ENUM)
@@ -363,6 +390,11 @@ HMICapabilitiesImpl::HMICapabilitiesImpl(ApplicationManager& app_mngr)
, prerecorded_speech_(NULL)
, is_navigation_supported_(false)
, is_phone_call_supported_(false)
+ , is_video_streaming_supported_(false)
+ , navigation_capability_(NULL)
+ , phone_capability_(NULL)
+ , video_streaming_capability_(NULL)
+ , rc_capability_(NULL)
, app_mngr_(app_mngr)
, hmi_language_handler_(app_mngr) {
InitCapabilities();
@@ -372,6 +404,7 @@ HMICapabilitiesImpl::HMICapabilitiesImpl(ApplicationManager& app_mngr)
is_ui_cooperating_ = true;
is_navi_cooperating_ = true;
is_ivi_cooperating_ = true;
+ is_rc_cooperating_ = true;
}
}
@@ -390,6 +423,10 @@ HMICapabilitiesImpl::~HMICapabilitiesImpl() {
delete audio_pass_thru_capabilities_;
delete pcm_stream_capabilities_;
delete prerecorded_speech_;
+ delete navigation_capability_;
+ delete phone_capability_;
+ delete video_streaming_capability_;
+ delete rc_capability_;
}
bool HMICapabilitiesImpl::VerifyImageType(const int32_t image_type) const {
@@ -430,6 +467,10 @@ void HMICapabilitiesImpl::set_is_ivi_cooperating(const bool value) {
is_ivi_cooperating_ = value;
}
+void HMICapabilitiesImpl::set_is_rc_cooperating(const bool value) {
+ is_rc_cooperating_ = value;
+}
+
void HMICapabilitiesImpl::set_attenuated_supported(const bool state) {
attenuated_supported_ = state;
}
@@ -605,6 +646,44 @@ void HMICapabilitiesImpl::set_phone_call_supported(const bool supported) {
is_phone_call_supported_ = supported;
}
+void HMICapabilitiesImpl::set_video_streaming_supported(const bool supported) {
+ is_video_streaming_supported_ = supported;
+}
+
+void HMICapabilitiesImpl::set_navigation_capability(
+ const smart_objects::SmartObject& navigation_capability) {
+ if (navigation_capability_) {
+ delete navigation_capability_;
+ }
+ navigation_capability_ =
+ new smart_objects::SmartObject(navigation_capability);
+}
+
+void HMICapabilitiesImpl::set_phone_capability(
+ const smart_objects::SmartObject& phone_capability) {
+ if (phone_capability_) {
+ delete phone_capability_;
+ }
+ phone_capability_ = new smart_objects::SmartObject(phone_capability);
+}
+
+void HMICapabilitiesImpl::set_video_streaming_capability(
+ const smart_objects::SmartObject& video_streaming_capability) {
+ if (video_streaming_capability_) {
+ delete video_streaming_capability_;
+ }
+ video_streaming_capability_ =
+ new smart_objects::SmartObject(video_streaming_capability);
+}
+
+void HMICapabilitiesImpl::set_rc_capability(
+ const smart_objects::SmartObject& rc_capability) {
+ if (rc_capability_) {
+ delete rc_capability_;
+ }
+ rc_capability_ = new smart_objects::SmartObject(rc_capability);
+}
+
void HMICapabilitiesImpl::Init(resumption::LastState* last_state) {
hmi_language_handler_.Init(last_state);
if (false == load_capabilities_from_file()) {
@@ -636,6 +715,10 @@ bool HMICapabilitiesImpl::is_ivi_cooperating() const {
return is_ivi_cooperating_;
}
+bool HMICapabilitiesImpl::is_rc_cooperating() const {
+ return is_rc_cooperating_;
+}
+
const smart_objects::SmartObject* HMICapabilitiesImpl::ui_supported_languages()
const {
return ui_supported_languages_;
@@ -716,6 +799,29 @@ bool HMICapabilitiesImpl::phone_call_supported() const {
return is_phone_call_supported_;
}
+bool HMICapabilitiesImpl::video_streaming_supported() const {
+ return is_video_streaming_supported_;
+}
+
+const smart_objects::SmartObject* HMICapabilitiesImpl::navigation_capability()
+ const {
+ return navigation_capability_;
+}
+
+const smart_objects::SmartObject* HMICapabilitiesImpl::phone_capability()
+ const {
+ return phone_capability_;
+}
+
+const smart_objects::SmartObject*
+HMICapabilitiesImpl::video_streaming_capability() const {
+ return video_streaming_capability_;
+}
+
+const smart_objects::SmartObject* HMICapabilitiesImpl::rc_capability() const {
+ return rc_capability_;
+}
+
bool HMICapabilitiesImpl::load_capabilities_from_file() {
std::string json_string;
std::string file_name = app_mngr_.get_settings().hmi_capabilities_file_name();
@@ -960,6 +1066,83 @@ bool HMICapabilitiesImpl::load_capabilities_from_file() {
soft_button_capabilities, soft_button_capabilities_so);
set_soft_button_capabilities(soft_button_capabilities_so);
}
+ if (check_existing_json_member(ui, "systemCapabilities")) {
+ Json::Value system_capabilities = ui.get("systemCapabilities", "");
+ if (check_existing_json_member(system_capabilities,
+ "navigationCapability")) {
+ Json::Value navigation_capability =
+ system_capabilities.get("navigationCapability", "");
+ smart_objects::SmartObject navigation_capability_so;
+ Formatters::CFormatterJsonBase::jsonValueToObj(
+ navigation_capability, navigation_capability_so);
+ set_navigation_capability(navigation_capability_so);
+ }
+ if (check_existing_json_member(system_capabilities,
+ "phoneCapability")) {
+ Json::Value phone_capability =
+ system_capabilities.get("phoneCapability", "");
+ smart_objects::SmartObject phone_capability_so;
+ Formatters::CFormatterJsonBase::jsonValueToObj(phone_capability,
+ phone_capability_so);
+ set_phone_capability(phone_capability_so);
+ }
+ if (check_existing_json_member(system_capabilities,
+ "videoStreamingCapability")) {
+ Json::Value vs_capability =
+ system_capabilities.get("videoStreamingCapability", "");
+ smart_objects::SmartObject vs_capability_so;
+ Formatters::CFormatterJsonBase::jsonValueToObj(vs_capability,
+ vs_capability_so);
+
+ if (vs_capability_so.keyExists("supportedFormats")) {
+ smart_objects::SmartObject& supported_format_array =
+ vs_capability_so["supportedFormats"];
+ smart_objects::SmartObject converted_array(
+ smart_objects::SmartType_Array);
+ for (uint32_t i = 0, j = 0; i < supported_format_array.length();
+ i++) {
+ if (!supported_format_array[i].keyExists("protocol") ||
+ !supported_format_array[i].keyExists("codec")) {
+ continue;
+ }
+
+ std::map<std::string,
+ hmi_apis::Common_VideoStreamingProtocol::eType>::
+ const_iterator it_protocol =
+ video_streaming_protocol_enum.find(
+ supported_format_array[i]["protocol"].asString());
+
+ std::map<std::string,
+ hmi_apis::Common_VideoStreamingCodec::eType>::
+ const_iterator it_codec = video_streaming_codec_enum.find(
+ supported_format_array[i]["codec"].asString());
+
+ // format is valid only if both protocol and codec are converted
+ // to enum values successfully
+ if (it_protocol != video_streaming_protocol_enum.end() &&
+ it_codec != video_streaming_codec_enum.end()) {
+ smart_objects::SmartObject format_so =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ format_so["protocol"] = it_protocol->second;
+ format_so["codec"] = it_codec->second;
+ converted_array[j++] = format_so;
+ }
+ }
+ vs_capability_so.erase("supportedFormats");
+ vs_capability_so["supportedFormats"] = converted_array;
+ }
+ set_video_streaming_capability(vs_capability_so);
+ }
+ if (check_existing_json_member(system_capabilities,
+ "remoteControlCapability")) {
+ Json::Value rc_capability =
+ system_capabilities.get("remoteControlCapability", "");
+ smart_objects::SmartObject rc_capability_so;
+ Formatters::CFormatterJsonBase::jsonValueToObj(rc_capability,
+ rc_capability_so);
+ set_rc_capability(rc_capability_so);
+ }
+ }
} // UI end
// VR
@@ -1065,7 +1248,6 @@ bool HMICapabilitiesImpl::load_capabilities_from_file() {
vehicle_type_so);
set_vehicle_type(vehicle_type_so);
} // VehicleType end
-
} catch (...) {
return false;
}
diff --git a/src/components/application_manager/src/hmi_command_factory.cc b/src/components/application_manager/src/hmi_command_factory.cc
index 3f8a60a4a5..ffaa8d9b5f 100644
--- a/src/components/application_manager/src/hmi_command_factory.cc
+++ b/src/components/application_manager/src/hmi_command_factory.cc
@@ -2,6 +2,9 @@
Copyright (c) 2013, Ford Motor Company
All rights reserved.
+ Copyright (c) 2017 Xevo Inc.
+ All rights reserved.
+
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -13,7 +16,7 @@
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
+ Neither the name of the copyright holders nor the names of their contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
@@ -246,6 +249,8 @@
#include "application_manager/commands/hmi/on_ui_keyboard_input_notification.h"
#include "application_manager/commands/hmi/on_ui_touch_event_notification.h"
#include "application_manager/commands/hmi/on_ui_reset_timeout_notification.h"
+#include "application_manager/commands/hmi/navi_set_video_config_request.h"
+#include "application_manager/commands/hmi/navi_set_video_config_response.h"
#include "application_manager/commands/hmi/navi_start_stream_request.h"
#include "application_manager/commands/hmi/navi_start_stream_response.h"
#include "application_manager/commands/hmi/navi_stop_stream_request.h"
@@ -276,6 +281,13 @@
#include "application_manager/commands/hmi/on_tts_reset_timeout_notification.h"
#include "application_manager/commands/hmi/dial_number_request.h"
#include "application_manager/commands/hmi/dial_number_response.h"
+#include "application_manager/commands/hmi/ui_send_haptic_data_request.h"
+#include "application_manager/commands/hmi/ui_send_haptic_data_response.h"
+
+#include "application_manager/commands/hmi/rc_is_ready_request.h"
+#include "application_manager/commands/hmi/rc_is_ready_response.h"
+#include "application_manager/commands/hmi/rc_get_capabilities_request.h"
+#include "application_manager/commands/hmi/rc_get_capabilities_response.h"
CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager")
namespace application_manager {
@@ -2078,6 +2090,16 @@ CommandSharedPtr HMICommandFactory::CreateCommand(
message, application_manager));
break;
}
+ case hmi_apis::FunctionID::Navigation_SetVideoConfig: {
+ if (is_response) {
+ command.reset(new commands::NaviSetVideoConfigResponse(
+ message, application_manager));
+ } else {
+ command.reset(new commands::NaviSetVideoConfigRequest(
+ message, application_manager));
+ }
+ break;
+ }
case hmi_apis::FunctionID::Navigation_StartStream: {
if (is_response) {
command.reset(new commands::NaviStartStreamResponse(
@@ -2252,6 +2274,36 @@ CommandSharedPtr HMICommandFactory::CreateCommand(
message, application_manager));
break;
}
+ case hmi_apis::FunctionID::RC_IsReady: {
+ if (is_response) {
+ command.reset(
+ new commands::RCIsReadyResponse(message, application_manager));
+ } else {
+ command.reset(
+ new commands::RCIsReadyRequest(message, application_manager));
+ }
+ break;
+ }
+ case hmi_apis::FunctionID::RC_GetCapabilities: {
+ if (is_response) {
+ command.reset(new commands::RCGetCapabilitiesResponse(
+ message, application_manager));
+ } else {
+ command.reset(new commands::RCGetCapabilitiesRequest(
+ message, application_manager));
+ }
+ break;
+ }
+ case hmi_apis::FunctionID::UI_SendHapticData: {
+ if (is_response) {
+ command.reset(new commands::UISendHapticDataResponse(
+ message, application_manager));
+ } else {
+ command.reset(new commands::UISendHapticDataRequest(
+ message, application_manager));
+ }
+ break;
+ }
}
return command;
}
diff --git a/src/components/application_manager/src/hmi_interfaces_impl.cc b/src/components/application_manager/src/hmi_interfaces_impl.cc
index 8a9944bec4..4479665f64 100644
--- a/src/components/application_manager/src/hmi_interfaces_impl.cc
+++ b/src/components/application_manager/src/hmi_interfaces_impl.cc
@@ -2,6 +2,9 @@
* Copyright (c) 2016, Ford Motor Company
* All rights reserved.
*
+ * Copyright (c) 2017 Xevo Inc.
+ * All rights reserved.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
@@ -13,7 +16,7 @@
* 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
+ * Neither the name of the copyright holders nor the names of their contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -155,6 +158,7 @@ generate_function_to_interface_convert_map() {
convert_map[UI_IsReady] = HmiInterfaces::HMI_INTERFACE_UI;
convert_map[UI_ClosePopUp] = HmiInterfaces::HMI_INTERFACE_UI;
convert_map[UI_OnResetTimeout] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_SendHapticData] = HmiInterfaces::HMI_INTERFACE_UI;
convert_map[Navigation_IsReady] = HmiInterfaces::HMI_INTERFACE_Navigation;
convert_map[Navigation_SendLocation] =
HmiInterfaces::HMI_INTERFACE_Navigation;
@@ -166,6 +170,8 @@ generate_function_to_interface_convert_map() {
HmiInterfaces::HMI_INTERFACE_Navigation;
convert_map[Navigation_OnTBTClientState] =
HmiInterfaces::HMI_INTERFACE_Navigation;
+ convert_map[Navigation_SetVideoConfig] =
+ HmiInterfaces::HMI_INTERFACE_Navigation;
convert_map[Navigation_StartStream] = HmiInterfaces::HMI_INTERFACE_Navigation;
convert_map[Navigation_StopStream] = HmiInterfaces::HMI_INTERFACE_Navigation;
convert_map[Navigation_StartAudioStream] =
@@ -214,6 +220,8 @@ generate_function_to_interface_convert_map() {
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;
return convert_map;
}
@@ -235,6 +243,8 @@ HmiInterfacesImpl::HmiInterfacesImpl() {
HmiInterfaces::STATE_NOT_RESPONSE;
interfaces_states_[HmiInterfaces::HMI_INTERFACE_VR] =
HmiInterfaces::STATE_NOT_RESPONSE;
+ interfaces_states_[HmiInterfaces::HMI_INTERFACE_RC] =
+ HmiInterfaces::STATE_NOT_RESPONSE;
}
HmiInterfaces::InterfaceState HmiInterfacesImpl::GetInterfaceState(
diff --git a/src/components/application_manager/src/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc
index 1f05232476..393a9d7784 100644
--- a/src/components/application_manager/src/hmi_state.cc
+++ b/src/components/application_manager/src/hmi_state.cc
@@ -1,3 +1,4 @@
+
/*
* Copyright (c) 2015, Ford Motor Company
* All rights reserved.
@@ -74,6 +75,11 @@ bool HmiState::is_voice_communication_app(const uint32_t app_id) const {
return app ? app->is_voice_communication_supported() : false;
}
+bool HmiState::is_mobile_projection_app(const uint32_t app_id) const {
+ const ApplicationSharedPtr app = app_mngr_.application(app_id);
+ return app ? app->mobile_projection_enabled() : false;
+}
+
mobile_apis::AudioStreamingState::eType VRHmiState::audio_streaming_state()
const {
using namespace mobile_apis;
@@ -133,7 +139,7 @@ mobile_apis::HMILevel::eType PhoneCallHmiState::hmi_level() const {
HMILevel::HMI_NONE)) {
return parent()->hmi_level();
}
- if (is_navi_app(app_id_)) {
+ if (is_navi_app(app_id_) || is_mobile_projection_app(app_id_)) {
return HMILevel::HMI_LIMITED;
}
if (!is_media_app(app_id_)) {
diff --git a/src/components/application_manager/src/message.cc b/src/components/application_manager/src/message.cc
index a7c887d348..b211b270b8 100644
--- a/src/components/application_manager/src/message.cc
+++ b/src/components/application_manager/src/message.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Ford Motor Company
+ * Copyright (c) 2017, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -64,9 +64,20 @@ Message::Message(protocol_handler::MessagePriority priority)
, binary_data_(NULL)
, data_size_(0)
, payload_size_(0)
- , version_(kUnknownProtocol) {}
+ , version_(
+ protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_UNKNOWN) {}
-Message::Message(const Message& message) : priority_(message.priority_) {
+Message::Message(const Message& message)
+ : function_id_(0)
+ , correlation_id_(0)
+ , type_(kUnknownType)
+ , priority_(message.priority_)
+ , connection_key_(0)
+ , binary_data_(NULL)
+ , data_size_(0)
+ , payload_size_(0)
+ , version_(
+ protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_UNKNOWN) {
*this = message;
}
@@ -87,7 +98,7 @@ Message& Message::operator=(const Message& message) {
return *this;
}
-bool Message::operator==(const Message& message) {
+bool Message::operator==(const Message& message) const {
bool function_id = function_id_ == message.function_id_;
bool correlation_id = correlation_id_ == message.correlation_id_;
bool connection_key = connection_key_ == message.connection_key_;
@@ -96,14 +107,17 @@ bool Message::operator==(const Message& message) {
bool version = version_ == message.version_;
bool data_size = data_size_ == message.data_size_;
bool payload_size = payload_size_ == message.payload_size_;
-
- bool binary_data = std::equal(binary_data_->begin(),
- binary_data_->end(),
- message.binary_data_->begin(),
- BinaryDataPredicate);
+ bool binary_data_available = true;
+ if (binary_data_) {
+ binary_data_available = std::equal(binary_data_->begin(),
+ binary_data_->end(),
+ message.binary_data_->begin(),
+ BinaryDataPredicate);
+ }
return function_id && correlation_id && connection_key && type &&
- binary_data && json_message && version && data_size && payload_size;
+ binary_data_available && json_message && version && data_size &&
+ payload_size;
}
Message::~Message() {
@@ -116,6 +130,12 @@ int32_t Message::function_id() const {
return function_id_;
}
+#ifdef SDL_REMOTE_CONTROL
+std::string Message::function_name() const {
+ return function_name_;
+}
+#endif // SDL_REMOTE_CONTROL
+
int32_t Message::correlation_id() const {
return correlation_id_;
}
@@ -128,7 +148,7 @@ MessageType Message::type() const {
return type_;
}
-ProtocolVersion Message::protocol_version() const {
+protocol_handler::MajorProtocolVersion Message::protocol_version() const {
return version_;
}
@@ -156,6 +176,12 @@ void Message::set_function_id(int32_t id) {
function_id_ = id;
}
+#ifdef SDL_REMOTE_CONTROL
+void Message::set_function_name(const std::string& name) {
+ function_name_ = name;
+}
+#endif // SDL_REMOTE_CONTROL
+
void Message::set_correlation_id(int32_t id) {
correlation_id_ = id;
}
@@ -178,14 +204,15 @@ void Message::set_binary_data(BinaryData* data) {
delete binary_data_;
}
- binary_data_ = data;
+ binary_data_ = new BinaryData(*data);
}
void Message::set_json_message(const std::string& json_message) {
json_message_ = json_message;
}
-void Message::set_protocol_version(ProtocolVersion version) {
+void Message::set_protocol_version(
+ protocol_handler::MajorProtocolVersion version) {
version_ = version;
}
@@ -204,4 +231,11 @@ void Message::set_data_size(size_t data_size) {
void Message::set_payload_size(size_t payload_size) {
payload_size_ = payload_size;
}
+
+bool Message::is_sufficient_version(
+ protocol_handler::MajorProtocolVersion minVersion,
+ protocol_handler::MajorProtocolVersion version) {
+ return version >= minVersion &&
+ version <= protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5;
+}
} // namespace application_manager
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 19bb658bca..65f4c79fa6 100644
--- a/src/components/application_manager/src/message_helper/message_helper.cc
+++ b/src/components/application_manager/src/message_helper/message_helper.cc
@@ -443,6 +443,95 @@ hmi_apis::Common_Result::eType MessageHelper::MobileToHMIResult(
return HMIResultFromString(result);
}
+#ifdef SDL_REMOTE_CONTROL
+void MessageHelper::SendHMIStatusNotification(
+ const Application& application_impl,
+ ApplicationManager& application_manager) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ smart_objects::SmartObjectSPtr notification = new smart_objects::SmartObject;
+ if (!notification) {
+ LOG4CXX_ERROR(logger_, "Failed to create smart object");
+ return;
+ }
+ smart_objects::SmartObject& message = *notification;
+
+ message[strings::params][strings::function_id] =
+ static_cast<int32_t>(mobile_api::FunctionID::OnHMIStatusID);
+
+ message[strings::params][strings::message_type] =
+ static_cast<int32_t>(application_manager::MessageType::kNotification);
+
+ message[strings::params][strings::connection_key] =
+ static_cast<int32_t>(application_impl.app_id());
+
+ message[strings::msg_params][strings::hmi_level] =
+ static_cast<int32_t>(application_impl.hmi_level());
+
+ message[strings::msg_params][strings::audio_streaming_state] =
+ static_cast<int32_t>(application_impl.audio_streaming_state());
+
+ message[strings::msg_params][strings::system_context] =
+ static_cast<int32_t>(application_impl.system_context());
+
+ application_manager.ManageMobileCommand(notification,
+ commands::Command::ORIGIN_SDL);
+}
+
+void MessageHelper::SendActivateAppToHMI(
+ uint32_t const app_id,
+ ApplicationManager& application_manager,
+ hmi_apis::Common_HMILevel::eType level,
+ bool send_policy_priority) {
+ application_manager::ApplicationConstSharedPtr app =
+ application_manager.application(app_id);
+ if (!app) {
+ LOG4CXX_WARN(logger_, "Invalid app_id: " << app_id);
+ return;
+ }
+
+ utils::SharedPtr<smart_objects::SmartObject> message =
+ new smart_objects::SmartObject(smart_objects::SmartType_Map);
+
+ (*message)[strings::params][strings::function_id] =
+ hmi_apis::FunctionID::BasicCommunication_ActivateApp;
+ (*message)[strings::params][strings::message_type] = MessageType::kRequest;
+ (*message)[strings::params][strings::correlation_id] =
+ application_manager.GetNextHMICorrelationID();
+ (*message)[strings::msg_params][strings::app_id] = app_id;
+
+ if (send_policy_priority) {
+ std::string priority;
+ application_manager.GetPolicyHandler().GetPriority(app->policy_app_id(),
+ &priority);
+ // According SDLAQ-CRS-2794
+ // SDL have to send ActivateApp without "proirity" parameter to HMI.
+ // in case of unconsented device
+ std::string mac_adress;
+ connection_handler::DeviceHandle device_handle = app->device();
+ application_manager.connection_handler()
+ .get_session_observer()
+ .GetDataOnDeviceID(device_handle, NULL, NULL, &mac_adress, NULL);
+
+ policy::DeviceConsent consent =
+ application_manager.GetPolicyHandler().GetUserConsentForDevice(
+ mac_adress);
+ if (!priority.empty() &&
+ (policy::DeviceConsent::kDeviceAllowed == consent)) {
+ (*message)[strings::msg_params][strings::priority] =
+ GetPriorityCode(priority);
+ }
+ }
+
+ // We haven't send HMI level to HMI in case it FULL.
+ if (hmi_apis::Common_HMILevel::INVALID_ENUM != level &&
+ hmi_apis::Common_HMILevel::FULL != level) {
+ (*message)[strings::msg_params][strings::activate_app_hmi_level] = level;
+ }
+
+ application_manager.ManageHMICommand(message);
+}
+#endif // SDL_REMOTE_CONTROL
+
mobile_apis::HMILevel::eType MessageHelper::StringToHMILevel(
const std::string& hmi_level) {
using namespace NsSmartDeviceLink::NsSmartObjects;
@@ -619,8 +708,8 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateBlockedByPoliciesResponse(
(*response)[strings::params][strings::connection_key] = connection_key;
(*response)[strings::params][strings::protocol_type] =
commands::CommandImpl::mobile_protocol_type_;
- (*response)[strings::params][strings::protocol_version] =
- static_cast<int>(kV2);
+ (*response)[strings::params][strings::protocol_version] = static_cast<int>(
+ protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_2);
return response;
}
@@ -637,9 +726,12 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateDeviceListSO(
smart_objects::SmartObject(smart_objects::SmartType_Array);
smart_objects::SmartObject& list_so = (*device_list_so)[strings::device_list];
- int32_t index = 0;
+ uint32_t index = 0;
+ // According to requirements, SDL should send info about 100 devices at
+ // maximum, even if SDL has more devices connected.
+ const uint32_t max_device_count = 100;
for (connection_handler::DeviceMap::const_iterator it = devices.begin();
- devices.end() != it;
+ devices.end() != it && index < max_device_count;
++it) {
const connection_handler::Device& d =
static_cast<connection_handler::Device>(it->second);
@@ -1445,8 +1537,6 @@ smart_objects::SmartObjectSPtr MessageHelper::GetBCActivateAppRequestToHMI(
if (send_policy_priority) {
std::string priority;
- // TODO(KKolodiy): need remove method policy_manager
-
policy_handler.GetPriority(app->policy_app_id(), &priority);
// According SDLAQ-CRS-2794
// SDL have to send ActivateApp without "proirity" parameter to HMI.
@@ -1745,6 +1835,26 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateNegativeResponse(
return utils::MakeShared<smart_objects::SmartObject>(response_data);
}
+void MessageHelper::SendNaviSetVideoConfig(
+ int32_t app_id,
+ ApplicationManager& app_mngr,
+ const smart_objects::SmartObject& video_params) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ smart_objects::SmartObjectSPtr request =
+ CreateRequestObject(app_mngr.GetNextHMICorrelationID());
+ if (!request) {
+ return;
+ }
+
+ (*request)[strings::params][strings::function_id] =
+ hmi_apis::FunctionID::Navigation_SetVideoConfig;
+
+ (*request)[strings::msg_params][strings::app_id] = app_id;
+ (*request)[strings::msg_params][strings::config] = video_params;
+
+ app_mngr.ManageHMICommand(request);
+}
+
void MessageHelper::SendNaviStartStream(const int32_t app_id,
ApplicationManager& app_mngr) {
LOG4CXX_AUTO_TRACE(logger_);
diff --git a/src/components/application_manager/src/mobile_command_factory.cc b/src/components/application_manager/src/mobile_command_factory.cc
index 688bacf1ac..f6f9cab7f5 100644
--- a/src/components/application_manager/src/mobile_command_factory.cc
+++ b/src/components/application_manager/src/mobile_command_factory.cc
@@ -2,6 +2,9 @@
Copyright (c) 2013, Ford Motor Company
All rights reserved.
+ Copyright (c) 2017 Xevo Inc.
+ All rights reserved.
+
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -13,7 +16,7 @@
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
+ Neither the name of the copyright holders nor the names of their contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
@@ -56,6 +59,8 @@
#include "application_manager/commands/mobile/generic_response.h"
#include "application_manager/commands/mobile/get_dtcs_request.h"
#include "application_manager/commands/mobile/get_dtcs_response.h"
+#include "application_manager/commands/mobile/get_system_capability_request.h"
+#include "application_manager/commands/mobile/get_system_capability_response.h"
#include "application_manager/commands/mobile/get_vehicle_data_request.h"
#include "application_manager/commands/mobile/get_vehicle_data_response.h"
#include "application_manager/commands/mobile/get_way_points_request.h"
@@ -133,6 +138,8 @@
#include "application_manager/commands/mobile/send_location_response.h"
#include "application_manager/commands/mobile/dial_number_request.h"
#include "application_manager/commands/mobile/dial_number_response.h"
+#include "application_manager/commands/mobile/send_haptic_data_request.h"
+#include "application_manager/commands/mobile/send_haptic_data_response.h"
#include "interfaces/MOBILE_API.h"
#include "utils/make_shared.h"
@@ -450,6 +457,17 @@ CommandSharedPtr MobileCommandFactory::CreateCommand(
}
break;
}
+ case mobile_apis::FunctionID::GetSystemCapabilityID: {
+ if ((*message)[strings::params][strings::message_type] ==
+ static_cast<int>(application_manager::MessageType::kResponse)) {
+ command.reset(new commands::GetSystemCapabilityResponse(
+ message, application_manager));
+ } else {
+ command.reset(new commands::GetSystemCapabilityRequest(
+ message, application_manager));
+ }
+ break;
+ }
case mobile_apis::FunctionID::ReadDIDID: {
if ((*message)[strings::params][strings::message_type] ==
static_cast<int>(application_manager::MessageType::kResponse)) {
@@ -604,6 +622,17 @@ CommandSharedPtr MobileCommandFactory::CreateCommand(
}
break;
}
+ case mobile_apis::FunctionID::SendHapticDataID: {
+ if ((*message)[strings::params][strings::message_type] ==
+ static_cast<int>(application_manager::MessageType::kResponse)) {
+ command.reset(
+ new commands::SendHapticDataResponse(message, application_manager));
+ } else {
+ command.reset(
+ new commands::SendHapticDataRequest(message, application_manager));
+ }
+ break;
+ }
case mobile_apis::FunctionID::OnButtonEventID: {
command.reset(new commands::mobile::OnButtonEventNotification(
message, application_manager));
diff --git a/src/components/application_manager/src/mobile_message_handler.cc b/src/components/application_manager/src/mobile_message_handler.cc
index b635cb1f84..f7beea670e 100644
--- a/src/components/application_manager/src/mobile_message_handler.cc
+++ b/src/components/application_manager/src/mobile_message_handler.cc
@@ -67,26 +67,31 @@ MobileMessageHandler::HandleIncomingMessageProtocol(
DCHECK_OR_RETURN(message, NULL);
application_manager::Message* out_message = NULL;
switch (message->protocol_version()) {
- case ProtocolVersion::kV1:
+ case protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_1:
LOG4CXX_DEBUG(logger_, "Protocol version - V1");
out_message =
MobileMessageHandler::HandleIncomingMessageProtocolV1(message);
break;
- case ProtocolVersion::kV2:
+ case protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_2:
LOG4CXX_DEBUG(logger_, "Protocol version - V2");
out_message =
MobileMessageHandler::HandleIncomingMessageProtocolV2(message);
break;
- case ProtocolVersion::kV3:
+ case protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_3:
LOG4CXX_DEBUG(logger_, "Protocol version - V3");
out_message =
MobileMessageHandler::HandleIncomingMessageProtocolV2(message);
break;
- case ProtocolVersion::kV4:
+ case protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_4:
LOG4CXX_DEBUG(logger_, "Protocol version - V4");
out_message =
MobileMessageHandler::HandleIncomingMessageProtocolV2(message);
break;
+ case protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5:
+ LOG4CXX_DEBUG(logger_, "Protocol version - V5");
+ out_message =
+ MobileMessageHandler::HandleIncomingMessageProtocolV2(message);
+ break;
default:
LOG4CXX_WARN(logger_, "Can't recognise protocol version");
out_message = NULL;
@@ -116,12 +121,13 @@ MobileMessageHandler::HandleOutgoingMessageProtocol(
<< message->correlation_id() << ", "
<< message->json_message());
- if (message->protocol_version() == application_manager::kV1) {
+ if (message->protocol_version() ==
+ protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_1) {
return MobileMessageHandler::HandleOutgoingMessageProtocolV1(message);
}
- if ((message->protocol_version() == application_manager::kV2) ||
- (message->protocol_version() == application_manager::kV3) ||
- (message->protocol_version() == application_manager::kV4)) {
+ if (Message::is_sufficient_version(
+ protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_2,
+ message->protocol_version())) {
return MobileMessageHandler::HandleOutgoingMessageProtocolV2(message);
}
return NULL;
@@ -142,7 +148,7 @@ MobileMessageHandler::HandleIncomingMessageProtocolV1(
outgoing_message->set_connection_key(message->connection_key());
outgoing_message->set_protocol_version(
- static_cast<application_manager::ProtocolVersion>(
+ static_cast<protocol_handler::MajorProtocolVersion>(
message->protocol_version()));
outgoing_message->set_json_message(std::string(
reinterpret_cast<const char*>(message->data()), message->data_size()));
@@ -184,7 +190,7 @@ MobileMessageHandler::HandleIncomingMessageProtocolV2(
outgoing_message->set_correlation_id(int32_t(payload.header.correlation_id));
outgoing_message->set_connection_key(message->connection_key());
outgoing_message->set_protocol_version(
- static_cast<application_manager::ProtocolVersion>(
+ static_cast<protocol_handler::MajorProtocolVersion>(
message->protocol_version()));
outgoing_message->set_data_size(message->data_size());
outgoing_message->set_payload_size(message->payload_size());
diff --git a/src/components/application_manager/src/policies/delegates/statistics_delegate.cc b/src/components/application_manager/src/policies/delegates/statistics_delegate.cc
index 11c1dc9a91..e668be4ed1 100644
--- a/src/components/application_manager/src/policies/delegates/statistics_delegate.cc
+++ b/src/components/application_manager/src/policies/delegates/statistics_delegate.cc
@@ -39,6 +39,9 @@ StatisticsDelegate::StatisticsDelegate(PolicyHandler& policy_handler,
usage_statistics::GlobalCounterId type)
: type_(INCREMENT_GLOBAL)
, global_counter_(type)
+ , app_counter_(usage_statistics::AppCounterId::APP_COUNTER_NONE)
+ , app_info_(usage_statistics::AppInfoId::APP_INFO_NONE)
+ , stop_watch_(usage_statistics::AppStopwatchId::STOPWATCH_NONE)
, app_id_("")
, value_("")
, timespan_seconds_(0)
@@ -48,7 +51,10 @@ StatisticsDelegate::StatisticsDelegate(PolicyHandler& policy_handler,
const std::string& app_id,
usage_statistics::AppCounterId type)
: type_(INCREMENT_APP)
+ , global_counter_(usage_statistics::GlobalCounterId::GLOBAL_COUNTER_NONE)
, app_counter_(type)
+ , app_info_(usage_statistics::AppInfoId::APP_INFO_NONE)
+ , stop_watch_(usage_statistics::AppStopwatchId::STOPWATCH_NONE)
, app_id_(app_id)
, value_("")
, timespan_seconds_(0)
@@ -59,7 +65,10 @@ StatisticsDelegate::StatisticsDelegate(PolicyHandler& policy_handler,
usage_statistics::AppInfoId type,
const std::string& value)
: type_(SET)
+ , global_counter_(usage_statistics::GlobalCounterId::GLOBAL_COUNTER_NONE)
+ , app_counter_(usage_statistics::AppCounterId::APP_COUNTER_NONE)
, app_info_(type)
+ , stop_watch_(usage_statistics::AppStopwatchId::STOPWATCH_NONE)
, app_id_(app_id)
, value_(value)
, timespan_seconds_(0)
@@ -70,6 +79,9 @@ StatisticsDelegate::StatisticsDelegate(PolicyHandler& policy_handler,
usage_statistics::AppStopwatchId type,
int32_t timespan_seconds)
: type_(ADD)
+ , global_counter_(usage_statistics::GlobalCounterId::GLOBAL_COUNTER_NONE)
+ , app_counter_(usage_statistics::AppCounterId::APP_COUNTER_NONE)
+ , app_info_(usage_statistics::AppInfoId::APP_INFO_NONE)
, stop_watch_(type)
, app_id_(app_id)
, value_("")
diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc
index 840b1ae0f8..ad21f533a1 100644
--- a/src/components/application_manager/src/policies/policy_handler.cc
+++ b/src/components/application_manager/src/policies/policy_handler.cc
@@ -55,6 +55,9 @@
#include "utils/scope_guard.h"
#include "utils/make_shared.h"
#include "policy/policy_manager.h"
+#ifdef SDL_REMOTE_CONTROL
+#include "functional_module/plugin_manager.h"
+#endif // SDL_REMOTE_CONTROL
namespace policy {
@@ -64,31 +67,32 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "PolicyHandler")
namespace {
using namespace mobile_apis;
-typedef std::map<RequestType::eType, std::string> RequestTypeMap;
+typedef std::map<mobile_apis::RequestType::eType, std::string> RequestTypeMap;
RequestTypeMap TypeToString = {
- {RequestType::INVALID_ENUM, "INVALID_ENUM"},
- {RequestType::HTTP, "HTTP"},
- {RequestType::FILE_RESUME, "FILE_RESUME"},
- {RequestType::AUTH_REQUEST, "AUTH_REQUEST"},
- {RequestType::AUTH_CHALLENGE, "AUTH_CHALLENGE"},
- {RequestType::AUTH_ACK, "AUTH_ACK"},
- {RequestType::PROPRIETARY, "PROPRIETARY"},
- {RequestType::QUERY_APPS, "QUERY_APPS"},
- {RequestType::LAUNCH_APP, "LAUNCH_APP"},
- {RequestType::LOCK_SCREEN_ICON_URL, "LOCK_SCREEN_ICON_URL"},
- {RequestType::TRAFFIC_MESSAGE_CHANNEL, "TRAFFIC_MESSAGE_CHANNEL"},
- {RequestType::DRIVER_PROFILE, "DRIVER_PROFILE"},
- {RequestType::VOICE_SEARCH, "VOICE_SEARCH"},
- {RequestType::NAVIGATION, "NAVIGATION"},
- {RequestType::PHONE, "PHONE"},
- {RequestType::CLIMATE, "CLIMATE"},
- {RequestType::SETTINGS, "SETTINGS"},
- {RequestType::VEHICLE_DIAGNOSTICS, "VEHICLE_DIAGNOSTICS"},
- {RequestType::EMERGENCY, "EMERGENCY"},
- {RequestType::MEDIA, "MEDIA"},
- {RequestType::FOTA, "FOTA"}};
-
-const std::string RequestTypeToString(RequestType::eType type) {
+ {mobile_apis::RequestType::INVALID_ENUM, "INVALID_ENUM"},
+ {mobile_apis::RequestType::HTTP, "HTTP"},
+ {mobile_apis::RequestType::FILE_RESUME, "FILE_RESUME"},
+ {mobile_apis::RequestType::AUTH_REQUEST, "AUTH_REQUEST"},
+ {mobile_apis::RequestType::AUTH_CHALLENGE, "AUTH_CHALLENGE"},
+ {mobile_apis::RequestType::AUTH_ACK, "AUTH_ACK"},
+ {mobile_apis::RequestType::PROPRIETARY, "PROPRIETARY"},
+ {mobile_apis::RequestType::QUERY_APPS, "QUERY_APPS"},
+ {mobile_apis::RequestType::LAUNCH_APP, "LAUNCH_APP"},
+ {mobile_apis::RequestType::LOCK_SCREEN_ICON_URL, "LOCK_SCREEN_ICON_URL"},
+ {mobile_apis::RequestType::TRAFFIC_MESSAGE_CHANNEL,
+ "TRAFFIC_MESSAGE_CHANNEL"},
+ {mobile_apis::RequestType::DRIVER_PROFILE, "DRIVER_PROFILE"},
+ {mobile_apis::RequestType::VOICE_SEARCH, "VOICE_SEARCH"},
+ {mobile_apis::RequestType::NAVIGATION, "NAVIGATION"},
+ {mobile_apis::RequestType::PHONE, "PHONE"},
+ {mobile_apis::RequestType::CLIMATE, "CLIMATE"},
+ {mobile_apis::RequestType::SETTINGS, "SETTINGS"},
+ {mobile_apis::RequestType::VEHICLE_DIAGNOSTICS, "VEHICLE_DIAGNOSTICS"},
+ {mobile_apis::RequestType::EMERGENCY, "EMERGENCY"},
+ {mobile_apis::RequestType::MEDIA, "MEDIA"},
+ {mobile_apis::RequestType::FOTA, "FOTA"}};
+
+const std::string RequestTypeToString(mobile_apis::RequestType::eType type) {
RequestTypeMap::const_iterator it = TypeToString.find(type);
if (TypeToString.end() != it) {
return (*it).second;
@@ -471,8 +475,12 @@ void PolicyHandler::OnDeviceConsentChanged(const std::string& device_id,
const bool is_allowed) {
POLICY_LIB_CHECK_VOID();
connection_handler::DeviceHandle device_handle;
- application_manager_.connection_handler().GetDeviceID(device_id,
- &device_handle);
+ if (!application_manager_.connection_handler().GetDeviceID(device_id,
+ &device_handle)) {
+ LOG4CXX_ERROR(logger_,
+ "Unable to get device handle for device_id: " << device_id);
+ return;
+ }
// In case of changed consent for device, related applications will be
// limited to pre_DataConsent permissions, if device disallowed, or switch
// back to their own permissions, if device allowed again, and must be
@@ -1021,16 +1029,8 @@ bool PolicyHandler::SendMessageToSDK(const BinaryMessage& pt_string,
LOG4CXX_AUTO_TRACE(logger_);
POLICY_LIB_CHECK(false);
- ApplicationSharedPtr app;
- uint32_t app_id = 0;
- if (last_used_app_ids_.empty()) {
- LOG4CXX_WARN(logger_, "last_used_app_ids_ is empty");
- return false;
- } else {
- app_id = last_used_app_ids_.back();
-
- app = application_manager_.application(app_id);
- }
+ const uint32_t app_id = GetAppIdForSending();
+ ApplicationSharedPtr app = application_manager_.application(app_id);
if (!app) {
LOG4CXX_WARN(logger_,
@@ -1187,6 +1187,10 @@ void PolicyHandler::OnAllowSDLFunctionalityNotification(
accessor.GetData().end(),
DeactivateApplication(device_handle,
application_manager_.state_controller()));
+#ifdef SDL_REMOTE_CONTROL
+ application_manager_.GetPluginManager().OnPolicyEvent(
+ functional_modules::PolicyEvent::kApplicationsDisabled);
+#endif // SDL_REMOTE_CONTROL
} else {
std::for_each(
accessor.GetData().begin(),
@@ -1195,7 +1199,6 @@ void PolicyHandler::OnAllowSDLFunctionalityNotification(
policy_manager_.get(),
application_manager_.state_controller()));
}
-
#endif // EXTERNAL_PROPRIETARY_MODE
}
}
@@ -1573,11 +1576,11 @@ uint32_t PolicyHandler::NextRetryTimeout() {
return policy_manager_->NextRetryTimeout();
}
-uint32_t PolicyHandler::TimeoutExchangeSec() {
+uint32_t PolicyHandler::TimeoutExchangeSec() const {
return TimeoutExchangeMSec() / date_time::DateTime::MILLISECONDS_IN_SECOND;
}
-uint32_t PolicyHandler::TimeoutExchangeMSec() {
+uint32_t PolicyHandler::TimeoutExchangeMSec() const {
POLICY_LIB_CHECK(0);
return policy_manager_->TimeoutExchangeMSec();
}
@@ -1950,4 +1953,141 @@ bool PolicyHandler::IsUrlAppIdValid(const uint32_t app_idx,
return ((is_registered && !is_empty_urls) || is_default);
}
+
+#ifdef SDL_REMOTE_CONTROL
+
+std::vector<std::string> PolicyHandler::GetDevicesIds(
+ const std::string& policy_app_id) {
+ return application_manager_.devices(policy_app_id);
+}
+
+void PolicyHandler::UpdateHMILevel(ApplicationSharedPtr app,
+ mobile_apis::HMILevel::eType level) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ DCHECK_OR_RETURN_VOID(app);
+ if (app->hmi_level() == mobile_apis::HMILevel::HMI_NONE) {
+ // If default is FULL, send request to HMI. Notification to mobile will be
+ // sent on response receiving.
+ if (mobile_apis::HMILevel::HMI_FULL == level) {
+ MessageHelper::SendActivateAppToHMI(app->app_id(), application_manager_);
+ } else {
+ LOG4CXX_INFO(logger_,
+ "Changing hmi level of application "
+ << app->app_id() << " to default hmi level " << level);
+ // Set application hmi level
+ application_manager_.ChangeAppsHMILevel(app->app_id(), level);
+ // If hmi Level is full, it will be seted after ActivateApp response
+ MessageHelper::SendHMIStatusNotification(*app, application_manager_);
+ }
+ }
+}
+
+bool PolicyHandler::CheckModule(const PTString& app_id,
+ const PTString& module) {
+ POLICY_LIB_CHECK(false);
+ return policy_manager_->CheckModule(app_id, module);
+}
+
+void PolicyHandler::OnRemoteAppPermissionsChanged(
+ const std::string& device_id, const std::string& application_id) {
+ POLICY_LIB_CHECK_VOID();
+ policy_manager_->SendAppPermissionsChanged(device_id, application_id);
+}
+
+void PolicyHandler::OnUpdateHMIStatus(const std::string& device_id,
+ const std::string& policy_app_id,
+ const std::string& hmi_level) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ ApplicationSharedPtr app =
+ application_manager_.application(device_id, policy_app_id);
+ if (!app) {
+ LOG4CXX_WARN(logger_,
+ "Could not find application: " << device_id << " - "
+ << policy_app_id);
+ return;
+ }
+ mobile_apis::HMILevel::eType level =
+ MessageHelper::StringToHMILevel(hmi_level);
+ if (mobile_apis::HMILevel::INVALID_ENUM == level) {
+ LOG4CXX_WARN(logger_,
+ "Couldn't convert default hmi level " << hmi_level
+ << " to enum.");
+ return;
+ }
+
+ LOG4CXX_INFO(logger_,
+ "Changing hmi level of application "
+ << app->app_id() << " to default hmi level " << level);
+ // Set application hmi level
+ application_manager_.ChangeAppsHMILevel(app->app_id(), level);
+ MessageHelper::SendHMIStatusNotification(*app, application_manager_);
+}
+
+bool PolicyHandler::GetModuleTypes(const std::string& policy_app_id,
+ std::vector<std::string>* modules) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ POLICY_LIB_CHECK(false);
+ return policy_manager_->GetModuleTypes(policy_app_id, modules);
+}
+
+void PolicyHandler::SetDefaultHmiTypes(
+ const std::string& application_id,
+ const smart_objects::SmartObject* app_types) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ POLICY_LIB_CHECK_VOID();
+ std::vector<int> hmi_types;
+ if (app_types && app_types->asArray()) {
+ smart_objects::SmartArray* hmi_list = app_types->asArray();
+ std::transform(hmi_list->begin(),
+ hmi_list->end(),
+ std::back_inserter(hmi_types),
+ SmartObjectToInt());
+ }
+ policy_manager_->SetDefaultHmiTypes(application_id, hmi_types);
+}
+
+bool PolicyHandler::CheckHMIType(const std::string& application_id,
+ mobile_apis::AppHMIType::eType hmi,
+ const smart_objects::SmartObject* app_types) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ POLICY_LIB_CHECK(false);
+ std::vector<int> policy_hmi_types;
+ bool ret = policy_manager_->GetHMITypes(application_id, &policy_hmi_types);
+
+ std::vector<int> additional_hmi_types;
+ if (app_types && app_types->asArray()) {
+ smart_objects::SmartArray* hmi_list = app_types->asArray();
+ std::transform(hmi_list->begin(),
+ hmi_list->end(),
+ std::back_inserter(additional_hmi_types),
+ SmartObjectToInt());
+ }
+ const std::vector<int>& hmi_types =
+ ret ? policy_hmi_types : additional_hmi_types;
+ return std::find(hmi_types.begin(), hmi_types.end(), hmi) != hmi_types.end();
+}
+
+void PolicyHandler::OnUpdateHMILevel(const std::string& device_id,
+ const std::string& policy_app_id,
+ const std::string& hmi_level) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ ApplicationSharedPtr app =
+ application_manager_.application(device_id, policy_app_id);
+ if (!app) {
+ LOG4CXX_WARN(logger_,
+ "Could not find application: " << device_id << " - "
+ << policy_app_id);
+ return;
+ }
+ mobile_apis::HMILevel::eType level =
+ MessageHelper::StringToHMILevel(hmi_level);
+ if (mobile_apis::HMILevel::INVALID_ENUM == level) {
+ LOG4CXX_WARN(logger_,
+ "Couldn't convert default hmi level " << hmi_level
+ << " to enum.");
+ return;
+ }
+ UpdateHMILevel(app, level);
+}
+#endif // SDL_REMOTE_CONTROL
} // namespace policy
diff --git a/src/components/application_manager/src/request_controller.cc b/src/components/application_manager/src/request_controller.cc
index 77a1853a39..1b9bd7ffb9 100644
--- a/src/components/application_manager/src/request_controller.cc
+++ b/src/components/application_manager/src/request_controller.cc
@@ -63,8 +63,11 @@ RequestController::RequestController(const RequestControlerSettings& settings)
RequestController::~RequestController() {
LOG4CXX_AUTO_TRACE(logger_);
- timer_stop_flag_ = true;
- timer_condition_.Broadcast();
+ {
+ sync_primitives::AutoLock auto_lock(timer_lock);
+ timer_stop_flag_ = true;
+ timer_condition_.Broadcast();
+ }
timer_.Stop();
if (pool_state_ != TPoolState::STOPPED) {
DestroyThreadpool();
@@ -370,11 +373,11 @@ void RequestController::TimeoutThread() {
LOG4CXX_DEBUG(
logger_,
"ENTER Waiting fore response count: " << waiting_for_response_.Size());
+ sync_primitives::AutoLock auto_lock(timer_lock);
while (!timer_stop_flag_) {
RequestInfoPtr probably_expired =
waiting_for_response_.FrontWithNotNullTimeout();
if (!probably_expired) {
- sync_primitives::AutoLock auto_lock(timer_lock);
timer_condition_.Wait(auto_lock);
continue;
}
@@ -388,7 +391,6 @@ void RequestController::TimeoutThread() {
<< " request id: " << probably_expired->requestId()
<< " connection_key: " << probably_expired->app_id()
<< " NOT expired");
- sync_primitives::AutoLock auto_lock(timer_lock);
const TimevalStruct current_time = date_time::DateTime::getCurrentTime();
const TimevalStruct end_time = probably_expired->end_time();
if (current_time < end_time) {
diff --git a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc
index ad50bbf104..e7788bf9ff 100644
--- a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc
+++ b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc
@@ -644,7 +644,7 @@ bool ResumeCtrlImpl::DisconnectedJustBeforeIgnOff(
DCHECK_OR_RETURN(saved_app.keyExists(strings::time_stamp), false);
const time_t time_stamp =
- static_cast<time_t>(saved_app[strings::time_stamp].asUInt());
+ static_cast<time_t>(saved_app[strings::time_stamp].asInt());
time_t ign_off_time =
static_cast<time_t>(resumption_storage_->GetIgnOffTime());
const uint32_t sec_spent_before_ign = labs(ign_off_time - time_stamp);
@@ -798,9 +798,13 @@ void ResumeCtrlImpl::OnAppRegistrationEnd() {
int32_t ResumeCtrlImpl::GetSavedAppHmiLevel(
const std::string& app_id, const std::string& device_id) const {
+ using namespace mobile_apis;
smart_objects::SmartObject saved_app;
if (resumption_storage_->GetSavedApplication(app_id, device_id, saved_app)) {
- const int32_t saved_hmi_level = saved_app[strings::hmi_level].asInt();
+ const HMILevel::eType saved_hmi_level =
+ static_cast<mobile_apis::HMILevel::eType>(
+ saved_app[strings::hmi_level].asInt());
+
return saved_hmi_level;
}
return static_cast<int32_t>(mobile_apis::HMILevel::INVALID_ENUM);
diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc
index 99d9e4122a..d5041ef836 100644
--- a/src/components/application_manager/src/smart_object_keys.cc
+++ b/src/components/application_manager/src/smart_object_keys.cc
@@ -134,6 +134,13 @@ const char* audio_pass_thru_capabilities = "audioPassThruCapabilities";
const char* pcm_stream_capabilities = "pcmStreamCapabilities";
const char* audio_pass_thru_icon = "audioPassThruIcon";
const char* way_points = "wayPoints";
+const char* system_capability = "systemCapability";
+const char* system_capability_type = "systemCapabilityType";
+const char* system_capabilities = "systemCapabilities";
+const char* navigation_capability = "navigationCapability";
+const char* phone_capability = "phoneCapability";
+const char* video_streaming_capability = "videoStreamingCapability";
+const char* rc_capability = "remoteControlCapability";
// PutFile
const char* sync_file_name = "syncFileName";
@@ -225,6 +232,7 @@ const char* supported_diag_modes = "supportedDiagModes";
const char* hmi_capabilities = "hmiCapabilities";
const char* navigation = "navigation";
const char* phone_call = "phoneCall";
+const char* video_streaming = "videoStreaming";
const char* sdl_version = "sdlVersion";
const char* system_software_version = "systemSoftwareVersion";
const char* priority = "priority";
@@ -293,6 +301,22 @@ const char* const status = "status";
const char* const external_consent_status = "externalConsentStatus";
const char* const consented_functions = "consentedFunctions";
const char* const source = "source";
+const char* const config = "config";
+const char* const protocol = "protocol";
+const char* const codec = "codec";
+const char* const width = "width";
+const char* const height = "height";
+const char* const rejected_params = "rejectedParams";
+const char* const preferred_resolution = "preferredResolution";
+const char* const resolution_width = "resolutionWidth";
+const char* const resolution_height = "resolutionHeight";
+const char* const max_bitrate = "maxBitrate";
+const char* const supported_formats = "supportedFormats";
+const char* const haptic_spatial_data_supported = "hapticSpatialDataSupported";
+const char* const haptic_rect_data = "hapticRectData";
+const char* const rect = "rect";
+const char* const x = "x";
+const char* const y = "y";
} // namespace strings
namespace json {
diff --git a/src/components/application_manager/src/state_controller_impl.cc b/src/components/application_manager/src/state_controller_impl.cc
index 06a7e508e5..b456ff6abb 100644
--- a/src/components/application_manager/src/state_controller_impl.cc
+++ b/src/components/application_manager/src/state_controller_impl.cc
@@ -363,9 +363,9 @@ bool StateControllerImpl::IsResumptionAllowed(ApplicationSharedPtr app,
}
if (IsTempStateActive(HmiState::StateID::STATE_ID_EMBEDDED_NAVI) &&
- app->is_navi()) {
+ (app->is_navi() || app->mobile_projection_enabled())) {
LOG4CXX_DEBUG(logger_,
- "Resumption for navi app is not allowed. "
+ "Resumption for navi or projection app is not allowed. "
<< "EMBEDDED_NAVI event is active");
return false;
}
@@ -556,12 +556,19 @@ bool StateControllerImpl::IsSameAppType(ApplicationConstSharedPtr app1,
ApplicationConstSharedPtr app2) {
const bool both_media =
app1->is_media_application() && app2->is_media_application();
+
const bool both_navi = app1->is_navi() && app2->is_navi();
+
const bool both_vc = app1->is_voice_communication_supported() &&
app2->is_voice_communication_supported();
+
const bool both_simple =
!app1->IsAudioApplication() && !app2->IsAudioApplication();
- return both_simple || both_media || both_navi || both_vc;
+
+ const bool both_projection =
+ app1->mobile_projection_enabled() && app2->mobile_projection_enabled();
+
+ return both_simple || both_media || both_navi || both_vc || both_projection;
}
void StateControllerImpl::on_event(const event_engine::Event& event) {
diff --git a/src/components/application_manager/test/CMakeLists.txt b/src/components/application_manager/test/CMakeLists.txt
index dba8d99a62..089f8fd25e 100644
--- a/src/components/application_manager/test/CMakeLists.txt
+++ b/src/components/application_manager/test/CMakeLists.txt
@@ -45,12 +45,13 @@ include_directories(
${COMPONENTS_DIR}/resumption/include/
${COMPONENTS_DIR}/utils/include/
${POLICY_PATH}/include/
+ ${COMPONENTS_DIR}/policy/policy_regular/test/include
${POLICY_PATH}/policy/test/include/
${POLICY_MOCK_INCLUDE_PATH}/
${COMPONENTS_DIR}/media_manager/include/
${COMPONENTS_DIR}/security_manager/include/
- ${COMPONENTS_DIR}/policy/test/include/
${COMPONENTS_DIR}/application_manager/test/include/
+ ${BSON_INCLUDE_DIRECTORY}
)
set(testSources
@@ -68,10 +69,14 @@ set(testSources
${AM_TEST_DIR}/usage_statistics_test.cc
${AM_TEST_DIR}/policy_handler_test.cc
${AM_TEST_DIR}/mock_message_helper.cc
- #${AM_TEST_DIR}/application_manager_impl_test.cc
+ ${AM_TEST_DIR}/application_manager_impl_test.cc
)
+if(REMOTE_CONTROL)
+ list(APPEND testSources ${AM_TEST_DIR}/rc_policy_handler_test.cc)
+endif(REMOTE_CONTROL)
+
set (RequestController_SOURCES
${AM_TEST_DIR}/request_controller/request_controller_test.cc
${AM_TEST_DIR}/mock_message_helper.cc
@@ -97,6 +102,8 @@ set(LIBRARIES
Resumption
ProtocolHandler
SecurityManager
+ bson -L${BSON_LIBS_DIRECTORY}
+ emhashmap -L${EMHASHMAP_LIBS_DIRECTORY}
)
if (${CMAKE_SYSTEM_NAME} MATCHES "QNX")
@@ -123,6 +130,7 @@ set(CMAKE_EXE_LINKER_FLAGS
"${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath=${CMAKE_CURRENT_BINARY_DIR}"
)
create_test("application_manager_test" "${testSources}" "${LIBRARIES}")
+add_dependencies("application_manager_test" libbson)
create_test("request_controller_test" "${RequestController_SOURCES}" "${LIBRARIES}")
# TODO [AKozoriz] : Fix not buildable tests
diff --git a/src/components/application_manager/test/application_impl_test.cc b/src/components/application_manager/test/application_impl_test.cc
index 54414a93de..a1e284b40d 100644
--- a/src/components/application_manager/test/application_impl_test.cc
+++ b/src/components/application_manager/test/application_impl_test.cc
@@ -569,12 +569,14 @@ TEST_F(ApplicationImplTest, ChangeSupportingAppHMIType_TypeNotNaviNotVoice) {
EXPECT_FALSE(app_impl->is_navi());
EXPECT_FALSE(app_impl->is_voice_communication_supported());
+ EXPECT_FALSE(app_impl->mobile_projection_enabled());
app_impl->set_app_types(type_media);
app_impl->ChangeSupportingAppHMIType();
EXPECT_FALSE(app_impl->is_navi());
EXPECT_FALSE(app_impl->is_voice_communication_supported());
+ EXPECT_FALSE(app_impl->mobile_projection_enabled());
}
TEST_F(ApplicationImplTest, ChangeSupportingAppHMIType_TypeIsVoice) {
@@ -583,12 +585,14 @@ TEST_F(ApplicationImplTest, ChangeSupportingAppHMIType_TypeIsVoice) {
EXPECT_FALSE(app_impl->is_navi());
EXPECT_FALSE(app_impl->is_voice_communication_supported());
+ EXPECT_FALSE(app_impl->mobile_projection_enabled());
app_impl->set_app_types(type_comm);
app_impl->ChangeSupportingAppHMIType();
EXPECT_FALSE(app_impl->is_navi());
EXPECT_TRUE(app_impl->is_voice_communication_supported());
+ EXPECT_FALSE(app_impl->mobile_projection_enabled());
}
TEST_F(ApplicationImplTest, ChangeSupportingAppHMIType_TypeIsNavi) {
@@ -597,12 +601,14 @@ TEST_F(ApplicationImplTest, ChangeSupportingAppHMIType_TypeIsNavi) {
EXPECT_FALSE(app_impl->is_navi());
EXPECT_FALSE(app_impl->is_voice_communication_supported());
+ EXPECT_FALSE(app_impl->mobile_projection_enabled());
app_impl->set_app_types(type_navi);
app_impl->ChangeSupportingAppHMIType();
EXPECT_TRUE(app_impl->is_navi());
EXPECT_FALSE(app_impl->is_voice_communication_supported());
+ EXPECT_FALSE(app_impl->mobile_projection_enabled());
}
TEST_F(ApplicationImplTest, ChangeSupportingAppHMIType_TypeIsNaviAndVoice) {
@@ -613,12 +619,34 @@ TEST_F(ApplicationImplTest, ChangeSupportingAppHMIType_TypeIsNaviAndVoice) {
EXPECT_FALSE(app_impl->is_navi());
EXPECT_FALSE(app_impl->is_voice_communication_supported());
+ EXPECT_FALSE(app_impl->mobile_projection_enabled());
app_impl->set_app_types(app_types);
app_impl->ChangeSupportingAppHMIType();
EXPECT_TRUE(app_impl->is_navi());
EXPECT_TRUE(app_impl->is_voice_communication_supported());
+ EXPECT_FALSE(app_impl->mobile_projection_enabled());
+}
+
+TEST_F(ApplicationImplTest,
+ ChangeSupportingAppHMIType_TypeIsNaviAndVoiceAndProjection) {
+ smart_objects::SmartObject app_types;
+ app_types[0] = AppHMIType::NAVIGATION;
+ app_types[1] = AppHMIType::COMMUNICATION;
+ app_types[2] = AppHMIType::MEDIA;
+ app_types[3] = AppHMIType::PROJECTION;
+
+ EXPECT_FALSE(app_impl->is_navi());
+ EXPECT_FALSE(app_impl->is_voice_communication_supported());
+ EXPECT_FALSE(app_impl->mobile_projection_enabled());
+
+ app_impl->set_app_types(app_types);
+ app_impl->ChangeSupportingAppHMIType();
+
+ EXPECT_TRUE(app_impl->is_navi());
+ EXPECT_TRUE(app_impl->is_voice_communication_supported());
+ EXPECT_TRUE(app_impl->mobile_projection_enabled());
}
TEST_F(ApplicationImplTest, UpdateHash_AppMngrNotSuspended) {
@@ -629,6 +657,31 @@ TEST_F(ApplicationImplTest, UpdateHash_AppMngrNotSuspended) {
EXPECT_TRUE(app_impl->is_application_data_changed());
}
+TEST_F(ApplicationImplTest, SetVideoConfig_MobileNavi_StreamingNotApproved) {
+ EXPECT_CALL(*MockMessageHelper::message_helper_mock(),
+ SendNaviSetVideoConfig(app_id, _, _));
+
+ smart_objects::SmartObject params;
+ app_impl->SetVideoConfig(protocol_handler::ServiceType::kMobileNav, params);
+}
+
+TEST_F(ApplicationImplTest, SetVideoConfig_MobileNavi_StreamingApproved) {
+ app_impl->set_video_streaming_approved(true);
+ EXPECT_CALL(*MockMessageHelper::message_helper_mock(),
+ SendNaviSetVideoConfig(app_id, _, _)).Times(0);
+
+ smart_objects::SmartObject params;
+ app_impl->SetVideoConfig(protocol_handler::ServiceType::kMobileNav, params);
+}
+
+TEST_F(ApplicationImplTest, SetVideoConfig_NotMobileNavi) {
+ EXPECT_CALL(*MockMessageHelper::message_helper_mock(),
+ SendNaviSetVideoConfig(app_id, _, _)).Times(0);
+
+ smart_objects::SmartObject params;
+ app_impl->SetVideoConfig(protocol_handler::ServiceType::kAudio, params);
+}
+
TEST_F(ApplicationImplTest, StartStreaming_MobileNavi_StreamingNotApproved) {
EXPECT_CALL(*MockMessageHelper::message_helper_mock(),
SendNaviStartStream(app_id, _));
diff --git a/src/components/application_manager/test/application_manager_impl_test.cc b/src/components/application_manager/test/application_manager_impl_test.cc
index 5b232e1dfc..d19d3cd8ed 100644
--- a/src/components/application_manager/test/application_manager_impl_test.cc
+++ b/src/components/application_manager/test/application_manager_impl_test.cc
@@ -32,11 +32,13 @@
#include <stdint.h>
#include <memory>
#include <set>
+#include <bson_object.h>
#include "gtest/gtest.h"
#include "application_manager/application.h"
#include "application_manager/application_impl.h"
#include "application_manager/application_manager_impl.h"
+#include "application_manager/mock_application.h"
#include "application_manager/mock_application_manager_settings.h"
#include "application_manager/mock_resumption_data.h"
#include "application_manager/resumption/resume_ctrl_impl.h"
@@ -45,6 +47,7 @@
#include "hmi_message_handler/mock_hmi_message_handler.h"
#include "policy/mock_policy_settings.h"
#include "policy/usage_statistics/mock_statistics_manager.h"
+#include "protocol/bson_object_keys.h"
#include "protocol_handler/mock_session_observer.h"
#include "utils/custom_string.h"
#include "utils/file_system.h"
@@ -61,14 +64,22 @@ namespace policy_test = test::components::policy_handler_test;
namespace con_test = connection_handler_test;
using testing::_;
+using ::testing::ByRef;
+using ::testing::DoAll;
using ::testing::Mock;
using ::testing::Return;
using ::testing::ReturnRef;
using ::testing::NiceMock;
+using ::testing::SaveArg;
using ::testing::SetArgPointee;
using namespace application_manager;
+// custom action to call a member function with 4 arguments
+ACTION_P6(InvokeMemberFuncWithArg4, ptr, memberFunc, a, b, c, d) {
+ (ptr->*memberFunc)(a, b, c, d);
+}
+
namespace {
const std::string kDirectoryName = "./test_storage";
const uint32_t kTimeout = 10000u;
@@ -124,8 +135,14 @@ class ApplicationManagerImplTest : public ::testing::Test {
.WillByDefault(ReturnRef(kTimeout));
app_manager_impl_.reset(new am::ApplicationManagerImpl(
mock_application_manager_settings_, mock_policy_settings_));
+ mock_app_ptr_ = utils::SharedPtr<MockApplication>(new MockApplication());
ASSERT_TRUE(app_manager_impl_.get());
+ ASSERT_TRUE(mock_app_ptr_.get());
+ }
+
+ void AddMockApplication() {
+ app_manager_impl_->AddMockApplication(mock_app_ptr_);
}
NiceMock<policy_test::MockPolicySettings> mock_policy_settings_;
@@ -139,6 +156,7 @@ class ApplicationManagerImplTest : public ::testing::Test {
application_manager::MockMessageHelper* mock_message_helper_;
uint32_t app_id_;
application_manager::MessageHelper* message_helper_;
+ utils::SharedPtr<MockApplication> mock_app_ptr_;
};
TEST_F(ApplicationManagerImplTest, ProcessQueryApp_ExpectSuccess) {
@@ -195,6 +213,432 @@ TEST_F(
EXPECT_TRUE(result.find(app_id_) != result.end());
}
+TEST_F(ApplicationManagerImplTest, OnServiceStartedCallback_RpcService) {
+ AddMockApplication();
+
+ const connection_handler::DeviceHandle device_handle = 0;
+ const protocol_handler::ServiceType service_type =
+ protocol_handler::ServiceType::kRpc;
+ const int32_t session_key = 123;
+ EXPECT_CALL(*mock_app_ptr_, app_id()).WillRepeatedly(Return(session_key));
+
+ bool result = false;
+ std::vector<std::string> rejected_params;
+ EXPECT_CALL(mock_connection_handler_, NotifyServiceStartedResult(_, _, _))
+ .WillOnce(DoAll(SaveArg<1>(&result), SaveArg<2>(&rejected_params)));
+
+ app_manager_impl_->OnServiceStartedCallback(
+ device_handle, session_key, service_type, NULL);
+
+ // check: return value is true and list is empty
+ EXPECT_TRUE(result);
+ EXPECT_TRUE(rejected_params.empty());
+}
+
+TEST_F(ApplicationManagerImplTest, OnServiceStartedCallback_UnknownApp) {
+ AddMockApplication();
+
+ const connection_handler::DeviceHandle device_handle = 0;
+ const protocol_handler::ServiceType service_type =
+ protocol_handler::ServiceType::kInvalidServiceType;
+ const int32_t session_key = 123;
+ EXPECT_CALL(*mock_app_ptr_, app_id()).WillRepeatedly(Return(456));
+
+ bool result = false;
+ std::vector<std::string> rejected_params;
+ EXPECT_CALL(mock_connection_handler_, NotifyServiceStartedResult(_, _, _))
+ .WillOnce(DoAll(SaveArg<1>(&result), SaveArg<2>(&rejected_params)));
+
+ app_manager_impl_->OnServiceStartedCallback(
+ device_handle, session_key, service_type, NULL);
+
+ // check: return value is false and list is empty
+ EXPECT_FALSE(result);
+ EXPECT_TRUE(rejected_params.empty());
+}
+
+TEST_F(ApplicationManagerImplTest, OnServiceStartedCallback_UnknownService) {
+ AddMockApplication();
+
+ const connection_handler::DeviceHandle device_handle = 0;
+ const protocol_handler::ServiceType service_type =
+ protocol_handler::ServiceType::kInvalidServiceType;
+ const int32_t session_key = 123;
+ EXPECT_CALL(*mock_app_ptr_, app_id()).WillRepeatedly(Return(session_key));
+
+ bool result = false;
+ std::vector<std::string> rejected_params;
+ EXPECT_CALL(mock_connection_handler_, NotifyServiceStartedResult(_, _, _))
+ .WillOnce(DoAll(SaveArg<1>(&result), SaveArg<2>(&rejected_params)));
+
+ app_manager_impl_->OnServiceStartedCallback(
+ device_handle, session_key, service_type, NULL);
+
+ // check: return value is false and list is empty
+ EXPECT_FALSE(result);
+ EXPECT_TRUE(rejected_params.empty());
+}
+
+TEST_F(ApplicationManagerImplTest, OnServiceStartedCallback_VideoServiceStart) {
+ AddMockApplication();
+
+ const connection_handler::DeviceHandle device_handle = 0;
+ const protocol_handler::ServiceType service_type =
+ protocol_handler::ServiceType::kMobileNav;
+ const int32_t session_key = 123;
+ EXPECT_CALL(*mock_app_ptr_, app_id()).WillRepeatedly(Return(session_key));
+ EXPECT_CALL(*mock_app_ptr_, is_navi()).WillRepeatedly(Return(true));
+ EXPECT_CALL(*mock_app_ptr_, hmi_level())
+ .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL));
+
+ bool result = false;
+ std::vector<std::string> rejected_params;
+ EXPECT_CALL(mock_connection_handler_, NotifyServiceStartedResult(_, _, _))
+ .WillOnce(DoAll(SaveArg<1>(&result), SaveArg<2>(&rejected_params)));
+
+ // check: SetVideoConfig() should not be called, StartStreaming() is called
+ EXPECT_CALL(*mock_app_ptr_, SetVideoConfig(_, _)).Times(0);
+ EXPECT_CALL(*mock_app_ptr_, StartStreaming(service_type)).WillOnce(Return());
+
+ app_manager_impl_->OnServiceStartedCallback(
+ device_handle, session_key, service_type, NULL);
+
+ // check: return value is true and list is empty
+ EXPECT_TRUE(result);
+ EXPECT_TRUE(rejected_params.empty());
+}
+
+TEST_F(ApplicationManagerImplTest,
+ OnServiceStartedCallback_VideoServiceNotStart1) {
+ AddMockApplication();
+
+ const connection_handler::DeviceHandle device_handle = 0;
+ const protocol_handler::ServiceType service_type =
+ protocol_handler::ServiceType::kMobileNav;
+ const int32_t session_key = 123;
+ EXPECT_CALL(*mock_app_ptr_, app_id()).WillRepeatedly(Return(session_key));
+ // is_navi() is false
+ EXPECT_CALL(*mock_app_ptr_, is_navi()).WillRepeatedly(Return(false));
+ EXPECT_CALL(*mock_app_ptr_, hmi_level())
+ .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL));
+
+ bool result = false;
+ std::vector<std::string> rejected_params;
+ EXPECT_CALL(mock_connection_handler_, NotifyServiceStartedResult(_, _, _))
+ .WillOnce(DoAll(SaveArg<1>(&result), SaveArg<2>(&rejected_params)));
+
+ // check: SetVideoConfig() and StartStreaming() should not be called
+ EXPECT_CALL(*mock_app_ptr_, SetVideoConfig(_, _)).Times(0);
+ EXPECT_CALL(*mock_app_ptr_, StartStreaming(service_type)).Times(0);
+
+ app_manager_impl_->OnServiceStartedCallback(
+ device_handle, session_key, service_type, NULL);
+
+ // check: return value is false and list is empty
+ EXPECT_FALSE(result);
+ EXPECT_TRUE(rejected_params.empty());
+}
+
+TEST_F(ApplicationManagerImplTest,
+ OnServiceStartedCallback_VideoServiceNotStart2) {
+ AddMockApplication();
+
+ const connection_handler::DeviceHandle device_handle = 0;
+ const protocol_handler::ServiceType service_type =
+ protocol_handler::ServiceType::kMobileNav;
+ const int32_t session_key = 123;
+ EXPECT_CALL(*mock_app_ptr_, app_id()).WillRepeatedly(Return(session_key));
+ EXPECT_CALL(*mock_app_ptr_, is_navi()).WillRepeatedly(Return(true));
+ // HMI level is not FULL nor LIMITED
+ EXPECT_CALL(*mock_app_ptr_, hmi_level())
+ .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_BACKGROUND));
+
+ bool result = false;
+ std::vector<std::string> rejected_params;
+ EXPECT_CALL(mock_connection_handler_, NotifyServiceStartedResult(_, _, _))
+ .WillOnce(DoAll(SaveArg<1>(&result), SaveArg<2>(&rejected_params)));
+
+ // check: SetVideoConfig() and StartStreaming() should not be called
+ EXPECT_CALL(*mock_app_ptr_, SetVideoConfig(_, _)).Times(0);
+ EXPECT_CALL(*mock_app_ptr_, StartStreaming(service_type)).Times(0);
+
+ app_manager_impl_->OnServiceStartedCallback(
+ device_handle, session_key, service_type, NULL);
+
+ // check: return value is false and list is empty
+ EXPECT_FALSE(result);
+ EXPECT_TRUE(rejected_params.empty());
+}
+
+TEST_F(ApplicationManagerImplTest,
+ OnServiceStartedCallback_VideoSetConfig_SUCCESS) {
+ AddMockApplication();
+
+ const connection_handler::DeviceHandle device_handle = 0;
+ const protocol_handler::ServiceType service_type =
+ protocol_handler::ServiceType::kMobileNav;
+ const int32_t session_key = 123;
+ EXPECT_CALL(*mock_app_ptr_, app_id()).WillRepeatedly(Return(session_key));
+ EXPECT_CALL(*mock_app_ptr_, is_navi()).WillRepeatedly(Return(true));
+ EXPECT_CALL(*mock_app_ptr_, hmi_level())
+ .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_LIMITED));
+
+ bool result = false;
+ std::vector<std::string> rejected_params;
+ EXPECT_CALL(mock_connection_handler_, NotifyServiceStartedResult(_, _, _))
+ .WillOnce(DoAll(SaveArg<1>(&result), SaveArg<2>(&rejected_params)));
+
+ BsonObject input_params;
+ bson_object_initialize_default(&input_params);
+ char protocol_version[] = "1.0.0";
+ bson_object_put_string(&input_params,
+ protocol_handler::strings::protocol_version,
+ protocol_version);
+ bson_object_put_int64(&input_params, protocol_handler::strings::mtu, 100);
+ char protocol_name[] = "RTP";
+ bson_object_put_string(
+ &input_params, protocol_handler::strings::video_protocol, protocol_name);
+ char codec_name[] = "VP9";
+ bson_object_put_string(
+ &input_params, protocol_handler::strings::video_codec, codec_name);
+ bson_object_put_int32(&input_params, protocol_handler::strings::height, 640);
+ bson_object_put_int32(&input_params, protocol_handler::strings::width, 480);
+
+ smart_objects::SmartObject converted_params(smart_objects::SmartType_Map);
+ converted_params[strings::protocol] =
+ hmi_apis::Common_VideoStreamingProtocol::RTP;
+ converted_params[strings::codec] = hmi_apis::Common_VideoStreamingCodec::VP9;
+ converted_params[strings::height] = 640;
+ converted_params[strings::width] = 480;
+
+ std::vector<std::string> empty;
+
+ // check: SetVideoConfig() and StartStreaming() are called
+ EXPECT_CALL(*mock_app_ptr_, SetVideoConfig(service_type, converted_params))
+ .WillOnce(DoAll(InvokeMemberFuncWithArg4(
+ app_manager_impl_.get(),
+ &ApplicationManagerImpl::OnStreamingConfigured,
+ session_key,
+ service_type,
+ true,
+ ByRef(empty)),
+ Return(true)));
+ EXPECT_CALL(*mock_app_ptr_, StartStreaming(service_type)).WillOnce(Return());
+
+ app_manager_impl_->OnServiceStartedCallback(
+ device_handle, session_key, service_type, &input_params);
+
+ // check: return value is true and list is empty
+ EXPECT_TRUE(result);
+ EXPECT_TRUE(rejected_params.empty());
+}
+
+static bool ValidateList(std::vector<std::string>& expected,
+ std::vector<std::string>& actual) {
+ if (expected.size() != actual.size()) {
+ return false;
+ }
+ for (unsigned int i = 0; i < expected.size(); i++) {
+ std::string& param = expected[i];
+ unsigned int j;
+ for (j = 0; j < actual.size(); j++) {
+ if (param == actual[j]) {
+ break;
+ }
+ }
+ if (j == actual.size()) {
+ // not found
+ return false;
+ }
+ }
+ return true;
+}
+
+TEST_F(ApplicationManagerImplTest,
+ OnServiceStartedCallback_VideoSetConfig_FAILURE) {
+ AddMockApplication();
+
+ const connection_handler::DeviceHandle device_handle = 0;
+ const protocol_handler::ServiceType service_type =
+ protocol_handler::ServiceType::kMobileNav;
+ const int32_t session_key = 123;
+ EXPECT_CALL(*mock_app_ptr_, app_id()).WillRepeatedly(Return(session_key));
+ EXPECT_CALL(*mock_app_ptr_, is_navi()).WillRepeatedly(Return(true));
+ EXPECT_CALL(*mock_app_ptr_, hmi_level())
+ .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL));
+
+ bool result = false;
+ std::vector<std::string> rejected_params;
+ EXPECT_CALL(mock_connection_handler_, NotifyServiceStartedResult(_, _, _))
+ .WillOnce(DoAll(SaveArg<1>(&result), SaveArg<2>(&rejected_params)));
+
+ BsonObject input_params;
+ bson_object_initialize_default(&input_params);
+ char protocol_version[] = "1.0.0";
+ bson_object_put_string(&input_params,
+ protocol_handler::strings::protocol_version,
+ protocol_version);
+ bson_object_put_int64(&input_params, protocol_handler::strings::mtu, 100);
+ char protocol_name[] = "RTP";
+ bson_object_put_string(
+ &input_params, protocol_handler::strings::video_protocol, protocol_name);
+ char codec_name[] = "VP9";
+ bson_object_put_string(
+ &input_params, protocol_handler::strings::video_codec, codec_name);
+ bson_object_put_int32(&input_params, protocol_handler::strings::height, 640);
+ bson_object_put_int32(&input_params, protocol_handler::strings::width, 480);
+
+ smart_objects::SmartObject converted_params(smart_objects::SmartType_Map);
+ converted_params[strings::protocol] =
+ hmi_apis::Common_VideoStreamingProtocol::RTP;
+ converted_params[strings::codec] = hmi_apis::Common_VideoStreamingCodec::VP9;
+ converted_params[strings::height] = 640;
+ converted_params[strings::width] = 480;
+
+ std::vector<std::string> rejected_list;
+ rejected_list.push_back(std::string("protocol"));
+ rejected_list.push_back(std::string("codec"));
+
+ // simulate HMI returning negative response
+ EXPECT_CALL(*mock_app_ptr_, SetVideoConfig(service_type, converted_params))
+ .WillOnce(DoAll(InvokeMemberFuncWithArg4(
+ app_manager_impl_.get(),
+ &ApplicationManagerImpl::OnStreamingConfigured,
+ session_key,
+ service_type,
+ false,
+ ByRef(rejected_list)),
+ Return(true)));
+
+ // check: StartStreaming() should not be called
+ EXPECT_CALL(*mock_app_ptr_, StartStreaming(service_type)).Times(0);
+
+ app_manager_impl_->OnServiceStartedCallback(
+ device_handle, session_key, service_type, &input_params);
+
+ // check: return value is false
+ EXPECT_FALSE(result);
+
+ // check: rejected param list contains "videoProtocol" and "videoCodec"
+ ASSERT_EQ(2u, rejected_params.size());
+ std::vector<std::string> expected_list;
+ expected_list.push_back(
+ std::string(protocol_handler::strings::video_protocol));
+ expected_list.push_back(std::string(protocol_handler::strings::video_codec));
+ ASSERT_TRUE(ValidateList(expected_list, rejected_params));
+}
+
+TEST_F(ApplicationManagerImplTest,
+ OnServiceStartedCallback_VideoServiceWithoutVideoParams) {
+ AddMockApplication();
+
+ const connection_handler::DeviceHandle device_handle = 0;
+ const protocol_handler::ServiceType service_type =
+ protocol_handler::ServiceType::kMobileNav;
+ const int32_t session_key = 123;
+ EXPECT_CALL(*mock_app_ptr_, app_id()).WillRepeatedly(Return(session_key));
+ EXPECT_CALL(*mock_app_ptr_, is_navi()).WillRepeatedly(Return(true));
+ EXPECT_CALL(*mock_app_ptr_, hmi_level())
+ .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL));
+
+ bool result = false;
+ std::vector<std::string> rejected_params;
+ EXPECT_CALL(mock_connection_handler_, NotifyServiceStartedResult(_, _, _))
+ .WillOnce(DoAll(SaveArg<1>(&result), SaveArg<2>(&rejected_params)));
+
+ BsonObject input_params;
+ bson_object_initialize_default(&input_params);
+ char protocol_version[] = "1.0.0";
+ bson_object_put_string(&input_params, "protocolVersion", protocol_version);
+ bson_object_put_int64(&input_params, "mtu", 100);
+
+ // check: SetVideoConfig() should not be called, StartStreaming() is called
+ EXPECT_CALL(*mock_app_ptr_, SetVideoConfig(_, _)).Times(0);
+ EXPECT_CALL(*mock_app_ptr_, StartStreaming(service_type)).WillOnce(Return());
+
+ app_manager_impl_->OnServiceStartedCallback(
+ device_handle, session_key, service_type, &input_params);
+
+ // check: return value is true and list is empty
+ EXPECT_TRUE(result);
+ EXPECT_TRUE(rejected_params.empty());
+}
+
+TEST_F(ApplicationManagerImplTest, OnServiceStartedCallback_AudioServiceStart) {
+ AddMockApplication();
+
+ const connection_handler::DeviceHandle device_handle = 0;
+ const protocol_handler::ServiceType service_type =
+ protocol_handler::ServiceType::kAudio;
+ const int32_t session_key = 123;
+ EXPECT_CALL(*mock_app_ptr_, app_id()).WillRepeatedly(Return(session_key));
+ EXPECT_CALL(*mock_app_ptr_, is_navi()).WillRepeatedly(Return(true));
+ EXPECT_CALL(*mock_app_ptr_, hmi_level())
+ .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL));
+
+ bool result = false;
+ std::vector<std::string> rejected_params;
+ EXPECT_CALL(mock_connection_handler_, NotifyServiceStartedResult(_, _, _))
+ .WillOnce(DoAll(SaveArg<1>(&result), SaveArg<2>(&rejected_params)));
+
+ // check: SetVideoConfig() should not be called, StartStreaming() is called
+ EXPECT_CALL(*mock_app_ptr_, SetVideoConfig(_, _)).Times(0);
+ EXPECT_CALL(*mock_app_ptr_, StartStreaming(service_type)).WillOnce(Return());
+
+ app_manager_impl_->OnServiceStartedCallback(
+ device_handle, session_key, service_type, NULL);
+
+ // check: return value is true and list is empty
+ EXPECT_TRUE(result);
+ EXPECT_TRUE(rejected_params.empty());
+}
+
+TEST_F(ApplicationManagerImplTest,
+ OnServiceStartedCallback_AudioServiceWithParams) {
+ AddMockApplication();
+
+ const connection_handler::DeviceHandle device_handle = 0;
+ const protocol_handler::ServiceType service_type =
+ protocol_handler::ServiceType::kAudio;
+ const int32_t session_key = 123;
+ EXPECT_CALL(*mock_app_ptr_, app_id()).WillRepeatedly(Return(session_key));
+ EXPECT_CALL(*mock_app_ptr_, is_navi()).WillRepeatedly(Return(true));
+ EXPECT_CALL(*mock_app_ptr_, hmi_level())
+ .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL));
+
+ bool result = false;
+ std::vector<std::string> rejected_params;
+ EXPECT_CALL(mock_connection_handler_, NotifyServiceStartedResult(_, _, _))
+ .WillOnce(DoAll(SaveArg<1>(&result), SaveArg<2>(&rejected_params)));
+
+ BsonObject input_params;
+ bson_object_initialize_default(&input_params);
+ char protocol_version[] = "1.0.0";
+ bson_object_put_string(&input_params,
+ protocol_handler::strings::protocol_version,
+ protocol_version);
+ bson_object_put_int64(&input_params, protocol_handler::strings::mtu, 100);
+ char protocol_name[] = "RTP";
+ bson_object_put_string(
+ &input_params, protocol_handler::strings::video_protocol, protocol_name);
+ char codec_name[] = "VP9";
+ bson_object_put_string(
+ &input_params, protocol_handler::strings::video_codec, codec_name);
+ bson_object_put_int32(&input_params, protocol_handler::strings::height, 640);
+ bson_object_put_int32(&input_params, protocol_handler::strings::width, 480);
+
+ // check: SetVideoConfig() should not be called, StartStreaming() is called
+ EXPECT_CALL(*mock_app_ptr_, SetVideoConfig(_, _)).Times(0);
+ EXPECT_CALL(*mock_app_ptr_, StartStreaming(service_type)).WillOnce(Return());
+
+ app_manager_impl_->OnServiceStartedCallback(
+ device_handle, session_key, service_type, &input_params);
+
+ // check: return value is true and list is empty
+ EXPECT_TRUE(result);
+ EXPECT_TRUE(rejected_params.empty());
+}
+
} // application_manager_test
} // namespace components
} // namespace test
diff --git a/src/components/application_manager/test/commands/CMakeLists.txt b/src/components/application_manager/test/commands/CMakeLists.txt
index e22d1434a7..cc16e4d87b 100644
--- a/src/components/application_manager/test/commands/CMakeLists.txt
+++ b/src/components/application_manager/test/commands/CMakeLists.txt
@@ -44,8 +44,10 @@ include_directories(
set(COMMANDS_TEST_DIR ${AM_TEST_DIR}/commands)
file(GLOB SOURCES
+ ${COMMANDS_TEST_DIR}/*
${COMPONENTS_DIR}/application_manager/test/mock_message_helper.cc
${COMPONENTS_DIR}/application_manager/src/smart_object_keys.cc
+ ${COMPONENTS_DIR}/application_manager/src/message.cc
${COMMANDS_TEST_DIR}/hmi/*
${COMMANDS_TEST_DIR}/hmi/hmi_notifications/*
${COMMANDS_TEST_DIR}/mobile/*
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 2471ec1165..1948608b9f 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
@@ -64,6 +64,7 @@ using ::testing::_;
using ::testing::Return;
using ::testing::SaveArg;
using ::testing::DoAll;
+using ::testing::Mock;
using ::utils::SharedPtr;
using am::commands::MessageSharedPtr;
@@ -121,13 +122,18 @@ class CommandRequestImplTest
CommandParametersPermissions& removed_parameters_permissions() {
return removed_parameters_permissions_;
}
+
+ void SetHashUpdateMode(HashUpdateMode mode) {
+ hash_update_mode_ = mode;
+ }
};
- CommandRequestImplTest() {
- mock_message_helper_ = am::MockMessageHelper::message_helper_mock();
+ CommandRequestImplTest()
+ : mock_message_helper_(*am::MockMessageHelper::message_helper_mock()) {
+ Mock::VerifyAndClearExpectations(&mock_message_helper_);
}
~CommandRequestImplTest() {
- mock_message_helper_ = NULL;
+ Mock::VerifyAndClearExpectations(&mock_message_helper_);
}
MockAppPtr InitAppSetDataAccessor(SharedPtr<ApplicationSet>& app_set) {
@@ -141,7 +147,7 @@ class CommandRequestImplTest
}
sync_primitives::Lock app_set_lock_;
- am::MockMessageHelper* mock_message_helper_;
+ am::MockMessageHelper& mock_message_helper_;
};
typedef CommandRequestImplTest::UnwrappedCommandRequestImpl UCommandRequestImpl;
@@ -173,7 +179,7 @@ TEST_F(CommandRequestImplTest, OnTimeOut_StateAwaitingHMIResponse_SUCCESS) {
CommandPtr command = CreateCommand<UCommandRequestImpl>(msg);
MessageSharedPtr dummy_msg(CreateMessage());
- EXPECT_CALL(*mock_message_helper_, CreateNegativeResponse(_, _, _, _))
+ EXPECT_CALL(mock_message_helper_, CreateNegativeResponse(_, _, _, _))
.WillOnce(Return(dummy_msg));
EXPECT_CALL(
app_mngr_,
@@ -269,12 +275,11 @@ TEST_F(CommandRequestImplTest, SendHMIRequest_NoUseEvent_SUCCESS) {
EXPECT_CALL(app_mngr_, GetNextHMICorrelationID())
.WillOnce(Return(kCorrelationId));
- MockHmiInterfaces hmi_interfaces;
- EXPECT_CALL(app_mngr_, hmi_interfaces()).WillOnce(ReturnRef(hmi_interfaces));
- EXPECT_CALL(hmi_interfaces, GetInterfaceFromFunction(_))
- .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_BasicCommunication));
- EXPECT_CALL(hmi_interfaces, GetInterfaceState(_))
- .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE));
+ EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceFromFunction(_))
+ .WillRepeatedly(
+ Return(am::HmiInterfaces::HMI_INTERFACE_BasicCommunication));
+ EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
+ .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE));
// Return `true` prevents call of `SendResponse` method;
EXPECT_CALL(app_mngr_, ManageHMICommand(_)).WillOnce(Return(true));
@@ -287,12 +292,11 @@ TEST_F(CommandRequestImplTest, SendHMIRequest_UseEvent_SUCCESS) {
EXPECT_CALL(app_mngr_, GetNextHMICorrelationID())
.WillOnce(Return(kCorrelationId));
- MockHmiInterfaces hmi_interfaces;
- EXPECT_CALL(app_mngr_, hmi_interfaces()).WillOnce(ReturnRef(hmi_interfaces));
- EXPECT_CALL(hmi_interfaces, GetInterfaceFromFunction(_))
- .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_BasicCommunication));
- EXPECT_CALL(hmi_interfaces, GetInterfaceState(_))
- .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE));
+ EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceFromFunction(_))
+ .WillRepeatedly(
+ Return(am::HmiInterfaces::HMI_INTERFACE_BasicCommunication));
+ EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
+ .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE));
// Return `true` prevents call of `SendResponse` method;
EXPECT_CALL(app_mngr_, ManageHMICommand(_)).WillOnce(Return(true));
@@ -307,7 +311,7 @@ TEST_F(CommandRequestImplTest, RemoveDisallowedParameters_SUCCESS) {
vehicle_data.insert(
am::VehicleData::value_type(kMissedParam, am::VehicleDataType::MYKEY));
- EXPECT_CALL(*mock_message_helper_, vehicle_data())
+ EXPECT_CALL(mock_message_helper_, vehicle_data())
.WillOnce(ReturnRef(vehicle_data));
MessageSharedPtr msg = CreateMessage();
@@ -348,33 +352,24 @@ TEST_F(CommandRequestImplTest,
}
TEST_F(CommandRequestImplTest,
- CheckAllowedParameters_NoAppWithSameConnectionKey_SUCCESS) {
- MessageSharedPtr msg = CreateMessage();
- (*msg)[strings::params][strings::connection_key] = kConnectionKey;
-
- CommandPtr command = CreateCommand<UCommandRequestImpl>(msg);
-
- SharedPtr<ApplicationSet> app_set;
- MockAppPtr app(InitAppSetDataAccessor(app_set));
- EXPECT_CALL(*app, app_id()).WillOnce(Return(6u));
- EXPECT_TRUE(command->CheckPermissions());
+ CheckAllowedParameters_NoAppWithSameConnectionKey_UNSUCCESS) {
+ MessageSharedPtr message = CreateMessage();
+ CommandPtr command = CreateCommand<UCommandRequestImpl>(message);
+ EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(MockAppPtr()));
+ EXPECT_FALSE(command->CheckPermissions());
}
TEST_F(CommandRequestImplTest, CheckAllowedParameters_NoMsgParamsMap_SUCCESS) {
- MessageSharedPtr msg = CreateMessage();
- (*msg)[strings::params][strings::connection_key] = kConnectionKey;
- (*msg)[strings::msg_params] = 0u;
+ MockAppPtr mock_app = CreateMockApp();
+ ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app));
- CommandPtr command = CreateCommand<UCommandRequestImpl>(msg);
+ MessageSharedPtr message = CreateMessage();
+ (*message)[strings::msg_params] =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
- SharedPtr<ApplicationSet> app_set;
- MockAppPtr app(InitAppSetDataAccessor(app_set));
- EXPECT_CALL(*app, app_id()).WillOnce(Return(kConnectionKey));
- EXPECT_CALL(*app, policy_app_id()).WillOnce(Return(kPolicyAppId));
- EXPECT_CALL(*app, hmi_level())
- .WillOnce(Return(mobile_apis::HMILevel::HMI_NONE));
+ CommandPtr command = CreateCommand<UCommandRequestImpl>(message);
- EXPECT_CALL(app_mngr_, CheckPolicyPermissions(_, _, _, _, _))
+ EXPECT_CALL(app_mngr_, CheckPolicyPermissions(_, _, _, _))
.WillOnce(Return(kMobResultSuccess));
EXPECT_TRUE(command->CheckPermissions());
@@ -382,32 +377,31 @@ TEST_F(CommandRequestImplTest, CheckAllowedParameters_NoMsgParamsMap_SUCCESS) {
TEST_F(CommandRequestImplTest,
CheckAllowedParameters_WrongPolicyPermissions_UNSUCCESS) {
- MessageSharedPtr msg = CreateMessage();
- (*msg)[strings::params][strings::connection_key] = kConnectionKey;
- (*msg)[strings::msg_params] = 0u;
+ MockAppPtr mock_app = CreateMockApp();
+ ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app));
- CommandPtr command = CreateCommand<UCommandRequestImpl>(msg);
+ MessageSharedPtr message = CreateMessage();
+ (*message)[strings::msg_params] =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+
+ CommandPtr command = CreateCommand<UCommandRequestImpl>(message);
- SharedPtr<ApplicationSet> app_set;
- MockAppPtr app(InitAppSetDataAccessor(app_set));
- EXPECT_CALL(*app, app_id()).Times(2).WillRepeatedly(Return(kConnectionKey));
- EXPECT_CALL(*app, policy_app_id()).WillOnce(Return(kPolicyAppId));
- EXPECT_CALL(*app, hmi_level())
- .WillOnce(Return(mobile_apis::HMILevel::HMI_NONE));
+ EXPECT_CALL(*mock_app, app_id())
+ .Times(1)
+ .WillRepeatedly(Return(kConnectionKey));
- EXPECT_CALL(app_mngr_, CheckPolicyPermissions(_, _, _, _, _))
+ EXPECT_CALL(app_mngr_, CheckPolicyPermissions(_, _, _, _))
.WillOnce(Return(mobile_apis::Result::INVALID_ENUM));
- MessageSharedPtr dummy_msg;
- EXPECT_CALL(*mock_message_helper_,
- CreateBlockedByPoliciesResponse(_, _, _, _))
- .WillOnce(Return(dummy_msg));
+ EXPECT_CALL(mock_message_helper_, CreateBlockedByPoliciesResponse(_, _, _, _))
+ .WillOnce(Return(smart_objects::SmartObjectSPtr()));
+
EXPECT_CALL(app_mngr_, SendMessageToMobile(_, _));
EXPECT_FALSE(command->CheckPermissions());
}
ACTION_P(GetArg3, output) {
- *output = arg3;
+ *output = arg2;
}
TEST_F(CommandRequestImplTest, CheckAllowedParameters_MsgParamsMap_SUCCESS) {
@@ -417,15 +411,11 @@ TEST_F(CommandRequestImplTest, CheckAllowedParameters_MsgParamsMap_SUCCESS) {
CommandPtr command = CreateCommand<UCommandRequestImpl>(msg);
- SharedPtr<ApplicationSet> app_set;
- MockAppPtr app(InitAppSetDataAccessor(app_set));
- EXPECT_CALL(*app, app_id()).WillOnce(Return(kConnectionKey));
- EXPECT_CALL(*app, policy_app_id()).WillOnce(Return(kPolicyAppId));
- EXPECT_CALL(*app, hmi_level())
- .WillOnce(Return(mobile_apis::HMILevel::HMI_NONE));
+ MockAppPtr app = CreateMockApp();
+ ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
RPCParams params;
- EXPECT_CALL(app_mngr_, CheckPolicyPermissions(_, _, _, _, _))
+ EXPECT_CALL(app_mngr_, CheckPolicyPermissions(_, _, _, _))
.WillOnce(DoAll(GetArg3(&params), Return(kMobResultSuccess)));
EXPECT_TRUE(command->CheckPermissions());
@@ -438,7 +428,7 @@ TEST_F(CommandRequestImplTest, AddDisallowedParameters_SUCCESS) {
vehicle_data.insert(am::VehicleData::value_type(kDisallowedParam1,
am::VehicleDataType::MYKEY));
- EXPECT_CALL(*mock_message_helper_, vehicle_data())
+ EXPECT_CALL(mock_message_helper_, vehicle_data())
.WillOnce(ReturnRef(vehicle_data));
MessageSharedPtr msg;
@@ -490,7 +480,7 @@ TEST_F(CommandRequestImplTest,
vehicle_data.insert(am::VehicleData::value_type(kDisallowedParam1,
am::VehicleDataType::MYKEY));
- EXPECT_CALL(*mock_message_helper_, vehicle_data())
+ EXPECT_CALL(mock_message_helper_, vehicle_data())
.WillOnce(ReturnRef(vehicle_data));
MessageSharedPtr msg = CreateMessage();
@@ -515,6 +505,81 @@ TEST_F(CommandRequestImplTest,
(*result)[strings::msg_params][strings::info].asString().empty());
}
+TEST_F(CommandRequestImplTest, HashUpdateAllowed_UpdateExpected) {
+ MessageSharedPtr msg;
+ CommandPtr command = CreateCommand<UCommandRequestImpl>(msg);
+ command->SetHashUpdateMode(CommandRequestImpl::HashUpdateMode::kDoHashUpdate);
+
+ MessageSharedPtr result;
+ EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _))
+ .WillOnce(DoAll(SaveArg<0>(&result), Return(true)));
+
+ const bool is_succedeed = true;
+ command->SendResponse(is_succedeed, kMobResultSuccess, NULL, NULL);
+
+ MockAppPtr mock_app = CreateMockApp();
+ EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app));
+ EXPECT_CALL(*mock_app, UpdateHash());
+
+ command.reset();
+}
+
+TEST_F(CommandRequestImplTest, HashUpdateDisallowed_HashUpdateNotExpected) {
+ MessageSharedPtr msg;
+ CommandPtr command = CreateCommand<UCommandRequestImpl>(msg);
+ command->SetHashUpdateMode(
+ CommandRequestImpl::HashUpdateMode::kSkipHashUpdate);
+
+ MessageSharedPtr result;
+ EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _))
+ .WillOnce(DoAll(SaveArg<0>(&result), Return(true)));
+
+ const bool is_succedeed = true;
+ command->SendResponse(is_succedeed, kMobResultSuccess, NULL, NULL);
+
+ MockAppPtr mock_app = CreateMockApp();
+ EXPECT_CALL(*mock_app, UpdateHash()).Times(0);
+
+ command.reset();
+}
+
+TEST_F(CommandRequestImplTest, RequestFailed_HashUpdateNotExpected) {
+ MessageSharedPtr msg;
+ CommandPtr command = CreateCommand<UCommandRequestImpl>(msg);
+ command->SetHashUpdateMode(CommandRequestImpl::HashUpdateMode::kDoHashUpdate);
+
+ MessageSharedPtr result;
+ EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _))
+ .WillOnce(DoAll(SaveArg<0>(&result), Return(true)));
+
+ const bool is_succedeed = false;
+ command->SendResponse(is_succedeed, kMobResultSuccess, NULL, NULL);
+
+ MockAppPtr mock_app = CreateMockApp();
+ EXPECT_CALL(*mock_app, UpdateHash()).Times(0);
+
+ command.reset();
+}
+
+TEST_F(CommandRequestImplTest, AppNotFound_HashUpdateNotExpected) {
+ MessageSharedPtr msg;
+ CommandPtr command = CreateCommand<UCommandRequestImpl>(msg);
+ command->SetHashUpdateMode(CommandRequestImpl::HashUpdateMode::kDoHashUpdate);
+
+ MessageSharedPtr result;
+ EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _))
+ .WillOnce(DoAll(SaveArg<0>(&result), Return(true)));
+
+ const bool is_succedeed = true;
+ command->SendResponse(is_succedeed, kMobResultSuccess, NULL, NULL);
+
+ MockAppPtr mock_app = CreateMockApp();
+ EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(MockAppPtr()));
+ EXPECT_CALL(*mock_app, UpdateHash()).Times(0);
+
+ command.reset();
+}
+
} // namespace command_request_impl
} // namespace commands_test
} // namespace components
diff --git a/src/components/application_manager/test/commands/hmi/hmi_notifications/hmi_notifications_test.cc b/src/components/application_manager/test/commands/hmi/hmi_notifications/hmi_notifications_test.cc
index ecdb698c56..9af72a7925 100644
--- a/src/components/application_manager/test/commands/hmi/hmi_notifications/hmi_notifications_test.cc
+++ b/src/components/application_manager/test/commands/hmi/hmi_notifications/hmi_notifications_test.cc
@@ -130,6 +130,9 @@
#include "application_manager/policies/mock_policy_handler_interface.h"
#include "application_manager/mock_message_helper.h"
#include "protocol_handler/mock_session_observer.h"
+#ifdef SDL_REMOTE_CONTROL
+#include "functional_module/plugin_manager.h"
+#endif // SDL_REMOTE_CONTROL
namespace am = application_manager;
@@ -1106,6 +1109,12 @@ TEST_F(HMICommandsNotificationsTest,
(*notification)[am::strings::msg_params][am::strings::reason] =
static_cast<int32_t>(*it_mobile_reason);
+#ifdef SDL_REMOTE_CONTROL
+ functional_modules::PluginManager plugin_mng;
+ EXPECT_CALL(app_mngr_, GetPluginManager())
+ .WillRepeatedly(ReturnRef(plugin_mng));
+#endif // SDL_REMOTE_CONTROL
+
EXPECT_CALL(app_mngr_, application(kAppId_)).WillRepeatedly(Return(app_));
EXPECT_CALL(*message_helper_mock_,
GetOnAppInterfaceUnregisteredNotificationToMobile(
@@ -1130,6 +1139,12 @@ TEST_F(HMICommandsNotificationsTest,
utils::SharedPtr<Command> command =
CreateCommand<OnExitApplicationNotification>(message);
+#ifdef SDL_REMOTE_CONTROL
+ functional_modules::PluginManager plugin_mng;
+ EXPECT_CALL(app_mngr_, GetPluginManager())
+ .WillRepeatedly(ReturnRef(plugin_mng));
+#endif // SDL_REMOTE_CONTROL
+
EXPECT_CALL(app_mngr_, application(_)).Times(0);
EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
EXPECT_CALL(app_mngr_, UnregisterApplication(_, _, _, _)).Times(0);
@@ -1184,6 +1199,12 @@ TEST_F(HMICommandsNotificationsTest,
utils::SharedPtr<Command> command =
CreateCommand<OnExitApplicationNotification>(message);
+#ifdef SDL_REMOTE_CONTROL
+ functional_modules::PluginManager plugin_mng;
+ EXPECT_CALL(app_mngr_, GetPluginManager())
+ .WillRepeatedly(ReturnRef(plugin_mng));
+#endif // SDL_REMOTE_CONTROL
+
EXPECT_CALL(app_mngr_, application(kAppId_)).WillRepeatedly(Return(app_));
EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
EXPECT_CALL(app_mngr_, UnregisterApplication(_, _, _, _)).Times(0);
diff --git a/src/components/application_manager/test/commands/hmi/navi_audio_start_stream_request_test.cc b/src/components/application_manager/test/commands/hmi/navi_audio_start_stream_request_test.cc
index e590412204..c187cc75d9 100644
--- a/src/components/application_manager/test/commands/hmi/navi_audio_start_stream_request_test.cc
+++ b/src/components/application_manager/test/commands/hmi/navi_audio_start_stream_request_test.cc
@@ -67,8 +67,6 @@ class AudioStartStreamRequestTest
: public CommandRequestTest<CommandsTestMocks::kIsNice> {
public:
AudioStartStreamRequestTest() {
- ON_CALL(app_mngr_, hmi_interfaces())
- .WillByDefault(ReturnRef(mock_hmi_interfaces_));
ON_CALL(app_mngr_settings_, start_stream_retry_amount())
.WillByDefault(ReturnRef(start_stream_retry_amount_));
msg_ = CreateMessage();
@@ -78,7 +76,6 @@ class AudioStartStreamRequestTest
std::pair<uint32_t, int32_t> start_stream_retry_amount_;
MessageSharedPtr msg_;
SharedPtr<AudioStartStreamRequest> command_;
- MOCK(am::MockHmiInterfaces) mock_hmi_interfaces_;
};
TEST_F(AudioStartStreamRequestTest, Run_HmiInterfaceNotAvailable_NoRequest) {
diff --git a/src/components/application_manager/test/commands/hmi/navi_is_ready_request_test.cc b/src/components/application_manager/test/commands/hmi/navi_is_ready_request_test.cc
index b08bf6e515..825cca9185 100644
--- a/src/components/application_manager/test/commands/hmi/navi_is_ready_request_test.cc
+++ b/src/components/application_manager/test/commands/hmi/navi_is_ready_request_test.cc
@@ -69,12 +69,9 @@ class NaviIsReadyRequestTest
NaviIsReadyRequestTest() : command_(CreateCommand<NaviIsReadyRequest>()) {
ON_CALL(app_mngr_, hmi_capabilities())
.WillByDefault(ReturnRef(mock_hmi_capabilities_));
- ON_CALL(app_mngr_, hmi_interfaces())
- .WillByDefault(ReturnRef(mock_hmi_interfaces_));
}
NaviIsReadyRequestPtr command_;
- MOCK(am::MockHmiInterfaces) mock_hmi_interfaces_;
MOCK(application_manager_test::MockHMICapabilities) mock_hmi_capabilities_;
};
diff --git a/src/components/application_manager/test/commands/hmi/navi_set_video_config_request_test.cc b/src/components/application_manager/test/commands/hmi/navi_set_video_config_request_test.cc
new file mode 100644
index 0000000000..7c04aa724c
--- /dev/null
+++ b/src/components/application_manager/test/commands/hmi/navi_set_video_config_request_test.cc
@@ -0,0 +1,216 @@
+/*
+ * Copyright (c) 2017 Xevo Inc.
+ * 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 names of the copyright holders 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 <algorithm>
+
+#include "application_manager/commands/hmi/navi_set_video_config_request.h"
+
+#include "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/commands/command_request_test.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/hmi_interfaces.h"
+#include "application_manager/mock_hmi_interface.h"
+#include "application_manager/event_engine/event.h"
+#include "application_manager/mock_event_dispatcher.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace hmi_commands_test {
+namespace navi_set_video_config_request {
+
+using ::testing::_;
+using ::testing::ReturnRef;
+namespace am = ::application_manager;
+using am::commands::MessageSharedPtr;
+using am::commands::NaviSetVideoConfigRequest;
+using am::event_engine::Event;
+
+namespace {
+const uint32_t kAppId = 1u;
+const uint32_t kHmiAppId = 13u;
+const hmi_apis::FunctionID::eType kEventID =
+ hmi_apis::FunctionID::Navigation_SetVideoConfig;
+} // namespace
+
+typedef SharedPtr<NaviSetVideoConfigRequest> NaviSetVideoConfigRequestPtr;
+
+class NaviSetVideoConfigRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ NaviSetVideoConfigRequestTest() {
+ mock_app_ptr_ = CreateMockApp();
+ ON_CALL(app_mngr_, hmi_interfaces())
+ .WillByDefault(ReturnRef(mock_hmi_interfaces_));
+ ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_ptr_));
+ ON_CALL(app_mngr_, application_by_hmi_app(_))
+ .WillByDefault(Return(mock_app_ptr_));
+ ON_CALL(app_mngr_, event_dispatcher())
+ .WillByDefault(ReturnRef(mock_event_dispatcher_));
+ ON_CALL(*mock_app_ptr_, app_id()).WillByDefault(Return(kAppId));
+ ON_CALL(*mock_app_ptr_, hmi_app_id()).WillByDefault(Return(kHmiAppId));
+ }
+
+ MOCK(am::MockHmiInterfaces) mock_hmi_interfaces_;
+ MockAppPtr mock_app_ptr_;
+ MockEventDispatcher mock_event_dispatcher_;
+};
+
+TEST_F(NaviSetVideoConfigRequestTest, OnEventWithSuccessResponse) {
+ MessageSharedPtr request_msg = CreateMessage();
+ (*request_msg)[am::strings::msg_params][am::strings::app_id] = kAppId;
+
+ NaviSetVideoConfigRequestPtr command =
+ CreateCommand<NaviSetVideoConfigRequest>(request_msg);
+
+ MessageSharedPtr event_msg = CreateMessage();
+ (*event_msg)[am::strings::params][am::hmi_response::code] =
+ hmi_apis::Common_Result::SUCCESS;
+ Event event(kEventID);
+ event.set_smart_object(*event_msg);
+
+ std::vector<std::string> empty;
+ EXPECT_CALL(
+ app_mngr_,
+ OnStreamingConfigured(
+ kAppId, protocol_handler::ServiceType::kMobileNav, true, empty))
+ .Times(1);
+
+ command->on_event(event);
+}
+
+static bool ValidateList(std::vector<std::string>& expected,
+ std::vector<std::string>& actual) {
+ std::sort(expected.begin(), expected.end());
+ std::sort(actual.begin(), actual.end());
+ return std::equal(expected.begin(), expected.end(), actual.begin());
+}
+
+TEST_F(NaviSetVideoConfigRequestTest, OnEventWithRejectedResponse) {
+ MessageSharedPtr request_msg = CreateMessage();
+ (*request_msg)[am::strings::msg_params][am::strings::app_id] = kAppId;
+ (*request_msg)[am::strings::msg_params][am::strings::config] =
+ smart_objects::SmartObject(smart_objects::SmartType_Array);
+ (*request_msg)[am::strings::msg_params][am::strings::config]
+ [am::strings::protocol] =
+ hmi_apis::Common_VideoStreamingProtocol::RTP;
+ (*request_msg)[am::strings::msg_params][am::strings::config]
+ [am::strings::codec] =
+ hmi_apis::Common_VideoStreamingCodec::H265;
+ (*request_msg)[am::strings::msg_params][am::strings::config]
+ [am::strings::height] = 640;
+ (*request_msg)[am::strings::msg_params][am::strings::config]
+ [am::strings::width] = 480;
+
+ NaviSetVideoConfigRequestPtr command =
+ CreateCommand<NaviSetVideoConfigRequest>(request_msg);
+
+ MessageSharedPtr event_msg = CreateMessage();
+ (*event_msg)[am::strings::params][am::hmi_response::code] =
+ hmi_apis::Common_Result::REJECTED;
+
+ (*event_msg)[am::strings::msg_params][am::strings::rejected_params] =
+ smart_objects::SmartObject(smart_objects::SmartType_Array);
+ (*event_msg)[am::strings::msg_params][am::strings::rejected_params][0] =
+ "codec";
+ (*event_msg)[am::strings::msg_params][am::strings::rejected_params][1] =
+ "protocol";
+ Event event(kEventID);
+ event.set_smart_object(*event_msg);
+
+ std::vector<std::string> rejected_params;
+ EXPECT_CALL(app_mngr_,
+ OnStreamingConfigured(
+ kAppId, protocol_handler::ServiceType::kMobileNav, false, _))
+ .WillOnce(SaveArg<3>(&rejected_params));
+
+ command->on_event(event);
+
+ ASSERT_EQ(2u, rejected_params.size());
+ std::vector<std::string> expected_list;
+ expected_list.push_back(std::string("protocol"));
+ expected_list.push_back(std::string("codec"));
+ ASSERT_TRUE(ValidateList(expected_list, rejected_params));
+}
+
+TEST_F(NaviSetVideoConfigRequestTest,
+ OnEventWithRejectedResponseWithoutParams) {
+ MessageSharedPtr request_msg = CreateMessage();
+ (*request_msg)[am::strings::msg_params][am::strings::app_id] = kAppId;
+
+ NaviSetVideoConfigRequestPtr command =
+ CreateCommand<NaviSetVideoConfigRequest>(request_msg);
+
+ MessageSharedPtr event_msg = CreateMessage();
+ (*event_msg)[am::strings::params][am::hmi_response::code] =
+ hmi_apis::Common_Result::REJECTED;
+
+ Event event(kEventID);
+ event.set_smart_object(*event_msg);
+
+ std::vector<std::string> empty;
+ EXPECT_CALL(
+ app_mngr_,
+ OnStreamingConfigured(
+ kAppId, protocol_handler::ServiceType::kMobileNav, false, empty))
+ .WillOnce(Return());
+
+ command->on_event(event);
+}
+
+TEST_F(NaviSetVideoConfigRequestTest, OnTimeout) {
+ MessageSharedPtr request_msg = CreateMessage();
+ (*request_msg)[am::strings::msg_params][am::strings::app_id] = kAppId;
+
+ NaviSetVideoConfigRequestPtr command =
+ CreateCommand<NaviSetVideoConfigRequest>(request_msg);
+
+ std::vector<std::string> empty;
+ EXPECT_CALL(
+ app_mngr_,
+ OnStreamingConfigured(
+ kAppId, protocol_handler::ServiceType::kMobileNav, false, empty))
+ .WillOnce(Return());
+
+ EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _)).Times(1);
+
+ command->onTimeOut();
+}
+
+} // namespace navi_set_video_config_request
+} // namespace hmi_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/hmi/navi_set_video_config_response_test.cc b/src/components/application_manager/test/commands/hmi/navi_set_video_config_response_test.cc
new file mode 100644
index 0000000000..753c2a9179
--- /dev/null
+++ b/src/components/application_manager/test/commands/hmi/navi_set_video_config_response_test.cc
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2017 Xevo Inc.
+ * 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 names of the copyright holders 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 "application_manager/commands/commands_test.h"
+#include "application_manager/commands/hmi/navi_set_video_config_response.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_event_dispatcher.h"
+#include "application_manager/mock_hmi_capabilities.h"
+#include "application_manager/smart_object_keys.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace hmi_commands_test {
+namespace navi_set_video_config_response {
+
+using utils::SharedPtr;
+using application_manager::commands::NaviSetVideoConfigResponse;
+using test::components::event_engine_test::MockEventDispatcher;
+using testing::_;
+using testing::ReturnRef;
+using ::testing::NiceMock;
+
+typedef NiceMock<
+ ::test::components::application_manager_test::MockHMICapabilities>
+ MockHMICapabilities;
+
+class NaviSetVideoConfigResponseTest
+ : public CommandsTest<CommandsTestMocks::kIsNice> {};
+
+TEST_F(NaviSetVideoConfigResponseTest, RUN_SUCCESS) {
+ MessageSharedPtr msg = CreateMessage();
+
+ SharedPtr<NaviSetVideoConfigResponse> command(
+ CreateCommand<NaviSetVideoConfigResponse>(msg));
+
+ MockEventDispatcher mock_event_dispatcher;
+ EXPECT_CALL(app_mngr_, event_dispatcher())
+ .WillOnce(ReturnRef(mock_event_dispatcher));
+ EXPECT_CALL(mock_event_dispatcher, raise_event(_));
+
+ command->Run();
+}
+
+} // namespace navi_set_video_config_response
+} // namespace hmi_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/hmi/navi_start_stream_request_test.cc b/src/components/application_manager/test/commands/hmi/navi_start_stream_request_test.cc
index 8a157c9a0f..1327ff6dd6 100644
--- a/src/components/application_manager/test/commands/hmi/navi_start_stream_request_test.cc
+++ b/src/components/application_manager/test/commands/hmi/navi_start_stream_request_test.cc
@@ -67,8 +67,6 @@ class NaviStartStreamRequestTest
: public CommandRequestTest<CommandsTestMocks::kIsNice> {
public:
NaviStartStreamRequestTest() {
- ON_CALL(app_mngr_, hmi_interfaces())
- .WillByDefault(ReturnRef(mock_hmi_interfaces_));
ON_CALL(app_mngr_settings_, start_stream_retry_amount())
.WillByDefault(ReturnRef(start_stream_retry_amount_));
msg_ = CreateMessage();
@@ -78,7 +76,6 @@ class NaviStartStreamRequestTest
std::pair<uint32_t, int32_t> start_stream_retry_amount_;
MessageSharedPtr msg_;
SharedPtr<NaviStartStreamRequest> command_;
- MOCK(am::MockHmiInterfaces) mock_hmi_interfaces_;
};
TEST_F(NaviStartStreamRequestTest, Run_HmiInterfaceNotAvailable_NoRequest) {
diff --git a/src/components/application_manager/test/commands/hmi/navi_stop_stream_requests_test.cc b/src/components/application_manager/test/commands/hmi/navi_stop_stream_requests_test.cc
index 91b781c1ff..18f82cd645 100644
--- a/src/components/application_manager/test/commands/hmi/navi_stop_stream_requests_test.cc
+++ b/src/components/application_manager/test/commands/hmi/navi_stop_stream_requests_test.cc
@@ -73,7 +73,6 @@ class NaviStopStreamRequestsTest
MessageSharedPtr msg_;
SharedPtr<Command> command_;
- MOCK(am::MockHmiInterfaces) mock_hmi_interfaces_;
};
typedef testing::Types<commands::AudioStopStreamRequest,
diff --git a/src/components/application_manager/test/commands/hmi/rc_get_capabilities_response_test.cc b/src/components/application_manager/test/commands/hmi/rc_get_capabilities_response_test.cc
new file mode 100644
index 0000000000..f851bd644a
--- /dev/null
+++ b/src/components/application_manager/test/commands/hmi/rc_get_capabilities_response_test.cc
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2016, 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 "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "smart_objects/smart_object.h"
+#include "interfaces/MOBILE_API.h"
+#include "application_manager/mock_hmi_capabilities.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/commands/commands_test.h"
+#include "application_manager/commands/command_impl.h"
+#include "application_manager/commands/hmi/rc_get_capabilities_response.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace hmi_commands_test {
+namespace rc_get_capabilities_response {
+
+using ::utils::SharedPtr;
+using ::testing::NiceMock;
+namespace am = ::application_manager;
+namespace strings = am::strings;
+namespace hmi_response = am::hmi_response;
+using am::commands::RCGetCapabilitiesResponse;
+using am::commands::CommandImpl;
+
+typedef SharedPtr<RCGetCapabilitiesResponse> RCGetCapabilitiesResponsePtr;
+typedef NiceMock<
+ ::test::components::application_manager_test::MockHMICapabilities>
+ MockHMICapabilities;
+
+namespace {
+const uint32_t kConnectionKey = 2u;
+} // namespace
+
+class RCGetCapabilitiesResponseTest
+ : public CommandsTest<CommandsTestMocks::kIsNice> {
+ public:
+ MessageSharedPtr CreateCommandMsg() {
+ MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*command_msg)[strings::msg_params][strings::number] = "123";
+ (*command_msg)[strings::params][strings::connection_key] = kConnectionKey;
+ (*command_msg)[strings::params][hmi_response::code] =
+ hmi_apis::Common_Result::SUCCESS;
+ (*command_msg)[strings::msg_params][strings::rc_capability] =
+ (capabilities_);
+
+ return command_msg;
+ }
+
+ MockHMICapabilities mock_hmi_capabilities_;
+ SmartObject capabilities_;
+};
+
+TEST_F(RCGetCapabilitiesResponseTest, RUN_SUCCESSS) {
+ MessageSharedPtr command_msg = CreateCommandMsg();
+
+ RCGetCapabilitiesResponsePtr command(
+ CreateCommand<RCGetCapabilitiesResponse>(command_msg));
+
+ EXPECT_CALL(app_mngr_, hmi_capabilities())
+ .WillOnce(ReturnRef(mock_hmi_capabilities_));
+
+ smart_objects::SmartObject rc_capability_so =
+ (*command_msg)[strings::msg_params][strings::rc_capability];
+
+ EXPECT_CALL(mock_hmi_capabilities_, set_rc_capability(rc_capability_so));
+
+ command->Run();
+}
+
+} // namespace rc_get_capabilities_response
+} // namespace hmi_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/hmi/rc_is_ready_request_test.cc b/src/components/application_manager/test/commands/hmi/rc_is_ready_request_test.cc
new file mode 100644
index 0000000000..af54321ca7
--- /dev/null
+++ b/src/components/application_manager/test/commands/hmi/rc_is_ready_request_test.cc
@@ -0,0 +1,172 @@
+/*
+ * Copyright (c) 2016, 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/commands/hmi/rc_is_ready_request.h"
+
+#include "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/commands/command_request_test.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/hmi_interfaces.h"
+#include "application_manager/mock_hmi_interface.h"
+#include "application_manager/mock_hmi_capabilities.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/event_engine/event.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace hmi_commands_test {
+namespace rc_is_ready_request {
+
+using ::testing::_;
+using ::testing::ReturnRef;
+namespace am = ::application_manager;
+using am::commands::MessageSharedPtr;
+using am::commands::RCIsReadyRequest;
+using am::MockMessageHelper;
+using am::event_engine::Event;
+
+typedef SharedPtr<RCIsReadyRequest> RCIsReadyRequestPtr;
+
+class RCIsReadyRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ RCIsReadyRequestTest() : command_(CreateCommand<RCIsReadyRequest>()) {}
+
+ void SetUpExpectations(bool is_rc_cooperating_available,
+ bool is_send_message_to_hmi,
+ bool is_message_contain_param,
+ am::HmiInterfaces::InterfaceState state) {
+ if (is_send_message_to_hmi) {
+ EXPECT_CALL(app_mngr_, hmi_capabilities())
+ .WillRepeatedly(ReturnRef(mock_hmi_capabilities_));
+ ExpectSendMessagesToHMI();
+ } else {
+ EXPECT_CALL(app_mngr_, hmi_capabilities())
+ .WillOnce(ReturnRef(mock_hmi_capabilities_));
+ }
+ EXPECT_CALL(mock_hmi_capabilities_,
+ set_is_rc_cooperating(is_rc_cooperating_available));
+
+ if (is_message_contain_param) {
+ EXPECT_CALL(app_mngr_, hmi_interfaces())
+ .WillRepeatedly(ReturnRef(mock_hmi_interfaces_));
+ EXPECT_CALL(
+ mock_hmi_interfaces_,
+ SetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_RC, state));
+ } else {
+ EXPECT_CALL(app_mngr_, hmi_interfaces())
+ .WillOnce(ReturnRef(mock_hmi_interfaces_));
+ EXPECT_CALL(mock_hmi_interfaces_, SetInterfaceState(_, _)).Times(0);
+ }
+ EXPECT_CALL(mock_hmi_interfaces_,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_RC))
+ .WillOnce(Return(state));
+ }
+
+ void ExpectSendMessagesToHMI() {
+ smart_objects::SmartObjectSPtr capabilities(
+ new smart_objects::SmartObject(smart_objects::SmartType_Map));
+ EXPECT_CALL(*(MockMessageHelper::message_helper_mock()),
+ CreateModuleInfoSO(hmi_apis::FunctionID::RC_GetCapabilities, _))
+ .WillOnce(Return(capabilities));
+ EXPECT_CALL(app_mngr_, ManageHMICommand(capabilities));
+ }
+
+ void PrepareEvent(bool is_message_contain_param,
+ Event& event,
+ bool is_rc_cooperating_available = false) {
+ MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
+ if (is_message_contain_param) {
+ (*msg)[am::strings::msg_params][am::strings::available] =
+ is_rc_cooperating_available;
+ }
+ event.set_smart_object(*msg);
+ }
+
+ RCIsReadyRequestPtr command_;
+ am::MockHmiInterfaces mock_hmi_interfaces_;
+ application_manager_test::MockHMICapabilities mock_hmi_capabilities_;
+};
+
+TEST_F(RCIsReadyRequestTest, Run_NoKeyAvailableInMessage_HmiInterfacesIgnored) {
+ const bool is_rc_cooperating_available = false;
+ const bool is_send_message_to_hmi = true;
+ const bool is_message_contain_param = false;
+ Event event(hmi_apis::FunctionID::RC_IsReady);
+ PrepareEvent(is_message_contain_param, event);
+ SetUpExpectations(is_rc_cooperating_available,
+ is_send_message_to_hmi,
+ is_message_contain_param,
+ am::HmiInterfaces::STATE_NOT_RESPONSE);
+ command_->on_event(event);
+}
+
+TEST_F(RCIsReadyRequestTest, Run_KeyAvailableEqualToFalse_StateNotAvailable) {
+ const bool is_rc_cooperating_available = false;
+ const bool is_send_message_to_hmi = false;
+ const bool is_message_contain_param = true;
+ Event event(hmi_apis::FunctionID::RC_IsReady);
+ PrepareEvent(is_message_contain_param, event);
+ SetUpExpectations(is_rc_cooperating_available,
+ is_send_message_to_hmi,
+ is_message_contain_param,
+ am::HmiInterfaces::STATE_NOT_AVAILABLE);
+ command_->on_event(event);
+}
+
+TEST_F(RCIsReadyRequestTest, Run_KeyAvailableEqualToTrue_StateAvailable) {
+ const bool is_rc_cooperating_available = true;
+ const bool is_send_message_to_hmi = true;
+ const bool is_message_contain_param = true;
+ Event event(hmi_apis::FunctionID::RC_IsReady);
+ PrepareEvent(is_message_contain_param, event, is_rc_cooperating_available);
+ SetUpExpectations(is_rc_cooperating_available,
+ is_send_message_to_hmi,
+ is_message_contain_param,
+ am::HmiInterfaces::STATE_AVAILABLE);
+ command_->on_event(event);
+}
+
+TEST_F(RCIsReadyRequestTest, Run_HMIDoestRespond_SendMessageToHMIByTimeout) {
+ ExpectSendMessagesToHMI();
+ command_->onTimeOut();
+}
+
+} // namespace rc_is_ready_request
+} // namespace hmi_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/hmi/rc_is_ready_response_test.cc b/src/components/application_manager/test/commands/hmi/rc_is_ready_response_test.cc
new file mode 100644
index 0000000000..157dff6216
--- /dev/null
+++ b/src/components/application_manager/test/commands/hmi/rc_is_ready_response_test.cc
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2016, 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 "gtest/gtest.h"
+#include "utils/shared_ptr.h"
+#include "smart_objects/smart_object.h"
+#include "commands/commands_test.h"
+#include "application_manager/mock_hmi_capabilities.h"
+#include "application_manager/commands/hmi/rc_is_ready_response.h"
+#include "application_manager/mock_event_dispatcher.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace hmi_commands_test {
+namespace rc_is_ready_response {
+
+using ::testing::Return;
+using ::utils::SharedPtr;
+using ::testing::NiceMock;
+namespace am = ::application_manager;
+namespace strings = ::application_manager::strings;
+namespace hmi_response = am::hmi_response;
+using am::commands::RCIsReadyResponse;
+using test::components::event_engine_test::MockEventDispatcher;
+
+typedef SharedPtr<RCIsReadyResponse> RCIsReadyResponsePtr;
+
+class RCIsReadyResponseTest : public CommandsTest<CommandsTestMocks::kIsNice> {
+};
+
+TEST_F(RCIsReadyResponseTest, RUN_SUCCESS) {
+ RCIsReadyResponsePtr command(CreateCommand<RCIsReadyResponse>());
+
+ MockEventDispatcher mock_event_dispatcher;
+ EXPECT_CALL(app_mngr_, event_dispatcher())
+ .WillOnce(ReturnRef(mock_event_dispatcher));
+ EXPECT_CALL(mock_event_dispatcher, raise_event(_));
+
+ command->Run();
+}
+
+} // namespace rc_is_ready_response
+} // namespace hmi_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/hmi/sdl_activate_app_request_test.cc b/src/components/application_manager/test/commands/hmi/sdl_activate_app_request_test.cc
index eeae0422d1..3805df5834 100644
--- a/src/components/application_manager/test/commands/hmi/sdl_activate_app_request_test.cc
+++ b/src/components/application_manager/test/commands/hmi/sdl_activate_app_request_test.cc
@@ -209,9 +209,11 @@ TEST_F(SDLActivateAppRequestTest, FindAppToRegister_SUCCESS) {
ON_CALL(*mock_app_first, device()).WillByDefault(Return(kHandle));
EXPECT_CALL(*mock_app_first, is_foreground()).WillOnce(Return(false));
ON_CALL(*mock_app_first, protocol_version())
- .WillByDefault(Return(am::ProtocolVersion::kV4));
+ .WillByDefault(
+ Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5));
ON_CALL(*mock_app, protocol_version())
- .WillByDefault(Return(am::ProtocolVersion::kV4));
+ .WillByDefault(
+ Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5));
const std::string url = "url";
ON_CALL(*mock_app_first, SchemaUrl()).WillByDefault(Return(url));
@@ -291,7 +293,8 @@ TEST_F(SDLActivateAppRequestTest, FirstAppActive_SUCCESS) {
app_list_.insert(mock_app_first);
ON_CALL(*mock_app_first, protocol_version())
- .WillByDefault(Return(am::ProtocolVersion::kV4));
+ .WillByDefault(
+ Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5));
ON_CALL(*mock_app_first, device()).WillByDefault(Return(kHandle));
EXPECT_CALL(*mock_app_first, is_foreground()).WillRepeatedly(Return(true));
@@ -355,7 +358,8 @@ TEST_F(SDLActivateAppRequestTest, FirstAppIsForeground_SUCCESS) {
DataAccessor<ApplicationSet> accessor(app_list_, lock_);
EXPECT_CALL(app_mngr_, applications()).WillRepeatedly(Return(accessor));
ON_CALL(*mock_app_first, protocol_version())
- .WillByDefault(Return(am::ProtocolVersion::kV4));
+ .WillByDefault(
+ Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5));
ON_CALL(*mock_app_first, device()).WillByDefault(Return(kHandle));
EXPECT_CALL(*mock_app_first, is_foreground()).WillOnce(Return(true));
@@ -389,7 +393,8 @@ TEST_F(SDLActivateAppRequestTest, FirstAppNotRegisteredAndEmpty_SUCCESS) {
DataAccessor<ApplicationSet> accessor(app_list_, lock_);
EXPECT_CALL(app_mngr_, applications()).WillRepeatedly(Return(accessor));
ON_CALL(*mock_app_first, protocol_version())
- .WillByDefault(Return(am::ProtocolVersion::kV4));
+ .WillByDefault(
+ Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5));
EXPECT_CALL(*mock_app_first, is_foreground()).WillOnce(Return(false));
EXPECT_CALL(*message_helper_mock_, SendLaunchApp(_, _, _, _));
@@ -423,7 +428,8 @@ TEST_F(SDLActivateAppRequestTest, FirstAppNotRegistered_SUCCESS) {
app_list_.insert(mock_app_first);
ON_CALL(*mock_app_first, protocol_version())
- .WillByDefault(Return(am::ProtocolVersion::kV4));
+ .WillByDefault(
+ Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5));
EXPECT_CALL(*mock_app_first, is_foreground()).WillRepeatedly(Return(true));
EXPECT_CALL(*message_helper_mock_, SendLaunchApp(_, _, _, _));
diff --git a/src/components/application_manager/test/commands/hmi/simple_requests_to_hmi_test.cc b/src/components/application_manager/test/commands/hmi/simple_requests_to_hmi_test.cc
index f444e45a6c..3fa3aaef3a 100644
--- a/src/components/application_manager/test/commands/hmi/simple_requests_to_hmi_test.cc
+++ b/src/components/application_manager/test/commands/hmi/simple_requests_to_hmi_test.cc
@@ -2,6 +2,9 @@
* Copyright (c) 2016, Ford Motor Company
* All rights reserved.
*
+ * Copyright (c) 2017 Xevo Inc.
+ * All rights reserved.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
@@ -13,7 +16,7 @@
* 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
+ * Neither the name of the copyright holders nor the names of their contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -114,6 +117,7 @@
#include "application_manager/commands/hmi/sdl_policy_update.h"
#include "application_manager/commands/hmi/ui_set_icon_request.h"
#include "application_manager/commands/hmi/dial_number_request.h"
+#include "application_manager/commands/hmi/ui_send_haptic_data_request.h"
#include "application_manager/test/include/application_manager/mock_event_dispatcher.h"
@@ -217,7 +221,8 @@ typedef Types<am_commands::VIGetVehicleTypeRequest,
am_commands::NaviAlertManeuverRequest,
am_commands::AudioStopStreamRequest,
am_commands::NaviGetWayPointsRequest,
- am_commands::UISetGlobalPropertiesRequest> RequestCommandsList;
+ am_commands::UISetGlobalPropertiesRequest,
+ am_commands::UISendHapticDataRequest> RequestCommandsList;
typedef Types<am_commands::UIScrollableMessageRequest,
am_commands::VRGetCapabilitiesRequest,
diff --git a/src/components/application_manager/test/commands/hmi/simple_response_from_hmi_test.cc b/src/components/application_manager/test/commands/hmi/simple_response_from_hmi_test.cc
index 7e55b8b834..f55b2e5835 100644
--- a/src/components/application_manager/test/commands/hmi/simple_response_from_hmi_test.cc
+++ b/src/components/application_manager/test/commands/hmi/simple_response_from_hmi_test.cc
@@ -2,6 +2,9 @@
* Copyright (c) 2016, Ford Motor Company
* All rights reserved.
*
+ * Copyright (c) 2017 Xevo Inc.
+ * All rights reserved.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
@@ -13,7 +16,7 @@
* 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
+ * Neither the name of the copyright holders nor the names of their contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -102,6 +105,7 @@
#include "hmi/update_app_list_response.h"
#include "hmi/update_device_list_response.h"
#include "hmi/notification_from_hmi.h"
+#include "hmi/ui_send_haptic_data_response.h"
namespace test {
namespace components {
@@ -232,8 +236,9 @@ typedef Types<
CommandData<commands::VRPerformInteractionResponse,
hmi_apis::FunctionID::VR_PerformInteraction>,
CommandData<commands::UIScrollableMessageResponse,
- hmi_apis::FunctionID::UI_ScrollableMessage> >
- ResponseCommandsList;
+ hmi_apis::FunctionID::UI_ScrollableMessage>,
+ CommandData<commands::UISendHapticDataResponse,
+ hmi_apis::FunctionID::UI_SendHapticData> > ResponseCommandsList;
typedef Types<commands::AudioStopStreamResponse,
commands::NaviStopStreamResponse,
diff --git a/src/components/application_manager/test/commands/hmi/ui_get_capabilities_response_test.cc b/src/components/application_manager/test/commands/hmi/ui_get_capabilities_response_test.cc
index 11162f9a03..b02c9851ee 100644
--- a/src/components/application_manager/test/commands/hmi/ui_get_capabilities_response_test.cc
+++ b/src/components/application_manager/test/commands/hmi/ui_get_capabilities_response_test.cc
@@ -2,6 +2,9 @@
* Copyright (c) 2016, Ford Motor Company
* All rights reserved.
*
+ * Copyright (c) 2017 Xevo Inc.
+ * All rights reserved.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
@@ -13,7 +16,7 @@
* 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
+ * Neither the name of the copyright holders nor the names of their contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -216,6 +219,126 @@ TEST_F(UIGetCapabilitiesResponseTest, SetPhoneCall_SUCCESS) {
command->Run();
}
+TEST_F(UIGetCapabilitiesResponseTest, SetVideoStreaming_SUCCESS) {
+ MessageSharedPtr command_msg = CreateCommandMsg();
+ (*command_msg)[strings::msg_params][strings::hmi_capabilities] =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ (*command_msg)[strings::msg_params][strings::hmi_capabilities]
+ [strings::video_streaming] = true;
+
+ ResponseFromHMIPtr command(
+ CreateCommand<UIGetCapabilitiesResponse>(command_msg));
+
+ EXPECT_CALL(app_mngr_, hmi_capabilities())
+ .WillOnce(ReturnRef(mock_hmi_capabilities_));
+
+ smart_objects::SmartObject hmi_capabilities_so =
+ (*command_msg)[strings::msg_params][strings::hmi_capabilities];
+ EXPECT_CALL(mock_hmi_capabilities_,
+ set_video_streaming_supported(
+ hmi_capabilities_so[strings::video_streaming].asBool()));
+
+ command->Run();
+}
+
+TEST_F(UIGetCapabilitiesResponseTest, SetNavigationCapability_SUCCESS) {
+ MessageSharedPtr command_msg = CreateCommandMsg();
+ (*command_msg)[strings::msg_params][strings::system_capabilities] =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+
+ (*command_msg)[strings::msg_params][strings::system_capabilities]
+ [strings::navigation_capability]["sendLocationEnabled"] = true;
+
+ (*command_msg)[strings::msg_params][strings::system_capabilities]
+ [strings::navigation_capability]["getWayPointsEnabled"] = true;
+
+ ResponseFromHMIPtr command(
+ CreateCommand<UIGetCapabilitiesResponse>(command_msg));
+
+ EXPECT_CALL(app_mngr_, hmi_capabilities())
+ .WillOnce(ReturnRef(mock_hmi_capabilities_));
+
+ smart_objects::SmartObject navigation_capability_so =
+ (*command_msg)[strings::msg_params][strings::system_capabilities]
+ [strings::navigation_capability];
+
+ EXPECT_CALL(mock_hmi_capabilities_,
+ set_navigation_capability(navigation_capability_so));
+
+ command->Run();
+}
+
+TEST_F(UIGetCapabilitiesResponseTest, SetPhonenCapability_SUCCESS) {
+ MessageSharedPtr command_msg = CreateCommandMsg();
+ (*command_msg)[strings::msg_params][strings::system_capabilities] =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+
+ (*command_msg)[strings::msg_params][strings::system_capabilities]
+ [strings::phone_capability]["dialNumberEnabled"] = true;
+
+ ResponseFromHMIPtr command(
+ CreateCommand<UIGetCapabilitiesResponse>(command_msg));
+
+ EXPECT_CALL(app_mngr_, hmi_capabilities())
+ .WillOnce(ReturnRef(mock_hmi_capabilities_));
+
+ smart_objects::SmartObject phone_capability_so =
+ (*command_msg)[strings::msg_params][strings::system_capabilities]
+ [strings::phone_capability];
+
+ EXPECT_CALL(mock_hmi_capabilities_,
+ set_phone_capability(phone_capability_so));
+
+ command->Run();
+}
+
+TEST_F(UIGetCapabilitiesResponseTest, SetVideoStreamingCapability_SUCCESS) {
+ MessageSharedPtr command_msg = CreateCommandMsg();
+ (*command_msg)[strings::msg_params][strings::system_capabilities] =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+
+ (*command_msg)[strings::msg_params][strings::system_capabilities]
+ [strings::video_streaming_capability] =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ smart_objects::SmartObject& video_streaming_capability =
+ (*command_msg)[strings::msg_params][strings::system_capabilities]
+ [strings::video_streaming_capability];
+
+ video_streaming_capability[strings::preferred_resolution] =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ video_streaming_capability[strings::preferred_resolution]
+ [strings::resolution_width] = 800;
+ video_streaming_capability[strings::preferred_resolution]
+ [strings::resolution_height] = 350;
+
+ video_streaming_capability[strings::max_bitrate] = 10000;
+
+ video_streaming_capability[strings::supported_formats] =
+ smart_objects::SmartObject(smart_objects::SmartType_Array);
+
+ video_streaming_capability[strings::supported_formats][0] =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+
+ video_streaming_capability[strings::supported_formats][0][strings::protocol] =
+ hmi_apis::Common_VideoStreamingProtocol::RAW;
+
+ video_streaming_capability[strings::supported_formats][0][strings::codec] =
+ hmi_apis::Common_VideoStreamingCodec::H264;
+
+ video_streaming_capability[strings::haptic_spatial_data_supported] = true;
+
+ ResponseFromHMIPtr command(
+ CreateCommand<UIGetCapabilitiesResponse>(command_msg));
+
+ EXPECT_CALL(app_mngr_, hmi_capabilities())
+ .WillOnce(ReturnRef(mock_hmi_capabilities_));
+
+ EXPECT_CALL(mock_hmi_capabilities_,
+ set_video_streaming_capability(video_streaming_capability));
+
+ command->Run();
+}
+
} // namespace ui_get_capabilities_response
} // namespace hmi_commands_test
} // namespace commands_test
diff --git a/src/components/application_manager/test/commands/hmi/ui_is_ready_request_test.cc b/src/components/application_manager/test/commands/hmi/ui_is_ready_request_test.cc
index 2759a8a19e..23146eec9a 100644
--- a/src/components/application_manager/test/commands/hmi/ui_is_ready_request_test.cc
+++ b/src/components/application_manager/test/commands/hmi/ui_is_ready_request_test.cc
@@ -151,7 +151,6 @@ class UIIsReadyRequestTest
}
UIIsReadyRequestPtr command_;
- am::MockHmiInterfaces mock_hmi_interfaces_;
MockMessageHelper& mock_message_helper_;
application_manager_test::MockHMICapabilities mock_hmi_capabilities_;
policy_test::MockPolicyHandlerInterface mock_policy_handler_interface_;
diff --git a/src/components/application_manager/test/commands/hmi/vi_is_ready_request_test.cc b/src/components/application_manager/test/commands/hmi/vi_is_ready_request_test.cc
index 48293f9a12..1e15d4ab60 100644
--- a/src/components/application_manager/test/commands/hmi/vi_is_ready_request_test.cc
+++ b/src/components/application_manager/test/commands/hmi/vi_is_ready_request_test.cc
@@ -121,7 +121,6 @@ class VIIsReadyRequestTest
}
VIIsReadyRequestPtr command_;
- am::MockHmiInterfaces mock_hmi_interfaces_;
application_manager_test::MockHMICapabilities mock_hmi_capabilities_;
policy_test::MockPolicyHandlerInterface mock_policy_handler_interface_;
};
diff --git a/src/components/application_manager/test/commands/hmi/vr_is_ready_request_test.cc b/src/components/application_manager/test/commands/hmi/vr_is_ready_request_test.cc
index 64e5c25546..64735a77e2 100644
--- a/src/components/application_manager/test/commands/hmi/vr_is_ready_request_test.cc
+++ b/src/components/application_manager/test/commands/hmi/vr_is_ready_request_test.cc
@@ -139,7 +139,6 @@ class VRIsReadyRequestTest
}
VRIsReadyRequestPtr command_;
- am::MockHmiInterfaces mock_hmi_interfaces_;
application_manager_test::MockHMICapabilities mock_hmi_capabilities_;
};
diff --git a/src/components/application_manager/test/commands/mobile/add_command_request_test.cc b/src/components/application_manager/test/commands/mobile/add_command_request_test.cc
index 567c3d32f9..dec0ffe7ad 100644
--- a/src/components/application_manager/test/commands/mobile/add_command_request_test.cc
+++ b/src/components/application_manager/test/commands/mobile/add_command_request_test.cc
@@ -62,7 +62,6 @@ using am::ApplicationManager;
using am::commands::MessageSharedPtr;
using am::ApplicationSharedPtr;
using am::MockMessageHelper;
-using am::MockHmiInterfaces;
using ::testing::_;
using ::utils::SharedPtr;
using ::testing::Return;
@@ -520,7 +519,6 @@ TEST_F(AddCommandRequestTest, OnEvent_UI_SUCCESS) {
EXPECT_CALL(mock_message_helper_,
HMIToMobileResult(hmi_apis::Common_Result::SUCCESS))
.WillOnce(Return(mobile_apis::Result::SUCCESS));
- EXPECT_CALL(*mock_app_, UpdateHash());
request_ptr->on_event(event);
}
@@ -541,7 +539,6 @@ TEST_F(AddCommandRequestTest, OnEvent_VR_SUCCESS) {
EXPECT_CALL(*mock_app_, commands_map())
.WillRepeatedly(
Return(DataAccessor<am::CommandsMap>(commands_map, lock_)));
- EXPECT_CALL(*mock_app_, UpdateHash());
EXPECT_CALL(
app_mngr_,
ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand)))
@@ -668,7 +665,6 @@ TEST_F(AddCommandRequestTest,
event_ui.set_smart_object(*msg_);
Event event_vr(hmi_apis::FunctionID::VR_AddCommand);
event_vr.set_smart_object(*msg_);
- EXPECT_CALL(*mock_app_, UpdateHash());
request_ptr->on_event(event_ui);
request_ptr->on_event(event_vr);
}
diff --git a/src/components/application_manager/test/commands/mobile/add_sub_menu_request_test.cc b/src/components/application_manager/test/commands/mobile/add_sub_menu_request_test.cc
index 95bcede5fa..9617f91016 100644
--- a/src/components/application_manager/test/commands/mobile/add_sub_menu_request_test.cc
+++ b/src/components/application_manager/test/commands/mobile/add_sub_menu_request_test.cc
@@ -54,7 +54,6 @@ namespace am = ::application_manager;
using am::commands::AddSubMenuRequest;
using am::commands::MessageSharedPtr;
using am::event_engine::Event;
-using am::MockHmiInterfaces;
using am::MockMessageHelper;
using ::testing::_;
using ::testing::Mock;
@@ -98,12 +97,6 @@ TEST_F(AddSubMenuRequestTest, OnEvent_UI_UNSUPPORTED_RESOURCE) {
Event event(hmi_apis::FunctionID::UI_AddSubMenu);
event.set_smart_object(*ev_msg);
- MockHmiInterfaces hmi_interfaces;
- ON_CALL(app_mngr_, hmi_interfaces()).WillByDefault(ReturnRef(hmi_interfaces));
- EXPECT_CALL(hmi_interfaces,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE));
-
EXPECT_CALL(mock_message_helper_,
HMIToMobileResult(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE))
.WillOnce(Return(mobile_apis::Result::UNSUPPORTED_RESOURCE));
@@ -113,7 +106,7 @@ TEST_F(AddSubMenuRequestTest, OnEvent_UI_UNSUPPORTED_RESOURCE) {
app_mngr_,
ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
.WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true)));
-
+ command->Init();
command->on_event(event);
EXPECT_EQ((*ui_command_result)[am::strings::msg_params][am::strings::success]
diff --git a/src/components/application_manager/test/commands/mobile/alert_maneuver_request_test.cc b/src/components/application_manager/test/commands/mobile/alert_maneuver_request_test.cc
index a835239a90..ee0662e5c6 100644
--- a/src/components/application_manager/test/commands/mobile/alert_maneuver_request_test.cc
+++ b/src/components/application_manager/test/commands/mobile/alert_maneuver_request_test.cc
@@ -63,7 +63,6 @@ namespace am = ::application_manager;
using am::commands::AlertManeuverRequest;
using am::commands::MessageSharedPtr;
using am::event_engine::Event;
-using am::MockHmiInterfaces;
using am::MockMessageHelper;
typedef SharedPtr<AlertManeuverRequest> CommandPtr;
@@ -93,10 +92,7 @@ class AlertManeuverRequestTest
EXPECT_CALL(*mock_message_helper, HMIToMobileResult(_))
.WillOnce(Return(mobile_apis::Result::UNSUPPORTED_RESOURCE));
- MockHmiInterfaces hmi_interfaces;
- EXPECT_CALL(app_mngr_, hmi_interfaces())
- .WillRepeatedly(ReturnRef(hmi_interfaces));
- EXPECT_CALL(hmi_interfaces, GetInterfaceState(_))
+ EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillRepeatedly(Return(state));
MessageSharedPtr response_to_mobile;
@@ -213,13 +209,10 @@ TEST_F(AlertManeuverRequestTest, Run_ProcessingResult_SUCCESS) {
ProcessSoftButtons(_, _, _, _))
.WillOnce(Return(mobile_apis::Result::SUCCESS));
- MockHmiInterfaces hmi_interfaces;
- EXPECT_CALL(app_mngr_, hmi_interfaces())
- .WillRepeatedly(ReturnRef(hmi_interfaces));
- EXPECT_CALL(hmi_interfaces, GetInterfaceFromFunction(_))
+ EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceFromFunction(_))
.WillRepeatedly(
Return(am::HmiInterfaces::InterfaceID::HMI_INTERFACE_TTS));
- EXPECT_CALL(hmi_interfaces, GetInterfaceState(_))
+ EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE));
EXPECT_CALL(*(am::MockMessageHelper::message_helper_mock()),
diff --git a/src/components/application_manager/test/commands/mobile/alert_request_test.cc b/src/components/application_manager/test/commands/mobile/alert_request_test.cc
index 43151c2d98..f83a40843c 100644
--- a/src/components/application_manager/test/commands/mobile/alert_request_test.cc
+++ b/src/components/application_manager/test/commands/mobile/alert_request_test.cc
@@ -56,7 +56,6 @@ using am::commands::AlertRequest;
using am::commands::CommandImpl;
using am::commands::MessageSharedPtr;
using am::MockMessageHelper;
-using am::MockHmiInterfaces;
using ::utils::SharedPtr;
using am::event_engine::Event;
using policy_test::MockPolicyHandlerInterface;
@@ -125,15 +124,13 @@ class AlertRequestTest : public CommandRequestTest<CommandsTestMocks::kIsNice> {
ON_CALL(app_mngr_, application(kConnectionKey))
.WillByDefault(Return(mock_app_));
ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey));
- ON_CALL(app_mngr_, hmi_interfaces())
- .WillByDefault(ReturnRef(hmi_interfaces_));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
.WillByDefault(
Return(am::HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
.WillByDefault(
Return(am::HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE));
@@ -199,7 +196,6 @@ class AlertRequestTest : public CommandRequestTest<CommandsTestMocks::kIsNice> {
MockAppPtr mock_app_;
MessageSharedPtr msg_;
MockPolicyHandlerInterface mock_policy_handler_;
- NiceMock<MockHmiInterfaces> hmi_interfaces_;
};
TEST_F(AlertRequestTest, OnTimeout_GENERIC_ERROR) {
@@ -267,6 +263,9 @@ TEST_F(AlertRequestTest, OnEvent_UI_HmiSendSuccess_UNSUPPORTED_RESOURCE) {
event.set_smart_object(*msg);
MessageSharedPtr ui_command_result;
+ ON_CALL(mock_message_helper_,
+ HMIToMobileResult(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE))
+ .WillByDefault(Return(am::mobile_api::Result::UNSUPPORTED_RESOURCE));
EXPECT_CALL(
app_mngr_,
ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
diff --git a/src/components/application_manager/test/commands/mobile/change_registration_test.cc b/src/components/application_manager/test/commands/mobile/change_registration_test.cc
index 0c76a08fe9..2fd43a6353 100644
--- a/src/components/application_manager/test/commands/mobile/change_registration_test.cc
+++ b/src/components/application_manager/test/commands/mobile/change_registration_test.cc
@@ -65,7 +65,6 @@ using am::ApplicationManager;
using am::commands::MessageSharedPtr;
using am::ApplicationSharedPtr;
using am::MockMessageHelper;
-using am::MockHmiInterfaces;
using ::testing::_;
using ::testing::Mock;
using ::utils::SharedPtr;
@@ -118,28 +117,28 @@ class ChangeRegistrationRequestTest
.WillOnce(Return(supported_languages_.get()));
EXPECT_CALL(app_mngr_, hmi_interfaces())
- .WillRepeatedly(ReturnRef(hmi_interfaces_));
+ .WillRepeatedly(ReturnRef(mock_hmi_interfaces_));
EXPECT_CALL(
- hmi_interfaces_,
+ mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::UI_ChangeRegistration))
.WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- EXPECT_CALL(hmi_interfaces_,
+ EXPECT_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
.WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE));
EXPECT_CALL(
- hmi_interfaces_,
+ mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::VR_ChangeRegistration))
.WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_VR));
- EXPECT_CALL(hmi_interfaces_,
+ EXPECT_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR))
.WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE));
EXPECT_CALL(
- hmi_interfaces_,
+ mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_ChangeRegistration))
.WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
- EXPECT_CALL(hmi_interfaces_,
+ EXPECT_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
.WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE));
}
@@ -185,10 +184,7 @@ class ChangeRegistrationRequestTest
(*tts_response)[strings::params][hmi_response::code] = hmi_response;
(*tts_response)[strings::msg_params] = 0;
- MockHmiInterfaces hmi_interfaces;
- EXPECT_CALL(app_mngr_, hmi_interfaces())
- .WillRepeatedly(ReturnRef(hmi_interfaces));
- EXPECT_CALL(hmi_interfaces, GetInterfaceState(_))
+ EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillRepeatedly(Return(state));
am::event_engine::Event event_ui(
@@ -251,8 +247,6 @@ class ChangeRegistrationRequestTest
ON_CALL(app_mngr_, application(kConnectionKey))
.WillByDefault(Return(mock_app_));
ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey));
- ON_CALL(app_mngr_, hmi_interfaces())
- .WillByDefault(ReturnRef(hmi_interfaces_));
ON_CALL(app_mngr_, hmi_capabilities())
.WillByDefault(ReturnRef(hmi_capabilities_));
}
@@ -288,7 +282,6 @@ class ChangeRegistrationRequestTest
MockHMICapabilities;
sync_primitives::Lock app_set_lock_;
MockHMICapabilities hmi_capabilities_;
- NiceMock<MockHmiInterfaces> hmi_interfaces_;
MockMessageHelper& mock_message_helper_;
MockAppPtr mock_app_;
MessageSharedPtr supported_languages_;
@@ -322,25 +315,25 @@ TEST_F(ChangeRegistrationRequestTest,
ExpectationsHmiCapabilities(supported_languages);
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::UI_ChangeRegistration))
.WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
.WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::VR_ChangeRegistration))
.WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_VR));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR))
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_RESPONSE));
ON_CALL(
- hmi_interfaces_,
+ mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_ChangeRegistration))
.WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
.WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
command->Run();
@@ -367,10 +360,7 @@ TEST_F(ChangeRegistrationRequestTest,
hmi_apis::FunctionID::TTS_ChangeRegistration);
event_tts.set_smart_object(*tts_response);
- MockHmiInterfaces hmi_interfaces;
- EXPECT_CALL(app_mngr_, hmi_interfaces())
- .WillRepeatedly(ReturnRef(hmi_interfaces));
- EXPECT_CALL(hmi_interfaces, GetInterfaceState(_))
+ EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
MessageSharedPtr response_to_mobile;
@@ -478,25 +468,25 @@ TEST_F(ChangeRegistrationRequestTest,
ExpectationsHmiCapabilities(supported_languages);
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::UI_ChangeRegistration))
.WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::VR_ChangeRegistration))
.WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_VR));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR))
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
ON_CALL(
- hmi_interfaces_,
+ mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_ChangeRegistration))
.WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
diff --git a/src/components/application_manager/test/commands/mobile/create_interaction_choice_set_test.cc b/src/components/application_manager/test/commands/mobile/create_interaction_choice_set_test.cc
index a0b0dc32ff..a627740588 100644
--- a/src/components/application_manager/test/commands/mobile/create_interaction_choice_set_test.cc
+++ b/src/components/application_manager/test/commands/mobile/create_interaction_choice_set_test.cc
@@ -64,7 +64,6 @@ using am::ApplicationManager;
using am::commands::MessageSharedPtr;
using am::ApplicationSharedPtr;
using am::MockMessageHelper;
-using am::MockHmiInterfaces;
using ::testing::_;
using ::testing::Mock;
using ::utils::SharedPtr;
@@ -116,7 +115,7 @@ class CreateInteractionChoiceSetRequestTest
: message_helper_mock_(*am::MockMessageHelper::message_helper_mock())
, message_(CreateMessage())
, command_(CreateCommand<CreateInteractionChoiceSetRequest>(message_))
- , app_(CreateMockApp()) {
+ , mock_app_(CreateMockApp()) {
Mock::VerifyAndClearExpectations(&message_helper_mock_);
}
~CreateInteractionChoiceSetRequestTest() {
@@ -166,7 +165,7 @@ class CreateInteractionChoiceSetRequestTest
MockMessageHelper& message_helper_mock_;
MessageSharedPtr message_;
CreateInteractionChoiceSetRequestPtr command_;
- MockAppPtr app_;
+ MockAppPtr mock_app_;
sync_primitives::Lock lock_;
};
@@ -213,11 +212,10 @@ TEST_F(CreateInteractionChoiceSetRequestTest, OnEvent_VR_UNSUPPORTED_RESOURCE) {
utils::SharedPtr<CreateInteractionChoiceSetRequest> req_vr =
CreateCommand<CreateInteractionChoiceSetRequest>(msg_vr);
- MockAppPtr mock_app = CreateMockApp();
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app));
- ON_CALL(*mock_app, app_id()).WillByDefault(Return(kConnectionKey));
+ ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_));
+
smart_objects::SmartObject* null_obj = NULL;
- ON_CALL(*mock_app, FindChoiceSet(_)).WillByDefault(Return(null_obj));
+ ON_CALL(*mock_app_, FindChoiceSet(_)).WillByDefault(Return(null_obj));
MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
(*msg)[strings::params][hmi_response::code] =
@@ -229,25 +227,21 @@ TEST_F(CreateInteractionChoiceSetRequestTest, OnEvent_VR_UNSUPPORTED_RESOURCE) {
event.set_smart_object(*msg);
smart_objects::SmartObject* ptr = NULL;
- ON_CALL(*mock_app, FindCommand(kCmdId)).WillByDefault(Return(ptr));
+ ON_CALL(*mock_app_, FindCommand(kCmdId)).WillByDefault(Return(ptr));
EXPECT_EQ(NULL, ptr);
- MockMessageHelper* mock_message_helper =
- MockMessageHelper::message_helper_mock();
- ON_CALL(*mock_message_helper, HMIToMobileResult(_))
+ ON_CALL(message_helper_mock_, HMIToMobileResult(_))
.WillByDefault(Return(mobile_apis::Result::SUCCESS));
am::CommandsMap commands_map;
- ON_CALL(*mock_app, commands_map())
+ ON_CALL(*mock_app_, commands_map())
.WillByDefault(
Return(DataAccessor<am::CommandsMap>(commands_map, lock_)));
- MockHmiInterfaces hmi_interfaces;
- ON_CALL(app_mngr_, hmi_interfaces()).WillByDefault(ReturnRef(hmi_interfaces));
- ON_CALL(hmi_interfaces, GetInterfaceFromFunction(_))
+
+ ON_CALL(mock_hmi_interfaces_, GetInterfaceFromFunction(_))
.WillByDefault(
Return(am::HmiInterfaces::HMI_INTERFACE_BasicCommunication));
- ON_CALL(hmi_interfaces, GetInterfaceState(_))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
+
EXPECT_CALL(app_mngr_, ManageHMICommand(_)).WillOnce(Return(true));
req_vr->Run();
@@ -287,7 +281,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest, Run_VerifyImageFail_UNSUCCESS) {
(*message_)[am::strings::msg_params][am::strings::choice_set][0]
[am::strings::secondary_image] = kSecondImage;
- EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(app_));
+ EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_));
EXPECT_CALL(message_helper_mock_, VerifyImage(_, _, _))
.WillRepeatedly(Return(mobile_apis::Result::INVALID_DATA));
EXPECT_CALL(app_mngr_, GenerateGrammarID()).Times(0);
@@ -303,14 +297,14 @@ TEST_F(CreateInteractionChoiceSetRequestTest, Run_FindChoiceSetFail_UNSUCCESS) {
(*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] =
kChoiceSetId;
- EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(app_));
+ EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_));
EXPECT_CALL(message_helper_mock_, VerifyImage(_, _, _))
.WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
smart_objects::SmartObject* invalid_choice_set_id =
&((*message_)[am::strings::msg_params]
[am::strings::interaction_choice_set_id]);
- EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId))
+ EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(invalid_choice_set_id));
EXPECT_CALL(app_mngr_, GenerateGrammarID()).Times(0);
command_->Run();
@@ -337,13 +331,13 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
(*message_)[am::strings::msg_params][am::strings::choice_set][1]
[am::strings::vr_commands][0] = kVrCommands1;
- EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(app_));
+ EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_));
EXPECT_CALL(message_helper_mock_, VerifyImage(_, _, _))
.WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
smart_objects::SmartObject* choice_set_id = NULL;
- EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId))
+ EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(choice_set_id));
EXPECT_CALL(app_mngr_, GenerateGrammarID()).Times(0);
@@ -372,9 +366,9 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
kChoiceSetId;
smart_objects::SmartObject* choice_set_id = NULL;
- EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId))
+ EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillRepeatedly(Return(choice_set_id));
- EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app_));
+ EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(mock_app_));
EXPECT_CALL(message_helper_mock_, VerifyImage(_, _, _))
.WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
@@ -443,17 +437,17 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
Run_ValidAmountVrCommands_SUCCESS) {
FillMessageFieldsItem1(message_);
FillMessageFieldsItem2(message_);
- EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(app_));
+ EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_));
EXPECT_CALL(message_helper_mock_, VerifyImage(_, _, _))
.WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
smart_objects::SmartObject* choice_set_id = NULL;
- EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId))
+ EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(choice_set_id));
EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId));
- EXPECT_CALL(*app_, AddChoiceSet(kChoiceSetId, _));
+ EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
EXPECT_CALL(app_mngr_, GetNextHMICorrelationID())
.Times(AtLeast(2))
.WillOnce(Return(kConnectionKey))
@@ -482,16 +476,16 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
(*message_)[am::strings::msg_params][am::strings::choice_set][1]
[am::strings::vr_commands][0] = kVrCommands2;
- EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(app_));
+ EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_));
EXPECT_CALL(message_helper_mock_, VerifyImage(_, _, _))
.WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
smart_objects::SmartObject* choice_set_id = NULL;
- EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId))
+ EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(choice_set_id));
- EXPECT_CALL(*app_, AddChoiceSet(kChoiceSetId, _));
+ EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
command_->Run();
}
@@ -528,17 +522,17 @@ TEST_F(CreateInteractionChoiceSetRequestTest, OnEvent_ValidVrNoError_SUCCESS) {
FillMessageFieldsItem1(message_);
FillMessageFieldsItem2(message_);
- EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(app_));
+ EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_));
EXPECT_CALL(message_helper_mock_, VerifyImage(_, _, _))
.WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
smart_objects::SmartObject* choice_set_id = NULL;
- EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId))
+ EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(choice_set_id));
EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId));
- EXPECT_CALL(*app_, AddChoiceSet(kChoiceSetId, _));
+ EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
ON_CALL(app_mngr_, GetNextHMICorrelationID())
.WillByDefault(Return(kCorrelationId));
command_->Run();
@@ -561,17 +555,17 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
FillMessageFieldsItem1(message_);
FillMessageFieldsItem2(message_);
- EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(app_));
+ EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_));
EXPECT_CALL(message_helper_mock_, VerifyImage(_, _, _))
.WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
smart_objects::SmartObject* choice_set_id = NULL;
- EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId))
+ EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(choice_set_id));
EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId));
- EXPECT_CALL(*app_, AddChoiceSet(kChoiceSetId, _));
+ EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
ON_CALL(app_mngr_, GetNextHMICorrelationID())
.WillByDefault(Return(kCorrelationId));
command_->Run();
@@ -595,17 +589,17 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
(*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] =
kChoiceSetId;
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app_));
+ ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_));
EXPECT_CALL(message_helper_mock_, VerifyImage(_, _, _))
.WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
smart_objects::SmartObject* choice_set_id = NULL;
- EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId))
+ EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(choice_set_id));
EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId));
- EXPECT_CALL(*app_, AddChoiceSet(kChoiceSetId, _));
+ EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
ON_CALL(app_mngr_, GetNextHMICorrelationID())
.WillByDefault(Return(kCorrelationId));
command_->Run();
@@ -620,7 +614,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
TEST_F(CreateInteractionChoiceSetRequestTest,
OnTimeOut_InvalidErrorFromHMI_UNSUCCESS) {
- EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(app_));
+ EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_));
EXPECT_CALL(app_mngr_,
ManageMobileCommand(
@@ -642,17 +636,17 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
(*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] =
kChoiceSetId;
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app_));
+ ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_));
EXPECT_CALL(message_helper_mock_, VerifyImage(_, _, _))
.WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
smart_objects::SmartObject* choice_set_id = NULL;
- EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId))
+ EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(choice_set_id));
EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId));
- EXPECT_CALL(*app_, AddChoiceSet(kChoiceSetId, _));
+ EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
ON_CALL(app_mngr_, GetNextHMICorrelationID())
.WillByDefault(Return(kCorrelationId));
command_->Run();
@@ -664,7 +658,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
event.set_smart_object(*message_);
command_->on_event(event);
- EXPECT_CALL(*app_, RemoveChoiceSet(kChoiceSetId));
+ EXPECT_CALL(*mock_app_, RemoveChoiceSet(kChoiceSetId));
EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _));
command_->onTimeOut();
@@ -682,17 +676,17 @@ TEST_F(CreateInteractionChoiceSetRequestTest, OnTimeOut_InvalidApp_UNSUCCESS) {
(*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] =
kChoiceSetId;
- EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app_));
+ EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(mock_app_));
EXPECT_CALL(message_helper_mock_, VerifyImage(_, _, _))
.WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
smart_objects::SmartObject* choice_set_id = NULL;
- EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId))
+ EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(choice_set_id));
EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId));
- EXPECT_CALL(*app_, AddChoiceSet(kChoiceSetId, _));
+ EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
ON_CALL(app_mngr_, GetNextHMICorrelationID())
.WillByDefault(Return(kCorrelationId));
command_->Run();
@@ -707,7 +701,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest, OnTimeOut_InvalidApp_UNSUCCESS) {
MockAppPtr invalid_app;
EXPECT_CALL(app_mngr_, application(kConnectionKey))
.WillOnce(Return(invalid_app));
- EXPECT_CALL(*app_, RemoveChoiceSet(_)).Times(0);
+ EXPECT_CALL(*mock_app_, RemoveChoiceSet(_)).Times(0);
command_->onTimeOut();
}
@@ -724,34 +718,38 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
(*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] =
kChoiceSetId;
- EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app_));
-
EXPECT_CALL(message_helper_mock_, VerifyImage(_, _, _))
.WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
smart_objects::SmartObject* choice_set_id = NULL;
- EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId))
- .WillOnce(Return(choice_set_id));
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app_));
EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId));
- EXPECT_CALL(*app_, AddChoiceSet(kChoiceSetId, _));
ON_CALL(app_mngr_, GetNextHMICorrelationID())
.WillByDefault(Return(kCorrelationId));
+
+ EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
+ .WillOnce(Return(choice_set_id));
+ EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
+
command_->Run();
FillMessageFieldsItem2(message_);
+
EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)).Times(0);
EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _));
+
Event event(hmi_apis::FunctionID::VR_AddCommand);
event.set_smart_object(*message_);
- MockAppPtr invalid_app;
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(invalid_app));
command_->on_event(event);
- EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app_));
- EXPECT_CALL(*app_, RemoveChoiceSet(_));
+ EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _));
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app_));
+ EXPECT_CALL(*mock_app_, RemoveChoiceSet(_));
+
command_->onTimeOut();
}
@@ -791,18 +789,18 @@ TEST_F(CreateInteractionChoiceSetRequestTest, Run_ErrorFromHmiFalse_UNSUCCESS) {
(*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] =
kChoiceSetId;
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app_));
+ ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_));
EXPECT_CALL(message_helper_mock_, VerifyImage(_, _, _))
.WillRepeatedly(Return(mobile_apis::Result::GENERIC_ERROR));
smart_objects::SmartObject* choice_set_id = NULL;
- EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId))
+ EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillRepeatedly(Return(choice_set_id));
EXPECT_CALL(app_mngr_, GenerateGrammarID())
.WillRepeatedly(Return(kGrammarId));
- EXPECT_CALL(*app_, AddChoiceSet(kChoiceSetId, _)).Times(2);
+ EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _)).Times(2);
ON_CALL(app_mngr_, GetNextHMICorrelationID())
.WillByDefault(Return(kCorrelationId));
command_->Run();
diff --git a/src/components/application_manager/test/commands/mobile/delete_command_request_test.cc b/src/components/application_manager/test/commands/mobile/delete_command_request_test.cc
index 1e03dcaaf1..efa889a2c1 100644
--- a/src/components/application_manager/test/commands/mobile/delete_command_request_test.cc
+++ b/src/components/application_manager/test/commands/mobile/delete_command_request_test.cc
@@ -61,7 +61,6 @@ using am::commands::DeleteCommandRequest;
using am::commands::MessageSharedPtr;
using am::event_engine::Event;
using am::MockMessageHelper;
-using am::MockHmiInterfaces;
typedef SharedPtr<DeleteCommandRequest> DeleteCommandPtr;
@@ -130,15 +129,12 @@ class DeleteCommandRequestTest
ON_CALL(app_mngr_, application(kConnectionKey))
.WillByDefault(Return(mock_app_));
ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey));
- ON_CALL(app_mngr_, hmi_interfaces())
- .WillByDefault(ReturnRef(hmi_interfaces_));
}
void TearDown() OVERRIDE {
Mock::VerifyAndClearExpectations(&mock_message_helper_);
}
- NiceMock<MockHmiInterfaces> hmi_interfaces_;
MockMessageHelper& mock_message_helper_;
MockAppPtr mock_app_;
};
@@ -158,12 +154,12 @@ TEST_F(DeleteCommandRequestTest,
(*test_msg)[am::strings::vr_commands] = 0;
(*test_msg)[am::strings::menu_params] = 0;
- ON_CALL(hmi_interfaces_, GetInterfaceFromFunction(_))
+ ON_CALL(mock_hmi_interfaces_, GetInterfaceFromFunction(_))
.WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_VR));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR))
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
ON_CALL(*mock_app_, FindCommand(kCommandId))
@@ -189,8 +185,6 @@ TEST_F(DeleteCommandRequestTest,
EXPECT_CALL(*mock_app_, RemoveCommand(kCommandId));
- EXPECT_CALL(*mock_app_, UpdateHash());
-
MessageSharedPtr vr_command_result;
EXPECT_CALL(
app_mngr_,
@@ -218,12 +212,12 @@ TEST_F(DeleteCommandRequestTest,
(*test_msg)[am::strings::vr_commands] = 0;
(*test_msg)[am::strings::menu_params] = 0;
- ON_CALL(hmi_interfaces_, GetInterfaceFromFunction(_))
+ ON_CALL(mock_hmi_interfaces_, GetInterfaceFromFunction(_))
.WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR))
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
ON_CALL(*app, FindCommand(kCommandId)).WillByDefault(Return(test_msg.get()));
@@ -248,8 +242,6 @@ TEST_F(DeleteCommandRequestTest,
EXPECT_CALL(*app, RemoveCommand(kCommandId));
- EXPECT_CALL(*app, UpdateHash());
-
MessageSharedPtr result_msg(
CatchMobileCommandResult(CallOnEvent(*command, event_ui)));
diff --git a/src/components/application_manager/test/commands/mobile/delete_file_test.cc b/src/components/application_manager/test/commands/mobile/delete_file_test.cc
index 6af9a62bf0..3692f7298e 100644
--- a/src/components/application_manager/test/commands/mobile/delete_file_test.cc
+++ b/src/components/application_manager/test/commands/mobile/delete_file_test.cc
@@ -159,7 +159,7 @@ TEST_F(DeleteFileRequestTest, Run_ValidFileName_SUCCESS) {
kConnectionKey;
EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
+ .WillRepeatedly(Return(mock_app_));
EXPECT_CALL(*mock_app_, hmi_level())
.WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL));
diff --git a/src/components/application_manager/test/commands/mobile/delete_interaction_choice_set_test.cc b/src/components/application_manager/test/commands/mobile/delete_interaction_choice_set_test.cc
index 64c2fae1d3..a6d9d8f50a 100644
--- a/src/components/application_manager/test/commands/mobile/delete_interaction_choice_set_test.cc
+++ b/src/components/application_manager/test/commands/mobile/delete_interaction_choice_set_test.cc
@@ -191,8 +191,10 @@ TEST_F(DeleteInteractionChoiceSetRequestTest,
[am::strings::interaction_choice_set_id]);
smart_objects::SmartObject* invalid_choice_set_id = NULL;
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillRepeatedly(Return(app_));
+
InSequence seq;
- EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app_));
EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(choice_set_id));
@@ -206,8 +208,11 @@ TEST_F(DeleteInteractionChoiceSetRequestTest,
EXPECT_CALL(*app_, RemoveChoiceSet(kChoiceSetId));
EXPECT_CALL(*app_, UpdateHash());
- command_->Run();
- EXPECT_TRUE(Mock::VerifyAndClearExpectations(app_.get()));
+ DeleteInteractionChoiceSetRequestPtr command =
+ CreateCommand<DeleteInteractionChoiceSetRequest>(message_);
+
+ command->Init();
+ command->Run();
}
TEST_F(DeleteInteractionChoiceSetRequestTest, Run_SendVrDeleteCommand_SUCCESS) {
@@ -221,8 +226,10 @@ TEST_F(DeleteInteractionChoiceSetRequestTest, Run_SendVrDeleteCommand_SUCCESS) {
smart_objects::SmartObject* choice_set_id =
&((*message_)[am::strings::msg_params]);
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillRepeatedly(Return(app_));
+
InSequence seq;
- EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app_));
EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(choice_set_id));
@@ -238,8 +245,11 @@ TEST_F(DeleteInteractionChoiceSetRequestTest, Run_SendVrDeleteCommand_SUCCESS) {
EXPECT_CALL(*app_, RemoveChoiceSet(kChoiceSetId));
EXPECT_CALL(*app_, UpdateHash());
- command_->Run();
- EXPECT_TRUE(Mock::VerifyAndClearExpectations(app_.get()));
+ DeleteInteractionChoiceSetRequestPtr command =
+ CreateCommand<DeleteInteractionChoiceSetRequest>(message_);
+
+ command->Init();
+ command->Run();
}
TEST_F(DeleteInteractionChoiceSetResponseTest, Run_SuccessFalse_UNSUCCESS) {
diff --git a/src/components/application_manager/test/commands/mobile/delete_sub_menu_test.cc b/src/components/application_manager/test/commands/mobile/delete_sub_menu_test.cc
index dd57d5f8c6..beff4c3584 100644
--- a/src/components/application_manager/test/commands/mobile/delete_sub_menu_test.cc
+++ b/src/components/application_manager/test/commands/mobile/delete_sub_menu_test.cc
@@ -241,9 +241,11 @@ TEST_F(DeleteSubMenuRequestTest, OnEvent_UnknownEventId_UNSUCCESS) {
TEST_F(DeleteSubMenuRequestTest, OnEvent_InvalidApp_UNSUCCESS) {
Event event(hmi_apis::FunctionID::UI_DeleteSubMenu);
(*message_)[am::strings::params][am::hmi_response::code] =
- am::mobile_api::Result::SUCCESS;
+ hmi_apis::Common_Result::eType::SUCCESS;
event.set_smart_object(*message_);
-
+ ON_CALL(mock_message_helper_,
+ HMIToMobileResult(hmi_apis::Common_Result::eType::SUCCESS))
+ .WillByDefault(Return(am::mobile_api::Result::SUCCESS));
MockAppPtr invalid_app;
EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(invalid_app));
EXPECT_CALL(*app_, RemoveSubMenu(_)).Times(0);
@@ -270,8 +272,9 @@ TEST_F(DeleteSubMenuRequestTest, OnEvent_DeleteSubmenu_SUCCESS) {
commands_map_.insert(
std::make_pair(0, &((*message_)[am::strings::msg_params])));
+ EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app_));
+
InSequence seq;
- EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(app_));
EXPECT_CALL(*app_, commands_map()).WillOnce(Return(accessor_));
EXPECT_CALL(*app_, app_id()).WillOnce(Return(kConnectionKey));
EXPECT_CALL(*app_, get_grammar_id()).WillOnce(Return(kGrammarId));
@@ -282,8 +285,12 @@ TEST_F(DeleteSubMenuRequestTest, OnEvent_DeleteSubmenu_SUCCESS) {
EXPECT_CALL(*app_, RemoveSubMenu(_));
EXPECT_CALL(*app_, UpdateHash());
- command_->on_event(event);
- EXPECT_TRUE(Mock::VerifyAndClearExpectations(app_.get()));
+
+ DeleteSubMenuRequestPtr command =
+ CreateCommand<DeleteSubMenuRequest>(message_);
+
+ command->Init();
+ command->on_event(event);
}
TEST_F(DeleteSubMenuResponseTest, Run_SUCCESS) {
@@ -311,7 +318,11 @@ TEST_F(DeleteSubMenuRequestTest,
commands_map_.insert(
std::make_pair(0, &((*message_)[am::strings::msg_params])));
- EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(app_));
+ ON_CALL(mock_message_helper_,
+ HMIToMobileResult(hmi_apis::Common_Result::SUCCESS))
+ .WillByDefault(Return(am::mobile_api::Result::SUCCESS));
+
+ EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app_));
EXPECT_CALL(app_mngr_, ManageHMICommand(_)).Times(0);
EXPECT_CALL(*app_, commands_map()).Times(2).WillRepeatedly(Return(accessor_));
EXPECT_CALL(*app_, RemoveCommand(_)).Times(0);
@@ -334,7 +345,10 @@ TEST_F(DeleteSubMenuRequestTest,
commands_map_.insert(
std::make_pair(0, &((*message_)[am::strings::msg_params])));
- EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(app_));
+ EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_))
+ .WillRepeatedly(Return(am::mobile_api::Result::SUCCESS));
+
+ EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app_));
EXPECT_CALL(app_mngr_, ManageHMICommand(_)).Times(0);
EXPECT_CALL(*app_, commands_map()).Times(2).WillRepeatedly(Return(accessor_));
EXPECT_CALL(*app_, RemoveCommand(_)).Times(0);
diff --git a/src/components/application_manager/test/commands/mobile/dial_number_request_test.cc b/src/components/application_manager/test/commands/mobile/dial_number_request_test.cc
index 2f7415c98e..33c84d305a 100644
--- a/src/components/application_manager/test/commands/mobile/dial_number_request_test.cc
+++ b/src/components/application_manager/test/commands/mobile/dial_number_request_test.cc
@@ -156,15 +156,6 @@ TEST_F(DialNumberRequestTest, OnEvent_UnknownEvent_UNSUCCESS) {
}
TEST_F(DialNumberRequestTest, OnEvent_SUCCESS) {
- MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
- (*command_msg)[am::strings::params][am::strings::connection_key] =
- kConnectionKey;
-
- DialNumberRequestPtr command(CreateCommand<DialNumberRequest>(command_msg));
-
- MockAppPtr app(CreateMockApp());
- EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app));
-
MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map));
(*event_msg)[am::strings::params][am::hmi_response::code] =
mobile_apis::Result::SUCCESS;
@@ -173,10 +164,19 @@ TEST_F(DialNumberRequestTest, OnEvent_SUCCESS) {
Event event(hmi_apis::FunctionID::BasicCommunication_DialNumber);
event.set_smart_object(*event_msg);
+ MockAppPtr app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillRepeatedly(Return(app));
+
EXPECT_CALL(
app_mngr_,
ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _));
+ MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*command_msg)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
+
+ DialNumberRequestPtr command(CreateCommand<DialNumberRequest>(command_msg));
command->on_event(event);
}
diff --git a/src/components/application_manager/test/commands/mobile/end_audio_pass_thru_request_test.cc b/src/components/application_manager/test/commands/mobile/end_audio_pass_thru_request_test.cc
index ceb5e3b916..b8c0ed23f3 100644
--- a/src/components/application_manager/test/commands/mobile/end_audio_pass_thru_request_test.cc
+++ b/src/components/application_manager/test/commands/mobile/end_audio_pass_thru_request_test.cc
@@ -59,7 +59,6 @@ using ::testing::ReturnRef;
using am::commands::MessageSharedPtr;
using am::commands::EndAudioPassThruRequest;
using am::event_engine::Event;
-using am::MockHmiInterfaces;
using am::MockMessageHelper;
typedef SharedPtr<EndAudioPassThruRequest> EndAudioPassThruRequestPtr;
@@ -90,12 +89,6 @@ TEST_F(EndAudioPassThruRequestTest, OnEvent_UI_UNSUPPORTED_RESOUCRE) {
Event event(hmi_apis::FunctionID::UI_EndAudioPassThru);
event.set_smart_object(*event_msg);
- MockHmiInterfaces hmi_interfaces;
- ON_CALL(app_mngr_, hmi_interfaces()).WillByDefault(ReturnRef(hmi_interfaces));
- ON_CALL(hmi_interfaces,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
-
EXPECT_CALL(mock_message_helper_,
HMIToMobileResult(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE))
.WillOnce(Return(mobile_apis::Result::UNSUPPORTED_RESOURCE));
@@ -108,6 +101,9 @@ TEST_F(EndAudioPassThruRequestTest, OnEvent_UI_UNSUPPORTED_RESOUCRE) {
ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
.WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true)));
+ MockAppPtr app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app));
+
command->on_event(event);
EXPECT_EQ((*ui_command_result)[am::strings::msg_params][am::strings::success]
diff --git a/src/components/application_manager/test/commands/mobile/get_dtcs_request_test.cc b/src/components/application_manager/test/commands/mobile/get_dtcs_request_test.cc
index 31d406d959..dfa38a758b 100644
--- a/src/components/application_manager/test/commands/mobile/get_dtcs_request_test.cc
+++ b/src/components/application_manager/test/commands/mobile/get_dtcs_request_test.cc
@@ -61,12 +61,18 @@ using am::commands::MessageSharedPtr;
using am::commands::GetDTCsRequest;
using am::event_engine::Event;
using am::MockMessageHelper;
+using testing::Mock;
namespace mobile_result = mobile_apis::Result;
typedef SharedPtr<GetDTCsRequest> GetDTCsRequestPtr;
class GetDTCsRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {};
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ GetDTCsRequestTest() : CommandRequestTest<CommandsTestMocks::kIsNice>() {
+ Mock::VerifyAndClearExpectations(message_helper_mock_);
+ }
+};
TEST_F(GetDTCsRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) {
GetDTCsRequestPtr command(CreateCommand<GetDTCsRequest>());
@@ -112,8 +118,6 @@ TEST_F(GetDTCsRequestTest, OnEvent_UnknownEvent_UNSUCCESS) {
}
TEST_F(GetDTCsRequestTest, OnEvent_SUCCESS) {
- GetDTCsRequestPtr command(CreateCommand<GetDTCsRequest>());
-
MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map));
(*event_msg)[am::strings::msg_params] = 0;
(*event_msg)[am::strings::params][am::hmi_response::code] =
@@ -130,6 +134,10 @@ TEST_F(GetDTCsRequestTest, OnEvent_SUCCESS) {
app_mngr_,
ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _));
+ MockAppPtr app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app));
+
+ GetDTCsRequestPtr command(CreateCommand<GetDTCsRequest>());
command->on_event(event);
}
diff --git a/src/components/application_manager/test/commands/mobile/get_way_points_request_test.cc b/src/components/application_manager/test/commands/mobile/get_way_points_request_test.cc
index 4b13576a39..d886a2b1bd 100644
--- a/src/components/application_manager/test/commands/mobile/get_way_points_request_test.cc
+++ b/src/components/application_manager/test/commands/mobile/get_way_points_request_test.cc
@@ -76,6 +76,7 @@ class GetWayPointsRequestTest
: message_helper_mock_(*am::MockMessageHelper::message_helper_mock()) {
Mock::VerifyAndClearExpectations(&message_helper_mock_);
}
+
~GetWayPointsRequestTest() {
Mock::VerifyAndClearExpectations(&message_helper_mock_);
}
@@ -90,6 +91,9 @@ class GetWayPointsRequestTest
message_);
mock_app_ = CreateMockApp();
ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_));
+
+ ON_CALL(message_helper_mock_, HMIToMobileResult(_))
+ .WillByDefault(Return(mobile_apis::Result::SUCCESS));
}
MockMessageHelper& message_helper_mock_;
@@ -127,6 +131,12 @@ class GetWayPointsRequestOnEventTest
event.set_smart_object(*event_msg);
+ EXPECT_CALL(message_helper_mock_, HMIToMobileResult(_))
+ .WillOnce(Return(ResultCode));
+
+ MockAppPtr app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app));
+
MessageSharedPtr result_msg(
CatchMobileCommandResult(CallOnEvent(*command, event)));
EXPECT_EQ(
@@ -195,7 +205,7 @@ TEST_F(GetWayPointsRequestTest, Run_ApplicationRegistered_Success) {
}
TEST_F(GetWayPointsRequestTest,
- OnEvent_NavigationGetWayPointsEvent_SendResponce) {
+ OnEvent_NavigationGetWayPointsEvent_SendResponse) {
am::event_engine::Event event(hmi_apis::FunctionID::Navigation_GetWayPoints);
(*message_)[am::strings::params][am::hmi_response::code] =
@@ -248,42 +258,46 @@ TEST_F(GetWayPointsRequestOnEventTest, OnEvent_Expect_SUCCESS_Case3) {
}
TEST_F(GetWayPointsRequestOnEventTest, OnEvent_Expect_GENERIC_ERROR_Case1) {
- EXPECT_CALL(app_mngr_, hmi_interfaces()).WillOnce(ReturnRef(hmi_interfaces_));
- EXPECT_CALL(hmi_interfaces_,
+ EXPECT_CALL(mock_hmi_interfaces_,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
+ .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE));
+ EXPECT_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_Navigation))
- .WillOnce(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
- EXPECT_CALL(message_helper_mock_, HMIToMobileResult(_))
- .WillOnce(Return(mobile_apis::Result::GENERIC_ERROR));
+ .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+
CheckOnEventResponse(" ", GENERIC_ERROR, false);
}
TEST_F(GetWayPointsRequestOnEventTest, OnEvent_Expect_GENERIC_ERROR_Case2) {
- EXPECT_CALL(app_mngr_, hmi_interfaces()).WillOnce(ReturnRef(hmi_interfaces_));
- EXPECT_CALL(hmi_interfaces_,
+ EXPECT_CALL(mock_hmi_interfaces_,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
+ .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE));
+ EXPECT_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_Navigation))
- .WillOnce(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
- EXPECT_CALL(message_helper_mock_, HMIToMobileResult(_))
- .WillOnce(Return(mobile_apis::Result::GENERIC_ERROR));
+ .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+
CheckOnEventResponse("test\t", GENERIC_ERROR, false);
}
TEST_F(GetWayPointsRequestOnEventTest, OnEvent_Expect_GENERIC_ERROR_Case3) {
- EXPECT_CALL(app_mngr_, hmi_interfaces()).WillOnce(ReturnRef(hmi_interfaces_));
- EXPECT_CALL(hmi_interfaces_,
+ EXPECT_CALL(mock_hmi_interfaces_,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
+ .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE));
+ EXPECT_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_Navigation))
- .WillOnce(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
- EXPECT_CALL(message_helper_mock_, HMIToMobileResult(_))
- .WillOnce(Return(mobile_apis::Result::GENERIC_ERROR));
+ .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+
CheckOnEventResponse("test\n", GENERIC_ERROR, false);
}
TEST_F(GetWayPointsRequestOnEventTest, OnEvent_Expect_GENERIC_ERROR_Case4) {
- EXPECT_CALL(app_mngr_, hmi_interfaces()).WillOnce(ReturnRef(hmi_interfaces_));
- EXPECT_CALL(hmi_interfaces_,
+ EXPECT_CALL(mock_hmi_interfaces_,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
+ .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE));
+ EXPECT_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_Navigation))
- .WillOnce(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
- EXPECT_CALL(message_helper_mock_, HMIToMobileResult(_))
- .WillOnce(Return(mobile_apis::Result::GENERIC_ERROR));
+ .WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+
CheckOnEventResponse("test\t\n", GENERIC_ERROR, false);
}
diff --git a/src/components/application_manager/test/commands/mobile/list_files_request_test.cc b/src/components/application_manager/test/commands/mobile/list_files_request_test.cc
index 85377054ef..ae0e523832 100644
--- a/src/components/application_manager/test/commands/mobile/list_files_request_test.cc
+++ b/src/components/application_manager/test/commands/mobile/list_files_request_test.cc
@@ -61,7 +61,12 @@ using am::commands::ListFilesRequest;
using am::commands::MessageSharedPtr;
class ListFilesRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {};
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ ListFilesRequestTest() : kStoragePath_("storage"), kResponseSize_(1) {}
+ const std::string kStoragePath_;
+ const uint32_t kResponseSize_;
+};
TEST_F(ListFilesRequestTest, Run_AppNotRegistered_UNSUCCESS) {
SharedPtr<ListFilesRequest> command(CreateCommand<ListFilesRequest>());
@@ -105,7 +110,17 @@ TEST_F(ListFilesRequestTest, Run_SUCCESS) {
MockAppPtr app(CreateMockApp());
SharedPtr<ListFilesRequest> command(CreateCommand<ListFilesRequest>());
+ EXPECT_CALL(app_mngr_, get_settings())
+ .WillRepeatedly(ReturnRef(app_mngr_settings_));
+
+ ON_CALL(app_mngr_settings_, app_storage_folder())
+ .WillByDefault(ReturnRef(kStoragePath_));
+
+ ON_CALL(app_mngr_settings_, list_files_response_size())
+ .WillByDefault(ReturnRef(kResponseSize_));
+
ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app));
+
ON_CALL(*app, hmi_level())
.WillByDefault(Return(mobile_apis::HMILevel::HMI_FULL));
diff --git a/src/components/application_manager/test/commands/mobile/on_hmi_status_notification_from_mobile_test.cc b/src/components/application_manager/test/commands/mobile/on_hmi_status_notification_from_mobile_test.cc
index 2cfed4a26a..34f8a010d8 100644
--- a/src/components/application_manager/test/commands/mobile/on_hmi_status_notification_from_mobile_test.cc
+++ b/src/components/application_manager/test/commands/mobile/on_hmi_status_notification_from_mobile_test.cc
@@ -52,7 +52,7 @@ const connection_handler::DeviceHandle kHandle = 2u;
namespace strings = application_manager::strings;
using application_manager::commands::OnHMIStatusNotificationFromMobile;
-using application_manager::ProtocolVersion;
+using protocol_handler::MajorProtocolVersion;
using application_manager::ApplicationSet;
using testing::Mock;
using testing::Return;
@@ -91,7 +91,8 @@ TEST_F(OnHMIStatusNotificationFromMobileTest,
EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor));
EXPECT_CALL(*mock_app, protocol_version())
- .WillRepeatedly(Return(ProtocolVersion::kV4));
+ .WillRepeatedly(
+ Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5));
EXPECT_CALL(*mock_app, is_foreground()).WillRepeatedly(Return(true));
command->Run();
@@ -144,7 +145,8 @@ TEST_F(OnHMIStatusNotificationFromMobileTest,
EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor));
EXPECT_CALL(*mock_app, protocol_version())
- .WillRepeatedly(Return(ProtocolVersion::kV4));
+ .WillRepeatedly(
+ Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5));
EXPECT_CALL(*mock_app, is_foreground()).WillRepeatedly(Return(true));
command->Run();
@@ -172,7 +174,8 @@ TEST_F(OnHMIStatusNotificationFromMobileTest,
EXPECT_CALL(app_mngr_, applications()).Times(0);
EXPECT_CALL(*mock_app, protocol_version())
- .WillOnce(Return(ProtocolVersion::kV3));
+ .WillOnce(
+ Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_3));
EXPECT_CALL(*mock_app, is_foreground()).Times(0);
command->Run();
@@ -199,7 +202,8 @@ TEST_F(OnHMIStatusNotificationFromMobileTest,
EXPECT_CALL(app_mngr_, applications()).Times(0);
EXPECT_CALL(*mock_app, protocol_version())
- .WillOnce(Return(ProtocolVersion::kV3));
+ .WillOnce(
+ Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_3));
EXPECT_CALL(*mock_app, is_foreground()).Times(0);
command->Run();
@@ -224,7 +228,8 @@ TEST_F(OnHMIStatusNotificationFromMobileTest,
EXPECT_CALL(app_mngr_, IsAppsQueriedFrom(kHandle)).WillOnce(Return(false));
EXPECT_CALL(*mock_app, protocol_version())
- .WillOnce(Return(ProtocolVersion::kV4));
+ .WillOnce(
+ Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5));
EXPECT_CALL(app_mngr_, applications()).Times(0);
@@ -261,7 +266,8 @@ TEST_F(OnHMIStatusNotificationFromMobileTest,
EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor));
EXPECT_CALL(*mock_app, protocol_version())
- .WillRepeatedly(Return(ProtocolVersion::kV4));
+ .WillRepeatedly(
+ Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5));
EXPECT_CALL(*mock_app, is_foreground()).WillRepeatedly(Return(false));
EXPECT_CALL(app_mngr_, MarkAppsGreyOut(kHandle, false));
diff --git a/src/components/application_manager/test/commands/mobile/on_hmi_status_notification_test.cc b/src/components/application_manager/test/commands/mobile/on_hmi_status_notification_test.cc
index 8f2ce3d3dc..2da0e60df1 100644
--- a/src/components/application_manager/test/commands/mobile/on_hmi_status_notification_test.cc
+++ b/src/components/application_manager/test/commands/mobile/on_hmi_status_notification_test.cc
@@ -49,7 +49,7 @@ const uint32_t kConnectionKey = 1u;
namespace strings = application_manager::strings;
using application_manager::commands::OnHMIStatusNotification;
-using application_manager::ProtocolVersion;
+using protocol_handler::MajorProtocolVersion;
using application_manager::MockMessageHelper;
using application_manager::commands::CommandImpl;
using testing::Mock;
diff --git a/src/components/application_manager/test/commands/mobile/on_touch_event_notification_test.cc b/src/components/application_manager/test/commands/mobile/on_touch_event_notification_test.cc
index 466facec1f..c90991fdf7 100644
--- a/src/components/application_manager/test/commands/mobile/on_touch_event_notification_test.cc
+++ b/src/components/application_manager/test/commands/mobile/on_touch_event_notification_test.cc
@@ -76,10 +76,16 @@ TEST_F(OnTouchEventNotificationTest, Run_AppIsNotFullscreen_UNSUCCESS) {
std::vector<ApplicationSharedPtr> applications_with_navi;
applications_with_navi.push_back(mock_app);
+ std::vector<ApplicationSharedPtr> applications_with_mobile_projection;
+ applications_with_mobile_projection.push_back(mock_app);
+
EXPECT_CALL(app_mngr_, applications_with_navi())
.WillOnce(Return(applications_with_navi));
- EXPECT_CALL(*mock_app, IsFullscreen()).WillOnce(Return(false));
+ EXPECT_CALL(app_mngr_, applications_with_mobile_projection())
+ .WillOnce(Return(applications_with_mobile_projection));
+
+ EXPECT_CALL(*mock_app, IsFullscreen()).WillRepeatedly(Return(false));
EXPECT_CALL(*mock_app, app_id()).Times(0);
@@ -118,14 +124,20 @@ TEST_F(OnTouchEventNotificationTest, Run_NotEmptyListOfAppsWithNavi_SUCCESS) {
std::vector<ApplicationSharedPtr> applications_with_navi;
applications_with_navi.push_back(mock_app);
+ std::vector<ApplicationSharedPtr> applications_with_mobile_projection;
+ applications_with_mobile_projection.push_back(mock_app);
+
EXPECT_CALL(app_mngr_, applications_with_navi())
.WillOnce(Return(applications_with_navi));
- EXPECT_CALL(*mock_app, IsFullscreen()).WillOnce(Return(true));
+ EXPECT_CALL(app_mngr_, applications_with_mobile_projection())
+ .WillOnce(Return(applications_with_mobile_projection));
+
+ EXPECT_CALL(*mock_app, IsFullscreen()).WillRepeatedly(Return(true));
- EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kAppId));
+ EXPECT_CALL(*mock_app, app_id()).WillRepeatedly(Return(kAppId));
- EXPECT_CALL(app_mngr_, SendMessageToMobile(CheckMessageData(), _));
+ EXPECT_CALL(app_mngr_, SendMessageToMobile(CheckMessageData(), _)).Times(2);
command_->Run();
}
diff --git a/src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc b/src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc
index 9126e43050..e2adc38f50 100644
--- a/src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc
+++ b/src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc
@@ -55,7 +55,6 @@ using am::commands::PerformAudioPassThruRequest;
using am::commands::CommandImpl;
using am::commands::MessageSharedPtr;
using am::MockMessageHelper;
-using am::MockHmiInterfaces;
using ::utils::SharedPtr;
using ::testing::_;
using ::testing::Mock;
@@ -131,8 +130,6 @@ class PerformAudioPassThruRequestTest
ON_CALL(app_mngr_, application(kConnectionKey))
.WillByDefault(Return(mock_app_));
ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey));
- ON_CALL(app_mngr_, hmi_interfaces())
- .WillByDefault(ReturnRef(hmi_interfaces_));
command_sptr_ =
CreateCommand<am::commands::PerformAudioPassThruRequest>(message_);
@@ -156,7 +153,6 @@ class PerformAudioPassThruRequestTest
}
sync_primitives::Lock lock_;
- NiceMock<MockHmiInterfaces> hmi_interfaces_;
MockMessageHelper& mock_message_helper_;
MockAppPtr mock_app_;
MessageSharedPtr message_;
@@ -217,10 +213,10 @@ TEST_F(PerformAudioPassThruRequestTest,
am::event_engine::Event event(hmi_apis::FunctionID::UI_PerformAudioPassThru);
event.set_smart_object(*msg);
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
@@ -312,10 +308,10 @@ TEST_F(PerformAudioPassThruRequestTest,
// Send speak request sending
ON_CALL(app_mngr_, GetNextHMICorrelationID())
.WillByDefault(Return(kCorrelationId));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_Speak))
.WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
- ON_CALL(hmi_interfaces_, GetInterfaceState(_))
+ ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
EXPECT_CALL(app_mngr_, ManageHMICommand(_))
.WillOnce(DoAll(SaveArg<0>(&speak_reqeust_result_msg), Return(true)));
@@ -324,10 +320,10 @@ TEST_F(PerformAudioPassThruRequestTest,
ON_CALL(app_mngr_, GetNextHMICorrelationID())
.WillByDefault(Return(kCorrelationId));
ON_CALL(
- hmi_interfaces_,
+ mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::UI_PerformAudioPassThru))
.WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(hmi_interfaces_, GetInterfaceState(_))
+ ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
EXPECT_CALL(app_mngr_, ManageHMICommand(_))
.WillOnce(DoAll(SaveArg<0>(&perform_result_msg), Return(true)));
@@ -359,10 +355,10 @@ TEST_F(PerformAudioPassThruRequestTest,
ON_CALL(app_mngr_, GetNextHMICorrelationID())
.WillByDefault(Return(kCorrelationId));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_StopSpeaking))
.WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
- ON_CALL(hmi_interfaces_, GetInterfaceState(_))
+ ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0);
@@ -395,10 +391,10 @@ TEST_F(PerformAudioPassThruRequestTest,
InSequence dummy;
ON_CALL(app_mngr_, GetNextHMICorrelationID())
.WillByDefault(Return(kCorrelationId));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_Speak))
.WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
- ON_CALL(hmi_interfaces_, GetInterfaceState(_))
+ ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
EXPECT_CALL(app_mngr_, ManageHMICommand(_))
.WillOnce(DoAll(SaveArg<0>(&speak_reqeust_result_msg), Return(true)));
@@ -407,10 +403,10 @@ TEST_F(PerformAudioPassThruRequestTest,
ON_CALL(app_mngr_, GetNextHMICorrelationID())
.WillByDefault(Return(kCorrelationId));
ON_CALL(
- hmi_interfaces_,
+ mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::UI_PerformAudioPassThru))
.WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(hmi_interfaces_, GetInterfaceState(_))
+ ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
EXPECT_CALL(app_mngr_, ManageHMICommand(_))
.WillOnce(DoAll(SaveArg<0>(&perform_result_msg), Return(true)));
@@ -463,10 +459,10 @@ TEST_F(PerformAudioPassThruRequestTest,
InSequence dummy;
ON_CALL(app_mngr_, GetNextHMICorrelationID())
.WillByDefault(Return(kCorrelationId));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_Speak))
.WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
- ON_CALL(hmi_interfaces_, GetInterfaceState(_))
+ ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
EXPECT_CALL(app_mngr_, ManageHMICommand(_))
.WillOnce(DoAll(SaveArg<0>(&speak_reqeust_result_msg), Return(true)));
@@ -475,10 +471,10 @@ TEST_F(PerformAudioPassThruRequestTest,
ON_CALL(app_mngr_, GetNextHMICorrelationID())
.WillByDefault(Return(kCorrelationId));
ON_CALL(
- hmi_interfaces_,
+ mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::UI_PerformAudioPassThru))
.WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(hmi_interfaces_, GetInterfaceState(_))
+ ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
EXPECT_CALL(app_mngr_, ManageHMICommand(_))
.WillOnce(DoAll(SaveArg<0>(&perform_result_msg), Return(true)));
@@ -506,10 +502,10 @@ TEST_F(
ON_CALL(app_mngr_, GetNextHMICorrelationID())
.WillByDefault(Return(kCorrelationId));
ON_CALL(
- hmi_interfaces_,
+ mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::UI_PerformAudioPassThru))
.WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
- ON_CALL(hmi_interfaces_, GetInterfaceState(_))
+ ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
// Perform audio path thru request sending
EXPECT_CALL(app_mngr_, ManageHMICommand(_))
@@ -518,10 +514,10 @@ TEST_F(
// Perform audio path thru request sending
ON_CALL(app_mngr_, GetNextHMICorrelationID())
.WillByDefault(Return(kCorrelationId));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::UI_OnRecordStart))
.WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(hmi_interfaces_, GetInterfaceState(_))
+ ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
// Start recording notification sending
EXPECT_CALL(app_mngr_, ManageHMICommand(_))
@@ -583,7 +579,7 @@ TEST_F(PerformAudioPassThruRequestTest,
EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _));
- ON_CALL(hmi_interfaces_, GetInterfaceState(_))
+ ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_))
@@ -609,7 +605,7 @@ TEST_F(PerformAudioPassThruRequestTest,
hmi_apis::Common_Result::SUCCESS;
event_perform.set_smart_object(*message_);
- ON_CALL(hmi_interfaces_, GetInterfaceState(_))
+ ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
// First call on_event for setting result_tts_speak_ to UNSUPPORTED_RESOURCE
EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _));
@@ -619,7 +615,7 @@ TEST_F(PerformAudioPassThruRequestTest,
// Second call for test correct behavior of UI_PerformAudioPassThru event
EXPECT_CALL(app_mngr_, EndAudioPassThrough()).WillOnce(Return(false));
EXPECT_CALL(app_mngr_, StopAudioPassThru(_)).Times(0);
- ON_CALL(hmi_interfaces_, GetInterfaceState(_))
+ ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
CallOnEvent caller_perform(*command_sptr_, event_perform);
@@ -648,7 +644,7 @@ TEST_F(PerformAudioPassThruRequestTest,
StartAudioPassThruThread(kConnectionKey, kCorrelationId, _, _, _, _));
EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _));
- ON_CALL(hmi_interfaces_, GetInterfaceState(_))
+ ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
ON_CALL(mock_message_helper_, HMIToMobileResult(_))
.WillByDefault(Return(am::mobile_api::Result::SUCCESS));
@@ -673,7 +669,7 @@ TEST_F(PerformAudioPassThruRequestTest,
app_mngr_,
StartAudioPassThruThread(kConnectionKey, kCorrelationId, _, _, _, _));
EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _));
- ON_CALL(hmi_interfaces_, GetInterfaceState(_))
+ ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
CallOnEvent caller(*command_sptr_, event);
caller();
@@ -732,10 +728,10 @@ TEST_F(PerformAudioPassThruRequestTest,
MessageSharedPtr perform_result_msg;
ON_CALL(app_mngr_, GetNextHMICorrelationID())
.WillByDefault(Return(kCorrelationId));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_Speak))
.WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
- ON_CALL(hmi_interfaces_, GetInterfaceState(_))
+ ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
EXPECT_CALL(app_mngr_, ManageHMICommand(_))
.WillOnce(DoAll(SaveArg<0>(&speak_reqeust_result_msg), Return(true)));
@@ -744,10 +740,10 @@ TEST_F(PerformAudioPassThruRequestTest,
ON_CALL(app_mngr_, GetNextHMICorrelationID())
.WillByDefault(Return(kCorrelationId));
ON_CALL(
- hmi_interfaces_,
+ mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::UI_PerformAudioPassThru))
.WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(hmi_interfaces_, GetInterfaceState(_))
+ ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
EXPECT_CALL(app_mngr_, ManageHMICommand(_))
.WillOnce(DoAll(SaveArg<0>(&perform_result_msg), Return(true)));
diff --git a/src/components/application_manager/test/commands/mobile/perform_interaction_test.cc b/src/components/application_manager/test/commands/mobile/perform_interaction_test.cc
index 22ce735c61..84a0e0b354 100644
--- a/src/components/application_manager/test/commands/mobile/perform_interaction_test.cc
+++ b/src/components/application_manager/test/commands/mobile/perform_interaction_test.cc
@@ -62,7 +62,6 @@ using am::ApplicationManager;
using am::commands::MessageSharedPtr;
using am::ApplicationSharedPtr;
using am::MockMessageHelper;
-using am::MockHmiInterfaces;
using ::testing::_;
using ::testing::Mock;
using ::utils::SharedPtr;
@@ -91,8 +90,6 @@ class PerformInteractionRequestTest
ON_CALL(app_mngr_, application(kConnectionKey))
.WillByDefault(Return(mock_app_));
ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey));
- ON_CALL(app_mngr_, hmi_interfaces())
- .WillByDefault(ReturnRef(hmi_interfaces_));
}
void TearDown() OVERRIDE {
@@ -111,7 +108,6 @@ class PerformInteractionRequestTest
}
sync_primitives::Lock lock_;
- NiceMock<MockHmiInterfaces> hmi_interfaces_;
MockMessageHelper& mock_message_helper_;
MockAppPtr mock_app_;
};
@@ -174,10 +170,6 @@ TEST_F(PerformInteractionRequestTest,
MockAppPtr mock_app;
EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(mock_app));
- MockHmiInterfaces hmi_interfaces;
- EXPECT_CALL(app_mngr_, hmi_interfaces())
- .WillRepeatedly(ReturnRef(hmi_interfaces));
-
MessageSharedPtr response_msg_vr =
CreateMessage(smart_objects::SmartType_Map);
(*response_msg_vr)[strings::params][hmi_response::code] =
@@ -197,10 +189,10 @@ TEST_F(PerformInteractionRequestTest,
am::event_engine::Event event_ui(hmi_apis::FunctionID::UI_PerformInteraction);
event_ui.set_smart_object(*response_msg_ui);
- EXPECT_CALL(hmi_interfaces,
+ EXPECT_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
.WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
- EXPECT_CALL(hmi_interfaces,
+ EXPECT_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR))
.WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
@@ -228,10 +220,10 @@ TEST_F(PerformInteractionRequestTest,
utils::SharedPtr<PerformInteractionRequest> command =
CreateCommand<PerformInteractionRequest>(msg_from_mobile);
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR))
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
diff --git a/src/components/application_manager/test/commands/mobile/read_did_request_test.cc b/src/components/application_manager/test/commands/mobile/read_did_request_test.cc
index 334f559ae6..7e46f6942f 100644
--- a/src/components/application_manager/test/commands/mobile/read_did_request_test.cc
+++ b/src/components/application_manager/test/commands/mobile/read_did_request_test.cc
@@ -98,6 +98,9 @@ TEST_F(ReadDIDRequestTest, OnEvent_SUCCESS) {
EXPECT_CALL(app_mngr_,
ManageMobileCommand(MobileResultCodeIs(mobile_response_code), _));
+ MockAppPtr app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app));
+
command->on_event(event);
testing::Mock::VerifyAndClearExpectations(&mock_message_helper);
diff --git a/src/components/application_manager/test/commands/mobile/register_app_interface_request_test.cc b/src/components/application_manager/test/commands/mobile/register_app_interface_request_test.cc
index 96b3cb067b..844f87d57e 100644
--- a/src/components/application_manager/test/commands/mobile/register_app_interface_request_test.cc
+++ b/src/components/application_manager/test/commands/mobile/register_app_interface_request_test.cc
@@ -151,8 +151,6 @@ class RegisterAppInterfaceRequestTest
.WillByDefault(Return(policy::DeviceConsent::kDeviceAllowed));
ON_CALL(app_mngr_, GetDeviceTransportType(_))
.WillByDefault(Return(hmi_apis::Common_TransportType::WIFI));
- ON_CALL(app_mngr_, hmi_interfaces())
- .WillByDefault(ReturnRef(mock_hmi_interfaces_));
ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
ON_CALL(
@@ -191,15 +189,11 @@ class RegisterAppInterfaceRequestTest
typedef IsNiceMock<application_manager_test::MockHMICapabilities,
kMocksAreNice>::Result MockHMICapabilities;
- typedef IsNiceMock<am::MockHmiInterfaces, kMocksAreNice>::Result
- MockHmiInterfaces;
-
MockPolicyHandlerInterface mock_policy_handler_;
MockResumeCtrl mock_resume_crt_;
MockConnectionHandler mock_connection_handler_;
MockSessionObserver mock_session_observer_;
MockHMICapabilities mock_hmi_capabilities_;
- MockHmiInterfaces mock_hmi_interfaces_;
};
TEST_F(RegisterAppInterfaceRequestTest, Init_SUCCESS) {
diff --git a/src/components/application_manager/test/commands/mobile/reset_global_properties_test.cc b/src/components/application_manager/test/commands/mobile/reset_global_properties_test.cc
index 29c52bb0d5..e133ec9119 100644
--- a/src/components/application_manager/test/commands/mobile/reset_global_properties_test.cc
+++ b/src/components/application_manager/test/commands/mobile/reset_global_properties_test.cc
@@ -280,7 +280,6 @@ TEST_F(ResetGlobalPropertiesRequestTest,
EXPECT_CALL(*mock_app_, reset_vr_help_title());
EXPECT_CALL(*mock_app_, reset_vr_help());
-
EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true));
smart_objects::SmartObjectSPtr vr_help =
@@ -297,7 +296,6 @@ TEST_F(ResetGlobalPropertiesRequestTest,
ManageMobileCommand(
MobileResultCodeIs(mobile_apis::Result::eType::SUCCESS),
am::commands::Command::ORIGIN_SDL));
- EXPECT_CALL(*mock_app_, UpdateHash());
command_->on_event(event);
}
@@ -344,7 +342,6 @@ TEST_F(ResetGlobalPropertiesRequestTest,
app_mngr_,
ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::WARNINGS),
am::commands::Command::ORIGIN_SDL));
- EXPECT_CALL(*mock_app_, UpdateHash());
command_->on_event(event);
}
@@ -368,8 +365,7 @@ TEST_F(ResetGlobalPropertiesResponseTest, Run_Sendmsg_SUCCESS) {
command->Run();
}
-TEST_F(ResetGlobalPropertiesRequestTest, OnEvent_InvalidApp_UNSUCCESS) {
- Event event(hmi_apis::FunctionID::UI_SetGlobalProperties);
+TEST_F(ResetGlobalPropertiesRequestTest, OnEvent_InvalidApp_NoHashUpdate) {
(*msg_)[am::strings::params][am::hmi_response::code] =
hmi_apis::Common_Result::eType::SUCCESS;
@@ -387,22 +383,23 @@ TEST_F(ResetGlobalPropertiesRequestTest, OnEvent_InvalidApp_UNSUCCESS) {
EXPECT_CALL(*mock_message_helper_, CreateAppVrHelp(_))
.WillOnce(Return(vr_help));
- command_->Run();
+ EXPECT_CALL(*mock_app_, UpdateHash()).Times(0);
- event.set_smart_object(*msg_);
+ ResetGlobalPropertiesRequestPtr command =
+ CreateCommand<ResetGlobalPropertiesRequest>(msg_);
+ command->Run();
+
+ EXPECT_CALL(*mock_message_helper_, HMIToMobileResult(_))
+ .WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
EXPECT_CALL(app_mngr_,
ManageMobileCommand(
MobileResultCodeIs(mobile_apis::Result::eType::SUCCESS),
am::commands::Command::ORIGIN_SDL));
- MockAppPtr invalid_app;
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(invalid_app));
-
- EXPECT_CALL(*mock_app_, UpdateHash()).Times(0);
-
- command_->on_event(event);
+ Event event(hmi_apis::FunctionID::UI_SetGlobalProperties);
+ event.set_smart_object(*msg_);
+ command->on_event(event);
}
} // namespace reset_global_properties
diff --git a/src/components/application_manager/test/commands/mobile/scrollable_message_test.cc b/src/components/application_manager/test/commands/mobile/scrollable_message_test.cc
index aba549eb34..d9fac769e5 100644
--- a/src/components/application_manager/test/commands/mobile/scrollable_message_test.cc
+++ b/src/components/application_manager/test/commands/mobile/scrollable_message_test.cc
@@ -61,7 +61,6 @@ using am::commands::ScrollableMessageRequest;
using am::commands::CommandImpl;
using am::commands::MessageSharedPtr;
using am::MockMessageHelper;
-using am::MockHmiInterfaces;
using ::utils::SharedPtr;
using ::testing::_;
using ::testing::Eq;
@@ -146,11 +145,6 @@ TEST_F(ScrollableMessageRequestTest, OnEvent_UI_UNSUPPORTED_RESOURCE) {
.WillByDefault(Return(mock_app));
ON_CALL(*mock_app, app_id()).WillByDefault(Return(kConnectionKey));
- MockHmiInterfaces hmi_interfaces;
- ON_CALL(app_mngr_, hmi_interfaces()).WillByDefault(ReturnRef(hmi_interfaces));
- EXPECT_CALL(hmi_interfaces,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE));
MockHMICapabilities hmi_capabilities;
ON_CALL(app_mngr_, hmi_capabilities())
@@ -298,11 +292,6 @@ TEST_F(ScrollableMessageRequestTest,
EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_))
.WillOnce(Return(mobile_apis::Result::UNSUPPORTED_RESOURCE));
- MockHmiInterfaces hmi_interfaces;
- ON_CALL(app_mngr_, hmi_interfaces()).WillByDefault(ReturnRef(hmi_interfaces));
- EXPECT_CALL(hmi_interfaces, GetInterfaceState(_))
- .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE));
-
EXPECT_CALL(
app_mngr_,
ManageMobileCommand(
diff --git a/src/components/application_manager/test/commands/mobile/send_haptic_data_test.cc b/src/components/application_manager/test/commands/mobile/send_haptic_data_test.cc
new file mode 100644
index 0000000000..49483209b6
--- /dev/null
+++ b/src/components/application_manager/test/commands/mobile/send_haptic_data_test.cc
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2017 Xevo Inc.
+ * 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 Xevo Inc. 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 "commands/commands_test.h"
+#include "commands/command_request_test.h"
+
+#include "mobile/send_haptic_data_request.h"
+#include "mobile/send_haptic_data_response.h"
+
+#include "interfaces/MOBILE_API.h"
+#include "application_manager/application.h"
+#include "application_manager/mock_application.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+namespace send_haptic_data {
+
+using ::testing::_;
+using ::testing::Return;
+
+namespace am = ::application_manager;
+
+using am::commands::SendHapticDataRequest;
+using am::commands::SendHapticDataResponse;
+using am::commands::MessageSharedPtr;
+
+typedef SharedPtr<SendHapticDataRequest> SendHapticDataRequestPtr;
+typedef SharedPtr<SendHapticDataResponse> SendHapticDataResponsePtr;
+
+namespace {
+const uint32_t kConnectionKey = 1u;
+}
+
+class SendHapticDataRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ SendHapticDataRequestTest()
+ : msg_(CreateMessage(::smart_objects::SmartType_Map))
+ , mock_app_(CreateMockApp()) {}
+
+ void SetUp() OVERRIDE {
+ (*msg_)[am::strings::params][am::strings::connection_key] = kConnectionKey;
+ ON_CALL(app_mngr_, application(kConnectionKey))
+ .WillByDefault(Return(mock_app_));
+ }
+
+ MessageSharedPtr msg_;
+ MockAppPtr mock_app_;
+};
+
+class SendHapticDataResponseTest
+ : public CommandsTest<CommandsTestMocks::kIsNice> {
+ public:
+ SendHapticDataResponseTest() : message_(CreateMessage()) {}
+
+ void SetUp() OVERRIDE {
+ command_sptr_ = CreateCommand<SendHapticDataResponse>(message_);
+ }
+
+ MessageSharedPtr message_;
+ SharedPtr<SendHapticDataResponse> command_sptr_;
+};
+
+TEST_F(SendHapticDataRequestTest, Run_SUCCESS) {
+ EXPECT_CALL(app_mngr_,
+ ManageHMICommand(
+ HMIResultCodeIs(hmi_apis::FunctionID::UI_SendHapticData)))
+ .WillOnce(Return(true));
+
+ SendHapticDataRequestPtr command(CreateCommand<SendHapticDataRequest>(msg_));
+
+ command->Init();
+ command->Run();
+}
+
+TEST_F(SendHapticDataRequestTest, OnEvent_SUCCESS) {
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS),
+ am::commands::Command::ORIGIN_SDL));
+
+ (*msg_)[am::strings::msg_params] = 0;
+ (*msg_)[am::strings::params][am::hmi_response::code] =
+ hmi_apis::Common_Result::eType::SUCCESS;
+ Event event(hmi_apis::FunctionID::UI_SendHapticData);
+ event.set_smart_object(*msg_);
+ SendHapticDataRequestPtr command(CreateCommand<SendHapticDataRequest>(msg_));
+
+ command->Init();
+ command->on_event(event);
+}
+
+TEST_F(SendHapticDataResponseTest, Run_Success) {
+ ::smart_objects::SmartObject& message_ref = *message_;
+ message_ref[am::strings::msg_params][am::strings::result_code] =
+ mobile_apis::Result::SUCCESS;
+
+ EXPECT_CALL(
+ app_mngr_,
+ SendMessageToMobile(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _));
+ command_sptr_->Init();
+ command_sptr_->Run();
+}
+
+} // namespace send_haptic_data
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/send_location_request_test.cc b/src/components/application_manager/test/commands/mobile/send_location_request_test.cc
index df412695fd..03cc715188 100644
--- a/src/components/application_manager/test/commands/mobile/send_location_request_test.cc
+++ b/src/components/application_manager/test/commands/mobile/send_location_request_test.cc
@@ -351,11 +351,19 @@ TEST_F(SendLocationRequestTest, Run_HMIUINotCoop_Cancelled) {
TEST_F(SendLocationRequestTest, OnEvent_Success) {
mobile_apis::Result::eType response_code = mobile_apis::Result::SUCCESS;
(*message_)[strings::params][hmi_response::code] = response_code;
+ (*message_)[strings::params][strings::connection_key] = kConnectionKey;
+
Event event(hmi_apis::FunctionID::Navigation_SendLocation);
event.set_smart_object(*message_);
+
EXPECT_CALL(mock_message_helper_,
HMIToMobileResult(hmi_apis::Common_Result::SUCCESS))
.WillOnce(Return(mobile_apis::Result::SUCCESS));
+
+ MockAppPtr app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillRepeatedly(Return(app));
+
command_->on_event(event);
}
diff --git a/src/components/application_manager/test/commands/mobile/set_app_icon_test.cc b/src/components/application_manager/test/commands/mobile/set_app_icon_test.cc
index b51b7c83ea..60b01f2cfa 100644
--- a/src/components/application_manager/test/commands/mobile/set_app_icon_test.cc
+++ b/src/components/application_manager/test/commands/mobile/set_app_icon_test.cc
@@ -55,7 +55,6 @@ using am::commands::SetAppIconRequest;
using am::commands::CommandImpl;
using am::commands::MessageSharedPtr;
using am::MockMessageHelper;
-using am::MockHmiInterfaces;
using ::utils::SharedPtr;
using ::testing::_;
using ::testing::Mock;
@@ -73,6 +72,15 @@ class SetAppIconRequestTest
public:
SetAppIconRequestTest()
: mock_message_helper_(*MockMessageHelper::message_helper_mock()) {}
+
+ void SetUp() OVERRIDE {
+ Mock::VerifyAndClearExpectations(&mock_message_helper_);
+ }
+
+ void TearDown() OVERRIDE {
+ Mock::VerifyAndClearExpectations(&mock_message_helper_);
+ }
+
MockMessageHelper& mock_message_helper_;
MessageSharedPtr CreateFullParamsUISO() {
@@ -118,12 +126,6 @@ TEST_F(SetAppIconRequestTest, OnEvent_UI_UNSUPPORTED_RESOURCE) {
ON_CALL(*mock_app, set_app_icon_path(_)).WillByDefault(Return(true));
ON_CALL(*mock_app, app_icon_path()).WillByDefault(ReturnRef(file_path));
- MockHmiInterfaces hmi_interfaces;
- ON_CALL(app_mngr_, hmi_interfaces()).WillByDefault(ReturnRef(hmi_interfaces));
- EXPECT_CALL(hmi_interfaces,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE));
-
MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
(*msg)[am::strings::params][am::hmi_response::code] =
hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
@@ -158,7 +160,6 @@ TEST_F(SetAppIconRequestTest, OnEvent_UI_UNSUPPORTED_RESOURCE) {
.asString()
.empty());
}
- Mock::VerifyAndClearExpectations(&mock_message_helper_);
}
} // namespace set_app_icon_request
diff --git a/src/components/application_manager/test/commands/mobile/set_display_layout_test.cc b/src/components/application_manager/test/commands/mobile/set_display_layout_test.cc
index 0518b325ea..68aa76010f 100644
--- a/src/components/application_manager/test/commands/mobile/set_display_layout_test.cc
+++ b/src/components/application_manager/test/commands/mobile/set_display_layout_test.cc
@@ -57,7 +57,6 @@ using am::commands::SetDisplayLayoutRequest;
using am::commands::CommandImpl;
using am::commands::MessageSharedPtr;
using am::MockMessageHelper;
-using am::MockHmiInterfaces;
using ::utils::SharedPtr;
using ::testing::_;
using ::testing::Mock;
@@ -89,8 +88,6 @@ class SetDisplayLayoutRequestTest
ON_CALL(app_mngr_, application(kConnectionKey))
.WillByDefault(Return(mock_app_));
ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey));
- ON_CALL(app_mngr_, hmi_interfaces())
- .WillByDefault(ReturnRef(hmi_interfaces_));
}
~SetDisplayLayoutRequestTest() {
@@ -133,7 +130,6 @@ class SetDisplayLayoutRequestTest
}
sync_primitives::Lock lock_;
- NiceMock<MockHmiInterfaces> hmi_interfaces_;
MockMessageHelper& mock_message_helper_;
MockAppPtr mock_app_;
};
@@ -164,7 +160,7 @@ TEST_F(SetDisplayLayoutRequestTest,
Event event(hmi_apis::FunctionID::UI_SetDisplayLayout);
event.set_smart_object(*msg);
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
@@ -186,6 +182,7 @@ TEST_F(SetDisplayLayoutRequestTest, Run_InvalidApp_UNSUCCESS) {
MessageSharedPtr msg(CreateMessage(smart_objects::SmartType_Map));
(*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
CommandPtr command(CreateCommand<SetDisplayLayoutRequest>(msg));
+
MockAppPtr invalid_mock_app;
EXPECT_CALL(app_mngr_, application(kConnectionKey))
.WillOnce(Return(invalid_mock_app));
@@ -209,8 +206,6 @@ TEST_F(SetDisplayLayoutRequestTest, Run_SUCCESS) {
EXPECT_CALL(app_mngr_, GetNextHMICorrelationID())
.WillOnce(Return(kCorrelationKey));
- EXPECT_CALL(app_mngr_, hmi_interfaces())
- .WillOnce(ReturnRef(mock_hmi_interfaces_));
EXPECT_CALL(
mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetDisplayLayout))
@@ -236,14 +231,13 @@ TEST_F(SetDisplayLayoutRequestTest, OnEvent_InvalidEventId_UNSUCCESS) {
}
TEST_F(SetDisplayLayoutRequestTest, OnEvent_SUCCESS) {
- CommandPtr command(CreateCommand<SetDisplayLayoutRequest>());
-
am::event_engine::Event event(hmi_apis::FunctionID::UI_SetDisplayLayout);
MessageSharedPtr msg = CreateMessage();
(*msg)[am::strings::params][am::hmi_response::code] =
hmi_apis::Common_Result::SUCCESS;
(*msg)[am::strings::msg_params][am::hmi_response::display_capabilities] = 0;
+ (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey;
event.set_smart_object(*msg);
MockHMICapabilities hmi_capabilities;
@@ -251,17 +245,23 @@ TEST_F(SetDisplayLayoutRequestTest, OnEvent_SUCCESS) {
(*dispaly_capabilities_msg)[am::hmi_response::templates_available] =
"templates_available";
+ EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_))
+ .WillOnce(Return(mobile_apis::Result::SUCCESS));
+
EXPECT_CALL(app_mngr_, hmi_capabilities())
.WillOnce(ReturnRef(hmi_capabilities));
EXPECT_CALL(hmi_capabilities, display_capabilities())
.WillOnce(Return(dispaly_capabilities_msg.get()));
-
+ ON_CALL(mock_message_helper_,
+ HMIToMobileResult(hmi_apis::Common_Result::eType::SUCCESS))
+ .WillByDefault(Return(am::mobile_api::Result::SUCCESS));
EXPECT_CALL(
app_mngr_,
ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS),
am::commands::Command::CommandOrigin::ORIGIN_SDL));
+ CommandPtr command(CreateCommand<SetDisplayLayoutRequest>(msg));
command->on_event(event);
}
diff --git a/src/components/application_manager/test/commands/mobile/set_global_properties_test.cc b/src/components/application_manager/test/commands/mobile/set_global_properties_test.cc
index 0908b54ba7..7143bdf71a 100644
--- a/src/components/application_manager/test/commands/mobile/set_global_properties_test.cc
+++ b/src/components/application_manager/test/commands/mobile/set_global_properties_test.cc
@@ -55,7 +55,6 @@ using am::commands::SetGlobalPropertiesRequest;
using am::commands::CommandImpl;
using am::commands::MessageSharedPtr;
using am::MockMessageHelper;
-using am::MockHmiInterfaces;
using am::CommandsMap;
using utils::custom_string::CustomString;
using ::utils::SharedPtr;
@@ -119,8 +118,6 @@ class SetGlobalPropertiesRequestTest
vr_help_array[0][am::strings::text] = kText;
vr_help_array[0][am::strings::position] = kPosition;
(*msg)[am::strings::msg_params][am::strings::vr_help] = vr_help_array;
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
}
void OnEventUISetupHelper(MessageSharedPtr msg,
@@ -155,8 +152,6 @@ class SetGlobalPropertiesRequestTest
(*msg)[am::strings::msg_params][am::strings::timeout_prompt] =
timeout_prompt;
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0);
EXPECT_CALL(app_mngr_,
RemoveAppFromTTSGlobalPropertiesList(kConnectionKey));
@@ -216,8 +211,9 @@ class SetGlobalPropertiesRequestTest
ON_CALL(app_mngr_, application(kConnectionKey))
.WillByDefault(Return(mock_app_));
ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey));
- ON_CALL(app_mngr_, hmi_interfaces())
- .WillByDefault(ReturnRef(hmi_interfaces_));
+ ON_CALL(mock_hmi_interfaces_,
+ GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
+ .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
}
void TearDown() OVERRIDE {
@@ -237,22 +233,21 @@ class SetGlobalPropertiesRequestTest
void ExpectationsHmiInterface_Run() {
EXPECT_CALL(
- hmi_interfaces_,
+ mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties))
.WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
EXPECT_CALL(
- hmi_interfaces_,
+ mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_SetGlobalProperties))
.WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
}
sync_primitives::Lock lock_;
- NiceMock<MockHmiInterfaces> hmi_interfaces_;
MockMessageHelper& mock_message_helper_;
MockAppPtr mock_app_;
};
@@ -297,8 +292,6 @@ TEST_F(SetGlobalPropertiesRequestTest,
ON_CALL(mock_message_helper_, VerifyImage(_, _, _))
.WillByDefault(Return(mobile_apis::Result::SUCCESS));
- EXPECT_CALL(*mock_app_, UpdateHash());
-
(*msg_vr)[am::strings::params][am::hmi_response::code] =
hmi_apis::Common_Result::SUCCESS;
Event event_vr(hmi_apis::FunctionID::TTS_SetGlobalProperties);
@@ -330,9 +323,6 @@ TEST_F(SetGlobalPropertiesRequestTest, OnEvent_SUCCESS_Expect_MessageNotSend) {
utils::SharedPtr<SetGlobalPropertiesRequest> command =
CreateCommand<SetGlobalPropertiesRequest>(response);
- MockAppPtr mock_app(CreateMockApp());
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app));
-
EXPECT_CALL(
app_mngr_,
ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
@@ -345,6 +335,8 @@ TEST_F(SetGlobalPropertiesRequestTest,
MessageSharedPtr response = CreateMessage(smart_objects::SmartType_Map);
(*response)[am::strings::params][am::hmi_response::code] =
hmi_apis::Common_Result::SUCCESS;
+ (*response)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
(*response)[am::strings::msg_params][am::strings::info] = "qwe";
am::event_engine::Event event_tts(
@@ -356,16 +348,10 @@ TEST_F(SetGlobalPropertiesRequestTest,
utils::SharedPtr<SetGlobalPropertiesRequest> command =
CreateCommand<SetGlobalPropertiesRequest>(response);
- MockAppPtr mock_app(CreateMockApp());
- ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app));
-
ON_CALL(mock_message_helper_, HMIToMobileResult(_))
.WillByDefault(Return(mobile_apis::Result::UNSUPPORTED_RESOURCE));
- MockHmiInterfaces hmi_interfaces;
- EXPECT_CALL(app_mngr_, hmi_interfaces())
- .WillRepeatedly(ReturnRef(hmi_interfaces));
- EXPECT_CALL(hmi_interfaces, GetInterfaceState(_))
+ EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
MessageSharedPtr response_to_mobile;
@@ -393,11 +379,11 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_VRNoMenuAndKeyboard_SUCCESS) {
SharedPtr<SetGlobalPropertiesRequest> command(
CreateCommand<SetGlobalPropertiesRequest>(msg));
EXPECT_CALL(
- hmi_interfaces_,
+ mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties))
.WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
@@ -434,11 +420,11 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_VRWithMenuAndKeyboard_SUCCESS) {
EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId));
EXPECT_CALL(
- hmi_interfaces_,
+ mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties))
.WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
@@ -595,10 +581,10 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_NoVR_SUCCESS) {
EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId));
EXPECT_CALL(
- hmi_interfaces_,
+ mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties))
.WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
@@ -667,10 +653,10 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_NoVRNoDataNoDefault_Canceled) {
EXPECT_CALL(*mock_app_, app_id());
EXPECT_CALL(
- hmi_interfaces_,
+ mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties))
.WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
@@ -712,10 +698,10 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_NoVRNoDataDefaultCreated_SUCCESS) {
EXPECT_CALL(*mock_app_, set_keyboard_props(keyboard_properties));
EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId));
EXPECT_CALL(
- hmi_interfaces_,
+ mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties))
.WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
@@ -757,10 +743,10 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_NoVRNoDataFromSynonyms_SUCCESS) {
EXPECT_CALL(*mock_app_, set_keyboard_props(keyboard_properties));
EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId));
EXPECT_CALL(
- hmi_interfaces_,
+ mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties))
.WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
SharedPtr<SetGlobalPropertiesRequest> command(
@@ -791,10 +777,10 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_TTSHelpAndTimeout_SUCCESS) {
EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId));
EXPECT_CALL(
- hmi_interfaces_,
+ mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_SetGlobalProperties))
.WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
@@ -822,10 +808,10 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_TTSOnlyHelp_SUCCESS) {
EXPECT_CALL(*mock_app_, timeout_prompt()).Times(0);
EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId));
EXPECT_CALL(
- hmi_interfaces_,
+ mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_SetGlobalProperties))
.WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
SharedPtr<SetGlobalPropertiesRequest> command(
@@ -852,10 +838,10 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_TTSOnlyTimeout_SUCCESS) {
EXPECT_CALL(*mock_app_, timeout_prompt()).WillOnce(Return(&timeout_prompt));
EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId));
EXPECT_CALL(
- hmi_interfaces_,
+ mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_SetGlobalProperties))
.WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
SharedPtr<SetGlobalPropertiesRequest> command(
@@ -1060,16 +1046,16 @@ TEST_F(SetGlobalPropertiesRequestTest, OnEvent_UIAndSuccessResultCode_SUCCESS) {
hmi_apis::Common_Result::SUCCESS;
(*msg)[am::strings::params][am::hmi_response::code] = response_code;
- SharedPtr<SetGlobalPropertiesRequest> command(
- CreateCommand<SetGlobalPropertiesRequest>(msg));
ON_CALL(
- hmi_interfaces_,
+ mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties))
.WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
+ SharedPtr<SetGlobalPropertiesRequest> command(
+ CreateCommand<SetGlobalPropertiesRequest>(msg));
OnEventUISetupHelper(msg, command);
Event event(hmi_apis::FunctionID::UI_SetGlobalProperties);
@@ -1077,11 +1063,8 @@ TEST_F(SetGlobalPropertiesRequestTest, OnEvent_UIAndSuccessResultCode_SUCCESS) {
EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_))
.WillOnce(Return(mobile_apis::Result::SUCCESS));
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(*mock_app_, UpdateHash());
- EXPECT_CALL(hmi_interfaces_, GetInterfaceState(_))
+ EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
EXPECT_CALL(app_mngr_,
@@ -1100,23 +1083,20 @@ TEST_F(SetGlobalPropertiesRequestTest, OnEvent_UIAndWarningResultCode_SUCCESS) {
SharedPtr<SetGlobalPropertiesRequest> command(
CreateCommand<SetGlobalPropertiesRequest>(msg));
ON_CALL(
- hmi_interfaces_,
+ mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties))
.WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
OnEventUISetupHelper(msg, command);
EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_)).Times(0);
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(*mock_app_, UpdateHash());
Event event(hmi_apis::FunctionID::UI_SetGlobalProperties);
event.set_smart_object(*msg);
- EXPECT_CALL(hmi_interfaces_, GetInterfaceState(_))
+ EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_))
.WillOnce(Return(mobile_apis::Result::SUCCESS));
@@ -1133,23 +1113,25 @@ TEST_F(SetGlobalPropertiesRequestTest, OnEvent_InvalidApp_Canceled) {
hmi_apis::Common_Result::WARNINGS;
(*msg)[am::strings::params][am::hmi_response::code] = response_code;
ON_CALL(
- hmi_interfaces_,
+ mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties))
.WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
SharedPtr<SetGlobalPropertiesRequest> command(
CreateCommand<SetGlobalPropertiesRequest>(msg));
OnEventUISetupHelper(msg, command);
- EXPECT_CALL(hmi_interfaces_, GetInterfaceState(_))
+ EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_))
.WillOnce(Return(mobile_apis::Result::SUCCESS));
+
EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(MockAppPtr()));
+ .WillRepeatedly(Return(MockAppPtr()));
+
EXPECT_CALL(*mock_app_, UpdateHash()).Times(0);
Event event(hmi_apis::FunctionID::UI_SetGlobalProperties);
@@ -1181,17 +1163,17 @@ TEST_F(SetGlobalPropertiesRequestTest,
hmi_apis::Common_Result::SUCCESS;
(*msg)[am::strings::params][am::hmi_response::code] = response_code;
ON_CALL(
- hmi_interfaces_,
+ mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_SetGlobalProperties))
.WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
SharedPtr<SetGlobalPropertiesRequest> command(
CreateCommand<SetGlobalPropertiesRequest>(msg));
OnEventTTSSetupHelper(msg, command);
- EXPECT_CALL(hmi_interfaces_, GetInterfaceState(_))
+ EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
EXPECT_CALL(app_mngr_,
@@ -1200,9 +1182,6 @@ TEST_F(SetGlobalPropertiesRequestTest,
EXPECT_CALL(mock_message_helper_, HMIToMobileResult(response_code))
.WillOnce(Return(mobile_apis::Result::SUCCESS));
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(*mock_app_, UpdateHash());
Event event(hmi_apis::FunctionID::TTS_SetGlobalProperties);
event.set_smart_object(*msg);
@@ -1217,10 +1196,10 @@ TEST_F(SetGlobalPropertiesRequestTest,
hmi_apis::Common_Result::WARNINGS;
(*msg)[am::strings::params][am::hmi_response::code] = response_code;
ON_CALL(
- hmi_interfaces_,
+ mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::TTS_SetGlobalProperties))
.WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS))
.WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
SharedPtr<SetGlobalPropertiesRequest> command(
@@ -1228,7 +1207,7 @@ TEST_F(SetGlobalPropertiesRequestTest,
OnEventTTSSetupHelper(msg, command);
- EXPECT_CALL(hmi_interfaces_, GetInterfaceState(_))
+ EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
EXPECT_CALL(app_mngr_,
@@ -1237,9 +1216,6 @@ TEST_F(SetGlobalPropertiesRequestTest,
EXPECT_CALL(mock_message_helper_, HMIToMobileResult(_))
.WillOnce(Return(mobile_apis::Result::SUCCESS));
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app_));
- EXPECT_CALL(*mock_app_, UpdateHash());
Event event(hmi_apis::FunctionID::TTS_SetGlobalProperties);
event.set_smart_object(*msg);
diff --git a/src/components/application_manager/test/commands/mobile/set_media_clock_timer_test.cc b/src/components/application_manager/test/commands/mobile/set_media_clock_timer_test.cc
index da6f29cf5e..3056d0e9fc 100644
--- a/src/components/application_manager/test/commands/mobile/set_media_clock_timer_test.cc
+++ b/src/components/application_manager/test/commands/mobile/set_media_clock_timer_test.cc
@@ -53,7 +53,6 @@ namespace am = ::application_manager;
using am::commands::SetMediaClockRequest;
using am::commands::MessageSharedPtr;
using am::event_engine::Event;
-using am::MockHmiInterfaces;
using am::MockMessageHelper;
using ::testing::_;
using ::testing::Mock;
@@ -84,8 +83,6 @@ class SetMediaClockRequestTest
ON_CALL(app_mngr_, application(kConnectionKey))
.WillByDefault(Return(mock_app_));
ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey));
- ON_CALL(app_mngr_, hmi_interfaces())
- .WillByDefault(ReturnRef(hmi_interfaces_));
}
void TearDown() OVERRIDE {
@@ -117,7 +114,6 @@ class SetMediaClockRequestTest
EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _));
}
- NiceMock<MockHmiInterfaces> hmi_interfaces_;
MockMessageHelper& mock_message_helper_;
MockAppPtr mock_app_;
};
@@ -140,7 +136,7 @@ TEST_F(SetMediaClockRequestTest,
Event event(hmi_apis::FunctionID::UI_SetMediaClockTimer);
event.set_smart_object(*ev_msg);
- EXPECT_CALL(hmi_interfaces_,
+ EXPECT_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
.WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_RESPONSE));
@@ -183,10 +179,10 @@ TEST_F(SetMediaClockRequestTest, Run_UpdateCountUp_SUCCESS) {
EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppID));
EXPECT_CALL(app_mngr_, GetNextHMICorrelationID())
.WillOnce(Return(kCorrelationId));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetMediaClockTimer))
.WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
.WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
EXPECT_CALL(app_mngr_, ManageHMICommand(_)).WillOnce(Return(true));
@@ -218,10 +214,10 @@ TEST_F(SetMediaClockRequestTest, Run_UpdateCountDown_SUCCESS) {
EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppID));
EXPECT_CALL(app_mngr_, GetNextHMICorrelationID())
.WillOnce(Return(kCorrelationId));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetMediaClockTimer))
.WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
- ON_CALL(hmi_interfaces_,
+ ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
.WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
EXPECT_CALL(app_mngr_, ManageHMICommand(_)).WillOnce(Return(true));
@@ -340,6 +336,9 @@ TEST_F(SetMediaClockRequestTest, OnEvent_Success) {
EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _));
+ MockAppPtr app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app));
+
Event event(hmi_apis::FunctionID::UI_SetMediaClockTimer);
event.set_smart_object(*msg);
diff --git a/src/components/application_manager/test/commands/mobile/show_test.cc b/src/components/application_manager/test/commands/mobile/show_test.cc
index 2d2e19cbf2..86889ac5cd 100644
--- a/src/components/application_manager/test/commands/mobile/show_test.cc
+++ b/src/components/application_manager/test/commands/mobile/show_test.cc
@@ -56,7 +56,6 @@ using am::commands::ShowRequest;
using am::commands::CommandImpl;
using am::commands::MessageSharedPtr;
using am::MockMessageHelper;
-using am::MockHmiInterfaces;
using test::components::policy_test::MockPolicyHandlerInterface;
using ::utils::SharedPtr;
using ::testing::_;
@@ -177,13 +176,6 @@ TEST_F(ShowRequestTest, OnEvent_UI_UNSUPPORTED_RESOURCE) {
ON_CALL(app_mngr_, application(kConnectionKey))
.WillByDefault(Return(mock_app));
ON_CALL(*mock_app, app_id()).WillByDefault(Return(kConnectionKey));
- MockHmiInterfaces hmi_interfaces;
- ON_CALL(app_mngr_, hmi_interfaces()).WillByDefault(ReturnRef(hmi_interfaces));
- ON_CALL(hmi_interfaces, GetInterfaceFromFunction(_))
- .WillByDefault(
- Return(am::HmiInterfaces::HMI_INTERFACE_BasicCommunication));
- ON_CALL(hmi_interfaces, GetInterfaceState(_))
- .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
(*msg)[am::strings::params][am::hmi_response::code] =
@@ -760,16 +752,23 @@ TEST_F(ShowRequestTest, Run_EmptyParams_Canceled) {
TEST_F(ShowRequestTest, OnEvent_SuccessResultCode_SUCCESS) {
MessageSharedPtr msg = CreateMessage();
(*msg)[am::strings::params][am::hmi_response::code] =
- mobile_apis::Result::SUCCESS;
+ hmi_apis::Common_Result::eType::SUCCESS;
(*msg)[am::strings::msg_params] = SmartObject(smart_objects::SmartType_Map);
SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _));
+ ON_CALL(mock_message_helper_,
+ HMIToMobileResult(hmi_apis::Common_Result::eType::SUCCESS))
+ .WillByDefault(Return(am::mobile_api::Result::SUCCESS));
+ EXPECT_CALL(app_mngr_,
+ ManageMobileCommand(
+ MobileResultCodeIs(mobile_apis::Result::eType::SUCCESS), _));
Event event(hmi_apis::FunctionID::UI_Show);
event.set_smart_object(*msg);
+ EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(mock_app_));
+
command->on_event(event);
}
@@ -782,11 +781,16 @@ TEST_F(ShowRequestTest, OnEvent_WarningsResultCode_SUCCESS) {
SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
+ EXPECT_CALL(mock_message_helper_,
+ HMIToMobileResult(hmi_apis::Common_Result::WARNINGS))
+ .WillOnce(Return(mobile_apis::Result::WARNINGS));
EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _));
Event event(hmi_apis::FunctionID::UI_Show);
event.set_smart_object(*msg);
+ EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(mock_app_));
+
command->on_event(event);
}
diff --git a/src/components/application_manager/test/commands/mobile/slider_test.cc b/src/components/application_manager/test/commands/mobile/slider_test.cc
index 7f260f7ddb..20262ed35a 100644
--- a/src/components/application_manager/test/commands/mobile/slider_test.cc
+++ b/src/components/application_manager/test/commands/mobile/slider_test.cc
@@ -56,7 +56,6 @@ using am::commands::SliderRequest;
using am::commands::CommandImpl;
using am::commands::MessageSharedPtr;
using am::MockMessageHelper;
-using am::MockHmiInterfaces;
using policy_test::MockPolicyHandlerInterface;
using ::utils::SharedPtr;
using ::testing::_;
@@ -159,11 +158,6 @@ TEST_F(SliderRequestTest, OnEvent_UI_UNSUPPORTED_RESOURCE) {
.WillByDefault(Return(mock_app));
ON_CALL(*mock_app, app_id()).WillByDefault(Return(kConnectionKey));
- MockHmiInterfaces hmi_interfaces;
- ON_CALL(app_mngr_, hmi_interfaces()).WillByDefault(ReturnRef(hmi_interfaces));
- EXPECT_CALL(hmi_interfaces,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
- .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE));
MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
(*msg)[am::strings::params][am::hmi_response::code] =
diff --git a/src/components/application_manager/test/commands/mobile/speak_request_test.cc b/src/components/application_manager/test/commands/mobile/speak_request_test.cc
index 58eec42902..f8a7d22b40 100644
--- a/src/components/application_manager/test/commands/mobile/speak_request_test.cc
+++ b/src/components/application_manager/test/commands/mobile/speak_request_test.cc
@@ -67,7 +67,6 @@ using am::ApplicationManager;
using am::commands::MessageSharedPtr;
using am::ApplicationSharedPtr;
using am::MockMessageHelper;
-using am::MockHmiInterfaces;
using ::testing::_;
using ::utils::SharedPtr;
using ::testing::Return;
@@ -113,10 +112,8 @@ class SpeakRequestTest : public CommandRequestTest<CommandsTestMocks::kIsNice> {
ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app));
MessageSharedPtr response_to_mobile;
- MockHmiInterfaces hmi_interfaces;
- EXPECT_CALL(app_mngr_, hmi_interfaces())
- .WillOnce(ReturnRef(hmi_interfaces));
- EXPECT_CALL(hmi_interfaces, GetInterfaceState(_)).WillOnce(Return(state));
+ EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
+ .WillRepeatedly(Return(state));
MockMessageHelper* mock_message_helper =
MockMessageHelper::message_helper_mock();
EXPECT_CALL(*mock_message_helper, HMIToMobileResult(_))
diff --git a/src/components/application_manager/test/commands/mobile/subscribe_way_points_request_test.cc b/src/components/application_manager/test/commands/mobile/subscribe_way_points_request_test.cc
index 66cd740bbe..4546293172 100644
--- a/src/components/application_manager/test/commands/mobile/subscribe_way_points_request_test.cc
+++ b/src/components/application_manager/test/commands/mobile/subscribe_way_points_request_test.cc
@@ -83,6 +83,7 @@ TEST_F(SubscribeWayPointsRequestTest, Run_SUCCESS) {
EXPECT_CALL(*app, UpdateHash());
}
+ command->Init();
MessageSharedPtr mobile_result_msg(
CatchMobileCommandResult(CallRun(*command)));
@@ -120,6 +121,7 @@ TEST_F(SubscribeWayPointsRequestTest, OnEvent_SUCCESS) {
EXPECT_CALL(*app, UpdateHash());
}
+ command->Init();
command->on_event(event);
Mock::VerifyAndClearExpectations(mock_message_helper);
diff --git a/src/components/application_manager/test/commands/mobile/unregister_app_interface_request_test.cc b/src/components/application_manager/test/commands/mobile/unregister_app_interface_request_test.cc
index 7cc5e59470..ae4e46d40b 100644
--- a/src/components/application_manager/test/commands/mobile/unregister_app_interface_request_test.cc
+++ b/src/components/application_manager/test/commands/mobile/unregister_app_interface_request_test.cc
@@ -84,7 +84,7 @@ TEST_F(UnregisterAppInterfaceRequestTest, Run_SUCCESS) {
MockAppPtr mock_app(CreateMockApp());
EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
+ .WillRepeatedly(Return(mock_app));
const mobile_apis::AppInterfaceUnregisteredReason::eType kUnregisterReason =
mobile_apis::AppInterfaceUnregisteredReason::INVALID_ENUM;
diff --git a/src/components/application_manager/test/commands/mobile/unsubscribe_button_request_test.cc b/src/components/application_manager/test/commands/mobile/unsubscribe_button_request_test.cc
index a71f8a43c8..46a1ce02eb 100644
--- a/src/components/application_manager/test/commands/mobile/unsubscribe_button_request_test.cc
+++ b/src/components/application_manager/test/commands/mobile/unsubscribe_button_request_test.cc
@@ -6,6 +6,7 @@
#include "application_manager/commands/command_request_test.h"
#include "application_manager/mock_application_manager.h"
#include "application_manager/mock_message_helper.h"
+#include "application_manager/mock_hmi_capabilities.h"
#include "application_manager/commands/mobile/unsubscribe_button_request.h"
namespace test {
@@ -30,7 +31,13 @@ const mobile_apis::ButtonName::eType kButtonId = mobile_apis::ButtonName::OK;
} // namespace
class UnsubscribeButtonRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {};
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ public:
+ typedef TypeIf<kMocksAreNice,
+ NiceMock<application_manager_test::MockHMICapabilities>,
+ application_manager_test::MockHMICapabilities>::Result
+ MockHMICapabilities;
+};
TEST_F(UnsubscribeButtonRequestTest, Run_AppNotRegistered_UNSUCCESS) {
CommandPtr command(CreateCommand<UnsubscribeButtonRequest>());
@@ -55,13 +62,21 @@ TEST_F(UnsubscribeButtonRequestTest,
CommandPtr command(CreateCommand<UnsubscribeButtonRequest>(command_msg));
+ UnsubscribeButtonRequestTest::MockHMICapabilities hmi_capabilities;
+ EXPECT_CALL(app_mngr_, hmi_capabilities())
+ .WillOnce(ReturnRef(hmi_capabilities));
+ EXPECT_CALL(hmi_capabilities, is_ui_cooperating()).WillOnce(Return(true));
+
+ MessageSharedPtr button_caps_ptr(CreateMessage(smart_objects::SmartType_Map));
+ (*button_caps_ptr)[0][am::hmi_response::button_name] = kButtonId;
+ EXPECT_CALL(hmi_capabilities, button_capabilities())
+ .WillOnce(Return(button_caps_ptr.get()));
+
MockAppPtr mock_app(CreateMockApp());
EXPECT_CALL(app_mngr_, application(kConnectionKey))
.WillOnce(Return(mock_app));
-
EXPECT_CALL(*mock_app, UnsubscribeFromButton(kButtonId))
.WillOnce(Return(false));
-
EXPECT_CALL(
app_mngr_,
ManageMobileCommand(MobileResultCodeIs(mobile_result::IGNORED), _));
@@ -69,9 +84,35 @@ TEST_F(UnsubscribeButtonRequestTest,
command->Run();
}
-TEST_F(UnsubscribeButtonRequestTest, Run_SUCCESS) {
- const mobile_apis::ButtonName::eType kButtonId = mobile_apis::ButtonName::OK;
+TEST_F(UnsubscribeButtonRequestTest,
+ Run_UnsubscribeNotAllowedByHmiCapabilities_UNSUCCESS) {
+ MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
+ (*command_msg)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
+ (*command_msg)[am::strings::msg_params][am::strings::button_name] = kButtonId;
+ CommandPtr command(CreateCommand<UnsubscribeButtonRequest>(command_msg));
+ MockAppPtr mock_app(CreateMockApp());
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+
+ UnsubscribeButtonRequestTest::MockHMICapabilities hmi_capabilities;
+ EXPECT_CALL(app_mngr_, hmi_capabilities())
+ .WillOnce(ReturnRef(hmi_capabilities));
+ EXPECT_CALL(hmi_capabilities, is_ui_cooperating()).WillOnce(Return(true));
+
+ MessageSharedPtr button_caps_ptr(CreateMessage(smart_objects::SmartType_Map));
+ EXPECT_CALL(hmi_capabilities, button_capabilities())
+ .WillOnce(Return(button_caps_ptr.get()));
+
+ EXPECT_CALL(app_mngr_,
+ ManageMobileCommand(
+ MobileResultCodeIs(mobile_result::UNSUPPORTED_RESOURCE), _));
+
+ command->Run();
+}
+
+TEST_F(UnsubscribeButtonRequestTest, Run_SUCCESS) {
MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
(*command_msg)[am::strings::params][am::strings::connection_key] =
kConnectionKey;
@@ -79,9 +120,19 @@ TEST_F(UnsubscribeButtonRequestTest, Run_SUCCESS) {
CommandPtr command(CreateCommand<UnsubscribeButtonRequest>(command_msg));
+ UnsubscribeButtonRequestTest::MockHMICapabilities hmi_capabilities;
+ EXPECT_CALL(app_mngr_, hmi_capabilities())
+ .WillOnce(ReturnRef(hmi_capabilities));
+ EXPECT_CALL(hmi_capabilities, is_ui_cooperating()).WillOnce(Return(true));
+
+ MessageSharedPtr button_caps_ptr(CreateMessage(smart_objects::SmartType_Map));
+ (*button_caps_ptr)[0][am::hmi_response::button_name] = kButtonId;
+ EXPECT_CALL(hmi_capabilities, button_capabilities())
+ .WillOnce(Return(button_caps_ptr.get()));
+
MockAppPtr mock_app(CreateMockApp());
EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
+ .WillRepeatedly(Return(mock_app));
EXPECT_CALL(*mock_app, UnsubscribeFromButton(kButtonId))
.WillOnce(Return(true));
@@ -94,7 +145,7 @@ TEST_F(UnsubscribeButtonRequestTest, Run_SUCCESS) {
ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _));
EXPECT_CALL(*mock_app, UpdateHash());
-
+ command->Init();
command->Run();
}
diff --git a/src/components/application_manager/test/commands/mobile/unsubscribe_vehicle_request_test.cc b/src/components/application_manager/test/commands/mobile/unsubscribe_vehicle_request_test.cc
index eae368347e..9652364646 100644
--- a/src/components/application_manager/test/commands/mobile/unsubscribe_vehicle_request_test.cc
+++ b/src/components/application_manager/test/commands/mobile/unsubscribe_vehicle_request_test.cc
@@ -181,22 +181,26 @@ void UnsubscribeVehicleRequestTest::UnsubscribeSuccessfully() {
(*command_msg)[am::strings::params][am::strings::connection_key] =
kConnectionKey;
(*command_msg)[am::strings::msg_params][kMsgParamKey] = true;
+
am::VehicleData vehicle_data;
vehicle_data.insert(am::VehicleData::value_type(kMsgParamKey, kVehicleType));
+
EXPECT_CALL(*(am::MockMessageHelper::message_helper_mock()), vehicle_data())
.WillOnce(ReturnRef(vehicle_data));
- CommandPtr command(CreateCommand<UnsubscribeVehicleDataRequest>(command_msg));
am::ApplicationSet application_set_;
MockAppPtr mock_app(CreateMockApp());
application_set_.insert(mock_app);
DataAccessor<am::ApplicationSet> accessor(application_set_, app_set_lock_);
+
EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
- EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor));
+ .WillRepeatedly(Return(mock_app));
+
+ EXPECT_CALL(app_mngr_, applications()).WillRepeatedly(Return(accessor));
EXPECT_CALL(*mock_app, IsSubscribedToIVI(kVehicleType))
.WillRepeatedly(Return(true));
+
EXPECT_CALL(*mock_app, UnsubscribeFromIVI(kVehicleType))
.WillRepeatedly(Return(true));
@@ -204,6 +208,7 @@ void UnsubscribeVehicleRequestTest::UnsubscribeSuccessfully() {
app_mngr_,
ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _));
+ CommandPtr command(CreateCommand<UnsubscribeVehicleDataRequest>(command_msg));
command->Run();
}
@@ -230,6 +235,7 @@ TEST_F(UnsubscribeVehicleRequestTest, OnEvent_DataNotSubscribed_IGNORED) {
EXPECT_CALL(
app_mngr_,
ManageMobileCommand(MobileResultCodeIs(mobile_result::IGNORED), _));
+ command->Init();
command->Run();
am::event_engine::Event test_event(
@@ -274,15 +280,10 @@ TEST_F(UnsubscribeVehicleRequestTest, OnEvent_DataUnsubscribed_SUCCESS) {
EXPECT_CALL(*(am::MockMessageHelper::message_helper_mock()),
HMIToMobileResult(hmi_result)).WillOnce(Return(mob_result));
- EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
-
EXPECT_CALL(
app_mngr_,
ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _));
- EXPECT_CALL(*mock_app, UpdateHash());
-
command->on_event(test_event);
}
diff --git a/src/components/application_manager/test/commands/mobile/unsubscribe_way_points_request_test.cc b/src/components/application_manager/test/commands/mobile/unsubscribe_way_points_request_test.cc
index 738cf35553..50567a7c62 100644
--- a/src/components/application_manager/test/commands/mobile/unsubscribe_way_points_request_test.cc
+++ b/src/components/application_manager/test/commands/mobile/unsubscribe_way_points_request_test.cc
@@ -152,7 +152,7 @@ TEST_F(UnSubscribeWayPointsRequestTest,
OnEvent_ReceivedNavigationUnSubscribeWayPointsEvent_SUCCESS) {
MockAppPtr mock_app(CreateMockApp());
EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
+ .WillRepeatedly(Return(mock_app));
MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map));
(*event_msg)[am::strings::msg_params] = 0;
diff --git a/src/components/application_manager/test/hmi_capabilities.json b/src/components/application_manager/test/hmi_capabilities.json
index 61cda5ce43..9db6ee78ae 100644
--- a/src/components/application_manager/test/hmi_capabilities.json
+++ b/src/components/application_manager/test/hmi_capabilities.json
@@ -1,465 +1,699 @@
{
- "UI":
- {
+ "UI": {
"language":"EN_US",
"languages":[
- "EN_US","ES_MX","FR_CA","DE_DE","ES_ES","EN_GB","RU_RU","TR_TR","PL_PL","FR_FR","IT_IT","SV_SE","PT_PT","NL_NL","ZH_TW",
-"JA_JP","AR_SA","KO_KR","PT_BR","CS_CZ","DA_DK","NO_NO"
+ "EN_US",
+ "ES_MX",
+ "FR_CA",
+ "DE_DE",
+ "ES_ES",
+ "EN_GB",
+ "RU_RU",
+ "TR_TR",
+ "PL_PL",
+ "FR_FR",
+ "IT_IT",
+ "SV_SE",
+ "PT_PT",
+ "NL_NL",
+ "ZH_TW",
+ "JA_JP",
+ "AR_SA",
+ "KO_KR",
+ "PT_BR",
+ "CS_CZ",
+ "DA_DK",
+ "NO_NO",
+ "NL_BE",
+ "EL_GR",
+ "HU_HU",
+ "FI_FI",
+ "SK_SK",
+ "EN_IN",
+ "TH_TH",
+ "EN_SA",
+ "HE_IL",
+ "RO_RO",
+ "UK_UA",
+ "ID_ID",
+ "VI_VN",
+ "MS_MY",
+ "HI_IN"
],
- "displayCapabilities":
+ "displayCapabilities": {
+ "displayType": "GEN2_8_DMA",
+ "textFields": [
{
- "displayType":"GEN2_8_DMA",
- "textFields": [{
- "name": "mainField1",
- "characterSet": "TYPE2SET",
- "width": 500,
- "rows": 1
- },
- {
- "name": "mainField2",
- "characterSet": "TYPE2SET",
- "width": 500,
- "rows": 1
- },
- {
- "name": "mainField3",
- "characterSet": "TYPE2SET",
- "width": 500,
- "rows": 1
- },
- {
- "name": "mainField4",
- "characterSet": "TYPE2SET",
- "width": 500,
- "rows": 1
- },
- {
- "name": "statusBar",
- "characterSet": "TYPE2SET",
- "width": 500,
- "rows": 1
- },
- {
- "name": "mediaClock",
- "characterSet": "TYPE2SET",
- "width": 500,
- "rows": 1
- },
- {
- "name": "mediaTrack",
- "characterSet": "TYPE2SET",
- "width": 500,
- "rows": 1
- },
- {
- "name": "alertText1",
- "characterSet": "TYPE2SET",
- "width": 500,
- "rows": 1
- },
- {
- "name": "alertText2",
- "characterSet": "TYPE2SET",
- "width": 500,
- "rows": 1
- },
- {
- "name": "alertText3",
- "characterSet": "TYPE2SET",
- "width": 500,
- "rows": 1
- },
- {
- "name": "scrollableMessageBody",
- "characterSet": "TYPE2SET",
- "width": 500,
- "rows": 1
- },
- {
- "name": "initialInteractionText",
- "characterSet": "TYPE2SET",
- "width": 500,
- "rows": 1
- },
- {
- "name": "navigationText1",
- "characterSet": "TYPE2SET",
- "width": 500,
- "rows": 1
- },
- {
- "name": "navigationText2",
- "characterSet": "TYPE2SET",
- "width": 500,
- "rows": 1
- },
- {
- "name": "ETA",
- "characterSet": "TYPE2SET",
- "width": 500,
- "rows": 1
- },
- {
- "name": "totalDistance",
- "characterSet": "TYPE2SET",
- "width": 500,
- "rows": 1
- },
- {
- "name": "navigationText",
- "characterSet": "TYPE2SET",
- "width": 500,
- "rows": 1
- },
- {
- "name": "audioPassThruDisplayText1",
- "characterSet": "TYPE2SET",
- "width": 500,
- "rows": 1
- },
- {
- "name": "audioPassThruDisplayText2",
- "characterSet": "TYPE2SET",
- "width": 500,
- "rows": 1
- },
- {
- "name": "sliderHeader",
- "characterSet": "TYPE2SET",
- "width": 500,
- "rows": 1
- },
- {
- "name": "sliderFooter",
- "characterSet": "TYPE2SET",
- "width": 500,
- "rows": 1
- },
- {
- "name": "notificationText",
- "characterSet": "TYPE2SET",
- "width": 500,
- "rows": 1
- },
- {
- "name": "menuName",
- "characterSet": "TYPE2SET",
- "width": 500,
- "rows": 1
- },
- {
- "name": "secondaryText",
- "characterSet": "TYPE2SET",
- "width": 500,
- "rows": 1
- },
- {
- "name": "tertiaryText",
- "characterSet": "TYPE2SET",
- "width": 500,
- "rows": 1
- },
- {
- "name": "timeToDestination",
- "characterSet": "TYPE2SET",
- "width": 500,
- "rows": 1
- },
- {
- "name": "turnText",
- "characterSet": "TYPE2SET",
- "width": 500,
- "rows": 1
- },
- {
- "name": "menuTitle",
- "characterSet": "TYPE2SET",
- "width": 500,
- "rows": 1
- }
- ],
- "imageFields":
- [
- {
- "name":"softButtonImage",
- "imageTypeSupported":
- [
- ],
- "imageResolution":
- {
- "resolutionWidth":35,
- "resolutionHeight":35
- }
- },
- {
- "name":"choiceImage",
- "imageTypeSupported":
- [
- ],
- "imageResolution":
- {
- "resolutionWidth":35,
- "resolutionHeight":35
- }
- },
- {
- "name":"choiceSecondaryImage",
- "imageTypeSupported":
- [
- ],
- "imageResolution":
- {
- "resolutionWidth":35,
- "resolutionHeight":35
- }
- },
- {
- "name":"menuIcon",
- "imageTypeSupported":
- [
- ],
- "imageResolution":
- {
- "resolutionWidth":35,
- "resolutionHeight":35
- }
- },
- {
- "name":"cmdIcon",
- "imageTypeSupported":
- [
- ],
- "imageResolution":
- {
- "resolutionWidth":35,
- "resolutionHeight":35
- }
- },
- {
- "name":"appIcon",
- "imageTypeSupported":
- [
- ],
- "imageResolution":
- {
- "resolutionWidth":35,
- "resolutionHeight":35
- }
- },
- {
- "name":"graphic",
- "imageTypeSupported":
- [
-
- ],
- "imageResolution":
- {
- "resolutionWidth":35,
- "resolutionHeight":35
- }
- },
- {
- "name":"locationImage",
- "imageTypeSupported":
- [
- "GRAPHIC_PNG"
- ],
- "imageResolution":
- {
- "resolutionWidth":35,
- "resolutionHeight":35
- }
- }
+ "name": "mainField1",
+ "characterSet": "TYPE2SET",
+ "width": 500,
+ "rows": 1
+ },
+ {
+ "name": "mainField2",
+ "characterSet": "TYPE2SET",
+ "width": 500,
+ "rows": 1
+ },
+ {
+ "name": "mainField3",
+ "characterSet": "TYPE2SET",
+ "width": 500,
+ "rows": 1
+ },
+ {
+ "name": "mainField4",
+ "characterSet": "TYPE2SET",
+ "width": 500,
+ "rows": 1
+ },
+ {
+ "name": "statusBar",
+ "characterSet": "TYPE2SET",
+ "width": 500,
+ "rows": 1
+ },
+ {
+ "name": "mediaClock",
+ "characterSet": "TYPE2SET",
+ "width": 500,
+ "rows": 1
+ },
+ {
+ "name": "mediaTrack",
+ "characterSet": "TYPE2SET",
+ "width": 500,
+ "rows": 1
+ },
+ {
+ "name": "alertText1",
+ "characterSet": "TYPE2SET",
+ "width": 500,
+ "rows": 1
+ },
+ {
+ "name": "alertText2",
+ "characterSet": "TYPE2SET",
+ "width": 500,
+ "rows": 1
+ },
+ {
+ "name": "alertText3",
+ "characterSet": "TYPE2SET",
+ "width": 500,
+ "rows": 1
+ },
+ {
+ "name": "scrollableMessageBody",
+ "characterSet": "TYPE2SET",
+ "width": 500,
+ "rows": 1
+ },
+ {
+ "name": "initialInteractionText",
+ "characterSet": "TYPE2SET",
+ "width": 500,
+ "rows": 1
+ },
+ {
+ "name": "navigationText1",
+ "characterSet": "TYPE2SET",
+ "width": 500,
+ "rows": 1
+ },
+ {
+ "name": "navigationText2",
+ "characterSet": "TYPE2SET",
+ "width": 500,
+ "rows": 1
+ },
+ {
+ "name": "ETA",
+ "characterSet": "TYPE2SET",
+ "width": 500,
+ "rows": 1
+ },
+ {
+ "name": "totalDistance",
+ "characterSet": "TYPE2SET",
+ "width": 500,
+ "rows": 1
+ },
+ {
+ "name": "navigationText",
+ "characterSet": "TYPE2SET",
+ "width": 500,
+ "rows": 1
+ },
+ {
+ "name": "audioPassThruDisplayText1",
+ "characterSet": "TYPE2SET",
+ "width": 500,
+ "rows": 1
+ },
+ {
+ "name": "audioPassThruDisplayText2",
+ "characterSet": "TYPE2SET",
+ "width": 500,
+ "rows": 1
+ },
+ {
+ "name": "sliderHeader",
+ "characterSet": "TYPE2SET",
+ "width": 500,
+ "rows": 1
+ },
+ {
+ "name": "sliderFooter",
+ "characterSet": "TYPE2SET",
+ "width": 500,
+ "rows": 1
+ },
+ {
+ "name": "notificationText",
+ "characterSet": "TYPE2SET",
+ "width": 500,
+ "rows": 1
+ },
+ {
+ "name": "menuName",
+ "characterSet": "TYPE2SET",
+ "width": 500,
+ "rows": 1
+ },
+ {
+ "name": "secondaryText",
+ "characterSet": "TYPE2SET",
+ "width": 500,
+ "rows": 1
+ },
+ {
+ "name": "tertiaryText",
+ "characterSet": "TYPE2SET",
+ "width": 500,
+ "rows": 1
+ },
+ {
+ "name": "timeToDestination",
+ "characterSet": "TYPE2SET",
+ "width": 500,
+ "rows": 1
+ },
+ {
+ "name": "turnText",
+ "characterSet": "TYPE2SET",
+ "width": 500,
+ "rows": 1
+ },
+ {
+ "name": "menuTitle",
+ "characterSet": "TYPE2SET",
+ "width": 500,
+ "rows": 1
+ }
+ ],
+ "imageFields": [
+ {
+ "name": "softButtonImage",
+ "imageTypeSupported": [],
+ "imageResolution": {
+ "resolutionWidth": 35,
+ "resolutionHeight": 35
+ }
+ },
+ {
+ "name": "choiceImage",
+ "imageTypeSupported": [],
+ "imageResolution": {
+ "resolutionWidth": 35,
+ "resolutionHeight": 35
+ }
+ },
+ {
+ "name": "choiceSecondaryImage",
+ "imageTypeSupported": [],
+ "imageResolution": {
+ "resolutionWidth": 35,
+ "resolutionHeight": 35
+ }
+ },
+ {
+ "name": "menuIcon",
+ "imageTypeSupported": [],
+ "imageResolution": {
+ "resolutionWidth": 35,
+ "resolutionHeight": 35
+ }
+ },
+ {
+ "name": "cmdIcon",
+ "imageTypeSupported": [],
+ "imageResolution": {
+ "resolutionWidth": 35,
+ "resolutionHeight": 35
+ }
+ },
+ {
+ "name": "appIcon",
+ "imageTypeSupported": [],
+ "imageResolution": {
+ "resolutionWidth": 35,
+ "resolutionHeight": 35
+ }
+ },
+ {
+ "name": "graphic",
+ "imageTypeSupported": [],
+ "imageResolution": {
+ "resolutionWidth": 35,
+ "resolutionHeight": 35
+ }
+ },
+ {
+ "name": "locationImage",
+ "imageTypeSupported": [
+ "GRAPHIC_PNG"
+ ],
+ "imageResolution": {
+ "resolutionWidth": 35,
+ "resolutionHeight": 35
+ }
+ }
- ],
- "mediaClockFormats":
- [
- "CLOCK1","CLOCK2","CLOCK3","CLOCKTEXT1","CLOCKTEXT2","CLOCKTEXT3","CLOCKTEXT4"
],
- "graphicSupported":true,
- "templatesAvailable":
- [
+ "mediaClockFormats": [
+ "CLOCK1",
+ "CLOCK2",
+ "CLOCK3",
+ "CLOCKTEXT1",
+ "CLOCKTEXT2",
+ "CLOCKTEXT3",
+ "CLOCKTEXT4"
+ ],
+ "graphicSupported": true,
+ "templatesAvailable": [
- "DEFAULT","MEDIA","NON-MEDIA","ONSCREEN_PRESETS","NAV_FULLSCREEN_MAP","NAV_KEYBOARD",
- "GRAPHIC_WITH_TEXT","TEXT_WITH_GRAPHIC","TILES_ONLY","TEXTBUTTONS_ONLY",
- "GRAPHIC_WITH_TILES","TILES_WITH_GRAPHIC","GRAPHIC_WITH_TEXT_AND_SOFTBUTTONS",
- "TEXT_AND_SOFTBUTTONS_WITH_GRAPHIC","GRAPHIC_WITH_TEXTBUTTONS",
- "TEXTBUTTONS_WITH_GRAPHIC","LARGE_GRAPHIC_WITH_SOFTBUTTONS",
- "DOUBLE_GRAPHIC_WITH_SOFTBUTTONS","LARGE_GRAPHIC_ONLY"
- ],
- "screenParams":
- {
- "resolution":
- {
- "resolutionWidth":800,
- "resolutionHeight":350
- },
- "touchEventAvailable":
- {
- "pressAvailable":true,
- "multiTouchAvailable":false,
- "doublePressAvailable":false
- }
- },
- "numCustomPresetsAvailable":8,
- "imageCapabilities":
- [
+ "DEFAULT",
+ "MEDIA",
+ "NON-MEDIA",
+ "ONSCREEN_PRESETS",
+ "NAV_FULLSCREEN_MAP",
+ "NAV_KEYBOARD",
+ "GRAPHIC_WITH_TEXT",
+ "TEXT_WITH_GRAPHIC",
+ "TILES_ONLY",
+ "TEXTBUTTONS_ONLY",
+ "GRAPHIC_WITH_TILES",
+ "TILES_WITH_GRAPHIC",
+ "GRAPHIC_WITH_TEXT_AND_SOFTBUTTONS",
+ "TEXT_AND_SOFTBUTTONS_WITH_GRAPHIC",
+ "GRAPHIC_WITH_TEXTBUTTONS",
+ "TEXTBUTTONS_WITH_GRAPHIC",
+ "LARGE_GRAPHIC_WITH_SOFTBUTTONS",
+ "DOUBLE_GRAPHIC_WITH_SOFTBUTTONS",
+ "LARGE_GRAPHIC_ONLY"
+ ],
+ "screenParams": {
+ "resolution": {
+ "resolutionWidth": 800,
+ "resolutionHeight": 350
+ },
+ "touchEventAvailable": {
+ "pressAvailable": true,
+ "multiTouchAvailable": false,
+ "doublePressAvailable": false
+ }
+ },
+ "numCustomPresetsAvailable": 8,
+ "imageCapabilities": [
"DYNAMIC",
"STATIC"
]
},
- "audioPassThruCapabilities":
- {
- "samplingRate" : "44KHZ",
- "bitsPerSample" : "RATE_8_BIT",
- "audioType" : "PCM"
+ "audioPassThruCapabilities": {
+ "samplingRate": "44KHZ",
+ "bitsPerSample": "RATE_8_BIT",
+ "audioType": "PCM"
},
- "pcmStreamCapabilities":
- {
- "samplingRate" : "16KHZ",
- "bitsPerSample" : "RATE_16_BIT",
- "audioType" : "PCM"
+ "pcmStreamCapabilities": {
+ "samplingRate": "16KHZ",
+ "bitsPerSample": "RATE_16_BIT",
+ "audioType": "PCM"
},
- "hmiZoneCapabilities":"FRONT",
- "softButtonCapabilities":
- [
- {
- "shortPressAvailable":true,
- "longPressAvailable" :true,
- "upDownAvailable" :true,
- "imageSupported" :true
- }
+ "hmiZoneCapabilities": "FRONT",
+ "softButtonCapabilities": [
+ {
+ "shortPressAvailable": true,
+ "longPressAvailable": true,
+ "upDownAvailable": true,
+ "imageSupported": true
+ }
+ ],
+ "systemCapabilities": {
+ "navigationCapability": {
+ "sendLocationEnabled": true,
+ "getWayPointsEnabled": true
+ },
+ "phoneCapability": {
+ "dialNumberEnabled": true
+ },
+
+ "remoteControlCapability":{
+ "climateControlCapabilities": [
+ {
+ "moduleName": "primary_climate",
+ "fanSpeedAvailable": true,
+ "desiredTemperatureAvailable": true,
+ "acEnableAvailable": true,
+ "acMaxEnableAvailable": true,
+ "circulateAirEnableAvailable": true,
+ "autoModeEnableAvailable": true,
+ "dualModeEnableAvailable": true,
+ "defrostZoneAvailable": true,
+ "ventilationModeAvailable": true,
+ "defrostZone": [
+ "FRONT",
+ "REAR",
+ "ALL",
+ "NONE"
+ ],
+ "ventilationMode": [
+ "UPPER",
+ "LOWER",
+ "BOTH",
+ "NONE"
+ ]
+ }
+ ],
+ "radioControlCapabilities": [
+ {
+ "moduleName": "radio",
+ "radioEnableAvailable": true,
+ "radioBandAvailable": true,
+ "radioFrequencyAvailable": true,
+ "hdChannelAvailable": true,
+ "rdsDataAvailable": true,
+ "availableHDsAvailable": true,
+ "stateAvailable": true,
+ "signalStrengthAvailable": true,
+ "signalChangeThresholdAvailable": true
+ }
+ ],
+ "buttonCapabilities": [
+ {
+ "name": "AC_MAX",
+ "shortPressAvailable": true,
+ "longPressAvailable": true,
+ "upDownAvailable": false
+ },
+ {
+ "name": "AC",
+ "shortPressAvailable": true,
+ "longPressAvailable": true,
+ "upDownAvailable": false
+ },
+ {
+ "name": "RECIRCULATE",
+ "shortPressAvailable": true,
+ "longPressAvailable": true,
+ "upDownAvailable": false
+ },
+ {
+ "name": "FAN_UP",
+ "shortPressAvailable": true,
+ "longPressAvailable": true,
+ "upDownAvailable": false
+ },
+ {
+ "name": "FAN_DOWN",
+ "shortPressAvailable": true,
+ "longPressAvailable": true,
+ "upDownAvailable": false
+ },
+ {
+ "name": "TEMP_UP",
+ "shortPressAvailable": true,
+ "longPressAvailable": true,
+ "upDownAvailable": false
+ },
+ {
+ "name": "TEMP_DOWN",
+ "shortPressAvailable": true,
+ "longPressAvailable": true,
+ "upDownAvailable": false
+ },
+ {
+ "name": "DEFROST_MAX",
+ "shortPressAvailable": true,
+ "longPressAvailable": true,
+ "upDownAvailable": false
+ },
+ {
+ "name": "DEFROST",
+ "shortPressAvailable": true,
+ "longPressAvailable": true,
+ "upDownAvailable": false
+ },
+ {
+ "name": "DEFROST_REAR",
+ "shortPressAvailable": true,
+ "longPressAvailable": true,
+ "upDownAvailable": false
+ },
+ {
+ "name": "UPPER_VENT",
+ "shortPressAvailable": true,
+ "longPressAvailable": true,
+ "upDownAvailable": false
+ },
+ {
+ "name": "LOWER_VENT",
+ "shortPressAvailable": true,
+ "longPressAvailable": true,
+ "upDownAvailable": false
+ },
+ {
+ "name": "VOLUME_UP",
+ "shortPressAvailable": true,
+ "longPressAvailable": true,
+ "upDownAvailable": false
+ },
+ {
+ "name": "VOLUME_DOWN",
+ "shortPressAvailable": true,
+ "longPressAvailable": true,
+ "upDownAvailable": false
+ },
+ {
+ "name": "EJECT",
+ "shortPressAvailable": true,
+ "longPressAvailable": true,
+ "upDownAvailable": false
+ },
+ {
+ "name": "SOURCE",
+ "shortPressAvailable": true,
+ "longPressAvailable": true,
+ "upDownAvailable": false
+ },
+ {
+ "name": "SHUFFLE",
+ "shortPressAvailable": true,
+ "longPressAvailable": true,
+ "upDownAvailable": false
+ },
+ {
+ "name": "REPEAT",
+ "shortPressAvailable": true,
+ "longPressAvailable": true,
+ "upDownAvailable": false
+ }
+ ]
+ },
+ "videoStreamingCapability": {
+ "preferredResolution": {
+ "resolutionWidth": 800,
+ "resolutionHeight": 350
+ },
+ "maxBitrate": 10000,
+ "supportedFormats": [
+ {
+ "protocol": "RAW",
+ "codec": "H264"
+ },
+ {
+ "protocol": "RTP",
+ "codec": "Theora"
+ }
+ ],
+ "hapticSpatialDataSupported": true
+ }
+ }
+ },
+ "VR": {
+ "capabilities": [
+ "TEXT"
+ ],
+ "language": "ES_MX",
+ "languages": [
+ "AR_SA",
+ "EN_US",
+ "ES_MX",
+ "FR_CA",
+ "DE_DE",
+ "ES_ES",
+ "EN_GB",
+ "RU_RU",
+ "TR_TR",
+ "PL_PL",
+ "FR_FR",
+ "IT_IT",
+ "SV_SE",
+ "PT_PT",
+ "NL_NL",
+ "ZH_TW",
+ "JA_JP",
+ "KO_KR",
+ "PT_BR",
+ "CS_CZ",
+ "DA_DK",
+ "NO_NO"
]
},
- "VR":
- {
- "capabilities":["TEXT"],
- "language":"ES_MX",
- "languages":
- [
- "AR_SA", "EN_US","ES_MX","FR_CA","DE_DE","ES_ES","EN_GB","RU_RU","TR_TR","PL_PL","FR_FR","IT_IT","SV_SE","PT_PT","NL_NL","ZH_TW",
-"JA_JP","KO_KR","PT_BR","CS_CZ","DA_DK","NO_NO"
- ]
-},
- "TTS":
- {
- "capabilities":["TEXT"],
- "language":"DE_DE",
- "languages":
- [
- "DA_DK","CS_CZ","KO_KR","EN_US","ES_MX","FR_CA","DE_DE","ES_ES","EN_GB","RU_RU","TR_TR","PL_PL","FR_FR","IT_IT","SV_SE","PT_PT","NL_NL","ZH_TW",
-"JA_JP","AR_SA","PT_BR","NO_NO"
+ "TTS": {
+ "capabilities": [
+ "TEXT"
+ ],
+ "language": "DE_DE",
+ "languages": [
+ "DA_DK",
+ "CS_CZ",
+ "KO_KR",
+ "EN_US",
+ "ES_MX",
+ "FR_CA",
+ "DE_DE",
+ "ES_ES",
+ "EN_GB",
+ "RU_RU",
+ "TR_TR",
+ "PL_PL",
+ "FR_FR",
+ "IT_IT",
+ "SV_SE",
+ "PT_PT",
+ "NL_NL",
+ "ZH_TW",
+ "JA_JP",
+ "AR_SA",
+ "PT_BR",
+ "NO_NO"
]
},
- "Buttons":
- {
- "capabilities":
- [
- {
- "name":"PRESET_0",
- "shortPressAvailable":true,
- "longPressAvailable" :true,
- "upDownAvailable" :true
+ "Buttons": {
+ "capabilities": [
+ {
+ "name": "PRESET_0",
+ "shortPressAvailable": true,
+ "longPressAvailable": true,
+ "upDownAvailable": true
},
{
- "name":"PRESET_1",
- "shortPressAvailable":true,
- "longPressAvailable" :true,
- "upDownAvailable" :true
+ "name": "PRESET_1",
+ "shortPressAvailable": true,
+ "longPressAvailable": true,
+ "upDownAvailable": true
},
{
- "name":"PRESET_2",
- "shortPressAvailable":true,
- "longPressAvailable" :true,
- "upDownAvailable" :true
+ "name": "PRESET_2",
+ "shortPressAvailable": true,
+ "longPressAvailable": true,
+ "upDownAvailable": true
},
{
- "name":"PRESET_3",
- "shortPressAvailable":true,
- "longPressAvailable" :true,
- "upDownAvailable" :true
+ "name": "PRESET_3",
+ "shortPressAvailable": true,
+ "longPressAvailable": true,
+ "upDownAvailable": true
},
{
- "name":"PRESET_4",
- "shortPressAvailable":true,
- "longPressAvailable" :true,
- "upDownAvailable" :true
+ "name": "PRESET_4",
+ "shortPressAvailable": true,
+ "longPressAvailable": true,
+ "upDownAvailable": true
},
{
- "name":"PRESET_5",
- "shortPressAvailable":true,
- "longPressAvailable" :true,
- "upDownAvailable" :true
+ "name": "PRESET_5",
+ "shortPressAvailable": true,
+ "longPressAvailable": true,
+ "upDownAvailable": true
},
{
- "name":"PRESET_6",
- "shortPressAvailable":true,
- "longPressAvailable" :true,
- "upDownAvailable" :true
+ "name": "PRESET_6",
+ "shortPressAvailable": true,
+ "longPressAvailable": true,
+ "upDownAvailable": true
},
{
- "name":"PRESET_7",
- "shortPressAvailable":true,
- "longPressAvailable" :true,
- "upDownAvailable" :true
+ "name": "PRESET_7",
+ "shortPressAvailable": true,
+ "longPressAvailable": true,
+ "upDownAvailable": true
},
{
- "name":"PRESET_8",
- "shortPressAvailable":true,
- "longPressAvailable" :true,
- "upDownAvailable" :true
+ "name": "PRESET_8",
+ "shortPressAvailable": true,
+ "longPressAvailable": true,
+ "upDownAvailable": true
},
{
- "name":"PRESET_9",
- "shortPressAvailable":true,
- "longPressAvailable" :true,
- "upDownAvailable" :true
+ "name": "PRESET_9",
+ "shortPressAvailable": true,
+ "longPressAvailable": true,
+ "upDownAvailable": true
},
{
- "name":"OK",
- "shortPressAvailable":true,
- "longPressAvailable" :true,
- "upDownAvailable" :true
+ "name": "OK",
+ "shortPressAvailable": true,
+ "longPressAvailable": true,
+ "upDownAvailable": true
},
{
- "name":"SEEKLEFT",
- "shortPressAvailable":true,
- "longPressAvailable" :true,
- "upDownAvailable" :true
+ "name": "SEEKLEFT",
+ "shortPressAvailable": true,
+ "longPressAvailable": true,
+ "upDownAvailable": true
},
{
- "name":"SEEKRIGHT",
- "shortPressAvailable":true,
- "longPressAvailable" :true,
- "upDownAvailable" :true
+ "name": "SEEKRIGHT",
+ "shortPressAvailable": true,
+ "longPressAvailable": true,
+ "upDownAvailable": true
},
{
- "name":"TUNEUP",
- "shortPressAvailable":true,
- "longPressAvailable" :true,
- "upDownAvailable" :true
+ "name": "TUNEUP",
+ "shortPressAvailable": true,
+ "longPressAvailable": true,
+ "upDownAvailable": true
},
{
- "name":"TUNEDOWN",
- "shortPressAvailable":true,
- "longPressAvailable" :true,
- "upDownAvailable" :true
+ "name": "TUNEDOWN",
+ "shortPressAvailable": true,
+ "longPressAvailable": true,
+ "upDownAvailable": true
}
],
- "presetBankCapabilities":
- {
- "onScreenPresetsAvailable":true
+ "presetBankCapabilities": {
+ "onScreenPresetsAvailable": true
}
},
- "VehicleInfo":
- {
- "make" :"Ford",
- "model" :"Fiesta",
- "modelYear" :"2013",
- "trim" :"SE"
+ "VehicleInfo": {
+ "make": "Ford",
+ "model": "Fiesta",
+ "modelYear": "2013",
+ "trim": "SE"
},
- "SyncMessageVersion":
- {
+ "SyncMessageVersion": {
"majorVersion": 3,
"minorVersion": 0
}
diff --git a/src/components/application_manager/test/hmi_capabilities_test.cc b/src/components/application_manager/test/hmi_capabilities_test.cc
index 4eb9f920d9..5c3830d5a5 100644
--- a/src/components/application_manager/test/hmi_capabilities_test.cc
+++ b/src/components/application_manager/test/hmi_capabilities_test.cc
@@ -2,6 +2,9 @@
* Copyright (c) 2017, Ford Motor Company
* All rights reserved.
*
+ * Copyright (c) 2017 Xevo Inc.
+ * All rights reserved.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
@@ -13,7 +16,7 @@
* 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
+ * Neither the name of the copyright holders nor the names of their contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -104,7 +107,8 @@ const char* const cstring_values_[] = {
"EN_US", "ES_MX", "FR_CA", "DE_DE", "ES_ES", "EN_GB", "RU_RU", "TR_TR",
"PL_PL", "FR_FR", "IT_IT", "SV_SE", "PT_PT", "NL_NL", "EN_AU", "ZH_CN",
"ZH_TW", "JA_JP", "AR_SA", "KO_KR", "PT_BR", "CS_CZ", "DA_DK", "NO_NO",
- "NL_BE", "EL_GR", "HU_HU", "FI_FI", "SK_SK"};
+ "NL_BE", "EL_GR", "HU_HU", "FI_FI", "SK_SK", "EN_IN", "TH_TH", "EN_SA",
+ "HE_IL", "RO_RO", "UK_UA", "ID_ID", "VI_VN", "MS_MY", "HI_IN"};
const hmi_apis::Common_Language::eType enum_values_[] = {
hmi_apis::Common_Language::EN_US, hmi_apis::Common_Language::ES_MX,
@@ -121,7 +125,12 @@ const hmi_apis::Common_Language::eType enum_values_[] = {
hmi_apis::Common_Language::DA_DK, hmi_apis::Common_Language::NO_NO,
hmi_apis::Common_Language::NL_BE, hmi_apis::Common_Language::EL_GR,
hmi_apis::Common_Language::HU_HU, hmi_apis::Common_Language::FI_FI,
- hmi_apis::Common_Language::SK_SK};
+ hmi_apis::Common_Language::SK_SK, hmi_apis::Common_Language::EN_IN,
+ hmi_apis::Common_Language::TH_TH, hmi_apis::Common_Language::EN_SA,
+ hmi_apis::Common_Language::HE_IL, hmi_apis::Common_Language::RO_RO,
+ hmi_apis::Common_Language::UK_UA, hmi_apis::Common_Language::ID_ID,
+ hmi_apis::Common_Language::VI_VN, hmi_apis::Common_Language::MS_MY,
+ hmi_apis::Common_Language::HI_IN};
struct CStringComparator {
bool operator()(const char* a, const char* b) {
@@ -351,12 +360,113 @@ TEST_F(HMICapabilitiesTest, LoadCapabilitiesFromFile) {
// Check vehicle type
const smart_objects::SmartObject vehicle_type_so =
*(hmi_capabilities_test->vehicle_type());
- EXPECT_TRUE(preset_bank_so["onScreenPresetsAvailable"].asBool());
EXPECT_EQ("Ford", vehicle_type_so["make"].asString());
EXPECT_EQ("Fiesta", vehicle_type_so["model"].asString());
EXPECT_EQ("2013", vehicle_type_so["modelYear"].asString());
EXPECT_EQ("SE", vehicle_type_so["trim"].asString());
+
+ // Check system capabilities
+ smart_objects::SmartObject navigation_capability_so =
+ *(hmi_capabilities_test->navigation_capability());
+
+ EXPECT_TRUE(navigation_capability_so.keyExists("sendLocationEnabled"));
+ EXPECT_TRUE(navigation_capability_so.keyExists("getWayPointsEnabled"));
+ EXPECT_TRUE(navigation_capability_so["sendLocationEnabled"].asBool());
+ EXPECT_TRUE(navigation_capability_so["getWayPointsEnabled"].asBool());
+
+ const smart_objects::SmartObject phone_capability_so =
+ *(hmi_capabilities_test->phone_capability());
+
+ EXPECT_TRUE(phone_capability_so.keyExists("dialNumberEnabled"));
+ EXPECT_TRUE(phone_capability_so["dialNumberEnabled"].asBool());
+
+ const smart_objects::SmartObject vs_capability_so =
+ *(hmi_capabilities_test->video_streaming_capability());
+
+ EXPECT_TRUE(vs_capability_so.keyExists(strings::preferred_resolution));
+ EXPECT_TRUE(vs_capability_so[strings::preferred_resolution].keyExists(
+ strings::resolution_width));
+ EXPECT_TRUE(vs_capability_so[strings::preferred_resolution].keyExists(
+ strings::resolution_height));
+ EXPECT_EQ(
+ 800,
+ vs_capability_so[strings::preferred_resolution][strings::resolution_width]
+ .asInt());
+ EXPECT_EQ(350,
+ vs_capability_so[strings::preferred_resolution]
+ [strings::resolution_height].asInt());
+ EXPECT_TRUE(vs_capability_so.keyExists(strings::max_bitrate));
+ EXPECT_EQ(10000, vs_capability_so[strings::max_bitrate].asInt());
+ EXPECT_TRUE(vs_capability_so.keyExists(strings::supported_formats));
+ const uint32_t supported_formats_len =
+ vs_capability_so[strings::supported_formats].length();
+ EXPECT_EQ(2u, supported_formats_len);
+ EXPECT_TRUE(vs_capability_so[strings::supported_formats][0].keyExists(
+ strings::protocol));
+ EXPECT_TRUE(vs_capability_so[strings::supported_formats][0].keyExists(
+ strings::codec));
+ EXPECT_EQ(0,
+ vs_capability_so[strings::supported_formats][0][strings::protocol]
+ .asInt());
+ EXPECT_EQ(
+ 0,
+ vs_capability_so[strings::supported_formats][0][strings::codec].asInt());
+ EXPECT_TRUE(vs_capability_so[strings::supported_formats][1].keyExists(
+ strings::protocol));
+ EXPECT_TRUE(vs_capability_so[strings::supported_formats][1].keyExists(
+ strings::codec));
+ EXPECT_EQ(1,
+ vs_capability_so[strings::supported_formats][1][strings::protocol]
+ .asInt());
+ EXPECT_EQ(
+ 2,
+ vs_capability_so[strings::supported_formats][1][strings::codec].asInt());
+
+ EXPECT_TRUE(
+ vs_capability_so.keyExists(strings::haptic_spatial_data_supported));
+ EXPECT_TRUE(
+ vs_capability_so[strings::haptic_spatial_data_supported].asBool());
+
+ // Check remote control capabilites
+ const smart_objects::SmartObject rc_capability_so =
+ *(hmi_capabilities_test->rc_capability());
+
+ EXPECT_TRUE(rc_capability_so.keyExists("climateControlCapabilities"));
+ EXPECT_TRUE(rc_capability_so.keyExists("radioControlCapabilities"));
+ EXPECT_TRUE(rc_capability_so.keyExists("buttonCapabilities"));
+
+ EXPECT_TRUE(
+ rc_capability_so["climateControlCapabilities"][0]["fanSpeedAvailable"]
+ .asBool());
+ EXPECT_TRUE(rc_capability_so["climateControlCapabilities"][0]
+ ["desiredTemperatureAvailable"].asBool());
+ EXPECT_TRUE(
+ rc_capability_so["climateControlCapabilities"][0]["acEnableAvailable"]
+ .asBool());
+ EXPECT_TRUE(
+ rc_capability_so["climateControlCapabilities"][0]["acMaxEnableAvailable"]
+ .asBool());
+
+ EXPECT_TRUE(
+ rc_capability_so["radioControlCapabilities"][0]["radioBandAvailable"]
+ .asBool());
+ EXPECT_TRUE(
+ rc_capability_so["radioControlCapabilities"][0]["radioFrequencyAvailable"]
+ .asBool());
+ EXPECT_TRUE(
+ rc_capability_so["radioControlCapabilities"][0]["hdChannelAvailable"]
+ .asBool());
+ EXPECT_TRUE(
+ rc_capability_so["radioControlCapabilities"][0]["rdsDataAvailable"]
+ .asBool());
+
+ EXPECT_TRUE(rc_capability_so["buttonCapabilities"][0]["shortPressAvailable"]
+ .asBool());
+ EXPECT_TRUE(
+ rc_capability_so["buttonCapabilities"][0]["longPressAvailable"].asBool());
+ EXPECT_FALSE(
+ rc_capability_so["buttonCapabilities"][0]["upDownAvailable"].asBool());
}
TEST_F(HMICapabilitiesTest, VerifyImageType) {
diff --git a/src/components/application_manager/test/include/application_manager/mock_application.h b/src/components/application_manager/test/include/application_manager/mock_application.h
index 2617f777bb..c24e4590f5 100644
--- a/src/components/application_manager/test/include/application_manager/mock_application.h
+++ b/src/components/application_manager/test/include/application_manager/mock_application.h
@@ -34,6 +34,7 @@
#include <string>
#include "gmock/gmock.h"
#include "application_manager/application.h"
+#include "application_manager/app_extension.h"
#include "smart_objects/smart_object.h"
#include "utils/custom_string.h"
#include "application_manager/usage_statistics.h"
@@ -59,6 +60,8 @@ class MockApplication : public ::application_manager::Application {
MOCK_METHOD0(ChangeSupportingAppHMIType, void());
MOCK_CONST_METHOD0(is_navi, bool());
MOCK_METHOD1(set_is_navi, void(bool allow));
+ MOCK_CONST_METHOD0(mobile_projection_enabled, bool());
+ MOCK_METHOD1(set_mobile_projection_enabled, void(bool allow));
MOCK_CONST_METHOD0(video_streaming_approved, bool());
MOCK_METHOD1(set_video_streaming_approved, void(bool state));
MOCK_CONST_METHOD0(audio_streaming_approved, bool());
@@ -68,6 +71,9 @@ class MockApplication : public ::application_manager::Application {
MOCK_CONST_METHOD0(audio_streaming_allowed, bool());
MOCK_METHOD1(set_audio_streaming_allowed, void(bool state));
MOCK_CONST_METHOD0(is_audio, bool());
+ MOCK_METHOD2(SetVideoConfig,
+ bool(protocol_handler::ServiceType service_type,
+ const smart_objects::SmartObject& params));
MOCK_METHOD1(StartStreaming,
void(protocol_handler::ServiceType service_type));
MOCK_METHOD1(StopStreaming, void(protocol_handler::ServiceType service_type));
@@ -121,9 +127,9 @@ class MockApplication : public ::application_manager::Application {
MOCK_METHOD1(set_grammar_id, void(uint32_t value));
MOCK_METHOD1(
set_protocol_version,
- void(const ::application_manager::ProtocolVersion& protocol_version));
+ void(const ::protocol_handler::MajorProtocolVersion& protocol_version));
MOCK_CONST_METHOD0(protocol_version,
- ::application_manager::ProtocolVersion());
+ ::protocol_handler::MajorProtocolVersion());
MOCK_METHOD1(set_is_resuming, void(bool));
MOCK_CONST_METHOD0(is_resuming, bool());
MOCK_METHOD1(AddFile, bool(const ::application_manager::AppFile& file));
@@ -275,12 +281,41 @@ class MockApplication : public ::application_manager::Application {
MOCK_CONST_METHOD0(bundle_id, const std::string&());
MOCK_METHOD1(set_bundle_id, void(const std::string& bundle_id));
MOCK_METHOD0(GetAvailableDiskSpace, uint32_t());
+
MOCK_METHOD1(set_mobile_app_id, void(const std::string& policy_app_id));
MOCK_CONST_METHOD0(is_foreground, bool());
MOCK_METHOD1(set_foreground, void(bool is_foreground));
MOCK_CONST_METHOD0(IsRegistered, bool());
MOCK_CONST_METHOD0(SchemaUrl, std::string());
MOCK_CONST_METHOD0(PackageName, std::string());
+
+#ifdef SDL_REMOTE_CONTROL
+ MOCK_METHOD1(
+ set_system_context,
+ void(const application_manager::mobile_api::SystemContext::eType&));
+ MOCK_METHOD1(
+ set_audio_streaming_state,
+ void(const application_manager::mobile_api::AudioStreamingState::eType&
+ state));
+ MOCK_METHOD1(IsSubscribedToInteriorVehicleData,
+ bool(smart_objects::SmartObject module));
+ MOCK_METHOD1(SubscribeToInteriorVehicleData,
+ bool(smart_objects::SmartObject module));
+ MOCK_METHOD1(UnsubscribeFromInteriorVehicleData,
+ bool(smart_objects::SmartObject module));
+ MOCK_METHOD1(
+ set_hmi_level,
+ void(const application_manager::mobile_api::HMILevel::eType& hmi_level));
+ MOCK_METHOD1(QueryInterface,
+ application_manager::AppExtensionPtr(
+ application_manager::AppExtensionUID uid));
+ MOCK_METHOD1(AddExtension,
+ bool(application_manager::AppExtensionPtr extention));
+ MOCK_METHOD1(RemoveExtension, bool(application_manager::AppExtensionUID uid));
+ MOCK_METHOD0(RemoveExtensions, void());
+ MOCK_CONST_METHOD0(SubscribesIVI, const std::set<uint32_t>&());
+
+#endif // SDL_REMOTE_CONTROL
};
} // namespace application_manager_test
diff --git a/src/components/application_manager/test/include/application_manager/mock_hmi_capabilities.h b/src/components/application_manager/test/include/application_manager/mock_hmi_capabilities.h
index a8664f5e2c..dd7ec5f0d5 100644
--- a/src/components/application_manager/test/include/application_manager/mock_hmi_capabilities.h
+++ b/src/components/application_manager/test/include/application_manager/mock_hmi_capabilities.h
@@ -61,6 +61,9 @@ class MockHMICapabilities : public ::application_manager::HMICapabilities {
MOCK_CONST_METHOD0(is_ivi_cooperating, bool());
MOCK_METHOD1(set_is_ivi_cooperating, void(const bool value));
+ MOCK_CONST_METHOD0(is_rc_cooperating, bool());
+ MOCK_METHOD1(set_is_rc_cooperating, void(const bool value));
+
MOCK_CONST_METHOD0(attenuated_supported, bool());
MOCK_METHOD1(set_attenuated_supported, void(const bool state));
@@ -154,6 +157,27 @@ class MockHMICapabilities : public ::application_manager::HMICapabilities {
MOCK_CONST_METHOD0(phone_call_supported, bool());
MOCK_METHOD1(set_phone_call_supported, void(const bool supported));
+ MOCK_CONST_METHOD0(video_streaming_supported, bool());
+ MOCK_METHOD1(set_video_streaming_supported, void(const bool supported));
+
+ MOCK_CONST_METHOD0(navigation_capability,
+ const smart_objects::SmartObject*());
+ MOCK_METHOD1(set_navigation_capability,
+ void(const smart_objects::SmartObject& navigation_capability));
+
+ MOCK_CONST_METHOD0(phone_capability, const smart_objects::SmartObject*());
+ MOCK_METHOD1(set_phone_capability,
+ void(const smart_objects::SmartObject& phone_capability));
+
+ MOCK_CONST_METHOD0(video_streaming_capability,
+ const smart_objects::SmartObject*());
+ MOCK_METHOD1(
+ set_video_streaming_capability,
+ void(const smart_objects::SmartObject& video_streaming_capability));
+ MOCK_CONST_METHOD0(rc_capability, const smart_objects::SmartObject*());
+ MOCK_METHOD1(set_rc_capability,
+ void(const smart_objects::SmartObject& rc_capability));
+
MOCK_METHOD1(Init, void(resumption::LastState* last_state));
MOCK_CONST_METHOD0(ccpu_version, const std::string&());
diff --git a/src/components/application_manager/test/include/application_manager/mock_message_helper.h b/src/components/application_manager/test/include/application_manager/mock_message_helper.h
index 0d28f9e522..f927f6bb72 100644
--- a/src/components/application_manager/test/include/application_manager/mock_message_helper.h
+++ b/src/components/application_manager/test/include/application_manager/mock_message_helper.h
@@ -70,6 +70,10 @@ class MockMessageHelper {
const connection_handler::DeviceMap& devices,
const policy::PolicyHandlerInterface& policy_handler,
ApplicationManager& app_mngr));
+ MOCK_METHOD3(SendNaviSetVideoConfig,
+ void(int32_t app_id,
+ ApplicationManager& app_mngr,
+ const smart_objects::SmartObject& video_params));
MOCK_METHOD2(SendNaviStartStream,
void(int32_t connection_key, ApplicationManager& app_mngr));
MOCK_METHOD2(SendNaviStopStream,
@@ -109,7 +113,14 @@ class MockMessageHelper {
uint32_t correlation_id,
ApplicationManager& app_mngr));
MOCK_METHOD1(SendGetSystemInfoRequest, void(ApplicationManager& app_mngr));
-
+ MOCK_METHOD4(SendActivateAppToHMI,
+ void(uint32_t const app_id,
+ ApplicationManager& application_manager,
+ hmi_apis::Common_HMILevel::eType level,
+ bool send_policy_priority));
+ MOCK_METHOD2(SendHMIStatusNotification,
+ void(const Application& application_impl,
+ ApplicationManager& application_manager));
MOCK_METHOD4(SendPolicyUpdate,
void(const std::string& file_path,
const uint32_t timeout,
diff --git a/src/components/application_manager/test/message_helper/CMakeLists.txt b/src/components/application_manager/test/message_helper/CMakeLists.txt
index d115ad8b40..e4a77aa00a 100755
--- a/src/components/application_manager/test/message_helper/CMakeLists.txt
+++ b/src/components/application_manager/test/message_helper/CMakeLists.txt
@@ -47,6 +47,13 @@ set(LIBRARIES
Utils
)
+if(REMOTE_CONTROL)
+ SET (LIBRARIES
+ ${LIBRARIES}
+ FunctionalModule
+ )
+endif(REMOTE_CONTROL)
+
set(SOURCES
${COMPONENTS_DIR}/application_manager/test/message_helper/message_helper_test.cc
)
diff --git a/src/components/application_manager/test/message_helper/message_helper_test.cc b/src/components/application_manager/test/message_helper/message_helper_test.cc
index 94ab511dc4..289e4f5d05 100644
--- a/src/components/application_manager/test/message_helper/message_helper_test.cc
+++ b/src/components/application_manager/test/message_helper/message_helper_test.cc
@@ -96,7 +96,8 @@ TEST(MessageHelperTestCreate,
obj[strings::params][strings::correlation_id].asUInt());
EXPECT_EQ(connection_key,
obj[strings::params][strings::connection_key].asUInt());
- EXPECT_EQ(kV2, obj[strings::params][strings::protocol_version].asInt());
+ EXPECT_EQ(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_2,
+ obj[strings::params][strings::protocol_version].asInt());
}
TEST(MessageHelperTestCreate, CreateSetAppIcon_SendNullPathImagetype_Equal) {
@@ -448,7 +449,9 @@ class MessageHelperTest : public ::testing::Test {
"RU-RU", "TR-TR", "PL-PL", "FR-FR", "IT-IT", "SV-SE",
"PT-PT", "NL-NL", "EN-AU", "ZH-CN", "ZH-TW", "JA-JP",
"AR-SA", "KO-KR", "PT-BR", "CS-CZ", "DA-DK", "NO-NO",
- "NL-BE", "EL-GR", "HU-HU", "FI-FI", "SK-SK"}
+ "NL-BE", "EL-GR", "HU-HU", "FI-FI", "SK-SK", "EN-IN",
+ "TH-TH", "EN-SA", "HE-IL", "RO-RO", "UK-UA", "ID-ID",
+ "VI-VN", "MS-MY", "HI-IN"}
, hmi_result_strings{"SUCCESS",
"UNSUPPORTED_REQUEST",
"UNSUPPORTED_RESOURCE",
@@ -1025,6 +1028,39 @@ TEST_F(MessageHelperTest,
std::find(status_array->begin(), status_array->end(), item_2_so));
}
#endif
+
+TEST_F(MessageHelperTest, SendNaviSetVideoConfigRequest) {
+ smart_objects::SmartObjectSPtr result;
+ EXPECT_CALL(mock_application_manager, ManageHMICommand(_))
+ .WillOnce(DoAll(SaveArg<0>(&result), Return(true)));
+
+ int32_t app_id = 123;
+ smart_objects::SmartObject video_params(smart_objects::SmartType_Map);
+ video_params[strings::protocol] =
+ hmi_apis::Common_VideoStreamingProtocol::RTP;
+ video_params[strings::codec] = hmi_apis::Common_VideoStreamingCodec::H264;
+ video_params[strings::width] = 640;
+ video_params[strings::height] = 480;
+
+ MessageHelper::SendNaviSetVideoConfig(
+ app_id, mock_application_manager, video_params);
+
+ EXPECT_EQ(hmi_apis::FunctionID::Navigation_SetVideoConfig,
+ (*result)[strings::params][strings::function_id].asInt());
+
+ smart_objects::SmartObject& msg_params = (*result)[strings::msg_params];
+ EXPECT_TRUE(msg_params.keyExists(strings::config));
+
+ EXPECT_TRUE(msg_params[strings::config].keyExists(strings::protocol));
+ EXPECT_EQ(1, msg_params[strings::config][strings::protocol].asInt());
+ EXPECT_TRUE(msg_params[strings::config].keyExists(strings::codec));
+ EXPECT_EQ(0, msg_params[strings::config][strings::codec].asInt());
+ EXPECT_TRUE(msg_params[strings::config].keyExists(strings::width));
+ EXPECT_EQ(640, msg_params[strings::config][strings::width].asInt());
+ EXPECT_TRUE(msg_params[strings::config].keyExists(strings::height));
+ EXPECT_EQ(480, msg_params[strings::config][strings::height].asInt());
+}
+
} // namespace application_manager_test
} // namespace components
} // namespace test
diff --git a/src/components/application_manager/test/mobile_message_handler_test.cc b/src/components/application_manager/test/mobile_message_handler_test.cc
index 07b523c56e..3f2ba0a3c5 100644
--- a/src/components/application_manager/test/mobile_message_handler_test.cc
+++ b/src/components/application_manager/test/mobile_message_handler_test.cc
@@ -53,7 +53,7 @@ using protocol_handler::ServiceType;
using protocol_handler::MessagePriority;
using protocol_handler::PROTOCOL_HEADER_V2_SIZE;
using application_manager::MobileMessageHandler;
-using application_manager::ProtocolVersion;
+using protocol_handler::MajorProtocolVersion;
using ::testing::_;
using ::application_manager::Message;
using ::application_manager::MobileMessage;
@@ -176,7 +176,7 @@ class MobileMessageHandlerTest : public testing::Test {
message->set_correlation_id(correlation_id);
message->set_connection_key(connection_key);
message->set_protocol_version(
- static_cast<ProtocolVersion>(protocol_version));
+ static_cast<protocol_handler::MajorProtocolVersion>(protocol_version));
message->set_message_type(application_manager::MessageType::kNotification);
if (data) {
message->set_binary_data(data);
@@ -270,7 +270,7 @@ TEST_F(
size_t payload_size = data.size();
std::srand(time(0));
// Generate unknown random protocol version except 1-3
- uint32_t protocol_version = 4 + rand() % UINT32_MAX;
+ uint32_t protocol_version = 5 + rand() % UINT32_MAX;
Message* message =
HandleIncomingMessage(protocol_version, data, payload_size);
@@ -288,7 +288,7 @@ TEST_F(
const uint32_t correlation_id = 92u;
const uint32_t connection_key = 1u;
// Generate unknown random protocol version except 1-3
- uint32_t protocol_version = 4 + rand() % UINT32_MAX;
+ uint32_t protocol_version = 5 + rand() % UINT32_MAX;
MobileMessage message_to_send = CreateMessageForSending(
protocol_version, function_id, correlation_id, connection_key, data);
diff --git a/src/components/application_manager/test/mobile_message_handler_v1_test.cc b/src/components/application_manager/test/mobile_message_handler_v1_test.cc
index f5a6e7833d..a19ea991b9 100644
--- a/src/components/application_manager/test/mobile_message_handler_v1_test.cc
+++ b/src/components/application_manager/test/mobile_message_handler_v1_test.cc
@@ -111,7 +111,8 @@ TEST(MobileMessageHandlerTestV1Test,
utils::MakeShared<application_manager::Message>(
protocol_handler::MessagePriority::kDefault);
- message->set_protocol_version(application_manager::ProtocolVersion::kV1);
+ message->set_protocol_version(
+ protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_1);
message->set_json_message(data_json);
message->set_connection_key(connection_key_p1);
@@ -121,7 +122,8 @@ TEST(MobileMessageHandlerTestV1Test,
ASSERT_TRUE(ptr);
EXPECT_EQ(connection_key, ptr->connection_key());
- EXPECT_EQ(static_cast<uint32_t>(application_manager::ProtocolVersion::kV1),
+ EXPECT_EQ(static_cast<uint32_t>(
+ protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_1),
ptr->protocol_version());
}
diff --git a/src/components/application_manager/test/mock_message_helper.cc b/src/components/application_manager/test/mock_message_helper.cc
index 01ce9cb066..5f221a105b 100644
--- a/src/components/application_manager/test/mock_message_helper.cc
+++ b/src/components/application_manager/test/mock_message_helper.cc
@@ -33,6 +33,8 @@
#include "application_manager/message_helper.h"
#include "application_manager/mock_message_helper.h"
#include "application_manager/policies/policy_handler_interface.h"
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
namespace application_manager {
@@ -41,6 +43,13 @@ void MessageHelper::SendHashUpdateNotification(uint32_t const app_id,
MockMessageHelper::message_helper_mock()->SendHashUpdateNotification(
app_id, app_mngr);
}
+void MessageHelper::SendNaviSetVideoConfig(
+ int32_t app_id,
+ ApplicationManager& app_mngr,
+ const smart_objects::SmartObject& video_params) {
+ MockMessageHelper::message_helper_mock()->SendNaviSetVideoConfig(
+ app_id, app_mngr, video_params);
+}
void MessageHelper::SendNaviStartStream(int32_t connection_key,
ApplicationManager& app_mngr) {
MockMessageHelper::message_helper_mock()->SendNaviStartStream(connection_key,
@@ -220,6 +229,25 @@ void MessageHelper::SendPolicyUpdate(const std::string& file_path,
file_path, timeout, retries, app_mngr);
}
+#ifdef SDL_REMOTE_CONTROL
+void MessageHelper::SendActivateAppToHMI(
+ uint32_t const app_id,
+ ApplicationManager& application_manager,
+ hmi_apis::Common_HMILevel::eType level,
+ bool send_policy_priority) {
+ MockMessageHelper::message_helper_mock()->SendActivateAppToHMI(
+ app_id, application_manager, level, send_policy_priority);
+}
+
+void MessageHelper::SendHMIStatusNotification(
+ const Application& application_impl,
+ ApplicationManager& application_manager) {
+ MockMessageHelper::message_helper_mock()->SendHMIStatusNotification(
+ application_impl, application_manager);
+}
+
+#endif // SDL_REMOTE_CONTROL
+
void MessageHelper::SendUpdateSDLResponse(const std::string& result,
uint32_t correlation_id,
ApplicationManager& app_mngr) {
@@ -240,7 +268,7 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateModuleInfoSO(
}
MockMessageHelper* MockMessageHelper::message_helper_mock() {
- static MockMessageHelper message_helper_mock;
+ static ::testing::NiceMock<MockMessageHelper> message_helper_mock;
return &message_helper_mock;
}
void MessageHelper::SendAllOnButtonSubscriptionNotificationsForApp(
diff --git a/src/components/application_manager/test/policy_handler_test.cc b/src/components/application_manager/test/policy_handler_test.cc
index 9713989f81..4c3e882eae 100644
--- a/src/components/application_manager/test/policy_handler_test.cc
+++ b/src/components/application_manager/test/policy_handler_test.cc
@@ -1997,34 +1997,59 @@ TEST_F(PolicyHandlerTest, GetAppIdForSending_ExpectReturnAnyAppInNone) {
EXPECT_EQ(app_in_none_id_1 || app_in_none_id_2, app_id);
}
-TEST_F(PolicyHandlerTest, SendMessageToSDK) {
- // Precondition
+TEST_F(PolicyHandlerTest,
+ SendMessageToSDK_SuitableAppPresent_ExpectedNotificationSending) {
BinaryMessage msg;
const std::string url = "test_url";
EnablePolicyAndPolicyManagerMock();
test_app.insert(mock_app_);
- // Expectations
+
EXPECT_CALL(app_manager_, application(kAppId1_))
.WillRepeatedly(Return(mock_app_));
- EXPECT_CALL(*mock_app_, policy_app_id()).WillOnce(Return(kPolicyAppId_));
+ EXPECT_CALL(*mock_app_, app_id()).WillRepeatedly(Return(kAppId1_));
+ EXPECT_CALL(*mock_app_, policy_app_id())
+ .WillRepeatedly(Return(kPolicyAppId_));
+ EXPECT_CALL(*mock_app_, hmi_level())
+ .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL));
+ EXPECT_CALL(*mock_app_, IsRegistered()).WillRepeatedly(Return(true));
+
+ const connection_handler::DeviceHandle test_device_id = 1u;
+ EXPECT_CALL(*mock_app_, device()).WillRepeatedly(Return(test_device_id));
+ EXPECT_CALL(*mock_policy_manager_, GetUserConsentForDevice(_))
+ .WillOnce(Return(kDeviceAllowed));
// Act
- policy_handler_.last_used_app_ids().push_back(kAppId1_);
EXPECT_CALL(mock_message_helper_,
SendPolicySnapshotNotification(kAppId1_, msg, url, _));
EXPECT_TRUE(policy_handler_.SendMessageToSDK(msg, url));
}
-TEST_F(PolicyHandlerTest, SendMessageToSDK_InavalidApp_UNSUCCESS) {
+TEST_F(PolicyHandlerTest,
+ SendMessageToSDK_NoSuitableApp_ExpectedNotificationNotSent) {
BinaryMessage msg;
const std::string url = "test_url";
EnablePolicyAndPolicyManagerMock();
- utils::SharedPtr<application_manager_test::MockApplication> invalid_app;
- policy_handler_.last_used_app_ids().push_back(kAppId1_);
+ test_app.insert(mock_app_);
EXPECT_CALL(app_manager_, application(kAppId1_))
- .WillOnce(Return(invalid_app));
- EXPECT_CALL(*mock_app_, policy_app_id()).Times(0);
+ .WillRepeatedly(Return(mock_app_));
+ EXPECT_CALL(*mock_app_, app_id()).WillRepeatedly(Return(kAppId1_));
+ EXPECT_CALL(*mock_app_, policy_app_id())
+ .WillRepeatedly(Return(kPolicyAppId_));
+ EXPECT_CALL(*mock_app_, hmi_level())
+ .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_NONE));
+ EXPECT_CALL(*mock_app_, IsRegistered()).WillRepeatedly(Return(true));
+
+ const connection_handler::DeviceHandle test_device_id = 1u;
+ EXPECT_CALL(*mock_app_, device()).WillRepeatedly(Return(test_device_id));
+ EXPECT_CALL(*mock_policy_manager_, GetUserConsentForDevice(_))
+ .WillOnce(Return(kDeviceDisallowed));
+
+ // Expected to get 0 as application id so SDL does not have valid application
+ // with such id
+ EXPECT_CALL(app_manager_, application(0))
+ .WillOnce(Return(
+ utils::SharedPtr<application_manager_test::MockApplication>()));
EXPECT_FALSE(policy_handler_.SendMessageToSDK(msg, url));
}
diff --git a/src/components/application_manager/test/rc_policy_handler_test.cc b/src/components/application_manager/test/rc_policy_handler_test.cc
new file mode 100644
index 0000000000..7faf3e36cb
--- /dev/null
+++ b/src/components/application_manager/test/rc_policy_handler_test.cc
@@ -0,0 +1,400 @@
+/*
+ * 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.
+ */
+
+#include <string>
+#include <vector>
+#include <fstream>
+#include "gmock/gmock.h"
+
+#include "application_manager/policies/policy_handler.h"
+#include "application_manager/policies/delegates/app_permission_delegate.h"
+#include "policy/mock_cache_manager.h"
+#include "application_manager/mock_message_helper.h"
+#include "connection_handler/mock_connection_handler_settings.h"
+#include "policy/policy_types.h"
+#include "policy/access_remote.h"
+#include "json/reader.h"
+#include "json/writer.h"
+#include "json/value.h"
+#include "smart_objects/smart_object.h"
+#include "utils/make_shared.h"
+#include "utils/custom_string.h"
+#include "interfaces/MOBILE_API.h"
+#include "policy/mock_policy_settings.h"
+#include "application_manager/mock_application.h"
+#include "policy/usage_statistics/mock_statistics_manager.h"
+#include "protocol_handler/mock_session_observer.h"
+#include "connection_handler/mock_connection_handler.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/policies/mock_policy_handler_observer.h"
+#include "application_manager/mock_event_dispatcher.h"
+#include "policy/mock_policy_manager.h"
+
+namespace test {
+namespace components {
+namespace rc_policy_handler_test {
+
+using namespace application_manager;
+using namespace policy;
+using namespace utils::custom_string;
+using testing::_;
+using ::testing::Mock;
+using ::testing::Return;
+using ::testing::ReturnRef;
+using ::testing::NiceMock;
+using ::testing::DoAll;
+using ::testing::SetArgPointee;
+
+class RCPolicyHandlerTest : public ::testing::Test {
+ public:
+ RCPolicyHandlerTest()
+ : policy_handler_(policy_settings_, app_manager_)
+ , kPolicyAppId_("fake_app_id")
+ , kMacAddr_("kMacAddr_ess")
+ , kDeviceId_("fake_device_id")
+ , kHmiLevel_("NONE")
+ , default_hmi_("fake_hmi")
+ , app_set(test_app, app_lock)
+ , kAppId1_(10u)
+ , kAppId2_(11u)
+ , kConnectionKey_(1u)
+ , kCorrelationKey_(2u)
+ , kUrl_("test_url")
+ , mock_message_helper_(*MockMessageHelper::message_helper_mock()) {}
+
+ protected:
+ NiceMock<policy_handler_test::MockPolicySettings> policy_settings_;
+ utils::SharedPtr<application_manager_test::MockApplication> mock_app_;
+ connection_handler_test::MockConnectionHandler conn_handler;
+ protocol_handler_test::MockSessionObserver mock_session_observer;
+ components::usage_statistics_test::MockStatisticsManager
+ mock_statistics_manager_;
+ PolicyHandler policy_handler_;
+ utils::SharedPtr<policy_manager_test::MockPolicyManager> mock_policy_manager_;
+ application_manager_test::MockApplicationManager app_manager_;
+ const std::string kPolicyAppId_;
+ const std::string kMacAddr_;
+ const std::string kDeviceId_;
+ const std::string kHmiLevel_;
+ std::string default_hmi_;
+ ApplicationSet test_app;
+ sync_primitives::Lock app_lock;
+ DataAccessor<ApplicationSet> app_set;
+ const uint32_t kAppId1_;
+ const uint32_t kAppId2_;
+ const uint32_t kConnectionKey_;
+ const uint32_t kCorrelationKey_;
+ const std::string kUrl_;
+ application_manager::MockMessageHelper& mock_message_helper_;
+
+ virtual void SetUp() OVERRIDE {
+ Mock::VerifyAndClearExpectations(&mock_message_helper_);
+ ON_CALL(app_manager_, applications()).WillByDefault(Return(app_set));
+ ON_CALL(policy_settings_, enable_policy()).WillByDefault(Return(true));
+ mock_policy_manager_ =
+ utils::MakeShared<policy_manager_test::MockPolicyManager>();
+ ASSERT_TRUE(mock_policy_manager_.valid());
+
+ ON_CALL(app_manager_, connection_handler())
+ .WillByDefault(ReturnRef(conn_handler));
+ ON_CALL(conn_handler, get_session_observer())
+ .WillByDefault(ReturnRef(mock_session_observer));
+
+ mock_app_ = utils::MakeShared<application_manager_test::MockApplication>();
+ }
+
+ virtual void TearDown() OVERRIDE {
+ Mock::VerifyAndClearExpectations(&mock_message_helper_);
+ }
+
+ void ChangePolicyManagerToMock() {
+ policy_handler_.SetPolicyManager(mock_policy_manager_);
+ }
+
+ void EnablePolicy() {
+ ON_CALL(policy_settings_, enable_policy()).WillByDefault(Return(true));
+ }
+
+ void EnablePolicyAndPolicyManagerMock() {
+ EnablePolicy();
+ ChangePolicyManagerToMock();
+ }
+};
+
+TEST_F(RCPolicyHandlerTest,
+ SendMessageToSDK_RemoteControlInvalidMobileAppId_UNSUCCESS) {
+ // Precondition
+ BinaryMessage msg;
+ EnablePolicyAndPolicyManagerMock();
+
+ EXPECT_CALL(app_manager_, applications()).WillOnce(Return(app_set));
+ test_app.insert(mock_app_);
+
+ ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId1_));
+ ON_CALL(*mock_app_, hmi_level())
+ .WillByDefault(Return(mobile_apis::HMILevel::HMI_FULL));
+ EXPECT_CALL(*mock_app_, IsRegistered()).WillOnce(Return(true));
+
+ EXPECT_CALL(app_manager_, application(kAppId1_))
+ .WillRepeatedly(Return(mock_app_));
+ const std::string empty_mobile_app_id("");
+ EXPECT_CALL(*mock_app_, policy_app_id())
+ .WillOnce(Return(empty_mobile_app_id));
+
+ EXPECT_CALL(*mock_policy_manager_, GetUserConsentForDevice(_))
+ .WillOnce(Return(kDeviceAllowed));
+
+ EXPECT_CALL(mock_message_helper_, SendPolicySnapshotNotification(_, _, _, _))
+ .Times(0);
+ EXPECT_FALSE(policy_handler_.SendMessageToSDK(msg, kUrl_));
+}
+
+TEST_F(RCPolicyHandlerTest, SendMessageToSDK_RemoteControl_SUCCESS) {
+ BinaryMessage msg;
+ EnablePolicyAndPolicyManagerMock();
+ EXPECT_CALL(app_manager_, applications()).WillOnce(Return(app_set));
+ test_app.insert(mock_app_);
+
+ ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId1_));
+ ON_CALL(*mock_app_, hmi_level())
+ .WillByDefault(Return(mobile_apis::HMILevel::HMI_FULL));
+ EXPECT_CALL(*mock_app_, IsRegistered()).WillOnce(Return(true));
+
+ EXPECT_CALL(app_manager_, application(kAppId1_))
+ .WillRepeatedly(Return(mock_app_));
+
+ EXPECT_CALL(*mock_app_, policy_app_id()).WillOnce(Return(kPolicyAppId_));
+
+ EXPECT_CALL(*mock_policy_manager_, GetUserConsentForDevice(_))
+ .WillOnce(Return(kDeviceAllowed));
+
+ EXPECT_CALL(mock_message_helper_,
+ SendPolicySnapshotNotification(kAppId1_, _, kUrl_, _));
+ EXPECT_TRUE(policy_handler_.SendMessageToSDK(msg, kUrl_));
+}
+
+TEST_F(RCPolicyHandlerTest, OnUpdateHMILevel_InvalidApp_UNSUCCESS) {
+ EnablePolicyAndPolicyManagerMock();
+
+ utils::SharedPtr<application_manager_test::MockApplication> invalid_app;
+ EXPECT_CALL(app_manager_, application(kDeviceId_, kPolicyAppId_))
+ .WillOnce(Return(invalid_app));
+ EXPECT_CALL(mock_message_helper_, StringToHMILevel(_)).Times(0);
+
+ const std::string hmi_level("HMI_FULL");
+ policy_handler_.OnUpdateHMILevel(kDeviceId_, kPolicyAppId_, hmi_level);
+}
+
+TEST_F(RCPolicyHandlerTest, OnUpdateHMILevel_InvalidHmiLevel_UNSUCCESS) {
+ EnablePolicyAndPolicyManagerMock();
+
+ EXPECT_CALL(app_manager_, application(kDeviceId_, kPolicyAppId_))
+ .WillOnce(Return(mock_app_));
+
+ const std::string hmi_level("INVALID_ENUM");
+ EXPECT_CALL(mock_message_helper_, StringToHMILevel(hmi_level))
+ .WillOnce(Return(mobile_apis::HMILevel::INVALID_ENUM));
+
+ policy_handler_.OnUpdateHMILevel(kDeviceId_, kPolicyAppId_, hmi_level);
+}
+
+TEST_F(RCPolicyHandlerTest, OnUpdateHMILevel_HmiLevelFull_SUCCESS) {
+ EnablePolicyAndPolicyManagerMock();
+
+ EXPECT_CALL(app_manager_, application(kDeviceId_, kPolicyAppId_))
+ .WillOnce(Return(mock_app_));
+
+ const std::string hmi_level("HMI_FULL");
+ EXPECT_CALL(mock_message_helper_, StringToHMILevel(hmi_level))
+ .WillOnce(Return(mobile_apis::HMILevel::HMI_FULL));
+
+ EXPECT_CALL(*mock_app_, hmi_level())
+ .WillOnce(Return(mobile_apis::HMILevel::HMI_NONE));
+ EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId1_));
+ EXPECT_CALL(mock_message_helper_, SendActivateAppToHMI(kAppId1_, _, _, _));
+
+ policy_handler_.OnUpdateHMILevel(kDeviceId_, kPolicyAppId_, hmi_level);
+}
+
+TEST_F(RCPolicyHandlerTest, OnUpdateHMILevel_HmiLevelChanged_SUCCESS) {
+ EnablePolicyAndPolicyManagerMock();
+
+ EXPECT_CALL(app_manager_, application(kDeviceId_, kPolicyAppId_))
+ .WillOnce(Return(mock_app_));
+
+ const std::string hmi_level("HMI_LIMITED");
+ EXPECT_CALL(mock_message_helper_, StringToHMILevel(hmi_level))
+ .WillOnce(Return(mobile_apis::HMILevel::HMI_LIMITED));
+
+ EXPECT_CALL(*mock_app_, hmi_level())
+ .WillOnce(Return(mobile_apis::HMILevel::HMI_NONE));
+ EXPECT_CALL(*mock_app_, app_id()).WillRepeatedly(Return(kAppId1_));
+
+ EXPECT_CALL(app_manager_,
+ ChangeAppsHMILevel(kAppId1_, mobile_apis::HMILevel::HMI_LIMITED));
+
+ EXPECT_CALL(mock_message_helper_, SendHMIStatusNotification(_, _));
+
+ policy_handler_.OnUpdateHMILevel(kDeviceId_, kPolicyAppId_, hmi_level);
+}
+
+TEST_F(RCPolicyHandlerTest, CheckModule_SUCCESS) {
+ EnablePolicyAndPolicyManagerMock();
+
+ const PTString module("module");
+ EXPECT_CALL(*mock_policy_manager_, CheckModule(kPolicyAppId_, module))
+ .WillOnce(Return(true));
+
+ EXPECT_TRUE(policy_handler_.CheckModule(kPolicyAppId_, module));
+}
+
+ACTION_P(SetDeviceHandle, handle) {
+ *arg1 = handle;
+}
+
+TEST_F(RCPolicyHandlerTest,
+ OnRemoteAppPermissionsChanged_DifferentDeviceHandle_SUCCESS) {
+ EnablePolicyAndPolicyManagerMock();
+ EXPECT_CALL(*mock_policy_manager_,
+ SendAppPermissionsChanged(kDeviceId_, kPolicyAppId_));
+
+ policy_handler_.OnRemoteAppPermissionsChanged(kDeviceId_, kPolicyAppId_);
+}
+
+TEST_F(RCPolicyHandlerTest, OnUpdateHMIStatus_InvalidApp_UNSUCCESS) {
+ EnablePolicyAndPolicyManagerMock();
+ utils::SharedPtr<application_manager_test::MockApplication> invalid_app;
+ EXPECT_CALL(app_manager_, application(_, _)).WillOnce(Return(invalid_app));
+ EXPECT_CALL(app_manager_, ChangeAppsHMILevel(_, _)).Times(0);
+
+ const std::string hmi_level("HMI_NONE");
+ policy_handler_.OnUpdateHMIStatus(kDeviceId_, kPolicyAppId_, hmi_level);
+}
+
+TEST_F(RCPolicyHandlerTest, OnUpdateHMIStatus_HmiLevelInvalidEnum_UNSUCCESS) {
+ EnablePolicyAndPolicyManagerMock();
+ EXPECT_CALL(app_manager_, application(kDeviceId_, kPolicyAppId_))
+ .WillOnce(Return(mock_app_));
+
+ const std::string hmi_level("INVALID_ENUM");
+ EXPECT_CALL(mock_message_helper_, StringToHMILevel(hmi_level))
+ .WillOnce(Return(mobile_apis::HMILevel::INVALID_ENUM));
+
+ EXPECT_CALL(app_manager_, ChangeAppsHMILevel(_, _)).Times(0);
+
+ policy_handler_.OnUpdateHMIStatus(kDeviceId_, kPolicyAppId_, hmi_level);
+}
+
+TEST_F(RCPolicyHandlerTest, OnUpdateHMIStatus_ValidAppAndHmiLevel_SUCCESS) {
+ EnablePolicyAndPolicyManagerMock();
+ EXPECT_CALL(app_manager_, application(kDeviceId_, kPolicyAppId_))
+ .WillOnce(Return(mock_app_));
+
+ const std::string hmi_level("HMI_NONE");
+ EXPECT_CALL(mock_message_helper_, StringToHMILevel(hmi_level))
+ .WillOnce(Return(mobile_apis::HMILevel::HMI_NONE));
+
+ EXPECT_CALL(*mock_app_, app_id()).WillRepeatedly(Return(kAppId1_));
+
+ EXPECT_CALL(app_manager_,
+ ChangeAppsHMILevel(kAppId1_, mobile_apis::HMILevel::HMI_NONE));
+ EXPECT_CALL(mock_message_helper_, SendHMIStatusNotification(_, _));
+
+ policy_handler_.OnUpdateHMIStatus(kDeviceId_, kPolicyAppId_, hmi_level);
+}
+
+TEST_F(RCPolicyHandlerTest,
+ OnUpdateHMIStatusFourParams_HmiLevelInvalidEnum_UNSUCCESS) {
+ EnablePolicyAndPolicyManagerMock();
+ EXPECT_CALL(app_manager_, application(kDeviceId_, kPolicyAppId_))
+ .WillOnce(Return(mock_app_));
+
+ const std::string hmi_level("INVALID_ENUM");
+ EXPECT_CALL(mock_message_helper_, StringToHMILevel(hmi_level))
+ .WillOnce(Return(mobile_apis::HMILevel::INVALID_ENUM));
+
+ EXPECT_CALL(app_manager_, ChangeAppsHMILevel(_, _)).Times(0);
+ policy_handler_.OnUpdateHMIStatus(kDeviceId_, kPolicyAppId_, hmi_level);
+}
+
+TEST_F(RCPolicyHandlerTest, OnUpdateHMIStatus_ValidParams_SUCCESS) {
+ EnablePolicyAndPolicyManagerMock();
+ EXPECT_CALL(app_manager_, application(kDeviceId_, kPolicyAppId_))
+ .WillOnce(Return(mock_app_));
+
+ const std::string hmi_level("HMI_NONE");
+ EXPECT_CALL(mock_message_helper_, StringToHMILevel(hmi_level))
+ .WillOnce(Return(mobile_apis::HMILevel::HMI_NONE));
+
+ EXPECT_CALL(*mock_app_, app_id()).WillRepeatedly(Return(kAppId1_));
+ EXPECT_CALL(app_manager_,
+ ChangeAppsHMILevel(kAppId1_, mobile_apis::HMILevel::HMI_NONE));
+ EXPECT_CALL(mock_message_helper_, SendHMIStatusNotification(_, _));
+
+ policy_handler_.OnUpdateHMIStatus(kDeviceId_, kPolicyAppId_, hmi_level);
+}
+
+TEST_F(RCPolicyHandlerTest, GetModuleTypes_GetModuleTypes_SUCCESS) {
+ EnablePolicyAndPolicyManagerMock();
+ std::vector<std::string> modules;
+
+ EXPECT_CALL(*mock_policy_manager_, GetModuleTypes(kPolicyAppId_, &modules))
+ .WillOnce(Return(true));
+
+ EXPECT_TRUE(policy_handler_.GetModuleTypes(kPolicyAppId_, &modules));
+}
+
+TEST_F(RCPolicyHandlerTest, CheckHMIType_ValidTypes_SUCCESS) {
+ EnablePolicyAndPolicyManagerMock();
+ mobile_apis::AppHMIType::eType hmi = mobile_apis::AppHMIType::MEDIA;
+
+ const smart_objects::SmartObjectSPtr app_types =
+ utils::MakeShared<smart_objects::SmartObject>(
+ smart_objects::SmartType_Array);
+ (*app_types)[strings::app_hmi_type][0] = mobile_apis::AppHMIType::MEDIA;
+ (*app_types)[strings::app_hmi_type][1] =
+ mobile_apis::AppHMIType::BACKGROUND_PROCESS;
+
+ std::vector<int> policy_hmi_types;
+ policy_hmi_types.push_back(mobile_apis::AppHMIType::MEDIA);
+ policy_hmi_types.push_back(mobile_apis::AppHMIType::BACKGROUND_PROCESS);
+
+ EXPECT_CALL(*mock_policy_manager_, GetHMITypes(kPolicyAppId_, _))
+ .WillOnce(DoAll(SetArgPointee<1>(policy_hmi_types), Return(true)));
+
+ EXPECT_TRUE(policy_handler_.CheckHMIType(
+ kPolicyAppId_, hmi, &(*app_types.get())[strings::app_hmi_type]));
+}
+
+} // namespace rc_policy_handler_test
+} // namespace components
+} // namespace test
diff --git a/src/components/config_profile/include/config_profile/profile.h b/src/components/config_profile/include/config_profile/profile.h
index 1302643f31..ac4950220e 100644
--- a/src/components/config_profile/include/config_profile/profile.h
+++ b/src/components/config_profile/include/config_profile/profile.h
@@ -111,6 +111,7 @@ class Profile : public protocol_handler::ProtocolHandlerSettings,
/**
* @brief Returns true, if SDL 4.0 is enabled
*/
+ // DEPRECATED, use max_supported_protocol_version instead
bool enable_protocol_4() const OVERRIDE;
/**
@@ -130,6 +131,26 @@ class Profile : public protocol_handler::ProtocolHandlerSettings,
const uint32_t& app_icons_amount_to_remove() const OVERRIDE;
/**
+ * @brief Returns the maximum payload size for control services
+ */
+ size_t maximum_control_payload_size() const OVERRIDE;
+
+ /**
+ * @brief Returns the maximum payload size for RPC services
+ */
+ size_t maximum_rpc_payload_size() const OVERRIDE;
+
+ /**
+ * @brief Returns the maximum payload size for audio services
+ */
+ size_t maximum_audio_payload_size() const OVERRIDE;
+
+ /**
+ * @brief Returns the maximum payload size for video services
+ */
+ size_t maximum_video_payload_size() const OVERRIDE;
+
+ /**
* @brief Returns the path to the config file
*/
const std::string& config_file_name() const;
@@ -155,9 +176,9 @@ class Profile : public protocol_handler::ProtocolHandlerSettings,
const uint16_t video_streaming_port() const OVERRIDE;
/**
- * @brief Returns port for audio streaming
- */
- const uint16_t audio_streaming_port() const;
+ * @brief Returns port for audio streaming
+ */
+ const uint16_t audio_streaming_port() const OVERRIDE;
/**
* @brief Returns streaming timeout
@@ -191,6 +212,11 @@ class Profile : public protocol_handler::ProtocolHandlerSettings,
const std::vector<std::string>& vr_commands() const;
/**
+ * @brief Returns folder containing all plugins
+ */
+ const std::string& plugins_folder() const OVERRIDE;
+
+ /**
* @brief Maximum command id available for mobile app
*/
const uint32_t& max_cmd_id() const;
@@ -209,7 +235,7 @@ class Profile : public protocol_handler::ProtocolHandlerSettings,
/**
* @brief Returns desirable thread stack size
*/
- const uint64_t& thread_min_stack_size() const;
+ const uint64_t thread_min_stack_size() const;
/**
* @brief Returns true if audio mixing is supported
@@ -344,10 +370,19 @@ class Profile : public protocol_handler::ProtocolHandlerSettings,
// TransportManageSettings interface
+ /*
+ * @brief Returns true if last state singleton is used
+ */
bool use_last_state() const OVERRIDE;
+ /**
+ * @brief Timeout in transport manager before disconnect
+ */
uint32_t transport_manager_disconnect_timeout() const OVERRIDE;
+ /**
+ * @brief Returns port for TCP transport adapter
+ */
uint16_t transport_manager_tcp_adapter_port() const OVERRIDE;
// TransportManageMMESettings interface
@@ -759,10 +794,13 @@ class Profile : public protocol_handler::ProtocolHandlerSettings,
std::string app_config_folder_;
std::string app_storage_folder_;
std::string app_resource_folder_;
- bool enable_protocol_4_;
std::string app_icons_folder_;
uint32_t app_icons_folder_max_size_;
uint32_t app_icons_amount_to_remove_;
+ size_t maximum_control_payload_size_;
+ size_t maximum_rpc_payload_size_;
+ size_t maximum_audio_payload_size_;
+ size_t maximum_video_payload_size_;
std::string config_file_name_;
std::string server_address_;
uint16_t server_port_;
@@ -856,6 +894,7 @@ class Profile : public protocol_handler::ProtocolHandlerSettings,
std::string iap_pool_protocol_mask_;
std::string iap_system_config_;
std::string iap2_system_config_;
+ std::string plugins_folder_;
int iap2_hub_connect_attempts_;
int iap_hub_connection_wait_timeout_;
uint16_t tts_global_properties_timeout_;
diff --git a/src/components/config_profile/src/ini_file.cc b/src/components/config_profile/src/ini_file.cc
index 1c30c8b201..3245b096cb 100644
--- a/src/components/config_profile/src/ini_file.cc
+++ b/src/components/config_profile/src/ini_file.cc
@@ -39,6 +39,8 @@
#include <limits.h>
#include <stdint.h>
+#include "utils/logger.h"
+
#ifndef _WIN32
#include <unistd.h>
#else
@@ -53,6 +55,8 @@
namespace profile {
+CREATE_LOGGERPTR_GLOBAL(logger_, "Profile")
+
char* ini_write_inst(const char* fname, uint8_t flag) {
FILE* fp = 0;
@@ -272,9 +276,11 @@ char ini_write_value(const char* fname,
fclose(wr_fp);
fclose(rd_fp);
- remove(fname);
if (0 != rename(temp_fname, fname)) {
- remove(temp_fname);
+ if (0 != remove(temp_fname)) {
+ LOG4CXX_WARN_WITH_ERRNO(
+ logger_, "Unable to remove temp file: " << std::string(temp_fname));
+ }
return FALSE;
}
diff --git a/src/components/config_profile/src/profile.cc b/src/components/config_profile/src/profile.cc
index 0871a769ba..6389375bb8 100644
--- a/src/components/config_profile/src/profile.cc
+++ b/src/components/config_profile/src/profile.cc
@@ -85,6 +85,7 @@ const char* kFilesystemRestrictionsSection = "FILESYSTEM RESTRICTIONS";
const char* kIAPSection = "IAP";
const char* kProtocolHandlerSection = "ProtocolHandler";
const char* kSDL4Section = "SDL4";
+const char* kSDL5Section = "SDL5";
const char* kResumptionSection = "Resumption";
const char* kAppLaunchSection = "AppLaunch";
@@ -100,10 +101,13 @@ const char* kAppStorageFolderKey = "AppStorageFolder";
const char* kAppResourseFolderKey = "AppResourceFolder";
const char* kLogsEnabledKey = "LogsEnabled";
const char* kAppConfigFolderKey = "AppConfigFolder";
-const char* kEnableProtocol4Key = "EnableProtocol4";
const char* kAppIconsFolderKey = "AppIconsFolder";
const char* kAppIconsFolderMaxSizeKey = "AppIconsFolderMaxSize";
const char* kAppIconsAmountToRemoveKey = "AppIconsAmountToRemove";
+const char* kMaximumControlPayloadSizeKey = "MaximumControlPayloadSize";
+const char* kMaximumRpcPayloadSizeKey = "MaximumRpcPayloadSize";
+const char* kMaximumAudioPayloadSizeKey = "MaximumAudioPayloadSize";
+const char* kMaximumVideoPayloadSizeKey = "MaximumVideoPayloadSize";
const char* kLaunchHMIKey = "LaunchHMI";
const char* kDefaultSDLVersion = "";
#ifdef WEB_HMI
@@ -137,6 +141,7 @@ const char* kTimeoutPromptKey = "TimeOutPromt";
const char* kHelpTitleKey = "HelpTitle";
const char* kHelpCommandKey = "HelpCommand";
const char* kSystemFilesPathKey = "SystemFilesPath";
+const char* kPluginsFolderKey = "PluginFolder";
const char* kHeartBeatTimeoutKey = "HeartBeatTimeout";
const char* kMaxSupportedProtocolVersionKey = "MaxSupportedProtocolVersion";
const char* kUseLastStateKey = "UseLastState";
@@ -215,6 +220,7 @@ const char* kDefaultPreloadedPTFileName = "sdl_preloaded_pt.json";
const char* kDefaultServerAddress = "127.0.0.1";
const char* kDefaultAppInfoFileName = "app_info.dat";
const char* kDefaultSystemFilesPath = "/tmp/fs/mp/images/ivsu_cache";
+const char* kDefaultPluginsPath = "plugins";
const char* kDefaultTtsDelimiter = ",";
const uint32_t kDefaultAudioDataStoppedTimeout = 1000;
const uint32_t kDefaultVideoDataStoppedTimeout = 1000;
@@ -238,7 +244,7 @@ const uint32_t kDefaultBeforeUpdateHours = 24;
const uint32_t kDefaultHubProtocolIndex = 0;
const uint32_t kDefaultHeartBeatTimeout = 0;
-const uint16_t kDefaultMaxSupportedProtocolVersion = 3;
+const uint16_t kDefaultMaxSupportedProtocolVersion = 5;
const uint16_t kDefautTransportManagerTCPPort = 12345;
const uint16_t kDefaultServerPort = 8087;
const uint16_t kDefaultVideoStreamingPort = 5050;
@@ -286,6 +292,10 @@ const uint16_t kDefaultOpenAttemptTimeoutMs = 500;
const uint32_t kDefaultAppIconsFolderMaxSize = 104857600;
const uint32_t kDefaultAppIconsAmountToRemove = 1;
const uint16_t kDefaultAttemptsToOpenResumptionDB = 5;
+const size_t kDefaultMaximumControlPayloadSize = 0;
+const size_t kDefaultMaximumRpcPayloadSize = 0;
+const size_t kDefaultMaximumAudioPayloadSize = 0;
+const size_t kDefaultMaximumVideoPayloadSize = 0;
const uint16_t kDefaultOpenAttemptTimeoutMsResumptionDB = 500;
const uint16_t kDefaultAppLaunchWaitTime = 5000;
const uint16_t kDefaultAppLaunchMaxRetryAttempt = 3;
@@ -313,15 +323,19 @@ Profile::Profile()
app_config_folder_()
, app_storage_folder_()
, app_resource_folder_()
- , enable_protocol_4_(false)
, app_icons_folder_()
, app_icons_folder_max_size_(kDefaultAppIconsFolderMaxSize)
, app_icons_amount_to_remove_(kDefaultAppIconsAmountToRemove)
+ , maximum_control_payload_size_(kDefaultMaximumControlPayloadSize)
+ , maximum_rpc_payload_size_(kDefaultMaximumRpcPayloadSize)
+ , maximum_audio_payload_size_(kDefaultMaximumAudioPayloadSize)
+ , maximum_video_payload_size_(kDefaultMaximumVideoPayloadSize)
, config_file_name_(kDefaultConfigFileName)
, server_address_(kDefaultServerAddress)
, server_port_(kDefaultServerPort)
, video_streaming_port_(kDefaultVideoStreamingPort)
, audio_streaming_port_(kDefaultAudioStreamingPort)
+ , stop_streaming_timeout_(kDefaultStopStreamingTimeout)
, time_testing_port_(kDefaultTimeTestingPort)
, hmi_capabilities_file_name_(kDefaultHmiCapabilitiesFileName)
, help_prompt_()
@@ -332,6 +346,8 @@ Profile::Profile()
, max_cmd_id_(kDefaultMaxCmdId)
, default_timeout_(kDefaultTimeout)
, app_resuming_timeout_(kDefaultAppResumingTimeout)
+ , app_resumption_save_persistent_data_timeout_(
+ kDefaultAppSavePersistentDataTimeout)
, app_dir_quota_(kDefaultDirQuota)
, app_hmi_level_none_time_scale_max_requests_(
kDefaultAppHmiLevelNoneTimeScaleMaxRequests)
@@ -363,6 +379,8 @@ Profile::Profile()
, recording_file_source_(kDefaultRecordingFileSourceName)
, recording_file_name_(kDefaultRecordingFileName)
, application_list_update_timeout_(kDefaultApplicationListUpdateTimeout)
+ , max_thread_pool_size_(kDefaultMaxThreadPoolSize)
+ , default_hub_protocol_index_(kDefaultHubProtocolIndex)
, iap_legacy_protocol_mask_(kDefaultLegacyProtocolMask)
, iap_hub_protocol_mask_(kDefaultHubProtocolMask)
, iap_pool_protocol_mask_(kDefaultPoolProtocolMask)
@@ -373,6 +391,8 @@ Profile::Profile()
, tts_global_properties_timeout_(kDefaultTTSGlobalPropertiesTimeout)
, attempts_to_open_policy_db_(kDefaultAttemptsToOpenPolicyDB)
, open_attempt_timeout_ms_(kDefaultAttemptsToOpenPolicyDB)
+ , resumption_delay_before_ign_(kDefaultResumptionDelayBeforeIgn)
+ , resumption_delay_after_ign_(kDefaultResumptionDelayAfterIgn)
, hash_string_size_(kDefaultHashStringSize)
, use_db_for_resumption_(false)
, attempts_to_open_resumption_db_(kDefaultAttemptsToOpenResumptionDB)
@@ -432,7 +452,7 @@ const std::string& Profile::app_resource_folder() const {
}
bool Profile::enable_protocol_4() const {
- return enable_protocol_4_;
+ return max_supported_protocol_version_ >= 4;
}
const std::string& Profile::app_icons_folder() const {
@@ -447,6 +467,22 @@ const uint32_t& Profile::app_icons_amount_to_remove() const {
return app_icons_amount_to_remove_;
}
+size_t Profile::maximum_control_payload_size() const {
+ return maximum_control_payload_size_;
+}
+
+size_t Profile::maximum_rpc_payload_size() const {
+ return maximum_rpc_payload_size_;
+}
+
+size_t Profile::maximum_audio_payload_size() const {
+ return maximum_audio_payload_size_;
+}
+
+size_t Profile::maximum_video_payload_size() const {
+ return maximum_video_payload_size_;
+}
+
const std::string& Profile::hmi_capabilities_file_name() const {
return hmi_capabilities_file_name_;
}
@@ -507,7 +543,7 @@ const uint16_t& Profile::time_testing_port() const {
return time_testing_port_;
}
-const uint64_t& Profile::thread_min_stack_size() const {
+const uint64_t Profile::thread_min_stack_size() const {
return min_tread_stack_size_;
}
@@ -627,6 +663,9 @@ const std::string& Profile::system_files_path() const {
return system_files_path_;
}
+const std::string& Profile::plugins_folder() const {
+ return plugins_folder_;
+}
const std::vector<uint32_t>& Profile::supported_diag_modes() const {
return supported_diag_modes_;
}
@@ -1001,17 +1040,6 @@ void Profile::UpdateValues() {
LOG_UPDATED_VALUE(app_resource_folder_, kAppResourseFolderKey, kMainSection);
- // Enable protocol ver.4 parameter
- std::string enable_protocol_4_value;
- if (ReadValue(&enable_protocol_4_value, kSDL4Section, kEnableProtocol4Key) &&
- 0 == strcmp("true", enable_protocol_4_value.c_str())) {
- enable_protocol_4_ = true;
- } else {
- enable_protocol_4_ = false;
- }
-
- LOG_UPDATED_BOOL_VALUE(enable_protocol_4_, kEnableProtocol4Key, kSDL4Section);
-
// Application icon folder
ReadStringValue(&app_icons_folder_,
file_system::CurrentWorkingDirectory().c_str(),
@@ -1046,6 +1074,39 @@ void Profile::UpdateValues() {
LOG_UPDATED_VALUE(
app_icons_amount_to_remove_, kAppIconsAmountToRemoveKey, kSDL4Section);
+ ReadUIntValue(&maximum_control_payload_size_,
+ kDefaultMaximumControlPayloadSize,
+ kSDL5Section,
+ kMaximumControlPayloadSizeKey);
+
+ LOG_UPDATED_VALUE(maximum_control_payload_size_,
+ kMaximumControlPayloadSizeKey,
+ kSDL5Section);
+
+ ReadUIntValue(&maximum_rpc_payload_size_,
+ kDefaultMaximumRpcPayloadSize,
+ kSDL5Section,
+ kMaximumRpcPayloadSizeKey);
+
+ LOG_UPDATED_VALUE(
+ maximum_rpc_payload_size_, kMaximumRpcPayloadSizeKey, kSDL5Section);
+
+ ReadUIntValue(&maximum_audio_payload_size_,
+ kDefaultMaximumAudioPayloadSize,
+ kSDL5Section,
+ kMaximumAudioPayloadSizeKey);
+
+ LOG_UPDATED_VALUE(
+ maximum_audio_payload_size_, kMaximumAudioPayloadSizeKey, kSDL5Section);
+
+ ReadUIntValue(&maximum_video_payload_size_,
+ kDefaultMaximumVideoPayloadSize,
+ kSDL5Section,
+ kMaximumVideoPayloadSizeKey);
+
+ LOG_UPDATED_VALUE(
+ maximum_video_payload_size_, kMaximumVideoPayloadSizeKey, kSDL5Section);
+
// Application info file name
ReadStringValue(&app_info_storage_,
kDefaultAppInfoFileName,
@@ -1500,6 +1561,10 @@ void Profile::UpdateValues() {
LOG_UPDATED_VALUE(system_files_path_, kSystemFilesPathKey, kMainSection);
+ // Plugins folder
+ ReadStringValue(
+ &plugins_folder_, kDefaultPluginsPath, kMainSection, kPluginsFolderKey);
+ LOG_UPDATED_VALUE(plugins_folder_, kPluginsFolderKey, kMainSection);
// Heartbeat timeout
ReadUIntValue(&heart_beat_timeout_,
kDefaultHeartBeatTimeout,
@@ -1626,10 +1691,11 @@ void Profile::UpdateValues() {
kProtocolHandlerSection,
kMaxSupportedProtocolVersionKey);
- // if .ini file contains protocol version less than 2 or more than 3
- // max_supported_protocol_version_ = 3
- if (max_supported_protocol_version_ < 2) {
- max_supported_protocol_version_ = 3;
+ if (max_supported_protocol_version_ < 1) {
+ max_supported_protocol_version_ = 1;
+ } else if (max_supported_protocol_version_ >
+ kDefaultMaxSupportedProtocolVersion) {
+ max_supported_protocol_version_ = kDefaultMaxSupportedProtocolVersion;
}
LOG_UPDATED_BOOL_VALUE(enable_policy_, kEnablePolicy, kPolicySection);
diff --git a/src/components/connection_handler/include/connection_handler/connection.h b/src/components/connection_handler/include/connection_handler/connection.h
index aafc562505..bd5858c4cd 100644
--- a/src/components/connection_handler/include/connection_handler/connection.h
+++ b/src/components/connection_handler/include/connection_handler/connection.h
@@ -41,6 +41,7 @@
#include "connection_handler/device.h"
#include "connection_handler/heartbeat_monitor.h"
#include "protocol/service_type.h"
+#include "protocol_handler/protocol_packet.h"
#ifdef ENABLE_SECURITY
namespace security_manager {
@@ -95,6 +96,7 @@ struct Session {
#endif // ENABLE_SECURITY
Session()
: service_list()
+ , protocol_version(::protocol_handler::PROTOCOL_VERSION_2)
#ifdef ENABLE_SECURITY
, ssl_context(NULL)
#endif // ENABLE_SECURITY
diff --git a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h
index cd8aec0ff3..aebc612a22 100644
--- a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h
+++ b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h
@@ -49,6 +49,7 @@
#include "utils/logger.h"
#include "utils/macro.h"
+#include "utils/message_queue.h"
#include "utils/lock.h"
#include "utils/stl_utils.h"
#include "utils/rwlock.h"
@@ -182,6 +183,7 @@ class ConnectionHandlerImpl
* \param hash_id pointer for session hash identifier
* \return uint32_t Id (number) of new session if successful, otherwise 0.
*/
+ // DEPRECATED
virtual uint32_t OnSessionStartedCallback(
const transport_manager::ConnectionUID connection_handle,
const uint8_t session_id,
@@ -191,18 +193,43 @@ class ConnectionHandlerImpl
/**
* \brief Callback function used by ProtocolHandler
+ * when Mobile Application initiates start of new session.
+ * Result must be notified through NotifySessionStartedResult().
+ * \param connection_handle Connection identifier within which session
+ * has to be started.
+ * \param sessionId Identifier of the session to be start
+ * \param service_type Type of service
+ * \param protocol_version Version of protocol
+ * \param is_protected would be service protected
+ * \param params configuration parameters specified by mobile
+ */
+ virtual void OnSessionStartedCallback(
+ const transport_manager::ConnectionUID connection_handle,
+ const uint8_t session_id,
+ const protocol_handler::ServiceType& service_type,
+ const bool is_protected,
+ const BsonObject* params);
+
+ // DEPRECATED
+ uint32_t OnSessionEndedCallback(
+ const transport_manager::ConnectionUID connection_handle,
+ const uint8_t session_id,
+ const uint32_t& hashCode,
+ const protocol_handler::ServiceType& service_type) OVERRIDE;
+ /**
+ * \brief Callback function used by ProtocolHandler
* when Mobile Application initiates session ending.
* \param connection_handle Connection identifier within which session exists
* \param sessionId Identifier of the session to be ended
* \param hashCode Hash used only in second version of SmartDeviceLink
- * protocol.
+ * protocol. (Set to HASH_ID_WRONG if the hash is incorrect)
* If not equal to hash assigned to session on start then operation fails.
* \return uint32_t 0 if operation fails, session key otherwise
*/
uint32_t OnSessionEndedCallback(
const transport_manager::ConnectionUID connection_handle,
const uint8_t session_id,
- const uint32_t& hashCode,
+ uint32_t* hashCode,
const protocol_handler::ServiceType& service_type) OVERRIDE;
/**
@@ -435,8 +462,72 @@ class ConnectionHandlerImpl
const protocol_handler::SessionObserver& get_session_observer();
DevicesDiscoveryStarter& get_device_discovery_starter();
+ /**
+ * \brief Invoked when observer's OnServiceStartedCallback is completed
+ * \param session_key the key of started session passed to
+ * OnServiceStartedCallback().
+ * \param result true if observer accepts starting service, false otherwise
+ * \param rejected_params list of rejected parameters' name. Only valid when
+ * result is false. Note that even if result is false, this may be empty.
+ *
+ * \note This is invoked only once but can be invoked by multiple threads.
+ * Also it can be invoked before OnServiceStartedCallback() returns.
+ **/
+ virtual void NotifyServiceStartedResult(
+ uint32_t session_key,
+ bool result,
+ std::vector<std::string>& rejected_params);
+
private:
/**
+ * \brief Struct to keep variables between OnSessionStartedCallback() and
+ * NotifyServiceStartedResult()
+ **/
+ struct ServiceStartedContext {
+ transport_manager::ConnectionUID connection_handle_;
+ uint8_t session_id_;
+ uint32_t new_session_id_;
+ protocol_handler::ServiceType service_type_;
+ uint32_t hash_id_;
+ bool is_protected_;
+
+ /**
+ * \brief Constructor
+ */
+ ServiceStartedContext()
+ : connection_handle_(0)
+ , session_id_(0)
+ , new_session_id_(0)
+ , service_type_(protocol_handler::kInvalidServiceType)
+ , hash_id_(0)
+ , is_protected_(0) {}
+
+ /**
+ * \brief Constructor
+ * \param connection_handle Connection identifier within which session is
+ * started.
+ * \param session_id Session ID specified to OnSessionStartedCallback()
+ * \param new_session_id Session ID generated
+ * \param service_type Type of service
+ * \param hash_id Hash ID generated from connection_handle and
+ * new_session_id
+ * \param is_protected Whether service will be protected
+ **/
+ ServiceStartedContext(transport_manager::ConnectionUID connection_handle,
+ uint8_t session_id,
+ uint32_t new_session_id,
+ protocol_handler::ServiceType service_type,
+ uint32_t hash_id,
+ bool is_protected)
+ : connection_handle_(connection_handle)
+ , session_id_(session_id)
+ , new_session_id_(new_session_id)
+ , service_type_(service_type)
+ , hash_id_(hash_id)
+ , is_protected_(is_protected) {}
+ };
+
+ /**
* \brief Disconnect application.
*
* \param device_handle DeviceHandle of disconnected device.
@@ -446,6 +537,19 @@ class ConnectionHandlerImpl
void OnConnectionEnded(const transport_manager::ConnectionUID connection_id);
+ /**
+ * \brief Convenient method to call NotifySessionStartedResult() with
+ * negative result.
+ * \param connection_handle Identifier of connection within which session
+ * exists
+ * \param session_id session ID passed to OnSessionStartedCallback()
+ * \param is_protected whether the service would be protected
+ **/
+ void NotifySessionStartedFailure(
+ const transport_manager::ConnectionUID connection_handle,
+ const uint8_t session_id,
+ bool is_protected);
+
const ConnectionHandlerSettings& settings_;
/**
* \brief Pointer to observer
@@ -480,6 +584,9 @@ class ConnectionHandlerImpl
*/
utils::StlMapDeleter<ConnectionList> connection_list_deleter_;
+ sync_primitives::Lock start_service_context_map_lock_;
+ std::map<uint32_t, ServiceStartedContext> start_service_context_map_;
+
#ifdef BUILD_TESTS
// Methods for test usage
public:
diff --git a/src/components/connection_handler/src/connection.cc b/src/components/connection_handler/src/connection.cc
index 7bb54d4493..202736e612 100644
--- a/src/components/connection_handler/src/connection.cc
+++ b/src/components/connection_handler/src/connection.cc
@@ -352,8 +352,7 @@ bool Connection::SupportHeartBeat(uint8_t session_id) {
}
Session& session = session_it->second;
return (
- (::protocol_handler::PROTOCOL_VERSION_3 == session.protocol_version ||
- ::protocol_handler::PROTOCOL_VERSION_4 == session.protocol_version) &&
+ (session.protocol_version >= ::protocol_handler::PROTOCOL_VERSION_3) &&
(0 != heartbeat_timeout_));
}
diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc
index 0f6720f6a1..6dd4fe06d7 100644
--- a/src/components/connection_handler/src/connection_handler_impl.cc
+++ b/src/components/connection_handler/src/connection_handler_impl.cc
@@ -69,7 +69,9 @@ ConnectionHandlerImpl::ConnectionHandlerImpl(
, protocol_handler_(NULL)
, connection_list_lock_()
, connection_handler_observer_lock_()
- , connection_list_deleter_(&connection_list_) {}
+ , connection_list_deleter_(&connection_list_)
+ , start_service_context_map_lock_()
+ , start_service_context_map_() {}
ConnectionHandlerImpl::~ConnectionHandlerImpl() {
LOG4CXX_AUTO_TRACE(logger_);
@@ -82,6 +84,9 @@ void ConnectionHandlerImpl::Stop() {
RemoveConnection(itr->second->connection_handle());
itr = connection_list_.begin();
}
+
+ sync_primitives::AutoLock auto_lock(start_service_context_map_lock_);
+ start_service_context_map_.clear();
}
void ConnectionHandlerImpl::set_connection_handler_observer(
@@ -169,12 +174,12 @@ void ConnectionHandlerImpl::OnDeviceRemoved(
RemoveConnection(*it);
}
- device_list_.erase(device_info.device_handle());
sync_primitives::AutoReadLock read_lock(connection_handler_observer_lock_);
if (connection_handler_observer_) {
connection_handler_observer_->RemoveDevice(device_info.device_handle());
connection_handler_observer_->OnDeviceListUpdated(device_list_);
}
+ device_list_.erase(device_info.device_handle());
}
void ConnectionHandlerImpl::OnScanDevicesFinished() {
@@ -279,6 +284,7 @@ bool AllowProtection(const ConnectionHandlerSettings& settings,
}
#endif // ENABLE_SECURITY
+// DEPRECATED
uint32_t ConnectionHandlerImpl::OnSessionStartedCallback(
const transport_manager::ConnectionUID connection_handle,
const uint8_t session_id,
@@ -290,6 +296,7 @@ uint32_t ConnectionHandlerImpl::OnSessionStartedCallback(
if (hash_id) {
*hash_id = protocol_handler::HASH_ID_WRONG;
}
+
#ifdef ENABLE_SECURITY
if (!AllowProtection(get_settings(), service_type, is_protected)) {
return 0;
@@ -348,6 +355,163 @@ uint32_t ConnectionHandlerImpl::OnSessionStartedCallback(
return new_session_id;
}
+void ConnectionHandlerImpl::OnSessionStartedCallback(
+ const transport_manager::ConnectionUID connection_handle,
+ const uint8_t session_id,
+ const protocol_handler::ServiceType& service_type,
+ const bool is_protected,
+ const BsonObject* params) {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ uint32_t new_session_id = 0;
+ uint32_t hash_id = protocol_handler::HASH_ID_WRONG;
+
+#ifdef ENABLE_SECURITY
+ if (!AllowProtection(get_settings(), service_type, is_protected)) {
+ std::vector<std::string> empty;
+ protocol_handler_->NotifySessionStartedResult(connection_handle,
+ session_id,
+ new_session_id,
+ hash_id,
+ is_protected,
+ empty);
+ return;
+ }
+#endif // ENABLE_SECURITY
+ sync_primitives::AutoReadLock lock(connection_list_lock_);
+ ConnectionList::iterator it = connection_list_.find(connection_handle);
+ if (connection_list_.end() == it) {
+ LOG4CXX_ERROR(logger_, "Unknown connection!");
+ NotifySessionStartedFailure(connection_handle, session_id, is_protected);
+ return;
+ }
+
+ Connection* connection = it->second;
+ if ((0 == session_id) && (protocol_handler::kRpc == service_type)) {
+ new_session_id = connection->AddNewSession();
+ if (0 == new_session_id) {
+ LOG4CXX_ERROR(logger_, "Couldn't start new session!");
+ NotifySessionStartedFailure(connection_handle, session_id, is_protected);
+ return;
+ }
+ hash_id = KeyFromPair(connection_handle, new_session_id);
+ } else { // Could be create new service or protected exists one
+ if (!connection->AddNewService(session_id, service_type, is_protected)) {
+ LOG4CXX_ERROR(logger_,
+ "Couldn't establish "
+#ifdef ENABLE_SECURITY
+ << (is_protected ? "protected" : "non-protected")
+#endif // ENABLE_SECURITY
+ << " service " << static_cast<int>(service_type)
+ << " for session " << static_cast<int>(session_id));
+ NotifySessionStartedFailure(connection_handle, session_id, is_protected);
+ return;
+ }
+ new_session_id = session_id;
+ hash_id = protocol_handler::HASH_ID_NOT_SUPPORTED;
+ }
+ sync_primitives::AutoReadLock read_lock(connection_handler_observer_lock_);
+ if (connection_handler_observer_) {
+ const uint32_t session_key = KeyFromPair(connection_handle, new_session_id);
+
+ ServiceStartedContext context(connection_handle,
+ session_id,
+ new_session_id,
+ service_type,
+ hash_id,
+ is_protected);
+ {
+ sync_primitives::AutoLock auto_lock(start_service_context_map_lock_);
+ start_service_context_map_[session_key] = context;
+ }
+
+ connection_handler_observer_->OnServiceStartedCallback(
+ connection->connection_device_handle(),
+ session_key,
+ service_type,
+ params);
+ } else {
+ if (protocol_handler_) {
+ std::vector<std::string> empty;
+ protocol_handler_->NotifySessionStartedResult(connection_handle,
+ session_id,
+ new_session_id,
+ hash_id,
+ is_protected,
+ empty);
+ }
+ }
+}
+
+void ConnectionHandlerImpl::NotifyServiceStartedResult(
+ uint32_t session_key,
+ bool result,
+ std::vector<std::string>& rejected_params) {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ ServiceStartedContext context;
+ {
+ sync_primitives::AutoLock auto_lock(start_service_context_map_lock_);
+ std::map<uint32_t, ServiceStartedContext>::iterator it =
+ start_service_context_map_.find(session_key);
+ if (it == start_service_context_map_.end()) {
+ LOG4CXX_ERROR(logger_, "context for start service not found!");
+ return;
+ }
+ context = it->second;
+ start_service_context_map_.erase(it);
+ }
+
+ Connection* connection = NULL;
+ {
+ sync_primitives::AutoReadLock lock(connection_list_lock_);
+ ConnectionList::iterator it =
+ connection_list_.find(context.connection_handle_);
+ if (connection_list_.end() == it) {
+ LOG4CXX_ERROR(logger_, "connection not found");
+ return;
+ }
+ connection = it->second;
+ }
+
+ if (!result) {
+ LOG4CXX_WARN(logger_,
+ "Service starting forbidden by connection_handler_observer");
+ if (protocol_handler::kRpc == context.service_type_) {
+ connection->RemoveSession(context.new_session_id_);
+ } else {
+ connection->RemoveService(context.session_id_, context.service_type_);
+ }
+ context.new_session_id_ = 0;
+ }
+
+ if (protocol_handler_ != NULL) {
+ protocol_handler_->NotifySessionStartedResult(context.connection_handle_,
+ context.session_id_,
+ context.new_session_id_,
+ context.hash_id_,
+ context.is_protected_,
+ rejected_params);
+ }
+}
+
+void ConnectionHandlerImpl::NotifySessionStartedFailure(
+ const transport_manager::ConnectionUID connection_handle,
+ const uint8_t session_id,
+ bool is_protected) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (protocol_handler_) {
+ std::vector<std::string> empty;
+ protocol_handler_->NotifySessionStartedResult(
+ connection_handle,
+ session_id,
+ 0,
+ protocol_handler::HASH_ID_WRONG,
+ is_protected,
+ empty);
+ }
+}
+
void ConnectionHandlerImpl::OnApplicationFloodCallBack(
const uint32_t& connection_key) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -378,11 +542,22 @@ void ConnectionHandlerImpl::OnMalformedMessageCallback(
CloseConnection(connection_handle);
}
+// DEPRECATED
uint32_t ConnectionHandlerImpl::OnSessionEndedCallback(
const transport_manager::ConnectionUID connection_handle,
const uint8_t session_id,
const uint32_t& hashCode,
const protocol_handler::ServiceType& service_type) {
+ uint32_t hashValue = hashCode;
+ return OnSessionEndedCallback(
+ connection_handle, session_id, &hashValue, service_type);
+}
+
+uint32_t ConnectionHandlerImpl::OnSessionEndedCallback(
+ const transport_manager::ConnectionUID connection_handle,
+ const uint8_t session_id,
+ uint32_t* hashCode,
+ const protocol_handler::ServiceType& service_type) {
LOG4CXX_AUTO_TRACE(logger_);
connection_list_lock_.AcquireForReading();
@@ -402,12 +577,13 @@ uint32_t ConnectionHandlerImpl::OnSessionEndedCallback(
"Session " << static_cast<uint32_t>(session_id)
<< " to be removed");
// old version of protocol doesn't support hash
- if (protocol_handler::HASH_ID_NOT_SUPPORTED != hashCode) {
- if (protocol_handler::HASH_ID_WRONG == hashCode ||
- session_key != hashCode) {
+ if (protocol_handler::HASH_ID_NOT_SUPPORTED != *hashCode) {
+ if (protocol_handler::HASH_ID_WRONG == *hashCode ||
+ session_key != *hashCode) {
LOG4CXX_WARN(logger_,
"Wrong hash_id for session "
<< static_cast<uint32_t>(session_id));
+ *hashCode = protocol_handler::HASH_ID_WRONG;
return 0;
}
}
@@ -669,6 +845,7 @@ security_manager::SSLContext::HandshakeContext
ConnectionHandlerImpl::GetHandshakeContext(uint32_t key) const {
return connection_handler_observer_->GetHandshakeContext(key);
}
+
#endif // ENABLE_SECURITY
void ConnectionHandlerImpl::StartDevicesDiscovery() {
diff --git a/src/components/connection_handler/test/connection_handler_impl_test.cc b/src/components/connection_handler/test/connection_handler_impl_test.cc
index 6b5c2c89ad..ec4e12ffe2 100644
--- a/src/components/connection_handler/test/connection_handler_impl_test.cc
+++ b/src/components/connection_handler/test/connection_handler_impl_test.cc
@@ -54,10 +54,18 @@ using namespace ::connection_handler;
using ::protocol_handler::ServiceType;
using namespace ::protocol_handler;
using ::testing::_;
+using ::testing::ByRef;
+using ::testing::DoAll;
using ::testing::InSequence;
using ::testing::Mock;
using ::testing::Return;
using ::testing::ReturnRefOfCopy;
+using ::testing::SaveArg;
+
+// custom action to call a member function with 3 arguments
+ACTION_P5(InvokeMemberFuncWithArg3, ptr, memberFunc, a, b, c) {
+ (ptr->*memberFunc)(a, b, c);
+}
namespace {
const uint32_t kAsyncExpectationsTimeout = 10000u;
@@ -108,8 +116,16 @@ class ConnectionHandlerTest : public ::testing::Test {
// Remove all specific services
}
void AddTestSession() {
- start_session_id_ = connection_handler_->OnSessionStartedCallback(
- uid_, 0, kRpc, PROTECTION_OFF, &out_hash_id_);
+ protocol_handler_test::MockProtocolHandler temp_protocol_handler;
+ connection_handler_->set_protocol_handler(&temp_protocol_handler);
+ EXPECT_CALL(temp_protocol_handler,
+ NotifySessionStartedResult(_, _, _, _, _, _))
+ .WillOnce(
+ DoAll(SaveArg<2>(&start_session_id_), SaveArg<3>(&out_hash_id_)));
+
+ connection_handler_->OnSessionStartedCallback(
+ uid_, 0, kRpc, PROTECTION_OFF, static_cast<BsonObject*>(NULL));
+ connection_handler_->set_protocol_handler(NULL);
EXPECT_NE(0u, start_session_id_);
EXPECT_EQ(SessionHash(uid_, start_session_id_), out_hash_id_);
connection_key_ = connection_handler_->KeyFromPair(uid_, start_session_id_);
@@ -123,8 +139,20 @@ class ConnectionHandlerTest : public ::testing::Test {
EXPECT_EQ(SessionHash(uid_, start_session_id_), out_hash_id_);
connection_key_ = connection_handler_->KeyFromPair(uid_, start_session_id_);
CheckSessionExists(uid_, start_session_id_);
- uint32_t session_id = connection_handler_->OnSessionStartedCallback(
- uid_, start_session_id_, service_type, PROTECTION_OFF, 0);
+
+ uint32_t session_id = 0;
+ protocol_handler_test::MockProtocolHandler temp_protocol_handler;
+ connection_handler_->set_protocol_handler(&temp_protocol_handler);
+ EXPECT_CALL(temp_protocol_handler,
+ NotifySessionStartedResult(_, _, _, _, _, _))
+ .WillOnce(SaveArg<2>(&session_id));
+
+ connection_handler_->OnSessionStartedCallback(uid_,
+ start_session_id_,
+ service_type,
+ PROTECTION_OFF,
+ static_cast<BsonObject*>(0));
+ connection_handler_->set_protocol_handler(NULL);
EXPECT_EQ(session_id, start_session_id_);
}
@@ -267,8 +295,14 @@ TEST_F(ConnectionHandlerTest, StartSession_NoConnection) {
// Null sessionId for start new session
const uint8_t sessionID = 0;
// Start new session with RPC service
- const uint32_t result_fail = connection_handler_->OnSessionStartedCallback(
- uid_, sessionID, kRpc, PROTECTION_ON, &out_hash_id_);
+ uint32_t result_fail = 0;
+ connection_handler_->set_protocol_handler(&mock_protocol_handler_);
+ EXPECT_CALL(mock_protocol_handler_,
+ NotifySessionStartedResult(_, _, _, _, _, _))
+ .WillOnce(DoAll(SaveArg<2>(&result_fail), SaveArg<3>(&out_hash_id_)));
+
+ connection_handler_->OnSessionStartedCallback(
+ uid_, sessionID, kRpc, PROTECTION_ON, static_cast<BsonObject*>(NULL));
// Unknown connection error is '0'
EXPECT_EQ(0u, result_fail);
EXPECT_EQ(protocol_handler::HASH_ID_WRONG, out_hash_id_);
@@ -1013,26 +1047,66 @@ TEST_F(ConnectionHandlerTest, StartService_withServices) {
AddTestDeviceConnection();
AddTestSession();
+ uint32_t start_audio = 0;
+ uint32_t start_video = 0;
+ connection_handler_->set_protocol_handler(&mock_protocol_handler_);
+ EXPECT_CALL(mock_protocol_handler_,
+ NotifySessionStartedResult(_, _, _, _, _, _))
+ .WillOnce(DoAll(SaveArg<2>(&start_audio), SaveArg<3>(&out_hash_id_)))
+ .WillOnce(DoAll(SaveArg<2>(&start_video), SaveArg<3>(&out_hash_id_)));
+
// Start Audio service
- const uint32_t start_audio = connection_handler_->OnSessionStartedCallback(
- uid_, start_session_id_, kAudio, PROTECTION_OFF, &out_hash_id_);
+ connection_handler_->OnSessionStartedCallback(uid_,
+ start_session_id_,
+ kAudio,
+ PROTECTION_OFF,
+ static_cast<BsonObject*>(NULL));
EXPECT_EQ(start_session_id_, start_audio);
CheckServiceExists(uid_, start_session_id_, kAudio, true);
EXPECT_EQ(protocol_handler::HASH_ID_NOT_SUPPORTED, out_hash_id_);
// Start Audio service
- const uint32_t start_video = connection_handler_->OnSessionStartedCallback(
- uid_, start_session_id_, kMobileNav, PROTECTION_OFF, &out_hash_id_);
+ connection_handler_->OnSessionStartedCallback(uid_,
+ start_session_id_,
+ kMobileNav,
+ PROTECTION_OFF,
+ static_cast<BsonObject*>(NULL));
EXPECT_EQ(start_session_id_, start_video);
CheckServiceExists(uid_, start_session_id_, kMobileNav, true);
EXPECT_EQ(protocol_handler::HASH_ID_NOT_SUPPORTED, out_hash_id_);
+
+ connection_handler_->set_protocol_handler(NULL);
}
-TEST_F(ConnectionHandlerTest, ServiceStop_UnExistSession) {
+TEST_F(ConnectionHandlerTest, StartService_withServices_withParams) {
AddTestDeviceConnection();
+ AddTestSession();
+ uint32_t start_video = 0;
+ // create a dummy pointer
+ int dummy = 0;
+ std::vector<std::string> empty;
+ BsonObject* dummy_param = reinterpret_cast<BsonObject*>(&dummy);
+ connection_handler_->set_protocol_handler(&mock_protocol_handler_);
+ EXPECT_CALL(mock_protocol_handler_,
+ NotifySessionStartedResult(_, _, _, _, _, empty))
+ .WillOnce(DoAll(SaveArg<2>(&start_video), SaveArg<3>(&out_hash_id_)));
+
+ connection_handler_->OnSessionStartedCallback(
+ uid_, start_session_id_, kMobileNav, PROTECTION_OFF, dummy_param);
+ EXPECT_EQ(start_session_id_, start_video);
+ CheckServiceExists(uid_, start_session_id_, kMobileNav, true);
+ EXPECT_EQ(protocol_handler::HASH_ID_NOT_SUPPORTED, out_hash_id_);
+
+ connection_handler_->set_protocol_handler(NULL);
+}
+
+TEST_F(ConnectionHandlerTest, ServiceStop_UnExistSession) {
+ AddTestDeviceConnection();
+ uint32_t dummy_hash = 0u;
const uint32_t end_session_result =
- connection_handler_->OnSessionEndedCallback(uid_, 0u, 0u, kAudio);
+ connection_handler_->OnSessionEndedCallback(
+ uid_, 0u, &dummy_hash, kAudio);
EXPECT_EQ(0u, end_session_result);
CheckSessionExists(uid_, 0);
}
@@ -1040,9 +1114,10 @@ TEST_F(ConnectionHandlerTest, ServiceStop_UnExistSession) {
TEST_F(ConnectionHandlerTest, ServiceStop_UnExistService) {
AddTestDeviceConnection();
AddTestSession();
+ uint32_t dummy_hash = 0u;
const uint32_t end_session_result =
connection_handler_->OnSessionEndedCallback(
- uid_, start_session_id_, 0u, kAudio);
+ uid_, start_session_id_, &dummy_hash, kAudio);
EXPECT_EQ(0u, end_session_result);
CheckServiceExists(uid_, start_session_id_, kAudio, false);
}
@@ -1050,17 +1125,29 @@ TEST_F(ConnectionHandlerTest, ServiceStop_UnExistService) {
TEST_F(ConnectionHandlerTest, ServiceStop) {
AddTestDeviceConnection();
AddTestSession();
+
+ uint32_t start_audio = 0;
+ connection_handler_->set_protocol_handler(&mock_protocol_handler_);
+ EXPECT_CALL(mock_protocol_handler_,
+ NotifySessionStartedResult(_, _, _, _, _, _))
+ .WillRepeatedly(
+ DoAll(SaveArg<2>(&start_audio), SaveArg<3>(&out_hash_id_)));
+
// Check ignoring hash_id on stop non-rpc service
for (uint32_t some_hash_id = 0; some_hash_id < 0xFF; ++some_hash_id) {
// Start audio service
- const uint32_t start_audio = connection_handler_->OnSessionStartedCallback(
- uid_, start_session_id_, kAudio, PROTECTION_OFF, &out_hash_id_);
+ connection_handler_->OnSessionStartedCallback(
+ uid_,
+ start_session_id_,
+ kAudio,
+ PROTECTION_OFF,
+ static_cast<BsonObject*>(NULL));
EXPECT_EQ(start_session_id_, start_audio);
EXPECT_EQ(protocol_handler::HASH_ID_NOT_SUPPORTED, out_hash_id_);
const uint32_t end_session_result =
connection_handler_->OnSessionEndedCallback(
- uid_, start_session_id_, some_hash_id, kAudio);
+ uid_, start_session_id_, &some_hash_id, kAudio);
EXPECT_EQ(connection_key_, end_session_result);
CheckServiceExists(uid_, start_session_id_, kAudio, false);
}
@@ -1072,12 +1159,13 @@ TEST_F(ConnectionHandlerTest, SessionStop_CheckHash) {
AddTestSession();
const uint32_t hash = connection_key_;
- const uint32_t wrong_hash = hash + 1;
+ uint32_t wrong_hash = hash + 1;
const uint32_t end_audio_wrong_hash =
connection_handler_->OnSessionEndedCallback(
- uid_, start_session_id_, wrong_hash, kRpc);
+ uid_, start_session_id_, &wrong_hash, kRpc);
EXPECT_EQ(0u, end_audio_wrong_hash);
+ EXPECT_EQ(protocol_handler::HASH_ID_WRONG, wrong_hash);
CheckSessionExists(uid_, start_session_id_);
const uint32_t end_audio = connection_handler_->OnSessionEndedCallback(
@@ -1092,13 +1180,14 @@ TEST_F(ConnectionHandlerTest, SessionStop_CheckSpecificHash) {
for (uint32_t session = 0; session < 0xFF; ++session) {
AddTestSession();
- const uint32_t wrong_hash = protocol_handler::HASH_ID_WRONG;
+ uint32_t wrong_hash = protocol_handler::HASH_ID_WRONG;
const uint32_t hash = protocol_handler::HASH_ID_NOT_SUPPORTED;
const uint32_t end_audio_wrong_hash =
connection_handler_->OnSessionEndedCallback(
uid_, start_session_id_, wrong_hash, kRpc);
EXPECT_EQ(0u, end_audio_wrong_hash);
+ EXPECT_EQ(protocol_handler::HASH_ID_WRONG, wrong_hash);
CheckSessionExists(uid_, start_session_id_);
const uint32_t end_audio = connection_handler_->OnSessionEndedCallback(
@@ -1118,17 +1207,197 @@ TEST_F(ConnectionHandlerTest, SessionStarted_WithRpc) {
&mock_connection_handler_observer);
uint32_t session_key =
connection_handler_->KeyFromPair(uid_, start_session_id_);
+ std::vector<std::string> empty;
EXPECT_CALL(mock_connection_handler_observer,
- OnServiceStartedCallback(device_handle_, session_key, kRpc))
- .WillOnce(Return(true));
+ OnServiceStartedCallback(device_handle_, session_key, kRpc, NULL))
+ .WillOnce(InvokeMemberFuncWithArg3(
+ connection_handler_,
+ &ConnectionHandler::NotifyServiceStartedResult,
+ session_key,
+ true,
+ ByRef(empty)));
+
+ uint32_t new_session_id = 0;
+ connection_handler_->set_protocol_handler(&mock_protocol_handler_);
+ EXPECT_CALL(mock_protocol_handler_,
+ NotifySessionStartedResult(_, _, _, _, _, _))
+ .WillOnce(DoAll(SaveArg<2>(&new_session_id), SaveArg<3>(&out_hash_id_)));
// Start new session with RPC service
- uint32_t new_session_id = connection_handler_->OnSessionStartedCallback(
- uid_, 0, kRpc, PROTECTION_OFF, &out_hash_id_);
+ connection_handler_->OnSessionStartedCallback(
+ uid_, 0, kRpc, PROTECTION_OFF, static_cast<BsonObject*>(NULL));
+
+ EXPECT_NE(0u, new_session_id);
+}
+
+TEST_F(ConnectionHandlerTest, ServiceStarted_Video_SUCCESS) {
+ AddTestDeviceConnection();
+ AddTestSession();
+
+ int dummy = 0;
+ BsonObject* dummy_params = reinterpret_cast<BsonObject*>(&dummy);
+
+ connection_handler_test::MockConnectionHandlerObserver
+ mock_connection_handler_observer;
+ connection_handler_->set_connection_handler_observer(
+ &mock_connection_handler_observer);
+ uint32_t session_key =
+ connection_handler_->KeyFromPair(uid_, start_session_id_);
+ std::vector<std::string> empty;
+ EXPECT_CALL(mock_connection_handler_observer,
+ OnServiceStartedCallback(
+ device_handle_, session_key, kMobileNav, dummy_params))
+ .WillOnce(InvokeMemberFuncWithArg3(
+ connection_handler_,
+ &ConnectionHandler::NotifyServiceStartedResult,
+ session_key,
+ true,
+ ByRef(empty)));
+
+ // confirm that NotifySessionStartedResult() is called
+ uint32_t new_session_id = 0;
+ connection_handler_->set_protocol_handler(&mock_protocol_handler_);
+ EXPECT_CALL(mock_protocol_handler_,
+ NotifySessionStartedResult(_, _, _, _, false, empty))
+ .WillOnce(DoAll(SaveArg<2>(&new_session_id), SaveArg<3>(&out_hash_id_)));
+
+ connection_handler_->OnSessionStartedCallback(
+ uid_, start_session_id_, kMobileNav, PROTECTION_OFF, dummy_params);
EXPECT_NE(0u, new_session_id);
}
+TEST_F(ConnectionHandlerTest, ServiceStarted_Video_FAILURE) {
+ AddTestDeviceConnection();
+ AddTestSession();
+
+ int dummy = 0;
+ BsonObject* dummy_params = reinterpret_cast<BsonObject*>(&dummy);
+
+ connection_handler_test::MockConnectionHandlerObserver
+ mock_connection_handler_observer;
+ connection_handler_->set_connection_handler_observer(
+ &mock_connection_handler_observer);
+ uint32_t session_key =
+ connection_handler_->KeyFromPair(uid_, start_session_id_);
+ std::vector<std::string> empty;
+ EXPECT_CALL(mock_connection_handler_observer,
+ OnServiceStartedCallback(
+ device_handle_, session_key, kMobileNav, dummy_params))
+ .WillOnce(InvokeMemberFuncWithArg3(
+ connection_handler_,
+ &ConnectionHandler::NotifyServiceStartedResult,
+ session_key,
+ false,
+ ByRef(empty)));
+
+ // confirm that NotifySessionStartedResult() is called
+ uint32_t new_session_id = 0;
+ connection_handler_->set_protocol_handler(&mock_protocol_handler_);
+ EXPECT_CALL(mock_protocol_handler_,
+ NotifySessionStartedResult(_, _, _, _, false, empty))
+ .WillOnce(DoAll(SaveArg<2>(&new_session_id), SaveArg<3>(&out_hash_id_)));
+
+ connection_handler_->OnSessionStartedCallback(
+ uid_, start_session_id_, kMobileNav, PROTECTION_OFF, dummy_params);
+
+ EXPECT_EQ(0u, new_session_id);
+}
+
+/*
+ * Simulate two OnSessionStartedCallback calls, and connection handler observer
+ * returns a positive reply for the first call with delay and a negative reply
+ * for the second call immediately.
+ */
+TEST_F(ConnectionHandlerTest, ServiceStarted_Video_Multiple) {
+ AddTestDeviceConnection();
+
+ uint32_t rpc_session_id1;
+ uint32_t rpc_session_id2;
+ uint32_t hash_id1;
+ uint32_t hash_id2;
+
+ protocol_handler_test::MockProtocolHandler temp_protocol_handler;
+ connection_handler_->set_protocol_handler(&temp_protocol_handler);
+ EXPECT_CALL(temp_protocol_handler,
+ NotifySessionStartedResult(_, _, _, _, _, _))
+ .WillOnce(DoAll(SaveArg<2>(&rpc_session_id1), SaveArg<3>(&hash_id1)))
+ .WillOnce(DoAll(SaveArg<2>(&rpc_session_id2), SaveArg<3>(&hash_id2)));
+
+ // add two sessions
+ connection_handler_->OnSessionStartedCallback(
+ uid_, 0, kRpc, PROTECTION_OFF, static_cast<BsonObject*>(NULL));
+ connection_handler_->OnSessionStartedCallback(
+ uid_, 0, kRpc, PROTECTION_OFF, static_cast<BsonObject*>(NULL));
+
+ EXPECT_NE(0u, rpc_session_id1);
+ EXPECT_NE(0u, rpc_session_id2);
+ EXPECT_EQ(SessionHash(uid_, rpc_session_id1), hash_id1);
+ EXPECT_EQ(SessionHash(uid_, rpc_session_id2), hash_id2);
+ CheckSessionExists(uid_, rpc_session_id1);
+ CheckSessionExists(uid_, rpc_session_id2);
+
+ connection_handler_->set_protocol_handler(NULL);
+
+ int dummy = 0;
+ BsonObject* dummy_params = reinterpret_cast<BsonObject*>(&dummy);
+
+ connection_handler_test::MockConnectionHandlerObserver
+ mock_connection_handler_observer;
+ connection_handler_->set_connection_handler_observer(
+ &mock_connection_handler_observer);
+ uint32_t session_key1 =
+ connection_handler_->KeyFromPair(uid_, rpc_session_id1);
+ uint32_t session_key2 =
+ connection_handler_->KeyFromPair(uid_, rpc_session_id2);
+
+ std::vector<std::string> empty;
+
+ EXPECT_CALL(mock_connection_handler_observer,
+ OnServiceStartedCallback(
+ device_handle_, session_key1, kMobileNav, dummy_params))
+ // don't call NotifyServiceStartedResult() with this event
+ .Times(1);
+ EXPECT_CALL(mock_connection_handler_observer,
+ OnServiceStartedCallback(
+ device_handle_, session_key2, kMobileNav, dummy_params))
+ // call NotifyServiceStartedResult() twice, first for the second session
+ // then for the first session
+ .WillOnce(DoAll(InvokeMemberFuncWithArg3(
+ connection_handler_,
+ &ConnectionHandler::NotifyServiceStartedResult,
+ session_key2,
+ false,
+ ByRef(empty)),
+ InvokeMemberFuncWithArg3(
+ connection_handler_,
+ &ConnectionHandler::NotifyServiceStartedResult,
+ session_key1,
+ true,
+ ByRef(empty))));
+
+ // verify that connection handler will not mix up the two results
+ uint32_t new_session_id1 = 0;
+ uint32_t new_session_id2 = 0;
+ connection_handler_->set_protocol_handler(&mock_protocol_handler_);
+ EXPECT_CALL(
+ mock_protocol_handler_,
+ NotifySessionStartedResult(_, rpc_session_id1, _, _, false, empty))
+ .WillOnce(SaveArg<2>(&new_session_id1));
+ EXPECT_CALL(
+ mock_protocol_handler_,
+ NotifySessionStartedResult(_, rpc_session_id2, _, _, false, empty))
+ .WillOnce(SaveArg<2>(&new_session_id2));
+
+ connection_handler_->OnSessionStartedCallback(
+ uid_, rpc_session_id1, kMobileNav, PROTECTION_OFF, dummy_params);
+ connection_handler_->OnSessionStartedCallback(
+ uid_, rpc_session_id2, kMobileNav, PROTECTION_OFF, dummy_params);
+
+ EXPECT_NE(0u, new_session_id1); // result is positive
+ EXPECT_EQ(0u, new_session_id2); // result is negative
+}
+
TEST_F(ConnectionHandlerTest,
SessionStarted_StartSession_SecureSpecific_Unprotect) {
EXPECT_CALL(mock_connection_handler_settings, heart_beat_timeout())
@@ -1138,10 +1407,18 @@ TEST_F(ConnectionHandlerTest,
// Forbid start kRPC without encryption
protected_services_.push_back(kRpc);
SetSpecificServices();
+
+ uint32_t session_id_fail = 0;
+ uint32_t session_id = 0;
+ connection_handler_->set_protocol_handler(&mock_protocol_handler_);
+ EXPECT_CALL(mock_protocol_handler_,
+ NotifySessionStartedResult(_, _, _, _, _, _))
+ .WillOnce(DoAll(SaveArg<2>(&session_id_fail), SaveArg<3>(&out_hash_id_)))
+ .WillOnce(DoAll(SaveArg<2>(&session_id), SaveArg<3>(&out_hash_id_)));
+
// Start new session with RPC service
- const uint32_t session_id_fail =
- connection_handler_->OnSessionStartedCallback(
- uid_, 0, kRpc, PROTECTION_OFF, &out_hash_id_);
+ connection_handler_->OnSessionStartedCallback(
+ uid_, 0, kRpc, PROTECTION_OFF, static_cast<BsonObject*>(NULL));
#ifdef ENABLE_SECURITY
EXPECT_EQ(0u, session_id_fail);
EXPECT_EQ(protocol_handler::HASH_ID_WRONG, out_hash_id_);
@@ -1155,8 +1432,8 @@ TEST_F(ConnectionHandlerTest,
protected_services_.push_back(kControl);
SetSpecificServices();
// Start new session with RPC service
- const uint32_t session_id = connection_handler_->OnSessionStartedCallback(
- uid_, 0, kRpc, PROTECTION_OFF, &out_hash_id_);
+ connection_handler_->OnSessionStartedCallback(
+ uid_, 0, kRpc, PROTECTION_OFF, static_cast<BsonObject*>(NULL));
EXPECT_NE(0u, session_id);
CheckService(uid_, session_id, kRpc, NULL, PROTECTION_OFF);
EXPECT_EQ(SessionHash(uid_, session_id), out_hash_id_);
@@ -1172,10 +1449,18 @@ TEST_F(ConnectionHandlerTest,
unprotected_services_.push_back(UnnamedService::kServedService2);
unprotected_services_.push_back(kControl);
SetSpecificServices();
+
+ uint32_t session_id_fail = 0;
+ uint32_t session_id = 0;
+ connection_handler_->set_protocol_handler(&mock_protocol_handler_);
+ EXPECT_CALL(mock_protocol_handler_,
+ NotifySessionStartedResult(_, _, _, _, _, _))
+ .WillOnce(SaveArg<2>(&session_id_fail))
+ .WillOnce(DoAll(SaveArg<2>(&session_id), SaveArg<3>(&out_hash_id_)));
+
// Start new session with RPC service
- const uint32_t session_id_fail =
- connection_handler_->OnSessionStartedCallback(
- uid_, 0, kRpc, PROTECTION_ON, NULL);
+ connection_handler_->OnSessionStartedCallback(
+ uid_, 0, kRpc, PROTECTION_ON, static_cast<BsonObject*>(NULL));
#ifdef ENABLE_SECURITY
EXPECT_EQ(0u, session_id_fail);
#else
@@ -1187,8 +1472,8 @@ TEST_F(ConnectionHandlerTest,
unprotected_services_.push_back(kControl);
SetSpecificServices();
// Start new session with RPC service
- const uint32_t session_id = connection_handler_->OnSessionStartedCallback(
- uid_, 0, kRpc, PROTECTION_ON, &out_hash_id_);
+ connection_handler_->OnSessionStartedCallback(
+ uid_, 0, kRpc, PROTECTION_ON, static_cast<BsonObject*>(NULL));
EXPECT_NE(0u, session_id);
EXPECT_EQ(SessionHash(uid_, session_id), out_hash_id_);
@@ -1207,9 +1492,21 @@ TEST_F(ConnectionHandlerTest,
protected_services_.push_back(UnnamedService::kServedService2);
protected_services_.push_back(kControl);
SetSpecificServices();
+
+ uint32_t session_id2 = 0;
+ uint32_t session_id3 = 0;
+ connection_handler_->set_protocol_handler(&mock_protocol_handler_);
+ EXPECT_CALL(mock_protocol_handler_,
+ NotifySessionStartedResult(_, _, _, _, _, _))
+ .WillOnce(SaveArg<2>(&session_id2))
+ .WillOnce(DoAll(SaveArg<2>(&session_id3), SaveArg<3>(&out_hash_id_)));
+
// Start new session with Audio service
- const uint32_t session_id2 = connection_handler_->OnSessionStartedCallback(
- uid_, start_session_id_, kAudio, PROTECTION_OFF, NULL);
+ connection_handler_->OnSessionStartedCallback(uid_,
+ start_session_id_,
+ kAudio,
+ PROTECTION_OFF,
+ static_cast<BsonObject*>(NULL));
#ifdef ENABLE_SECURITY
EXPECT_EQ(0u, session_id2);
#else
@@ -1222,8 +1519,11 @@ TEST_F(ConnectionHandlerTest,
protected_services_.push_back(UnnamedService::kServedService2);
protected_services_.push_back(kControl);
SetSpecificServices();
- const uint32_t session_id3 = connection_handler_->OnSessionStartedCallback(
- uid_, start_session_id_, kAudio, PROTECTION_OFF, &out_hash_id_);
+ connection_handler_->OnSessionStartedCallback(uid_,
+ start_session_id_,
+ kAudio,
+ PROTECTION_OFF,
+ static_cast<BsonObject*>(NULL));
// Returned original session id
#ifdef ENABLE_SECURITY
EXPECT_EQ(start_session_id_, session_id3);
@@ -1246,10 +1546,21 @@ TEST_F(ConnectionHandlerTest,
unprotected_services_.push_back(UnnamedService::kServedService2);
unprotected_services_.push_back(kControl);
SetSpecificServices();
+
+ uint32_t session_id_reject = 0;
+ uint32_t session_id3 = 0;
+ connection_handler_->set_protocol_handler(&mock_protocol_handler_);
+ EXPECT_CALL(mock_protocol_handler_,
+ NotifySessionStartedResult(_, _, _, _, _, _))
+ .WillOnce(SaveArg<2>(&session_id_reject))
+ .WillOnce(DoAll(SaveArg<2>(&session_id3), SaveArg<3>(&out_hash_id_)));
+
// Start new session with Audio service
- const uint32_t session_id_reject =
- connection_handler_->OnSessionStartedCallback(
- uid_, start_session_id_, kAudio, PROTECTION_ON, NULL);
+ connection_handler_->OnSessionStartedCallback(uid_,
+ start_session_id_,
+ kAudio,
+ PROTECTION_ON,
+ static_cast<BsonObject*>(NULL));
#ifdef ENABLE_SECURITY
EXPECT_EQ(0u, session_id_reject);
#else
@@ -1258,8 +1569,11 @@ TEST_F(ConnectionHandlerTest,
// Allow start kAudio with encryption
unprotected_services_.clear();
SetSpecificServices();
- const uint32_t session_id3 = connection_handler_->OnSessionStartedCallback(
- uid_, start_session_id_, kAudio, PROTECTION_ON, &out_hash_id_);
+ connection_handler_->OnSessionStartedCallback(uid_,
+ start_session_id_,
+ kAudio,
+ PROTECTION_ON,
+ static_cast<BsonObject*>(NULL));
// Returned original session id
#ifdef ENABLE_SECURITY
EXPECT_EQ(start_session_id_, session_id3);
@@ -1276,9 +1590,22 @@ TEST_F(ConnectionHandlerTest, SessionStarted_DealyProtect) {
AddTestDeviceConnection();
AddTestSession();
+ uint32_t session_id_new = 0;
+ uint32_t session_id2 = 0;
+ uint32_t session_id3 = 0;
+ connection_handler_->set_protocol_handler(&mock_protocol_handler_);
+ EXPECT_CALL(mock_protocol_handler_,
+ NotifySessionStartedResult(_, _, _, _, _, _))
+ .WillOnce(DoAll(SaveArg<2>(&session_id_new), SaveArg<3>(&out_hash_id_)))
+ .WillOnce(DoAll(SaveArg<2>(&session_id2), SaveArg<3>(&out_hash_id_)))
+ .WillOnce(DoAll(SaveArg<2>(&session_id3), SaveArg<3>(&out_hash_id_)));
+
// Start RPC protection
- const uint32_t session_id_new = connection_handler_->OnSessionStartedCallback(
- uid_, start_session_id_, kRpc, PROTECTION_ON, &out_hash_id_);
+ connection_handler_->OnSessionStartedCallback(uid_,
+ start_session_id_,
+ kRpc,
+ PROTECTION_ON,
+ static_cast<BsonObject*>(NULL));
#ifdef ENABLE_SECURITY
EXPECT_EQ(start_session_id_, session_id_new);
// Post protection nedd no hash
@@ -1292,15 +1619,21 @@ TEST_F(ConnectionHandlerTest, SessionStarted_DealyProtect) {
#endif // ENABLE_SECURITY
// Start Audio session without protection
- const uint32_t session_id2 = connection_handler_->OnSessionStartedCallback(
- uid_, start_session_id_, kAudio, PROTECTION_OFF, &out_hash_id_);
+ connection_handler_->OnSessionStartedCallback(uid_,
+ start_session_id_,
+ kAudio,
+ PROTECTION_OFF,
+ static_cast<BsonObject*>(NULL));
EXPECT_EQ(start_session_id_, session_id2);
EXPECT_EQ(protocol_handler::HASH_ID_NOT_SUPPORTED, out_hash_id_);
CheckService(uid_, start_session_id_, kAudio, NULL, PROTECTION_OFF);
// Start Audio protection
- const uint32_t session_id3 = connection_handler_->OnSessionStartedCallback(
- uid_, start_session_id_, kAudio, PROTECTION_ON, &out_hash_id_);
+ connection_handler_->OnSessionStartedCallback(uid_,
+ start_session_id_,
+ kAudio,
+ PROTECTION_ON,
+ static_cast<BsonObject*>(NULL));
#ifdef ENABLE_SECURITY
EXPECT_EQ(start_session_id_, session_id3);
EXPECT_EQ(protocol_handler::HASH_ID_NOT_SUPPORTED, out_hash_id_);
@@ -1316,8 +1649,16 @@ TEST_F(ConnectionHandlerTest, SessionStarted_DealyProtectBulk) {
AddTestDeviceConnection();
AddTestSession();
- const uint32_t session_id_new = connection_handler_->OnSessionStartedCallback(
- uid_, start_session_id_, kBulk, PROTECTION_ON, NULL);
+ uint32_t session_id_new = 0;
+ connection_handler_->set_protocol_handler(&mock_protocol_handler_);
+ EXPECT_CALL(mock_protocol_handler_,
+ NotifySessionStartedResult(_, _, _, _, _, _))
+ .WillOnce(SaveArg<2>(&session_id_new));
+ connection_handler_->OnSessionStartedCallback(uid_,
+ start_session_id_,
+ kBulk,
+ PROTECTION_ON,
+ static_cast<BsonObject*>(NULL));
#ifdef ENABLE_SECURITY
EXPECT_EQ(start_session_id_, session_id_new);
CheckService(uid_, start_session_id_, kRpc, NULL, PROTECTION_ON);
@@ -1412,9 +1753,19 @@ TEST_F(ConnectionHandlerTest, GetSSLContext_ByProtectedService) {
// kAudio is not exists yet
EXPECT_EQ(connection_handler_->GetSSLContext(connection_key_, kAudio),
reinterpret_cast<security_manager::SSLContext*>(NULL));
+
+ uint32_t session_id = 0;
+ connection_handler_->set_protocol_handler(&mock_protocol_handler_);
+ EXPECT_CALL(mock_protocol_handler_,
+ NotifySessionStartedResult(_, _, _, _, _, _))
+ .WillOnce(SaveArg<2>(&session_id));
+
// Open kAudio service
- const uint32_t session_id = connection_handler_->OnSessionStartedCallback(
- uid_, start_session_id_, kAudio, PROTECTION_ON, NULL);
+ connection_handler_->OnSessionStartedCallback(uid_,
+ start_session_id_,
+ kAudio,
+ PROTECTION_ON,
+ static_cast<BsonObject*>(NULL));
EXPECT_EQ(session_id, start_session_id_);
CheckService(uid_, session_id, kAudio, &mock_ssl_context, PROTECTION_ON);
@@ -1437,9 +1788,18 @@ TEST_F(ConnectionHandlerTest, GetSSLContext_ByDealyProtectedRPC) {
EXPECT_EQ(connection_handler_->GetSSLContext(connection_key_, kRpc),
reinterpret_cast<security_manager::SSLContext*>(NULL));
+ uint32_t session_id = 0;
+ connection_handler_->set_protocol_handler(&mock_protocol_handler_);
+ EXPECT_CALL(mock_protocol_handler_,
+ NotifySessionStartedResult(_, _, _, _, _, _))
+ .WillOnce(SaveArg<2>(&session_id));
+
// Protect kRpc (Bulk will be protect also)
- const uint32_t session_id = connection_handler_->OnSessionStartedCallback(
- uid_, start_session_id_, kRpc, PROTECTION_ON, NULL);
+ connection_handler_->OnSessionStartedCallback(uid_,
+ start_session_id_,
+ kRpc,
+ PROTECTION_ON,
+ static_cast<BsonObject*>(NULL));
EXPECT_EQ(start_session_id_, session_id);
CheckService(uid_, session_id, kRpc, &mock_ssl_context, PROTECTION_ON);
@@ -1465,9 +1825,18 @@ TEST_F(ConnectionHandlerTest, GetSSLContext_ByDealyProtectedBulk) {
EXPECT_EQ(connection_handler_->GetSSLContext(connection_key_, kRpc),
reinterpret_cast<security_manager::SSLContext*>(NULL));
+ uint32_t session_id = 0;
+ connection_handler_->set_protocol_handler(&mock_protocol_handler_);
+ EXPECT_CALL(mock_protocol_handler_,
+ NotifySessionStartedResult(_, _, _, _, _, _))
+ .WillOnce(SaveArg<2>(&session_id));
+
// Protect Bulk (kRpc will be protected also)
- const uint32_t session_id = connection_handler_->OnSessionStartedCallback(
- uid_, start_session_id_, kBulk, PROTECTION_ON, NULL);
+ connection_handler_->OnSessionStartedCallback(uid_,
+ start_session_id_,
+ kBulk,
+ PROTECTION_ON,
+ static_cast<BsonObject*>(NULL));
EXPECT_EQ(start_session_id_, session_id);
CheckService(uid_, session_id, kRpc, &mock_ssl_context, PROTECTION_ON);
diff --git a/src/components/connection_handler/test/connection_test.cc b/src/components/connection_handler/test/connection_test.cc
index 85f43f3785..4582cc10ee 100644
--- a/src/components/connection_handler/test/connection_test.cc
+++ b/src/components/connection_handler/test/connection_test.cc
@@ -201,6 +201,32 @@ TEST_F(ConnectionTest, HeartBeat_Protocol4_ZeroHeartBeat_NotSupported) {
EXPECT_FALSE(connection_->SupportHeartBeat(session_id));
}
+TEST_F(ConnectionTest, HeartBeat_Protocol5_PositiveHeartBeat_Supported) {
+ // Arrange
+ StartSession();
+ // Check execution if protocol version is 5
+ const uint8_t protocol_version = static_cast<uint8_t>(PROTOCOL_VERSION_5);
+ connection_->UpdateProtocolVersionSession(session_id, protocol_version);
+ EXPECT_TRUE(connection_->SupportHeartBeat(session_id));
+}
+
+TEST_F(ConnectionTest, HeartBeat_Protocol5_ZeroHeartBeat_NotSupported) {
+ // Correctc of connection (need connection with heartbeat=0)
+ delete connection_;
+ connection_ = 0;
+
+ const ConnectionHandle connectionHandle = 0;
+ const DeviceHandle device_handle = 0u;
+ const uint32_t heart_beat = 0u;
+ connection_ = new Connection(
+ connectionHandle, device_handle, connection_handler_, heart_beat);
+ StartSession();
+ // Check execution if protocol version is 5
+ const uint8_t protocol_version = static_cast<uint8_t>(PROTOCOL_VERSION_5);
+ connection_->UpdateProtocolVersionSession(session_id, protocol_version);
+ EXPECT_FALSE(connection_->SupportHeartBeat(session_id));
+}
+
// Try to add service without session
TEST_F(ConnectionTest, Session_AddNewServiceWithoutSession) {
EXPECT_EQ(connection_->AddNewService(session_id, kAudio, true),
diff --git a/src/components/formatters/test/meta_formatter_test.cc b/src/components/formatters/test/meta_formatter_test.cc
index 293f881c4a..87f05ab50e 100644
--- a/src/components/formatters/test/meta_formatter_test.cc
+++ b/src/components/formatters/test/meta_formatter_test.cc
@@ -68,20 +68,6 @@ TEST_F(CMetaFormatterTestHelper,
CMetaFormatter::CreateObjectByPattern(object2, schema, result_object2);
EXPECT_TRUE(creationresult);
- // Uncomment code to print objects in console
- // std::string formatted_string;
- // CFormatterJsonSDLRPCv1::toString(object1, formatted_string);
- // printf("object1 %s\n", formatted_string.c_str());
- //
- // CFormatterJsonSDLRPCv1::toString(result_object1, formatted_string);
- // printf("result_object1 %s\n", formatted_string.c_str());
- //
- // CFormatterJsonSDLRPCv1::toString(object2, formatted_string);
- // printf("object2 %s\n", formatted_string.c_str());
- //
- // CFormatterJsonSDLRPCv1::toString(result_object2, formatted_string);
- // printf("result_object2 %s\n", formatted_string.c_str());
-
CompareObjects(object1, result_object1);
CompareObjects(object2, result_object2);
@@ -112,13 +98,6 @@ TEST_F(CMetaFormatterTestHelper, NormalSchemaWithEmptyObject) {
FillObjectWithDefaultValues(expected_object);
CompareObjects(expected_object, result_object);
-
- // Uncomment code to print objects in console
- // std::string str;
- // AnyObjectToJsonString(result_object, str);
- // printf("result_object(default) %s", str.c_str());
- // AnyObjectToJsonString(expected_object, str);
- // printf("expected_object %s", str.c_str());
}
TEST_F(CMetaFormatterTestHelper,
@@ -140,11 +119,6 @@ TEST_F(CMetaFormatterTestHelper,
0, result_object[S_MSG_PARAMS]["syncMsgVersion"]["minorVersion"].asInt());
EXPECT_EQ(
0, result_object[S_MSG_PARAMS]["syncMsgVersion"]["patchVersion"].asInt());
-
- // Uncomment code to print object in console
- // std::string str;
- // AnyObjectToJsonString(result_object, str);
- // printf("result_object %s", str.c_str());
}
TEST_F(CMetaFormatterTestHelper, ObjectWithEmptyMap) {
@@ -191,11 +165,6 @@ TEST_F(CMetaFormatterTestHelper, ObjectWithEmptyMap) {
EXPECT_EQ(SmartType_Map, result_object_empty_map.getType())
<< "smartObject is not map type";
EXPECT_EQ(0u, result_object_empty_map.length()) << "non empty map";
-
- // Uncomment code to print object in console
- // std::string str;
- // AnyObjectToJsonString(result_object_empty_map, str);
- // printf("result_object(empty map) %s", str.c_str());
}
TEST_F(CMetaFormatterTestHelper, ObjectWithEmptyArray) {
@@ -233,11 +202,6 @@ TEST_F(CMetaFormatterTestHelper, ObjectWithEmptyArray) {
EXPECT_EQ(SmartType_Array, result_object_empty_array.getType())
<< "smartObject is not array type";
EXPECT_EQ(0u, result_object_empty_array.length()) << "non empty array";
-
- // Uncomment code to print object in console
- // std::string str;
- // AnyObjectToJsonString(result_object_empty_array, str);
- // printf("result_object(empty array) %s", str.c_str());
}
TEST_F(CMetaFormatterTestHelper,
@@ -325,13 +289,6 @@ TEST_F(CMetaFormatterTestHelper,
CMetaFormatter::CreateObjectByPattern(object, schema, result_object);
- // Uncomment code to print object in console
- // std::string str;
- // AnyObjectToJsonString(object, str);
- // printf("object %s", str.c_str());
- // AnyObjectToJsonString(result_object, str);
- // printf("result_object %s", str.c_str());
-
// Assert
EXPECT_EQ(500, result_object[S_PARAMS][S_FUNCTION_ID].asInt());
EXPECT_EQ(-1, result_object[S_PARAMS][S_MESSAGE_TYPE].asInt());
diff --git a/src/components/formatters/test/src/create_smartSchema.cc b/src/components/formatters/test/src/create_smartSchema.cc
index 4ae692429c..1497fbf281 100644
--- a/src/components/formatters/test/src/create_smartSchema.cc
+++ b/src/components/formatters/test/src/create_smartSchema.cc
@@ -339,7 +339,6 @@ CSmartSchema initSchemaForMetaFormatter() {
ISchemaItemPtr majorVersion_SchemaItem = TNumberSchemaItem<int>::create();
ISchemaItemPtr minorVersion_SchemaItem = TNumberSchemaItem<int>::create();
ISchemaItemPtr patchVersion_SchemaItem = TNumberSchemaItem<int>::create();
-
ISchemaItemPtr syncMsg_SchemaItem =
CStringSchemaItem::create(TSchemaItemParameter<size_t>(0),
TSchemaItemParameter<size_t>(1000),
diff --git a/src/components/formatters/test/src/meta_formatter_test_helper.cc b/src/components/formatters/test/src/meta_formatter_test_helper.cc
index a29c1bceb3..897c8d364d 100644
--- a/src/components/formatters/test/src/meta_formatter_test_helper.cc
+++ b/src/components/formatters/test/src/meta_formatter_test_helper.cc
@@ -109,17 +109,6 @@ void CMetaFormatterTestHelper::
obj[S_MSG_PARAMS]["languageDesired"] = Language::EN_EU;
obj[S_MSG_PARAMS]["hmiDisplayLanguageDesired"] = Language::RU_RU;
obj[S_MSG_PARAMS]["appID"] = "APP ID";
-
- // Commented not mandatory params for check creation object without them
- // obj[S_MSG_PARAMS]["ttsName"][0]["text"] = "ABC";
- // obj[S_MSG_PARAMS]["ttsName"][0]["type"] =
- // SpeechCapabilities::SC_TEXT;
-
- // obj[S_MSG_PARAMS]["vrSynonyms"][0] = "Synonym1";
- // obj[S_MSG_PARAMS]["vrSynonyms"][1] = "Synonym2";
-
- // obj[S_MSG_PARAMS]["appType"][0] = AppTypeTest::SYSTEM; // not mandatory
- // obj[S_MSG_PARAMS]["appType"][1] = AppTypeTest::MEDIA;
}
void CMetaFormatterTestHelper::FillObjectWithoutSomeMandatoryFields(
@@ -130,11 +119,6 @@ void CMetaFormatterTestHelper::FillObjectWithoutSomeMandatoryFields(
obj[S_PARAMS][S_PROTOCOL_VERSION] = 1;
obj[S_PARAMS][S_PROTOCOL_TYPE] = 0;
- // Commented mandatory params for check creation object without them
- // obj[S_PARAMS][S_CORRELATION_ID] = 12;
- // obj[S_MSG_PARAMS]["syncMsgVersion"]["majorVersion"] = 2;
- // obj[S_MSG_PARAMS]["syncMsgVersion"]["minorVersion"] = 10;
-
obj[S_MSG_PARAMS]["appName"] = "APP NAME";
obj[S_MSG_PARAMS]["ttsName"][0]["text"] = "ABC";
obj[S_MSG_PARAMS]["ttsName"][0]["type"] = SpeechCapabilities::SC_TEXT;
@@ -200,17 +184,6 @@ void CMetaFormatterTestHelper::FillObjectWithDefaultValues(SmartObject& obj) {
obj[S_MSG_PARAMS]["languageDesired"] = -1;
obj[S_MSG_PARAMS]["hmiDisplayLanguageDesired"] = -1;
obj[S_MSG_PARAMS]["appID"] = "";
-
- // Commented params for check creation object with only default values
- // obj[S_MSG_PARAMS]["ttsName"][0]["text"] = "ABC";
- // obj[S_MSG_PARAMS]["ttsName"][0]["type"] =
- // SpeechCapabilities::SC_TEXT;
-
- // obj[S_MSG_PARAMS]["vrSynonyms"][0] = "Synonym1";
- // obj[S_MSG_PARAMS]["vrSynonyms"][1] = "Synonym2";
-
- // obj[S_MSG_PARAMS]["appType"][0] = AppTypeTest::SYSTEM;
- // obj[S_MSG_PARAMS]["appType"][1] = AppTypeTest::MEDIA;
}
} // namespace formatters
diff --git a/src/components/functional_module/CMakeLists.txt b/src/components/functional_module/CMakeLists.txt
new file mode 100644
index 0000000000..07db91fc38
--- /dev/null
+++ b/src/components/functional_module/CMakeLists.txt
@@ -0,0 +1,58 @@
+if (ENABLE_GCOV)
+ set(GCOV_FLAGS "-ftest-coverage -fprofile-arcs")
+else()
+ set(GCOV_FLAGS "")
+endif()
+
+set(CMAKE_CXX_FLAGS "-fPIC -std=gnu++0x -Wno-deprecated-declarations -Wall -Werror ${GCOV_FLAGS}")
+
+if (CMAKE_BUILD_TYPE)
+ if (${CMAKE_BUILD_TYPE} STREQUAL "Release")
+ set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
+ set(CMAKE_CXX_FLAGS_DEBUG "")
+ else ()
+ set(CMAKE_CXX_FLAGS_RELEASE "")
+ set(CMAKE_CXX_FLAGS_DEBUG "-g3 -ggdb3 -DDEBUG")
+ endif()
+endif()
+
+set(GCOV gcov)
+
+include_directories (
+ ${COMPONENTS_DIR}/functional_module/include/
+ ${COMPONENTS_DIR}/remote_control/include/
+ ${COMPONENTS_DIR}/include/
+ ${COMPONENTS_DIR}/application_manager/include
+ ${COMPONENTS_DIR}/connection_handler/include/
+ ${COMPONENTS_DIR}/utils/include
+ ${POLICY_PATH}/include/
+ ${POLICY_GLOBAL_INCLUDE_PATH}/
+ ${COMPONENTS_DIR}/config_profile/include
+ ${COMPONENTS_DIR}/smart_objects/include
+ ${JSONCPP_INCLUDE_DIRECTORY}
+ ${LOG4CXX_INCLUDE_DIRECTORY}
+ ${CMAKE_BINARY_DIR}/src/components/
+
+ ${COMPONENTS_DIR}/application_manager/test/include/
+)
+
+set (SOURCES
+ ./src/generic_module.cc
+ ./src/plugin_manager.cc
+ ./src/timer/timer_director.cc
+)
+set (LIBRARIES
+ ApplicationManager
+ jsoncpp
+)
+
+add_library("FunctionalModule" ${SOURCES})
+target_link_libraries("FunctionalModule" ${LIBRARIES} )
+
+if(ENABLE_LOG)
+ target_link_libraries("FunctionalModule" log4cxx -L${LOG4CXX_LIBS_DIRECTORY} ${GCOV})
+endif()
+
+if(BUILD_TESTS)
+ add_subdirectory(test)
+endif()
diff --git a/src/components/functional_module/include/functional_module/function_ids.h b/src/components/functional_module/include/functional_module/function_ids.h
new file mode 100644
index 0000000000..1a504df6c9
--- /dev/null
+++ b/src/components/functional_module/include/functional_module/function_ids.h
@@ -0,0 +1,63 @@
+/*
+ * 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_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_FUNCTION_IDS_H_
+#define SRC_COMPONENTS_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_FUNCTION_IDS_H_
+#include "interfaces/MOBILE_API.h"
+#include "interfaces/HMI_API.h"
+
+namespace functional_modules {
+
+enum RCFunctionID {
+ // Remote SDL functions ids
+ BUTTON_PRESS = mobile_apis::FunctionID::ButtonPressID,
+ GET_INTERIOR_VEHICLE_DATA = mobile_apis::FunctionID::GetInteriorVehicleDataID,
+ SET_INTERIOR_VEHICLE_DATA = mobile_apis::FunctionID::SetInteriorVehicleDataID,
+ ON_INTERIOR_VEHICLE_DATA = mobile_apis::FunctionID::OnInteriorVehicleDataID,
+ ON_REMOTE_CONTROL_SETTINGS = hmi_apis::FunctionID::RC_OnRemoteControlSettings,
+};
+
+namespace hmi_api {
+const char get_interior_vehicle_data[] = "RC.GetInteriorVehicleData";
+const char set_interior_vehicle_data[] = "RC.SetInteriorVehicleData";
+const char on_interior_vehicle_data[] = "RC.OnInteriorVehicleData";
+const char button_press[] = "Buttons.ButtonPress";
+const char on_remote_control_settings[] = "RC.OnRemoteControlSettings";
+
+const char get_user_consent[] = "RC.GetInteriorVehicleDataConsent";
+const char on_app_deactivated[] = "BasicCommunication.OnAppDeactivated";
+const char sdl_activate_app[] = "SDL.ActivateApp";
+}
+
+} // namespace functional_modules
+
+#endif // SRC_COMPONENTS_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_FUNCTION_IDS_H_
diff --git a/src/components/functional_module/include/functional_module/generic_module.h b/src/components/functional_module/include/functional_module/generic_module.h
new file mode 100644
index 0000000000..0c686d3501
--- /dev/null
+++ b/src/components/functional_module/include/functional_module/generic_module.h
@@ -0,0 +1,179 @@
+/*
+ * 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_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_GENERIC_MODULE_H_
+#define SRC_COMPONENTS_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_GENERIC_MODULE_H_
+
+#include <deque>
+#include <string>
+#include "functional_module/module_observer.h"
+#include "functional_module/function_ids.h"
+#include "utils/shared_ptr.h"
+#include "application_manager/service.h"
+
+namespace functional_modules {
+
+/**
+ * @brief The PolicyEvent enum defines events related to policy
+ */
+enum PolicyEvent { kApplicationPolicyUpdated = 0, kApplicationsDisabled };
+
+/**
+ * @brief The ApplicationEvent enum defines events related to single application
+ */
+enum ApplicationEvent { kApplicationExit = 0, kApplicationUnregistered };
+
+enum ProcessResult {
+ NONE = -1,
+ PROCESSED,
+ PARTIALLY_PROCESSED,
+ CANNOT_PROCESS,
+ FAILED
+};
+
+enum ServiceState { IDLE = 0, SUSPENDED, LOWVOLTAGE, HMI_ADAPTER_INITIALIZED };
+
+typedef std::string HMIFunctionID;
+
+class GenericModule;
+typedef utils::SharedPtr<GenericModule> ModulePtr;
+
+struct PluginInfo {
+ std::string name;
+ int version;
+ std::deque<RCFunctionID> rc_function_list;
+ std::deque<HMIFunctionID> hmi_function_list;
+};
+
+class GenericModule {
+ public:
+ typedef std::deque<ModuleObserver*> Observers;
+
+ virtual ~GenericModule();
+ ModuleID GetModuleID() const {
+ return kModuleId_;
+ }
+ virtual PluginInfo GetPluginInfo() const = 0;
+
+ /**
+ * @brief Setter for service (interface for plugin t access SDL functionality)
+ * @param service pointer to new service instance
+ */
+ virtual void set_service(application_manager::ServicePtr service);
+
+ /**
+ * @brief Returns pointer to SDL core service interface
+ * @return pointer to core service interface
+ */
+ virtual application_manager::ServicePtr service();
+
+ virtual ProcessResult ProcessMessage(application_manager::MessagePtr msg) = 0;
+ virtual ProcessResult ProcessHMIMessage(
+ application_manager::MessagePtr msg) = 0;
+ virtual void OnServiceStateChanged(ServiceState state);
+
+ /**
+ * @brief Adds pointer to observer of module to be notified about
+ * exceptional sutiations in module.
+ * Raw pointer is passed to avoid circular dependencies.
+ * Module is not responsible for freeing observer's memory.
+ */
+ void AddObserver(ModuleObserver* const observer);
+
+ /**
+ * @brief Removes pointer to observer of module when it's no loger
+ * wants to be notified about exceptional sutiations in module.
+ * Raw pointer is passed to avoid circular dependencies.
+ * Module is not responsible for freeing observer's memory.
+ */
+ void RemoveObserver(ModuleObserver* const observer);
+
+ /**
+ * @brief Remove extension created for specified application
+ * @param app_id application id
+ */
+ virtual void RemoveAppExtension(uint32_t app_id) = 0;
+
+ /**
+ * @brief Check registering app can be handled by plugin
+ * @param msg Registration message
+ * @param app Application basis already create by Core
+ */
+ virtual bool IsAppForPlugin(
+ application_manager::ApplicationSharedPtr app) = 0;
+
+ /**
+ * @brief Notify about change of HMILevel of plugin's app
+ * @param app App with new HMILevel
+ * @param old_level Old HMILevel of app
+ */
+ virtual void OnAppHMILevelChanged(
+ application_manager::ApplicationSharedPtr app,
+ mobile_apis::HMILevel::eType old_level) = 0;
+
+ /**
+ * @brief OnApplicationEvent Processes application related events
+ * @param event Event
+ * @param application_id Application id
+ */
+ virtual void OnApplicationEvent(ApplicationEvent event,
+ const uint32_t application_id) = 0;
+
+ /**
+ * @brief OnPolicyEvent Processes policy related events
+ * @param event Policy event
+ */
+ virtual void OnPolicyEvent(PolicyEvent event) = 0;
+
+ protected:
+ explicit GenericModule(ModuleID module_id);
+ void NotifyObservers(ModuleObserver::Errors error);
+
+ /**
+ * @brief Remove extension for all applications
+ */
+ virtual void RemoveAppExtensions() = 0;
+
+ private:
+ application_manager::ServicePtr service_;
+ const ModuleID kModuleId_;
+
+ Observers observers_;
+ ServiceState state_;
+
+ friend class DriverGenericModuleTest;
+ DISALLOW_COPY_AND_ASSIGN(GenericModule);
+};
+
+} // namespace functional_modules
+
+#endif // SRC_COMPONENTS_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_GENERIC_MODULE_H_
diff --git a/src/components/functional_module/include/functional_module/module_observer.h b/src/components/functional_module/include/functional_module/module_observer.h
new file mode 100644
index 0000000000..a5e34db040
--- /dev/null
+++ b/src/components/functional_module/include/functional_module/module_observer.h
@@ -0,0 +1,54 @@
+/*
+ * 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_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_MODULE_OBSERVER_H_
+#define SRC_COMPONENTS_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_MODULE_OBSERVER_H_
+
+namespace functional_modules {
+
+typedef int ModuleID;
+
+class ModuleObserver {
+ public:
+ enum Errors { NONE = -1, OUT_OF_MEMORY, FS_FAILURE };
+ virtual ~ModuleObserver() {}
+
+ /**
+ * @brief OnError callback for module to notify SDL about internal error
+ * @param error error type
+ * @param module_id module that triggered error
+ */
+ virtual void OnError(Errors error, ModuleID module_id) = 0;
+};
+} // namespace functional_modules {
+
+#endif // SRC_COMPONENTS_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_MODULE_OBSERVER_H_
diff --git a/src/components/functional_module/include/functional_module/plugin_manager.h b/src/components/functional_module/include/functional_module/plugin_manager.h
new file mode 100644
index 0000000000..1fb5ac9838
--- /dev/null
+++ b/src/components/functional_module/include/functional_module/plugin_manager.h
@@ -0,0 +1,158 @@
+/*
+ * 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_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_PLUGIN_MANAGER_H_
+#define SRC_COMPONENTS_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_PLUGIN_MANAGER_H_
+
+#include <map>
+#include <string>
+#include "functional_module/generic_module.h"
+#include "application_manager/service.h"
+#include "application_manager/message.h"
+
+namespace functional_modules {
+
+class PluginManager : public ModuleObserver {
+ public:
+ PluginManager();
+ ~PluginManager();
+ typedef std::map<ModuleID, ModulePtr> Modules;
+
+ /**
+ * @brief LoadPlugins initialize loading plugins
+ * @param plugin_path path to search to plugin shared libraries
+ * @return count of loaded plugins
+ */
+ int LoadPlugins(const std::string& plugin_path);
+
+ /**
+ * @brief UnloadPlugins unload from memory all plugins
+ */
+ void UnloadPlugins();
+
+ /**
+ * @brief IsMessageForPlugin Verifies whether mobile message will be processed
+ * by plugins
+ * @param msg Mobile message
+ * @return True if any of plugins will process the message, otherwise - false
+ */
+ bool IsMessageForPlugin(application_manager::MessagePtr msg);
+
+ /**
+ * @brief IsHMIMessageForPlugin Verifies whether HMI message will be processed
+ * by plugins
+ * @param msg HMI message
+ * @return True if any of plugins will process the message, otherwise - false
+ */
+ bool IsHMIMessageForPlugin(application_manager::MessagePtr msg);
+
+ /**
+ * @brief ProcessMessage forwards mobile message to modules if any is
+ * subsribed for the message.
+ * @param msg Mobile message to process
+ * @return Result of processing
+ */
+ ProcessResult ProcessMessage(application_manager::MessagePtr msg);
+
+ /**
+ * @brief ProcessHMIMessage forwards HMI message to modules if any is
+ * subscribed for the message
+ * @param msg HMI message to process
+ * @return Result of processing
+ */
+ ProcessResult ProcessHMIMessage(application_manager::MessagePtr msg);
+ void SetServiceHandler(application_manager::ServicePtr service) {
+ service_ = service;
+ }
+ void OnServiceStateChanged(ServiceState state);
+ void OnError(ModuleObserver::Errors error, ModuleID module_id) FINAL;
+
+ /**
+ * @brief Remove extension created for specified application
+ * @param app_id application id
+ */
+ void RemoveAppExtension(uint32_t app_id);
+
+ /**
+ * @brief Check if app cooperates with one or more plugins, init it
+ * inside plugin accordingly if needed.
+ * @param app Application in question.
+ */
+ bool IsAppForPlugins(application_manager::ApplicationSharedPtr app);
+
+ /**
+ * Check if app cooperates with plugin
+ * @param app application
+ * @param module_id unique identifier of plugin
+ * @return true if application cooperates with this plugin
+ */
+ bool IsAppForPlugin(application_manager::ApplicationSharedPtr app,
+ ModuleID module_id) const;
+
+ /**
+ * @brief Notify plugins about change of HMILevel of app
+ * if app is related to plugin
+ * @param app App with new HMILevel
+ * @param old_level Old HMILevel of app
+ */
+ void OnAppHMILevelChanged(application_manager::ApplicationSharedPtr app,
+ mobile_apis::HMILevel::eType old_level);
+
+ /**
+ * @brief OnApplicationEvent Notifies modules on certain application events
+ * @param event Event
+ * @param application_id Application id of particular application
+ */
+ void OnApplicationEvent(functional_modules::ApplicationEvent event,
+ const uint32_t application_id);
+
+ /**
+ * @brief OnPolicyEvent Notifies modules on certain events from policy
+ * @param event Policy event
+ */
+ void OnPolicyEvent(functional_modules::PolicyEvent event);
+
+ Modules& plugins();
+
+ private:
+ Modules plugins_;
+ std::map<ModuleID, void*> dlls_;
+ std::map<RCFunctionID, ModulePtr> mobile_subscribers_;
+ std::map<HMIFunctionID, ModulePtr> hmi_subscribers_;
+ application_manager::ServicePtr service_;
+
+ DISALLOW_COPY_AND_ASSIGN(PluginManager);
+};
+
+} // namespace functional_modules
+
+#endif // SRC_COMPONENTS_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_PLUGIN_MANAGER_H_
diff --git a/src/components/functional_module/include/functional_module/timer/module_timer.h b/src/components/functional_module/include/functional_module/timer/module_timer.h
new file mode 100644
index 0000000000..e24259241b
--- /dev/null
+++ b/src/components/functional_module/include/functional_module/timer/module_timer.h
@@ -0,0 +1,246 @@
+/*
+ * 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_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_TIMER_MODULE_TIMER_H_
+#define SRC_COMPONENTS_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_TIMER_MODULE_TIMER_H_
+
+#include <list>
+#include <deque>
+#include <algorithm>
+#include <time.h>
+#include "utils/lock.h"
+
+namespace functional_modules {
+
+typedef unsigned int TimeUnit; // seconds
+
+class Trackable {
+ public:
+ Trackable() : start_time_(0) {}
+ virtual ~Trackable() {}
+
+ /**
+ * @brief custom_interval getter for custom interval
+ * @return return timer interval for trackable message
+ */
+ virtual TimeUnit custom_interval() const {
+ return 0;
+ }
+
+ /**
+ * @brief start_time getter for start time of message
+ * @return start time of message
+ */
+ virtual TimeUnit start_time() const {
+ return start_time_;
+ }
+
+ /**
+ * @brief set_start_time setting start time of message
+ * @param start_time start time
+ */
+ virtual void set_start_time(TimeUnit start_time) {
+ start_time_ = start_time;
+ }
+
+ private:
+ TimeUnit start_time_;
+};
+
+template <class Trackable>
+class TimerObserver {
+ public:
+ virtual ~TimerObserver() {}
+ virtual void OnTimeoutTriggered(const Trackable& expired) = 0;
+};
+
+template <class Trackable>
+class ModuleTimer {
+ public:
+ ModuleTimer();
+ ~ModuleTimer();
+ void set_period(TimeUnit period) {
+ period_ = period;
+ }
+ TimeUnit period() const {
+ return period_;
+ }
+ void AddObserver(TimerObserver<Trackable>* observer);
+ void RemoveObserver(TimerObserver<Trackable>* observer);
+
+ void CheckTimeout();
+ /**
+ * @brief Gets time in seconds when the nearest request timeout will be
+ * triggered
+ * @return time in seconds when the nearest request timeout will be triggered
+ */
+ TimeUnit GetSecondsToNearestTimeout();
+
+ /*
+ * @brief Adds object to be tracked by timer.
+ If same object is already added replaces it with new one
+ correspondingly updating start time of tracking.
+ */
+ void AddTrackable(const Trackable& object);
+ void RemoveTrackable(const Trackable& object);
+
+ protected:
+ void Notify(const Trackable& object);
+ void OnTimeout(const Trackable& object);
+ TimeUnit CurrentTime() const;
+ typename std::list<Trackable> trackables_;
+ volatile TimeUnit period_;
+
+ private:
+ std::deque<TimerObserver<Trackable>*> observers_;
+ mutable sync_primitives::Lock trackables_lock_;
+ friend class ModuleTimerTest;
+};
+
+template <class Trackable>
+ModuleTimer<Trackable>::ModuleTimer()
+ : period_(10) {}
+
+template <class Trackable>
+ModuleTimer<Trackable>::~ModuleTimer() {
+ observers_.clear();
+ sync_primitives::AutoLock auto_lock(trackables_lock_);
+ trackables_.clear();
+}
+
+template <class Trackable>
+void ModuleTimer<Trackable>::AddObserver(TimerObserver<Trackable>* observer) {
+ DCHECK(observer);
+ if (!observer) {
+ return;
+ }
+ observers_.push_back(observer);
+}
+
+template <class Trackable>
+void ModuleTimer<Trackable>::RemoveObserver(
+ TimerObserver<Trackable>* observer) {
+ DCHECK(observer);
+ if (!observer) {
+ return;
+ }
+ for (typename std::deque<TimerObserver<Trackable>*>::iterator it =
+ observers_.begin();
+ observers_.end() != it;
+ ++it) {
+ if (*it == observer) {
+ observers_.erase(it);
+ return;
+ }
+ }
+}
+
+template <class Trackable>
+void ModuleTimer<Trackable>::CheckTimeout() {
+ sync_primitives::AutoLock trackables_lock(trackables_lock_);
+ for (typename std::list<Trackable>::iterator it = trackables_.begin();
+ trackables_.end() != it;
+ ++it) {
+ TimeUnit period = it->custom_interval();
+ if (!period) {
+ period = period_;
+ }
+ if (CurrentTime() - it->start_time() >= period) {
+ OnTimeout(*it);
+ it = trackables_.erase(it);
+ }
+ }
+}
+
+template <class Trackable>
+TimeUnit ModuleTimer<Trackable>::GetSecondsToNearestTimeout() {
+ sync_primitives::AutoLock trackables_lock(trackables_lock_);
+ TimeUnit result = period_;
+ for (typename std::list<Trackable>::iterator it = trackables_.begin();
+ trackables_.end() != it;
+ ++it) {
+ TimeUnit period = it->custom_interval();
+ if (!period) {
+ period = period_;
+ }
+ const TimeUnit current_secs_to_timeout =
+ period - (CurrentTime() - it->start_time());
+ if (result > current_secs_to_timeout) {
+ result = current_secs_to_timeout;
+ }
+ }
+ return result;
+}
+
+template <class Trackable>
+void ModuleTimer<Trackable>::AddTrackable(const Trackable& object) {
+ sync_primitives::AutoLock trackables_lock(trackables_lock_);
+ trackables_.remove(object);
+ trackables_.push_back(object);
+ trackables_.back().set_start_time(CurrentTime());
+}
+
+template <class Trackable>
+void ModuleTimer<Trackable>::RemoveTrackable(const Trackable& object) {
+ sync_primitives::AutoLock trackables_lock(trackables_lock_);
+ trackables_.remove(object);
+}
+
+template <class Trackable>
+void ModuleTimer<Trackable>::Notify(const Trackable& object) {
+ for (typename std::deque<TimerObserver<Trackable>*>::const_iterator it =
+ observers_.begin();
+ observers_.end() != it;
+ ++it) {
+ (*it)->OnTimeoutTriggered(object);
+ }
+}
+
+template <class Trackable>
+void ModuleTimer<Trackable>::OnTimeout(const Trackable& object) {
+ Notify(object);
+}
+
+template <class Trackable>
+TimeUnit ModuleTimer<Trackable>::CurrentTime() const {
+ // TODO(PV): move outside to platform-dependant parts
+ struct timespec current_time;
+ if (0 == clock_gettime(CLOCK_MONOTONIC, &current_time)) {
+ return current_time.tv_sec;
+ } else {
+ return 0;
+ }
+}
+
+} // namespace functional_modules
+
+#endif // SRC_COMPONENTS_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_TIMER_MODULE_TIMER_H_
diff --git a/src/components/functional_module/include/functional_module/timer/timer_director.h b/src/components/functional_module/include/functional_module/timer/timer_director.h
new file mode 100644
index 0000000000..fb67b9b5de
--- /dev/null
+++ b/src/components/functional_module/include/functional_module/timer/timer_director.h
@@ -0,0 +1,92 @@
+/*
+ * 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_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_TIMER_TIMER_DIRECTOR_H_
+#define SRC_COMPONENTS_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_TIMER_TIMER_DIRECTOR_H_
+
+#include <map>
+#include "utils/threads/thread.h"
+#include "utils/conditional_variable.h"
+#include "functional_module/timer/module_timer.h"
+
+namespace functional_modules {
+
+template <class T>
+class TimerThreadDelegate : public threads::ThreadDelegate {
+ public:
+ explicit TimerThreadDelegate(ModuleTimer<T>& timer);
+ void threadMain();
+ void exitThreadMain();
+
+ /**
+ * @brief Reset awaiting timer by notifying cond var
+ */
+ void ResetTimer();
+
+ private:
+ ModuleTimer<T>& timer_;
+ volatile bool keep_running_;
+ mutable sync_primitives::Lock keep_running_lock_;
+ mutable sync_primitives::ConditionalVariable keep_running_cond_;
+ friend class TimerThreadDelegateTest;
+};
+
+class TimerDirector {
+ public:
+ TimerDirector();
+ ~TimerDirector();
+
+ /**
+ * @brief Register timer for execution in separate thread.
+ Registers only one timer of a type. Attempt to register timer
+ of already existing type will fail.
+ */
+ template <class T>
+ void RegisterTimer(ModuleTimer<T>& timer);
+ template <class T>
+ void UnregisterTimer(const ModuleTimer<T>& timer);
+ void UnregisterAllTimers();
+ /**
+ * @brief Reset awaiting timeout for specified module timer
+ * @param timer timer to reset awaiting timeout
+ */
+ template <class T>
+ void ResetTimer(ModuleTimer<T>& timer);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(TimerDirector);
+ std::map<std::string, threads::Thread*> timer_threads_;
+};
+
+} // namespace functional_modules
+
+#endif // SRC_COMPONENTS_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_TIMER_TIMER_DIRECTOR_H_
diff --git a/src/components/functional_module/src/generic_module.cc b/src/components/functional_module/src/generic_module.cc
new file mode 100644
index 0000000000..142b1ef58c
--- /dev/null
+++ b/src/components/functional_module/src/generic_module.cc
@@ -0,0 +1,54 @@
+#include "functional_module/generic_module.h"
+namespace functional_modules {
+
+typedef std::deque<ModuleObserver*>::iterator ModuleObserverIterator;
+
+GenericModule::GenericModule(ModuleID module_id)
+ : kModuleId_(module_id), state_(ServiceState::IDLE) {}
+
+GenericModule::~GenericModule() {
+ observers_.clear();
+}
+
+void GenericModule::AddObserver(ModuleObserver* const observer) {
+ DCHECK(observer);
+ if (!observer) {
+ return;
+ }
+ observers_.push_back(observer);
+}
+
+void GenericModule::RemoveObserver(ModuleObserver* const observer) {
+ DCHECK(observer);
+ if (!observer) {
+ return;
+ }
+ for (ModuleObserverIterator it = observers_.begin(); observers_.end() != it;
+ ++it) {
+ if (*it == observer) {
+ observers_.erase(it);
+ return;
+ }
+ }
+}
+
+void GenericModule::NotifyObservers(ModuleObserver::Errors error) {
+ for (ModuleObserverIterator it = observers_.begin(); observers_.end() != it;
+ ++it) {
+ (*it)->OnError(error, kModuleId_);
+ }
+}
+
+void GenericModule::set_service(application_manager::ServicePtr service) {
+ service_ = service;
+}
+
+void GenericModule::OnServiceStateChanged(ServiceState state) {
+ state_ = state;
+}
+
+application_manager::ServicePtr GenericModule::service() {
+ return service_;
+}
+
+} // namespace functional_modules
diff --git a/src/components/functional_module/src/plugin_manager.cc b/src/components/functional_module/src/plugin_manager.cc
new file mode 100644
index 0000000000..b38048f843
--- /dev/null
+++ b/src/components/functional_module/src/plugin_manager.cc
@@ -0,0 +1,393 @@
+/*
+ * 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.
+ */
+
+#include <dlfcn.h>
+#include <algorithm>
+#include "functional_module/plugin_manager.h"
+#include "functional_module/function_ids.h"
+#include "protocol/common.h"
+#include "utils/file_system.h"
+#include "utils/logger.h"
+#include "json/json.h"
+
+namespace functional_modules {
+
+CREATE_LOGGERPTR_GLOBAL(logger_, "PluginManager")
+
+namespace {
+const std::string ExtractMethodName(application_manager::MessagePtr msg) {
+ DCHECK_OR_RETURN(msg, "");
+ Json::Value value;
+ Json::Reader reader;
+ reader.parse(msg->json_message(), value);
+
+ const char* kMethod = "method";
+ const char* kResult = "result";
+ const char* kError = "error";
+ const char* kData = "data";
+
+ if (value.isMember(kMethod)) {
+ return value.get(kMethod, "").asCString();
+ }
+ if (value.isMember(kResult)) {
+ const Json::Value& result = value.get(kResult, Json::Value());
+ return result.get(kMethod, "").asCString();
+ }
+ if (value.isMember(kError)) {
+ const Json::Value& error = value.get(kError, Json::Value());
+ const Json::Value& data = error.get(kData, Json::Value());
+ return data.get(kMethod, "").asCString();
+ }
+
+ return std::string();
+}
+} // namespace
+
+typedef std::map<ModuleID, ModulePtr>::iterator PluginsIterator;
+typedef std::map<RCFunctionID, ModulePtr>::iterator PluginFunctionsIterator;
+typedef std::map<HMIFunctionID, ModulePtr>::iterator PluginHMIFunctionsIterator;
+
+PluginManager::PluginManager() : service_() {
+ LOG4CXX_DEBUG(logger_, "Creating plugin mgr");
+}
+
+PluginManager::~PluginManager() {
+ mobile_subscribers_.clear();
+ hmi_subscribers_.clear();
+ UnloadPlugins();
+}
+
+int PluginManager::LoadPlugins(const std::string& plugin_path) {
+ LOG4CXX_INFO(logger_, "Loading plugins from " << plugin_path);
+ std::vector<std::string> plugin_files = file_system::ListFiles(plugin_path);
+ for (size_t i = 0; i < plugin_files.size(); ++i) {
+ size_t pos = plugin_files[i].find_last_of(".");
+ if (std::string::npos != pos) {
+ if (plugin_files[i].substr(pos + 1).compare("so") != 0) {
+ continue;
+ }
+ } else {
+ continue;
+ }
+ std::string full_name = plugin_path + '/' + plugin_files[i];
+ void* generic_plugin_dll = dlopen(full_name.c_str(), RTLD_LAZY);
+ if (NULL == generic_plugin_dll) {
+ LOG4CXX_ERROR(logger_,
+ "Failed to open dll " << plugin_files[i] << "\n"
+ << dlerror());
+ continue;
+ }
+ typedef GenericModule* (*Create)();
+ Create create_manager =
+ reinterpret_cast<Create>(dlsym(generic_plugin_dll, "Create"));
+ char* error_string = dlerror();
+ if (NULL != error_string) {
+ LOG4CXX_ERROR(logger_,
+ "Failed to export dll's " << plugin_files[i] << " symbols\n"
+ << error_string);
+ dlclose(generic_plugin_dll);
+ continue;
+ }
+ ModulePtr module = create_manager();
+ if (!module) {
+ LOG4CXX_ERROR(logger_,
+ "Failed to create plugin main class " << plugin_files[i]);
+ dlclose(generic_plugin_dll);
+ continue;
+ } else {
+ LOG4CXX_DEBUG(logger_,
+ "Opened and working plugin from " << plugin_files[i]
+ << " with id "
+ << module->GetModuleID());
+ dlls_.insert(std::pair<ModuleID, void*>(module->GetModuleID(),
+ generic_plugin_dll));
+ plugins_.insert(
+ std::pair<ModuleID, ModulePtr>(module->GetModuleID(), module));
+ std::deque<RCFunctionID> subscribers =
+ module->GetPluginInfo().rc_function_list;
+ for (size_t i = 0; i < subscribers.size(); ++i) {
+ mobile_subscribers_.insert(
+ std::pair<RCFunctionID, ModulePtr>(subscribers[i], module));
+ }
+
+ std::deque<HMIFunctionID> hmi_subscribers =
+ module->GetPluginInfo().hmi_function_list;
+ for (size_t i = 0; i < hmi_subscribers.size(); ++i) {
+ hmi_subscribers_.insert(
+ std::pair<HMIFunctionID, ModulePtr>(hmi_subscribers[i], module));
+ }
+ module->set_service(service_);
+ module->AddObserver(this);
+ }
+ }
+ return plugins_.size();
+}
+
+void PluginManager::UnloadPlugins() {
+ for (Modules::iterator it = plugins_.begin(); plugins_.end() != it; ++it) {
+ it->second->RemoveObserver(this);
+ }
+ plugins_.clear();
+
+ for (std::map<ModuleID, void*>::iterator it = dlls_.begin();
+ dlls_.end() != it;
+ ++it) {
+ dlclose(it->second);
+ }
+ dlls_.clear();
+}
+
+bool PluginManager::IsMessageForPlugin(application_manager::MessagePtr msg) {
+ DCHECK(msg);
+ if (!msg) {
+ LOG4CXX_ERROR(logger_, "Null pointer message was received.");
+ return false;
+ }
+ if (protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_UNKNOWN !=
+ msg->protocol_version() &&
+ protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_HMI !=
+ msg->protocol_version()) {
+ RCFunctionID id = static_cast<RCFunctionID>(msg->function_id());
+ return (mobile_subscribers_.find(id) != mobile_subscribers_.end());
+ } else {
+ return false;
+ }
+}
+
+bool PluginManager::IsHMIMessageForPlugin(application_manager::MessagePtr msg) {
+ DCHECK(msg);
+ if (!msg) {
+ LOG4CXX_ERROR(logger_, "Null pointer message was received.");
+ return false;
+ }
+
+ Json::Value value;
+ Json::Reader reader;
+ reader.parse(msg->json_message(), value);
+ if (protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_HMI ==
+ msg->protocol_version()) {
+ std::string msg_method;
+ // Request or notification from HMI
+ if (value.isMember("method") && value["method"].isString()) {
+ msg_method = value["method"].asCString();
+ // Response from HMI
+ } else if (value.isMember("result") && value["result"].isMember("method") &&
+ value["result"]["method"].isString()) {
+ msg_method = value["result"]["method"].asCString();
+ // Error response from HMI
+ } else if (value.isMember("error") && value["error"].isMember("data") &&
+ value["error"]["data"].isMember("method") &&
+ value["error"]["data"]["method"].isString()) {
+ msg_method = value["error"]["data"]["method"].asCString();
+ } else {
+ LOG4CXX_WARN(logger_,
+ "Message with HMI protocol version can not be handled by "
+ "plugin manager, because required 'method' field was not "
+ "found, or was containing an invalid string.");
+ return false;
+ }
+
+ return (hmi_subscribers_.find(msg_method) != hmi_subscribers_.end());
+ }
+
+ return false;
+}
+
+ProcessResult PluginManager::ProcessMessage(
+ application_manager::MessagePtr msg) {
+ DCHECK(msg);
+ if (!msg) {
+ LOG4CXX_ERROR(logger_, "Null pointer message was received.");
+ return ProcessResult::CANNOT_PROCESS;
+ }
+
+ protocol_handler::MajorProtocolVersion version = msg->protocol_version();
+ if (protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_UNKNOWN ==
+ version ||
+ protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_HMI == version) {
+ return ProcessResult::CANNOT_PROCESS;
+ }
+
+ ProcessResult result = ProcessResult::CANNOT_PROCESS;
+ PluginFunctionsIterator subscribed_plugin_itr =
+ mobile_subscribers_.find(static_cast<RCFunctionID>(msg->function_id()));
+ if (mobile_subscribers_.end() != subscribed_plugin_itr) {
+ result = subscribed_plugin_itr->second->ProcessMessage(msg);
+ if (ProcessResult::PROCESSED != result) {
+ LOG4CXX_ERROR(logger_, "Plugin failed to process message.");
+ }
+ }
+
+ return result;
+}
+
+ProcessResult PluginManager::ProcessHMIMessage(
+ application_manager::MessagePtr msg) {
+ DCHECK_OR_RETURN(msg, ProcessResult::CANNOT_PROCESS);
+
+ if (protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_HMI !=
+ msg->protocol_version()) {
+ return ProcessResult::CANNOT_PROCESS;
+ }
+
+ const std::string& msg_method = ExtractMethodName(msg);
+ if (msg_method.empty()) {
+ LOG4CXX_WARN(logger_,
+ "Message with HMI protocol version can not be handled by "
+ "plugin manager, because required 'method' field was not "
+ "found, or was containing an invalid string.");
+ return ProcessResult::CANNOT_PROCESS;
+ }
+
+ LOG4CXX_DEBUG(logger_, "Parsed method name is " << msg_method);
+
+ ProcessResult result = ProcessResult::CANNOT_PROCESS;
+ PluginHMIFunctionsIterator subscribed_plugin_itr =
+ hmi_subscribers_.find(msg_method);
+ if (hmi_subscribers_.end() != subscribed_plugin_itr) {
+ result = subscribed_plugin_itr->second->ProcessHMIMessage(msg);
+ }
+
+ return result;
+}
+
+void PluginManager::OnServiceStateChanged(ServiceState state) {
+ for (PluginsIterator it = plugins_.begin(); plugins_.end() != it; ++it) {
+ it->second->OnServiceStateChanged(state);
+ }
+}
+
+void PluginManager::OnError(ModuleObserver::Errors error, ModuleID module_id) {
+ std::string error_string;
+ switch (error) {
+ case ModuleObserver::Errors::OUT_OF_MEMORY:
+ error_string = "Module run out of memory.";
+ break;
+ case ModuleObserver::Errors::FS_FAILURE:
+ error_string = "Plugin failed to run file system operation.";
+ break;
+ default: {
+ LOG4CXX_ERROR(logger_,
+ "Error " << error_string << " was received from module "
+ << module_id);
+ } break;
+ }
+}
+
+void PluginManager::RemoveAppExtension(uint32_t app_id) {
+ for (PluginsIterator it = plugins_.begin(); plugins_.end() != it; ++it) {
+ it->second->RemoveAppExtension(app_id);
+ }
+}
+
+bool PluginManager::IsAppForPlugins(
+ application_manager::ApplicationSharedPtr app) {
+ DCHECK(app);
+ if (!app) {
+ return false;
+ }
+
+ bool res = false;
+ for (PluginsIterator it = plugins_.begin(); plugins_.end() != it; ++it) {
+ res = res || it->second->IsAppForPlugin(app);
+ }
+ return res;
+}
+
+bool PluginManager::IsAppForPlugin(
+ application_manager::ApplicationSharedPtr app, ModuleID module_id) const {
+ DCHECK_OR_RETURN(app, false);
+ Modules::const_iterator i = plugins_.find(module_id);
+ return i != plugins_.end() ? i->second->IsAppForPlugin(app) : false;
+}
+
+void PluginManager::OnAppHMILevelChanged(
+ application_manager::ApplicationSharedPtr app,
+ mobile_apis::HMILevel::eType old_level) {
+ DCHECK_OR_RETURN_VOID(app);
+ for (PluginsIterator it = plugins_.begin(); plugins_.end() != it; ++it) {
+ if (it->second->IsAppForPlugin(app)) {
+ LOG4CXX_DEBUG(logger_,
+ "Application " << app->name().AsMBString() << " of plugin "
+ << it->second->GetModuleID()
+ << " has changed level from " << old_level
+ << " to " << app->hmi_level());
+ it->second->OnAppHMILevelChanged(app, old_level);
+ }
+ }
+}
+
+typedef std::map<ModuleID, ModulePtr>::value_type PluginsValueType;
+
+struct HandleApplicationEvent {
+ private:
+ const functional_modules::ApplicationEvent event_;
+ const uint32_t app_id_;
+
+ public:
+ HandleApplicationEvent(functional_modules::ApplicationEvent e,
+ const uint32_t app_id)
+ : event_(e), app_id_(app_id) {}
+ void operator()(PluginsValueType& p) {
+ p.second->OnApplicationEvent(event_, app_id_);
+ }
+};
+
+struct HandlePolicyEvent {
+ private:
+ const functional_modules::PolicyEvent event_;
+
+ public:
+ HandlePolicyEvent(functional_modules::PolicyEvent e) : event_(e) {}
+ void operator()(PluginsValueType& p) {
+ p.second->OnPolicyEvent(event_);
+ }
+};
+
+void PluginManager::OnApplicationEvent(
+ functional_modules::ApplicationEvent event, const uint32_t application_id) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ std::for_each(plugins_.begin(),
+ plugins_.end(),
+ HandleApplicationEvent(event, application_id));
+}
+
+void PluginManager::OnPolicyEvent(PolicyEvent event) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ std::for_each(plugins_.begin(), plugins_.end(), HandlePolicyEvent(event));
+}
+
+PluginManager::Modules& PluginManager::plugins() {
+ return plugins_;
+}
+
+} // namespace functional_modules
diff --git a/src/components/functional_module/src/timer/timer_director.cc b/src/components/functional_module/src/timer/timer_director.cc
new file mode 100644
index 0000000000..81ce117851
--- /dev/null
+++ b/src/components/functional_module/src/timer/timer_director.cc
@@ -0,0 +1,156 @@
+/*
+ * 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.
+ */
+#include <typeinfo>
+#include "functional_module/timer/timer_director.h"
+#include "remote_control/rc_module_timer.h"
+#include "utils/logger.h"
+
+namespace functional_modules {
+
+template <class T>
+TimerThreadDelegate<T>::TimerThreadDelegate(ModuleTimer<T>& timer)
+ : timer_(timer), keep_running_(false) {}
+
+template <class T>
+void TimerThreadDelegate<T>::threadMain() {
+ if (keep_running_) {
+ this->exitThreadMain();
+ }
+ {
+ sync_primitives::AutoLock run_lock(keep_running_lock_);
+ keep_running_ = true;
+ }
+ sync_primitives::AutoLock run_lock(keep_running_lock_);
+ while (keep_running_) {
+ const TimeUnit msecs_to_wait = timer_.GetSecondsToNearestTimeout() * 1000;
+ sync_primitives::ConditionalVariable::WaitStatus wait_status =
+ keep_running_cond_.WaitFor(run_lock, msecs_to_wait);
+ if (sync_primitives::ConditionalVariable::kTimeout == wait_status &&
+ keep_running_) {
+ timer_.CheckTimeout();
+ }
+ }
+}
+
+template <class T>
+void TimerThreadDelegate<T>::exitThreadMain() {
+ if (keep_running_) {
+ sync_primitives::AutoLock run_lock(keep_running_lock_);
+ keep_running_ = false;
+ keep_running_cond_.NotifyOne();
+ }
+}
+
+template <class T>
+void TimerThreadDelegate<T>::ResetTimer() {
+ if (keep_running_) {
+ sync_primitives::AutoLock run_lock(keep_running_lock_);
+ keep_running_cond_.NotifyOne();
+ }
+}
+
+TimerDirector::TimerDirector() {}
+
+TimerDirector::~TimerDirector() {
+ UnregisterAllTimers();
+}
+
+template <class T>
+void TimerDirector::RegisterTimer(ModuleTimer<T>& timer) {
+ std::string type_name = typeid(timer).name();
+ std::map<std::string, threads::Thread*>::iterator it =
+ timer_threads_.find(type_name);
+ if (timer_threads_.end() != it) {
+ // Attempt to register timer of already existing type fail.
+ return;
+ }
+ TimerThreadDelegate<T>* delegate = new TimerThreadDelegate<T>(timer);
+ threads::Thread* thread = threads::CreateThread(type_name.c_str(), delegate);
+
+ const size_t kStackSize = 16384;
+ if (thread->start(threads::ThreadOptions(kStackSize))) {
+ timer_threads_.insert(std::make_pair(type_name, thread));
+ } else {
+ // Failed to start timer thread for
+ }
+}
+
+template void TimerDirector::RegisterTimer<remote_control::TrackableMessage>(
+ ModuleTimer<remote_control::TrackableMessage>& timer);
+
+template <class T>
+void TimerDirector::UnregisterTimer(const ModuleTimer<T>& timer) {
+ std::string type_name = typeid(timer).name();
+ std::map<std::string, threads::Thread*>::iterator it =
+ timer_threads_.find(type_name);
+ if (timer_threads_.end() == it) {
+ /// Failed to unregister timer that was not registered
+ return;
+ }
+ threads::ThreadDelegate* delegate = it->second->delegate();
+ DeleteThread(it->second);
+ delete delegate;
+ timer_threads_.erase(it);
+}
+
+template void TimerDirector::UnregisterTimer<remote_control::TrackableMessage>(
+ const ModuleTimer<remote_control::TrackableMessage>& timer);
+
+template <class T>
+void TimerDirector::ResetTimer(ModuleTimer<T>& timer) {
+ const std::string type_name = typeid(timer).name();
+ std::map<std::string, threads::Thread*>::iterator it =
+ timer_threads_.find(type_name);
+ if (timer_threads_.end() == it) {
+ return;
+ }
+ TimerThreadDelegate<T>* delegate =
+ static_cast<TimerThreadDelegate<T>*>(it->second->delegate());
+ delegate->ResetTimer();
+}
+
+template void TimerDirector::ResetTimer<remote_control::TrackableMessage>(
+ ModuleTimer<remote_control::TrackableMessage>& timer);
+
+void TimerDirector::UnregisterAllTimers() {
+ for (std::map<std::string, threads::Thread*>::iterator it =
+ timer_threads_.begin();
+ timer_threads_.end() != it;
+ ++it) {
+ threads::ThreadDelegate* delegate = it->second->delegate();
+ DeleteThread(it->second);
+ delete delegate;
+ }
+ timer_threads_.clear();
+}
+
+} // namespace functional_modules
diff --git a/src/components/functional_module/test/CMakeLists.txt b/src/components/functional_module/test/CMakeLists.txt
new file mode 100644
index 0000000000..c4e966c84e
--- /dev/null
+++ b/src/components/functional_module/test/CMakeLists.txt
@@ -0,0 +1,53 @@
+include_directories (
+ ${LOG4CXX_INCLUDE_DIRECTORY}
+ ${GMOCK_INCLUDE_DIRECTORY}
+ ${CMAKE_SOURCE_DIR}/src/components/functional_module/include/
+ ${CMAKE_SOURCE_DIR}/src/components/include/
+ ${CMAKE_SOURCE_DIR}/src/components/application_manager/include
+ ${CMAKE_SOURCE_DIR}/src/components/connection_handler/include
+ ${CMAKE_SOURCE_DIR}/src/components/utils/include
+ ${CMAKE_SOURCE_DIR}/src/components/policy/include
+ ${CMAKE_SOURCE_DIR}/src/components/smart_objects/include
+ ${JSONCPP_INCLUDE_DIRECTORY}
+ ${CMAKE_BINARY_DIR}/src/components/
+ include
+ plugins
+)
+
+set (LIBRARIES
+ gtest
+ gmock
+ gmock_main
+ FunctionalModule
+ dl
+ ApplicationManager
+ jsoncpp
+ Utils
+ ConfigProfile
+ gcov
+)
+
+set(SOURCES
+ ./src/generic_module_test.cc
+ ./src/plugin_manager_test.cc
+ ./src/module_timer_test.cc
+)
+
+# use, i.e. don't skip the full RPATH for the build tree
+SET(CMAKE_SKIP_BUILD_RPATH FALSE)
+
+# when building, don't use the install RPATH already
+# (but later on when installing)
+SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
+
+SET(RPATH_DIRECTORIES
+ /usr/local/lib
+ /usr/local
+ ${CMAKE_BINARY_DIR}/src/components/utils
+)
+
+SET(CMAKE_INSTALL_RPATH "${RPATH_DIRECTORIES}")
+
+add_subdirectory(plugins)
+
+create_test("function_module_test" "${SOURCES}" "${LIBRARIES}")
diff --git a/src/components/functional_module/test/include/driver_generic_module_test.h b/src/components/functional_module/test/include/driver_generic_module_test.h
new file mode 100644
index 0000000000..0d5aae1f37
--- /dev/null
+++ b/src/components/functional_module/test/include/driver_generic_module_test.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2015, 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_FUNCTIONAL_MODULE_TEST_INCLUDE_DRIVER_GENERIC_MODULE_TEST_H_
+#define SRC_COMPONENTS_FUNCTIONAL_MODULE_TEST_INCLUDE_DRIVER_GENERIC_MODULE_TEST_H_
+
+#include "functional_module/generic_module.h"
+
+namespace functional_modules {
+
+class DriverGenericModuleTest : public GenericModule {
+ public:
+ explicit DriverGenericModuleTest(ModuleID module_id)
+ : GenericModule(module_id) {}
+ virtual ~DriverGenericModuleTest() {}
+ virtual PluginInfo GetPluginInfo() const {
+ PluginInfo info;
+ info.name = "DriverGenericModuleTest";
+ info.version = 1;
+ return info;
+ }
+ virtual ProcessResult ProcessMessage(application_manager::MessagePtr msg) {
+ NotifyObservers(ModuleObserver::FS_FAILURE);
+ return ProcessResult::FAILED;
+ }
+ virtual ProcessResult ProcessHMIMessage(application_manager::MessagePtr msg) {
+ return ProcessResult::PROCESSED;
+ }
+ virtual void RemoveAppExtension(uint32_t app_id) {}
+ virtual void RemoveAppExtensions() {}
+ bool IsAppForPlugin(application_manager::ApplicationSharedPtr app) {
+ return true;
+ }
+
+ void OnAppHMILevelChanged(application_manager::ApplicationSharedPtr,
+ mobile_apis::HMILevel::eType) {}
+
+ const Observers& observers() {
+ return observers_;
+ }
+
+ void OnApplicationEvent(functional_modules::ApplicationEvent event,
+ const uint32_t application_id) {}
+
+ void OnPolicyEvent(functional_modules::PolicyEvent event) {}
+
+ void OnUnregisterApplication(const uint32_t app_id) {}
+};
+
+} // namespace functional_modules
+
+#endif // SRC_COMPONENTS_FUNCTIONAL_MODULE_TEST_INCLUDE_DRIVER_GENERIC_MODULE_TEST_H_
diff --git a/src/components/functional_module/test/include/mock_application.h b/src/components/functional_module/test/include/mock_application.h
new file mode 100644
index 0000000000..e73851094e
--- /dev/null
+++ b/src/components/functional_module/test/include/mock_application.h
@@ -0,0 +1,248 @@
+/*
+ * Copyright (c) 2015, 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_FUNCTIONAL_MODULE_TEST_INCLUDE_MOCK_APPLICATION_H_
+#define SRC_COMPONENTS_FUNCTIONAL_MODULE_TEST_INCLUDE_MOCK_APPLICATION_H_
+
+#include "gmock/gmock.h"
+#include "application_manager/application.h"
+#include "application_manager/usage_statistics.h"
+#include "smart_objects/smart_object.h"
+
+namespace application_manager {
+
+class MockApplication : public Application {
+ public:
+ MOCK_CONST_METHOD0(active_message, const smart_objects::SmartObject*());
+ MOCK_CONST_METHOD0(curHash, const std::string&());
+ MOCK_METHOD0(UpdateHash, void());
+ MOCK_METHOD0(CloseActiveMessage, void());
+ MOCK_CONST_METHOD0(IsFullscreen, bool());
+ MOCK_METHOD0(MakeFullscreen, bool());
+ MOCK_CONST_METHOD0(IsAudible, bool());
+ MOCK_METHOD0(MakeNotAudible, void());
+ MOCK_CONST_METHOD0(allowed_support_navigation, bool());
+ MOCK_METHOD1(set_allowed_support_navigation, void(bool allow));
+ MOCK_CONST_METHOD0(hmi_supports_navi_streaming, bool());
+ MOCK_METHOD1(set_hmi_supports_navi_streaming, void(const bool& supports));
+ MOCK_CONST_METHOD0(app_allowed, bool());
+ MOCK_CONST_METHOD0(has_been_activated, bool());
+ MOCK_CONST_METHOD0(version, const Version&());
+ MOCK_METHOD1(set_hmi_application_id, void(uint32_t hmi_app_id));
+ MOCK_CONST_METHOD0(hmi_app_id, uint32_t());
+ MOCK_CONST_METHOD0(app_id, uint32_t());
+ MOCK_CONST_METHOD0(name, const std::string&());
+ MOCK_CONST_METHOD0(folder_name, const std::string());
+ MOCK_CONST_METHOD0(is_media_application, bool());
+ MOCK_CONST_METHOD0(hmi_level, const mobile_api::HMILevel::eType&());
+ MOCK_CONST_METHOD0(put_file_in_none_count, const uint32_t());
+ MOCK_CONST_METHOD0(delete_file_in_none_count, const uint32_t());
+ MOCK_CONST_METHOD0(list_files_in_none_count, const uint32_t());
+ MOCK_CONST_METHOD0(system_context, const mobile_api::SystemContext::eType&());
+ MOCK_CONST_METHOD0(audio_streaming_state,
+ const mobile_api::AudioStreamingState::eType&());
+ MOCK_CONST_METHOD0(app_icon_path, const std::string&());
+ MOCK_CONST_METHOD0(device, connection_handler::DeviceHandle());
+ MOCK_METHOD1(set_tts_speak_state, void(bool state_tts_speak));
+ MOCK_METHOD0(tts_speak_state, bool());
+ MOCK_METHOD1(set_tts_properties_in_none, void(bool active));
+ MOCK_METHOD0(tts_properties_in_none, bool());
+ MOCK_METHOD1(set_tts_properties_in_full, void(bool active));
+ MOCK_METHOD0(tts_properties_in_full, bool());
+ MOCK_METHOD1(set_version, void(const Version& version));
+ MOCK_METHOD1(set_name, void(const std::string& name));
+ MOCK_METHOD1(set_is_media_application, void(bool is_media));
+ MOCK_METHOD1(set_hmi_level,
+ void(const mobile_api::HMILevel::eType& hmi_level));
+ MOCK_METHOD0(increment_put_file_in_none_count, void());
+ MOCK_METHOD0(increment_delete_file_in_none_count, void());
+ MOCK_METHOD0(increment_list_files_in_none_count, void());
+ MOCK_METHOD1(set_system_context,
+ void(const mobile_api::SystemContext::eType& system_context));
+ MOCK_METHOD1(set_audio_streaming_state,
+ void(const mobile_api::AudioStreamingState::eType& state));
+ MOCK_METHOD1(set_app_icon_path, bool(const std::string& file_name));
+ MOCK_METHOD1(set_app_allowed, void(const bool& allowed));
+ MOCK_METHOD1(set_device, void(connection_handler::DeviceHandle device));
+ MOCK_CONST_METHOD0(get_grammar_id, uint32_t());
+ MOCK_METHOD1(set_grammar_id, void(uint32_t value));
+ MOCK_METHOD1(set_protocol_version,
+ void(const ProtocolVersion& protocol_version));
+ MOCK_CONST_METHOD0(protocol_version, ProtocolVersion());
+ MOCK_METHOD1(AddFile, bool(AppFile& file));
+ MOCK_CONST_METHOD0(getAppFiles, const AppFilesMap&());
+ MOCK_METHOD1(UpdateFile, bool(AppFile& file));
+ MOCK_METHOD1(DeleteFile, bool(const std::string& file_name));
+ MOCK_METHOD1(GetFile, const AppFile*(const std::string& file_name));
+ MOCK_METHOD1(SubscribeToButton,
+ bool(mobile_apis::ButtonName::eType btn_name));
+ MOCK_METHOD1(IsSubscribedToButton,
+ bool(mobile_apis::ButtonName::eType btn_name));
+ MOCK_METHOD1(UnsubscribeFromButton,
+ bool(mobile_apis::ButtonName::eType btn_name));
+ MOCK_METHOD1(SubscribeToIVI, bool(uint32_t vehicle_info_type_));
+ MOCK_METHOD1(IsSubscribedToIVI, bool(uint32_t vehicle_info_type_));
+ MOCK_METHOD1(UnsubscribeFromIVI, bool(uint32_t vehicle_info_type_));
+ MOCK_METHOD2(IsCommandLimitsExceeded,
+ bool(mobile_apis::FunctionID::eType cmd_id,
+ TLimitSource source));
+ MOCK_METHOD0(usage_report, UsageStatistics&());
+ MOCK_METHOD2(SubscribeToSoftButtons,
+ void(int32_t cmd_id, const SoftButtonID& softbuttons_id));
+ MOCK_METHOD1(IsSubscribedToSoftButton, bool(const uint32_t softbutton_id));
+ MOCK_METHOD1(UnsubscribeFromSoftButtons, void(int32_t cmd_id));
+ MOCK_METHOD1(QueryInterface, AppExtensionPtr(AppExtensionUID uid));
+ MOCK_METHOD1(AddExtension, bool(AppExtensionPtr extention));
+ MOCK_METHOD1(RemoveExtension, bool(AppExtensionUID uid));
+ MOCK_METHOD0(RemoveExtensions, void());
+ MOCK_CONST_METHOD0(help_prompt, const smart_objects::SmartObject*());
+ MOCK_CONST_METHOD0(timeout_prompt, const smart_objects::SmartObject*());
+ MOCK_CONST_METHOD0(vr_help_title, const smart_objects::SmartObject*());
+ MOCK_CONST_METHOD0(vr_help, const smart_objects::SmartObject*());
+ MOCK_CONST_METHOD0(tbt_state, const mobile_api::TBTState::eType&());
+ MOCK_CONST_METHOD0(show_command, const smart_objects::SmartObject*());
+ MOCK_CONST_METHOD0(tbt_show_command, const smart_objects::SmartObject*());
+ MOCK_CONST_METHOD0(SubscribedButtons,
+ const std::set<mobile_apis::ButtonName::eType>&());
+ MOCK_CONST_METHOD0(SubscribesIVI, const std::set<uint32_t>&());
+ MOCK_CONST_METHOD0(keyboard_props, const smart_objects::SmartObject*());
+ MOCK_CONST_METHOD0(menu_title, const smart_objects::SmartObject*());
+ MOCK_CONST_METHOD0(menu_icon, const smart_objects::SmartObject*());
+ MOCK_METHOD1(set_help_prompt,
+ void(const smart_objects::SmartObject& help_prompt));
+ MOCK_METHOD1(set_timeout_prompt,
+ void(const smart_objects::SmartObject& timeout_prompt));
+ MOCK_METHOD1(set_vr_help_title,
+ void(const smart_objects::SmartObject& vr_help_title));
+ MOCK_METHOD0(reset_vr_help_title, void());
+ MOCK_METHOD1(set_vr_help, void(const smart_objects::SmartObject& vr_help));
+ MOCK_METHOD0(reset_vr_help, void());
+ MOCK_METHOD1(set_tbt_state,
+ void(const mobile_api::TBTState::eType& tbt_state));
+ MOCK_METHOD1(set_show_command,
+ void(const smart_objects::SmartObject& show_command));
+ MOCK_METHOD1(set_tbt_show_command,
+ void(const smart_objects::SmartObject& tbt_show));
+ MOCK_METHOD1(set_keyboard_props,
+ void(const smart_objects::SmartObject& keyboard_props));
+ MOCK_METHOD1(set_menu_title,
+ void(const smart_objects::SmartObject& menu_title));
+ MOCK_METHOD1(set_menu_icon,
+ void(const smart_objects::SmartObject& menu_icon));
+ MOCK_METHOD2(AddCommand,
+ void(uint32_t cmd_id,
+ const smart_objects::SmartObject& command));
+ MOCK_METHOD1(RemoveCommand, void(uint32_t cmd_id));
+ MOCK_METHOD1(FindCommand, smart_objects::SmartObject*(uint32_t cmd_id));
+ MOCK_METHOD2(AddSubMenu,
+ void(uint32_t menu_id, const smart_objects::SmartObject& menu));
+ MOCK_METHOD1(RemoveSubMenu, void(uint32_t menu_id));
+ MOCK_CONST_METHOD1(FindSubMenu,
+ smart_objects::SmartObject*(uint32_t menu_id));
+ MOCK_METHOD1(IsSubMenuNameAlreadyExist, bool(const std::string& name));
+ MOCK_METHOD2(AddChoiceSet,
+ void(uint32_t choice_set_id,
+ const smart_objects::SmartObject& choice_set));
+ MOCK_METHOD1(RemoveChoiceSet, void(uint32_t choice_set_id));
+ MOCK_METHOD1(FindChoiceSet,
+ smart_objects::SmartObject*(uint32_t choice_set_id));
+ MOCK_METHOD2(AddPerformInteractionChoiceSet,
+ void(uint32_t choice_set_id,
+ const smart_objects::SmartObject& choice_set));
+ MOCK_METHOD0(DeletePerformInteractionChoiceSetMap, void());
+ MOCK_CONST_METHOD0(performinteraction_choice_set_map,
+ DataAccessor<PerformChoiceSetMap>());
+ MOCK_CONST_METHOD1(FindPerformInteractionChoiceSet,
+ smart_objects::SmartObject*(uint32_t choice_set_id));
+ MOCK_CONST_METHOD0(commands_map, DataAccessor<CommandsMap>());
+ MOCK_CONST_METHOD0(sub_menu_map, DataAccessor<SubMenuMap>());
+ MOCK_CONST_METHOD0(choice_set_map, DataAccessor<ChoiceSetMap>());
+ MOCK_METHOD1(set_perform_interaction_active, void(uint32_t active));
+ MOCK_CONST_METHOD0(is_perform_interaction_active, uint32_t());
+ MOCK_METHOD1(set_perform_interaction_ui_corrid, void(uint32_t choice));
+ MOCK_CONST_METHOD0(perform_interaction_ui_corrid, uint32_t());
+ MOCK_METHOD1(set_perform_interaction_mode, void(int32_t mode));
+ MOCK_CONST_METHOD0(perform_interaction_mode, int32_t());
+ MOCK_METHOD1(set_reset_global_properties_active, void(bool active));
+ MOCK_CONST_METHOD0(is_reset_global_properties_active, bool());
+ MOCK_CONST_METHOD0(app_types, const smart_objects::SmartObject*());
+ MOCK_CONST_METHOD0(vr_synonyms, const smart_objects::SmartObject*());
+ MOCK_CONST_METHOD0(mobile_app_id, std::string());
+ MOCK_CONST_METHOD0(tts_name, const smart_objects::SmartObject*());
+ MOCK_CONST_METHOD0(ngn_media_screen_name,
+ const smart_objects::SmartObject*());
+ MOCK_CONST_METHOD0(language, const mobile_api::Language::eType&());
+ MOCK_CONST_METHOD0(ui_language, const mobile_api::Language::eType&());
+ MOCK_METHOD1(set_app_types,
+ void(const smart_objects::SmartObject& app_types));
+ MOCK_METHOD1(set_vr_synonyms,
+ void(const smart_objects::SmartObject& vr_synonyms));
+ MOCK_METHOD1(set_mobile_app_id,
+ void(const smart_objects::SmartObject& mobile_app_id));
+ MOCK_METHOD1(set_tts_name, void(const smart_objects::SmartObject& tts_name));
+ MOCK_METHOD1(set_ngn_media_screen_name,
+ void(const smart_objects::SmartObject& ngn_name));
+ MOCK_METHOD1(set_language, void(const mobile_api::Language::eType& language));
+ MOCK_METHOD1(set_ui_language,
+ void(const mobile_api::Language::eType& ui_language));
+ MOCK_METHOD1(load_global_properties,
+ void(const smart_objects::SmartObject& so));
+ MOCK_METHOD1(set_mobile_app_id, void(const std::string& mobile_app_id));
+ MOCK_METHOD0(ChangeSupportingAppHMIType, void());
+ MOCK_CONST_METHOD0(is_navi, bool());
+ MOCK_METHOD1(set_is_navi, void(bool allow));
+ MOCK_CONST_METHOD0(hmi_supports_navi_video_streaming, bool());
+ MOCK_METHOD1(set_hmi_supports_navi_video_streaming, void(bool supports));
+ MOCK_CONST_METHOD0(hmi_supports_navi_audio_streaming, bool());
+ MOCK_METHOD1(set_hmi_supports_navi_audio_streaming, void(bool supports));
+ MOCK_CONST_METHOD0(is_voice_communication_supported, bool());
+ MOCK_METHOD1(set_voice_communication_supported, void(bool));
+ MOCK_METHOD1(set_activated, bool(bool is_active));
+ MOCK_CONST_METHOD0(is_foreground, bool());
+ MOCK_METHOD1(set_foreground, void(bool is_foreground));
+ MOCK_CONST_METHOD0(IsAudioApplication, bool());
+ MOCK_CONST_METHOD0(video_stream_retry_active, bool());
+ MOCK_METHOD1(set_video_stream_retry_active, void(bool active));
+ MOCK_CONST_METHOD0(audio_stream_retry_active, bool());
+ MOCK_METHOD1(set_audio_stream_retry_active, void(bool active));
+ MOCK_METHOD0(OnVideoStreamRetry, void());
+ MOCK_METHOD0(OnAudioStreamRetry, void());
+ MOCK_METHOD1(SubscribeToInteriorVehicleData,
+ bool(smart_objects::SmartObject module));
+ MOCK_METHOD1(IsSubscribedToInteriorVehicleData,
+ bool(smart_objects::SmartObject module));
+ MOCK_METHOD1(UnsubscribeFromInteriorVehicleData,
+ bool(smart_objects::SmartObject module));
+};
+
+} // namespace application_manager
+
+#endif // SRC_COMPONENTS_FUNCTIONAL_MODULE_TEST_INCLUDE_MOCK_APPLICATION_H_
diff --git a/src/components/functional_module/test/include/mock_module_observer.h b/src/components/functional_module/test/include/mock_module_observer.h
new file mode 100644
index 0000000000..bfa5117b29
--- /dev/null
+++ b/src/components/functional_module/test/include/mock_module_observer.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2015, 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_FUNCTIONAL_MODULE_TEST_INCLUDE_MOCK_MODULE_OBSERVER_H_
+#define SRC_COMPONENTS_FUNCTIONAL_MODULE_TEST_INCLUDE_MOCK_MODULE_OBSERVER_H_
+
+#include "gmock/gmock.h"
+#include "functional_module/module_observer.h"
+
+namespace functional_modules {
+
+class MockModuleObserver : public ModuleObserver {
+ public:
+ MOCK_METHOD2(OnError, void(Errors error, ModuleID module_id));
+ int ObserverMethod() {
+ return 13;
+ }
+};
+
+} // namespace functional_modules
+
+#endif // SRC_COMPONENTS_FUNCTIONAL_MODULE_TEST_INCLUDE_MOCK_MODULE_OBSERVER_H_
diff --git a/src/components/functional_module/test/include/mock_service.h b/src/components/functional_module/test/include/mock_service.h
new file mode 100644
index 0000000000..d1fa7f2747
--- /dev/null
+++ b/src/components/functional_module/test/include/mock_service.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2015, 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_FUNCTIONAL_MODULE_TEST_INCLUDE_MOCK_SERVICE_H_
+#define SRC_COMPONENTS_FUNCTIONAL_MODULE_TEST_INCLUDE_MOCK_SERVICE_H_
+
+#include "gmock/gmock.h"
+#include "application_manager/service.h"
+
+namespace application_manager {
+
+class MockService : public Service {
+ public:
+ MOCK_METHOD1(CheckPolicyPermissions,
+ mobile_apis::Result::eType(MessagePtr msg));
+ MOCK_METHOD1(GetApplication, ApplicationSharedPtr(ApplicationId app_id));
+ MOCK_METHOD1(SendMessageToHMI, void(const MessagePtr& message));
+ MOCK_METHOD1(SendMessageToMobile, void(const MessagePtr& message));
+ MOCK_METHOD0(GetNextCorrelationID, uint32_t());
+ MOCK_METHOD1(GetApplications,
+ std::vector<ApplicationSharedPtr>(AppExtensionUID));
+ MOCK_METHOD2(ChangeNotifyHMILevel,
+ void(ApplicationSharedPtr app,
+ mobile_apis::HMILevel::eType level));
+ MOCK_METHOD2(NotifyHMIAboutHMILevel,
+ void(ApplicationSharedPtr app,
+ mobile_apis::HMILevel::eType level));
+ MOCK_CONST_METHOD0(GetRCCapabilities, const smart_objects::SmartObject*());
+ MOCK_METHOD2(CheckModule,
+ bool(const ApplicationId& app_id, const std::string& module));
+ MOCK_METHOD1(RemoveHMIFakeParameters,
+ void(application_manager::MessagePtr& message));
+ MOCK_CONST_METHOD1(IsRemoteControlApplication,
+ bool(ApplicationSharedPtr app));
+ MOCK_CONST_METHOD1(IsInterfaceAvailable,
+ bool(const HmiInterfaces::InterfaceID interface));
+ MOCK_CONST_METHOD2(GetModuleTypes,
+ bool(const std::string& application_id,
+ std::vector<std::string>* modules));
+ MOCK_METHOD1(ValidateMessageBySchema,
+ application_manager::MessageValidationResult(
+ const application_manager::Message& message));
+ MOCK_CONST_METHOD0(GetSettings, const ApplicationManagerSettings&());
+};
+}
+// namespace application_manager
+
+#endif // SRC_COMPONENTS_FUNCTIONAL_MODULE_TEST_INCLUDE_MOCK_SERVICE_H_
diff --git a/src/components/functional_module/test/include/module_timer_test.h b/src/components/functional_module/test/include/module_timer_test.h
new file mode 100644
index 0000000000..456346b544
--- /dev/null
+++ b/src/components/functional_module/test/include/module_timer_test.h
@@ -0,0 +1,56 @@
+#include "utils/macro.h"
+#include "functional_module/timer/module_timer.h"
+
+namespace functional_modules {
+
+class TestTrackable : public Trackable {
+ public:
+ explicit TestTrackable(TimeUnit interval = 0)
+ : Trackable(), custom_interval_(interval) {}
+
+ virtual TimeUnit custom_interval() const {
+ return custom_interval_;
+ }
+
+ bool operator==(const TestTrackable& other) const {
+ return custom_interval_ == other.custom_interval_;
+ }
+
+ private:
+ TimeUnit custom_interval_;
+};
+
+class ModuleTimerTest {
+ public:
+ ModuleTimerTest(ModuleTimer<TestTrackable>& timer) : timer_(timer) {}
+
+ TimeUnit period() const {
+ return timer_.period_;
+ }
+
+ int observers_size() const {
+ return timer_.observers_.size();
+ }
+
+ int trackables_size() const {
+ return timer_.trackables_.size();
+ }
+
+ TestTrackable trackable(const TestTrackable& track) const {
+ return *std::find(
+ timer_.trackables_.begin(), timer_.trackables_.end(), track);
+ }
+
+ TimeUnit current_time() const {
+ return timer_.CurrentTime();
+ }
+
+ private:
+ ModuleTimer<TestTrackable>& timer_;
+};
+
+class MockTimerObserver : public TimerObserver<TestTrackable> {
+ public:
+ MOCK_METHOD1(OnTimeoutTriggered, void(const TestTrackable& expired));
+};
+} // namespace functional_modules
diff --git a/src/components/functional_module/test/plugins/CMakeLists.txt b/src/components/functional_module/test/plugins/CMakeLists.txt
new file mode 100644
index 0000000000..7afe8387b8
--- /dev/null
+++ b/src/components/functional_module/test/plugins/CMakeLists.txt
@@ -0,0 +1,17 @@
+set(target PluginMock)
+
+include_directories (
+ ${LOG4CXX_INCLUDE_DIRECTORY}
+ ${GMOCK_INCLUDE_DIRECTORY}
+ ${CMAKE_SOURCE_DIR}/src/components/functional_module/include/
+ ${CMAKE_SOURCE_DIR}/src/components/include/
+ ${JSONCPP_INCLUDE_DIRECTORY}
+)
+
+set(SOURCES
+ ./mock_generic_module.cc
+)
+
+add_library(${target} SHARED ${SOURCES})
+target_link_libraries(${target})
+add_dependencies(${target} MOBILE_API HMI_API)
diff --git a/src/components/functional_module/test/plugins/mock_generic_module.cc b/src/components/functional_module/test/plugins/mock_generic_module.cc
new file mode 100644
index 0000000000..dcf6d7d4fe
--- /dev/null
+++ b/src/components/functional_module/test/plugins/mock_generic_module.cc
@@ -0,0 +1,23 @@
+#include "mock_generic_module.h"
+
+using functional_modules::GenericModule;
+using functional_modules::RCFunctionID;
+using functional_modules::PluginInfo;
+
+using ::testing::_;
+using ::testing::Return;
+
+MockGenericModule::MockGenericModule() : GenericModule(19) {
+ PluginInfo info;
+ info.name = "MockGenericModule";
+ info.version = 1;
+ info.rc_function_list.push_back(static_cast<RCFunctionID>(101));
+ info.hmi_function_list.push_back("HMI-Func-1");
+
+ EXPECT_CALL(*this, GetPluginInfo()).Times(2).WillRepeatedly(Return(info));
+ EXPECT_CALL(*this, set_service(_)).Times(1);
+}
+
+extern "C" GenericModule* Create() {
+ return new MockGenericModule();
+}
diff --git a/src/components/functional_module/test/plugins/mock_generic_module.h b/src/components/functional_module/test/plugins/mock_generic_module.h
new file mode 100644
index 0000000000..0139866d67
--- /dev/null
+++ b/src/components/functional_module/test/plugins/mock_generic_module.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2015, 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 TEST_COMPONENTS_FUNCTIONAL_MODULE_PLUGINS_MOCK_GENERIC_MODULE_H_
+#define TEST_COMPONENTS_FUNCTIONAL_MODULE_PLUGINS_MOCK_GENERIC_MODULE_H_
+
+#include "gmock/gmock.h"
+#include "functional_module/generic_module.h"
+
+using functional_modules::GenericModule;
+using functional_modules::PluginInfo;
+using functional_modules::ProcessResult;
+using functional_modules::ServiceState;
+
+using ::testing::_;
+using ::testing::Return;
+
+class MockGenericModule : public GenericModule {
+ public:
+ MockGenericModule();
+ MOCK_CONST_METHOD0(GetPluginInfo, PluginInfo());
+ MOCK_METHOD1(set_service, void(application_manager::ServicePtr service));
+ MOCK_METHOD0(service, application_manager::ServicePtr());
+ MOCK_METHOD1(ProcessMessage,
+ ProcessResult(application_manager::MessagePtr msg));
+ MOCK_METHOD1(ProcessHMIMessage,
+ ProcessResult(application_manager::MessagePtr msg));
+ MOCK_METHOD1(OnServiceStateChanged, void(ServiceState state));
+ MOCK_METHOD1(RemoveAppExtension, void(uint32_t app_id));
+ MOCK_METHOD1(IsAppForPlugin,
+ bool(application_manager::ApplicationSharedPtr app));
+ MOCK_METHOD2(OnAppHMILevelChanged,
+ void(application_manager::ApplicationSharedPtr app,
+ mobile_apis::HMILevel::eType old_level));
+ MOCK_METHOD1(OnUnregisterApplication, void(const uint32_t app_id));
+ MOCK_METHOD2(OnApplicationEvent,
+ void(functional_modules::ApplicationEvent event,
+ const uint32_t application_id));
+ MOCK_METHOD1(OnPolicyEvent, void(functional_modules::PolicyEvent event));
+ MOCK_METHOD0(RemoveAppExtensions, void());
+};
+
+#endif // TEST_COMPONENTS_FUNCTIONAL_MODULE_PLUGINS_MOCK_GENERIC_MODULE_H_
diff --git a/src/components/functional_module/test/src/generic_module_test.cc b/src/components/functional_module/test/src/generic_module_test.cc
new file mode 100644
index 0000000000..71d8325f6d
--- /dev/null
+++ b/src/components/functional_module/test/src/generic_module_test.cc
@@ -0,0 +1,106 @@
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "driver_generic_module_test.h"
+
+#include "mock_module_observer.h"
+#include "mock_service.h"
+
+using application_manager::ServicePtr;
+using application_manager::MockService;
+
+using ::testing::_;
+
+namespace functional_modules {
+
+TEST(GenericModuleTest, SetService) {
+ DriverGenericModuleTest module(18);
+ MockService* mock_service = new MockService();
+ ServicePtr exp_service(mock_service);
+
+ module.set_service(exp_service);
+ ServicePtr out_service = module.service();
+
+ EXPECT_EQ(exp_service.get(), out_service.get());
+}
+
+TEST(GenericModuleTest, RemoveObserver) {
+ DriverGenericModuleTest module(18);
+ MockModuleObserver* observer = new MockModuleObserver();
+ module.AddObserver(observer);
+
+ module.RemoveObserver(observer);
+ const DriverGenericModuleTest::Observers& empty = module.observers();
+ ASSERT_TRUE(empty.empty());
+ delete observer;
+}
+
+TEST(GenericModuleTest, EmptyRemoveObserver) {
+ DriverGenericModuleTest module(18);
+ MockModuleObserver* observer = new MockModuleObserver();
+ module.RemoveObserver(observer);
+ const DriverGenericModuleTest::Observers& empty = module.observers();
+ ASSERT_TRUE(empty.empty());
+ delete observer;
+}
+
+TEST(GenericModuleTest, WrongRemoveObserver) {
+ DriverGenericModuleTest module(18);
+ MockModuleObserver observer;
+ module.AddObserver(&observer);
+
+ MockModuleObserver* wrong_observer = new MockModuleObserver();
+ module.RemoveObserver(wrong_observer);
+ const DriverGenericModuleTest::Observers& empty = module.observers();
+ ASSERT_EQ(1u, empty.size());
+ EXPECT_EQ(&observer, empty[0]);
+ delete wrong_observer;
+}
+
+TEST(GenericModuleTest, CrashRemovedObserver) {
+ DriverGenericModuleTest module(18);
+ MockModuleObserver* observer = new MockModuleObserver();
+ module.AddObserver(observer);
+ EXPECT_EQ(13, observer->ObserverMethod());
+ module.RemoveObserver(observer);
+ EXPECT_EQ(13, observer->ObserverMethod());
+ delete observer;
+ MockModuleObserver second_observer;
+ module.AddObserver(&second_observer);
+ EXPECT_EQ(13, second_observer.ObserverMethod());
+ module.RemoveObserver(&second_observer);
+ EXPECT_EQ(13, second_observer.ObserverMethod());
+}
+
+TEST(GenericModuleTest, NotifyObservers) {
+ DriverGenericModuleTest module(3);
+ MockModuleObserver observer;
+ module.AddObserver(&observer);
+
+ EXPECT_CALL(observer, OnError(ModuleObserver::FS_FAILURE, 3)).Times(1);
+
+ application_manager::MessagePtr message;
+ module.ProcessMessage(message);
+}
+
+TEST(GenericModuleTest, NotifyObserversComplex) {
+ DriverGenericModuleTest module(3);
+ MockModuleObserver observer_1;
+ module.AddObserver(&observer_1);
+ MockModuleObserver observer_2;
+ module.AddObserver(&observer_2);
+
+ EXPECT_CALL(observer_1, OnError(ModuleObserver::FS_FAILURE, 3)).Times(1);
+ EXPECT_CALL(observer_2, OnError(ModuleObserver::FS_FAILURE, 3)).Times(1);
+
+ application_manager::MessagePtr message;
+ module.ProcessMessage(message);
+
+ module.RemoveObserver(&observer_1);
+ EXPECT_CALL(observer_1, OnError(ModuleObserver::FS_FAILURE, 3)).Times(0);
+ EXPECT_CALL(observer_2, OnError(ModuleObserver::FS_FAILURE, 3)).Times(1);
+
+ module.ProcessMessage(message);
+}
+
+} // namespace functional_modules
diff --git a/src/components/functional_module/test/src/module_timer_test.cc b/src/components/functional_module/test/src/module_timer_test.cc
new file mode 100644
index 0000000000..668c3e2955
--- /dev/null
+++ b/src/components/functional_module/test/src/module_timer_test.cc
@@ -0,0 +1,123 @@
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+#include "module_timer_test.h"
+
+namespace functional_modules {
+
+TEST(ModuleTimerTest, set_period) {
+ ModuleTimer<TestTrackable> timer;
+ timer.set_period(10000);
+ ModuleTimerTest test(timer);
+ EXPECT_EQ(10000u, test.period());
+}
+
+TEST(ModuleTimerTest, add_observer) {
+ ModuleTimer<TestTrackable> timer;
+ ModuleTimerTest test(timer);
+ for (size_t i = 0; i < 5; ++i) {
+ MockTimerObserver observer;
+ timer.AddObserver(&observer);
+ }
+ EXPECT_EQ(5, test.observers_size());
+}
+
+TEST(ModuleTimerTest, remove_observer) {
+ ModuleTimer<TestTrackable> timer;
+ ModuleTimerTest test(timer);
+
+ MockTimerObserver observer;
+ timer.AddObserver(&observer);
+ MockTimerObserver observer2;
+ timer.AddObserver(&observer2);
+ timer.RemoveObserver(&observer);
+ EXPECT_EQ(1, test.observers_size());
+ MockTimerObserver observer3;
+ timer.RemoveObserver(&observer3);
+ EXPECT_EQ(1, test.observers_size());
+ timer.RemoveObserver(&observer2);
+ EXPECT_EQ(0, test.observers_size());
+}
+
+TEST(ModuleTimerTest, start) {
+ ModuleTimer<TestTrackable> timer;
+ ModuleTimerTest test(timer);
+ timer.set_period(1);
+ MockTimerObserver observer;
+ timer.AddObserver(&observer);
+ TestTrackable track;
+ timer.AddTrackable(track);
+ sleep(2);
+ EXPECT_CALL(observer, OnTimeoutTriggered(track)).Times(1);
+ timer.CheckTimeout();
+ EXPECT_EQ(0, test.trackables_size());
+ timer.set_period(4);
+ timer.AddTrackable(track);
+ sleep(2);
+ EXPECT_CALL(observer, OnTimeoutTriggered(track)).Times(0);
+ timer.CheckTimeout();
+ EXPECT_EQ(1, test.trackables_size());
+ TestTrackable track2(1);
+ timer.AddTrackable(track2);
+ timer.AddTrackable(track);
+ sleep(2);
+ EXPECT_CALL(observer, OnTimeoutTriggered(track2)).Times(1);
+ EXPECT_CALL(observer, OnTimeoutTriggered(track)).Times(0);
+ timer.CheckTimeout();
+ EXPECT_EQ(1, test.trackables_size());
+}
+
+TEST(ModuleTimerTest, add_trackable) {
+ ModuleTimer<TestTrackable> timer;
+ ModuleTimerTest test(timer);
+ timer.AddTrackable(TestTrackable());
+ ASSERT_EQ(1, test.trackables_size());
+ // adding the same object twice
+ timer.AddTrackable(TestTrackable());
+ EXPECT_EQ(1, test.trackables_size());
+ // adding another object
+ TestTrackable track(3);
+ timer.AddTrackable(track);
+ ASSERT_EQ(2, test.trackables_size());
+ EXPECT_TRUE(test.trackable(track).start_time() - test.current_time() < 1);
+ timer.AddTrackable(track);
+ sleep(3);
+ EXPECT_TRUE(test.current_time() - test.trackable(track).start_time() < 4 &&
+ test.current_time() - test.trackable(track).start_time() > 2);
+}
+
+TEST(ModuleTimerTest, remove_trackable) {
+ ModuleTimer<TestTrackable> timer;
+ ModuleTimerTest test(timer);
+ EXPECT_EQ(0, test.trackables_size());
+ TestTrackable track1;
+ TestTrackable track2(1);
+ timer.AddTrackable(track1);
+ timer.AddTrackable(track2);
+ EXPECT_EQ(2, test.trackables_size());
+ timer.RemoveTrackable(track2);
+ ASSERT_EQ(1, test.trackables_size());
+ TestTrackable track3(2);
+ timer.RemoveTrackable(track3);
+ ASSERT_EQ(1, test.trackables_size());
+ timer.RemoveTrackable(track1);
+ ASSERT_EQ(0, test.trackables_size());
+}
+
+TEST(ModuleTimerTest, notify) {
+ ModuleTimer<TestTrackable> timer;
+ ModuleTimerTest test(timer);
+ timer.set_period(1);
+ MockTimerObserver observer;
+ timer.AddObserver(&observer);
+ TestTrackable track;
+ timer.AddTrackable(track);
+ TestTrackable track2(2);
+ timer.AddTrackable(track2);
+ sleep(2);
+ EXPECT_CALL(observer, OnTimeoutTriggered(track)).Times(1);
+ EXPECT_CALL(observer, OnTimeoutTriggered(track2)).Times(0);
+ timer.CheckTimeout();
+ EXPECT_EQ(1, test.trackables_size());
+}
+
+} // namespace functional_modules
diff --git a/src/components/functional_module/test/src/plugin_manager_test.cc b/src/components/functional_module/test/src/plugin_manager_test.cc
new file mode 100644
index 0000000000..5c251113a8
--- /dev/null
+++ b/src/components/functional_module/test/src/plugin_manager_test.cc
@@ -0,0 +1,146 @@
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+#include "functional_module/plugin_manager.h"
+#include "mock_generic_module.h"
+#include "mock_service.h"
+#include "application_manager/mock_application.h"
+#include "utils/shared_ptr.h"
+#include "utils/make_shared.h"
+
+using application_manager::Message;
+using protocol_handler::MajorProtocolVersion;
+using application_manager::MockService;
+using ::testing::NiceMock;
+using ::testing::Expectation;
+using ::testing::ReturnRef;
+
+namespace functional_modules {
+
+class PluginManagerTest : public ::testing::Test {
+ public:
+ PluginManagerTest()
+ : manager(utils::MakeShared<PluginManager>())
+ , service(utils::MakeShared<MockService>()) {}
+
+ protected:
+ utils::SharedPtr<PluginManager> manager;
+ utils::SharedPtr<MockService> service;
+ MockGenericModule* module;
+
+ void SetUp() OVERRIDE {
+ manager->SetServiceHandler(service);
+
+ ASSERT_EQ(1, manager->LoadPlugins("./plugins/"));
+ const PluginManager::Modules& plugins = manager->plugins();
+ PluginManager::Modules::const_iterator i = plugins.begin();
+ module = static_cast<MockGenericModule*>(i->second.get());
+ }
+};
+
+TEST_F(PluginManagerTest, ChangePluginsState) {
+ ServiceState kState = ServiceState::SUSPENDED;
+ EXPECT_CALL(*module, OnServiceStateChanged(kState));
+ manager->OnServiceStateChanged(kState);
+}
+
+TEST_F(PluginManagerTest, RemoveAppExtension) {
+ const uint32_t kAppId = 2;
+ EXPECT_CALL(*module, RemoveAppExtension(kAppId)).Times(1);
+ manager->RemoveAppExtension(kAppId);
+}
+
+TEST_F(PluginManagerTest, ProcessMessageFail) {
+ Message* msg = new Message(protocol_handler::MessagePriority::FromServiceType(
+ protocol_handler::ServiceType::kRpc));
+ application_manager::MessagePtr message(msg);
+ msg->set_protocol_version(MajorProtocolVersion::PROTOCOL_VERSION_UNKNOWN);
+ EXPECT_CALL(*module, ProcessMessage(message)).Times(0);
+ manager->ProcessMessage(message);
+}
+
+TEST_F(PluginManagerTest, ProcessMessagePass) {
+ Message* msg = new Message(protocol_handler::MessagePriority::FromServiceType(
+ protocol_handler::ServiceType::kRpc));
+ application_manager::MessagePtr message(msg);
+ msg->set_protocol_version(MajorProtocolVersion::PROTOCOL_VERSION_3);
+ msg->set_function_id(101); // see MockGenericModule
+ EXPECT_CALL(*module, ProcessMessage(message))
+ .Times(1)
+ .WillOnce(Return(ProcessResult::PROCESSED));
+ manager->ProcessMessage(message);
+}
+
+TEST_F(PluginManagerTest, SDL_events_triggers_module) {
+ using namespace functional_modules;
+ std::vector<ApplicationEvent> app_events;
+ app_events.push_back(ApplicationEvent::kApplicationExit);
+ app_events.push_back(ApplicationEvent::kApplicationUnregistered);
+
+ std::vector<ApplicationEvent>::const_iterator ev = app_events.begin();
+ const uint32_t kDummyAppId = 1;
+ for (; app_events.end() != ev; ++ev) {
+ EXPECT_CALL(*module, OnApplicationEvent(*ev, kDummyAppId));
+ manager->OnApplicationEvent(*ev, kDummyAppId);
+ }
+
+ std::vector<PolicyEvent> policy_events;
+ policy_events.push_back(PolicyEvent::kApplicationPolicyUpdated);
+ policy_events.push_back(PolicyEvent::kApplicationsDisabled);
+
+ std::vector<PolicyEvent>::const_iterator ev_policy = policy_events.begin();
+ for (; policy_events.end() != ev_policy; ++ev_policy) {
+ EXPECT_CALL(*module, OnPolicyEvent(*ev_policy));
+ manager->OnPolicyEvent(*ev_policy);
+ }
+}
+
+TEST_F(PluginManagerTest, ProcessHMIMessageFail) {
+ Message* msg = new Message(protocol_handler::MessagePriority::FromServiceType(
+ protocol_handler::ServiceType::kRpc));
+ application_manager::MessagePtr message(msg);
+ message->set_protocol_version(MajorProtocolVersion::PROTOCOL_VERSION_UNKNOWN);
+ EXPECT_CALL(*module, ProcessHMIMessage(message)).Times(0);
+ manager->ProcessHMIMessage(message);
+}
+
+TEST_F(PluginManagerTest, ProcessHMIMessagePass) {
+ Message* msg = new Message(protocol_handler::MessagePriority::FromServiceType(
+ protocol_handler::ServiceType::kRpc));
+ application_manager::MessagePtr message(msg);
+ message->set_protocol_version(MajorProtocolVersion::PROTOCOL_VERSION_HMI);
+ std::string json = "{\"method\": \"HMI-Func-1\"}"; // see MockGenericModule
+ message->set_json_message(json);
+ EXPECT_CALL(*module, ProcessHMIMessage(message))
+ .Times(1)
+ .WillOnce(Return(ProcessResult::PROCESSED));
+ manager->ProcessHMIMessage(message);
+}
+
+TEST_F(PluginManagerTest, IsAppForPlugins) {
+ using test::components::application_manager_test::MockApplication;
+ MockApplication* app = new MockApplication();
+ application_manager::ApplicationSharedPtr app_ptr(app);
+ EXPECT_CALL(*module, IsAppForPlugin(app_ptr)).Times(1);
+ manager->IsAppForPlugins(app_ptr);
+}
+
+TEST_F(PluginManagerTest, OnAppHMILevelChanged) {
+ using test::components::application_manager_test::MockApplication;
+ NiceMock<MockApplication>* app = new NiceMock<MockApplication>();
+ application_manager::ApplicationSharedPtr app_ptr(app);
+
+ const application_manager::custom_str::CustomString name("name");
+ ON_CALL(*app, name()).WillByDefault(ReturnRef(name));
+ mobile_apis::HMILevel::eType level = mobile_apis::HMILevel::eType::HMI_NONE;
+ ON_CALL(*app, hmi_level()).WillByDefault(Return(level));
+
+ Expectation is_for_plugin =
+ EXPECT_CALL(*module, IsAppForPlugin(app_ptr)).WillOnce(Return(true));
+ EXPECT_CALL(*module, OnAppHMILevelChanged(app_ptr, _))
+ .Times(1)
+ .After(is_for_plugin);
+ manager->OnAppHMILevelChanged(app_ptr,
+ mobile_apis::HMILevel::eType::HMI_FULL);
+}
+
+} // namespace functional_modules
diff --git a/src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_adapter_impl.h b/src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_adapter_impl.h
index bd118032d6..f2a5ce2dd8 100644
--- a/src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_adapter_impl.h
+++ b/src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_adapter_impl.h
@@ -51,7 +51,7 @@ class HMIMessageAdapterImpl : public HMIMessageAdapter {
/**
* \brief Destructor
*/
- virtual ~HMIMessageAdapterImpl();
+ ~HMIMessageAdapterImpl();
protected:
virtual HMIMessageHandler* handler() const {
diff --git a/src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_handler_impl.h b/src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_handler_impl.h
index 8b238b4aa8..0d85c30fc2 100644
--- a/src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_handler_impl.h
+++ b/src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_handler_impl.h
@@ -89,14 +89,14 @@ class HMIMessageHandlerImpl : public HMIMessageHandler,
explicit HMIMessageHandlerImpl(const HMIMessageHandlerSettings& settings);
~HMIMessageHandlerImpl();
- void OnMessageReceived(MessageSharedPointer message);
- void SendMessageToHMI(MessageSharedPointer message);
+ void OnMessageReceived(MessageSharedPointer message) OVERRIDE;
+ void SendMessageToHMI(MessageSharedPointer message) OVERRIDE;
void set_message_observer(HMIMessageObserver* observer);
- void OnErrorSending(MessageSharedPointer message);
- void AddHMIMessageAdapter(HMIMessageAdapter* adapter);
- void RemoveHMIMessageAdapter(HMIMessageAdapter* adapter);
+ void OnErrorSending(MessageSharedPointer message) OVERRIDE;
+ void AddHMIMessageAdapter(HMIMessageAdapter* adapter) OVERRIDE;
+ void RemoveHMIMessageAdapter(HMIMessageAdapter* adapter) OVERRIDE;
- virtual const HMIMessageHandlerSettings& get_settings() const OVERRIDE;
+ const HMIMessageHandlerSettings& get_settings() const OVERRIDE;
#ifdef BUILD_TESTS
std::set<HMIMessageAdapter*> message_adapters() const {
@@ -120,15 +120,16 @@ class HMIMessageHandlerImpl : public HMIMessageHandler,
// threads::MessageLoopThread<*>::Handler implementations
// CALLED ON messages_from_hmi_ THREAD!
- virtual void Handle(const impl::MessageFromHmi message) OVERRIDE;
+ void Handle(const impl::MessageFromHmi message) OVERRIDE;
// CALLED ON messages_to_hmi_ THREAD!
- virtual void Handle(const impl::MessageToHmi message) OVERRIDE;
+ void Handle(const impl::MessageToHmi message) OVERRIDE;
private:
const HMIMessageHandlerSettings& settings_;
HMIMessageObserver* observer_;
- mutable sync_primitives::Lock observer_locker_;
std::set<HMIMessageAdapter*> message_adapters_;
+ mutable sync_primitives::Lock observer_locker_;
+ mutable sync_primitives::Lock message_adapters_locker_;
// Construct message threads when everything is already created
diff --git a/src/components/hmi_message_handler/src/dbus_message_adapter.cc b/src/components/hmi_message_handler/src/dbus_message_adapter.cc
index 00f5ad6be8..5b0b11e557 100644
--- a/src/components/hmi_message_handler/src/dbus_message_adapter.cc
+++ b/src/components/hmi_message_handler/src/dbus_message_adapter.cc
@@ -179,7 +179,8 @@ void DBusMessageAdapter::SendMessageToCore(
// merge
// MessagePriority::FromServiceType(message.servicetype)
// shall be used instead
- message->set_protocol_version(application_manager::ProtocolVersion::kHMI);
+ message->set_protocol_version(
+ protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_HMI);
message->set_smart_object(obj);
handler()->OnMessageReceived(message);
LOG4CXX_INFO(logger_, "Successfully sent to observer");
diff --git a/src/components/hmi_message_handler/src/hmi_message_handler_impl.cc b/src/components/hmi_message_handler/src/hmi_message_handler_impl.cc
index 1c774b9efe..70865f7771 100644
--- a/src/components/hmi_message_handler/src/hmi_message_handler_impl.cc
+++ b/src/components/hmi_message_handler/src/hmi_message_handler_impl.cc
@@ -94,6 +94,7 @@ void HMIMessageHandlerImpl::AddHMIMessageAdapter(HMIMessageAdapter* adapter) {
LOG4CXX_WARN(logger_, "HMIMessageAdapter is not valid!");
return;
}
+ sync_primitives::AutoLock lock(message_adapters_locker_);
message_adapters_.insert(adapter);
}
@@ -104,6 +105,7 @@ void HMIMessageHandlerImpl::RemoveHMIMessageAdapter(
LOG4CXX_WARN(logger_, "HMIMessageAdapter is not valid!");
return;
}
+ sync_primitives::AutoLock lock(message_adapters_locker_);
message_adapters_.erase(adapter);
}
@@ -123,6 +125,7 @@ void HMIMessageHandlerImpl::Handle(const impl::MessageFromHmi message) {
LOG4CXX_INFO(logger_, "Message from hmi given away.");
}
void HMIMessageHandlerImpl::Handle(const impl::MessageToHmi message) {
+ sync_primitives::AutoLock lock(message_adapters_locker_);
for (std::set<HMIMessageAdapter*>::iterator it = message_adapters_.begin();
it != message_adapters_.end();
++it) {
diff --git a/src/components/hmi_message_handler/src/messagebroker_adapter.cc b/src/components/hmi_message_handler/src/messagebroker_adapter.cc
index 27cf9df8cd..abefbe3e24 100644
--- a/src/components/hmi_message_handler/src/messagebroker_adapter.cc
+++ b/src/components/hmi_message_handler/src/messagebroker_adapter.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Ford Motor Company
+ * Copyright (c) 2017, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -135,6 +135,8 @@ void MessageBrokerAdapter::SubscribeTo() {
MessageBrokerController::subscribeTo("SDL.OnDeviceStateChanged");
MessageBrokerController::subscribeTo("SDL.OnPolicyUpdate");
MessageBrokerController::subscribeTo("BasicCommunication.OnEventChanged");
+ MessageBrokerController::subscribeTo("RC.OnInteriorVehicleData");
+ MessageBrokerController::subscribeTo("RC.OnRemoteControlSettings");
LOG4CXX_INFO(logger_, "Subscribed to notifications.");
}
@@ -171,7 +173,8 @@ void MessageBrokerAdapter::ProcessRecievedFromMB(Json::Value& root) {
protocol_handler::MessagePriority::kDefault));
// message->set_message_type()
message->set_json_message(message_string);
- message->set_protocol_version(application_manager::ProtocolVersion::kHMI);
+ message->set_protocol_version(
+ protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_HMI);
if (!handler()) {
LOG4CXX_WARN(logger_, "handler is NULL");
diff --git a/src/components/hmi_message_handler/test/hmi_message_adapter_test.cc b/src/components/hmi_message_handler/test/hmi_message_adapter_test.cc
index b0f63c6a0c..eead7106c6 100644
--- a/src/components/hmi_message_handler/test/hmi_message_adapter_test.cc
+++ b/src/components/hmi_message_handler/test/hmi_message_adapter_test.cc
@@ -42,7 +42,7 @@ namespace test {
namespace components {
namespace hmi_message_handler_test {
-using ::testing::ReturnRef;
+using ::testing::Return;
using hmi_message_handler::HMIMessageHandlerImpl;
typedef utils::SharedPtr<MockHMIMessageAdapterImpl>
@@ -53,7 +53,7 @@ TEST(HMIMessageAdapterImplTest, Handler_CorrectPointer_CorrectReturnedPointer) {
mock_hmi_message_handler_settings;
const uint64_t stack_size = 1000u;
ON_CALL(mock_hmi_message_handler_settings, thread_min_stack_size())
- .WillByDefault(ReturnRef(stack_size));
+ .WillByDefault(Return(stack_size));
HMIMessageHandler* message_handler =
new hmi_message_handler::HMIMessageHandlerImpl(
mock_hmi_message_handler_settings);
diff --git a/src/components/hmi_message_handler/test/hmi_message_handler_impl_test.cc b/src/components/hmi_message_handler/test/hmi_message_handler_impl_test.cc
index 09f20ed75d..33be4a9228 100644
--- a/src/components/hmi_message_handler/test/hmi_message_handler_impl_test.cc
+++ b/src/components/hmi_message_handler/test/hmi_message_handler_impl_test.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Ford Motor Company
+ * Copyright (c) 2017, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -43,7 +43,7 @@ namespace test {
namespace components {
namespace hmi_message_handler_test {
-using ::testing::ReturnRef;
+using ::testing::Return;
using ::testing::_;
class HMIMessageHandlerImplTest : public ::testing::Test {
@@ -63,7 +63,7 @@ class HMIMessageHandlerImplTest : public ::testing::Test {
virtual void SetUp() OVERRIDE {
ON_CALL(mock_hmi_message_handler_settings, thread_min_stack_size())
- .WillByDefault(ReturnRef(stack_size));
+ .WillByDefault(Return(stack_size));
hmi_handler_ = new hmi_message_handler::HMIMessageHandlerImpl(
mock_hmi_message_handler_settings);
ASSERT_TRUE(NULL != hmi_handler_);
diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h
index 180be220cc..c1a37a24f1 100644
--- a/src/components/include/application_manager/application_manager.h
+++ b/src/components/include/application_manager/application_manager.h
@@ -49,6 +49,9 @@
#include "application_manager/state_controller.h"
#include "application_manager/hmi_interfaces.h"
#include "policy/policy_types.h"
+#ifdef SDL_REMOTE_CONTROL
+#include "functional_module/plugin_manager.h"
+#endif
namespace resumption {
class LastState;
@@ -85,6 +88,7 @@ class Application;
class StateControllerImpl;
struct CommandParametersPermissions;
using policy::RPCParams;
+typedef std::vector<ApplicationSharedPtr> AppSharedPtrs;
struct ApplicationsAppIdSorter {
bool operator()(const ApplicationSharedPtr lhs,
const ApplicationSharedPtr rhs) const {
@@ -153,10 +157,35 @@ class ApplicationManager {
virtual ApplicationSharedPtr application_by_policy_id(
const std::string& policy_app_id) const = 0;
- virtual std::vector<ApplicationSharedPtr> applications_by_button(
- uint32_t button) = 0;
- virtual std::vector<ApplicationSharedPtr> applications_with_navi() = 0;
+ virtual AppSharedPtrs applications_by_button(uint32_t button) = 0;
+ virtual AppSharedPtrs applications_with_navi() = 0;
+#ifdef SDL_REMOTE_CONTROL
+ /**
+ * @brief application find application by device and policy identifier
+ * @param device_id device id
+ * @param policy_app_id poilcy identifier
+ * @return pointer to application in case if application exist, in other case
+ * return empty shared pointer
+ */
+ virtual ApplicationSharedPtr application(
+ const std::string& device_id, const std::string& policy_app_id) const = 0;
+
+ virtual void ChangeAppsHMILevel(uint32_t app_id,
+ mobile_apis::HMILevel::eType level) = 0;
+
+ virtual std::vector<std::string> devices(
+ const std::string& policy_app_id) const = 0;
+
+ virtual void SendPostMessageToMobile(const MessagePtr& message) = 0;
+
+ virtual void SendPostMessageToHMI(const MessagePtr& message) = 0;
+
+ virtual functional_modules::PluginManager& GetPluginManager() = 0;
+#endif // SDL_REMOTE_CONTROL
+
+ virtual std::vector<ApplicationSharedPtr>
+ applications_with_mobile_projection() = 0;
/**
* @brief Returns media application with LIMITED HMI Level if exists
*
@@ -182,6 +211,9 @@ class ApplicationManager {
*/
virtual ApplicationSharedPtr get_limited_voice_application() const = 0;
+ virtual ApplicationSharedPtr get_limited_mobile_projection_application()
+ const = 0;
+
/**
* @brief Retrieves application id associated with correlation id
*
@@ -259,9 +291,16 @@ class ApplicationManager {
virtual void SendMessageToHMI(const commands::MessageSharedPtr message) = 0;
+ virtual void RemoveHMIFakeParameters(
+ application_manager::MessagePtr& message) = 0;
+
virtual bool ManageHMICommand(const commands::MessageSharedPtr message) = 0;
virtual bool ManageMobileCommand(const commands::MessageSharedPtr message,
commands::Command::CommandOrigin origin) = 0;
+
+ virtual MessageValidationResult ValidateMessageBySchema(
+ const Message& message) = 0;
+
virtual mobile_api::HMILevel::eType GetDefaultHmiLevel(
ApplicationConstSharedPtr application) const = 0;
/**
@@ -335,8 +374,8 @@ class ApplicationManager {
* @param vehicle_info Enum value of type of vehicle data
* @param new value (for integer values currently) of vehicle data
*/
- virtual std::vector<ApplicationSharedPtr> IviInfoUpdated(
- VehicleDataType vehicle_info, int value) = 0;
+ virtual AppSharedPtrs IviInfoUpdated(VehicleDataType vehicle_info,
+ int value) = 0;
virtual ApplicationSharedPtr RegisterApplication(const utils::SharedPtr<
smart_objects::SmartObject>& request_for_registration) = 0;
@@ -587,9 +626,28 @@ class ApplicationManager {
*/
virtual void ForbidStreaming(uint32_t app_id) = 0;
+ /**
+ * @brief Called when application completes streaming configuration
+ * @param app_id Streaming application id
+ * @param service_type Streaming service type
+ * @param result true if configuration is successful, false otherwise
+ * @param rejected_params list of rejected parameters' name. Valid
+ * only when result is false.
+ */
+ virtual void OnStreamingConfigured(
+ uint32_t app_id,
+ protocol_handler::ServiceType service_type,
+ bool result,
+ std::vector<std::string>& rejected_params) = 0;
+
virtual const ApplicationManagerSettings& get_settings() const = 0;
virtual event_engine::EventDispatcher& event_dispatcher() = 0;
+
+ virtual uint32_t GetAvailableSpaceForApp(const std::string& folder_name) = 0;
+ virtual void OnTimerSendTTSGlobalProperties() = 0;
+ virtual void OnLowVoltage() = 0;
+ virtual void OnWakeUp() = 0;
};
} // namespace application_manager
diff --git a/src/components/include/application_manager/application_manager_settings.h b/src/components/include/application_manager/application_manager_settings.h
index 5bd8e5d208..e745a831c6 100644
--- a/src/components/include/application_manager/application_manager_settings.h
+++ b/src/components/include/application_manager/application_manager_settings.h
@@ -94,6 +94,7 @@ class ApplicationManagerSettings : public RequestControlerSettings,
virtual const uint32_t& app_icons_folder_max_size() const = 0;
virtual const uint32_t& app_icons_amount_to_remove() const = 0;
virtual const uint32_t& list_files_response_size() const = 0;
+ virtual const std::string& plugins_folder() const = 0;
};
} // namespace application_manager
diff --git a/src/components/include/application_manager/hmi_capabilities.h b/src/components/include/application_manager/hmi_capabilities.h
index 556620b644..fb40367b00 100644
--- a/src/components/include/application_manager/hmi_capabilities.h
+++ b/src/components/include/application_manager/hmi_capabilities.h
@@ -90,6 +90,9 @@ class HMICapabilities {
virtual bool is_ivi_cooperating() const = 0;
virtual void set_is_ivi_cooperating(const bool value) = 0;
+ virtual bool is_rc_cooperating() const = 0;
+ virtual void set_is_rc_cooperating(const bool value) = 0;
+
/*
* @brief Interface used to store information about software version of the
*target
@@ -409,6 +412,79 @@ class HMICapabilities {
*/
virtual bool phone_call_supported() const = 0;
+ /*
+ * @brief Interface to store whether HMI supports video streaming
+ *
+ * @param supported Indicates whether video streaming is supported by HMI
+ */
+ virtual void set_video_streaming_supported(const bool supported) = 0;
+
+ /*
+ * @brief Retrieves whether HMI supports video streaming
+ *
+ * @return TRUE if it supported, otherwise FALSE
+ */
+ virtual bool video_streaming_supported() const = 0;
+
+ /*
+ * @brief Interface used to store information regarding
+ * the navigation "System Capability"
+ *
+ * @param navigation_capability contains information related
+ * to the navigation system capability.
+ */
+ virtual void set_navigation_capability(
+ const smart_objects::SmartObject& navigation_capability) = 0;
+
+ /*
+ * @brief Retrieves information regarding the navigation system capability
+ *
+ * @return NAVIGATION system capability
+ */
+ virtual const smart_objects::SmartObject* navigation_capability() const = 0;
+
+ /*
+ * @brief Interface used to store information regarding
+ * the phone "System Capability"
+ *
+ * @param phone_capability contains information related
+ * to the phone system capability.
+ */
+ virtual void set_phone_capability(
+ const smart_objects::SmartObject& phone_capability) = 0;
+
+ /*
+ * @brief Retrieves information regarding the phone call system capability
+ *
+ * @return PHONE_CALL system capability
+ */
+ virtual const smart_objects::SmartObject* phone_capability() const = 0;
+
+ /*
+ * @brief Sets HMI's video streaming related capability information
+ *
+ * @param video_streaming_capability the video streaming related capabilities
+ */
+ virtual void set_video_streaming_capability(
+ const smart_objects::SmartObject& video_streaming_capability) = 0;
+
+ /*
+ * @brief Retrieves HMI's video streaming related capabilities
+ *
+ * @return HMI's video streaming related capability information
+ */
+ virtual const smart_objects::SmartObject* video_streaming_capability()
+ const = 0;
+
+ /**
+ * @brief Sets available RC capabilities for further usage by RC functionality
+ * @param rc_capability capabilities to set
+ */
+ virtual void set_rc_capability(
+ const smart_objects::SmartObject& rc_capability) = 0;
+
+ virtual const smart_objects::SmartObject* rc_capability() const = 0;
+
virtual void Init(resumption::LastState* last_state) = 0;
/**
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 c5af16863a..d7e9f1cea7 100644
--- a/src/components/include/application_manager/policies/policy_handler_interface.h
+++ b/src/components/include/application_manager/policies/policy_handler_interface.h
@@ -40,6 +40,7 @@
#include <queue>
#include "interfaces/MOBILE_API.h"
#include "application_manager/policies/policy_handler_observer.h"
+#include "application_manager/core_service.h"
#include "application_manager/application.h"
#include "policy/usage_statistics/statistics_manager.h"
#include "utils/custom_string.h"
@@ -105,8 +106,18 @@ class PolicyHandlerInterface {
EndpointUrls& out_end_points) = 0;
virtual std::string GetLockScreenIconUrl() const = 0;
virtual uint32_t NextRetryTimeout() = 0;
- virtual uint32_t TimeoutExchangeSec() = 0;
- virtual uint32_t TimeoutExchangeMSec() = 0;
+
+ /**
+ * Gets timeout to wait until receive response
+ * @return timeout in seconds
+ */
+ virtual uint32_t TimeoutExchangeSec() const = 0;
+
+ /**
+ * Gets timeout to wait until receive response
+ * @return timeout in miliseconds
+ */
+ virtual uint32_t TimeoutExchangeMSec() const = 0;
virtual void OnExceededTimeout() = 0;
virtual void OnSystemReady() = 0;
virtual void PTUpdatedAt(Counters counter, int value) = 0;
@@ -416,6 +427,73 @@ class PolicyHandlerInterface {
virtual const PolicySettings& get_settings() const = 0;
virtual const std::string RemoteAppsUrl() const = 0;
+#ifdef SDL_REMOTE_CONTROL
+ /**
+ * @brief Sets HMI default type for specified application
+ * @param application_id ID application
+ * @param app_types list of HMI types
+ */
+ virtual void SetDefaultHmiTypes(
+ const std::string& application_id,
+ const smart_objects::SmartObject* app_types) = 0;
+
+ /**
+ * Checks if application has HMI type
+ * @param application_id ID application
+ * @param hmi HMI type to check
+ * @param app_types additional list of HMI type to search in it
+ * @return true if hmi is contained in policy or app_types
+ */
+ virtual bool CheckHMIType(const std::string& application_id,
+ mobile_apis::AppHMIType::eType hmi,
+ const smart_objects::SmartObject* app_types) = 0;
+
+ /**
+ * Notifies about changing HMI level
+ * @param device_id unique identifier of device
+ * @param policy_app_id unique identifier of application in policy
+ * @param hmi_level default HMI level for this application
+ */
+ virtual void OnUpdateHMILevel(const std::string& device_id,
+ const std::string& policy_app_id,
+ const std::string& hmi_level) = 0;
+
+ /**
+ * Checks if module for application is present in policy table
+ * @param app_id id of application
+ * @param module type
+ * @return true if module is present, otherwise - false
+ */
+ virtual bool CheckModule(const PTString& app_id, const PTString& module) = 0;
+
+ /**
+ * @brief Notifies Remote apps about change in permissions
+ * @param device_id Device on which app is running
+ * @param application_id ID of app whose permissions are changed
+ */
+ virtual void OnRemoteAppPermissionsChanged(
+ const std::string& device_id, const std::string& application_id) = 0;
+
+ /**
+ * @brief Notifies Remote apps about change in HMI status
+ * @param device_id Device on which app is running
+ * @param policy_app_id ID of application
+ * @param hmi_level new HMI level for this application
+ */
+ virtual void OnUpdateHMIStatus(const std::string& device_id,
+ const std::string& policy_app_id,
+ const std::string& hmi_level) = 0;
+
+ /**
+ * Gets all allowed module types
+ * @param app_id unique identifier of application
+ * @param list of allowed module types
+ * @return true if application has allowed modules
+ */
+ virtual bool GetModuleTypes(const std::string& policy_app_id,
+ std::vector<std::string>* modules) const = 0;
+#endif // SDL_REMOTE_CONTROL
+
private:
/**
* @brief Processes data received via OnAppPermissionChanged notification
diff --git a/src/components/include/connection_handler/connection_handler.h b/src/components/include/connection_handler/connection_handler.h
index e8e1af715a..c70861b5f6 100644
--- a/src/components/include/connection_handler/connection_handler.h
+++ b/src/components/include/connection_handler/connection_handler.h
@@ -198,6 +198,22 @@ class ConnectionHandler {
virtual DevicesDiscoveryStarter& get_device_discovery_starter() = 0;
+ /**
+ * \brief Invoked when observer's OnServiceStartedCallback is completed
+ * \param session_key the key of started session passed to
+ * OnServiceStartedCallback().
+ * \param result true if observer accepts starting service, false otherwise
+ * \param rejected_params list of rejected parameters' name. Only valid when
+ * result is false. Note that even if result is false, this may be empty.
+ *
+ * \note This is invoked only once but can be invoked by multiple threads.
+ * Also it can be invoked before OnServiceStartedCallback() returns.
+ **/
+ virtual void NotifyServiceStartedResult(
+ uint32_t session_key,
+ bool result,
+ std::vector<std::string>& rejected_params) = 0;
+
protected:
/**
* \brief Destructor
diff --git a/src/components/include/connection_handler/connection_handler_observer.h b/src/components/include/connection_handler/connection_handler_observer.h
index e25b0aaea5..6bfc78af24 100644
--- a/src/components/include/connection_handler/connection_handler_observer.h
+++ b/src/components/include/connection_handler/connection_handler_observer.h
@@ -42,6 +42,8 @@
#include "security_manager/ssl_context.h"
#endif // ENABLE_SECURITY
+struct BsonObject;
+
/**
* \namespace connection_handler
* \brief SmartDeviceLink connection_handler namespace.
@@ -95,6 +97,22 @@ class ConnectionHandlerObserver {
/**
* \brief Callback function used by connection_handler
+ * when Mobile Application initiates start of new service.
+ * Result must be notified through NotifyServiceStartedResult().
+ * \param deviceHandle Device identifier within which session has to be
+ * started.
+ * \param sessionKey Key of started session.
+ * \param type Established service type
+ * \param params Configuration parameters for this service
+ */
+ virtual void OnServiceStartedCallback(
+ const connection_handler::DeviceHandle& device_handle,
+ const int32_t& session_key,
+ const protocol_handler::ServiceType& type,
+ const BsonObject* params) = 0;
+
+ /**
+ * \brief Callback function used by connection_handler
* when Mobile Application initiates service ending.
* \param session_key Key of session which should be ended
* \param type Type of service which should be ended
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 10e4231528..704cc619be 100644
--- a/src/components/include/hmi_message_handler/hmi_message_adapter.h
+++ b/src/components/include/hmi_message_handler/hmi_message_adapter.h
@@ -43,6 +43,12 @@ namespace hmi_message_handler {
* SDL with HMI has to implement this interface.
*/
class HMIMessageAdapter : public HMIMessageSender {
+ public:
+ /**
+ * \brief Destructor
+ */
+ virtual ~HMIMessageAdapter() {}
+
protected:
/**
* \brief Interface for subscriptions.
diff --git a/src/components/include/hmi_message_handler/hmi_message_handler_settings.h b/src/components/include/hmi_message_handler/hmi_message_handler_settings.h
index 5386869555..8b24f2cf7d 100644
--- a/src/components/include/hmi_message_handler/hmi_message_handler_settings.h
+++ b/src/components/include/hmi_message_handler/hmi_message_handler_settings.h
@@ -44,7 +44,7 @@ class HMIMessageHandlerSettings {
public:
virtual ~HMIMessageHandlerSettings() {}
- virtual const uint64_t& thread_min_stack_size() const = 0;
+ virtual const uint64_t thread_min_stack_size() const = 0;
};
} // namespace hmi_message_handler
#endif // SRC_COMPONENTS_INCLUDE_HMI_MESSAGE_HANDLER_HMI_MESSAGE_HANDLER_SETTINGS_H_
diff --git a/src/components/include/hmi_message_handler/hmi_message_observer.h b/src/components/include/hmi_message_handler/hmi_message_observer.h
index aef1e33379..0676615b53 100644
--- a/src/components/include/hmi_message_handler/hmi_message_observer.h
+++ b/src/components/include/hmi_message_handler/hmi_message_observer.h
@@ -43,6 +43,7 @@ namespace hmi_message_handler {
class HMIMessageObserver {
public:
+ virtual ~HMIMessageObserver() {}
virtual void OnMessageReceived(
utils::SharedPtr<application_manager::Message> message) = 0;
virtual void OnErrorSending(
diff --git a/src/components/include/hmi_message_handler/hmi_message_sender.h b/src/components/include/hmi_message_handler/hmi_message_sender.h
index 95ed2c63c4..91c20a1986 100644
--- a/src/components/include/hmi_message_handler/hmi_message_sender.h
+++ b/src/components/include/hmi_message_handler/hmi_message_sender.h
@@ -40,6 +40,7 @@ typedef utils::SharedPtr<application_manager::Message> MessageSharedPointer;
class HMIMessageSender {
public:
+ virtual ~HMIMessageSender() {}
virtual void SendMessageToHMI(MessageSharedPointer message) = 0;
};
}
diff --git a/src/components/include/policy/policy_external/policy/policy_listener.h b/src/components/include/policy/policy_external/policy/policy_listener.h
index f3388beb95..e850a3fa2b 100644
--- a/src/components/include/policy/policy_external/policy/policy_listener.h
+++ b/src/components/include/policy/policy_external/policy/policy_listener.h
@@ -30,8 +30,8 @@
POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_POLICY_LISTENER_H_
-#define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_POLICY_LISTENER_H_
+#ifndef SRC_COMPONENTS_INCLUDE_POLICY_POLICY_EXTERNAL_POLICY_POLICY_LISTENER_H_
+#define SRC_COMPONENTS_INCLUDE_POLICY_POLICY_EXTERNAL_POLICY_POLICY_LISTENER_H_
#include <queue>
@@ -52,12 +52,13 @@ class PolicyListener {
const Permissions& permissions) = 0;
virtual void OnPendingPermissionChange(const std::string& policy_app_id) = 0;
virtual void OnUpdateStatusChanged(const std::string&) = 0;
+
/**
- * Gets device ID
- * @param policy_app_id
- * @return device ID
- * @deprecated see std::vector<std::string> GetDevicesIds(const std::string&)
- */
+ * Gets device ID
+ * @param policy_app_id
+ * @return device ID
+ * @deprecated see std::vector<std::string> GetDevicesIds(const std::string&)
+ */
virtual std::string OnCurrentDeviceIdUpdateRequired(
const std::string& policy_app_id) = 0;
virtual void OnSystemInfoUpdateRequired() = 0;
@@ -67,12 +68,12 @@ class PolicyListener {
std::map<std::string, StringArray> app_hmi_types) = 0;
/**
- * @brief CanUpdate allows to find active application
- * and check whether related device consented.
- *
- * @return true if there are at least one application has been registered
- * with consented device.
- */
+ * @brief CanUpdate allows to find active application
+ * and check whether related device consented.
+ *
+ * @return true if there are at least one application has been registered
+ * with consented device.
+ */
virtual bool CanUpdate() = 0;
/**
@@ -129,12 +130,51 @@ class PolicyListener {
virtual void OnPTUFinished(const bool ptu_result) = 0;
/**
- * @brief Collects currently registered applications ids linked to their
- * device id
- * @return Collection of device_id-to-app_id links
- */
+ * @brief Collects currently registered applications ids linked to their
+ * device id
+ * @return Collection of device_id-to-app_id links
+ */
virtual void GetRegisteredLinks(
std::map<std::string, std::string>& out_links) const = 0;
+
+#ifdef SDL_REMOTE_CONTROL
+ /**
+ * Gets devices ids by policy application id
+ * @param policy_app_id
+ * @return list devices ids
+ */
+ virtual std::vector<std::string> GetDevicesIds(
+ const std::string& policy_app_id) = 0;
+
+ /**
+ * Notifies about changing HMI level
+ * @param device_id unique identifier of device
+ * @param policy_app_id unique identifier of application in policy
+ * @param hmi_level default HMI level for this application
+ */
+ virtual void OnUpdateHMILevel(const std::string& device_id,
+ const std::string& policy_app_id,
+ const std::string& hmi_level) = 0;
+
+ /**
+ * @brief Notifies Remote apps about change in permissions
+ * @param device_id Device on which app is running
+ * @param application_id ID of app whose permissions are changed
+ */
+ virtual void OnRemoteAppPermissionsChanged(
+ const std::string& device_id, const std::string& application_id) = 0;
+
+ /**
+ * Notifies about changing HMI status
+ * @param device_id unique identifier of device
+ * @param policy_app_id unique identifier of application in policy
+ * @param hmi_level default HMI level for this application
+ */
+ virtual void OnUpdateHMIStatus(const std::string& device_id,
+ const std::string& policy_app_id,
+ const std::string& hmi_level) = 0;
+
+#endif // SDL_REMOTE_CONTROL
};
-} // namespace policy
-#endif // SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_POLICY_LISTENER_H_
+} // namespace policy
+#endif // SRC_COMPONENTS_INCLUDE_POLICY_POLICY_EXTERNAL_POLICY_POLICY_LISTENER_H_
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 9201956e2a..adf195e3a9 100644
--- a/src/components/include/policy/policy_external/policy/policy_manager.h
+++ b/src/components/include/policy/policy_external/policy/policy_manager.h
@@ -30,8 +30,8 @@
POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_INCLUDE_POLICY_POLICY_MANAGER_H_
-#define SRC_COMPONENTS_INCLUDE_POLICY_POLICY_MANAGER_H_
+#ifndef SRC_COMPONENTS_INCLUDE_POLICY_POLICY_EXTERNAL_POLICY_POLICY_MANAGER_H_
+#define SRC_COMPONENTS_INCLUDE_POLICY_POLICY_EXTERNAL_POLICY_POLICY_MANAGER_H_
#include <vector>
@@ -40,7 +40,11 @@
#include "policy/policy_types.h"
#include "policy/policy_table/types.h"
#include "policy/policy_listener.h"
-#include "usage_statistics/statistics_manager.h"
+#include "policy/usage_statistics/statistics_manager.h"
+
+#ifdef SDL_REMOTE_CONTROL
+#include "policy/access_remote.h"
+#endif // SDL_REMOTE_CONTROL
namespace policy {
class PolicySettings;
@@ -55,12 +59,17 @@ class PolicyManager : public usage_statistics::StatisticsManager {
enum NotificationMode { kSilentMode, kNotifyApplicationMode };
virtual ~PolicyManager() {}
+ /**
+ * @brief set_listener set new policy listener instance
+ * @param listener new policy listener
+ */
virtual void set_listener(PolicyListener* listener) = 0;
/**
- * Inits Policy Table
- * @param file_name Path to preloaded PT file
- * @return true if successfully
+ * @brief Inits Policy Table
+ * @param file_name path to preloaded PT file
+ * @param settings pointer to policy init settings
+ * @return true if init is successful
*/
virtual bool InitPT(const std::string& file_name,
const PolicySettings* settings) = 0;
@@ -71,26 +80,30 @@ class PolicyManager : public usage_statistics::StatisticsManager {
* sent in snapshot and received Policy Table.
* @param file name of file with update policy table
* @param pt_content PTU as binary string
- * @return bool Success of operation
+ * @return true if successfully
*/
virtual bool LoadPT(const std::string& file,
const BinaryMessage& pt_content) = 0;
/**
- * Resets Policy Table
+ * @brief Resets Policy Table
* @param file_name Path to preloaded PT file
* @return true if successfully
*/
virtual bool ResetPT(const std::string& file_name) = 0;
+ /**
+ * @brief Gets last URL for sending PTS to from PT itself
+ * @param service_type Service specifies user of URL
+ * @return last URL or empty string if endpoint entry is empty
+ */
virtual std::string GetUpdateUrl(int service_type) = 0;
/**
- * @brief Gets all URLs for sending PTS to from PT itself.
- * @param service_type Service specifies user of URL
- * @return vector of urls
- */
-
+ * @brief Gets all URLs for sending PTS to from PT itself.
+ * @param service_type Service specifies user of URL
+ * @return vector of urls
+ */
virtual void GetUpdateUrls(const uint32_t service_type,
EndpointUrls& out_end_points) = 0;
virtual void GetUpdateUrls(const std::string& service_type,
@@ -98,7 +111,6 @@ class PolicyManager : public usage_statistics::StatisticsManager {
/**
* @brief GetLockScreenIcon allows to obtain lock screen icon url;
- *
* @return url which point to the resourse where lock screen icon could be
*obtained.
*/
@@ -116,6 +128,7 @@ class PolicyManager : public usage_statistics::StatisticsManager {
* @param app_id Id of application provided during registration
* @param hmi_level Current HMI Level of application
* @param rpc Name of RPC
+ * @param rpc_params List of RPC params
* @param CheckPermissionResult containing flag if HMI Level is allowed
* and list of allowed params.
*/
@@ -138,41 +151,43 @@ class PolicyManager : public usage_statistics::StatisticsManager {
virtual std::string GetPolicyTableStatus() const = 0;
/**
- * Checks is PT exceeded kilometers
+ * @brief Checks is PT exceeded kilometers
* @param kilometers current kilometers at odometer
* @return true if exceeded
*/
virtual void KmsChanged(int kilometers) = 0;
/**
- * Increments counter of ignition cycles
+ * @brief Increments counter of ignition cycles
*/
virtual void IncrementIgnitionCycles() = 0;
/**
* @brief Exchange by hmi or mobile request
+ * @return Current status of policy table
*/
virtual std::string ForcePTExchange() = 0;
/**
- * @brief ExchangeByUserRequest
+ * @brief Exchange by user request
+ * @return Current status of policy table
*/
virtual std::string ForcePTExchangeAtUserRequest() = 0;
/**
- * Resets retry sequence
+ * @brief Resets retry sequence
*/
virtual void ResetRetrySequence() = 0;
/**
- * Gets timeout to wait before next retry updating PT
+ * @brief Gets timeout to wait before next retry updating PT
* If timeout is less or equal to zero then the retry sequence is not need.
* @return timeout in seconds
*/
virtual int NextRetryTimeout() = 0;
/**
- * Gets timeout to wait until receive response
+ * @brief Gets timeout to wait until receive response
* @return timeout in seconds
*/
virtual uint32_t TimeoutExchangeMSec() = 0;
@@ -185,7 +200,7 @@ class PolicyManager : public usage_statistics::StatisticsManager {
virtual const std::vector<int> RetrySequenceDelaysSeconds() = 0;
/**
- * Handler of exceeding timeout of exchanging policy table
+ * @brief Handler of exceeding timeout of exchanging policy table
*/
virtual void OnExceededTimeout() = 0;
@@ -224,21 +239,24 @@ class PolicyManager : public usage_statistics::StatisticsManager {
/**
* @brief Update Application Policies as reaction
* on User allowing/disallowing device this app is running on.
+ * @param app_id Unique application id
+ * @param is_device_allowed true if user allowing device otherwise false
+ * @return true if operation was successful
*/
virtual bool ReactOnUserDevConsentForApp(const std::string& app_id,
const bool is_device_allowed) = 0;
/**
- * Sets counter value that passed for receiving PT UPdate.
+ * @brief Sets counter value that passed for receiving PT UPdate.
*/
virtual void PTUpdatedAt(Counters counter, int value) = 0;
/**
* @brief Retrieves data from app_policies about app on its registration:
- * @param app_id - id of registered app
- * @param app_types Section on HMI where app can appear (Navigation, Phone
- * etc)
+ * @param application_id - id of registered app
* @param nicknames Synonyms for application
+ * @param app_hmi_types Section on HMI where app can appear (Navigation, Phone
+ * etc)
*/
virtual bool GetInitialAppData(const std::string& application_id,
StringArray* nicknames = NULL,
@@ -267,6 +285,7 @@ class PolicyManager : public usage_statistics::StatisticsManager {
* The permissions is not const reference because it may contains
* valid data as well as invalid. So we will remove all invalid data
* from this structure.
+ * @param mode notification mode
*/
virtual void SetUserConsentForApp(const PermissionConsent& permissions,
const NotificationMode mode) = 0;
@@ -294,6 +313,7 @@ class PolicyManager : public usage_statistics::StatisticsManager {
* @brief Get user friendly messages for given RPC messages and language
* @param message_codes RPC message codes
* @param language Language
+ * @param active_hmi_language Currently active language
* @return Array of structs with appropriate message parameters
*/
virtual std::vector<UserFriendlyMessage> GetUserFriendlyMessages(
@@ -302,7 +322,7 @@ class PolicyManager : public usage_statistics::StatisticsManager {
const std::string& active_hmi_language) = 0;
/**
- * Checks if the application is revoked
+ * @brief Checks if the application is revoked
* @param app_id application id
* @return true if application is revoked
*/
@@ -329,11 +349,15 @@ class PolicyManager : public usage_statistics::StatisticsManager {
virtual AppPermissions GetAppPermissionsChanges(
const std::string& policy_app_id) = 0;
+ /**
+ * @brief Removes specific application permissions changes
+ * @param app_id Unique application id
+ */
virtual void RemovePendingPermissionChanges(const std::string& app_id) = 0;
/**
* @brief Return device id, which hosts specific application
- * @param Application id, which is required to update device id
+ * @param policy_app_id Application id, which is required to update device id
*/
virtual std::string& GetCurrentDeviceId(
const std::string& policy_app_id) const = 0;
@@ -356,13 +380,13 @@ class PolicyManager : public usage_statistics::StatisticsManager {
/**
* @brief Send OnPermissionsUpdated for choosen application
- * @param application_id
+ * @param application_id Unique application id
*/
virtual void SendNotificationOnPermissionsUpdated(
const std::string& application_id) = 0;
/**
- * Marks device as upaired
+ * @brief Marks device as upaired
* @param device_id id device
*/
virtual void MarkUnpairedDevice(const std::string& device_id) = 0;
@@ -370,7 +394,8 @@ class PolicyManager : public usage_statistics::StatisticsManager {
/**
* @brief Adds, application to the db or update existed one
* run PTU if policy update is necessary for application.
- * @param Application id assigned by Ford to the application
+ * @param application_id Unique application id
+ * @param hmi_types application HMI types
* @return function that will notify update manager about new application
*/
virtual StatusNotifier AddApplication(
@@ -379,18 +404,21 @@ class PolicyManager : public usage_statistics::StatisticsManager {
/**
* @brief Removes unpaired device records and related records from DB
- * @param device_ids List of device_id, which should be removed
* @return true, if succedeed, otherwise - false
*/
virtual bool CleanupUnpairedDevices() = 0;
/**
* @brief Check if app can keep context.
+ * @param app_id Unique application id
+ * @return true if app can keep context, otherwise - false
*/
virtual bool CanAppKeepContext(const std::string& app_id) const = 0;
/**
* @brief Check if app can steal focus.
+ * @param app_id Unique application id
+ * @return true if app can steal focus, otherwise - false
*/
virtual bool CanAppStealFocus(const std::string& app_id) const = 0;
@@ -402,9 +430,9 @@ class PolicyManager : public usage_statistics::StatisticsManager {
virtual void OnSystemReady() = 0;
/**
- * @brief GetNotificationNumber
- * @param priority
- * @return
+ * @brief Get number of notification by priority
+ * @param priority Specified priority
+ * @return notification number
*/
virtual uint32_t GetNotificationsNumber(
const std::string& priority) const = 0;
@@ -423,7 +451,7 @@ class PolicyManager : public usage_statistics::StatisticsManager {
virtual bool IsPredataPolicy(const std::string& policy_app_id) const = 0;
/**
- * Returns heart beat timeout
+ * @brief Returns heart beat timeout
* @param app_id application id
* @return if timeout was set then value in milliseconds greater zero
* otherwise heart beat for specific application isn't set
@@ -431,7 +459,8 @@ class PolicyManager : public usage_statistics::StatisticsManager {
virtual uint32_t HeartBeatTimeout(const std::string& app_id) const = 0;
/**
- * @brief SaveUpdateStatusRequired alows to save update status.
+ * @brief SaveUpdateStatusRequired allows to save update status.
+ * @param is_update_needed true if update needed
*/
virtual void SaveUpdateStatusRequired(bool is_update_needed) = 0;
@@ -442,14 +471,14 @@ class PolicyManager : public usage_statistics::StatisticsManager {
/**
* @brief Handler on applications search completed
+ * @param trigger_ptu contains true if PTU should be triggered
*/
virtual void OnAppsSearchCompleted(const bool trigger_ptu) = 0;
/**
* @brief OnAppRegisteredOnMobile allows to handle event when application were
* succesfully registered on mobile device.
- * It will send OnAppPermissionSend notification and will try to start PTU.
- *
+ * It will send OnAppPermissionSend notification and will try to start PTU. *
* @param application_id registered application.
*/
virtual void OnAppRegisteredOnMobile(const std::string& application_id) = 0;
@@ -457,13 +486,14 @@ class PolicyManager : public usage_statistics::StatisticsManager {
/**
* @brief Gets request types for application
* @param policy_app_id Unique application id
- * @return request_types Request types of application
+ * @return request types of application
*/
virtual const std::vector<std::string> GetAppRequestTypes(
const std::string policy_app_id) const = 0;
/**
* @brief Get information about vehicle
+ * @return vehicle information
*/
virtual const VehicleInfo GetVehicleInfo() const = 0;
@@ -476,7 +506,6 @@ class PolicyManager : public usage_statistics::StatisticsManager {
/**
* @brief RetrieveCertificate Allows to obtain certificate in order
* to start secure connection.
- *
* @return The certificate in PKCS#7 format.
*/
virtual std::string RetrieveCertificate() const = 0;
@@ -484,7 +513,6 @@ class PolicyManager : public usage_statistics::StatisticsManager {
/**
* @brief HasCertificate check whether policy table has certificate
* int module_config section.
- *
* @return true in case certificate exists, false otherwise
*/
virtual bool HasCertificate() const = 0;
@@ -495,6 +523,10 @@ class PolicyManager : public usage_statistics::StatisticsManager {
*/
virtual void SetDecryptedCertificate(const std::string& certificate) = 0;
+ /**
+ * @brief Getter for policy settings
+ * @return policy settings instance
+ */
virtual const PolicySettings& get_settings() const = 0;
/**
@@ -505,6 +537,57 @@ class PolicyManager : public usage_statistics::StatisticsManager {
*/
virtual AppIdURL GetNextUpdateUrl(const EndpointUrls& urls) = 0;
+#ifdef SDL_REMOTE_CONTROL
+ /**
+ * @brief Assigns new HMI types for specified application
+ * @param application_id Unique application id
+ * @param hmi_types new HMI types list
+ */
+ virtual void SetDefaultHmiTypes(const std::string& application_id,
+ const std::vector<int>& hmi_types) = 0;
+ /**
+ * @brief Gets HMI types
+ * @param application_id ID application
+ * @param app_types list to save HMI types
+ * @return true if policy has specific policy for this application
+ */
+ virtual bool GetHMITypes(const std::string& application_id,
+ std::vector<int>* app_types) = 0;
+
+ /**
+ * @brief Checks if module for application is present in policy table
+ * @param app_id id of application
+ * @param module type
+ * @return true if module is present, otherwise - false
+ */
+ virtual bool CheckModule(const PTString& app_id, const PTString& module) = 0;
+
+ /**
+ * @brief Send OnPermissionsChange notification to mobile app
+ * when it's permissions are changed.
+ * @param device_id Device on which app is running
+ * @param application_id ID of app whose permissions are changed
+ */
+ virtual void SendAppPermissionsChanged(const std::string& device_id,
+ const std::string& application_id) = 0;
+
+ /**
+ * @brief Gets all allowed module types
+ * @param policy_app_id unique identifier of application
+ * @param modules list of allowed module types
+ * @return true if application has allowed modules
+ */
+ virtual bool GetModuleTypes(const std::string& policy_app_id,
+ std::vector<std::string>* modules) const = 0;
+
+ /**
+ * @brief Setter for access_remote instance
+ * @param access_remote pointer to new access_remote instance
+ */
+ virtual void set_access_remote(
+ utils::SharedPtr<AccessRemote> access_remote) = 0;
+#endif // SDL_REMOTE_CONTROL
+
/**
* @brief Checks if there is existing URL in the EndpointUrls vector with
* index saved in the policy manager and if not, it moves to the next
@@ -518,11 +601,11 @@ class PolicyManager : public usage_statistics::StatisticsManager {
const EndpointUrls& urls) const = 0;
/**
- * @brief Checks, if SDL needs to update it's policy table "external consent
- * status" section
- * @param status ExternalConsent status
- * @return true if there's such a need, otherwise - false
- */
+ * @brief Checks, if SDL needs to update it's policy table section
+ "external_consent_status"
+ * @param ExternalConsent status
+ * @return true if such check is needed, false - if not.
+ */
virtual bool IsNeedToUpdateExternalConsentStatus(
const ExternalConsentStatus& status) const = 0;
@@ -536,19 +619,19 @@ class PolicyManager : public usage_statistics::StatisticsManager {
/**
* @brief Gets customer connectivity settings status
- * @return external consent status
+ * @return ExternalConsent status
*/
virtual ExternalConsentStatus GetExternalConsentStatus() = 0;
protected:
/**
- * Checks is PT exceeded IgnitionCycles
+ * @brief Checks is PT exceeded IgnitionCycles
* @return true if exceeded
*/
virtual bool ExceededIgnitionCycles() = 0;
/**
- * Checks is PT exceeded days
+ * @brief Checks is PT exceeded days
* @return true if exceeded
*/
virtual bool ExceededDays() = 0;
@@ -566,4 +649,4 @@ class PolicyManager : public usage_statistics::StatisticsManager {
extern "C" policy::PolicyManager* CreateManager();
extern "C" void DeleteManager(policy::PolicyManager*);
-#endif // SRC_COMPONENTS_INCLUDE_POLICY_POLICY_MANAGER_H_
+#endif // SRC_COMPONENTS_INCLUDE_POLICY_POLICY_EXTERNAL_POLICY_POLICY_MANAGER_H_
diff --git a/src/components/include/policy/policy_external/policy/usage_statistics/app_stopwatch.h b/src/components/include/policy/policy_external/policy/usage_statistics/app_stopwatch.h
index 45883163c4..3f01a30a62 100644
--- a/src/components/include/policy/policy_external/policy/usage_statistics/app_stopwatch.h
+++ b/src/components/include/policy/policy_external/policy/usage_statistics/app_stopwatch.h
@@ -30,10 +30,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_INCLUDE_POLICY_USAGE_STATISTICS_APP_STOPWATCH_H_
-#define SRC_COMPONENTS_INCLUDE_POLICY_USAGE_STATISTICS_APP_STOPWATCH_H_
+#ifndef SRC_COMPONENTS_INCLUDE_POLICY_POLICY_EXTERNAL_POLICY_USAGE_STATISTICS_APP_STOPWATCH_H_
+#define SRC_COMPONENTS_INCLUDE_POLICY_POLICY_EXTERNAL_POLICY_USAGE_STATISTICS_APP_STOPWATCH_H_
-#include "statistics_manager.h"
+#include "policy/usage_statistics/statistics_manager.h"
namespace usage_statistics {
@@ -47,4 +47,4 @@ class AppStopwatch {
} // namespace usage_statistics
-#endif // SRC_COMPONENTS_INCLUDE_POLICY_USAGE_STATISTICS_APP_STOPWATCH_H_
+#endif // SRC_COMPONENTS_INCLUDE_POLICY_POLICY_EXTERNAL_POLICY_USAGE_STATISTICS_APP_STOPWATCH_H_
diff --git a/src/components/include/policy/policy_external/policy/usage_statistics/statistics_manager.h b/src/components/include/policy/policy_external/policy/usage_statistics/statistics_manager.h
index a74bb0592e..7186400ff4 100644
--- a/src/components/include/policy/policy_external/policy/usage_statistics/statistics_manager.h
+++ b/src/components/include/policy/policy_external/policy/usage_statistics/statistics_manager.h
@@ -30,19 +30,25 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_INCLUDE_POLICY_USAGE_STATISTICS_STATISTICS_MANAGER_H_
-#define SRC_COMPONENTS_INCLUDE_POLICY_USAGE_STATISTICS_STATISTICS_MANAGER_H_
+#ifndef SRC_COMPONENTS_INCLUDE_POLICY_POLICY_EXTERNAL_POLICY_USAGE_STATISTICS_STATISTICS_MANAGER_H_
+#define SRC_COMPONENTS_INCLUDE_POLICY_POLICY_EXTERNAL_POLICY_USAGE_STATISTICS_STATISTICS_MANAGER_H_
#include <stdint.h>
#include <string>
namespace usage_statistics {
-enum GlobalCounterId { IAP_BUFFER_FULL, SYNC_OUT_OF_MEMORY, SYNC_REBOOTS };
+enum GlobalCounterId {
+ GLOBAL_COUNTER_NONE,
+ IAP_BUFFER_FULL,
+ SYNC_OUT_OF_MEMORY,
+ SYNC_REBOOTS
+};
-enum AppInfoId { LANGUAGE_GUI, LANGUAGE_VUI };
+enum AppInfoId { APP_INFO_NONE, LANGUAGE_GUI, LANGUAGE_VUI };
enum AppStopwatchId {
+ STOPWATCH_NONE,
SECONDS_HMI_FULL,
SECONDS_HMI_LIMITED,
SECONDS_HMI_BACKGROUND,
@@ -50,6 +56,7 @@ enum AppStopwatchId {
};
enum AppCounterId {
+ APP_COUNTER_NONE,
USER_SELECTIONS,
REJECTIONS_SYNC_OUT_OF_MEMORY,
REJECTIONS_NICKNAME_MISMATCH,
@@ -64,11 +71,36 @@ enum AppCounterId {
class StatisticsManager {
public:
virtual ~StatisticsManager() {}
+
+ /**
+ * @brief Increments global counter
+ * @param type counter type
+ */
virtual void Increment(GlobalCounterId type) = 0;
+
+ /**
+ * @brief Increments specified application counter
+ * @param app_id Unique ID of application
+ * @param type application counter type
+ */
virtual void Increment(const std::string& app_id, AppCounterId type) = 0;
+
+ /**
+ * @brief Sets specified application info value
+ * @param app_id Unique ID of application
+ * @param type application info type
+ * @param value new value for counter
+ */
virtual void Set(const std::string& app_id,
AppInfoId type,
const std::string& value) = 0;
+
+ /**
+ * @brief Add seconds for specified application stopwatch
+ * @param app_id Unique ID of application
+ * @param type application stopwatch type
+ * @param timespan_seconds seconds to add
+ */
virtual void Add(const std::string& app_id,
AppStopwatchId type,
int32_t timespan_seconds) = 0;
@@ -76,4 +108,4 @@ class StatisticsManager {
} // namespace usage_statistics
-#endif // SRC_COMPONENTS_INCLUDE_POLICY_USAGE_STATISTICS_STATISTICS_MANAGER_H_
+#endif // SRC_COMPONENTS_INCLUDE_POLICY_POLICY_EXTERNAL_POLICY_USAGE_STATISTICS_STATISTICS_MANAGER_H_
diff --git a/src/components/policy/policy_regular/include/policy/policy_listener.h b/src/components/include/policy/policy_regular/policy/policy_listener.h
index 0170f421e4..e8de37d5de 100644
--- a/src/components/policy/policy_regular/include/policy/policy_listener.h
+++ b/src/components/include/policy/policy_regular/policy/policy_listener.h
@@ -30,8 +30,8 @@
POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_POLICY_LISTENER_H_
-#define SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_POLICY_LISTENER_H_
+#ifndef SRC_COMPONENTS_INCLUDE_POLICY_POLICY_REGULAR_POLICY_POLICY_LISTENER_H_
+#define SRC_COMPONENTS_INCLUDE_POLICY_POLICY_REGULAR_POLICY_POLICY_LISTENER_H_
#include <queue>
@@ -111,6 +111,45 @@ class PolicyListener {
* @param certificate_data the value of the updated field.
*/
virtual void OnCertificateUpdated(const std::string& certificate_data) = 0;
+
+#ifdef SDL_REMOTE_CONTROL
+ /**
+ * Gets devices ids by policy application id
+ * @param policy_app_id
+ * @return list devices ids
+ */
+ virtual std::vector<std::string> GetDevicesIds(
+ const std::string& policy_app_id) = 0;
+
+ /**
+ * Notifies about changing HMI level
+ * @param device_id unique identifier of device
+ * @param policy_app_id unique identifier of application in policy
+ * @param hmi_level default HMI level for this application
+ */
+ virtual void OnUpdateHMILevel(const std::string& device_id,
+ const std::string& policy_app_id,
+ const std::string& hmi_level) = 0;
+
+ /**
+ * @brief Notifies Remote apps about change in permissions
+ * @param device_id Device on which app is running
+ * @param application_id ID of app whose permissions are changed
+ */
+ virtual void OnRemoteAppPermissionsChanged(
+ const std::string& device_id, const std::string& application_id) = 0;
+
+ /**
+ * Notifies about changing HMI status
+ * @param device_id unique identifier of device
+ * @param policy_app_id unique identifier of application in policy
+ * @param hmi_level default HMI level for this application
+ */
+ virtual void OnUpdateHMIStatus(const std::string& device_id,
+ const std::string& policy_app_id,
+ const std::string& hmi_level) = 0;
+
+#endif // SDL_REMOTE_CONTROL
};
} // namespace policy
-#endif // SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_POLICY_LISTENER_H_
+#endif // SRC_COMPONENTS_INCLUDE_POLICY_POLICY_REGULAR_POLICY_POLICY_LISTENER_H_
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 c8074b3528..510e35e699 100644
--- a/src/components/include/policy/policy_regular/policy/policy_manager.h
+++ b/src/components/include/policy/policy_regular/policy/policy_manager.h
@@ -30,8 +30,8 @@
POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_POLICY_MANAGER_H_
-#define SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_POLICY_MANAGER_H_
+#ifndef SRC_COMPONENTS_INCLUDE_POLICY_POLICY_REGULAR_POLICY_POLICY_MANAGER_H_
+#define SRC_COMPONENTS_INCLUDE_POLICY_POLICY_REGULAR_POLICY_POLICY_MANAGER_H_
#include <vector>
#include <cstdint>
@@ -41,6 +41,9 @@
#include "policy/policy_table/types.h"
#include "policy/policy_listener.h"
#include "policy/usage_statistics/statistics_manager.h"
+#ifdef SDL_REMOTE_CONTROL
+#include "policy/access_remote.h"
+#endif // SDL_REMOTE_CONTROL
namespace policy {
class PolicySettings;
@@ -50,12 +53,17 @@ class PolicyManager : public usage_statistics::StatisticsManager {
public:
virtual ~PolicyManager() {}
+ /**
+ * @brief set_listener set new policy listener instance
+ * @param listener new policy listener
+ */
virtual void set_listener(PolicyListener* listener) = 0;
/**
- * Inits Policy Table
- * @param file_name Path to preloaded PT file
- * @return true if successfully
+ * @brief Inits Policy Table
+ * @param file_name path to preloaded PT file
+ * @param settings pointer to policy init settings
+ * @return true if init is successful
*/
virtual bool InitPT(const std::string& file_name,
const PolicySettings* settings) = 0;
@@ -66,13 +74,13 @@ class PolicyManager : public usage_statistics::StatisticsManager {
* sent in snapshot and received Policy Table.
* @param file name of file with update policy table
* @param pt_content PTU as binary string
- * @return bool Success of operation
+ * @return true if successfully
*/
virtual bool LoadPT(const std::string& file,
const BinaryMessage& pt_content) = 0;
/**
- * Resets Policy Table
+ * @brief Resets Policy Table
* @param file_name Path to preloaded PT file
* @return true if successfully
*/
@@ -80,7 +88,6 @@ class PolicyManager : public usage_statistics::StatisticsManager {
/**
* @brief GetLockScreenIcon allows to obtain lock screen icon url;
- *
* @return url which point to the resourse where lock screen icon could be
*obtained.
*/
@@ -89,7 +96,7 @@ class PolicyManager : public usage_statistics::StatisticsManager {
/**
* @brief Gets all URLs for sending PTS to from PT itself.
* @param service_type Service specifies user of URL
- * @return vector of urls
+ * @param out_end_points output vector of urls
*/
virtual void GetUpdateUrls(const std::string& service_type,
EndpointUrls& out_end_points) = 0;
@@ -105,11 +112,13 @@ class PolicyManager : public usage_statistics::StatisticsManager {
* @brief Check if specified RPC for specified application
* has permission to be executed in specified HMI Level
* and also its permitted params.
+ * @param device_id Id of device of application
* @param app_id Id of application provided during registration
* @param hmi_level Current HMI Level of application
* @param rpc Name of RPC
- * @param CheckPermissionResult containing flag if HMI Level is allowed
- * and list of allowed params.
+ * @param rpc_params List of RPC params
+ * @param result containing flag if HMI Level is allowed and list of
+ * allowed params.
*/
virtual void CheckPermissions(const PTString& device_id,
const PTString& app_id,
@@ -118,6 +127,12 @@ class PolicyManager : public usage_statistics::StatisticsManager {
const RPCParams& rpc_params,
CheckPermissionResult& result) = 0;
+ /**
+ * @brief Changes isConsentNeeded for app pending permissions, in case
+ * user set permissions before app activation.
+ * @param Unique app id
+ * @param Current permissions for app
+ */
virtual void CheckPendingPermissionsChanges(
const std::string& policy_app_id,
const std::vector<FunctionalGroupPermission>& current_permissions) = 0;
@@ -135,36 +150,38 @@ class PolicyManager : public usage_statistics::StatisticsManager {
virtual std::string GetPolicyTableStatus() const = 0;
/**
- * Checks is PT exceeded kilometers
+ * @brief Checks is PT exceeded kilometers
* @param kilometers current kilometers at odometer
* @return true if exceeded
*/
virtual void KmsChanged(int kilometers) = 0;
/**
- * Increments counter of ignition cycles
+ * @brief Increments counter of ignition cycles
*/
virtual void IncrementIgnitionCycles() = 0;
/**
* @brief Exchange by hmi or mobile request
+ * @return Current status of policy table
*/
virtual std::string ForcePTExchange() = 0;
/**
- * @brief ExchangeByUserRequest
+ * @brief Exchange by user request
+ * @return Current status of policy table
*/
virtual std::string ForcePTExchangeAtUserRequest() = 0;
/**
- * Gets timeout to wait before next retry updating PT
- * If timeout is equal to zero then the retry sequence is not need.
+ * @brief Gets timeout to wait before next retry updating PT
+ * If timeout is less or equal to zero then the retry sequence is not need.
* @return timeout in seconds
*/
virtual uint32_t NextRetryTimeout() = 0;
/**
- * Gets timeout to wait until receive response
+ * @brief Gets timeout to wait until receive response
* @return timeout in seconds
*/
virtual uint32_t TimeoutExchangeMSec() = 0;
@@ -177,7 +194,7 @@ class PolicyManager : public usage_statistics::StatisticsManager {
virtual const std::vector<int> RetrySequenceDelaysSeconds() = 0;
/**
- * Handler of exceeding timeout of exchanging policy table
+ * @brief Handler of exceeding timeout of exchanging policy table
*/
virtual void OnExceededTimeout() = 0;
@@ -187,7 +204,7 @@ class PolicyManager : public usage_statistics::StatisticsManager {
virtual void OnUpdateStarted() = 0;
/**
- * @brief Check user consent for mobile device data connection
+ * @brief Gets user consent for mobile device data connection
* @param device_id Unique device identifier
* @return status of device consent
*/
@@ -195,7 +212,7 @@ class PolicyManager : public usage_statistics::StatisticsManager {
const std::string& device_id) const = 0;
/**
- * @brief Get user consent for application
+ * @brief Gets user consent for application
* @param device_id Device id
* @param policy_app_id Unique application id
* @param permissions Array of functional groups permissions
@@ -216,20 +233,24 @@ class PolicyManager : public usage_statistics::StatisticsManager {
/**
* @brief Update Application Policies as reaction
* on User allowing/disallowing device this app is running on.
+ * @param app_id Unique application id
+ * @param is_device_allowed true if user allowing device otherwise false
+ * @return true if operation was successful
*/
virtual bool ReactOnUserDevConsentForApp(const std::string app_id,
bool is_device_allowed) = 0;
+
/**
- * Sets counter value that passed for receiving PT UPdate.
+ * @brief Sets counter value that passed for receiving PT UPdate.
*/
virtual void PTUpdatedAt(Counters counter, int value) = 0;
/**
* @brief Retrieves data from app_policies about app on its registration:
- * @param app_id - id of registered app
- * @param app_types Section on HMI where app can appear (Navigation, Phone
- * etc)
+ * @param application_id - id of registered app
* @param nicknames Synonyms for application
+ * @param app_hmi_types Section on HMI where app can appear (Navigation, Phone
+ * etc)
*/
virtual bool GetInitialAppData(const std::string& application_id,
StringArray* nicknames = NULL,
@@ -291,7 +312,7 @@ class PolicyManager : public usage_statistics::StatisticsManager {
const std::string& language) = 0;
/**
- * Checks if the application is revoked
+ * @brief Checks if the application is revoked
* @param app_id application id
* @return true if application is revoked
*/
@@ -318,11 +339,15 @@ class PolicyManager : public usage_statistics::StatisticsManager {
virtual AppPermissions GetAppPermissionsChanges(
const std::string& policy_app_id) = 0;
+ /**
+ * @brief Removes specific application permissions changes
+ * @param app_id Unique application id
+ */
virtual void RemovePendingPermissionChanges(const std::string& app_id) = 0;
/**
* @brief Return device id, which hosts specific application
- * @param Application id, which is required to update device id
+ * @param policy_app_id Application id, which is required to update device id
*/
virtual std::string& GetCurrentDeviceId(
const std::string& policy_app_id) const = 0;
@@ -345,13 +370,13 @@ class PolicyManager : public usage_statistics::StatisticsManager {
/**
* @brief Send OnPermissionsUpdated for choosen application
- * @param application_id
+ * @param application_id Unique application id
*/
virtual void SendNotificationOnPermissionsUpdated(
const std::string& application_id) = 0;
/**
- * Marks device as upaired
+ * @brief Marks device as upaired
* @param device_id id device
*/
virtual void MarkUnpairedDevice(const std::string& device_id) = 0;
@@ -359,26 +384,31 @@ class PolicyManager : public usage_statistics::StatisticsManager {
/**
* @brief Adds, application to the db or update existed one
* run PTU if policy update is necessary for application.
- * @param Application id assigned by Ford to the application
+ * @param application_id Unique application id
+ * @param hmi_types application HMI types
* @return function that will notify update manager about new application
*/
virtual StatusNotifier AddApplication(
const std::string& application_id,
const rpc::policy_table_interface_base::AppHmiTypes& hmi_types) = 0;
+
/**
* @brief Removes unpaired device records and related records from DB
- * @param device_ids List of device_id, which should be removed
* @return true, if succedeed, otherwise - false
*/
virtual bool CleanupUnpairedDevices() = 0;
/**
* @brief Check if app can keep context.
+ * @param app_id Unique application id
+ * @return true if app can keep context, otherwise - false
*/
virtual bool CanAppKeepContext(const std::string& app_id) const = 0;
/**
* @brief Check if app can steal focus.
+ * @param app_id Unique application id
+ * @return true if app can steal focus, otherwise - false
*/
virtual bool CanAppStealFocus(const std::string& app_id) const = 0;
@@ -390,9 +420,9 @@ class PolicyManager : public usage_statistics::StatisticsManager {
virtual void OnSystemReady() = 0;
/**
- * @brief GetNotificationNumber
- * @param priority
- * @return
+ * @brief Get number of notification by priority
+ * @param priority Specified priority
+ * @return notification number
*/
virtual uint32_t GetNotificationsNumber(
const std::string& priority) const = 0;
@@ -411,7 +441,7 @@ class PolicyManager : public usage_statistics::StatisticsManager {
virtual bool IsPredataPolicy(const std::string& policy_app_id) const = 0;
/**
- * Returns heart beat timeout
+ * @brief Returns heart beat timeout
* @param app_id application id
* @return if timeout was set then value in milliseconds greater zero
* otherwise heart beat for specific application isn't set
@@ -419,7 +449,8 @@ class PolicyManager : public usage_statistics::StatisticsManager {
virtual uint32_t HeartBeatTimeout(const std::string& app_id) const = 0;
/**
- * @brief SaveUpdateStatusRequired alows to save update status.
+ * @brief SaveUpdateStatusRequired allows to save update status.
+ * @param is_update_needed true if update needed
*/
virtual void SaveUpdateStatusRequired(bool is_update_needed) = 0;
@@ -430,26 +461,28 @@ class PolicyManager : public usage_statistics::StatisticsManager {
/**
* @brief Handler on applications search completed
+ * @param trigger_ptu contains true if PTU should be triggered
*/
virtual void OnAppsSearchCompleted(const bool trigger_ptu) = 0;
+
/**
* @brief Gets request types for application
* @param policy_app_id Unique application id
- * @return request_types Request types of application
+ * @return request types of application
*/
virtual const std::vector<std::string> GetAppRequestTypes(
const std::string policy_app_id) const = 0;
/**
* @brief Get information about vehicle
+ * @return vehicle information
*/
virtual const VehicleInfo GetVehicleInfo() const = 0;
/**
- * @brief OnAppRegisteredOnMobile alows to handle event when application were
+ * @brief OnAppRegisteredOnMobile allows to handle event when application were
* succesfully registered on mobile device.
- * It will send OnAppPermissionSend notification and will try to start PTU.
- *
+ * It will send OnAppPermissionSend notification and will try to start PTU. *
* @param application_id registered application.
*/
virtual void OnAppRegisteredOnMobile(const std::string& application_id) = 0;
@@ -457,7 +490,6 @@ class PolicyManager : public usage_statistics::StatisticsManager {
/**
* @brief RetrieveCertificate Allows to obtain certificate in order
* to start secure connection.
- *
* @return The certificate in PKCS#7 format.
*/
virtual std::string RetrieveCertificate() const = 0;
@@ -465,11 +497,14 @@ class PolicyManager : public usage_statistics::StatisticsManager {
/**
* @brief HasCertificate check whether policy table has certificate
* int module_config section.
- *
* @return true in case certificate exists, false otherwise
*/
virtual bool HasCertificate() const = 0;
+ /**
+ * @brief Getter for policy settings
+ * @return policy settings instance
+ */
virtual const PolicySettings& get_settings() const = 0;
/**
@@ -479,6 +514,57 @@ class PolicyManager : public usage_statistics::StatisticsManager {
* urls vector
*/
virtual AppIdURL GetNextUpdateUrl(const EndpointUrls& urls) = 0;
+#ifdef SDL_REMOTE_CONTROL
+ /**
+ * @brief Assigns new HMI types for specified application
+ * @param application_id Unique application id
+ * @param hmi_types new HMI types list
+ */
+ virtual void SetDefaultHmiTypes(const std::string& application_id,
+ const std::vector<int>& hmi_types) = 0;
+
+ /**
+ * @brief Gets HMI types
+ * @param application_id ID application
+ * @param app_types list to save HMI types
+ * @return true if policy has specific policy for this application
+ */
+ virtual bool GetHMITypes(const std::string& application_id,
+ std::vector<int>* app_types) = 0;
+
+ /**
+ * @brief Checks if module for application is present in policy table
+ * @param app_id id of application
+ * @param module type
+ * @return true if module is present, otherwise - false
+ */
+ virtual bool CheckModule(const PTString& app_id, const PTString& module) = 0;
+
+ /**
+ * @brief Send OnPermissionsChange notification to mobile app
+ * when it's permissions are changed.
+ * @param device_id Device on which app is running
+ * @param application_id ID of app whose permissions are changed
+ */
+ virtual void SendAppPermissionsChanged(const std::string& device_id,
+ const std::string& application_id) = 0;
+
+ /**
+ * @brief Gets all allowed module types
+ * @param policy_app_id unique identifier of application
+ * @param modules list of allowed module types
+ * @return true if application has allowed modules
+ */
+ virtual bool GetModuleTypes(const std::string& policy_app_id,
+ std::vector<std::string>* modules) const = 0;
+
+ /**
+ * @brief Setter for access_remote instance
+ * @param access_remote pointer to new access_remote instance
+ */
+ virtual void set_access_remote(
+ utils::SharedPtr<AccessRemote> access_remote) = 0;
+#endif // SDL_REMOTE_CONTROL
/**
* @brief Checks if there is existing URL in the EndpointUrls vector with
@@ -494,13 +580,13 @@ class PolicyManager : public usage_statistics::StatisticsManager {
protected:
/**
- * Checks is PT exceeded IgnitionCycles
+ * @brief Checks is PT exceeded IgnitionCycles
* @return true if exceeded
*/
virtual bool ExceededIgnitionCycles() = 0;
/**
- * Checks is PT exceeded days
+ * @brief Checks is PT exceeded days
* @return true if exceeded
*/
virtual bool ExceededDays() = 0;
@@ -518,4 +604,4 @@ class PolicyManager : public usage_statistics::StatisticsManager {
extern "C" policy::PolicyManager* CreateManager();
extern "C" void DeleteManager(policy::PolicyManager*);
-#endif // SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_POLICY_MANAGER_H_
+#endif // SRC_COMPONENTS_INCLUDE_POLICY_POLICY_REGULAR_POLICY_POLICY_MANAGER_H_
diff --git a/src/components/policy/policy_regular/include/policy/usage_statistics/app_stopwatch.h b/src/components/include/policy/policy_regular/policy/usage_statistics/app_stopwatch.h
index 8093c11467..0bcd585737 100644
--- a/src/components/policy/policy_regular/include/policy/usage_statistics/app_stopwatch.h
+++ b/src/components/include/policy/policy_regular/policy/usage_statistics/app_stopwatch.h
@@ -30,8 +30,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_USAGE_STATISTICS_APP_STOPWATCH_H_
-#define SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_USAGE_STATISTICS_APP_STOPWATCH_H_
+#ifndef SRC_COMPONENTS_INCLUDE_POLICY_POLICY_REGULAR_POLICY_USAGE_STATISTICS_APP_STOPWATCH_H_
+#define SRC_COMPONENTS_INCLUDE_POLICY_POLICY_REGULAR_POLICY_USAGE_STATISTICS_APP_STOPWATCH_H_
#include "policy/usage_statistics/statistics_manager.h"
@@ -47,4 +47,4 @@ class AppStopwatch {
} // namespace usage_statistics
-#endif // SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_USAGE_STATISTICS_APP_STOPWATCH_H_
+#endif // SRC_COMPONENTS_INCLUDE_POLICY_POLICY_REGULAR_POLICY_USAGE_STATISTICS_APP_STOPWATCH_H_
diff --git a/src/components/include/policy/policy_regular/policy/usage_statistics/statistics_manager.h b/src/components/include/policy/policy_regular/policy/usage_statistics/statistics_manager.h
index a74bb0592e..23df30510b 100644
--- a/src/components/include/policy/policy_regular/policy/usage_statistics/statistics_manager.h
+++ b/src/components/include/policy/policy_regular/policy/usage_statistics/statistics_manager.h
@@ -30,19 +30,25 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_INCLUDE_POLICY_USAGE_STATISTICS_STATISTICS_MANAGER_H_
-#define SRC_COMPONENTS_INCLUDE_POLICY_USAGE_STATISTICS_STATISTICS_MANAGER_H_
+#ifndef SRC_COMPONENTS_INCLUDE_POLICY_POLICY_REGULAR_POLICY_USAGE_STATISTICS_STATISTICS_MANAGER_H_
+#define SRC_COMPONENTS_INCLUDE_POLICY_POLICY_REGULAR_POLICY_USAGE_STATISTICS_STATISTICS_MANAGER_H_
#include <stdint.h>
#include <string>
namespace usage_statistics {
-enum GlobalCounterId { IAP_BUFFER_FULL, SYNC_OUT_OF_MEMORY, SYNC_REBOOTS };
+enum GlobalCounterId {
+ GLOBAL_COUNTER_NONE,
+ IAP_BUFFER_FULL,
+ SYNC_OUT_OF_MEMORY,
+ SYNC_REBOOTS
+};
-enum AppInfoId { LANGUAGE_GUI, LANGUAGE_VUI };
+enum AppInfoId { APP_INFO_NONE, LANGUAGE_GUI, LANGUAGE_VUI };
enum AppStopwatchId {
+ STOPWATCH_NONE,
SECONDS_HMI_FULL,
SECONDS_HMI_LIMITED,
SECONDS_HMI_BACKGROUND,
@@ -50,6 +56,7 @@ enum AppStopwatchId {
};
enum AppCounterId {
+ APP_COUNTER_NONE,
USER_SELECTIONS,
REJECTIONS_SYNC_OUT_OF_MEMORY,
REJECTIONS_NICKNAME_MISMATCH,
@@ -64,11 +71,36 @@ enum AppCounterId {
class StatisticsManager {
public:
virtual ~StatisticsManager() {}
+
+ /**
+ * @brief Increments global counter
+ * @param type counter type
+ */
virtual void Increment(GlobalCounterId type) = 0;
+
+ /**
+ * @brief Increments specified application counter
+ * @param app_id Unique ID of application
+ * @param type application counter type
+ */
virtual void Increment(const std::string& app_id, AppCounterId type) = 0;
+
+ /**
+ * @brief Sets specified application info value
+ * @param app_id Unique ID of application
+ * @param type application info type
+ * @param value new value for counter
+ */
virtual void Set(const std::string& app_id,
AppInfoId type,
const std::string& value) = 0;
+
+ /**
+ * @brief Add seconds for specified application stopwatch
+ * @param app_id Unique ID of application
+ * @param type application stopwatch type
+ * @param timespan_seconds seconds to add
+ */
virtual void Add(const std::string& app_id,
AppStopwatchId type,
int32_t timespan_seconds) = 0;
@@ -76,4 +108,4 @@ class StatisticsManager {
} // namespace usage_statistics
-#endif // SRC_COMPONENTS_INCLUDE_POLICY_USAGE_STATISTICS_STATISTICS_MANAGER_H_
+#endif // SRC_COMPONENTS_INCLUDE_POLICY_POLICY_REGULAR_POLICY_USAGE_STATISTICS_STATISTICS_MANAGER_H_
diff --git a/src/components/include/protocol/bson_object_keys.h b/src/components/include/protocol/bson_object_keys.h
new file mode 100644
index 0000000000..6f80aeec2b
--- /dev/null
+++ b/src/components/include/protocol/bson_object_keys.h
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+
+namespace protocol_handler {
+
+namespace strings {
+
+extern const char* hash_id;
+extern const char* protocol_version;
+extern const char* mtu;
+extern const char* rejected_params;
+extern const char* height;
+extern const char* width;
+extern const char* video_protocol;
+extern const char* video_codec;
+
+} // namespace strings
+
+} // namespace protocol_handler
diff --git a/src/components/include/protocol/common.h b/src/components/include/protocol/common.h
index ce4c4adf6f..00d57a9bf5 100644
--- a/src/components/include/protocol/common.h
+++ b/src/components/include/protocol/common.h
@@ -56,8 +56,9 @@ const uint8_t PROTOCOL_HEADER_V2_SIZE = 12;
*\brief Protocol versions constants
* First 4-bit field of AppLink protocol packet
*/
-enum {
-
+enum MajorProtocolVersion {
+ PROTOCOL_VERSION_UNKNOWN = -1,
+ PROTOCOL_VERSION_HMI = 0x00,
/**
*\brief Constant: number of protocol version (1).
*/
@@ -85,6 +86,12 @@ enum {
*/
PROTOCOL_VERSION_4 = 0x04,
/**
+ *@brief Constant: number of protocol version (5).
+ * Supports constructed payloads for protocol packets
+ * SDL4.4 feature.
+ */
+ PROTOCOL_VERSION_5 = 0x05,
+ /**
*\brief Maximum value of packet version field (size 4-bit) specified AppLink
*Protocol v.7
*/
diff --git a/src/components/include/protocol_handler/protocol_handler.h b/src/components/include/protocol_handler/protocol_handler.h
index 183db21532..34135617bd 100644
--- a/src/components/include/protocol_handler/protocol_handler.h
+++ b/src/components/include/protocol_handler/protocol_handler.h
@@ -108,6 +108,27 @@ class ProtocolHandler {
virtual const ProtocolHandlerSettings& get_settings() const = 0;
virtual SessionObserver& get_session_observer() = 0;
+ /**
+ * \brief Called by connection handler to notify the result of
+ * OnSessionStartedCallback().
+ * \param connection_id Identifier of connection within which session exists
+ * \param session_id session ID passed to OnSessionStartedCallback()
+ * \param generated_session_id Generated session ID, will be 0 if session is
+ * not started
+ * \param hash_id Generated Hash ID
+ * \param protection whether the service will be protected
+ * \param rejected_params list of parameters' name that are rejected.
+ * Only valid when generated_session_id is 0. Note, even if
+ * generated_session_id is 0, the list may be empty.
+ */
+ virtual void NotifySessionStartedResult(
+ int32_t connection_id,
+ uint8_t session_id,
+ uint8_t generated_session_id,
+ uint32_t hash_id,
+ bool protection,
+ std::vector<std::string>& rejected_params) = 0;
+
protected:
/**
* \brief Destructor
diff --git a/src/components/include/protocol_handler/protocol_handler_settings.h b/src/components/include/protocol_handler/protocol_handler_settings.h
index 987b0ac449..362f49e140 100644
--- a/src/components/include/protocol_handler/protocol_handler_settings.h
+++ b/src/components/include/protocol_handler/protocol_handler_settings.h
@@ -15,6 +15,10 @@ class ProtocolHandlerSettings {
virtual ~ProtocolHandlerSettings() {}
virtual size_t maximum_payload_size() const = 0;
+ virtual size_t maximum_control_payload_size() const = 0;
+ virtual size_t maximum_rpc_payload_size() const = 0;
+ virtual size_t maximum_audio_payload_size() const = 0;
+ virtual size_t maximum_video_payload_size() const = 0;
virtual size_t message_frequency_count() const = 0;
virtual size_t message_frequency_time() const = 0;
virtual bool malformed_message_filtering() const = 0;
@@ -25,10 +29,12 @@ class ProtocolHandlerSettings {
*/
virtual uint32_t heart_beat_timeout() const = 0;
- virtual uint16_t max_supported_protocol_version() const = 0;
/*
* @brief Protocol version, from .ini file.
*/
+ virtual uint16_t max_supported_protocol_version() const = 0;
+
+ // DEPRECATED
virtual bool enable_protocol_4() const = 0;
virtual uint32_t multiframe_waiting_timeout() const = 0;
diff --git a/src/components/include/protocol_handler/session_observer.h b/src/components/include/protocol_handler/session_observer.h
index 5e630c6c74..e58d959c8c 100644
--- a/src/components/include/protocol_handler/session_observer.h
+++ b/src/components/include/protocol_handler/session_observer.h
@@ -39,10 +39,13 @@
#ifdef ENABLE_SECURITY
#include "security_manager/ssl_context.h"
#endif // ENABLE_SECURITY
- /**
- *\namespace protocol_handlerHandler
- *\brief Namespace for SmartDeviceLink ProtocolHandler related functionality.
- */
+
+struct BsonObject;
+
+/**
+ *\namespace protocol_handler
+ *\brief Namespace for SmartDeviceLink ProtocolHandler related functionality.
+ */
namespace protocol_handler {
/**
* \brief HASH_ID constants.
@@ -73,6 +76,7 @@ class SessionObserver {
* \param hash_id pointer for session hash identifier, uint32_t* hash_id
* \return uint32_t Id (number) of new session if successful, otherwise 0.
*/
+ // DEPRECATED
virtual uint32_t OnSessionStartedCallback(
const transport_manager::ConnectionUID connection_handle,
const uint8_t sessionId,
@@ -82,6 +86,32 @@ class SessionObserver {
/**
* \brief Callback function used by ProtocolHandler
+ * when Mobile Application initiates start of new session.
+ * Result must be notified through NotifySessionStartedResult().
+ * \param connection_handle Connection identifier within which session
+ * has to be started.
+ * \param sessionId Identifier of the session to be start
+ * \param service_type Type of service
+ * \param protocol_version Version of protocol
+ * \param is_protected would be service protected
+ * \param params configuration parameters specified by mobile
+ */
+ virtual void OnSessionStartedCallback(
+ const transport_manager::ConnectionUID connection_handle,
+ const uint8_t sessionId,
+ const protocol_handler::ServiceType& service_type,
+ const bool is_protected,
+ const BsonObject* params) = 0;
+
+ // DEPRECATED
+ virtual uint32_t OnSessionEndedCallback(
+ const transport_manager::ConnectionUID connection_handle,
+ const uint8_t sessionId,
+ const uint32_t& hashCode,
+ const protocol_handler::ServiceType& service_type) = 0;
+
+ /**
+ * \brief Callback function used by ProtocolHandler
* when Mobile Application initiates session ending.
* \param connection_handle Connection identifier within which session exists
* \param sessionId Identifier of the session to be ended
@@ -94,7 +124,7 @@ class SessionObserver {
virtual uint32_t OnSessionEndedCallback(
const transport_manager::ConnectionUID connection_handle,
const uint8_t sessionId,
- const uint32_t& hashCode,
+ uint32_t* hashCode,
const protocol_handler::ServiceType& service_type) = 0;
/**
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 fc9b213d04..e94d9b4b3a 100644
--- a/src/components/include/test/application_manager/mock_application_manager.h
+++ b/src/components/include/test/application_manager/mock_application_manager.h
@@ -45,6 +45,7 @@
#include "application_manager/hmi_capabilities.h"
#include "application_manager/vehicle_info_data.h"
#include "application_manager/state_controller.h"
+#include "application_manager/message.h"
#include "resumption/last_state.h"
#include "interfaces/MOBILE_API.h"
#include "application_manager/app_launch/app_launch_ctrl.h"
@@ -74,6 +75,23 @@ class MockApplicationManager : public application_manager::ApplicationManager {
application, application_manager::ApplicationSharedPtr(uint32_t app_id));
MOCK_CONST_METHOD0(active_application,
application_manager::ApplicationSharedPtr());
+
+#ifdef SDL_REMOTE_CONTROL
+ MOCK_CONST_METHOD2(application,
+ application_manager::ApplicationSharedPtr(
+ const std::string& device_id,
+ const std::string& policy_app_id));
+ MOCK_METHOD2(ChangeAppsHMILevel,
+ void(uint32_t app_id, mobile_apis::HMILevel::eType level));
+ MOCK_METHOD0(GetPluginManager, functional_modules::PluginManager&());
+ MOCK_CONST_METHOD1(
+ devices, std::vector<std::string>(const std::string& policy_app_id));
+ MOCK_METHOD1(SendPostMessageToMobile,
+ void(const application_manager::MessagePtr& message));
+ MOCK_METHOD1(SendPostMessageToHMI,
+ void(const application_manager::MessagePtr& message));
+#endif // SDL_REMOTE_CONTROL
+
MOCK_CONST_METHOD1(
application_by_hmi_app,
application_manager::ApplicationSharedPtr(uint32_t hmi_app_id));
@@ -85,12 +103,16 @@ class MockApplicationManager : public application_manager::ApplicationManager {
std::vector<application_manager::ApplicationSharedPtr>(uint32_t button));
MOCK_METHOD0(applications_with_navi,
std::vector<application_manager::ApplicationSharedPtr>());
+ MOCK_METHOD0(applications_with_mobile_projection,
+ std::vector<application_manager::ApplicationSharedPtr>());
MOCK_CONST_METHOD0(get_limited_media_application,
application_manager::ApplicationSharedPtr());
MOCK_CONST_METHOD0(get_limited_navi_application,
application_manager::ApplicationSharedPtr());
MOCK_CONST_METHOD0(get_limited_voice_application,
application_manager::ApplicationSharedPtr());
+ MOCK_CONST_METHOD0(get_limited_mobile_projection_application,
+ application_manager::ApplicationSharedPtr());
MOCK_METHOD1(application_id, uint32_t(const int32_t correlation_id));
MOCK_METHOD2(set_application_id,
void(const int32_t correlation_id, const uint32_t app_id));
@@ -106,6 +128,8 @@ class MockApplicationManager : public application_manager::ApplicationManager {
MOCK_METHOD1(
SendMessageToHMI,
void(const application_manager::commands::MessageSharedPtr message));
+ MOCK_METHOD1(RemoveHMIFakeParameters,
+ void(application_manager::MessagePtr& message));
MOCK_METHOD1(
ManageHMICommand,
bool(const application_manager::commands::MessageSharedPtr message));
@@ -257,6 +281,14 @@ class MockApplicationManager : public application_manager::ApplicationManager {
MOCK_METHOD0(OnTimerSendTTSGlobalProperties, void());
MOCK_METHOD0(OnLowVoltage, void());
MOCK_METHOD0(OnWakeUp, void());
+ MOCK_METHOD4(OnStreamingConfigured,
+ void(uint32_t app_id,
+ protocol_handler::ServiceType service_type,
+ bool result,
+ std::vector<std::string>& rejected_params));
+ MOCK_METHOD1(ValidateMessageBySchema,
+ application_manager::MessageValidationResult(
+ const application_manager::Message& message));
};
} // namespace application_manager_test
diff --git a/src/components/include/test/application_manager/mock_application_manager_settings.h b/src/components/include/test/application_manager/mock_application_manager_settings.h
index 44cb0db29c..25cf994566 100644
--- a/src/components/include/test/application_manager/mock_application_manager_settings.h
+++ b/src/components/include/test/application_manager/mock_application_manager_settings.h
@@ -102,6 +102,7 @@ class MockApplicationManagerSettings
MOCK_CONST_METHOD0(start_stream_retry_amount,
const std::pair<uint32_t, int32_t>&());
MOCK_CONST_METHOD0(app_icons_folder, const std::string&());
+ MOCK_CONST_METHOD0(plugins_folder, const std::string&());
MOCK_CONST_METHOD0(app_icons_folder_max_size, const uint32_t&());
MOCK_CONST_METHOD0(app_icons_amount_to_remove, const uint32_t&());
MOCK_CONST_METHOD0(list_files_response_size, const uint32_t&());
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 8f6972fd52..812df19ccd 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
@@ -104,8 +104,8 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface {
MOCK_CONST_METHOD0(GetLockScreenIconUrl, std::string());
MOCK_METHOD0(ResetRetrySequence, void());
MOCK_METHOD0(NextRetryTimeout, uint32_t());
- MOCK_METHOD0(TimeoutExchangeSec, uint32_t());
- MOCK_METHOD0(TimeoutExchangeMSec, uint32_t());
+ MOCK_CONST_METHOD0(TimeoutExchangeSec, uint32_t());
+ MOCK_CONST_METHOD0(TimeoutExchangeMSec, uint32_t());
MOCK_METHOD0(OnExceededTimeout, void());
MOCK_METHOD0(OnSystemReady, void());
MOCK_METHOD2(PTUpdatedAt, void(policy::Counters counter, int value));
@@ -227,6 +227,36 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface {
void(const std::string& service_type,
policy::EndpointUrls& end_points));
+#ifdef SDL_REMOTE_CONTROL
+ MOCK_METHOD3(OnUpdateHMILevel,
+ void(const std::string& device_id,
+ const std::string& policy_app_id,
+ const std::string& hmi_level));
+ MOCK_METHOD3(CheckHMIType,
+ bool(const std::string& application_id,
+ mobile_apis::AppHMIType::eType hmi,
+ const smart_objects::SmartObject* app_types));
+
+ MOCK_METHOD2(CheckModule,
+ bool(const policy::PTString& app_id,
+ const policy::PTString& module));
+
+ MOCK_METHOD2(OnRemoteAppPermissionsChanged,
+ void(const std::string& device_id,
+ const std::string& application_id));
+
+ MOCK_METHOD3(OnUpdateHMIStatus,
+ void(const std::string& device_id,
+ const std::string& policy_app_id,
+ const std::string& hmi_level));
+ MOCK_CONST_METHOD2(GetModuleTypes,
+ bool(const std::string& policy_app_id,
+ std::vector<std::string>* modules));
+ MOCK_METHOD2(SetDefaultHmiTypes,
+ void(const std::string& application_id,
+ const smart_objects::SmartObject* app_types));
+#endif // SDL_REMOTE_CONTROL
+
private:
#ifdef EXTERNAL_PROPRIETARY_MODE
MOCK_METHOD3(OnAppPermissionConsentInternal,
diff --git a/src/components/include/test/connection_handler/mock_connection_handler.h b/src/components/include/test/connection_handler/mock_connection_handler.h
index e17224b097..5cb5f471b5 100644
--- a/src/components/include/test/connection_handler/mock_connection_handler.h
+++ b/src/components/include/test/connection_handler/mock_connection_handler.h
@@ -96,6 +96,10 @@ class MockConnectionHandler : public connection_handler::ConnectionHandler {
MOCK_METHOD0(get_device_discovery_starter, DevicesDiscoveryStarter&());
MOCK_CONST_METHOD1(GetConnectedDevicesMAC,
void(std::vector<std::string>& macs));
+ MOCK_METHOD3(NotifyServiceStartedResult,
+ void(uint32_t session_key,
+ bool result,
+ std::vector<std::string>& rejected_params));
};
} // namespace connection_handler_test
diff --git a/src/components/include/test/connection_handler/mock_connection_handler_observer.h b/src/components/include/test/connection_handler/mock_connection_handler_observer.h
index 6ca4557b35..dead5bc61e 100644
--- a/src/components/include/test/connection_handler/mock_connection_handler_observer.h
+++ b/src/components/include/test/connection_handler/mock_connection_handler_observer.h
@@ -48,10 +48,16 @@ class MockConnectionHandlerObserver
MOCK_METHOD0(OnFindNewApplicationsRequest, void());
MOCK_METHOD1(RemoveDevice,
void(const connection_handler::DeviceHandle& device_handle));
+ // DEPRECATED
MOCK_METHOD3(OnServiceStartedCallback,
bool(const connection_handler::DeviceHandle& device_handle,
const int32_t& session_key,
const protocol_handler::ServiceType& type));
+ MOCK_METHOD4(OnServiceStartedCallback,
+ void(const connection_handler::DeviceHandle& device_handle,
+ const int32_t& session_key,
+ const protocol_handler::ServiceType& type,
+ const BsonObject* params));
MOCK_METHOD3(
OnServiceEndedCallback,
void(const int32_t& session_key,
diff --git a/src/components/include/test/hmi_message_handler/mock_hmi_message_handler_settings.h b/src/components/include/test/hmi_message_handler/mock_hmi_message_handler_settings.h
index fcbae93a70..a7e93ec25c 100644
--- a/src/components/include/test/hmi_message_handler/mock_hmi_message_handler_settings.h
+++ b/src/components/include/test/hmi_message_handler/mock_hmi_message_handler_settings.h
@@ -44,7 +44,7 @@ namespace hmi_message_handler_test {
class MockHMIMessageHandlerSettings
: public ::hmi_message_handler::HMIMessageHandlerSettings {
public:
- MOCK_CONST_METHOD0(thread_min_stack_size, const uint64_t&());
+ MOCK_CONST_METHOD0(thread_min_stack_size, const uint64_t());
};
} // namespace hmi_message_handler_test
} // namespace components
diff --git a/src/components/policy/policy_external/test/include/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h
index 617e99358e..e90fa63075 100644
--- a/src/components/policy/policy_external/test/include/policy/mock_cache_manager.h
+++ b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h
@@ -29,8 +29,8 @@
* 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_TEST_INCLUDE_POLICY_MOCK_CACHE_MANAGER_H_
-#define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_TEST_INCLUDE_POLICY_MOCK_CACHE_MANAGER_H_
+#ifndef SRC_COMPONENTS_INCLUDE_TEST_POLICY_POLICY_EXTERNAL_POLICY_MOCK_CACHE_MANAGER_H_
+#define SRC_COMPONENTS_INCLUDE_TEST_POLICY_POLICY_EXTERNAL_POLICY_MOCK_CACHE_MANAGER_H_
#include <string>
#include <vector>
@@ -253,4 +253,4 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface {
} // namespace components
} // namespace test
-#endif // SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_TEST_INCLUDE_POLICY_MOCK_CACHE_MANAGER_H_
+#endif // SRC_COMPONENTS_INCLUDE_TEST_POLICY_POLICY_EXTERNAL_POLICY_MOCK_CACHE_MANAGER_H_
diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_listener.h b/src/components/include/test/policy/policy_external/policy/mock_policy_listener.h
index 893d5a334f..ad2f1fd56c 100644
--- a/src/components/include/test/policy/policy_external/policy/mock_policy_listener.h
+++ b/src/components/include/test/policy/policy_external/policy/mock_policy_listener.h
@@ -29,8 +29,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_INCLUDE_TEST_POLICY_MOCK_POLICY_LISTENER_H_
-#define SRC_COMPONENTS_INCLUDE_TEST_POLICY_MOCK_POLICY_LISTENER_H_
+#ifndef SRC_COMPONENTS_INCLUDE_TEST_POLICY_POLICY_EXTERNAL_POLICY_MOCK_POLICY_LISTENER_H_
+#define SRC_COMPONENTS_INCLUDE_TEST_POLICY_POLICY_EXTERNAL_POLICY_MOCK_POLICY_LISTENER_H_
#include <string>
#include <map>
@@ -92,10 +92,20 @@ class MockPolicyListener : public ::policy::PolicyListener {
const std::string& hmi_level));
MOCK_CONST_METHOD1(GetRegisteredLinks,
void(std::map<std::string, std::string>&));
+#ifdef SDL_REMOTE_CONTROL
+ MOCK_METHOD1(OnRemoteAllowedChanged, void(bool new_consent));
+ MOCK_METHOD2(OnRemoteAppPermissionsChanged,
+ void(const std::string& device_id,
+ const std::string& application_id));
+ MOCK_METHOD3(OnUpdateHMIStatus,
+ void(const std::string& device_id,
+ const std::string& policy_app_id,
+ const std::string& hmi_level));
+#endif // SDL_REMOTE_CONTROL
};
} // namespace policy_test
} // namespace components
} // namespace test
-#endif // SRC_COMPONENTS_INCLUDE_TEST_POLICY_MOCK_POLICY_LISTENER_H_
+#endif // SRC_COMPONENTS_INCLUDE_TEST_POLICY_POLICY_EXTERNAL_POLICY_MOCK_POLICY_LISTENER_H_
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 0332b94a89..6227e7e85c 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
@@ -30,8 +30,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_INCLUDE_TEST_POLICY_MOCK_POLICY_MANAGER_H_
-#define SRC_COMPONENTS_INCLUDE_TEST_POLICY_MOCK_POLICY_MANAGER_H_
+#ifndef SRC_COMPONENTS_INCLUDE_TEST_POLICY_POLICY_EXTERNAL_POLICY_MOCK_POLICY_MANAGER_H_
+#define SRC_COMPONENTS_INCLUDE_TEST_POLICY_POLICY_EXTERNAL_POLICY_MOCK_POLICY_MANAGER_H_
#include <string>
#include <vector>
@@ -148,6 +148,25 @@ class MockPolicyManager : public PolicyManager {
StatusNotifier(
const std::string& application_id,
const rpc::policy_table_interface_base::AppHmiTypes& hmi_types));
+#ifdef SDL_REMOTE_CONTROL
+ MOCK_METHOD2(SetDefaultHmiTypes,
+ void(const std::string& application_id,
+ const std::vector<int>& hmi_types));
+ MOCK_METHOD2(GetHMITypes,
+ bool(const std::string& application_id,
+ std::vector<int>* app_types));
+ MOCK_METHOD2(CheckModule,
+ bool(const PTString& app_id, const PTString& module));
+ MOCK_METHOD2(SendAppPermissionsChanged,
+ void(const std::string& device_id,
+ const std::string& application_id));
+ MOCK_CONST_METHOD2(GetModuleTypes,
+ bool(const std::string& policy_app_id,
+ std::vector<std::string>* modules));
+ MOCK_METHOD1(set_access_remote,
+ void(utils::SharedPtr<AccessRemote> access_remote));
+#endif // SDL_REMOTE_CONTROL
+
MOCK_METHOD0(CleanupUnpairedDevices, bool());
MOCK_CONST_METHOD1(CanAppKeepContext, bool(const std::string& app_id));
MOCK_CONST_METHOD1(CanAppStealFocus, bool(const std::string& app_id));
@@ -201,4 +220,4 @@ class MockPolicyManager : public PolicyManager {
} // namespace components
} // namespace test
-#endif // SRC_COMPONENTS_INCLUDE_TEST_POLICY_MOCK_POLICY_MANAGER_H_
+#endif // SRC_COMPONENTS_INCLUDE_TEST_POLICY_POLICY_EXTERNAL_POLICY_MOCK_POLICY_MANAGER_H_
diff --git a/src/components/policy/policy_regular/test/include/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h
index 7569e2195d..39876cf713 100644
--- a/src/components/policy/policy_regular/test/include/policy/mock_cache_manager.h
+++ b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h
@@ -29,8 +29,8 @@
* 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_TEST_INCLUDE_MOCK_CACHE_MANAGER_H_
-#define SRC_COMPONENTS_POLICY_POLICY_REGULAR_TEST_INCLUDE_MOCK_CACHE_MANAGER_H_
+#ifndef SRC_COMPONENTS_INCLUDE_TEST_POLICY_POLICY_REGULAR_POLICY_MOCK_CACHE_MANAGER_H_
+#define SRC_COMPONENTS_INCLUDE_TEST_POLICY_POLICY_REGULAR_POLICY_MOCK_CACHE_MANAGER_H_
#include <string>
#include <vector>
@@ -202,7 +202,9 @@ class MockCacheManagerInterface : public CacheManagerInterface {
bool(const std::string& device_id,
const std::string& policy_app_id,
policy::Permissions& permission));
- MOCK_CONST_METHOD0(GetPT, utils::SharedPtr<policy_table::Table>());
+ MOCK_CONST_METHOD0(pt, utils::SharedPtr<policy_table::Table>());
+ MOCK_METHOD1(GetHMITypes,
+ const policy_table::AppHMITypes*(const std::string& app_id));
MOCK_CONST_METHOD0(GetCertificate, std::string());
MOCK_METHOD1(SetDecryptedCertificate, void(const std::string&));
MOCK_METHOD1(GetGroups, const policy_table::Strings&(const PTString& app_id));
@@ -215,4 +217,4 @@ class MockCacheManagerInterface : public CacheManagerInterface {
} // namespace components
} // namespace test
-#endif // SRC_COMPONENTS_POLICY_POLICY_REGULAR_TEST_INCLUDE_MOCK_CACHE_MANAGER_H_
+#endif // SRC_COMPONENTS_INCLUDE_TEST_POLICY_POLICY_REGULAR_POLICY_MOCK_CACHE_MANAGER_H_
diff --git a/src/components/policy/policy_regular/test/include/policy/mock_policy_listener.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_listener.h
index 2e4073aae9..d98a0279d7 100644
--- a/src/components/policy/policy_regular/test/include/policy/mock_policy_listener.h
+++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_listener.h
@@ -29,8 +29,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_POLICY_POLICY_REGULAR_TEST_INCLUDE_MOCK_POLICY_LISTENER_H_
-#define SRC_COMPONENTS_POLICY_POLICY_REGULAR_TEST_INCLUDE_MOCK_POLICY_LISTENER_H_
+#ifndef SRC_COMPONENTS_INCLUDE_TEST_POLICY_POLICY_REGULAR_POLICY_MOCK_POLICY_LISTENER_H_
+#define SRC_COMPONENTS_INCLUDE_TEST_POLICY_POLICY_REGULAR_POLICY_MOCK_POLICY_LISTENER_H_
#include <string>
@@ -43,19 +43,21 @@
namespace policy_table = ::rpc::policy_table_interface_base;
-namespace policy {
+namespace test {
+namespace components {
+namespace policy_test {
namespace custom_str = utils::custom_string;
-class MockPolicyListener : public PolicyListener {
+class MockPolicyListener : public ::policy::PolicyListener {
public:
MOCK_METHOD3(OnPermissionsUpdated,
void(const std::string& policy_app_id,
- const Permissions& permissions,
+ const policy::Permissions& permissions,
const policy::HMILevel& default_hmi));
MOCK_METHOD2(OnPermissionsUpdated,
void(const std::string& policy_app_id,
- const Permissions& permissions));
+ const policy::Permissions& permissions));
MOCK_METHOD1(OnPendingPermissionChange,
void(const std::string& policy_app_id));
MOCK_METHOD1(OnUpdateStatusChanged, void(const std::string& status));
@@ -67,17 +69,36 @@ class MockPolicyListener : public PolicyListener {
MOCK_METHOD0(OnUserRequestedUpdateCheckRequired, void());
MOCK_METHOD2(OnDeviceConsentChanged,
void(const std::string& device_id, bool is_allowed));
- MOCK_METHOD1(OnUpdateHMIAppType, void(std::map<std::string, StringArray>));
+ MOCK_METHOD1(OnUpdateHMIAppType,
+ void(std::map<std::string, policy::StringArray>));
MOCK_METHOD1(GetAvailableApps, void(std::queue<std::string>&));
- MOCK_METHOD1(OnSnapshotCreated, void(const BinaryMessage& pt_string));
+ MOCK_METHOD1(OnSnapshotCreated, void(const policy::BinaryMessage& pt_string));
MOCK_METHOD0(CanUpdate, bool());
MOCK_METHOD1(OnCertificateUpdated, void(const std::string&));
MOCK_CONST_METHOD2(SendOnAppPermissionsChanged,
- void(const AppPermissions&, const std::string&));
+ void(const policy::AppPermissions&, const std::string&));
+ MOCK_METHOD3(OnUpdateHMILevel,
+ void(const std::string& device_id,
+ const std::string& policy_app_id,
+ const std::string& hmi_level));
+ MOCK_METHOD1(GetDevicesIds,
+ std::vector<std::string>(const std::string& policy_app_id));
MOCK_CONST_METHOD1(GetRegisteredLinks,
void(std::map<std::string, std::string>&));
+#ifdef SDL_REMOTE_CONTROL
+ MOCK_METHOD1(OnRemoteAllowedChanged, void(bool new_consent));
+ MOCK_METHOD2(OnRemoteAppPermissionsChanged,
+ void(const std::string& device_id,
+ const std::string& application_id));
+ MOCK_METHOD3(OnUpdateHMIStatus,
+ void(const std::string& device_id,
+ const std::string& policy_app_id,
+ const std::string& hmi_level));
+#endif // SDL_REMOTE_CONTROL
};
-} // namespace policy
+} // namespace policy_test
+} // namespace components
+} // namespace test
-#endif // SRC_COMPONENTS_POLICY_POLICY_REGULAR_TEST_INCLUDE_MOCK_POLICY_LISTENER_H_
+#endif // SRC_COMPONENTS_INCLUDE_TEST_POLICY_POLICY_REGULAR_POLICY_MOCK_POLICY_LISTENER_H_
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 1ccca81d79..cfe41ee64c 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
@@ -30,8 +30,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_INCLUDE_TEST_POLICY_MOCK_POLICY_MANAGER_H_
-#define SRC_COMPONENTS_INCLUDE_TEST_POLICY_MOCK_POLICY_MANAGER_H_
+#ifndef SRC_COMPONENTS_INCLUDE_TEST_POLICY_POLICY_REGULAR_POLICY_MOCK_POLICY_MANAGER_H_
+#define SRC_COMPONENTS_INCLUDE_TEST_POLICY_POLICY_REGULAR_POLICY_MOCK_POLICY_MANAGER_H_
#include <string>
#include <vector>
@@ -147,6 +147,24 @@ class MockPolicyManager : public PolicyManager {
StatusNotifier(
const std::string& application_id,
const rpc::policy_table_interface_base::AppHmiTypes& hmi_types));
+#ifdef SDL_REMOTE_CONTROL
+ MOCK_METHOD2(SetDefaultHmiTypes,
+ void(const std::string& application_id,
+ const std::vector<int>& hmi_types));
+ MOCK_METHOD2(GetHMITypes,
+ bool(const std::string& application_id,
+ std::vector<int>* app_types));
+ MOCK_METHOD2(CheckModule,
+ bool(const PTString& app_id, const PTString& module));
+ MOCK_METHOD2(SendAppPermissionsChanged,
+ void(const std::string& device_id,
+ const std::string& application_id));
+ MOCK_CONST_METHOD2(GetModuleTypes,
+ bool(const std::string& policy_app_id,
+ std::vector<std::string>* modules));
+ MOCK_METHOD1(set_access_remote,
+ void(utils::SharedPtr<AccessRemote> access_remote));
+#endif // SDL_REMOTE_CONTROL
MOCK_METHOD0(CleanupUnpairedDevices, bool());
MOCK_CONST_METHOD1(CanAppKeepContext, bool(const std::string& app_id));
MOCK_CONST_METHOD1(CanAppStealFocus, bool(const std::string& app_id));
@@ -210,4 +228,4 @@ class MockPolicyManager : public PolicyManager {
} // namespace components
} // namespace test
-#endif // SRC_COMPONENTS_INCLUDE_TEST_POLICY_MOCK_POLICY_MANAGER_H_
+#endif // SRC_COMPONENTS_INCLUDE_TEST_POLICY_POLICY_REGULAR_POLICY_MOCK_POLICY_MANAGER_H_
diff --git a/src/components/include/test/protocol_handler/mock_protocol_handler.h b/src/components/include/test/protocol_handler/mock_protocol_handler.h
index 44287edd4d..37fbbb9742 100644
--- a/src/components/include/test/protocol_handler/mock_protocol_handler.h
+++ b/src/components/include/test/protocol_handler/mock_protocol_handler.h
@@ -62,6 +62,13 @@ class MockProtocolHandler : public ::protocol_handler::ProtocolHandler {
MOCK_CONST_METHOD0(get_settings,
const ::protocol_handler::ProtocolHandlerSettings&());
MOCK_METHOD0(get_session_observer, protocol_handler::SessionObserver&());
+ MOCK_METHOD6(NotifySessionStartedResult,
+ void(int32_t connection_id,
+ uint8_t session_id,
+ uint8_t generated_session_id,
+ uint32_t hash_id,
+ bool protection,
+ std::vector<std::string>& rejected_params));
};
} // namespace protocol_handler_test
} // namespace components
diff --git a/src/components/include/test/protocol_handler/mock_protocol_handler_settings.h b/src/components/include/test/protocol_handler/mock_protocol_handler_settings.h
index d12e7899e0..8ddeded889 100644
--- a/src/components/include/test/protocol_handler/mock_protocol_handler_settings.h
+++ b/src/components/include/test/protocol_handler/mock_protocol_handler_settings.h
@@ -43,6 +43,10 @@ class MockProtocolHandlerSettings
: public protocol_handler::ProtocolHandlerSettings {
public:
MOCK_CONST_METHOD0(maximum_payload_size, size_t());
+ MOCK_CONST_METHOD0(maximum_control_payload_size, size_t());
+ MOCK_CONST_METHOD0(maximum_rpc_payload_size, size_t());
+ MOCK_CONST_METHOD0(maximum_audio_payload_size, size_t());
+ MOCK_CONST_METHOD0(maximum_video_payload_size, size_t());
MOCK_CONST_METHOD0(message_frequency_count, size_t());
MOCK_CONST_METHOD0(message_frequency_time, size_t());
MOCK_CONST_METHOD0(malformed_message_filtering, bool());
diff --git a/src/components/include/test/protocol_handler/mock_session_observer.h b/src/components/include/test/protocol_handler/mock_session_observer.h
index c376cb85f5..4d2072624d 100644
--- a/src/components/include/test/protocol_handler/mock_session_observer.h
+++ b/src/components/include/test/protocol_handler/mock_session_observer.h
@@ -46,6 +46,7 @@ namespace protocol_handler_test {
*/
class MockSessionObserver : public ::protocol_handler::SessionObserver {
public:
+ // DEPRECATED
MOCK_METHOD5(
OnSessionStartedCallback,
uint32_t(const transport_manager::ConnectionUID connection_handle,
@@ -53,12 +54,24 @@ class MockSessionObserver : public ::protocol_handler::SessionObserver {
const protocol_handler::ServiceType& service_type,
const bool is_protected,
uint32_t* hash_id));
+ MOCK_METHOD5(OnSessionStartedCallback,
+ void(const transport_manager::ConnectionUID connection_handle,
+ const uint8_t sessionId,
+ const protocol_handler::ServiceType& service_type,
+ const bool is_protected,
+ const BsonObject* params));
MOCK_METHOD4(
OnSessionEndedCallback,
uint32_t(const transport_manager::ConnectionUID connection_handle,
const uint8_t sessionId,
const uint32_t& hashCode,
const protocol_handler::ServiceType& service_type));
+ MOCK_METHOD4(
+ OnSessionEndedCallback,
+ uint32_t(const transport_manager::ConnectionUID connection_handle,
+ const uint8_t sessionId,
+ uint32_t* hashCode,
+ const protocol_handler::ServiceType& service_type));
MOCK_METHOD1(OnApplicationFloodCallBack,
void(const uint32_t& connection_key));
MOCK_METHOD1(OnMalformedMessageCallback,
diff --git a/src/components/include/utils/macro.h b/src/components/include/utils/macro.h
index 0e029e4b06..4cf76fe022 100644
--- a/src/components/include/utils/macro.h
+++ b/src/components/include/utils/macro.h
@@ -113,6 +113,13 @@
return; \
}
+#define EXPORT_FUNCTION(TypeName) extern "C" TypeName* Create();
+
+#define EXPORT_FUNCTION_IMPL(TypeName) \
+ extern "C" TypeName* Create() { \
+ return new TypeName(); \
+ }
+
#define NOTREACHED() DCHECK(!"Unreachable code")
// Allows to perform static check that virtual function from base class is
@@ -134,6 +141,8 @@
#ifdef BUILD_TESTS
#define FRIEND_TEST(test_case_name, test_name) \
friend class test_case_name##_##test_name##_Test
-#endif
+#else // BUILD_TESTS
+#define FRIEND_TEST(test_case_name, test_name)
+#endif // BUILD_TESTS
#endif // SRC_COMPONENTS_INCLUDE_UTILS_MACRO_H_
diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml
index 0d6d5fad3d..554461cc86 100644
--- a/src/components/interfaces/HMI_API.xml
+++ b/src/components/interfaces/HMI_API.xml
@@ -1,7 +1,10 @@
<?xml version="1.0" standalone="yes"?>
<!--
-* Copyright (c) 2016, Ford Motor Company
+ * Copyright (c) 2016, Ford Motor Company
+ * All rights reserved.
+ *
+ * Copyright (c) 2017 Xevo Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -63,6 +66,7 @@
<element name="USER_DISALLOWED" value="23"/>
<element name="TRUNCATED_DATA" value="24"/>
<element name="SAVED" value="25"/>
+ <element name="READ_ONLY" value="26"/>
</enum>
<enum name="TransportType">
@@ -92,6 +96,27 @@
<element name="PRESET_9"/>
<element name="CUSTOM_BUTTON"/>
<element name="SEARCH"/>
+ <!-- Climate Buttons -->
+ <element name="AC_MAX" />
+ <element name="AC" />
+ <element name="RECIRCULATE" />
+ <element name="FAN_UP" />
+ <element name="FAN_DOWN" />
+ <element name="TEMP_UP" />
+ <element name="TEMP_DOWN" />
+ <element name="DEFROST_MAX" />
+ <element name="DEFROST" />
+ <element name="DEFROST_REAR" />
+ <element name="UPPER_VENT" />
+ <element name="LOWER_VENT" />
+
+ <!-- Radio Buttons -->
+ <element name="VOLUME_UP" />
+ <element name="VOLUME_DOWN" />
+ <element name="EJECT" />
+ <element name="SOURCE" />
+ <element name="SHUFFLE" />
+ <element name="REPEAT" />
</enum>
<enum name="ButtonEventMode">
@@ -200,6 +225,36 @@
<element name="SK-SK" internal_name="SK_SK">
<description>Slovak - Slovakia</description>
</element>
+ <element name="EN-IN" internal_name="EN_IN">
+ <description>English - India</description>
+ </element>
+ <element name="TH-TH" internal_name="TH_TH">
+ <description>Thai - Thailand</description>
+ </element>
+ <element name="EN-SA" internal_name="EN_SA">
+ <description>English - Middle East</description>
+ </element>
+ <element name="HE-IL" internal_name="HE_IL">
+ <description>Hebrew - Israel</description>
+ </element>
+ <element name="RO-RO" internal_name="RO_RO">
+ <description>Romanian - Romania</description>
+ </element>
+ <element name="UK-UA" internal_name="UK_UA">
+ <description>Ukrainian - Ukraine</description>
+ </element>
+ <element name="ID-ID" internal_name="ID_ID">
+ <description>Indonesian - Indonesia</description>
+ </element>
+ <element name="VI-VN" internal_name="VI_VN">
+ <description>Vietnamese - Vietnam</description>
+ </element>
+ <element name="MS-MY" internal_name="MS_MY">
+ <description>Malay - Malaysia</description>
+ </element>
+ <element name="HI-IN" internal_name="HI_IN">
+ <description>Hindi - India</description>
+ </element>
</enum>
<enum name="SoftButtonType">
@@ -234,6 +289,8 @@
<element name="BACKGROUND_PROCESS" />
<element name="TESTING" />
<element name="SYSTEM" />
+ <element name="PROJECTION" />
+ <element name="REMOTE_CONTROL" />
</enum>
<enum name="WayPointType">
@@ -824,6 +881,7 @@
<element name="BEGIN"/>
<element name="MOVE"/>
<element name="END"/>
+ <element name="CANCEL"/>
</enum>
<enum name="WarningLightStatus">
@@ -1206,6 +1264,86 @@
<element name="QUEUE" />
</enum>
+<enum name="VideoStreamingProtocol">
+ <description>Enum for each type of video streaming protocol type.</description>
+ <element name="RAW">
+ <description>
+ Raw stream bytes that contains no timestamp data and is the lowest supported video streaming
+ </description>
+ </element>
+ <element name="RTP">
+ <description>
+ RTP facilitates the transfer of real-time data. Information provided by this protocol include
+ timestamps (for synchronization), sequence numbers (for packet loss and reordering detection)
+ and the payload format which indicates the encoded format of the data.
+ </description>
+ </element>
+ <element name="RTSP">
+ <description>
+ The transmission of streaming data itself is not a task of RTSP. Most RTSP servers use the
+ Real-time Transport Protocol (RTP) in conjunction with Real-time Control Protocol (RTCP)
+ for media stream delivery. However, some vendors implement proprietary transport protocols.
+ </description>
+ </element>
+ <element name="RTMP">
+ <description>
+ Real-Time Messaging Protocol (RTMP) was initially a proprietary protocol developed by
+ Macromedia for streaming audio, video and data over the Internet, between a Flash player
+ and a server. Macromedia is now owned by Adobe, which has released an incomplete version
+ of the specification of the protocol for public use.
+ </description>
+ </element>
+ <element name="WEBM">
+ <description>
+ The WebM container is based on a profile of Matroska. WebM initially supported VP8 video and
+ Vorbis audio streams. In 2013 it was updated to accommodate VP9 video and Opus audio.
+ </description>
+ </element>
+</enum>
+
+<enum name="VideoStreamingCodec">
+ <description>Enum for each type of video streaming codec.</description>
+ <element name="H264">
+ <description>
+ A block-oriented motion-compensation-based video compression standard.
+ As of 2014 it is one of the most commonly used formats for the recording, compression, and
+ distribution of video content.
+ </description>
+ </element>
+ <element name="H265">
+ <description>
+ High Efficiency Video Coding (HEVC), also known as H.265 and MPEG-H Part 2, is a video
+ compression standard, one of several potential successors to the widely used AVC (H.264 or
+ MPEG-4 Part 10). In comparison to AVC, HEVC offers about double the data compression ratio
+ at the same level of video quality, or substantially improved video quality at the same
+ bit rate. It supports resolutions up to 8192x4320, including 8K UHD.
+ </description>
+ </element>
+ <element name="Theora">
+ <description>
+ Theora is derived from the formerly proprietary VP3 codec, released into the public domain
+ by On2 Technologies. It is broadly comparable in design and bitrate efficiency to
+ MPEG-4 Part 2, early versions of Windows Media Video, and RealVideo while lacking some of
+ the features present in some of these other codecs. It is comparable in open standards
+ philosophy to the BBC's Dirac codec.
+ </description>
+ </element>
+ <element name="VP8">
+ <description>
+ VP8 can be multiplexed into the Matroska-based container format WebM along with Vorbis and
+ Opus audio. The image format WebP is based on VP8's intra-frame coding. VP8's direct
+ successor, VP9, and the emerging royalty-free internet video format AV1 from the Alliance for
+ Open Media (AOMedia) are based on VP8.
+ </description>
+ </element>
+ <element name="VP9">
+ <description>
+ Similar to VP8, but VP9 is customized for video resolutions beyond high-definition video (UHD)
+ and also enables lossless compression.
+ </description>
+ </element>
+</enum>
+
<!-- Policies -->
<enum name="UpdateResult">
<element name="UP_TO_DATE"/>
@@ -1278,17 +1416,299 @@
</struct>
<!-- End of Policies -->
+<!-- Remote Control -->
+<enum name="ModuleType">
+ <element name="CLIMATE"/>
+ <element name="RADIO"/>
+ </enum>
+
+ <enum name="RadioBand">
+ <element name="AM"/>
+ <element name="FM"/>
+ <element name="XM"/>
+ </enum>
+
+ <struct name="RdsData">
+ <param name="PS" type="String" minlength="0" maxlength="8" mandatory="false">
+ <description>Program Service Name</description>
+ </param>
+ <param name="RT" type="String" minlength="0" maxlength="64" mandatory="false">
+ <description>Radio Text</description>
+ </param>
+ <param name="CT" type="String" minlength="24" maxlength="24" mandatory="false">
+ <description>The clock text in UTC format as YYYY-MM-DDThh:mm:ss.sTZD</description>
+ </param>
+ <param name="PI" type="String" minlength="0" maxlength="6" mandatory="false">
+ <description>Program Identification - the call sign for the radio station</description>
+ </param>
+ <param name="PTY" type="Integer" minvalue="0" maxvalue="31" mandatory="false">
+ <description>The program type - The region should be used to differentiate between EU and North America program types</description>
+ </param>
+ <param name="TP" type="Boolean" mandatory="false">
+ <description>Traffic Program Identification - Identifies a station that offers traffic</description>
+ </param>
+ <param name="TA" type="Boolean" mandatory="false">
+ <description>Traffic Announcement Identification - Indicates an ongoing traffic announcement</description>
+ </param>
+ <param name="REG" type="String" mandatory="false">
+ <description>Region</description>
+ </param>
+ </struct>
+
+ <enum name="RadioState">
+ <element name="ACQUIRING"/>
+ <element name="ACQUIRED"/>
+ <element name="MULTICAST"/>
+ <element name="NOT_FOUND"/>
+ </enum>
+
+ <struct name="RadioControlData">
+ <param name="frequencyInteger" type="Integer" minvalue="0" maxvalue="1710" mandatory="false">
+ <description>The integer part of the frequency ie for 101.7 this value should be 101</description>
+ </param>
+ <param name="frequencyFraction" type="Integer" minvalue="0" maxvalue="9" mandatory="false">
+ <description>The fractional part of the frequency for 101.7 is 7</description>
+ </param>
+ <param name="band" type="Common.RadioBand" mandatory="false">
+ </param>
+ <param name="rdsData" type="Common.RdsData" mandatory="false">
+ </param>
+ <param name="availableHDs" type="Integer" minvalue="1" maxvalue="3" mandatory="false">
+ <description>number of HD sub-channels if available</description>
+ </param>
+ <param name="hdChannel" type="Integer" minvalue="1" maxvalue="3" mandatory="false">
+ <description>Current HD sub-channel if available</description>
+ </param>
+ <param name="signalStrength" type="Integer" minvalue="0" maxvalue="100" mandatory="false">
+ </param>
+ <param name="signalChangeThreshold" type="Integer" minvalue="0" maxvalue="100" mandatory="false">
+ <description>If the signal strength falls below the set value for this parameter, the radio will tune to an alternative frequency</description>
+ </param>
+ <param name="radioEnable" type="Boolean" mandatory="false">
+ <description> True if the radio is on, false is the radio is off</description>
+ </param>
+ <param name="state" type="Common.RadioState" mandatory="false">
+ </param>
+ </struct>
+
+ <struct name="RadioControlCapabilities">
+ <description>Contains information about a radio control module's capabilities.</description>
+ <param name="moduleName" type="String" maxlength="100" mandatory="true" >
+ <description>The short name or a short description of the radio control module.</description>
+ </param>
+ <param name="radioEnableAvailable" type="Boolean" mandatory="false">
+ <description>
+ Availability of the control of enable/disable radio.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="radioBandAvailable" type="Boolean" mandatory="false" >
+ <description>
+ Availability of the control of radio band.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="radioFrequencyAvailable" type="Boolean" mandatory="false" >
+ <description>
+ Availability of the control of radio frequency.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="hdChannelAvailable" type="Boolean" mandatory="false" >
+ <description>
+ Availability of the control of HD radio channel.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="rdsDataAvailable" type="Boolean" mandatory="false" >
+ <description>
+ Availability of the getting Radio Data System (RDS) data.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="availableHDsAvailable" type="Boolean" mandatory="false" >
+ <description>
+ Availability of the getting the number of available HD channels.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="stateAvailable" type="Boolean" mandatory="false" >
+ <description>
+ Availability of the getting the Radio state.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="signalStrengthAvailable" type="Boolean" mandatory="false" >
+ <description>
+ Availability of the getting the signal strength.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="signalChangeThresholdAvailable" type="Boolean" mandatory="false" >
+ <description>
+ Availability of the getting the signal Change Threshold.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ </struct>
+
+ <enum name="DefrostZone">
+ <element name="FRONT"/>
+ <element name="REAR"/>
+ <element name="ALL"/>
+ <element name="NONE"/>
+ </enum>
+
+ <enum name="VentilationMode">
+ <element name="UPPER"/>
+ <element name="LOWER"/>
+ <element name="BOTH"/>
+ <element name="NONE"/>
+ </enum>
+
+ <enum name="TemperatureUnit">
+ <element name="FAHRENHEIT"/>
+ <element name="CELSIUS"/>
+ </enum>
+
+ <struct name="Temperature">
+ <param name="unit" type="TemperatureUnit" mandatory="true" >
+ <description>Temperature Unit</description>
+ </param>
+ <param name="value" type="Float" mandatory="true" >
+ <description>Temperature Value in TemperatureUnit specified unit. Range depends on OEM and is not checked by SDL.</description>
+ </param>
+ </struct>
+
+ <struct name="ClimateControlData">
+ <param name="fanSpeed" type="Integer" minvalue="0" maxvalue="100" mandatory="false">
+ </param>
+ <param name="currentTemperature" type="Common.Temperature" mandatory="false">
+ </param>
+ <param name="desiredTemperature" type="Common.Temperature" mandatory="false">
+ </param>
+ <param name="acEnable" type="Boolean" mandatory="false">
+ </param>
+ <param name="circulateAirEnable" type="Boolean" mandatory="false">
+ </param>
+ <param name="autoModeEnable" type="Boolean" mandatory="false">
+ </param>
+ <param name="defrostZone" type="DefrostZone" mandatory="false">
+ </param>
+ <param name="dualModeEnable" type="Boolean" mandatory="false">
+ </param>
+ <param name="acMaxEnable" type="Boolean" mandatory="false">
+ </param>
+ <param name="ventilationMode" type="Common.VentilationMode" mandatory="false">
+ </param>
+ </struct>
+
+ <struct name="ClimateControlCapabilities">
+ <description>Contains information about a climate control module's capabilities.</description>
+ <param name="moduleName" type="String" maxlength="100" mandatory="true" >
+ <description>The short name or a short description of the climate control module.</description>
+ </param>
+ <param name="currentTemperatureAvailable" type="Boolean" mandatory="false">
+ <description>
+ Availability of the reading of current temperature.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="fanSpeedAvailable" type="Boolean" mandatory="false">
+ <description>
+ Availability of the control of fan speed.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="desiredTemperatureAvailable" type="Boolean" mandatory="false">
+ <description>
+ Availability of the control of desired temperature.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="acEnableAvailable" type="Boolean" mandatory="false">
+ <description>
+ Availability of the control of turn on/off AC.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="acMaxEnableAvailable" type="Boolean" mandatory="false">
+ <description>
+ Availability of the control of enable/disable air conditioning is ON on the maximum level.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="circulateAirEnableAvailable" type="Boolean" mandatory="false">
+ <description>
+ Availability of the control of enable/disable circulate Air mode.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="autoModeEnableAvailable" type="Boolean" mandatory="false">
+ <description>
+ Availability of the control of enable/disable auto mode.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="dualModeEnableAvailable" type="Boolean" mandatory="false">
+ <description>
+ Availability of the control of enable/disable dual mode.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="defrostZoneAvailable" type="Boolean" mandatory="false">
+ <description>
+ Availability of the control of defrost zones.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="defrostZone" type="Common.DefrostZone" minsize="1" maxsize="100" array="true" mandatory="false">
+ <description>
+ A set of all defrost zones that are controllable.
+ </description>
+ </param>
+ <param name="ventilationModeAvailable" type="Boolean" mandatory="false">
+ <description>
+ Availability of the control of air ventilation mode.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="ventilationMode" type="Common.VentilationMode" minsize="1" maxsize="100" array="true" mandatory="false">
+ <description>
+ A set of all ventilation modes that are controllable.
+ </description>
+ </param>
+ </struct>
+
+ <struct name="ModuleData">
+ <description>The moduleType indicates which type of data should be changed and identifies which data object exists in this struct. For example, if the moduleType is CLIMATE then a "climateControlData" should exist</description>
+ <param name="moduleType" type="Common.ModuleType" mandatory="true" >
+ </param>
+ <param name="radioControlData" type="Common.RadioControlData" mandatory="false">
+ </param>
+ <param name="climateControlData" type="Common.ClimateControlData" mandatory="false">
+ </param>
+ </struct>
+
+<enum name="RCAccessMode">
+ <description>Enumeration that describes possible remote control access mode the application might be in on HU.</description>
+ <element name="AUTO_ALLOW"/>
+ <element name="AUTO_DENY"/>
+ <element name="ASK_DRIVER"/>
+</enum>
+
+<!-- End Remote Control -->
<struct name="TextField">
- <param name="name" type="Common.TextFieldName">
+ <param name="name" type="Common.TextFieldName" mandatory="true">
<description>The name that identifies the field. See TextFieldName.</description>
</param>
- <param name="characterSet" type="Common.CharacterSet">
+ <param name="characterSet" type="Common.CharacterSet" mandatory="true">
<description>The character set that is supported in this field. See CharacterSet.</description>
</param>
- <param name="width" type="Integer" minvalue="1" maxvalue="500">
+ <param name="width" type="Integer" minvalue="1" maxvalue="500" mandatory="true">
<description>The number of characters in one row of this field.</description>
</param>
- <param name="rows" type="Integer" minvalue="1" maxvalue="8">
+ <param name="rows" type="Integer" minvalue="1" maxvalue="8" mandatory="true">
<description>The number of rows of this field.</description>
</param>
</struct>
@@ -1311,10 +1731,10 @@
<struct name="VehicleDataResult">
<description>Individual published data request result</description>
- <param name="dataType" type="Common.VehicleDataType">
+ <param name="dataType" type="Common.VehicleDataType" mandatory="true">
<description>Defined published data element type.</description>
</param>
- <param name="resultCode" type="Common.VehicleDataResultCode">
+ <param name="resultCode" type="Common.VehicleDataResultCode" mandatory="true">
<description>Published data result code.</description>
</param>
</struct>
@@ -1569,6 +1989,32 @@
</param>
</struct>
+<struct name="VideoStreamingFormat">
+ <description>Video streaming formats and their specifications.</description>
+ <param name="protocol" type="Common.VideoStreamingProtocol" mandatory="true">
+ <description>Protocol type, see VideoStreamingProtocol</description>
+ </param>
+ <param name="codec" type="Common.VideoStreamingCodec" mandatory="true">
+ <description>Codec type, see VideoStreamingCodec</description>
+ </param>
+</struct>
+
+<struct name="VideoConfig">
+ <description>Configuration of a video stream.</description>
+ <param name="protocol" type="Common.VideoStreamingProtocol" mandatory="false">
+ <description>The video protocol configuration</description>
+ </param>
+ <param name="codec" type="Common.VideoStreamingCodec" mandatory="false">
+ <description>The video codec configuration</description>
+ </param>
+ <param name="width" type="Integer" mandatory="false">
+ <description>Width of the video stream, in pixels.</description>
+ </param>
+ <param name="height" type="Integer" mandatory="false">
+ <description>Height of the video stream, in pixels.</description>
+ </param>
+</struct>
+
<struct name="DisplayCapabilities">
<description>Contains information about the display capabilities.</description>
<param name="displayType" type="Common.DisplayType" mandatory="true">
@@ -1924,73 +2370,73 @@
</struct>
<struct name="ECallInfo">
- <param name="eCallNotificationStatus" type="Common.VehicleDataNotificationStatus">
+ <param name="eCallNotificationStatus" type="Common.VehicleDataNotificationStatus" mandatory="true">
<description>References signal "eCallNotification_4A". See VehicleDataNotificationStatus.</description>
</param>
- <param name="auxECallNotificationStatus" type="Common.VehicleDataNotificationStatus">
+ <param name="auxECallNotificationStatus" type="Common.VehicleDataNotificationStatus" mandatory="true">
<description>References signal "eCallNotification". See VehicleDataNotificationStatus.</description>
</param>
- <param name="eCallConfirmationStatus" type="Common.ECallConfirmationStatus">
+ <param name="eCallConfirmationStatus" type="Common.ECallConfirmationStatus" mandatory="true">
<description>References signal "eCallConfirmation". See ECallConfirmationStatus.</description>
</param>
</struct>
<struct name="AirbagStatus">
- <param name="driverAirbagDeployed" type="Common.VehicleDataEventStatus">
+ <param name="driverAirbagDeployed" type="Common.VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsDrvBag_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
- <param name="driverSideAirbagDeployed" type="Common.VehicleDataEventStatus">
+ <param name="driverSideAirbagDeployed" type="Common.VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsDrvSideBag_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
- <param name="driverCurtainAirbagDeployed" type="Common.VehicleDataEventStatus">
+ <param name="driverCurtainAirbagDeployed" type="Common.VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsDrvCrtnBag_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
- <param name="passengerAirbagDeployed" type="Common.VehicleDataEventStatus">
+ <param name="passengerAirbagDeployed" type="Common.VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsPasBag_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
- <param name="passengerCurtainAirbagDeployed" type="Common.VehicleDataEventStatus">
+ <param name="passengerCurtainAirbagDeployed" type="Common.VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsPasCrtnBag_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
- <param name="driverKneeAirbagDeployed" type="Common.VehicleDataEventStatus">
+ <param name="driverKneeAirbagDeployed" type="Common.VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsKneeDrvBag_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
- <param name="passengerSideAirbagDeployed" type="Common.VehicleDataEventStatus">
+ <param name="passengerSideAirbagDeployed" type="Common.VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsPasSideBag_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
- <param name="passengerKneeAirbagDeployed" type="Common.VehicleDataEventStatus">
+ <param name="passengerKneeAirbagDeployed" type="Common.VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsKneePasBag_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
</struct>
<struct name="EmergencyEvent">
- <param name="emergencyEventType" type="Common.EmergencyEventType">
+ <param name="emergencyEventType" type="Common.EmergencyEventType" mandatory="true">
<description>References signal "VedsEvntType_D_Ltchd". See EmergencyEventType.</description>
</param>
- <param name="fuelCutoffStatus" type="Common.FuelCutoffStatus">
+ <param name="fuelCutoffStatus" type="Common.FuelCutoffStatus" mandatory="true">
<description>References signal "RCM_FuelCutoff". See FuelCutoffStatus.</description>
</param>
- <param name="rolloverEvent" type="Common.VehicleDataEventStatus">
+ <param name="rolloverEvent" type="Common.VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsEvntRoll_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
- <param name="maximumChangeVelocity" type="Common.VehicleDataEventStatus">
+ <param name="maximumChangeVelocity" type="Common.VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsMaxDeltaV_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
- <param name="multipleEvents" type="Common.VehicleDataEventStatus">
+ <param name="multipleEvents" type="Common.VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsMultiEvnt_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
</struct>
<struct name="ClusterModeStatus">
- <param name="powerModeActive" type="Boolean">
+ <param name="powerModeActive" type="Boolean" mandatory="true">
<description>References signal "PowerMode_UB".</description>
</param>
- <param name="powerModeQualificationStatus" type="Common.PowerModeQualificationStatus">
+ <param name="powerModeQualificationStatus" type="Common.PowerModeQualificationStatus" mandatory="true">
<description>References signal "PowerModeQF". See PowerModeQualificationStatus.</description>
</param>
- <param name="carModeStatus" type="Common.CarModeStatus">
+ <param name="carModeStatus" type="Common.CarModeStatus" mandatory="true">
<description>References signal "CarMode". See CarMode.</description>
</param>
- <param name="powerModeStatus" type="Common.PowerModeStatus">
+ <param name="powerModeStatus" type="Common.PowerModeStatus" mandatory="true">
<description>References signal "PowerMode". See PowerMode.</description>
</param>
</struct>
@@ -2086,6 +2532,89 @@
</param>
</struct>
+ <struct name="NavigationCapability">
+ <description>Extended capabilities for an onboard navigation system</description>
+ <param name="sendLocationEnabled" type="Boolean" mandatory="false">
+ <description>If the module has the ability to add locations to the onboard nav</description>
+ </param>
+ <param name="getWayPointsEnabled" type="Boolean" mandatory="false">
+ <description>If the module has the ability to return way points from onboard nav</description>
+ </param>
+ </struct>
+
+ <struct name="PhoneCapability">
+ <description>Extended capabilities of the module's phone feature</description>
+ <param name="dialNumberEnabled" type="Boolean" mandatory="false">
+ <description>If the module has the abiulity to perform dial number</description>
+ </param>
+ </struct>
+
+ <struct name="VideoStreamingCapability">
+ <description>Contains information about this system's video streaming capabilities.</description>
+ <param name="preferredResolution" type="Common.ImageResolution" mandatory="false">
+ <description>The preferred resolution of a video stream for decoding and rendering on HMI.</description>
+ </param>
+ <param name="maxBitrate" type="Integer" minvalue="0" maxvalue="2147483647" mandatory="false">
+ <description>The maximum bitrate of video stream that is supported, in kbps.</description>
+ </param>
+ <param name="supportedFormats" type="Common.VideoStreamingFormat" array="true" mandatory="false">
+ <description>
+ Detailed information on each format supported by this system, in its preferred order
+ (i.e. the first element in the array is most preferable to the system).
+ Each object will contain a VideoStreamingFormat that describes what can be expected.
+ </description>
+ </param>
+ <param name="hapticSpatialDataSupported" type="Boolean" mandatory="false">
+ <description>True if the system can utilize the haptic spatial data from the source being streamed. </description>
+ </param>
+ </struct>
+
+ <struct name="SystemCapabilities">
+ <param name="navigationCapability" type="NavigationCapability" mandatory="false">
+ </param>
+ <param name="phoneCapability" type="PhoneCapability" mandatory="false">
+ </param>
+ <param name="videoStreamingCapability" type="VideoStreamingCapability" mandatory="false">
+ </param>
+ </struct>
+
+ <struct name="RemoteControlCapabilities">
+ <param name="climateControlCapabilities" type="ClimateControlCapabilities" mandatory="false" minsize="1" maxsize="100" array="true">
+ <description>If included, the platform supports RC climate controls. For this baseline version, maxsize=1. i.e. only one climate control module is supported.</description >
+ </param>
+ <param name="radioControlCapabilities" type="RadioControlCapabilities" mandatory="false" minsize="1" maxsize="100" array="true">
+ <description>If included, the platform supports RC radio controls. For this baseline version, maxsize=1. i.e. only one climate control module is supported.</description >
+ </param>
+ <param name="buttonCapabilities" type="ButtonCapabilities" mandatory="false" minsize="1" maxsize="100" array="true" >
+ <description>If included, the platform supports RC button controls with the included button names.</description >
+ </param>
+ </struct>
+
+ <struct name="Rectangle">
+ <param name="x" type="Float" mandatory="true">
+ <description>The X-coordinate of the user control</description>
+ </param>
+ <param name="y" type="Float" mandatory="true">
+ <description>The Y-coordinate of the user control</description>
+ </param>
+ <param name="width" type="Float" mandatory="true">
+ <description>The width of the user control's bounding rectangle</description>
+ </param>
+ <param name="height" type="Float" mandatory="true">
+ <description>The height of the user control's bounding rectangle</description>
+ </param>
+ </struct>
+
+ <struct name="HapticRect">
+ <description>Defines haptic rectangle data for each user control object for video streaming application</description>
+ <param name="id" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="true">
+ <description>A user control spatial identifier</description>
+ </param>
+ <param name="rect" type="Common.Rectangle" mandatory="true">
+ <description>The position of the haptic rectangle to be highlighted. The center of this rectangle will be "touched" when a press occurs.</description>
+ </param>
+ </struct>
+
</interface>
<interface name="Buttons" version="1.2.0" date="2017-04-27">
@@ -2100,6 +2629,23 @@
<description>Must be returned if the platform supports custom on-screen Presets</description>
</param>
</function>
+
+ <function name="ButtonPress" messagetype="request">
+ <description>Method is invoked when the application tries to press a button</description>
+ <param name="moduleType" type="Common.ModuleType" mandatory="true" >
+ <description>The module where the button should be pressed</description>
+ </param>
+ <param name="buttonName" type="Common.ButtonName" mandatory="true" />
+ <param name="buttonPressMode" type="Common.ButtonPressMode" mandatory="true" >
+ <description>Indicates whether this is a LONG or SHORT button press event.</description>
+ </param>
+ <param name="appID" type="Integer" mandatory="true">
+ <description>ID of the application that triggers the permission prompt.</description>
+ </param>
+ </function>
+ <function name="ButtonPress" messagetype="response">
+ </function>
+
<function name="OnButtonEvent" messagetype="notification">
<description>HU system must notify about every UP/DOWN event for buttons</description>
<param name="name" type="Common.ButtonName" mandatory="true"/>
@@ -2317,7 +2863,7 @@
</function>
<function name="DialNumber" messagetype="request">
<description>Request from SDL to call a specific number.</description>
- <param name="number" type="String" maxlength="40">
+ <param name="number" type="String" maxlength="40" mandatory="true">
<description>The number to dial. Only the character + and numbers are allowed.</description>
</param>
<param name="appID" type="Integer" mandatory="true">
@@ -2953,7 +3499,7 @@
<description>Optional text to label an app menu button (for certain touchscreen platforms).</description>
</param>
<param name="menuIcon" type="Common.Image" mandatory="false">
- <description>>Optional icon to draw on an app menu button (for certain touchscreen platforms).</description>
+ <description>Optional icon to draw on an app menu button (for certain touchscreen platforms).</description>
</param>
<param name="keyboardProperties" type="Common.KeyboardProperties" mandatory="false">
<description>On-screen keybaord configuration (if available).</description>
@@ -3000,6 +3546,9 @@
<param name="hmiCapabilities" type="Common.HMICapabilities" mandatory="false">
<description>Specifies the HMI’s capabilities. See HMICapabilities.</description>
</param>
+ <param name="systemCapabilities" type="Common.SystemCapabilities" mandatory="false">
+ <description>Specifies system capabilities. See SystemCapabilities</description>
+ </param>
</function>
<function name="ChangeRegistration" messagetype="request">
<description>Request from SmartDeviceLink to HMI to change language for app.</description>
@@ -3252,6 +3801,22 @@
<description>ID of application related to this RPC.</description>
</param>
</function>
+ <function name="SendHapticData" messagetype="request">
+ <description>Send the UI spatial data from MOBILE. This data will be utilized by the HMI to determine how and when haptic events should occur</description>
+ <param name="appID" type="Integer" mandatory="true">
+ <description>Internal ID of the application that requested this RPC.</description>
+ </param>
+ <param name="hapticRectData" type="Common.HapticRect" minsize="0" maxsize="1000" mandatory="false" array="true">
+ <description>
+ Array of rectangle data structures that represent the locations of all user controls present on the HMI.
+ This data should be updated if/when the application presents a new screen.
+ When a request is sent, if successful, it will replace all rectangle data previously sent through RPC.
+ Avoidance of doubt, when an empty hapticRectData, it will be clear all rectangle data previously sent through RPC.
+ </description>
+ </param>
+ </function>
+ <function name="SendHapticData" messagetype="response">
+ </function>
</interface>
<interface name="Navigation" version="1.4.0" date="2017-04-27">
@@ -3369,6 +3934,27 @@
<description>Current State of TBT client</description>
</param>
</function>
+ <function name="SetVideoConfig" messagetype="request">
+ <description>Request from SDL to HMI to ask whether HMI accepts a video stream with given configuration.</description>
+ <param name="config" type="Common.VideoConfig" mandatory="true">
+ <description>Configuration of a video stream.</description>
+ </param>
+ <param name="appID" type="Integer" mandatory="true">
+ <description>ID of application related to this RPC.</description>
+ </param>
+ </function>
+ <function name="SetVideoConfig" messagetype="response">
+ <description>
+ Response from HMI to SDL whether the configuration is accepted.
+ In a negative response, a list of rejected parameters are supplied.
+ </description>
+ <param name="rejectedParams" type="String" array="true" minsize="1" maxsize="1000" mandatory="false">
+ <description>
+ List of params of VideoConfig struct which are not accepted by HMI, e.g. "protocol" and "codec".
+ This param exists only when the response is negative.
+ </description>
+ </param>
+ </function>
<function name="StartStream" messagetype="request">
<description>Request from SmartDeviceLinkCore to HMI to start playing video streaming.</description>
<param name="url" type="String" minlength="21" maxlength="500" mandatory="true">
@@ -4255,4 +4841,94 @@
<param name="deviceId" type="Common.DeviceInfo" mandatory="false"/>
</function>
</interface>
+
+<interface name="RC" version="1.1" date="2017-07-18">
+ <function name="IsReady" messagetype="request">
+ <description>Method is invoked at system startup. Response should provide information about presence of any of remote controllable module and its readiness to cooperate with SDL.</description>
+ </function>
+ <function name="IsReady" messagetype="response">
+ <param name="available" type="Boolean" mandatory="true">
+ <description>Must be true if vehicle RC modules are present and ready to communicate with SDL.</description>
+ </param>
+ </function>
+
+ <function name="GetCapabilities" messagetype="request">
+ <description>Method is invoked at system startup by SDL to request information about Remote Control capabilities of HMI.</description>
+ </function>
+ <function name="GetCapabilities" messagetype="response">
+ <param name="remoteControlCapability" type="Common.RemoteControlCapabilities" mandatory="false">
+ <description>See RemoteControlCapabilities, all available RC modules and buttons shall be returned.</description>
+ </param>
+ </function>
+
+ <function name="SetInteriorVehicleData" functionID="SetInteriorVehicleDataID" messagetype="request">
+ <param name="moduleData" type="Common.ModuleData" mandatory="true" >
+ <description>The module type and data to set</description>
+ </param>
+ <param name="appID" type="Integer" mandatory="true">
+ <description>Internal SDL-assigned ID of the related application</description>
+ </param>
+ </function>
+
+ <function name="SetInteriorVehicleData" messagetype="response">
+ <description>Used to set the values of one zone and one data type within that zone</description>
+ <param name="moduleData" type="Common.ModuleData" mandatory="true" >
+ </param>
+ </function>
+
+<function name="GetInteriorVehicleData" messagetype="request">
+ <param name="moduleType" type="Common.ModuleType" mandatory="true" >
+ <description>The module data to retrieve from the vehicle for that type</description>
+ </param>
+ <param name="subscribe" type="Boolean" mandatory="false" defvalue="false">
+ <description>If subscribe is true, the head unit will send onInteriorVehicleData notifications for the module type</description>
+ </param>
+ <param name="appID" type="Integer" mandatory="true">
+ <description>Internal SDL-assigned ID of the related application</description>
+ </param>
+</function>
+
+<function name="GetInteriorVehicleData" messagetype="response">
+ <param name="moduleData" type="Common.ModuleData" mandatory="true" >
+ </param>
+ <param name="isSubscribed" type="Boolean" mandatory="false" >
+ <description>Is a conditional-mandatory parameter: must be returned in case "subscribe" parameter was present in the related request.
+ if "true" - the "moduleType" from request is successfully subscribed and the head unit will send onInteriorVehicleData notifications for the moduleDescription.
+ if "false" - the "moduleType" from request is either unsubscribed or failed to subscribe.</description>
+ </param>
+</function>
+
+<function name="GetInteriorVehicleDataConsent" messagetype="request">
+ <description>Sender: SDL->HMI. </description>
+ <description>HMI is expected to display a permission prompt to the driver showing the RC module and app details (for example, app's name).
+ The driver is expected to have an ability to grant or deny the permission.</description>
+ <param name="moduleType" type="Common.ModuleType" mandatory="true">
+ <description>The module type that the app requests to control.</description>
+ </param>
+ <param name="appID" type="Integer" mandatory="true">
+ <description>ID of the application that triggers the permission prompt.</description>
+ </param>
+ </function>
+ <function name="GetInteriorVehicleDataConsent" messagetype="response">
+ <param name="allowed" type="Boolean" mandatory="true">
+ <description>"true" - if the driver grants the permission for controlling to the named app;
+ "false" - in case the driver denies the permission for controlling to the named app.</description>
+ </param>
+</function>
+
+<function name="OnInteriorVehicleData" messagetype="notification">
+ <param name="moduleData" type="Common.ModuleData" mandatory="true" >
+ </param>
+</function>
+
+<function name="OnRemoteControlSettings" messagetype="notification">
+ <description>Sender: vehicle -> RSDL. Notification about remote-control settings changed. Sent after User`s choice through HMI.</description>
+ <param name="allowed" type="Boolean" mandatory="false" >
+ <description>If "true" - RC is allowed; if "false" - RC is disallowed.</description>
+ </param>
+ <param name="accessMode" type="Common.RCAccessMode" mandatory="false" >
+ <description>The remote control access mode specified by the driver via HMI.</description>
+ </param>
+</function>
+</interface>
</interfaces>
diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml
index 953f270741..2d550f04f2 100644
--- a/src/components/interfaces/MOBILE_API.xml
+++ b/src/components/interfaces/MOBILE_API.xml
@@ -132,6 +132,12 @@
<element name="RESUME_FAILED">
<description>The provided hash ID does not match the hash of the current set of registered data or the core could not resume the previous data.</description>
</element>
+ <element name="DATA_NOT_AVAILABLE">
+ <description>The requested data is not available on this vehicle or is not published for the connected app </description>
+ </element>
+ <element name="READ_ONLY">
+ <description>The value being set is read only</description>
+ </element>
</enum>
<enum name="ButtonPressMode">
@@ -246,6 +252,36 @@
<element name="SK-SK" internal_name="SK_SK">
<description>Slovak - Slovakia</description>
</element>
+ <element name="EN-IN" internal_name="EN_IN">
+ <description>English - India</description>
+ </element>
+ <element name="TH-TH" internal_name="TH_TH">
+ <description>Thai - Thailand</description>
+ </element>
+ <element name="EN-SA" internal_name="EN_SA">
+ <description>English - Middle East</description>
+ </element>
+ <element name="HE-IL" internal_name="HE_IL">
+ <description>Hebrew - Israel</description>
+ </element>
+ <element name="RO-RO" internal_name="RO_RO">
+ <description>Romanian - Romania</description>
+ </element>
+ <element name="UK-UA" internal_name="UK_UA">
+ <description>Ukrainian - Ukraine</description>
+ </element>
+ <element name="ID-ID" internal_name="ID_ID">
+ <description>Indonesian - Indonesia</description>
+ </element>
+ <element name="VI-VN" internal_name="VI_VN">
+ <description>Vietnamese - Vietnam</description>
+ </element>
+ <element name="MS-MY" internal_name="MS_MY">
+ <description>Malay - Malaysia</description>
+ </element>
+ <element name="HI-IN" internal_name="HI_IN">
+ <description>Hindi - India</description>
+ </element>
</enum>
<enum name="UpdateMode">
@@ -449,9 +485,9 @@
Describes different audio type configurations for PerformAudioPassThru.
e.g. {8kHz,8-bit,PCM}
</description>
- <param name="samplingRate" type="SamplingRate"/>
- <param name="bitsPerSample" type="BitsPerSample"/>
- <param name="audioType" type="AudioType"/>
+ <param name="samplingRate" type="SamplingRate" mandatory="true"/>
+ <param name="bitsPerSample" type="BitsPerSample" mandatory="true"/>
+ <param name="audioType" type="AudioType" mandatory="true"/>
</struct>
<enum name="VehicleDataType">
@@ -505,6 +541,28 @@
<element name="PRESET_9" />
<element name="CUSTOM_BUTTON" />
<element name="SEARCH" />
+
+ <!-- Climate Buttons -->
+ <element name="AC_MAX" />
+ <element name="AC" />
+ <element name="RECIRCULATE" />
+ <element name="FAN_UP" />
+ <element name="FAN_DOWN" />
+ <element name="TEMP_UP" />
+ <element name="TEMP_DOWN" />
+ <element name="DEFROST_MAX" />
+ <element name="DEFROST" />
+ <element name="DEFROST_REAR" />
+ <element name="UPPER_VENT" />
+ <element name="LOWER_VENT" />
+
+ <!-- Radio Buttons -->
+ <element name="VOLUME_UP" />
+ <element name="VOLUME_DOWN" />
+ <element name="EJECT" />
+ <element name="SOURCE" />
+ <element name="SHUFFLE" />
+ <element name="REPEAT" />
</enum>
<enum name="MediaClockFormat">
@@ -805,17 +863,97 @@
<element name="QUEUE" />
</enum>
+ <enum name="VideoStreamingProtocol">
+ <description>Enum for each type of video streaming protocol type.</description>
+ <element name="RAW">
+ <description>
+ Raw stream bytes that contains no timestamp data and is the lowest supported video streaming
+ </description>
+ </element>
+ <element name="RTP">
+ <description>
+ RTP facilitates the transfer of real-time data. Information provided by this protocol include
+ timestamps (for synchronization), sequence numbers (for packet loss and reordering detection)
+ and the payload format which indicates the encoded format of the data.
+ </description>
+ </element>
+ <element name="RTSP">
+ <description>
+ The transmission of streaming data itself is not a task of RTSP. Most RTSP servers use the
+ Real-time Transport Protocol (RTP) in conjunction with Real-time Control Protocol (RTCP)
+ for media stream delivery. However, some vendors implement proprietary transport protocols.
+ </description>
+ </element>
+ <element name="RTMP">
+ <description>
+ Real-Time Messaging Protocol (RTMP) was initially a proprietary protocol developed by
+ Macromedia for streaming audio, video and data over the Internet, between a Flash player
+ and a server. Macromedia is now owned by Adobe, which has released an incomplete version
+ of the specification of the protocol for public use.
+ </description>
+ </element>
+ <element name="WEBM">
+ <description>
+ The WebM container is based on a profile of Matroska. WebM initially supported VP8 video and
+ Vorbis audio streams. In 2013 it was updated to accommodate VP9 video and Opus audio.
+ </description>
+ </element>
+ </enum>
+
+ <enum name="VideoStreamingCodec">
+ <description>Enum for each type of video streaming codec.</description>
+ <element name="H264">
+ <description>
+ A block-oriented motion-compensation-based video compression standard.
+ As of 2014 it is one of the most commonly used formats for the recording, compression, and
+ distribution of video content.
+ </description>
+ </element>
+ <element name="H265">
+ <description>
+ High Efficiency Video Coding (HEVC), also known as H.265 and MPEG-H Part 2, is a video
+ compression standard, one of several potential successors to the widely used AVC (H.264 or
+ MPEG-4 Part 10). In comparison to AVC, HEVC offers about double the data compression ratio
+ at the same level of video quality, or substantially improved video quality at the same
+ bit rate. It supports resolutions up to 8192x4320, including 8K UHD.
+ </description>
+ </element>
+ <element name="Theora">
+ <description>
+ Theora is derived from the formerly proprietary VP3 codec, released into the public domain
+ by On2 Technologies. It is broadly comparable in design and bitrate efficiency to
+ MPEG-4 Part 2, early versions of Windows Media Video, and RealVideo while lacking some of
+ the features present in some of these other codecs. It is comparable in open standards
+ philosophy to the BBC's Dirac codec.
+ </description>
+ </element>
+ <element name="VP8">
+ <description>
+ VP8 can be multiplexed into the Matroska-based container format WebM along with Vorbis and
+ Opus audio. The image format WebP is based on VP8's intra-frame coding. VP8's direct
+ successor, VP9, and the emerging royalty-free internet video format AV1 from the Alliance for
+ Open Media (AOMedia) are based on VP8.
+ </description>
+ </element>
+ <element name="VP9">
+ <description>
+ Similar to VP8, but VP9 is customized for video resolutions beyond high-definition video (UHD)
+ and also enables lossless compression.
+ </description>
+ </element>
+ </enum>
+
<struct name="Image">
- <param name="value" minlength="0" maxlength="65535" type="String">
+ <param name="value" minlength="0" maxlength="65535" type="String" mandatory="true">
<description>Either the static hex icon value or the binary image file name identifier (sent by PutFile).</description>
</param>
- <param name="imageType" type="ImageType">
+ <param name="imageType" type="ImageType" mandatory="true">
<description>Describes, whether it is a static or dynamic image.</description>
</param>
</struct>
<struct name="SoftButton">
- <param name="type" type="SoftButtonType">
+ <param name="type" type="SoftButtonType" mandatory="true">
<description>Describes, whether it is text, highlighted text, icon, or dynamic image. See softButtonType</description>
</param>
<param name="text" minlength="0" maxlength="500" type="String" mandatory="false">
@@ -830,7 +968,7 @@
False, if not highlighted
</description>
</param>
- <param name="softButtonID" type="Integer" minvalue="0" maxvalue="65535">
+ <param name="softButtonID" type="Integer" minvalue="0" maxvalue="65535" mandatory="true">
<description>Value which is returned via OnButtonPress / OnButtonEvent</description>
</param>
<param name="systemAction" type="SystemAction" defvalue="DEFAULT_ACTION" mandatory="false">
@@ -840,9 +978,9 @@
<struct name="Choice">
<description>A choice is an option given to the user, which can be selected either by menu, or through voice recognition system.</description>
- <param name="choiceID" type="Integer" minvalue="0" maxvalue="65535" />
- <param name="menuName" type="String" maxlength="500" />
- <param name="vrCommands" type="String" minsize="1" maxsize="100" maxlength="99" array="true" />
+ <param name="choiceID" type="Integer" minvalue="0" maxvalue="65535" mandatory="true"/>
+ <param name="menuName" type="String" maxlength="500" mandatory="true"/>
+ <param name="vrCommands" type="String" minsize="1" maxsize="100" maxlength="99" array="true" mandatory="true"/>
<param name="image" type="Image" mandatory="false"/>
<param name="secondaryText" maxlength="500" type="String" mandatory="false">
<description>Optional secondary text to display; e.g. address of POI in a search result entry</description>
@@ -856,13 +994,13 @@
</struct>
<struct name="VrHelpItem">
- <param name="text" maxlength="500" type="String">
+ <param name="text" maxlength="500" type="String" mandatory="true">
<description>Text to display for VR Help item</description>
</param>
<param name="image" type="Image" mandatory="false">
<description>Image struct for VR Help item</description>
</param>
- <param name="position" type="Integer" minvalue="1" maxvalue="100">
+ <param name="position" type="Integer" minvalue="1" maxvalue="100" mandatory="true">
<description>Position to display item in VR Help list</description>
</param>
</struct>
@@ -870,10 +1008,10 @@
<struct name="SyncMsgVersion">
<description>Specifies the version number of the SYNC V4 protocol, that is supported by the mobile application</description>
- <param name="majorVersion" type="Integer" minvalue="1" maxvalue="10">
+ <param name="majorVersion" type="Integer" minvalue="1" maxvalue="10" mandatory="true">
<description>The major version indicates versions that is not-compatible to previous versions.</description>
</param>
- <param name="minorVersion" type="Integer" minvalue="0" maxvalue="1000">
+ <param name="minorVersion" type="Integer" minvalue="0" maxvalue="1000" mandatory="true">
<description>The minor version indicates a change to a previous version that should still allow to be run on an older version (with limited functionality)</description>
</param>
<param name="patchVersion" type="Integer" minvalue="0" maxvalue="1000" mandatory="false">
@@ -997,7 +1135,7 @@
</enum>
<struct name="SingleTireStatus">
- <param name="status" type="ComponentVolumeStatus">
+ <param name="status" type="ComponentVolumeStatus" mandatory="true">
<description>See ComponentVolumeStatus.</description>
</param>
</struct>
@@ -1168,61 +1306,61 @@
</enum>
<struct name="BeltStatus">
- <param name="driverBeltDeployed" type="VehicleDataEventStatus">
+ <param name="driverBeltDeployed" type="VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsDrvBelt_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
- <param name="passengerBeltDeployed" type="VehicleDataEventStatus">
+ <param name="passengerBeltDeployed" type="VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsPasBelt_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
- <param name="passengerBuckleBelted" type="VehicleDataEventStatus">
+ <param name="passengerBuckleBelted" type="VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsRw1PasBckl_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
- <param name="driverBuckleBelted" type="VehicleDataEventStatus">
+ <param name="driverBuckleBelted" type="VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsRw1DrvBckl_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
- <param name="leftRow2BuckleBelted" type="VehicleDataEventStatus">
+ <param name="leftRow2BuckleBelted" type="VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsRw2lBckl_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
- <param name="passengerChildDetected" type="VehicleDataEventStatus">
+ <param name="passengerChildDetected" type="VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsRw1PasChld_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
- <param name="rightRow2BuckleBelted" type="VehicleDataEventStatus">
+ <param name="rightRow2BuckleBelted" type="VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsRw2rBckl_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
- <param name="middleRow2BuckleBelted" type="VehicleDataEventStatus">
+ <param name="middleRow2BuckleBelted" type="VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsRw2mBckl_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
- <param name="middleRow3BuckleBelted" type="VehicleDataEventStatus">
+ <param name="middleRow3BuckleBelted" type="VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsRw3mBckl_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
- <param name="leftRow3BuckleBelted" type="VehicleDataEventStatus">
+ <param name="leftRow3BuckleBelted" type="VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsRw3lBckl_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
- <param name="rightRow3BuckleBelted" type="VehicleDataEventStatus">
+ <param name="rightRow3BuckleBelted" type="VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsRw3rBckl_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
- <param name="leftRearInflatableBelted" type="VehicleDataEventStatus">
+ <param name="leftRearInflatableBelted" type="VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsRw2lRib_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
- <param name="rightRearInflatableBelted" type="VehicleDataEventStatus">
+ <param name="rightRearInflatableBelted" type="VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsRw2rRib_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
- <param name="middleRow1BeltDeployed" type="VehicleDataEventStatus">
+ <param name="middleRow1BeltDeployed" type="VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsRw1mBelt_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
- <param name="middleRow1BuckleBelted" type="VehicleDataEventStatus">
+ <param name="middleRow1BuckleBelted" type="VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsRw1mBckl_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
</struct>
<struct name="BodyInformation">
- <param name="parkBrakeActive" type="Boolean">
+ <param name="parkBrakeActive" type="Boolean" mandatory="true">
<description>References signal "PrkBrkActv_B_Actl".</description>
</param>
- <param name="ignitionStableStatus" type="IgnitionStableStatus">
+ <param name="ignitionStableStatus" type="IgnitionStableStatus" mandatory="true">
<description>References signal "Ignition_Switch_Stable". See IgnitionStableStatus.</description>
</param>
- <param name="ignitionStatus" type="IgnitionStatus">
+ <param name="ignitionStatus" type="IgnitionStatus" mandatory="true">
<description>References signal "Ignition_status". See IgnitionStatus.</description>
</param>
<param name="driverDoorAjar" type="Boolean" mandatory="false">
@@ -1240,46 +1378,46 @@
</struct>
<struct name="DeviceStatus">
- <param name="voiceRecOn" type="Boolean">
+ <param name="voiceRecOn" type="Boolean" mandatory="true">
<description>References signal "CPM_VoiceRec_STAT".</description>
</param>
- <param name="btIconOn" type="Boolean">
+ <param name="btIconOn" type="Boolean" mandatory="true">
<description>References signal "BT_ICON".</description>
</param>
- <param name="callActive" type="Boolean">
+ <param name="callActive" type="Boolean" mandatory="true">
<description>References signal "CPM_Call_Active_STAT".</description>
</param>
- <param name="phoneRoaming" type="Boolean">
+ <param name="phoneRoaming" type="Boolean" mandatory="true">
<description>References signal "CPM_Phone_Roaming_STAT".</description>
</param>
- <param name="textMsgAvailable" type="Boolean">
+ <param name="textMsgAvailable" type="Boolean" mandatory="true">
<description>References signal "CPM_TextMsg_AVAL".</description>
</param>
- <param name="battLevelStatus" type="DeviceLevelStatus">
+ <param name="battLevelStatus" type="DeviceLevelStatus" mandatory="true">
<description>Device battery level status. References signal "CPM_Batt_Level_STAT". See DeviceLevelStatus.</description>
</param>
- <param name="stereoAudioOutputMuted" type="Boolean">
+ <param name="stereoAudioOutputMuted" type="Boolean" mandatory="true">
<description>References signal "CPM_Stereo_Audio_Output".</description>
</param>
- <param name="monoAudioOutputMuted" type="Boolean">
+ <param name="monoAudioOutputMuted" type="Boolean" mandatory="true">
<description>References signal "CPM_Mono_Audio_Output".</description>
</param>
- <param name="signalLevelStatus" type="DeviceLevelStatus">
+ <param name="signalLevelStatus" type="DeviceLevelStatus" mandatory="true">
<description>Device signal level status. References signal "CPM_Signal_Strength_STAT". See DeviceLevelStatus.</description>
</param>
- <param name="primaryAudioSource" type="PrimaryAudioSource">
+ <param name="primaryAudioSource" type="PrimaryAudioSource" mandatory="true">
<description>References signal "CPM_Stereo_PAS_Source". See PrimaryAudioSource.</description>
</param>
- <param name="eCallEventActive" type="Boolean">
+ <param name="eCallEventActive" type="Boolean" mandatory="true">
<description>References signal "eCall_Event".</description>
</param>
</struct>
<struct name="HeadLampStatus">
- <param name="lowBeamsOn" type="Boolean">
+ <param name="lowBeamsOn" type="Boolean" mandatory="true">
<description>Status of the low beam lamps. References signal "HeadLampLoActv_B_Stat".</description>
</param>
- <param name="highBeamsOn" type="Boolean">
+ <param name="highBeamsOn" type="Boolean" mandatory="true">
<description>Status of the high beam lamps. References signal "HeadLghtHiOn_B_Stat".</description>
</param>
<param name="ambientLightSensorStatus" type="AmbientLightStatus" mandatory="false">
@@ -1307,6 +1445,284 @@
</param>
</struct>
+ <enum name="ModuleType">
+ <element name="CLIMATE"/>
+ <element name="RADIO"/>
+ </enum>
+
+ <enum name="RadioBand">
+ <element name="AM"/>
+ <element name="FM"/>
+ <element name="XM"/>
+ </enum>
+
+ <struct name="RdsData">
+ <param name="PS" type="String" minlength="0" maxlength="8" mandatory="false" >
+ <description>Program Service Name</description>
+ </param>
+ <param name="RT" type="String" minlength="0" maxlength="64" mandatory="false" >
+ <description>Radio Text</description>
+ </param>
+ <param name="CT" type="String" minlength="24" maxlength="24" mandatory="false">
+ <description>The clock text in UTC format as YYYY-MM-DDThh:mm:ss.sTZD</description>
+ </param>
+ <param name="PI" type="String" minlength="0" maxlength="6" mandatory="false" >
+ <description>Program Identification - the call sign for the radio station</description>
+ </param>
+ <param name="PTY" type="Integer" minvalue="0" maxvalue="31" mandatory="false" >
+ <description>The program type - The region should be used to differentiate between EU and North America program types</description>
+ </param>
+ <param name="TP" type="Boolean" mandatory="false" >
+ <description>Traffic Program Identification - Identifies a station that offers traffic</description>
+ </param>
+ <param name="TA" type="Boolean" mandatory="false" >
+ <description>Traffic Announcement Identification - Indicates an ongoing traffic announcement</description>
+ </param>
+ <param name="REG" type="String" mandatory="false" >
+ <description>Region</description>
+ </param>
+ </struct>
+
+ <enum name="RadioState">
+ <element name="ACQUIRING"/>
+ <element name="ACQUIRED"/>
+ <element name="MULTICAST"/>
+ <element name="NOT_FOUND"/>
+ </enum>
+
+ <struct name="RadioControlData">
+ <param name="frequencyInteger" type="Integer" minvalue="0" maxvalue="1710" mandatory="false">
+ <description>The integer part of the frequency ie for 101.7 this value should be 101</description>
+ </param>
+ <param name="frequencyFraction" type="Integer" minvalue="0" maxvalue="9" mandatory="false">
+ <description>The fractional part of the frequency for 101.7 is 7</description>
+ </param>
+ <param name="band" type="RadioBand" mandatory="false">
+ </param>
+ <param name="rdsData" type="RdsData" mandatory="false">
+ <description> Read only parameter.</description>
+ </param>
+ <param name="availableHDs" type="Integer" minvalue="1" maxvalue="3" mandatory="false">
+ <description>number of HD sub-channels if available. Read only parameter.</description>
+ </param>
+ <param name="hdChannel" type="Integer" minvalue="1" maxvalue="3" mandatory="false">
+ <description>Current HD sub-channel if available</description>
+ </param>
+ <param name="signalStrength" type="Integer" minvalue="0" maxvalue="100" mandatory="false">
+ <description> Read only parameter.</description>
+ </param>
+ <param name="signalChangeThreshold" type="Integer" minvalue="0" maxvalue="100" mandatory="false">
+ <description>If the signal strength falls below the set value for this parameter,
+ the radio will tune to an alternative frequency. Read only parameter.</description>
+ </param>
+ <param name="radioEnable" type="Boolean" mandatory="false">
+ <description> True if the radio is on, false is the radio is off.</description>
+ </param>
+ <param name="state" type="RadioState" mandatory="false">
+ <description> Read only parameter.</description>
+ </param>
+ </struct>
+
+ <struct name="RadioControlCapabilities">
+ <description>Contains information about a radio control module's capabilities.</description>
+ <param name="moduleName" type="String" maxlength="100" mandatory="true" >
+ <description>The short name or a short description of the radio control module.</description>
+ </param>
+ <param name="radioEnableAvailable" type="Boolean" mandatory="false">
+ <description>
+ Availability of the control of enable/disable radio.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="radioBandAvailable" type="Boolean" mandatory="false" >
+ <description>
+ Availability of the control of radio band.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="radioFrequencyAvailable" type="Boolean" mandatory="false" >
+ <description>
+ Availability of the control of radio frequency.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="hdChannelAvailable" type="Boolean" mandatory="false" >
+ <description>
+ Availability of the control of HD radio channel.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="rdsDataAvailable" type="Boolean" mandatory="false" >
+ <description>
+ Availability of the getting Radio Data System (RDS) data.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="availableHDsAvailable" type="Boolean" mandatory="false" >
+ <description>
+ Availability of the getting the number of available HD channels.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="stateAvailable" type="Boolean" mandatory="false" >
+ <description>
+ Availability of the getting the Radio state.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="signalStrengthAvailable" type="Boolean" mandatory="false" >
+ <description>
+ Availability of the getting the signal strength.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="signalChangeThresholdAvailable" type="Boolean" mandatory="false" >
+ <description>
+ Availability of the getting the signal Change Threshold.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ </struct>
+
+ <enum name="DefrostZone">
+ <element name="FRONT"/>
+ <element name="REAR"/>
+ <element name="ALL"/>
+ <element name="NONE"/>
+ </enum>
+
+ <enum name="VentilationMode">
+ <element name="UPPER"/>
+ <element name="LOWER"/>
+ <element name="BOTH"/>
+ <element name="NONE"/>
+ </enum>
+
+ <enum name="TemperatureUnit">
+ <element name="FAHRENHEIT"/>
+ <element name="CELSIUS"/>
+ </enum>
+
+ <struct name="Temperature">
+ <param name="unit" type="TemperatureUnit" mandatory="true" >
+ <description>Temperature Unit</description>
+ </param>
+ <param name="value" type="Float" mandatory="true" >
+ <description>Temperature Value in TemperatureUnit specified unit. Range depends on OEM and is not checked by SDL.</description>
+ </param>
+ </struct>
+
+ <struct name="ClimateControlData">
+ <param name="fanSpeed" type="Integer" minvalue="0" maxvalue="100" mandatory="false">
+ </param>
+ <param name="currentTemperature" type="Temperature" mandatory="false">
+ <description> Read only parameter.</description>
+ </param>
+ <param name="desiredTemperature" type="Temperature" mandatory="false">
+ </param>
+ <param name="acEnable" type="Boolean" mandatory="false">
+ </param>
+ <param name="circulateAirEnable" type="Boolean" mandatory="false">
+ </param>
+ <param name="autoModeEnable" type="Boolean" mandatory="false">
+ </param>
+ <param name="defrostZone" type="DefrostZone" mandatory="false">
+ </param>
+ <param name="dualModeEnable" type="Boolean" mandatory="false">
+ </param>
+ <param name="acMaxEnable" type="Boolean" mandatory="false">
+ </param>
+ <param name="ventilationMode" type="VentilationMode" mandatory="false">
+ </param>
+ </struct>
+
+<struct name="ClimateControlCapabilities">
+ <description>Contains information about a climate control module's capabilities.</description>
+ <param name="moduleName" type="String" maxlength="100" mandatory="true" >
+ <description>The short name or a short description of the climate control module.</description>
+ </param>
+ <param name="currentTemperatureAvailable" type="Boolean" mandatory="false">
+ <description>
+ Availability of the reading of current temperature.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="fanSpeedAvailable" type="Boolean" mandatory="false">
+ <description>
+ Availability of the control of fan speed.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="desiredTemperatureAvailable" type="Boolean" mandatory="false">
+ <description>
+ Availability of the control of desired temperature.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="acEnableAvailable" type="Boolean" mandatory="false">
+ <description>
+ Availability of the control of turn on/off AC.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="acMaxEnableAvailable" type="Boolean" mandatory="false">
+ <description>
+ Availability of the control of enable/disable air conditioning is ON on the maximum level.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="circulateAirEnableAvailable" type="Boolean" mandatory="false">
+ <description>
+ Availability of the control of enable/disable circulate Air mode.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="autoModeEnableAvailable" type="Boolean" mandatory="false">
+ <description>
+ Availability of the control of enable/disable auto mode.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="dualModeEnableAvailable" type="Boolean" mandatory="false">
+ <description>
+ Availability of the control of enable/disable dual mode.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="defrostZoneAvailable" type="Boolean" mandatory="false">
+ <description>
+ Availability of the control of defrost zones.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="defrostZone" type="DefrostZone" minsize="1" maxsize="100" array="true" mandatory="false">
+ <description>
+ A set of all defrost zones that are controllable.
+ </description>
+ </param>
+ <param name="ventilationModeAvailable" type="Boolean" mandatory="false">
+ <description>
+ Availability of the control of air ventilation mode.
+ True: Available, False: Not Available, Not present: Not Available.
+ </description>
+ </param>
+ <param name="ventilationMode" type="VentilationMode" minsize="1" maxsize="100" array="true" mandatory="false">
+ <description>
+ A set of all ventilation modes that are controllable.
+ </description>
+ </param>
+</struct>
+
+ <struct name="ModuleData">
+ <description>The moduleType indicates which type of data should be changed and identifies which data object exists in this struct. For example, if the moduleType is CLIMATE then a "climateControlData" should exist</description>
+ <param name="moduleType" type="ModuleType" mandatory="true" >
+ </param>
+ <param name="radioControlData" type="RadioControlData" mandatory="false">
+ </param>
+ <param name="climateControlData" type="ClimateControlData" mandatory="false">
+ </param>
+ </struct>
+
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- Ford Specific Data Items -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~ -->
@@ -1415,84 +1831,84 @@
</enum>
<struct name="ECallInfo">
- <param name="eCallNotificationStatus" type="VehicleDataNotificationStatus">
+ <param name="eCallNotificationStatus" type="VehicleDataNotificationStatus" mandatory="true">
<description>References signal "eCallNotification_4A". See VehicleDataNotificationStatus.</description>
</param>
- <param name="auxECallNotificationStatus" type="VehicleDataNotificationStatus">
+ <param name="auxECallNotificationStatus" type="VehicleDataNotificationStatus" mandatory="true">
<description>References signal "eCallNotification". See VehicleDataNotificationStatus.</description>
</param>
- <param name="eCallConfirmationStatus" type="ECallConfirmationStatus">
+ <param name="eCallConfirmationStatus" type="ECallConfirmationStatus" mandatory="true">
<description>References signal "eCallConfirmation". See ECallConfirmationStatus.</description>
</param>
</struct>
<struct name="AirbagStatus">
- <param name="driverAirbagDeployed" type="VehicleDataEventStatus">
+ <param name="driverAirbagDeployed" type="VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsDrvBag_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
- <param name="driverSideAirbagDeployed" type="VehicleDataEventStatus">
+ <param name="driverSideAirbagDeployed" type="VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsDrvSideBag_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
- <param name="driverCurtainAirbagDeployed" type="VehicleDataEventStatus">
+ <param name="driverCurtainAirbagDeployed" type="VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsDrvCrtnBag_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
- <param name="passengerAirbagDeployed" type="VehicleDataEventStatus">
+ <param name="passengerAirbagDeployed" type="VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsPasBag_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
- <param name="passengerCurtainAirbagDeployed" type="VehicleDataEventStatus">
+ <param name="passengerCurtainAirbagDeployed" type="VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsPasCrtnBag_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
- <param name="driverKneeAirbagDeployed" type="VehicleDataEventStatus">
+ <param name="driverKneeAirbagDeployed" type="VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsKneeDrvBag_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
- <param name="passengerSideAirbagDeployed" type="VehicleDataEventStatus">
+ <param name="passengerSideAirbagDeployed" type="VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsPasSideBag_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
- <param name="passengerKneeAirbagDeployed" type="VehicleDataEventStatus">
+ <param name="passengerKneeAirbagDeployed" type="VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsKneePasBag_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
</struct>
<struct name="EmergencyEvent">
- <param name="emergencyEventType" type="EmergencyEventType">
+ <param name="emergencyEventType" type="EmergencyEventType" mandatory="true">
<description>References signal "VedsEvntType_D_Ltchd". See EmergencyEventType.</description>
</param>
- <param name="fuelCutoffStatus" type="FuelCutoffStatus">
+ <param name="fuelCutoffStatus" type="FuelCutoffStatus" mandatory="true">
<description>References signal "RCM_FuelCutoff". See FuelCutoffStatus.</description>
</param>
- <param name="rolloverEvent" type="VehicleDataEventStatus">
+ <param name="rolloverEvent" type="VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsEvntRoll_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
- <param name="maximumChangeVelocity" type="Integer" minvalue="0" maxvalue="255">
+ <param name="maximumChangeVelocity" type="Integer" minvalue="0" maxvalue="255" mandatory="true">
<description>References signal "VedsMaxDeltaV_D_Ltchd". Change in velocity in KPH. Additional reserved values:
0x00 No event
0xFE Not supported
0xFF Fault
</description>
</param>
- <param name="multipleEvents" type="VehicleDataEventStatus">
+ <param name="multipleEvents" type="VehicleDataEventStatus" mandatory="true">
<description>References signal "VedsMultiEvnt_D_Ltchd". See VehicleDataEventStatus.</description>
</param>
</struct>
<struct name="ClusterModeStatus">
- <param name="powerModeActive" type="Boolean">
+ <param name="powerModeActive" type="Boolean" mandatory="true">
<description>References signal "PowerMode_UB".</description>
</param>
- <param name="powerModeQualificationStatus" type="PowerModeQualificationStatus">
+ <param name="powerModeQualificationStatus" type="PowerModeQualificationStatus" mandatory="true">
<description>References signal "PowerModeQF". See PowerModeQualificationStatus.</description>
</param>
- <param name="carModeStatus" type="CarModeStatus">
+ <param name="carModeStatus" type="CarModeStatus" mandatory="true">
<description>References signal "CarMode". See CarMode.</description>
</param>
- <param name="powerModeStatus" type="PowerModeStatus">
+ <param name="powerModeStatus" type="PowerModeStatus" mandatory="true">
<description>References signal "PowerMode". See PowerMode.</description>
</param>
</struct>
<struct name="MyKey">
- <param name="e911Override" type="VehicleDataStatus">
+ <param name="e911Override" type="VehicleDataStatus" mandatory="true">
<description>Indicates whether e911 override is on. References signal "MyKey_e911Override_St". See VehicleDataStatus.</description>
</param>
</struct>
@@ -1535,101 +1951,101 @@
<struct name="TireStatus">
<description>The status and pressure of the tires.</description>
- <param name="pressureTelltale" type="WarningLightStatus">
+ <param name="pressureTelltale" type="WarningLightStatus" mandatory="true">
<description>Status of the Tire Pressure Telltale. See WarningLightStatus.</description>
</param>
- <param name="leftFront" type="SingleTireStatus">
+ <param name="leftFront" type="SingleTireStatus" mandatory="true">
<description>The status of the left front tire.</description>
</param>
- <param name="rightFront" type="SingleTireStatus">
+ <param name="rightFront" type="SingleTireStatus" mandatory="true">
<description>The status of the right front tire.</description>
</param>
- <param name="leftRear" type="SingleTireStatus">
+ <param name="leftRear" type="SingleTireStatus" mandatory="true">
<description>The status of the left rear tire.</description>
</param>
- <param name="rightRear" type="SingleTireStatus">
+ <param name="rightRear" type="SingleTireStatus" mandatory="true">
<description>The status of the right rear tire.</description>
</param>
- <param name="innerLeftRear" type="SingleTireStatus">
+ <param name="innerLeftRear" type="SingleTireStatus" mandatory="true">
<description>The status of the inner left rear.</description>
</param>
- <param name="innerRightRear" type="SingleTireStatus">
+ <param name="innerRightRear" type="SingleTireStatus" mandatory="true">
<description>The status of the inner right rear.</description>
</param>
</struct>
<struct name="GPSData">
<description>Struct with the GPS data.</description>
- <param name="longitudeDegrees" type="Float" minvalue="-180" maxvalue="180">
+ <param name="longitudeDegrees" type="Float" minvalue="-180" maxvalue="180" mandatory="true">
</param>
- <param name="latitudeDegrees" type="Float" minvalue="-90" maxvalue="90">
+ <param name="latitudeDegrees" type="Float" minvalue="-90" maxvalue="90" mandatory="true">
</param>
- <param name="utcYear" type="Integer" minvalue="2010" maxvalue="2100">
+ <param name="utcYear" type="Integer" minvalue="2010" maxvalue="2100" mandatory="true">
<description>The current UTC year.</description>
</param>
- <param name="utcMonth" type="Integer" minvalue="1" maxvalue="12">
+ <param name="utcMonth" type="Integer" minvalue="1" maxvalue="12" mandatory="true">
<description>The current UTC month.</description>
</param>
- <param name="utcDay" type="Integer" minvalue="1" maxvalue="31">
+ <param name="utcDay" type="Integer" minvalue="1" maxvalue="31" mandatory="true">
<description>The current UTC day.</description>
</param>
- <param name="utcHours" type="Integer" minvalue="0" maxvalue="23">
+ <param name="utcHours" type="Integer" minvalue="0" maxvalue="23" mandatory="true">
<description>The current UTC hour.</description>
</param>
- <param name="utcMinutes" type="Integer" minvalue="0" maxvalue="59">
+ <param name="utcMinutes" type="Integer" minvalue="0" maxvalue="59" mandatory="true">
<description>The current UTC minute.</description>
</param>
- <param name="utcSeconds" type="Integer" minvalue="0" maxvalue="59">
+ <param name="utcSeconds" type="Integer" minvalue="0" maxvalue="59" mandatory="true">
<description>The current UTC second.</description>
</param>
- <param name="compassDirection" type="CompassDirection">
+ <param name="compassDirection" type="CompassDirection" mandatory="true">
<description>See CompassDirection.</description>
</param>
- <param name="pdop" type="Float" minvalue="0" maxvalue="10" defvalue="0">
+ <param name="pdop" type="Float" minvalue="0" maxvalue="10" defvalue="0" mandatory="true">
<description>PDOP. If undefined or unavailable, then value shall be set to 0.</description>
</param>
- <param name="hdop" type="Float" minvalue="0" maxvalue="10" defvalue="0">
+ <param name="hdop" type="Float" minvalue="0" maxvalue="10" defvalue="0" mandatory="true">
<description>HDOP. If value is unknown, value shall be set to 0.</description>
</param>
- <param name="vdop" type="Float" minvalue="0" maxvalue="10" defvalue="0">
+ <param name="vdop" type="Float" minvalue="0" maxvalue="10" defvalue="0" mandatory="true">
<description>VDOP. If value is unknown, value shall be set to 0.</description>
</param>
- <param name="actual" type="Boolean">
+ <param name="actual" type="Boolean" mandatory="true">
<description>
True, if actual.
False, if infered.
</description>
</param>
- <param name="satellites" type="Integer" minvalue="0" maxvalue="31">
+ <param name="satellites" type="Integer" minvalue="0" maxvalue="31" mandatory="true">
<description>Number of satellites in view</description>
</param>
- <param name="dimension" type="Dimension">
+ <param name="dimension" type="Dimension" mandatory="true">
<description>See Dimension</description>
</param>
- <param name="altitude" type="Float" minvalue="-10000" maxvalue="10000">
+ <param name="altitude" type="Float" minvalue="-10000" maxvalue="10000" mandatory="true">
<description>Altitude in meters</description>
</param>
- <param name="heading" type="Float" minvalue="0" maxvalue="359.99">
+ <param name="heading" type="Float" minvalue="0" maxvalue="359.99" mandatory="true">
<description>The heading. North is 0. Resolution is 0.01</description>
</param>
- <param name="speed" type="Float" minvalue="0" maxvalue="500">
+ <param name="speed" type="Float" minvalue="0" maxvalue="500" mandatory="true">
<description>The speed in KPH</description>
</param>
</struct>
<struct name="VehicleDataResult">
<description>Individual published data request result</description>
- <param name="dataType" type="VehicleDataType">
+ <param name="dataType" type="VehicleDataType" mandatory="true">
<description>Defined published data element type.</description>
</param>
- <param name="resultCode" type="VehicleDataResultCode">
+ <param name="resultCode" type="VehicleDataResultCode" mandatory="true">
<description>Published data result code.</description>
</param>
</struct>
<struct name="DIDResult">
<description>Individual requested DID result and data</description>
- <param name="resultCode" type="VehicleDataResultCode">
+ <param name="resultCode" type="VehicleDataResultCode" mandatory="true">
<description>Individual DID result code.</description>
</param>
<param name="didLocation" type="Integer" minvalue="0" maxvalue="65535" mandatory="true">
@@ -1641,45 +2057,45 @@
</struct>
<struct name="StartTime">
- <param name="hours" type="Integer" minvalue="0" maxvalue="59">
+ <param name="hours" type="Integer" minvalue="0" maxvalue="59" mandatory="true">
<description>
The hour of the media clock.
Some radios only support a max of 19 hours. If out of range, it will be rejected.
</description>
</param>
- <param name="minutes" type="Integer" minvalue="0" maxvalue="59" />
- <param name="seconds" type="Integer" minvalue="0" maxvalue="59" />
+ <param name="minutes" type="Integer" minvalue="0" maxvalue="59" mandatory="true"/>
+ <param name="seconds" type="Integer" minvalue="0" maxvalue="59" mandatory="true"/>
</struct>
<struct name="TextField">
- <param name="name" type="TextFieldName">
+ <param name="name" type="TextFieldName" mandatory="true">
<description>The name that identifies the field. See TextFieldName.</description>
</param>
- <param name="characterSet" type="CharacterSet">
+ <param name="characterSet" type="CharacterSet" mandatory="true">
<description>The character set that is supported in this field. See CharacterSet.</description>
</param>
- <param name="width" type="Integer" minvalue="1" maxvalue="500">
+ <param name="width" type="Integer" minvalue="1" maxvalue="500" mandatory="true">
<description>The number of characters in one row of this field.</description>
</param>
- <param name="rows" type="Integer" minvalue="1" maxvalue="8">
+ <param name="rows" type="Integer" minvalue="1" maxvalue="8" mandatory="true">
<description>The number of rows of this field.</description>
</param>
</struct>
<struct name="ImageResolution">
- <param name="resolutionWidth" type="Integer" minvalue="1" maxvalue="10000">
+ <param name="resolutionWidth" type="Integer" minvalue="1" maxvalue="10000" mandatory="true">
<description>The image resolution width.</description>
</param>
- <param name="resolutionHeight" type="Integer" minvalue="1" maxvalue="10000">
+ <param name="resolutionHeight" type="Integer" minvalue="1" maxvalue="10000" mandatory="true">
<description>The image resolution height.</description>
</param>
</struct>
<struct name="ImageField">
- <param name="name" type="ImageFieldName">
+ <param name="name" type="ImageFieldName" mandatory="true">
<description>The name that identifies the field. See ImageFieldName.</description>
</param>
- <param name="imageTypeSupported" type="FileType" minsize="1" maxsize="100" array="true">
+ <param name="imageTypeSupported" type="FileType" minsize="1" maxsize="100" array="true" mandatory="true">
<description>The image types that are supported in this field. See FileType.</description>
</param>
<param name="imageResolution" type="ImageResolution" mandatory="false">
@@ -1700,6 +2116,7 @@
<element name="BEGIN"/>
<element name="MOVE"/>
<element name="END"/>
+ <element name="CANCEL"/>
</enum>
<struct name="TouchEvent">
@@ -1749,46 +2166,56 @@
</enum>
<struct name="HMIPermissions">
- <param name="allowed" type="HMILevel" minsize="0" maxsize="100" array="true">
+ <param name="allowed" type="HMILevel" minsize="0" maxsize="100" array="true" mandatory="true">
<description>A set of all HMI levels that are permitted for this given RPC.</description>
</param>
- <param name="userDisallowed" type="HMILevel" minsize="0" maxsize="100" array="true">
+ <param name="userDisallowed" type="HMILevel" minsize="0" maxsize="100" array="true" mandatory="true">
<description>A set of all HMI levels that are prohibited for this given RPC.</description>
</param>
</struct>
<struct name="ParameterPermissions">
- <param name="allowed" type="String" minsize="0" maxsize="100" maxlength = "100" array="true">
+ <param name="allowed" type="String" minsize="0" maxsize="100" maxlength = "100" array="true" mandatory="true">
<description>A set of all parameters that are permitted for this given RPC.</description>
</param>
- <param name="userDisallowed" type="String" minsize="0" maxsize="100" maxlength = "100" array="true">
+ <param name="userDisallowed" type="String" minsize="0" maxsize="100" maxlength = "100" array="true" mandatory="true">
<description>A set of all parameters that are prohibited for this given RPC.</description>
</param>
</struct>
<struct name="PermissionItem">
- <param name="rpcName" type="String" maxlength="100">
+ <param name="rpcName" type="String" maxlength="100" mandatory="true">
<description>Name of the individual RPC in the policy table.</description>
</param>
- <param name="hmiPermissions" type="HMIPermissions" />
- <param name="parameterPermissions" type="ParameterPermissions" />
+ <param name="hmiPermissions" type="HMIPermissions" mandatory="true"/>
+ <param name="parameterPermissions" type="ParameterPermissions" mandatory="true"/>
</struct>
+ <struct name="VideoStreamingFormat">
+ <description>Video streaming formats and their specifications.</description>
+ <param name="protocol" type="VideoStreamingProtocol" mandatory="true">
+ <description>Protocol type, see VideoStreamingProtocol</description>
+ </param>
+ <param name="codec" type="VideoStreamingCodec" mandatory="true">
+ <description>Codec type, see VideoStreamingCodec</description>
+ </param>
+ </struct>
+
<struct name="DisplayCapabilities">
<description>Contains information about the display capabilities.</description>
- <param name="displayType" type="DisplayType">
+ <param name="displayType" type="DisplayType" mandatory="true">
<description>The type of the display. See DisplayType</description>
</param>
- <param name="textFields" type="TextField" minsize="1" maxsize="100" array="true">
+ <param name="textFields" type="TextField" minsize="1" maxsize="100" array="true" mandatory="true">
<description>A set of all fields that support text data. See TextField</description>
</param>
<param name="imageFields" type="ImageField" minsize="1" maxsize="100" array="true" mandatory="false">
<description>A set of all fields that support images. See ImageField</description>
</param>
- <param name="mediaClockFormats" type="MediaClockFormat" minsize="0" maxsize="100" array="true">
+ <param name="mediaClockFormats" type="MediaClockFormat" minsize="0" maxsize="100" array="true" mandatory="true">
<description>A set of all supported formats of the media clock. See MediaClockFormat</description>
</param>
- <param name="graphicSupported" type="Boolean">
+ <param name="graphicSupported" type="Boolean" mandatory="true">
<description>The display's persistent screen supports referencing a static or dynamic image.</description>
</param>
<param name="templatesAvailable" type="String" minsize="0" maxsize="100" maxlength="100" array="true" mandatory="false">
@@ -1806,22 +2233,22 @@
<struct name="ButtonCapabilities">
<description>Contains information about a button's capabilities.</description>
- <param name="name" type="ButtonName">
+ <param name="name" type="ButtonName" mandatory="true">
<description>The name of the button. See ButtonName.</description>
</param>
- <param name="shortPressAvailable" type="Boolean">
+ <param name="shortPressAvailable" type="Boolean" mandatory="true">
<description>
The button supports a short press.
Whenever the button is pressed short, onButtonPressed( SHORT) will be invoked.
</description>
</param>
- <param name="longPressAvailable" type="Boolean">
+ <param name="longPressAvailable" type="Boolean" mandatory="true">
<description>
The button supports a LONG press.
Whenever the button is pressed long, onButtonPressed( LONG) will be invoked.
</description>
</param>
- <param name="upDownAvailable" type="Boolean">
+ <param name="upDownAvailable" type="Boolean" mandatory="true">
<description>
The button supports "button down" and "button up".
Whenever the button is pressed, onButtonEvent( DOWN) will be invoked.
@@ -1830,35 +2257,53 @@
</param>
</struct>
+ <struct name="RemoteControlCapabilities">
+ <param name="climateControlCapabilities" type="ClimateControlCapabilities" mandatory="false" minsize="1" maxsize="100" array="true">
+ <description>
+ If included, the platform supports RC climate controls.
+ For this baseline version, maxsize=1. i.e. only one climate control module is supported.
+ </description >
+ </param>
+ <param name="radioControlCapabilities" type="RadioControlCapabilities" mandatory="false" minsize="1" maxsize="100" array="true">
+ <description>
+ If included, the platform supports RC radio controls.
+ For this baseline version, maxsize=1. i.e. only one radio control module is supported.
+ </description >
+ </param>
+ <param name="buttonCapabilities" type="ButtonCapabilities" mandatory="false" minsize="1" maxsize="100" array="true" >
+ <description>If included, the platform supports RC button controls with the included button names.</description >
+ </param>
+ </struct>
+
<struct name="SoftButtonCapabilities">
<description>Contains information about a SoftButton's capabilities.</description>
- <param name="shortPressAvailable" type="Boolean">
+ <param name="shortPressAvailable" type="Boolean" mandatory="true">
<description>
The button supports a short press.
Whenever the button is pressed short, onButtonPressed( SHORT) will be invoked.
</description>
</param>
- <param name="longPressAvailable" type="Boolean">
+ <param name="longPressAvailable" type="Boolean" mandatory="true">
<description>
The button supports a LONG press.
Whenever the button is pressed long, onButtonPressed( LONG) will be invoked.
</description>
</param>
- <param name="upDownAvailable" type="Boolean">
+ <param name="upDownAvailable" type="Boolean" mandatory="true">
<description>
The button supports "button down" and "button up".
Whenever the button is pressed, onButtonEvent( DOWN) will be invoked.
Whenever the button is released, onButtonEvent( UP) will be invoked.
</description>
</param>
- <param name="imageSupported" type="Boolean">
+ <param name="imageSupported" type="Boolean" mandatory="true">
<description>The button supports referencing a static or dynamic image.</description>
</param>
</struct>
<struct name="PresetBankCapabilities">
<description>Contains information about on-screen preset capabilities.</description>
- <param name="onScreenPresetsAvailable" type="Boolean">
+ <param name="onScreenPresetsAvailable" type="Boolean" mandatory="true">
<description>Onscreen custom presets are available.</description>
</param>
</struct>
@@ -1870,6 +2315,9 @@
<param name="phoneCall" type="Boolean" mandatory="false">
<description>Availability of build in phone. True: Available, False: Not Available </description>
</param>
+ <param name="videoStreaming" type="Boolean" mandatory="false">
+ <description>Availability of video streaming. True: Available, False: Not Available</description>
+ </param>
</struct>
<struct name="MenuParams">
@@ -1890,20 +2338,20 @@
</description>
</param>
- <param name="menuName" type="String" maxlength="500">
+ <param name="menuName" type="String" maxlength="500" mandatory="true">
<description>Text to show in the menu for this sub menu.</description>
</param>
</struct>
<struct name="TTSChunk">
<description>A TTS chunk, that consists of the text/phonemes to speak and the type (like text or SAPI)</description>
- <param name="text" minlength="0" maxlength="500" type="String">
+ <param name="text" minlength="0" maxlength="500" type="String" mandatory="true">
<description>
The text or phonemes to speak.
May not be empty.
</description>
</param>
- <param name="type" type="SpeechCapabilities">
+ <param name="type" type="SpeechCapabilities" mandatory="true">
<description>Describes, whether it is text or a specific phoneme set. See SpeechCapabilities</description>
</param>
</struct>
@@ -2051,6 +2499,8 @@
<element name="BACKGROUND_PROCESS" />
<element name="TESTING" />
<element name="SYSTEM" />
+ <element name="PROJECTION" />
+ <element name="REMOTE_CONTROL" />
</enum>
<enum name="PredefinedLayout" platform="documentation">
@@ -2226,9 +2676,14 @@
<element name="SystemRequestID" value="38" hexvalue="26" />
<element name="SendLocationID" value="39" hexvalue="27" />
<element name="DialNumberID" value="40" hexvalue="28" />
+ <element name="ButtonPressID" value="41" hexvalue="29" />
+ <element name="GetInteriorVehicleDataID" value="43" hexvalue="2B" />
+ <element name="SetInteriorVehicleDataID" value="44" hexvalue="2C" />
<element name="GetWayPointsID" value="45" hexvalue="2D" />
<element name="SubscribeWayPointsID" value="46" hexvalue="2E"/>
<element name="UnsubscribeWayPointsID" value="47" hexvalue="2F"/>
+ <element name="GetSystemCapabilityID" value="48" hexvalue="30"/>
+ <element name="SendHapticDataID" value="49" hexvalue="31" />
<!--
Base Notifications
@@ -2250,6 +2705,7 @@
<element name="OnTouchEventID" value="32780" hexvalue="800C" />
<element name="OnSystemRequestID" value="32781" hexvalue="800D" />
<element name="OnHashChangeID" value="32782" hexvalue="800E" />
+ <element name="OnInteriorVehicleDataID" value="32783" hexvalue="800F" />
<element name="OnWayPointChangeID" value="32784" hexvalue="8010" />
<!--
@@ -2267,7 +2723,6 @@
<element name="OnEncodedSyncPDataID" value="98304" hexvalue="18000" />
<element name="OnSyncPDataID" value="98305" hexvalue="18001" />
-
</enum>
<enum name="messageType">
@@ -2378,6 +2833,91 @@
<description>Address to be used by navigation engines for search</description>
</param>
</struct>
+
+ <enum name="SystemCapabilityType">
+ <element name="NAVIGATION"/>
+ <element name="PHONE_CALL"/>
+ <element name="VIDEO_STREAMING"/>
+ <element name="AUDIO_STREAMING"/>
+ <element name="REMOTE_CONTROL"/>
+ </enum>
+
+ <struct name="NavigationCapability">
+ <description>Extended capabilities for an onboard navigation system</description>
+ <param name="sendLocationEnabled" type="Boolean" mandatory="false">
+ <description>If the module has the ability to add locations to the onboard nav</description>
+ </param>
+ <param name="getWayPointsEnabled" type="Boolean" mandatory="false">
+ <description>If the module has the ability to return way points from onboard nav</description>
+ </param>
+ </struct>
+
+ <struct name="PhoneCapability">
+ <description>Extended capabilities of the module's phone feature</description>
+ <param name="dialNumberEnabled" type="Boolean" mandatory="false">
+ <description>If the module has the abiulity to perform dial number</description>
+ </param>
+ </struct>
+
+ <struct name="VideoStreamingCapability">
+ <description>Contains information about this system's video streaming capabilities.</description>
+ <param name="preferredResolution" type="ImageResolution" mandatory="false">
+ <description>The preferred resolution of a video stream for decoding and rendering on HMI.</description>
+ </param>
+ <param name="maxBitrate" type="Integer" minvalue="0" maxvalue="2147483647" mandatory="false">
+ <description>The maximum bitrate of video stream that is supported, in kbps.</description>
+ </param>
+ <param name="supportedFormats" type="VideoStreamingFormat" array="true" mandatory="false">
+ <description>
+ Detailed information on each format supported by this system, in its preferred order
+ (i.e. the first element in the array is most preferable to the system).
+ Each object will contain a VideoStreamingFormat that describes what can be expected.
+ </description>
+ </param>
+ <param name="hapticSpatialDataSupported" type="Boolean" mandatory="false">
+ <description>True if the system can utilize the haptic spatial data from the source being streamed.</description>
+ </param>
+ </struct>
+
+ <struct name="SystemCapability">
+ <description>The systemCapabilityType indicates which type of data should be changed and identifies which data object exists in this struct. For example, if the SystemCapability Type is NAVIGATION then a "navigationCapability" should exist</description>
+ <param name="systemCapabilityType" type="SystemCapabilityType" mandatory="true">
+ </param>
+ <param name="navigationCapability" type="NavigationCapability" mandatory="false">
+ </param>
+ <param name="phoneCapability" type="PhoneCapability" mandatory="false">
+ </param>
+ <param name="videoStreamingCapability" type="VideoStreamingCapability" mandatory="false">
+ </param>
+ <param name="remoteControlCapability" type="RemoteControlCapabilities" mandatory="false">
+ </param>
+ </struct>
+
+ <struct name="Rectangle">
+ <param name="x" type="Float" mandatory="true">
+ <description>The upper left X-coordinate of the rectangle</description>
+ </param>
+ <param name="y" type="Float" mandatory="true">
+ <description>The upper left Y-coordinate of the rectangle</description>
+ </param>
+ <param name="width" type="Float" mandatory="true">
+ <description>The width of the rectangle</description>
+ </param>
+ <param name="height" type="Float" mandatory="true">
+ <description>The height of the rectangle</description>
+ </param>
+ </struct>
+
+ <struct name="HapticRect">
+ <description>Defines haptic data for each user control object for video streaming application</description>
+ <param name="id" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="true">
+ <description>A user control spatial identifier</description>
+ </param>
+ <param name="rect" type="Rectangle" mandatory="true">
+ <description>The position of the haptic rectangle to be highlighted. The center of this rectangle will be "touched" when a press occurs.</description>
+ </param>
+ </struct>
+
<!-- Requests/Responses -->
<function name="RegisterAppInterface" functionID="RegisterAppInterfaceID" messagetype="request">
@@ -2386,11 +2926,11 @@
Before registerAppInterface no other commands will be accepted/executed.
</description>
- <param name="syncMsgVersion" type="SyncMsgVersion">
+ <param name="syncMsgVersion" type="SyncMsgVersion" mandatory="true">
<description>See SyncMsgVersion</description>
</param>
- <param name="appName" type="String" maxlength="100">
+ <param name="appName" type="String" maxlength="100" mandatory="true">
<description>
The mobile application name, e.g. "Ford Drive Green".
Needs to be unique over all applications.
@@ -2429,7 +2969,7 @@
</description>
</param>
- <param name="isMediaApplication" type="Boolean">
+ <param name="isMediaApplication" type="Boolean" mandatory="true">
<description>
Indicates if the application is a media or a non-media application.
Only media applications will be able to stream audio to Sync that is audible outside of the BT media source.
@@ -2483,11 +3023,11 @@
<function name="RegisterAppInterface" functionID="RegisterAppInterfaceID" messagetype="response">
<description>The response to registerAppInterface</description>
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -2596,11 +3136,11 @@
<function name="UnregisterAppInterface" functionID="UnregisterAppInterfaceID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -2666,11 +3206,11 @@
<function name="SetGlobalProperties" functionID="SetGlobalPropertiesID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -2693,18 +3233,18 @@
<function name="ResetGlobalProperties" functionID="ResetGlobalPropertiesID" messagetype="request">
<description>Allows resetting global properties.</description>
- <param name="properties" type="GlobalProperty" minsize="1" maxsize="100" array="true" >
+ <param name="properties" type="GlobalProperty" minsize="1" maxsize="100" array="true" mandatory="true">
<description>Contains the names of all global properties (like timeoutPrompt) that should be unset. Resetting means, that they have the same value as at start up (default)</description>
</param>
</function>
<function name="ResetGlobalProperties" functionID="ResetGlobalPropertiesID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -2753,11 +3293,11 @@
<function name="AddCommand" functionID="AddCommandID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -2782,18 +3322,18 @@
<function name="DeleteCommand" functionID="DeleteCommandID" messagetype="request">
<description>Deletes all commands from the in-application menu with the specified command id.</description>
- <param name="cmdID" type="Integer" minvalue="0" maxvalue="2000000000">
+ <param name="cmdID" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="true">
<description>ID of the command(s) to delete.</description>
</param>
</function>
<function name="DeleteCommand" functionID="DeleteCommandID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -2815,7 +3355,7 @@
<function name="AddSubMenu" functionID="AddSubMenuID" messagetype="request">
<description>Adds a sub menu to the in-application menu.</description>
- <param name="menuID" type="Integer" minvalue="1" maxvalue="2000000000">
+ <param name="menuID" type="Integer" minvalue="1" maxvalue="2000000000" mandatory="true">
<description>unique ID of the sub menu to add.</description>
</param>
@@ -2830,17 +3370,17 @@
</description>
</param>
- <param name="menuName" maxlength="500" type="String">
+ <param name="menuName" maxlength="500" type="String" mandatory="true">
<description>Text to show in the menu for this sub menu.</description>
</param>
</function>
<function name="AddSubMenu" functionID="AddSubMenuID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -2861,7 +3401,7 @@
<function name="DeleteSubMenu" functionID="DeleteSubMenuID" messagetype="request">
<description>Deletes a submenu from the in-application menu.</description>
- <param name="menuID" type="Integer" minvalue="1" maxvalue="2000000000">
+ <param name="menuID" type="Integer" minvalue="1" maxvalue="2000000000" mandatory="true">
<description>The "menuID" of the submenu to delete. (See addSubMenu.menuID)</description>
</param>
@@ -2869,11 +3409,11 @@
<function name="DeleteSubMenu" functionID="DeleteSubMenuID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -2895,19 +3435,19 @@
<function name="CreateInteractionChoiceSet" functionID="CreateInteractionChoiceSetID" messagetype="request">
<description>creates interaction choice set to be used later by performInteraction</description>
- <param name="interactionChoiceSetID" type="Integer" minvalue="0" maxvalue="2000000000">
+ <param name="interactionChoiceSetID" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="true">
<description>Unique ID used for this interaction choice set.</description>
</param>
- <param name="choiceSet" type="Choice" minsize="1" maxsize="100" array="true" />
+ <param name="choiceSet" type="Choice" minsize="1" maxsize="100" array="true" mandatory="true"/>
</function>
<function name="CreateInteractionChoiceSet" functionID="CreateInteractionChoiceSetID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -2929,7 +3469,7 @@
<function name="PerformInteraction" functionID="PerformInteractionID" messagetype="request">
<description>Triggers an interaction (e.g. "Permit GPS?" - Yes, no, Always Allow).</description>
- <param name="initialText" type="String" maxlength="500" >
+ <param name="initialText" type="String" maxlength="500" mandatory="true">
<description>
Text to be displayed first.
</description>
@@ -2943,11 +3483,11 @@
</description>
</param>
- <param name="interactionMode" type="InteractionMode">
+ <param name="interactionMode" type="InteractionMode" mandatory="true">
<description>See InteractionMode.</description>
</param>
- <param name="interactionChoiceSetIDList" type="Integer" minsize="0" maxsize="100" minvalue="0" maxvalue="2000000000" array="true">
+ <param name="interactionChoiceSetIDList" type="Integer" minsize="0" maxsize="100" minvalue="0" maxvalue="2000000000" array="true" mandatory="true">
<description>List of interaction choice set IDs to use with an interaction.</description>
</param>
@@ -2990,11 +3530,11 @@
<function name="PerformInteraction" functionID="PerformInteractionID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -3042,17 +3582,17 @@
<description>Deletes interaction choice set that has been created with "CreateInteractionChoiceSet".</description>
<description>The interaction may only be deleted when not currently in use by a "performInteraction".</description>
- <param name="interactionChoiceSetID" type="Integer" minvalue="0" maxvalue="2000000000">
+ <param name="interactionChoiceSetID" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="true">
<description>ID of the interaction choice set to delete.</description>
</param>
</function>
<function name="DeleteInteractionChoiceSet" functionID="DeleteInteractionChoiceSetID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -3124,11 +3664,11 @@
<function name="Alert" functionID="AlertID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -3252,11 +3792,11 @@
<function name="Show" functionID="ShowID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -3279,7 +3819,7 @@
<function name="Speak" functionID="SpeakID" messagetype="request">
<description>Speaks a text.</description>
- <param name="ttsChunks" type="TTSChunk" minsize="1" maxsize="100" array="true">
+ <param name="ttsChunks" type="TTSChunk" minsize="1" maxsize="100" array="true" mandatory="true">
<description>
An array of text chunks of type TTSChunk. See TTSChunk.
The array must have at least one item.
@@ -3290,11 +3830,11 @@
<function name="Speak" functionID="SpeakID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -3345,11 +3885,11 @@
</function>
<function name="SetMediaClockTimer" functionID="SetMediaClockTimerID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -3403,11 +3943,11 @@
</function>
<function name="PerformAudioPassThru" functionID="PerformAudioPassThruID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -3432,11 +3972,11 @@
</function>
<function name="EndAudioPassThru" functionID="EndAudioPassThruID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -3460,17 +4000,17 @@
To unsubscribe the notifications, use unsubscribeButton.
</description>
- <param name="buttonName" type="ButtonName">
+ <param name="buttonName" type="ButtonName" mandatory="true">
<description>Name of the button to subscribe.</description>
</param>
</function>
<function name="SubscribeButton" functionID="SubscribeButtonID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -3491,17 +4031,17 @@
<function name="UnsubscribeButton" functionID="UnsubscribeButtonID" messagetype="request">
<description>Unsubscribes from built-in HMI buttons.</description>
- <param name="buttonName" type="ButtonName">
+ <param name="buttonName" type="ButtonName" mandatory="true">
<description>Name of the button to unsubscribe.</description>
</param>
</function>
<function name="UnsubscribeButton" functionID="UnsubscribeButtonID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -3607,11 +4147,11 @@
</function>
<function name="SubscribeVehicleData" functionID="SubscribeVehicleDataID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true, if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="WARNINGS"/>
@@ -3790,11 +4330,11 @@
</function>
<function name="UnsubscribeVehicleData" functionID="UnsubscribeVehicleDataID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true, if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="WARNINGS"/>
@@ -3976,11 +4516,11 @@
<function name="GetVehicleData" functionID="GetVehicleDataID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true, if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -4092,11 +4632,11 @@
<function name="ReadDID" functionID="ReadDIDID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true, if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -4135,11 +4675,11 @@
<function name="GetDTCs" functionID="GetDTCsID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true, if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -4190,11 +4730,11 @@
<function name="DiagnosticMessage" functionID="DiagnosticMessageID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true, if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -4222,7 +4762,7 @@
<function name="ScrollableMessage" functionID="ScrollableMessageID" messagetype="request">
<description>Creates a full screen overlay containing a large block of formatted text that can be scrolled with up to 8 SoftButtons defined</description>
- <param name="scrollableMessageBody" type="String" maxlength="500">
+ <param name="scrollableMessageBody" type="String" maxlength="500" mandatory="true">
<description>Body of text that can include newlines and tabs.</description>
</param>
<param name="timeout" type="Integer" minvalue="1000" maxvalue="65535" defvalue="30000" mandatory="false">
@@ -4237,11 +4777,11 @@
</function>
<function name="ScrollableMessage" functionID="ScrollableMessageID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true, if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -4291,11 +4831,11 @@
</function>
<function name="Slider" functionID="SliderID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true, if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="SAVED"/>
@@ -4365,10 +4905,10 @@
</function>
<function name="ShowConstantTBT" functionID="ShowConstantTBTID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true, if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -4396,10 +4936,10 @@
</function>
<function name="AlertManeuver" functionID="AlertManeuverID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true, if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -4429,10 +4969,10 @@
</function>
<function name="UpdateTurnList" functionID="UpdateTurnListID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true, if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -4476,14 +5016,14 @@
<function name="ChangeRegistration" functionID="ChangeRegistrationID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description>
true, if successful
false, if failed
</description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -4506,11 +5046,11 @@
Generic Response is sent, when the name of a received msg cannot be retrieved. Only used in case of an error.
Currently, only resultCode INVALID_DATA is used.
</description>
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true, if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="INVALID_DATA"/>
</param>
@@ -4568,11 +5108,11 @@
<function name="PutFile" functionID="PutFileID" messagetype="response">
<description>Response is sent, when the file data was copied (success case). Or when an error occured.</description>
<description>Not supported on First generation SYNC vehicles. </description>
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true, if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -4584,7 +5124,7 @@
<element name="UNSUPPORTED_REQUEST"/>
</param>
- <param name="spaceAvailable" type="Integer" minvalue="0" maxvalue="2000000000">
+ <param name="spaceAvailable" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="true">
<description>
Provides the total local space available in SDL Core for the registered app.
If the transfer has systemFile enabled, then the value will be set to 0 automatically.
@@ -4613,11 +5153,11 @@
Response is sent, when the file data was deleted (success case). Or when an error occured.
Not supported on First generation SYNC vehicles.
</description>
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -4629,7 +5169,7 @@
<element name="UNSUPPORTED_REQUEST"/>
</param>
- <param name="spaceAvailable" type="Integer" minvalue="0" maxvalue="2000000000">
+ <param name="spaceAvailable" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="true">
<description>Provides the total local space available on SYNC for the registered app.</description>
</param>
@@ -4650,11 +5190,11 @@
Returns the current list of resident filenames for the registered app along with the current space available
Not supported on First generation SYNC vehicles.
</description>
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true, if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -4673,7 +5213,7 @@
</description>
</param>
- <param name="spaceAvailable" type="Integer" minvalue="0" maxvalue="2000000000">
+ <param name="spaceAvailable" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="true">
<description>Provides the total local space available on SYNC for the registered app.</description>
</param>
@@ -4700,11 +5240,11 @@
Not supported on First generation SYNC vehicles.
</description>
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true, if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -4739,11 +5279,11 @@
<function name="SetDisplayLayout" functionID="SetDisplayLayoutID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true, if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -4795,11 +5335,11 @@
</function>
<function name="SystemRequest" functionID="SystemRequestID" messagetype="response" >
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true, if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -4820,6 +5360,36 @@
</param>
</function>
+ <function name="SendHapticData" functionID="SendHapticDataID" messagetype="request" >
+ <description>
+ Send the spatial data gathered from SDLCarWindow or VirtualDisplayEncoder to the HMI.
+ This data will be utilized by the HMI to determine how and when haptic events should occur
+ </description>
+ <param name="hapticRectData" type="HapticRect" minsize="0" maxsize="1000" mandatory="false" array="true">
+ <description>
+ Array of rectangle data structures that represent the locations of all user controls present on the HMI.
+ This data should be updated if/when the application presents a new screen.
+ When a request is sent, if successful, it will replace all rectangle data previously sent through RPC.
+ If an empty array is sent, the existing rectangle data will be cleared
+ </description>
+ </param>
+ </function>
+
+ <function name="SendHapticData" functionID="SendHapticDataID" messagetype="response" >
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
+ <description> true, if successful; false, if failed </description>
+ </param>
+
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
+ <description>See Result</description>
+ <element name="SUCCESS"/>
+ <element name="INVALID_DATA"/>
+ <element name="APPLICATION_NOT_REGISTERED"/>
+ <element name="GENERIC_ERROR"/>
+ <element name="DISALLOWED"/>
+ </param>
+ </function>
+
<function name="SendLocation" functionID="SendLocationID" messagetype="request">
<param name="longitudeDegrees" type="Float" minvalue="-180" maxvalue="180" mandatory="false">
</param>
@@ -4866,11 +5436,11 @@
</function>
<function name="SendLocation" functionID="SendLocationID" messagetype="response" >
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true, if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -4891,7 +5461,7 @@
<function name="DialNumber" functionID="DialNumberID" messagetype="request">
<description>Dials a phone number and switches to phone application.</description>
- <param name="number" type="String" maxlength="40">
+ <param name="number" type="String" maxlength="40" mandatory="true">
<description>
Phone number is a string, which can be up to 40 chars.
All characters shall be stripped from string except digits 0-9 and * # , ; +
@@ -4900,12 +5470,12 @@
</function>
<function name="DialNumber" functionID="DialNumberID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description>true, if successful</description>
<description>false, if failed</description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -4926,10 +5496,10 @@
</function>
<function name="SubscribeWayPoints" functionID="SubscribeWayPointsID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true, if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -4952,10 +5522,10 @@
</function>
<function name="GetWayPoints" functionID="GetWayPointsID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true, if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -4980,10 +5550,10 @@
</function>
<function name="UnsubscribeWayPoints" functionID="UnsubscribeWayPointsID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true, if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -5001,32 +5571,63 @@
</param>
</function>
+ <function name="GetSystemCapability" functionID="GetSystemCapabilityID" messagetype="request">
+ <param name="systemCapabilityType" type="SystemCapabilityType" mandatory="true">
+ <description>The type of system capability to get more information on</description>
+ </param>
+ </function>
+
+ <function name="GetSystemCapability" functionID="GetSystemCapabilityID" messagetype="response">
+ <param name="systemCapability" type="SystemCapability" mandatory="true">
+ </param>
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
+ <description>See Result</description>
+ <element name="SUCCESS"/>
+ <element name="INVALID_DATA"/>
+ <element name="OUT_OF_MEMORY"/>
+ <element name="TOO_MANY_PENDING_REQUESTS"/>
+ <element name="APPLICATION_NOT_REGISTERED"/>
+ <element name="GENERIC_ERROR"/>
+ <element name="REJECTED"/>
+ <element name="IGNORED"/>
+ <element name="DISALLOWED"/>
+ <element name="USER_DISALLOWED"/>
+ <element name="UNSUPPORTED_RESOURCE"/><description>The capability does not exist on the module</description>
+ <element name="DATA_NOT_AVAILABLE"/><description>The capability should exist on the module but there was an error retrieving the data.</description>
+ </param>
+ <param name="info" type="String" maxlength="1000" mandatory="false">
+ </param>
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
+ <description> true if successful; false, if failed </description>
+ </param>
+ </function>
+
<!-- Notifications -->
<function name="OnHMIStatus" functionID="OnHMIStatusID" messagetype="notification">
- <param name="hmiLevel" type="HMILevel">
+ <param name="hmiLevel" type="HMILevel" mandatory="true">
<description>See HMILevel</description>
</param>
- <param name="audioStreamingState" type="AudioStreamingState">
+ <param name="audioStreamingState" type="AudioStreamingState" mandatory="true">
<description>See AudioStreamingState</description>
</param>
- <param name="systemContext" type="SystemContext">
+ <param name="systemContext" type="SystemContext" mandatory="true">
<description>See SystemContext</description>
</param>
</function>
<function name="OnAppInterfaceUnregistered" functionID="OnAppInterfaceUnregisteredID" messagetype="notification">
- <param name="reason" type="AppInterfaceUnregisteredReason">
+ <param name="reason" type="AppInterfaceUnregisteredReason" mandatory="true">
<description>See AppInterfaceUnregisteredReason</description>
</param>
</function>
<function name="OnButtonEvent" functionID="OnButtonEventID" messagetype="notification">
<description>Notifies application of UP/DOWN events for buttons to which the application is subscribed.</description>
- <param name="buttonName" type="ButtonName"/>
- <param name="buttonEventMode" type="ButtonEventMode">
+ <param name="buttonName" type="ButtonName" mandatory="true"/>
+ <param name="buttonEventMode" type="ButtonEventMode" mandatory="true">
<description>Indicates whether this is an UP or DOWN event.</description>
</param>
<param name="customButtonID" type="Integer" minvalue="0" maxvalue="65536" mandatory="false">
@@ -5036,8 +5637,8 @@
<function name="OnButtonPress" functionID="OnButtonPressID" messagetype="notification">
<description>Notifies application of LONG/SHORT press events for buttons to which the application is subscribed.</description>
- <param name="buttonName" type="ButtonName"/>
- <param name="buttonPressMode" type="ButtonPressMode">
+ <param name="buttonName" type="ButtonName" mandatory="true"/>
+ <param name="buttonPressMode" type="ButtonPressMode" mandatory="true">
<description>Indicates whether this is a LONG or SHORT button press event.</description>
</param>
<param name="customButtonID" type="Integer" minvalue="0" maxvalue="65536" mandatory="false">
@@ -5129,32 +5730,32 @@
</function>
<function name="OnCommand" functionID="OnCommandID" messagetype="notification">
- <param name="cmdID" type="Integer" minvalue="0" maxvalue="2000000000">
+ <param name="cmdID" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="true">
<description>Command ID, which is related to a specific menu entry</description>
</param>
- <param name="triggerSource" type="TriggerSource">
+ <param name="triggerSource" type="TriggerSource" mandatory="true">
<description>See TriggerSource</description>
</param>
</function>
<function name="OnTBTClientState" functionID="OnTBTClientStateID" messagetype="notification" >
<description>Provides applications with notifications specific to the current TBT client status on the module</description>
- <param name="state" type="TBTState">
+ <param name="state" type="TBTState" mandatory="true">
<description>Current State of TBT client</description>
</param>
</function>
<function name="OnDriverDistraction" functionID="OnDriverDistractionID" messagetype="notification" >
<description>Provides driver distraction state to mobile applications</description>
- <param name="state" type="DriverDistractionState">
+ <param name="state" type="DriverDistractionState" mandatory="true">
<description>Current State of Driver Distraction</description>
</param>
</function>
<function name="OnPermissionsChange" functionID="OnPermissionsChangeID" messagetype="notification" >
<description>Provides update to app of which policy-table-enabled functions are available</description>
- <param name="permissionItem" type="PermissionItem" minsize="0" maxsize="500" array="true">
+ <param name="permissionItem" type="PermissionItem" minsize="0" maxsize="500" array="true" mandatory="true">
<description>Change in permissions for a given set of RPCs</description>
</param>
</function>
@@ -5164,10 +5765,10 @@
</function>
<function name="OnLanguageChange" functionID="OnLanguageChangeID" messagetype="notification">
- <param name="language" type="Language">
+ <param name="language" type="Language" mandatory="true">
<description>Current SYNC voice engine (VR+TTS) language</description>
</param>
- <param name="hmiDisplayLanguage" type="Language">
+ <param name="hmiDisplayLanguage" type="Language" mandatory="true">
<description>Current display language</description>
</param>
</function>
@@ -5267,11 +5868,11 @@
</function>
<function name="EncodedSyncPData" functionID="EncodedSyncPDataID" messagetype="response" >
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true, if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -5296,11 +5897,11 @@
</function>
<function name="SyncPData" functionID="SyncPDataID" messagetype="response" >
- <param name="success" type="Boolean" platform="documentation">
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
<description> true, if successful; false, if failed </description>
</param>
- <param name="resultCode" type="Result" platform="documentation">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -5340,6 +5941,123 @@
</param>
</function>
+<function name="ButtonPress" functionID="ButtonPressID" messagetype="request">
+ <param name="moduleType" type="ModuleType" mandatory="true" >
+ <description>The module where the button should be pressed</description>
+ </param>
+ <param name="buttonName" type="ButtonName" mandatory="true" >
+ <description>The name of supported RC climate or radio button.</description>
+ </param>
+ <param name="buttonPressMode" type="ButtonPressMode" mandatory="true" >
+ <description>Indicates whether this is a LONG or SHORT button press event.</description>
+ </param>
+</function>
+
+<function name="ButtonPress" functionID="ButtonPressID" messagetype="response">
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true" >
+ <description>See Result</description>
+ <element name="SUCCESS"/>
+ <element name="OUT_OF_MEMORY"/>
+ <element name="TOO_MANY_PENDING_REQUESTS"/>
+ <element name="APPLICATION_NOT_REGISTERED"/>
+ <element name="GENERIC_ERROR"/>
+ <element name="REJECTED"/>
+ <element name="IGNORED"/>
+ <element name="DISALLOWED"/>
+ <element name="USER_DISALLOWED"/>
+ <element name="IN_USE"/>
+ </param>
+ <param name="info" type="String" maxlength="1000" mandatory="false">
+ </param>
+ <param name="success" type="Boolean" platform="documentation" mandatory="true" >
+ <description> true if successful; false, if failed </description>
+ </param>
+</function>
+
+<function name="GetInteriorVehicleData" functionID="GetInteriorVehicleDataID" messagetype="request">
+ <param name="moduleType" type="ModuleType" mandatory="true" >
+ <description>
+ The type of a RC module to retrieve module data from the vehicle.
+ In the future, this should be the Identification of a module.
+ </description>
+ </param>
+ <param name="subscribe" type="Boolean" mandatory="false" defvalue="false">
+ <description>
+ If subscribe is true, the head unit will register onInteriorVehicleData notifications for the requested moduelType.
+ If subscribe is false, the head unit will unregister onInteriorVehicleData notifications for the requested moduelType.
+ </description>
+ </param>
+</function>
+
+ <function name="GetInteriorVehicleData" functionID="GetInteriorVehicleDataID" messagetype="response">
+ <param name="moduleData" type="ModuleData" mandatory="true" >
+ </param>
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true" >
+ <description>See Result</description>
+ <element name="SUCCESS"/>
+ <element name="INVALID_DATA"/>
+ <element name="OUT_OF_MEMORY"/>
+ <element name="TOO_MANY_PENDING_REQUESTS"/>
+ <element name="APPLICATION_NOT_REGISTERED"/>
+ <element name="GENERIC_ERROR"/>
+ <element name="REJECTED"/>
+ <element name="IGNORED"/>
+ <element name="DISALLOWED"/>
+ <element name="USER_DISALLOWED"/>
+ <element name="UNSUPPORTED_RESOURCE"/>
+ </param>
+ <param name="info" type="String" maxlength="1000" mandatory="false">
+ </param>
+ <param name="success" type="Boolean" platform="documentation" mandatory="true" >
+ <description> true if successful; false, if failed </description>
+ </param>
+ <param name="isSubscribed" type="Boolean" mandatory="false" >
+ <description>
+ It is a conditional-mandatory parameter: must be returned in case "subscribe" parameter was present in the related request.
+ if "true" - the "moduleType" from request is successfully subscribed and the head unit will send onInteriorVehicleData notifications for the moduleType.
+ if "false" - the "moduleType" from request is either unsubscribed or failed to subscribe.
+ </description>
+ </param>
+
+ </function>
+
+ <function name="SetInteriorVehicleData" functionID="SetInteriorVehicleDataID" messagetype="request">
+ <param name="moduleData" type="ModuleData" mandatory="true" >
+ <description>The module data to set for the requested RC module.</description>
+ </param>
+ </function>
+
+ <function name="SetInteriorVehicleData" functionID="SetInteriorVehicleDataID" messagetype="response">
+ <description>Used to set the values of one remote control module </description>
+ <param name="moduleData" type="ModuleData" mandatory="true" >
+ </param>
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true" >
+ <description>See Result</description>
+ <element name="SUCCESS"/>
+ <element name="INVALID_DATA"/>
+ <element name="OUT_OF_MEMORY"/>
+ <element name="TOO_MANY_PENDING_REQUESTS"/>
+ <element name="APPLICATION_NOT_REGISTERED"/>
+ <element name="GENERIC_ERROR"/>
+ <element name="REJECTED"/>
+ <element name="IGNORED"/>
+ <element name="DISALLOWED"/>
+ <element name="USER_DISALLOWED"/>
+ <element name="READ_ONLY"/>
+ <element name="UNSUPPORTED_RESOURCE"/>
+ </param>
+ <param name="info" type="String" maxlength="1000" mandatory="false">
+ </param>
+ <param name="success" type="Boolean" platform="documentation" mandatory="true" >
+ <description> true if successful; false, if failed </description>
+ </param>
+ </function>
+
+
+ <function name="OnInteriorVehicleData" functionID="OnInteriorVehicleDataID" messagetype="notification">
+ <param name="moduleData" type="ModuleData" mandatory="true">
+ </param>
+ </function>
<!-- Deprecating - covered by OnSystemRequest
<function name="OnSyncPData" functionID="OnSyncPDataID" messagetype="notification" >
diff --git a/src/components/interfaces/QT_HMI_API.xml b/src/components/interfaces/QT_HMI_API.xml
index 2d53559ad1..72076ca198 100644
--- a/src/components/interfaces/QT_HMI_API.xml
+++ b/src/components/interfaces/QT_HMI_API.xml
@@ -191,6 +191,36 @@
<element name="SK-SK" internal_name="SK_SK">
<description>Slovak - Slovakia</description>
</element>
+ <element name="EN-IN" internal_name="EN_IN">
+ <description>English - India</description>
+ </element>
+ <element name="TH-TH" internal_name="TH_TH">
+ <description>Thai - Thailand</description>
+ </element>
+ <element name="EN-SA" internal_name="EN_SA">
+ <description>English - Middle East</description>
+ </element>
+ <element name="HE-IL" internal_name="HE_IL">
+ <description>Hebrew - Israel</description>
+ </element>
+ <element name="RO-RO" internal_name="RO_RO">
+ <description>Romanian - Romania</description>
+ </element>
+ <element name="UK-UA" internal_name="UK_UA">
+ <description>Ukrainian - Ukraine</description>
+ </element>
+ <element name="ID-ID" internal_name="ID_ID">
+ <description>Indonesian - Indonesia</description>
+ </element>
+ <element name="VI-VN" internal_name="VI_VN">
+ <description>Vietnamese - Vietnam</description>
+ </element>
+ <element name="MS-MY" internal_name="MS_MY">
+ <description>Malay - Malaysia</description>
+ </element>
+ <element name="HI-IN" internal_name="HI_IN">
+ <description>Hindi - India</description>
+ </element>
</enum>
<enum name="SoftButtonType">
<description>Contains information about the SoftButton capabilities.</description>
diff --git a/src/components/interfaces/v4_protocol_v1_2_no_extra.xml b/src/components/interfaces/v4_protocol_v1_2_no_extra.xml
index ead8596ee6..cc522d9f1c 100644
--- a/src/components/interfaces/v4_protocol_v1_2_no_extra.xml
+++ b/src/components/interfaces/v4_protocol_v1_2_no_extra.xml
@@ -326,16 +326,16 @@
</enum>
<struct name="Choice">
<description>A choice is an option given to the user, which can be selected either by menu, or through voice recognition system.</description>
- <param name="choiceID" type="Integer" minvalue="0" maxvalue="65535"/>
- <param name="menuName" type="String" maxlength="500"/>
- <param name="vrCommands" type="String" minsize="1" maxsize="100" maxlength="99" array="true"/>
+ <param name="choiceID" type="Integer" minvalue="0" maxvalue="65535" mandatory="true"/>
+ <param name="menuName" type="String" maxlength="500" mandatory="true"/>
+ <param name="vrCommands" type="String" minsize="1" maxsize="100" maxlength="99" array="true" mandatory="true"/>
</struct>
<struct name="SyncMsgVersion">
<description>Specifies the version number of the SYNC V4 protocol, that is supported by the mobile application</description>
- <param name="majorVersion" type="Integer" minvalue="1" maxvalue="1">
+ <param name="majorVersion" type="Integer" minvalue="1" maxvalue="1" mandatory="true">
<description>The major version indicates versions that is not-compatible to previous versions.</description>
</param>
- <param name="minorVersion" type="Integer" minvalue="0" maxvalue="1000">
+ <param name="minorVersion" type="Integer" minvalue="0" maxvalue="1000" mandatory="true">
<description>The minor version indicates a change to a previous version that should still allow to be run on an older version (with limited functionality)</description>
</param>
</struct>
@@ -349,53 +349,53 @@
</element>
</enum>
<struct name="StartTime">
- <param name="hours" type="Integer" minvalue="0" maxvalue="59">
+ <param name="hours" type="Integer" minvalue="0" maxvalue="59" mandatory="true">
<description>The hour of the media clock.</description>
<description>Some radios only support a max of 19 hours. If out of range, it will be rejected.</description>
</param>
- <param name="minutes" type="Integer" minvalue="0" maxvalue="59"/>
- <param name="seconds" type="Integer" minvalue="0" maxvalue="59"/>
+ <param name="minutes" type="Integer" minvalue="0" maxvalue="59" mandatory="true"/>
+ <param name="seconds" type="Integer" minvalue="0" maxvalue="59" mandatory="true"/>
</struct>
<struct name="TextField">
- <param name="name" type="TextFieldName">
+ <param name="name" type="TextFieldName" mandatory="true">
<description>The name that identifies the field. See TextFieldName.</description>
</param>
- <param name="characterSet" type="CharacterSet">
+ <param name="characterSet" type="CharacterSet" mandatory="true">
<description>The character set that is supported in this field. See CharacterSet.</description>
</param>
- <param name="width" type="Integer" minvalue="1" maxvalue="40">
+ <param name="width" type="Integer" minvalue="1" maxvalue="40" mandatory="true">
<description>The number of characters in one row of this field.</description>
</param>
- <param name="rows" type="Integer" minvalue="1" maxvalue="3">
+ <param name="rows" type="Integer" minvalue="1" maxvalue="3" mandatory="true">
<description>The number of rows of this field.</description>
</param>
</struct>
<struct name="DisplayCapabilities">
<description>Contains information about the display capabilities.</description>
- <param name="displayType" type="DisplayType">
+ <param name="displayType" type="DisplayType" mandatory="true">
<description>The type of the display. See DisplayType</description>
</param>
- <param name="textFields" type="TextField" minsize="1" maxsize="100" array="true">
+ <param name="textFields" type="TextField" minsize="1" maxsize="100" array="true" mandatory="true">
<description>A set of all fields that support text data. See TextField</description>
</param>
- <param name="mediaClockFormats" type="MediaClockFormat" minsize="1" maxsize="100" array="true">
+ <param name="mediaClockFormats" type="MediaClockFormat" minsize="1" maxsize="100" array="true" mandatory="true">
<description>A set of all supported formats of the media clock. See MediaClockFormat</description>
</param>
</struct>
<struct name="ButtonCapabilities">
<description>Contains information about a buttons capabilities.</description>
- <param name="name" type="ButtonName">
+ <param name="name" type="ButtonName" mandatory="true">
<description>The name of the button. See ButtonName.</description>
</param>
- <param name="shortPressAvailable" type="Boolean">
+ <param name="shortPressAvailable" type="Boolean" mandatory="true">
<description>The button supports a short press.</description>
<description>Whenever the button is pressed short, onButtonPressed( SHORT) will be invoked.</description>
</param>
- <param name="longPressAvailable" type="Boolean">
+ <param name="longPressAvailable" type="Boolean" mandatory="true">
<description>The button supports a LONG press.</description>
<description>Whenever the button is pressed long, onButtonPressed( LONG) will be invoked.</description>
</param>
- <param name="upDownAvailable" type="Boolean">
+ <param name="upDownAvailable" type="Boolean" mandatory="true">
<description>The button supports "button down" and "button up".</description>
<description>Whenever the button is pressed, onButtonEvent( DOWN) will be invoked.</description>
<description>Whenever the button is released, onButtonEvent( UP) will be invoked.</description>
@@ -413,17 +413,17 @@
<description>if position is greater or equal than the number of items on top level, the sub menu will be appended to the end.</description>
<description>If this param was omitted the entry will be added at the end.</description>
</param>
- <param name="menuName" type="String" maxlength="500">
+ <param name="menuName" type="String" maxlength="500" mandatory="true">
<description>Text to show in the menu for this sub menu.</description>
</param>
</struct>
<struct name="TTSChunk">
<description>A TTS chunk, that consists of the text/phonemes to speak and the type (like text or SAPI)</description>
- <param name="text" maxlength="500" type="String">
+ <param name="text" maxlength="500" type="String" mandatory="true">
<description>The text or phonemes to speak.</description>
<description>May not be empty.</description>
</param>
- <param name="type" type="SpeechCapabilities">
+ <param name="type" type="SpeechCapabilities" mandatory="true">
<description>Describes, whether it is text or a specific phoneme set. See SpeechCapabilities</description>
</param>
</struct>
@@ -431,10 +431,10 @@
<function name="RegisterAppInterface" messagetype="request">
<description>Establishes an interface with a mobile application.</description>
<description>Before registerAppInterface no other commands will be accepted/executed.</description>
- <param name="syncMsgVersion" type="SyncMsgVersion">
+ <param name="syncMsgVersion" type="SyncMsgVersion" mandatory="true">
<description>See SyncMsgVersion</description>
</param>
- <param name="appName" type="String" maxlength="100">
+ <param name="appName" type="String" maxlength="100" mandatory="true">
<description>The mobile application name, e.g. "Ford Drive Green".</description>
<description>Needs to be unique over all applications.</description>
<description>May not be empty.</description>
@@ -457,11 +457,11 @@
<description>If not provided, the default is equal to False"</description>
<description>Indicates if the mobile application wants to use vehicle data like GPS or speed.</description>
</param>
- <param name="isMediaApplication" type="Boolean">
+ <param name="isMediaApplication" type="Boolean" mandatory="true">
<description>Indicates if the application is a media or a non-media application.</description>
<description>Only media applications will be able to stream audio to Sync that is audible outside of the BT media source.</description>
</param>
- <param name="languageDesired" type="Language">
+ <param name="languageDesired" type="Language" mandatory="true">
<description>See Language</description>
<description>If the language doesn't match the active language on Sync, it will be rejected.</description>
<description>If the language is changed, while an app is registered, it will get disconnected.</description>
@@ -475,11 +475,11 @@
</function>
<function name="RegisterAppInterface" messagetype="response">
<description>The response to registerAppInterface</description>
- <param name="success" type="Boolean">
+ <param name="success" type="Boolean" mandatory="true">
<description>true, if successful</description>
<description>false, if failed</description>
</param>
- <param name="resultCode" type="Result">
+ <param name="resultCode" type="Result" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -527,11 +527,11 @@
<description>Will fail, if no registerAppInterface was completed successfully before.</description>
</function>
<function name="UnregisterAppInterface" messagetype="response">
- <param name="success" type="Boolean">
+ <param name="success" type="Boolean" mandatory="true">
<description>true, if successful</description>
<description>false, if failed</description>
</param>
- <param name="resultCode" type="Result">
+ <param name="resultCode" type="Result" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -559,11 +559,11 @@
<issue creator="rs">Do we want to add VR threshold params?</issue>
</function>
<function name="SetGlobalProperties" messagetype="response">
- <param name="success" type="Boolean">
+ <param name="success" type="Boolean" mandatory="true">
<description>true, if successful</description>
<description>false, if failed</description>
</param>
- <param name="resultCode" type="Result">
+ <param name="resultCode" type="Result" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -579,16 +579,16 @@
</function>
<function name="ResetGlobalProperties" messagetype="request">
<description>Allows resetting global properties.</description>
- <param name="properties" type="GlobalProperty" minsize="1" maxsize="100" array="true">
+ <param name="properties" type="GlobalProperty" minsize="1" maxsize="100" array="true" mandatory="true">
<description>Contains the names of all global properties (like timeoutPrompt) that should be unset. Resetting means, that they have the same value as at start up (default)</description>
</param>
</function>
<function name="ResetGlobalProperties" messagetype="response">
- <param name="success" type="Boolean">
+ <param name="success" type="Boolean" mandatory="true">
<description>true, if successful</description>
<description>false, if failed</description>
</param>
- <param name="resultCode" type="Result">
+ <param name="resultCode" type="Result" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -605,7 +605,7 @@
<function name="AddCommand" messagetype="request">
<description>Adds a command to the in application menu.</description>
<description>Either menuParams or vrCommands must be provided.</description>
- <param name="cmdID" type="Integer" minvalue="0" maxvalue="2000000000">
+ <param name="cmdID" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="true">
<description>unique ID of the command to add.</description>
</param>
<param name="menuParams" type="MenuParams" mandatory="false">
@@ -617,11 +617,11 @@
</param>
</function>
<function name="AddCommand" messagetype="response">
- <param name="success" type="Boolean">
+ <param name="success" type="Boolean" mandatory="true">
<description>true, if successful</description>
<description>false, if failed</description>
</param>
- <param name="resultCode" type="Result">
+ <param name="resultCode" type="Result" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -639,16 +639,16 @@
</function>
<function name="DeleteCommand" messagetype="request">
<description>Deletes all commands from the in-application menu with the specified command id.</description>
- <param name="cmdID" type="Integer" minvalue="0" maxvalue="2000000000">
+ <param name="cmdID" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="true">
<description>ID of the command(s) to delete.</description>
</param>
</function>
<function name="DeleteCommand" messagetype="response">
- <param name="success" type="Boolean">
+ <param name="success" type="Boolean" mandatory="true">
<description>true, if successful</description>
<description>false, if failed</description>
</param>
- <param name="resultCode" type="Result">
+ <param name="resultCode" type="Result" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -666,7 +666,7 @@
</function>
<function name="AddSubMenu" messagetype="request">
<description>Adds a sub menu to the in-application menu.</description>
- <param name="menuID" type="Integer" minvalue="0" maxvalue="2000000000">
+ <param name="menuID" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="true">
<description>unique ID of the sub menu to add.</description>
</param>
<param name="position" type="Integer" minvalue="0" maxvalue="1000" mandatory="false">
@@ -677,16 +677,16 @@
<description>Position of any submenu will always be located before the return and exit options</description>
<description>If this param was omitted the entry will be added at the end.</description>
</param>
- <param name="menuName" maxlength="500" type="String">
+ <param name="menuName" maxlength="500" type="String" mandatory="true">
<description>Text to show in the menu for this sub menu.</description>
</param>
</function>
<function name="AddSubMenu" messagetype="response">
- <param name="success" type="Boolean">
+ <param name="success" type="Boolean" mandatory="true">
<description>true, if successful</description>
<description>false, if failed</description>
</param>
- <param name="resultCode" type="Result">
+ <param name="resultCode" type="Result" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -704,16 +704,16 @@
</function>
<function name="DeleteSubMenu" messagetype="request">
<description>Deletes a submenu from the in-application menu.</description>
- <param name="menuID" type="Integer" minvalue="0" maxvalue="2000000000">
+ <param name="menuID" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="true">
<description>The "menuID" of the submenu to delete. (See addSubMenu.menuID)</description>
</param>
</function>
<function name="DeleteSubMenu" messagetype="response">
- <param name="success" type="Boolean">
+ <param name="success" type="Boolean" mandatory="true">
<description>true, if successful</description>
<description>false, if failed</description>
</param>
- <param name="resultCode" type="Result">
+ <param name="resultCode" type="Result" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -731,17 +731,17 @@
</function>
<function name="CreateInteractionChoiceSet" messagetype="request">
<description>creates interaction choice set to be used later by performInteraction</description>
- <param name="interactionChoiceSetID" type="Integer" minvalue="0" maxvalue="2000000000">
+ <param name="interactionChoiceSetID" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="true">
<description>Unique ID used for this interaction choice set.</description>
</param>
- <param name="choiceSet" type="Choice" minsize="1" maxsize="100" array="true"/>
+ <param name="choiceSet" type="Choice" minsize="1" maxsize="100" array="true" mandatory="true"/>
</function>
<function name="CreateInteractionChoiceSet" messagetype="response">
- <param name="success" type="Boolean">
+ <param name="success" type="Boolean" mandatory="true">
<description>true, if successful</description>
<description>false, if failed</description>
</param>
- <param name="resultCode" type="Result">
+ <param name="resultCode" type="Result" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -759,18 +759,18 @@
</function>
<function name="PerformInteraction" messagetype="request">
<description>Triggers an interaction (e.g. "Permit GPS?" - Yes, no, Always Allow).</description>
- <param name="initialText" type="String" maxlength="500">
+ <param name="initialText" type="String" maxlength="500" mandatory="true">
<description>Text to be displayed first.</description>
</param>
- <param name="initialPrompt" type="TTSChunk" minsize="1" maxsize="100" array="true">
+ <param name="initialPrompt" type="TTSChunk" minsize="1" maxsize="100" array="true" mandatory="true">
<description>This is the intial prompt spoken to the user at the start of an interaction</description>
<description>An array of text chunks of type TTSChunk. See TTSChunk</description>
<description>The array must have at least one item</description>
</param>
- <param name="interactionMode" type="InteractionMode">
+ <param name="interactionMode" type="InteractionMode" mandatory="true">
<description>See InteractionMode.</description>
</param>
- <param name="interactionChoiceSetIDList" type="Integer" minsize="1" maxsize="100" minvalue="0" maxvalue="2000000000" array="true">
+ <param name="interactionChoiceSetIDList" type="Integer" minsize="1" maxsize="100" minvalue="0" maxvalue="2000000000" array="true" mandatory="true">
<description>List of interaction choice set IDs to use with an interaction.</description>
</param>
<param name="helpPrompt" type="TTSChunk" minsize="1" maxsize="100" array="true" mandatory="false">
@@ -789,11 +789,11 @@
</param>
</function>
<function name="PerformInteraction" messagetype="response">
- <param name="success" type="Boolean">
+ <param name="success" type="Boolean" mandatory="true">
<description>true, if successful</description>
<description>false, if failed</description>
</param>
- <param name="resultCode" type="Result">
+ <param name="resultCode" type="Result" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -819,16 +819,16 @@
<function name="DeleteInteractionChoiceSet" messagetype="request">
<description>Deletes interaction choice set that has been created with "CreateInteractionChoiceSet".</description>
<description>The interaction may only be deleted when not currently in use by a "performInteraction".</description>
- <param name="interactionChoiceSetID" type="Integer" minvalue="0" maxvalue="2000000000">
+ <param name="interactionChoiceSetID" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="true">
<description>ID of the interaction choice set to delete.</description>
</param>
</function>
<function name="DeleteInteractionChoiceSet" messagetype="response">
- <param name="success" type="Boolean">
+ <param name="success" type="Boolean" mandatory="true">
<description>true, if successful</description>
<description>false, if failed</description>
</param>
- <param name="resultCode" type="Result">
+ <param name="resultCode" type="Result" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -867,11 +867,11 @@
</param>
</function>
<function name="Alert" messagetype="response">
- <param name="success" type="Boolean">
+ <param name="success" type="Boolean" mandatory="true">
<description>true, if successful</description>
<description>false, if failed</description>
</param>
- <param name="resultCode" type="Result">
+ <param name="resultCode" type="Result" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -917,11 +917,11 @@
</param>
</function>
<function name="Show" messagetype="response">
- <param name="success" type="Boolean">
+ <param name="success" type="Boolean" mandatory="true">
<description>true, if successful</description>
<description>false, if failed</description>
</param>
- <param name="resultCode" type="Result">
+ <param name="resultCode" type="Result" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -937,17 +937,17 @@
</function>
<function name="Speak" messagetype="request">
<description>Speaks a text.</description>
- <param name="ttsChunks" type="TTSChunk" minsize="1" maxsize="100" array="true">
+ <param name="ttsChunks" type="TTSChunk" minsize="1" maxsize="100" array="true" mandatory="true">
<description>An array of text chunks of type TTSChunk. See TTSChunk</description>
<description>The array must have at least one item</description>
</param>
</function>
<function name="Speak" messagetype="response">
- <param name="success" type="Boolean">
+ <param name="success" type="Boolean" mandatory="true">
<description>true, if successful</description>
<description>false, if failed</description>
</param>
- <param name="resultCode" type="Result">
+ <param name="resultCode" type="Result" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -969,17 +969,17 @@
<description>startTime must be provided for "run"</description>
<description>startTime will be ignored for "pause" and "resum"</description>
</param>
- <param name="updateMode" type="UpdateMode">
+ <param name="updateMode" type="UpdateMode" mandatory="true">
<description>Enumeration to control the media clock.</description>
<description>In case of pause or resume, the start time value is ignored and shall be left out. For resume, the time continues with the same value as it was when paused.</description>
</param>
</function>
<function name="SetMediaClockTimer" messagetype="response">
- <param name="success" type="Boolean">
+ <param name="success" type="Boolean" mandatory="true">
<description>true, if successful</description>
<description>false, if failed</description>
</param>
- <param name="resultCode" type="Result">
+ <param name="resultCode" type="Result" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -1002,11 +1002,11 @@
</param>
</function>
<function name="EncodedSyncPData" messagetype="response">
- <param name="success" type="Boolean">
+ <param name="success" type="Boolean" mandatory="true">
<description>true, if successful</description>
<description>false, if failed</description>
</param>
- <param name="resultCode" type="Result">
+ <param name="resultCode" type="Result" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -1024,16 +1024,16 @@
<description>Subscribes to built-in HMI buttons.</description>
<description>The application will be notified by the OnButtonEvent and OnButtonPress.</description>
<description>To unsubscribe the notifications, use unsubscribeButton.</description>
- <param name="buttonName" type="ButtonName">
+ <param name="buttonName" type="ButtonName" mandatory="true">
<description>Name of the button to subscribe.</description>
</param>
</function>
<function name="SubscribeButton" messagetype="response">
- <param name="success" type="Boolean">
+ <param name="success" type="Boolean" mandatory="true">
<description>true, if successful</description>
<description>false, if failed</description>
</param>
- <param name="resultCode" type="Result">
+ <param name="resultCode" type="Result" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -1051,16 +1051,16 @@
</function>
<function name="UnsubscribeButton" messagetype="request">
<description>Unsubscribes from built-in HMI buttons.</description>
- <param name="buttonName" type="ButtonName">
+ <param name="buttonName" type="ButtonName" mandatory="true">
<description>Name of the button to unsubscribe.</description>
</param>
</function>
<function name="UnsubscribeButton" messagetype="response">
- <param name="success" type="Boolean">
+ <param name="success" type="Boolean" mandatory="true">
<description>true, if successful</description>
<description>false, if failed</description>
</param>
- <param name="resultCode" type="Result">
+ <param name="resultCode" type="Result" mandatory="true">
<description>See Result</description>
<element name="SUCCESS"/>
<element name="INVALID_DATA"/>
@@ -1079,11 +1079,11 @@
<function name="GenericResponse" messagetype="response">
<description>Generic Response is sent, when the name of a received msg cannot be retrieved. Only used in case of an error.</description>
<description>Currently, only resultCode INVALID_DATA is used.</description>
- <param name="success" type="Boolean">
+ <param name="success" type="Boolean" mandatory="true">
<description>true, if successful</description>
<description>false, if failed</description>
</param>
- <param name="resultCode" type="Result">
+ <param name="resultCode" type="Result" mandatory="true">
<description>See Result</description>
<element name="INVALID_DATA"/>
</param>
@@ -1093,40 +1093,40 @@
</function>
<!-- Notifications -->
<function name="OnHMIStatus" messagetype="notification">
- <param name="hmiLevel" type="HMILevel">
+ <param name="hmiLevel" type="HMILevel" mandatory="true">
<description>See HMILevel</description>
</param>
- <param name="audioStreamingState" type="AudioStreamingState">
+ <param name="audioStreamingState" type="AudioStreamingState" mandatory="true">
<description>See AudioStreamingState</description>
</param>
- <param name="systemContext" type="SystemContext">
+ <param name="systemContext" type="SystemContext" mandatory="true">
<description>See SystemContext</description>
</param>
</function>
<function name="OnAppInterfaceUnregistered" messagetype="notification">
- <param name="reason" type="AppInterfaceUnregisteredReason">
+ <param name="reason" type="AppInterfaceUnregisteredReason" mandatory="true">
<description>See AppInterfaceUnregisteredReason</description>
</param>
</function>
<function name="OnButtonEvent" messagetype="notification">
<description>Notifies application of UP/DOWN events for buttons to which the application is subscribed.</description>
- <param name="buttonName" type="ButtonName"/>
- <param name="buttonEventMode" type="ButtonEventMode">
+ <param name="buttonName" type="ButtonName" mandatory="true"/>
+ <param name="buttonEventMode" type="ButtonEventMode" mandatory="true">
<description>Indicates whether this is an UP or DOWN event.</description>
</param>
</function>
<function name="OnButtonPress" messagetype="notification">
<description>Notifies application of LONG/SHORT press events for buttons to which the application is subscribed.</description>
- <param name="buttonName" type="ButtonName"/>
- <param name="buttonPressMode" type="ButtonPressMode">
+ <param name="buttonName" type="ButtonName" mandatory="true"/>
+ <param name="buttonPressMode" type="ButtonPressMode" mandatory="true">
<description>Indicates whether this is a LONG or SHORT button press event.</description>
</param>
</function>
<function name="OnCommand" messagetype="notification">
- <param name="cmdID" type="Integer" minvalue="0" maxvalue="2000000000">
+ <param name="cmdID" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="true">
<description>Command ID, which is related to a specific menu entry.</description>
</param>
- <param name="triggerSource" type="TriggerSource">
+ <param name="triggerSource" type="TriggerSource" mandatory="true">
<description>See TriggerSource</description>
</param>
</function>
@@ -1138,13 +1138,13 @@
</function>
<function name="OnTBTClientState" messagetype="notification">
<description>Provides applications with notifications specific to the current TBT client status on the module</description>
- <param name="state" type="TBTState">
+ <param name="state" type="TBTState" mandatory="true">
<description>Current State of TBT client</description>
</param>
</function>
<function name="OnDriverDistraction" messagetype="notification">
<description>Provides driver distraction state to mobile applications</description>
- <param name="state" type="DriverDistractionState">
+ <param name="state" type="DriverDistractionState" mandatory="true">
<description>Current State of Driver Distraction</description>
</param>
</function>
diff --git a/src/components/media_manager/CMakeLists.txt b/src/components/media_manager/CMakeLists.txt
index c5b94ea7e1..4913102c9c 100644
--- a/src/components/media_manager/CMakeLists.txt
+++ b/src/components/media_manager/CMakeLists.txt
@@ -32,17 +32,20 @@ include(${CMAKE_SOURCE_DIR}/tools/cmake/helpers/platform.cmake)
include(${CMAKE_SOURCE_DIR}/tools/cmake/helpers/sources.cmake)
include_directories(
- include
+ ${COMPONENTS_DIR}/media_manager/include/
${COMPONENTS_DIR}/media_manager/include/audio/
${COMPONENTS_DIR}/media_manager/include/video/
+ ${COMPONENTS_DIR}/remote_control/include/
${COMPONENTS_DIR}/utils/include/
${COMPONENTS_DIR}/protocol_handler/include/
${COMPONENTS_DIR}/connection_handler/include/
${COMPONENTS_DIR}/application_manager/include/
${COMPONENTS_DIR}/smart_objects/include/
+ ${COMPONENTS_DIR}/policy/include/
+ ${COMPONENTS_DIR}/rpc_base/include/
+ ${COMPONENTS_DIR}/functional_module/include/
${COMPONENTS_DIR}/hmi_message_handler/include/
${COMPONENTS_DIR}/formatters/include/
- ${COMPONENTS_DIR}/rpc_base/include/
${COMPONENTS_DIR}/config_profile/include/
${JSONCPP_INCLUDE_DIRECTORY}
${CMAKE_BINARY_DIR}/src/components/
diff --git a/src/components/media_manager/include/media_manager/media_manager_impl.h b/src/components/media_manager/include/media_manager/media_manager_impl.h
index c84a5a884f..7fbd4f2f6f 100644
--- a/src/components/media_manager/include/media_manager/media_manager_impl.h
+++ b/src/components/media_manager/include/media_manager/media_manager_impl.h
@@ -86,9 +86,10 @@ class MediaManagerImpl : public MediaManager,
void set_mock_mic_listener(MediaListenerPtr media_listener);
void set_mock_mic_recorder(MediaAdapterImpl* media_adapter);
void set_mock_streamer(protocol_handler::ServiceType stype,
- MediaAdapterImpl* mock_stream);
- void set_mock_streamer_listener(protocol_handler::ServiceType stype,
- MediaAdapterListener* mock_stream);
+ ::utils::SharedPtr<MediaAdapterImpl> mock_stream);
+ void set_mock_streamer_listener(
+ protocol_handler::ServiceType stype,
+ ::utils::SharedPtr<MediaAdapterListener> mock_stream);
#endif // BUILD_TESTS
protected:
diff --git a/src/components/media_manager/src/audio/audio_stream_sender_thread.cc b/src/components/media_manager/src/audio/audio_stream_sender_thread.cc
index 7c18cb400b..9b0057dfe8 100644
--- a/src/components/media_manager/src/audio/audio_stream_sender_thread.cc
+++ b/src/components/media_manager/src/audio/audio_stream_sender_thread.cc
@@ -67,6 +67,7 @@ AudioStreamSenderThread::AudioStreamSenderThread(
application_manager::ApplicationManager& app_mngr)
: session_key_(session_key)
, fileName_(fileName)
+ , offset_(0)
, shouldBeStoped_(false)
, shouldBeStoped_lock_()
, shouldBeStoped_cv_()
diff --git a/src/components/media_manager/src/audio/from_mic_recorder_listener.cc b/src/components/media_manager/src/audio/from_mic_recorder_listener.cc
index a02ec17f90..647db1e1a3 100644
--- a/src/components/media_manager/src/audio/from_mic_recorder_listener.cc
+++ b/src/components/media_manager/src/audio/from_mic_recorder_listener.cc
@@ -42,7 +42,10 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "MediaManager")
FromMicRecorderListener::FromMicRecorderListener(
const std::string& file_name,
application_manager::ApplicationManager& app_mngr)
- : reader_(NULL), file_name_(file_name), application_manager_(app_mngr) {}
+ : reader_(NULL)
+ , file_name_(file_name)
+ , current_application_(0)
+ , application_manager_(app_mngr) {}
FromMicRecorderListener::~FromMicRecorderListener() {
LOG4CXX_AUTO_TRACE(logger_);
diff --git a/src/components/media_manager/src/media_manager_impl.cc b/src/components/media_manager/src/media_manager_impl.cc
index b89fc4c71f..6a9ded9029 100644
--- a/src/components/media_manager/src/media_manager_impl.cc
+++ b/src/components/media_manager/src/media_manager_impl.cc
@@ -96,13 +96,15 @@ void MediaManagerImpl::set_mock_mic_recorder(MediaAdapterImpl* media_adapter) {
#endif // EXTENDED_MEDIA_MODE
-void MediaManagerImpl::set_mock_streamer(protocol_handler::ServiceType stype,
- MediaAdapterImpl* mock_stream) {
+void MediaManagerImpl::set_mock_streamer(
+ protocol_handler::ServiceType stype,
+ ::utils::SharedPtr<MediaAdapterImpl> mock_stream) {
streamer_[stype] = mock_stream;
}
void MediaManagerImpl::set_mock_streamer_listener(
- protocol_handler::ServiceType stype, MediaAdapterListener* mock_stream) {
+ protocol_handler::ServiceType stype,
+ ::utils::SharedPtr<MediaAdapterListener> mock_stream) {
streamer_listener_[stype] = mock_stream;
}
diff --git a/src/components/media_manager/test/media_manager_impl_test.cc b/src/components/media_manager/test/media_manager_impl_test.cc
index f9618c7fb8..7d0226fa67 100644
--- a/src/components/media_manager/test/media_manager_impl_test.cc
+++ b/src/components/media_manager/test/media_manager_impl_test.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Ford Motor Company
+ * Copyright (c) 2017, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -33,147 +33,376 @@
#include "gmock/gmock.h"
#include "media_manager/media_manager_impl.h"
#include "media_manager/mock_media_adapter.h"
-#include "media_manager/mock_media_adapter_listener.h"
#include "media_manager/mock_media_adapter_impl.h"
-#include "protocol_handler/mock_protocol_handler.h"
+#include "media_manager/mock_media_adapter_listener.h"
#include "media_manager/mock_media_manager_settings.h"
-#include "application_manager/mock_application_manager.h"
-#include "utils/shared_ptr.h"
-#include "utils/make_shared.h"
#include "application_manager/event_engine/event_dispatcher.h"
-#include "application_manager/state_controller.h"
+#include "application_manager/message.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/mock_application_manager.h"
#include "application_manager/resumption/resume_ctrl.h"
-#include "resumption/last_state.h"
+#include "application_manager/state_controller.h"
+#include "protocol_handler/mock_protocol_handler.h"
+#include "protocol/common.h"
+#include "utils/make_shared.h"
+#include "utils/shared_ptr.h"
+#include "utils/file_system.h"
+#include "utils/scope_guard.h"
namespace test {
namespace components {
namespace media_manager_test {
+using namespace file_system;
+using namespace ::media_manager;
using ::testing::_;
+using ::testing::Return;
using ::testing::ReturnRef;
-using protocol_handler::ServiceType;
+using ::utils::SharedPtr;
+using ::utils::ScopeGuard;
+using ::utils::MakeGuard;
+using ::testing::NiceMock;
+using ::protocol_handler::ServiceType;
+using ::protocol_handler::RawMessagePtr;
+using application_manager::ApplicationSharedPtr;
+using application_manager::BinaryData;
+
+namespace {
+const uint16_t kVideoStreamingPort = 8901u;
+const uint16_t kAudioStreamingPort = 8000u;
+const int32_t kApplicationKey = 1;
+const int32_t kDuration = 1000;
+const std::string kStorageFolder = "test_storage_folder";
+const std::string kOutputFile = "test_output_file";
+const std::string kResourceFolder = "test_resource_folder";
+const std::string kRecordingFileSource = "test_recording_file_source";
+const std::string kNamedVideoPipePath = "named_video_pipe_path";
+const std::string kNamedAudioPipePath = "named_audio_pipe_path";
+const std::string kVideoStreamFile = "video_stream_file";
+const std::string kAudioStreamFile = "audio_stream_file";
+const std::string kServerAddress = "server_address";
+const std::string kSocketValue = "socket";
+const std::string kPipeValue = "pipe";
+const std::string kFileValue = "file";
+const std::string kDefaultValue = "";
+const std::string kOutputFilePath = kStorageFolder + "/" + kOutputFile;
+const uint32_t kProtocolVersion = ::protocol_handler::PROTOCOL_VERSION_2;
+const uint32_t kConnectionKey = 1u;
+
+void dealloc_data(uint8_t* data) {
+ delete[] data;
+}
+
+void dealloc_file(std::ofstream* test_file) {
+ delete test_file;
+}
+} // namespace
+
+typedef NiceMock<application_manager_test::MockApplication> MockApp;
+typedef SharedPtr<MockApp> MockAppPtr;
+typedef SharedPtr<MockMediaAdapterImpl> MockMediaAdapterImplPtr;
class MediaManagerImplTest : public ::testing::Test {
+ public:
+ // media_adapter_mock_ will be deleted in media_manager_impl (dtor)
+ MediaManagerImplTest() : media_adapter_mock_(new MockMediaAdapter()) {
+ media_adapter_listener_mock_ =
+ utils::MakeShared<MockMediaAdapterListener>();
+ ON_CALL(mock_media_manager_settings_, video_server_type())
+ .WillByDefault(ReturnRef(kDefaultValue));
+ ON_CALL(mock_media_manager_settings_, audio_server_type())
+ .WillByDefault(ReturnRef(kDefaultValue));
+ mock_app_ = ::utils::MakeShared<MockApp>();
+ media_manager_impl_.reset(
+ new MediaManagerImpl(app_mngr_, mock_media_manager_settings_));
+ }
+
protected:
+ void StartMicrophoneCheckHelper() {
+ EXPECT_CALL(app_mngr_, application(kApplicationKey))
+ .WillOnce(Return(mock_app_));
+ EXPECT_CALL(mock_media_manager_settings_, app_storage_folder())
+ .WillOnce(ReturnRef(kStorageFolder));
+ EXPECT_CALL(mock_media_manager_settings_, app_resource_folder())
+ .WillOnce(ReturnRef(kResourceFolder));
+ EXPECT_CALL(mock_media_manager_settings_, recording_file_source())
+ .WillOnce(ReturnRef(kRecordingFileSource));
+ }
+
+ void InitMediaManagerPrecondition(const std::string& server_type) {
+ EXPECT_CALL(mock_media_manager_settings_, video_server_type())
+ .WillRepeatedly(ReturnRef(server_type));
+ EXPECT_CALL(mock_media_manager_settings_, audio_server_type())
+ .WillRepeatedly(ReturnRef(server_type));
+ }
+
+ void InitMediaManagerSocketServerType() {
+ InitMediaManagerPrecondition(kSocketValue);
+ EXPECT_CALL(mock_media_manager_settings_, server_address())
+ .WillRepeatedly(ReturnRef(kServerAddress));
+ EXPECT_CALL(mock_media_manager_settings_, video_streaming_port())
+ .WillOnce(Return(kVideoStreamingPort));
+ EXPECT_CALL(mock_media_manager_settings_, audio_streaming_port())
+ .WillOnce(Return(kAudioStreamingPort));
+ media_manager_impl_.reset(
+ new MediaManagerImpl(app_mngr_, mock_media_manager_settings_));
+ }
+
+ void InitMediaManagerPipeServerType() {
+ InitMediaManagerPrecondition(kPipeValue);
+ EXPECT_CALL(mock_media_manager_settings_, named_video_pipe_path())
+ .WillOnce(ReturnRef(kNamedAudioPipePath));
+ EXPECT_CALL(mock_media_manager_settings_, named_audio_pipe_path())
+ .WillOnce(ReturnRef(kNamedAudioPipePath));
+ EXPECT_CALL(mock_media_manager_settings_, app_storage_folder())
+ .WillRepeatedly(ReturnRef(kStorageFolder));
+ media_manager_impl_.reset(
+ new MediaManagerImpl(app_mngr_, mock_media_manager_settings_));
+ }
+
+ void InitMediaManagerFileServerType() {
+ InitMediaManagerPrecondition(kFileValue);
+ EXPECT_CALL(mock_media_manager_settings_, video_stream_file())
+ .WillOnce(ReturnRef(kVideoStreamFile));
+ EXPECT_CALL(mock_media_manager_settings_, audio_stream_file())
+ .WillOnce(ReturnRef(kAudioStreamFile));
+ EXPECT_CALL(mock_media_manager_settings_, app_storage_folder())
+ .WillRepeatedly(ReturnRef(kStorageFolder));
+ media_manager_impl_.reset(
+ new MediaManagerImpl(app_mngr_, mock_media_manager_settings_));
+ }
+
+ void ReceivedMessage(const ServiceType service_type) {
+ EXPECT_CALL(app_mngr_, CanAppStream(kConnectionKey, service_type))
+ .WillOnce(Return(true));
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app_));
+ EXPECT_CALL(*mock_app_, WakeUpStreaming(service_type));
+ MockMediaAdapterImplPtr mock_media_streamer =
+ utils::MakeShared<MockMediaAdapterImpl>();
+ media_manager_impl_->set_mock_streamer(service_type, mock_media_streamer);
+ media_manager_impl_->set_mock_streamer_listener(
+ service_type, media_adapter_listener_mock_);
+ EXPECT_CALL(*mock_media_streamer, SendData(kConnectionKey, _));
+ EmulateMobileMessage(service_type);
+ }
+
+ void EmulateMobileMessage(const ServiceType serviceType) {
+ const uint32_t data_sending_size = 3u;
+ unsigned char data_sending[data_sending_size] = {0x20, 0x07, 0x01};
+ const RawMessagePtr raw_message_ptr(
+ new ::protocol_handler::RawMessage(kConnectionKey,
+ kProtocolVersion,
+ data_sending,
+ data_sending_size,
+ serviceType));
+ media_manager_impl_->OnMessageReceived(raw_message_ptr);
+ media_manager_impl_->OnMobileMessageSent(raw_message_ptr);
+ }
+
+ application_manager_test::MockApplicationManager app_mngr_;
+ MockAppPtr mock_app_;
+ SharedPtr<MockMediaAdapterListener> media_adapter_listener_mock_;
+ MockMediaAdapter* media_adapter_mock_;
const ::testing::NiceMock<MockMediaManagerSettings>
mock_media_manager_settings_;
- const std::string kDefaultValue_ = "";
+ SharedPtr<MediaManagerImpl> media_manager_impl_;
};
-TEST_F(MediaManagerImplTest, PlayA2DPSource) {
- MockMediaAdapter* media_mock_ = new MockMediaAdapter();
+TEST_F(MediaManagerImplTest,
+ OnMessageReceived_WithUnsupportedServiceType_Cancelled) {
+ EXPECT_CALL(app_mngr_, CanAppStream(_, _)).Times(0);
+ EXPECT_CALL(app_mngr_, application(_)).Times(0);
+ EmulateMobileMessage(ServiceType::kInvalidServiceType);
+}
- application_manager_test::MockApplicationManager mock_application_manager;
+TEST_F(MediaManagerImplTest,
+ OnMessageReceived_WithAudioServiceType_ApplicationNotFound_Cancelled) {
+ const ServiceType audio_type = ServiceType::kAudio;
+ EXPECT_CALL(app_mngr_, CanAppStream(kConnectionKey, audio_type))
+ .WillOnce(Return(true));
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(ApplicationSharedPtr()));
+ EmulateMobileMessage(audio_type);
+}
- ON_CALL(mock_media_manager_settings_, video_server_type())
- .WillByDefault(ReturnRef(kDefaultValue_));
- ON_CALL(mock_media_manager_settings_, audio_server_type())
- .WillByDefault(ReturnRef(kDefaultValue_));
- MediaManagerImpl mediaManagerImpl(mock_application_manager,
- mock_media_manager_settings_);
- int32_t application_key = 1;
+TEST_F(MediaManagerImplTest,
+ OnMessageReceived_WithVideoServiceType_ApplicationNotFound_Cancelled) {
+ const ServiceType video_type = ServiceType::kMobileNav;
+ EXPECT_CALL(app_mngr_, CanAppStream(kConnectionKey, video_type))
+ .WillOnce(Return(true));
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(ApplicationSharedPtr()));
+ EmulateMobileMessage(video_type);
+}
- mediaManagerImpl.set_mock_a2dp_player(media_mock_);
- EXPECT_CALL(*media_mock_, StartActivity(application_key));
- mediaManagerImpl.PlayA2DPSource(application_key);
+TEST_F(MediaManagerImplTest,
+ OnMessageReceived_WithAudioServiceType_ForbidStreaming_Cancelled) {
+ const ServiceType audio_type = ServiceType::kAudio;
+ EXPECT_CALL(app_mngr_, CanAppStream(kConnectionKey, audio_type))
+ .WillOnce(Return(false));
+ EXPECT_CALL(app_mngr_, ForbidStreaming(kConnectionKey));
+ EmulateMobileMessage(audio_type);
}
-TEST_F(MediaManagerImplTest, StopA2DPSource) {
- MockMediaAdapter* media_mock_ = new MockMediaAdapter();
- application_manager_test::MockApplicationManager mock_application_manager;
+TEST_F(MediaManagerImplTest,
+ OnMessageReceived_WithVideoServiceType_ForbidStreaming_Cancelled) {
+ const ServiceType video_type = ServiceType::kMobileNav;
+ EXPECT_CALL(app_mngr_, CanAppStream(kConnectionKey, video_type))
+ .WillOnce(Return(false));
+ EXPECT_CALL(app_mngr_, ForbidStreaming(kConnectionKey));
+ EmulateMobileMessage(video_type);
+}
- ON_CALL(mock_media_manager_settings_, video_server_type())
- .WillByDefault(ReturnRef(kDefaultValue_));
- ON_CALL(mock_media_manager_settings_, audio_server_type())
- .WillByDefault(ReturnRef(kDefaultValue_));
- MediaManagerImpl mediaManagerImpl(mock_application_manager,
- mock_media_manager_settings_);
- int32_t application_key = 1;
+TEST_F(MediaManagerImplTest, OnMessageReceived_WithAudioServiceType_SUCCESS) {
+ ReceivedMessage(ServiceType::kAudio);
+}
- mediaManagerImpl.set_mock_a2dp_player(media_mock_);
- EXPECT_CALL(*media_mock_, StopActivity(application_key));
- mediaManagerImpl.StopA2DPSource(application_key);
+TEST_F(MediaManagerImplTest, OnMessageReceived_WithVideoServiceType_SUCCESS) {
+ ReceivedMessage(ServiceType::kMobileNav);
}
-TEST_F(MediaManagerImplTest, StopMicrophoneRecording) {
- MockMediaAdapterListener* media_adapter_listener_mock_ =
- new MockMediaAdapterListener();
- application_manager_test::MockApplicationManager mock_application_manager;
+TEST_F(MediaManagerImplTest, Init_Settings_ExpectSocketValue) {
+ InitMediaManagerSocketServerType();
+}
- ON_CALL(mock_media_manager_settings_, video_server_type())
- .WillByDefault(ReturnRef(kDefaultValue_));
- ON_CALL(mock_media_manager_settings_, audio_server_type())
- .WillByDefault(ReturnRef(kDefaultValue_));
- MediaManagerImpl mediaManagerImpl(mock_application_manager,
- mock_media_manager_settings_);
- int32_t application_key = 1;
+TEST_F(MediaManagerImplTest, Init_Settings_ExpectPipeValue) {
+ InitMediaManagerPipeServerType();
+}
+
+TEST_F(MediaManagerImplTest, Init_Settings_ExpectFileValue) {
+ InitMediaManagerFileServerType();
+}
+
+TEST_F(MediaManagerImplTest, PlayA2DPSource_WithCorrectA2DP_SUCCESS) {
+ media_manager_impl_->set_mock_a2dp_player(media_adapter_mock_);
+ EXPECT_CALL(*media_adapter_mock_, StartActivity(kApplicationKey));
+ media_manager_impl_->PlayA2DPSource(kApplicationKey);
+}
+
+TEST_F(MediaManagerImplTest, StopA2DPSource_WithCorrectA2DP_SUCCESS) {
+ media_manager_impl_->set_mock_a2dp_player(media_adapter_mock_);
+ EXPECT_CALL(*media_adapter_mock_, StopActivity(kApplicationKey));
+ media_manager_impl_->StopA2DPSource(kApplicationKey);
+}
+
+TEST_F(MediaManagerImplTest,
+ StartMicrophoneRecording_SourceFileIsWritable_ExpectTrue) {
+ StartMicrophoneCheckHelper();
+ if (!DirectoryExists(kStorageFolder)) {
+ CreateDirectory(kStorageFolder);
+ }
+ EXPECT_FALSE(FileExists(kOutputFilePath));
+ EXPECT_TRUE(CreateFile(kOutputFilePath));
- mediaManagerImpl.set_mock_mic_listener(media_adapter_listener_mock_);
+ const std::string record_file_path =
+ kResourceFolder + "/" + kRecordingFileSource;
+ if (!DirectoryExists(kResourceFolder)) {
+ CreateDirectory(kResourceFolder);
+ }
+ EXPECT_FALSE(FileExists(record_file_path));
+ EXPECT_TRUE(CreateFile(record_file_path));
+ std::ofstream* test_file = Open(record_file_path);
+ ScopeGuard file_guard = MakeGuard(dealloc_file, test_file);
+ UNUSED(file_guard);
+ EXPECT_TRUE(test_file->is_open());
+ const uint32_t data_size = 4u;
+ uint8_t* data = new uint8_t[data_size];
+ ScopeGuard data_guard = MakeGuard(dealloc_data, data);
+ UNUSED(data_guard);
+ for (uint32_t i = 0u; i < data_size; ++i) {
+ data[i] = i;
+ }
+ EXPECT_TRUE(Write(test_file, data, data_size));
+ Close(test_file);
+ EXPECT_FALSE(test_file->is_open());
+ BinaryData result;
+ EXPECT_TRUE(ReadBinaryFile(record_file_path, result));
+ EXPECT_FALSE(result.empty());
+ for (uint32_t i = 0u; i < data_size; ++i) {
+ EXPECT_EQ(data[i], result[i]);
+ }
+ media_manager_impl_->StartMicrophoneRecording(
+ kApplicationKey, kOutputFile, kDuration);
+ EXPECT_TRUE(RemoveDirectory(kResourceFolder, true));
+ EXPECT_TRUE(RemoveDirectory(kStorageFolder, true));
+}
+
+TEST_F(MediaManagerImplTest,
+ StartMicrophoneRecording_OutputFileNotExists_ExpectFalse) {
+ StartMicrophoneCheckHelper();
+ media_manager_impl_->set_mock_mic_listener(media_adapter_listener_mock_);
+ EXPECT_FALSE(FileExists(kOutputFilePath));
+ media_manager_impl_->StartMicrophoneRecording(
+ kApplicationKey, kOutputFile, kDuration);
+}
+
+TEST_F(MediaManagerImplTest,
+ StartMicrophoneRecording_OutputFileCouldNotDeleted_ExpectTrue) {
+ StartMicrophoneCheckHelper();
+ if (!DirectoryExists(kStorageFolder)) {
+ CreateDirectory(kStorageFolder);
+ }
+ EXPECT_FALSE(FileExists(kOutputFilePath));
+ EXPECT_TRUE(CreateFile(kOutputFilePath));
+ chmod(kOutputFilePath.c_str(), S_IRUSR);
+ EXPECT_FALSE(DeleteFile(kOutputFilePath));
+ media_manager_impl_->set_mock_mic_listener(media_adapter_listener_mock_);
+ EXPECT_TRUE(FileExists(kOutputFilePath));
+ media_manager_impl_->StartMicrophoneRecording(
+ kApplicationKey, kOutputFile, kDuration);
+ chmod(kOutputFilePath.c_str(), S_IWUSR);
+ EXPECT_TRUE(RemoveDirectory(kStorageFolder, true));
+}
+
+TEST_F(MediaManagerImplTest, StopMicrophoneRecording_SUCCESS) {
+ media_manager_impl_->set_mock_mic_listener(media_adapter_listener_mock_);
#ifdef EXTENDED_MEDIA_MODE
MockMediaAdapterImpl* media_adapter_recorder_mock =
new MockMediaAdapterImpl();
- mediaManagerImpl.set_mock_mic_recorder(media_adapter_recorder_mock);
- EXPECT_CALL(*media_adapter_recorder_mock, StopActivity(application_key));
+ media_manager_impl_->set_mock_mic_recorder(media_adapter_recorder_mock);
+ EXPECT_CALL(*media_adapter_recorder_mock, StopActivity(kApplicationKey));
#endif // EXTENDED_MEDIA_MODE
- EXPECT_CALL(*media_adapter_listener_mock_, OnActivityEnded(application_key));
+ EXPECT_CALL(*media_adapter_listener_mock_, OnActivityEnded(kApplicationKey));
#ifdef EXTENDED_MEDIA_MODE
EXPECT_CALL(*media_adapter_recorder_mock, RemoveListener(_));
#endif // EXTENDED_MEDIA_MODE
- mediaManagerImpl.StopMicrophoneRecording(application_key);
+ media_manager_impl_->StopMicrophoneRecording(kApplicationKey);
}
-TEST_F(MediaManagerImplTest, StartStopStreaming) {
- application_manager_test::MockApplicationManager mock_application_manager;
+TEST_F(MediaManagerImplTest,
+ StartStopStreaming_AudioAndVideoServiceType_SUCCESS) {
+ MockMediaAdapterImplPtr mock_audio_media_streamer =
+ utils::MakeShared<MockMediaAdapterImpl>();
+ media_manager_impl_->set_mock_streamer(ServiceType::kAudio,
+ mock_audio_media_streamer);
+ MockMediaAdapterImplPtr mock_nav_media_streamer =
+ utils::MakeShared<MockMediaAdapterImpl>();
+ media_manager_impl_->set_mock_streamer(ServiceType::kMobileNav,
+ mock_nav_media_streamer);
- ON_CALL(mock_media_manager_settings_, video_server_type())
- .WillByDefault(ReturnRef(kDefaultValue_));
- ON_CALL(mock_media_manager_settings_, audio_server_type())
- .WillByDefault(ReturnRef(kDefaultValue_));
- MediaManagerImpl mediaManagerImpl(mock_application_manager,
- mock_media_manager_settings_);
-
- int32_t application_key = 1;
- MockMediaAdapterImpl* mock_audio_media_streamer = new MockMediaAdapterImpl();
- mediaManagerImpl.set_mock_streamer(protocol_handler::ServiceType::kAudio,
- mock_audio_media_streamer);
- MockMediaAdapterImpl* mock_nav_media_streamer = new MockMediaAdapterImpl();
- mediaManagerImpl.set_mock_streamer(protocol_handler::ServiceType::kMobileNav,
- mock_nav_media_streamer);
-
- EXPECT_CALL(*mock_audio_media_streamer, StartActivity(application_key));
- mediaManagerImpl.StartStreaming(application_key,
- protocol_handler::ServiceType::kAudio);
-
- EXPECT_CALL(*mock_nav_media_streamer, StartActivity(application_key));
- mediaManagerImpl.StartStreaming(application_key,
- protocol_handler::ServiceType::kMobileNav);
-
- EXPECT_CALL(*mock_audio_media_streamer, StopActivity(application_key));
- mediaManagerImpl.StopStreaming(application_key,
- protocol_handler::ServiceType::kAudio);
-
- EXPECT_CALL(*mock_nav_media_streamer, StopActivity(application_key));
- mediaManagerImpl.StopStreaming(application_key,
- protocol_handler::ServiceType::kMobileNav);
+ EXPECT_CALL(*mock_audio_media_streamer, StartActivity(kApplicationKey));
+ media_manager_impl_->StartStreaming(kApplicationKey, ServiceType::kAudio);
+ EXPECT_CALL(*mock_nav_media_streamer, StartActivity(kApplicationKey));
+ media_manager_impl_->StartStreaming(kApplicationKey, ServiceType::kMobileNav);
+ EXPECT_CALL(*mock_audio_media_streamer, StopActivity(kApplicationKey));
+ media_manager_impl_->StopStreaming(kApplicationKey, ServiceType::kAudio);
+ EXPECT_CALL(*mock_nav_media_streamer, StopActivity(kApplicationKey));
+ media_manager_impl_->StopStreaming(kApplicationKey, ServiceType::kMobileNav);
}
-TEST_F(MediaManagerImplTest, CheckFramesProcessed) {
- application_manager_test::MockApplicationManager mock_application_manager;
-
+TEST_F(MediaManagerImplTest,
+ CheckFramesProcessed_WithCorrectFramesNumber_SUCCESS) {
ON_CALL(mock_media_manager_settings_, video_server_type())
- .WillByDefault(ReturnRef(kDefaultValue_));
+ .WillByDefault(ReturnRef(kDefaultValue));
ON_CALL(mock_media_manager_settings_, audio_server_type())
- .WillByDefault(ReturnRef(kDefaultValue_));
- MediaManagerImpl mediaManagerImpl(mock_application_manager,
- mock_media_manager_settings_);
+ .WillByDefault(ReturnRef(kDefaultValue));
protocol_handler_test::MockProtocolHandler mock_protocol_handler;
- mediaManagerImpl.SetProtocolHandler(&mock_protocol_handler);
- int32_t application_key = 1;
- int32_t frame_number = 10;
-
+ media_manager_impl_->SetProtocolHandler(&mock_protocol_handler);
+ const int32_t frame_number = 10;
EXPECT_CALL(mock_protocol_handler,
- SendFramesNumber(application_key, frame_number));
- mediaManagerImpl.FramesProcessed(application_key, frame_number);
+ SendFramesNumber(kApplicationKey, frame_number));
+ media_manager_impl_->FramesProcessed(kApplicationKey, frame_number);
}
} // namespace media_manager_test
diff --git a/src/components/policy/policy_external/CMakeLists.txt b/src/components/policy/policy_external/CMakeLists.txt
index 2cbdbd7f64..8d04f20470 100644
--- a/src/components/policy/policy_external/CMakeLists.txt
+++ b/src/components/policy/policy_external/CMakeLists.txt
@@ -58,6 +58,10 @@ set(SOURCES
${COMPONENTS_DIR}/rpc_base/src/rpc_base/rpc_base.cc
)
+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
diff --git a/src/components/policy/policy_external/include/policy/access_remote.h b/src/components/policy/policy_external/include/policy/access_remote.h
new file mode 100644
index 0000000000..fd185af075
--- /dev/null
+++ b/src/components/policy/policy_external/include/policy/access_remote.h
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2015, 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_ACCESS_REMOTE_H_
+#define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_ACCESS_REMOTE_H_
+
+#include <vector>
+#include <ostream>
+#include <string>
+#include "policy/policy_table/types.h"
+#include "policy/policy_types.h"
+
+namespace policy_table = ::rpc::policy_table_interface_base;
+
+namespace policy {
+
+enum TypeAccess { kDisallowed, kAllowed };
+inline std::ostream& operator<<(std::ostream& output, TypeAccess x) {
+ output << "Access: ";
+ switch (x) {
+ case kDisallowed:
+ output << "DISALLOWED";
+ break;
+ case kAllowed:
+ output << "ALLOWED";
+ break;
+ default:
+ output << "Error: Unknown type";
+ }
+ return output;
+}
+
+struct ApplicationOnDevice {
+ PTString dev_id;
+ PTString app_id;
+};
+inline bool operator<(const ApplicationOnDevice& x,
+ const ApplicationOnDevice& y) {
+ return x.dev_id < y.dev_id || (x.dev_id == y.dev_id && x.app_id < y.app_id);
+}
+inline bool operator==(const ApplicationOnDevice& x,
+ const ApplicationOnDevice& y) {
+ return x.dev_id == y.dev_id && x.app_id == y.app_id;
+}
+inline std::ostream& operator<<(std::ostream& output,
+ const ApplicationOnDevice& who) {
+ output << "Subject(dev:" << who.dev_id << ", app:" << who.app_id << ")";
+ return output;
+}
+
+typedef std::vector<PTString> RemoteControlParams;
+
+class AccessRemote {
+ public:
+ virtual ~AccessRemote() {}
+ /**
+ * @brief CheckModuleType check if module type is allowed for application
+ * @param app_id application id
+ * @param module module
+ * @return true if allowed, if not - false
+ */
+ virtual bool CheckModuleType(const PTString& app_id,
+ policy_table::ModuleType module) const = 0;
+
+ /**
+ * @brief SetDefaultHmiTypes setup default hmi typed for application
+ * @param who application on specific device
+ * @param hmi_types hmi types list
+ */
+ virtual void SetDefaultHmiTypes(const ApplicationOnDevice& who,
+ const std::vector<int>& hmi_types) = 0;
+
+ /**
+ * @brief GetGroups return list of groups for applicaiton
+ * @param who application on specific device
+ * @return list of groups
+ */
+ virtual const policy_table::Strings& GetGroups(
+ const ApplicationOnDevice& who) = 0;
+
+ /**
+ * @brief GetPermissionsForApp read list of permissions for application
+ * @param device_id device
+ * @param app_id application
+ * @param group_types output parameter for permissions
+ * @return true
+ */
+ virtual bool GetPermissionsForApp(const std::string& device_id,
+ const std::string& app_id,
+ FunctionalIdType& group_types) = 0;
+
+ /**
+ * @brief IsAppRemoteControl check is app is remote controll
+ * @param who application on specific device
+ * @return true is remote controll aotherwise return false
+ */
+ virtual bool IsAppRemoteControl(const ApplicationOnDevice& who) = 0;
+
+ /**
+ * @brief GetModuleTypes get list of module types of application
+ * @param policy_app_id application id
+ * @param modules output parameter for module types
+ * @return true on success otherwise false
+ */
+ virtual bool GetModuleTypes(const std::string& policy_app_id,
+ std::vector<std::string>* modules) = 0;
+};
+
+} // namespace policy
+
+#endif // SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_ACCESS_REMOTE_H_
diff --git a/src/components/policy/policy_external/include/policy/access_remote_impl.h b/src/components/policy/policy_external/include/policy/access_remote_impl.h
new file mode 100644
index 0000000000..0fa53b0237
--- /dev/null
+++ b/src/components/policy/policy_external/include/policy/access_remote_impl.h
@@ -0,0 +1,174 @@
+/*
+ * Copyright (c) 2015, 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_ACCESS_REMOTE_IMPL_H_
+#define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_ACCESS_REMOTE_IMPL_H_
+
+#include <map>
+#include "policy/policy_table/types.h"
+#include "utils/macro.h"
+#include "utils/shared_ptr.h"
+#include "policy/access_remote.h"
+#include "policy/cache_manager.h"
+
+using policy_table::FunctionalGroupings;
+
+namespace policy {
+
+class AccessRemoteImpl : public AccessRemote {
+ public:
+ AccessRemoteImpl();
+ explicit AccessRemoteImpl(utils::SharedPtr<CacheManager> cache);
+ /**
+ * @brief CheckModuleType check if module type is allowed for application
+ * @param app_id application id
+ * @param module module
+ * @return true if allowed, if not - false
+ */
+ bool CheckModuleType(const PTString& app_id,
+ policy_table::ModuleType module) const OVERRIDE;
+
+ /**
+ * @brief SetDefaultHmiTypes setup default hmi typed for application
+ * @param who application on specific device
+ * @param hmi_types hmi types list
+ */
+ void SetDefaultHmiTypes(const ApplicationOnDevice& who,
+ const std::vector<int>& hmi_types) OVERRIDE;
+
+ /**
+ * @brief GetGroups return list of groups for applicaiton
+ * @param who application on specific device
+ * @return list of groups
+ */
+ const policy_table::Strings& GetGroups(
+ const ApplicationOnDevice& who) OVERRIDE;
+
+ /**
+ * @brief GetPermissionsForApp read list of permissions for application
+ * @param device_id device
+ * @param app_id application
+ * @param group_types output parameter for permissions
+ * @return true
+ */
+ bool GetPermissionsForApp(const std::string& device_id,
+ const std::string& app_id,
+ FunctionalIdType& group_types) OVERRIDE;
+
+ /**
+ * @brief IsAppRemoteControl check is app is remote controll
+ * @param who application on specific device
+ * @return true is remote controll aotherwise return false
+ */
+ bool IsAppRemoteControl(const ApplicationOnDevice& who) OVERRIDE;
+
+ /**
+ * @brief GetModuleTypes get list of module types of application
+ * @param policy_app_id application id
+ * @param modules output parameter for module types
+ * @return true on success otherwise false
+ */
+ bool GetModuleTypes(const std::string& policy_app_id,
+ std::vector<std::string>* modules) OVERRIDE;
+
+ private:
+ inline void set_enabled(bool value);
+ inline bool country_consent() const;
+ /**
+ * @brief HmiTypes get list of hmi types for application
+ * @param who application on specific device
+ * @return list of hmi types
+ */
+ const policy_table::AppHMITypes& HmiTypes(const ApplicationOnDevice& who);
+
+ /**
+ * @brief GetGroupsIds get list of groups for application
+ * @param device_id device id
+ * @param app_id application id
+ * @param grops_ids output parameter for group ids storing
+ */
+ void GetGroupsIds(const std::string& device_id,
+ const std::string& app_id,
+ FunctionalGroupIDs& grops_ids);
+
+ /**
+ * @brief IsAllowed check if modulename and rpc is allowed for application
+ * @param modules list of access modules
+ * @param module_name module name to check
+ * @param rpc_name rpc name to check
+ * @param input list of rpc parameters
+ * @return true if allowed otherwise return false
+ */
+ bool IsAllowed(const policy_table::AccessModules& modules,
+ const std::string& module_name,
+ const std::string& rpc_name,
+ RemoteControlParams* input) const;
+
+ /**
+ * @brief CompareParameters check if app parameters allowed
+ * @param parameters list of allowed parameters
+ * @param input list of parameters to check
+ * @return true if allowed otherwise return false
+ */
+ bool CompareParameters(const policy_table::Strings& parameters,
+ RemoteControlParams* input) const;
+
+ /**
+ * @brief cache_ contains pointer to cache manager instance
+ */
+ utils::SharedPtr<CacheManager> cache_;
+
+ /**
+ * @brief hmi_types_ contains list of default HMI types for applications
+ */
+ typedef std::map<ApplicationOnDevice, policy_table::AppHMITypes> HMIList;
+ HMIList hmi_types_;
+
+#ifdef BUILD_TESTS
+ FRIEND_TEST(AccessRemoteImplTest, KeyMapTest);
+ FRIEND_TEST(AccessRemoteImplTest, Allow);
+ FRIEND_TEST(AccessRemoteImplTest, Deny);
+ FRIEND_TEST(AccessRemoteImplTest, ChangeAccess);
+ FRIEND_TEST(AccessRemoteImplTest, ResetBySubject);
+ FRIEND_TEST(AccessRemoteImplTest, ResetByObject);
+ FRIEND_TEST(AccessRemoteImplTest, CheckAllowed);
+ FRIEND_TEST(AccessRemoteImplTest, CheckDisallowed);
+ FRIEND_TEST(AccessRemoteImplTest, CheckManual);
+ FRIEND_TEST(AccessRemoteImplTest, CheckModuleType);
+ FRIEND_TEST(AccessRemoteImplTest, EnableDisable);
+ FRIEND_TEST(AccessRemoteImplTest, SetDefaultHmiTypes);
+ FRIEND_TEST(AccessRemoteImplTest, GetGroups);
+#endif // BUILD_TESTS
+};
+
+} // namespace policy
+
+#endif // SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_ACCESS_REMOTE_IMPL_H_
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 95aed36f89..428a9bd2f6 100644
--- a/src/components/policy/policy_external/include/policy/cache_manager.h
+++ b/src/components/policy/policy_external/include/policy/cache_manager.h
@@ -914,6 +914,14 @@ class CacheManager : public CacheManagerInterface {
sync_primitives::Lock backuper_locker_;
BackgroundBackuper* backuper_;
const PolicySettings* settings_;
+
+ friend class AccessRemoteImpl;
+
+#ifdef BUILD_TESTS
+ FRIEND_TEST(AccessRemoteImplTest, CheckModuleType);
+ FRIEND_TEST(AccessRemoteImplTest, EnableDisable);
+ FRIEND_TEST(AccessRemoteImplTest, GetGroups);
+#endif // BUILD_TESTS
};
} // namespace policy
#endif // SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_CACHE_MANAGER_H_
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 66631f32cf..ae1f8922ba 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
@@ -36,8 +36,10 @@
#include <string>
#include <vector>
+#include "policy/policy_table/types.h"
+#include "policy/pt_representation.h"
#include "utils/shared_ptr.h"
-#include "usage_statistics/counter.h"
+#include "policy/usage_statistics/counter.h"
#include "policy/policy_types.h"
#include "policy/policy_settings.h"
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 10d6908b14..42c1ec0b46 100644
--- a/src/components/policy/policy_external/include/policy/policy_helper.h
+++ b/src/components/policy/policy_external/include/policy/policy_helper.h
@@ -323,6 +323,7 @@ FunctionalGroupIDs FindSame(const FunctionalGroupIDs& first,
* @return true, if succeded, otherwise - false
*/
bool UnwrapAppPolicies(policy_table::ApplicationPolicies& app_policies);
-}
+
+} // namespace policy
#endif // SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_POLICY_HELPER_H_
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 a37d0d66b9..f8d226c86a 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
@@ -43,6 +43,11 @@
#include "policy/policy_table/functions.h"
#include "policy/usage_statistics/statistics_manager.h"
+#ifdef SDL_REMOTE_CONTROL
+#include "policy/access_remote.h"
+#include "policy/access_remote_impl.h"
+#endif // SDL_REMOTE_CONTROL
+
namespace policy_table = rpc::policy_table_interface_base;
namespace policy {
@@ -52,172 +57,557 @@ class PolicyManagerImpl : public PolicyManager {
public:
PolicyManagerImpl();
explicit PolicyManagerImpl(bool in_memory);
- virtual void set_listener(PolicyListener* listener);
+
+ /**
+ * @brief set_listener set new policy listener instance
+ * @param listener new policy listener
+ */
+ void set_listener(PolicyListener* listener) OVERRIDE;
+
+ /**
+ * @brief listener get current policy listener instance
+ * @return current policy listener
+ */
PolicyListener* listener() const {
return listener_;
}
- virtual bool InitPT(const std::string& file_name,
- const PolicySettings* settings);
- virtual bool LoadPT(const std::string& file, const BinaryMessage& pt_content);
- virtual bool ResetPT(const std::string& file_name);
-
- virtual std::string GetUpdateUrl(int service_type);
- virtual void GetUpdateUrls(const uint32_t service_type,
- EndpointUrls& out_end_points);
- virtual void GetUpdateUrls(const std::string& service_type,
- EndpointUrls& out_end_points);
- virtual void RequestPTUpdate();
- virtual void CheckPermissions(const PTString& app_id,
- const PTString& hmi_level,
- const PTString& rpc,
- const RPCParams& rpc_params,
- CheckPermissionResult& result);
- virtual bool ResetUserConsent();
- virtual void KmsChanged(int kilometers);
- virtual void IncrementIgnitionCycles();
- virtual std::string ForcePTExchange();
- virtual std::string ForcePTExchangeAtUserRequest();
- virtual std::string GetPolicyTableStatus() const;
- virtual void ResetRetrySequence();
- virtual int NextRetryTimeout();
- virtual uint32_t TimeoutExchangeMSec();
- virtual const std::vector<int> RetrySequenceDelaysSeconds();
- virtual void OnExceededTimeout();
- virtual std::string GetLockScreenIconUrl() const OVERRIDE;
- virtual void OnUpdateStarted();
- virtual void PTUpdatedAt(Counters counter, int value);
-
- /**
- * Refresh data about retry sequence from policy table
+
+ /**
+ * @brief Inits Policy Table
+ * @param file_name path to preloaded PT file
+ * @param settings pointer to policy init settings
+ * @return true if init is successful
+ */
+ bool InitPT(const std::string& file_name,
+ const PolicySettings* settings) OVERRIDE;
+
+ /**
+ * @brief Updates Policy Table from binary message received from
+ * mobile device. Saves to Policy Table diff between Policy Table
+ * sent in snapshot and received Policy Table.
+ * @param file name of file with update policy table
+ * @param pt_content PTU as binary string
+ * @return true if successfully
+ */
+ bool LoadPT(const std::string& file,
+ const BinaryMessage& pt_content) OVERRIDE;
+
+ /**
+ * @brief Resets Policy Table
+ * @param file_name Path to preloaded PT file
+ * @return true if successfully
+ */
+ bool ResetPT(const std::string& file_name) OVERRIDE;
+
+ /**
+ * @brief Gets last URL for sending PTS to from PT itself
+ * @param service_type Service specifies user of URL
+ * @return last URL or empty string if endpoint entry is empty
+ */
+ std::string GetUpdateUrl(int service_type) OVERRIDE;
+
+ /**
+ * @brief Gets all URLs for sending PTS to from PT itself.
+ * @param service_type Service specifies user of URL
+ * @param out_end_points output vector of urls
+ */
+ void GetUpdateUrls(const uint32_t service_type,
+ EndpointUrls& out_end_points) OVERRIDE;
+ void GetUpdateUrls(const std::string& service_type,
+ EndpointUrls& out_end_points) OVERRIDE;
+
+ /**
+ * @brief PTU is needed, for this PTS has to be formed and sent.
+ */
+ void RequestPTUpdate() OVERRIDE;
+
+ /**
+ * @brief Check if specified RPC for specified application
+ * has permission to be executed in specified HMI Level
+ * and also its permitted params.
+ * @param app_id Id of application provided during registration
+ * @param hmi_level Current HMI Level of application
+ * @param rpc Name of RPC
+ * @param rpc_params List of RPC params
+ * @param result containing flag if HMI Level is allowed
+ * and list of allowed params.
+ */
+ void CheckPermissions(const PTString& app_id,
+ const PTString& hmi_level,
+ const PTString& rpc,
+ const RPCParams& rpc_params,
+ CheckPermissionResult& result) OVERRIDE;
+
+ /**
+ * @brief Clear all record of user consents. Used during Factory Reset.
+ * @return bool Success of operation
+ */
+ bool ResetUserConsent() OVERRIDE;
+
+ /**
+ * @brief Checks is PT exceeded kilometers
+ * @param kilometers current kilometers at odometer
+ * @return true if exceeded
+ */
+ void KmsChanged(int kilometers) OVERRIDE;
+
+ /**
+ * @brief Increments counter of ignition cycles
+ */
+ void IncrementIgnitionCycles() OVERRIDE;
+
+ /**
+ * @brief Exchange by hmi or mobile request
+ * @return Current status of policy table
+ */
+ std::string ForcePTExchange() OVERRIDE;
+
+ /**
+ * @brief Exchange by user request
+ * @return Current status of policy table
+ */
+ std::string ForcePTExchangeAtUserRequest() OVERRIDE;
+
+ /**
+ * @brief Returns current status of policy table for HMI
+ * @return Current status of policy table
+ */
+ std::string GetPolicyTableStatus() const OVERRIDE;
+
+ /**
+ * @brief Resets retry sequence
+ */
+ void ResetRetrySequence() OVERRIDE;
+
+ /**
+ * @brief Gets timeout to wait before next retry updating PT
+ * If timeout is less or equal to zero then the retry sequence is not need.
+ * @return timeout in seconds
+ */
+ int NextRetryTimeout() OVERRIDE;
+
+ /**
+ * @brief Gets timeout to wait until receive response
+ * @return timeout in seconds
+ */
+ uint32_t TimeoutExchangeMSec() OVERRIDE;
+
+ /**
+ * @brief List of timeouts in seconds between retries
+ * when attempt to update PT fails
+ * @return List of delays between attempts.
+ */
+ const std::vector<int> RetrySequenceDelaysSeconds() OVERRIDE;
+
+ /**
+ * @brief Handler of exceeding timeout of exchanging policy table
+ */
+ void OnExceededTimeout() OVERRIDE;
+
+ /**
+ * @brief GetLockScreenIcon allows to obtain lock screen icon url;
+ * @return url which point to the resourse where lock screen icon could be
+ *obtained.
+ */
+ std::string GetLockScreenIconUrl() const OVERRIDE;
+
+ /**
+ * @brief Handler of PTS sending out
+ */
+ void OnUpdateStarted() OVERRIDE;
+
+ /**
+ * @brief Sets counter value that passed for receiving PT UPdate.
+ */
+ void PTUpdatedAt(Counters counter, int value) OVERRIDE;
+
+ /**
+ * @brief Refresh data about retry sequence from policy table
*/
virtual void RefreshRetrySequence();
- virtual DeviceConsent GetUserConsentForDevice(
+
+ /**
+ * @brief Gets user consent for mobile device data connection
+ * @param device_id Unique device identifier
+ * @return status of device consent
+ */
+ DeviceConsent GetUserConsentForDevice(
const std::string& device_id) const OVERRIDE;
- virtual void GetUserConsentForApp(
+
+ /**
+ * @brief Gets user consent for application
+ * @param device_id Device id
+ * @param policy_app_id Unique application id
+ * @param permissions Array of functional groups permissions
+ */
+ void GetUserConsentForApp(
const std::string& device_id,
const std::string& policy_app_id,
- std::vector<FunctionalGroupPermission>& permissions);
- virtual void SetUserConsentForDevice(const std::string& device_id,
- const bool is_allowed);
- virtual bool ReactOnUserDevConsentForApp(const std::string& app_id,
- const bool is_device_allowed);
- virtual bool GetInitialAppData(const std::string& application_id,
- StringArray* nicknames = NULL,
- StringArray* app_hmi_types = NULL);
+ std::vector<FunctionalGroupPermission>& permissions) OVERRIDE;
+
+ /**
+ * @brief Set user consent for mobile device data connection
+ * @param device_id Unique device identifier
+ * @param is_allowed User consent for usage device data connection
+ */
+ void SetUserConsentForDevice(const std::string& device_id,
+ const bool is_allowed) OVERRIDE;
- virtual void AddDevice(const std::string& device_id,
- const std::string& connection_type);
+ /**
+ * @brief Update Application Policies as reaction
+ * on User allowing/disallowing device this app is running on.
+ * @param app_id Unique application id
+ * @param is_device_allowed true if user allowing device otherwise false
+ * @return true if operation was successful
+ */
+ bool ReactOnUserDevConsentForApp(const std::string& app_id,
+ const bool is_device_allowed) OVERRIDE;
+
+ /**
+ * @brief Retrieves data from app_policies about app on its registration:
+ * @param application_id - id of registered app
+ * @param nicknames Synonyms for application
+ * @param app_hmi_types Section on HMI where app can appear (Navigation, Phone
+ * etc)
+ */
+ bool GetInitialAppData(const std::string& application_id,
+ StringArray* nicknames = NULL,
+ StringArray* app_hmi_types = NULL) OVERRIDE;
+
+ /**
+ * @brief Add's device to policy table
+ * @param device_id Device mac address
+ * @param connection_type Device connection type
+ */
+ void AddDevice(const std::string& device_id,
+ const std::string& connection_type) OVERRIDE;
- virtual void SetDeviceInfo(const std::string& device_id,
- const DeviceInfo& device_info);
+ /**
+ * @brief Stores device parameters received during application registration
+ * to policy table
+ * @param device_id Device mac address
+ * @param device_info Received device parameters
+ */
+ void SetDeviceInfo(const std::string& device_id,
+ const DeviceInfo& device_info) OVERRIDE;
+ /**
+ * @brief Set user consent for application functional groups
+ * @param permissions User-defined application group pemissions.
+ * The permissions is not const reference because it may contains
+ * valid data as well as invalid. So we will remove all invalid data
+ * from this structure.
+ * @param mode notification mode
+ */
void SetUserConsentForApp(const PermissionConsent& permissions,
const NotificationMode mode) OVERRIDE;
- virtual bool GetDefaultHmi(const std::string& policy_app_id,
- std::string* default_hmi) const;
+ /**
+ * @brief Get default HMI level for application
+ * @param policy_app_id Unique application id
+ * @param default_hmi Default HMI level for application or empty, if value
+ * was not set
+ * @return true, if succedeed, otherwise - false
+ */
+ bool GetDefaultHmi(const std::string& policy_app_id,
+ std::string* default_hmi) const OVERRIDE;
- virtual bool GetPriority(const std::string& policy_app_id,
- std::string* priority) const;
+ /**
+ * @brief Get priority for application
+ * @param policy_app_id Unique application id
+ * @param priority Priority for application or empty, if value was not set
+ * @return true, if succedeed, otherwise - false
+ */
+ bool GetPriority(const std::string& policy_app_id,
+ std::string* priority) const OVERRIDE;
- virtual std::vector<UserFriendlyMessage> GetUserFriendlyMessages(
+ /**
+ * @brief Get user friendly messages for given RPC messages and language
+ * @param message_codes RPC message codes
+ * @param language Language
+ * @param active_hmi_language Currently active language
+ * @return Array of structs with appropriate message parameters
+ */
+ std::vector<UserFriendlyMessage> GetUserFriendlyMessages(
const std::vector<std::string>& message_code,
const std::string& language,
- const std::string& active_hmi_language);
+ const std::string& active_hmi_language) OVERRIDE;
- virtual bool IsApplicationRevoked(const std::string& app_id) const;
+ /**
+ * @brief Checks if the application is revoked
+ * @param app_id application id
+ * @return true if application is revoked
+ */
+ bool IsApplicationRevoked(const std::string& app_id) const OVERRIDE;
- virtual void GetPermissionsForApp(
+ /**
+ * @brief Get resulting RPCs permissions for application which started on
+ * specific device
+ * @param device_id Device id
+ * @param policy_app_id Unique application id
+ * @param permissions Array of functional groups permissions
+ */
+ void GetPermissionsForApp(
const std::string& device_id,
const std::string& policy_app_id,
- std::vector<FunctionalGroupPermission>& permissions);
+ std::vector<FunctionalGroupPermission>& permissions) OVERRIDE;
- virtual std::string& GetCurrentDeviceId(
- const std::string& policy_app_id) const;
+ /**
+ * @brief Return device id, which hosts specific application
+ * @param policy_app_id Application id, which is required to update device id
+ */
+ std::string& GetCurrentDeviceId(
+ const std::string& policy_app_id) const OVERRIDE;
- virtual void SetSystemLanguage(const std::string& language);
+ /**
+ * @brief Set current system language
+ * @param language Language
+ */
+ void SetSystemLanguage(const std::string& language) OVERRIDE;
- virtual void SetSystemInfo(const std::string& ccpu_version,
- const std::string& wers_country_code,
- const std::string& language);
- virtual void OnSystemReady();
+ /**
+ * @brief Set data from GetSystemInfo response to policy table
+ * @param ccpu_version CCPU version
+ * @param wers_country_code WERS country code
+ * @param language System language
+ */
+ void SetSystemInfo(const std::string& ccpu_version,
+ const std::string& wers_country_code,
+ const std::string& language) OVERRIDE;
- virtual uint32_t GetNotificationsNumber(
- const std::string& priority) const OVERRIDE;
+ /**
+ * @brief Runs necessary operations, which is depends on external system
+ * state, e.g. getting system-specific parameters which are need to be
+ * filled into policy table
+ */
+ void OnSystemReady() OVERRIDE;
- virtual void SetVINValue(const std::string& value);
+ /**
+ * @brief Get number of notification by priority
+ * @param priority Specified priority
+ * @return notification number
+ */
+ uint32_t GetNotificationsNumber(const std::string& priority) const OVERRIDE;
- // Interface StatisticsManager (begin)
- virtual void Increment(usage_statistics::GlobalCounterId type);
- virtual void Increment(const std::string& app_id,
- usage_statistics::AppCounterId type);
- virtual void Set(const std::string& app_id,
- usage_statistics::AppInfoId type,
- const std::string& value);
- virtual void Add(const std::string& app_id,
- usage_statistics::AppStopwatchId type,
- int32_t timespan_seconds);
- // Interface StatisticsManager (end)
+ /**
+ * @brief Allows to update Vehicle Identification Number in policy table.
+ * @param new value for the parameter.
+ */
+ void SetVINValue(const std::string& value) OVERRIDE;
- AppPermissions GetAppPermissionsChanges(const std::string& policy_app_id);
- void RemovePendingPermissionChanges(const std::string& app_id);
+ /**
+ * @brief Gets specific application permissions changes since last policy
+ * table update
+ * @param policy_app_id Unique application id
+ * @return Permissions changes
+ */
+ AppPermissions GetAppPermissionsChanges(
+ const std::string& policy_app_id) OVERRIDE;
- void SendNotificationOnPermissionsUpdated(const std::string& application_id);
+ /**
+ * @brief Removes specific application permissions changes
+ * @param app_id Unique application id
+ */
+ void RemovePendingPermissionChanges(const std::string& app_id) OVERRIDE;
- bool CleanupUnpairedDevices();
+ /**
+ * @brief Send OnPermissionsUpdated for choosen application
+ * @param application_id Unique application id
+ */
+ void SendNotificationOnPermissionsUpdated(
+ const std::string& application_id) OVERRIDE;
- bool CanAppKeepContext(const std::string& app_id) const;
- bool CanAppStealFocus(const std::string& app_id) const;
- void MarkUnpairedDevice(const std::string& device_id);
+ /**
+ * @brief Removes unpaired device records and related records from DB
+ * @return true, if succedeed, otherwise - false
+ */
+ bool CleanupUnpairedDevices() OVERRIDE;
+ /**
+ * @brief Check if app can keep context.
+ * @param app_id Unique application id
+ * @return true if app can keep context, otherwise - false
+ */
+ bool CanAppKeepContext(const std::string& app_id) const OVERRIDE;
+
+ /**
+ * @brief Check if app can steal focus.
+ * @param app_id Unique application id
+ * @return true if app can steal focus, otherwise - false
+ */
+ bool CanAppStealFocus(const std::string& app_id) const OVERRIDE;
+
+ /**
+ * @brief Marks device as upaired
+ * @param device_id id device
+ */
+ void MarkUnpairedDevice(const std::string& device_id) OVERRIDE;
+
+ /**
+ * @brief Adds, application to the db or update existed one
+ * run PTU if policy update is necessary for application.
+ * @param application_id Unique application id
+ * @param hmi_types application HMI types
+ * @return function that will notify update manager about new application
+ */
StatusNotifier AddApplication(
const std::string& application_id,
- const rpc::policy_table_interface_base::AppHmiTypes& hmi_types);
+ const rpc::policy_table_interface_base::AppHmiTypes& hmi_types) OVERRIDE;
+
+#ifdef SDL_REMOTE_CONTROL
+ /**
+ * @brief Assigns new HMI types for specified application
+ * @param application_id Unique application id
+ * @param hmi_types new HMI types list
+ */
+ void SetDefaultHmiTypes(const std::string& application_id,
+ const std::vector<int>& hmi_types) OVERRIDE;
+
+ /**
+ * @brief Gets HMI types
+ * @param application_id ID application
+ * @param app_types list to save HMI types
+ * @return true if policy has specific policy for this application
+ */
+ bool GetHMITypes(const std::string& application_id,
+ std::vector<int>* app_types) OVERRIDE;
+ /**
+ * @brief Setter for access_remote instance
+ * @param access_remote pointer to new access_remote instance
+ */
+ void set_access_remote(utils::SharedPtr<AccessRemote> access_remote) OVERRIDE;
+
+ /**
+ * @brief Sends notification about application HMI level changed
+ * @param who application information structure
+ */
+ void SendHMILevelChanged(const ApplicationOnDevice& who);
+
+ /**
+ * @brief Sends notification if application permissions were changed
+ * @param application_id Unique id of application
+ */
+ void OnPrimaryGroupsChanged(const std::string& application_id);
+#endif // SDL_REMOTE_CONTROL
+
+ /**
+ * @brief Removes consent for application functional group
+ * @param application_id Unique id of application
+ * @param group_name application functional group name
+ */
virtual void RemoveAppConsentForGroup(const std::string& app_id,
const std::string& group_name);
- virtual uint32_t HeartBeatTimeout(const std::string& app_id) const;
+ /**
+ * @brief Returns heart beat timeout
+ * @param app_id application id
+ * @return if timeout was set then value in milliseconds greater zero
+ * otherwise heart beat for specific application isn't set
+ */
+ uint32_t HeartBeatTimeout(const std::string& app_id) const OVERRIDE;
- virtual void SaveUpdateStatusRequired(bool is_update_needed);
+ /**
+ * @brief SaveUpdateStatusRequired allows to save update status.
+ * @param is_update_needed true if update needed
+ */
+ void SaveUpdateStatusRequired(bool is_update_needed) OVERRIDE;
- virtual bool IsPredataPolicy(const std::string& policy_app_id) const OVERRIDE;
- void set_cache_manager(CacheManagerInterface* cache_manager);
+ /**
+ * @brief Checks, if application has policy assigned w/o data consent
+ * @param policy_app_id Unique application id
+ * @return true, if policy assigned w/o data consent, otherwise -false
+ */
+ bool IsPredataPolicy(const std::string& policy_app_id) const OVERRIDE;
- virtual void OnAppsSearchStarted();
+ /**
+ * @brief Setter for cache_manager instance
+ * @param cache_manager pointer to new cache_manager instance
+ */
+ void set_cache_manager(CacheManagerInterface* cache_manager);
- virtual void OnAppsSearchCompleted(const bool trigger_ptu);
+ /**
+ * @brief Handler on applications search started
+ */
+ void OnAppsSearchStarted() OVERRIDE;
-#ifdef BUILD_TESTS
- inline CacheManagerInterfaceSPtr GetCache() {
- return cache_;
- }
- inline void SetSendOnUpdateFlags(const bool send_on_update_sent_out,
- const bool wrong_ptu_update_received) {
- send_on_update_sent_out_ = send_on_update_sent_out;
- wrong_ptu_update_received_ = wrong_ptu_update_received;
- }
-#endif // BUILD_TESTS
+ /**
+ * @brief Handler on applications search completed
+ * @param trigger_ptu contains true if PTU should be triggered
+ */
+ void OnAppsSearchCompleted(const bool trigger_ptu) OVERRIDE;
- virtual const std::vector<std::string> GetAppRequestTypes(
- const std::string policy_app_id) const;
+ /**
+ * @brief Gets request types for application
+ * @param policy_app_id Unique application id
+ * @return request types of application
+ */
+ const std::vector<std::string> GetAppRequestTypes(
+ const std::string policy_app_id) const OVERRIDE;
- virtual const VehicleInfo GetVehicleInfo() const;
+ /**
+ * @brief Get information about vehicle
+ * @return vehicle information
+ */
+ const VehicleInfo GetVehicleInfo() const OVERRIDE;
- virtual void OnAppRegisteredOnMobile(const std::string& application_id);
+ /**
+ * @brief OnAppRegisteredOnMobile allows to handle event when application were
+ * succesfully registered on mobile device.
+ * It will send OnAppPermissionSend notification and will try to start PTU. *
+ * @param application_id registered application.
+ */
+ void OnAppRegisteredOnMobile(const std::string& application_id) OVERRIDE;
- virtual const MetaInfo GetMetaInfo() const OVERRIDE;
+ /**
+ * @brief Gets meta information
+ * @return meta information
+ */
+ const MetaInfo GetMetaInfo() const OVERRIDE;
- virtual std::string RetrieveCertificate() const OVERRIDE;
+ /**
+ * @brief RetrieveCertificate Allows to obtain certificate in order
+ * to start secure connection.
+ * @return The certificate in PKCS#7 format.
+ */
+ std::string RetrieveCertificate() const OVERRIDE;
- virtual bool HasCertificate() const OVERRIDE;
+ /**
+ * @brief HasCertificate check whether policy table has certificate
+ * int module_config section.
+ * @return true in case certificate exists, false otherwise
+ */
+ bool HasCertificate() const OVERRIDE;
- virtual void SetDecryptedCertificate(const std::string& certificate) OVERRIDE;
+ /**
+ * @brief Sets decrypted certificate in policy table
+ * @param certificate content of certificate
+ */
+ void SetDecryptedCertificate(const std::string& certificate) OVERRIDE;
+ /**
+ * @brief Getter for policy settings
+ * @return policy settings instance
+ */
const PolicySettings& get_settings() const OVERRIDE;
+ /**
+ * @brief Finds the next URL that must be sent on OnSystemRequest retry
+ * @param urls vector of vectors that contain urls for each application
+ * @return Pair of policy application id and application url id from the
+ * urls vector
+ */
AppIdURL GetNextUpdateUrl(const EndpointUrls& urls) OVERRIDE;
+ /**
+ * @brief Checks if there is existing URL in the EndpointUrls vector with
+ * index saved in the policy manager and if not, it moves to the next
+ * application index
+ * @param rs contains the application index and url index from the
+ * urls vector that are to be sent on the next OnSystemRequest
+ * @param urls vector of vectors that contain urls for each application
+ * @return Pair of application index and url index
+ */
AppIdURL RetrySequenceUrl(const struct RetrySequenceURL& rs,
const EndpointUrls& urls) const OVERRIDE;
@@ -228,20 +618,90 @@ class PolicyManagerImpl : public PolicyManager {
* @return true if such check is needed, false - if not.
*/
bool IsNeedToUpdateExternalConsentStatus(
- const ExternalConsentStatus& status) const;
+ const ExternalConsentStatus& status) const OVERRIDE;
+
+ /**
+ * @brief Saves customer connectivity settings status
+ * @param status ExternalConsent status
+ * @return true if succeeded, otherwise - false
+ */
+ bool SetExternalConsentStatus(const ExternalConsentStatus& status) OVERRIDE;
/**
* @brief Gets customer connectivity settings status
* @return ExternalConsent status
*/
- bool SetExternalConsentStatus(const ExternalConsentStatus& status) OVERRIDE;
ExternalConsentStatus GetExternalConsentStatus() OVERRIDE;
+#ifdef BUILD_TESTS
+ /**
+ * @brief Getter for cache_manager instance
+ * @return cache_manager instance
+ */
+ inline CacheManagerInterfaceSPtr GetCache() {
+ return cache_;
+ }
+
+ /**
+ * @brief Setter for send_on_update_sent_out and wrong_ptu_update_received
+ * @param send_on_update_sent_out new value of this flag
+ * @param wrong_ptu_update_received new value of this flag
+ */
+ inline void SetSendOnUpdateFlags(const bool send_on_update_sent_out,
+ const bool wrong_ptu_update_received) {
+ send_on_update_sent_out_ = send_on_update_sent_out;
+ wrong_ptu_update_received_ = wrong_ptu_update_received;
+ }
+#endif // BUILD_TESTS
+
+ // Interface StatisticsManager (begin)
+ /**
+ * @brief Increments global counter
+ * @param type counter type
+ */
+ void Increment(usage_statistics::GlobalCounterId type) OVERRIDE;
+
+ /**
+ * @brief Increments specified application counter
+ * @param app_id Unique ID of application
+ * @param type application counter type
+ */
+ void Increment(const std::string& app_id,
+ usage_statistics::AppCounterId type) OVERRIDE;
+ /**
+ * @brief Sets specified application info value
+ * @param app_id Unique ID of application
+ * @param type application info type
+ * @param value new value for counter
+ */
+ void Set(const std::string& app_id,
+ usage_statistics::AppInfoId type,
+ const std::string& value) OVERRIDE;
+
+ /**
+ * @brief Add seconds for specified application stopwatch
+ * @param app_id Unique ID of application
+ * @param type application stopwatch type
+ * @param timespan_seconds seconds to add
+ */
+ void Add(const std::string& app_id,
+ usage_statistics::AppStopwatchId type,
+ int32_t timespan_seconds) OVERRIDE;
+ // Interface StatisticsManager (end)
+
protected:
+ /**
+ * @brief Parse policy table content and convert to PT object
+ * @param pt_content binary content of PT
+ * @return pointer to converted PT
+ */
virtual utils::SharedPtr<policy_table::Table> Parse(
const BinaryMessage& pt_content);
private:
+ /**
+ * @brief Checks if PT update should be started and schedules it if needed
+ */
void CheckTriggers();
/**
@@ -339,12 +799,73 @@ class PolicyManagerImpl : public PolicyManager {
const std::string& policy_app_id,
const std::vector<FunctionalGroupPermission>& current_permissions);
- virtual void StartPTExchange();
- virtual bool ExceededDays();
- virtual bool ExceededIgnitionCycles();
+ /**
+ * @brief StartPTExchange allows to start PTU. The function will check
+ * if one is required and starts the update flow in only case when previous
+ * condition is true.
+ */
+ void StartPTExchange() OVERRIDE;
+
+ /**
+ * @brief Checks is PT exceeded days
+ * @return true if exceeded
+ */
+ bool ExceededDays() OVERRIDE;
+
+ /**
+ * @brief Checks is PT exceeded IgnitionCycles
+ * @return true if exceeded
+ */
+ bool ExceededIgnitionCycles() OVERRIDE;
+
+ /**
+ * @brief Checks is specified policy table valid
+ * @param policy_table pointer to policy table to check
+ * @param type policy table type
+ * @return true if policy table valid, otherwise false
+ */
bool IsPTValid(utils::SharedPtr<policy_table::Table> policy_table,
policy_table::PolicyTableType type) const;
+#ifdef SDL_REMOTE_CONTROL
+ /**
+ * @brief Get resulting RPCs permissions for application which started on
+ * specific device
+ * @param device_id Device id
+ * @param policy_app_id Unique application id
+ * @param permissions Array of RPC param/HMI permissions
+ */
+ void GetPermissions(const std::string device_id,
+ const std::string application_id,
+ Permissions* data);
+
+ /**
+ * @brief Checks if module for application is present in policy table
+ * @param app_id id of application
+ * @param module type
+ * @return true if module is present, otherwise - false
+ */
+ bool CheckModule(const PTString& app_id, const PTString& module) OVERRIDE;
+
+ /**
+ * @brief Send OnPermissionsChange notification to mobile app
+ * when it's permissions are changed.
+ * @param device_id Device on which app is running
+ * @param application_id ID of app whose permissions are changed
+ */
+ void SendAppPermissionsChanged(const std::string& device_id,
+ const std::string& application_id) OVERRIDE;
+
+ /**
+ * @brief Gets all allowed module types
+ * @param policy_app_id unique identifier of application
+ * @param modules list of allowed module types
+ * @return true if application has allowed modules
+ */
+ bool GetModuleTypes(const std::string& policy_app_id,
+ std::vector<std::string>* modules) const OVERRIDE;
+#endif // SDL_REMOTE_CONTROL
+
/**
* @brief Notify application about its permissions changes by preparing and
* sending OnPermissionsChanged notification
@@ -445,11 +966,35 @@ class PolicyManagerImpl : public PolicyManager {
GroupsNames& out_allowed_groups,
GroupsNames& out_disallowed_groups) const;
+ /**
+ * @brief pointer to policy table listener for callbacks
+ */
PolicyListener* listener_;
+ /**
+ * @brief UpdateStatusManager instance for controlling PT status
+ */
UpdateStatusManager update_status_manager_;
+
+ /**
+ * @brief pointer to CacheManagerInterface instance for getting policy data
+ */
CacheManagerInterfaceSPtr cache_;
+#ifdef SDL_REMOTE_CONTROL
+ /**
+ * @brief pointer to AccessRemote instance for working with RC applications
+ */
+ utils::SharedPtr<AccessRemote> access_remote_;
+#endif
+
+ /**
+ * @brief lock guard for protecting applications list access
+ */
sync_primitives::Lock apps_registration_lock_;
+
+ /**
+ * @brief lock guard for protecting application permissions access
+ */
sync_primitives::Lock app_permissions_diff_lock_;
/**
@@ -461,22 +1006,22 @@ class PolicyManagerImpl : public PolicyManager {
PendingPermissions app_permissions_diff_;
/**
- * Timeout to wait response with UpdatePT
+ * @brief Timeout to wait response with UpdatePT
*/
- int retry_sequence_timeout_;
+ uint32_t retry_sequence_timeout_;
/**
- * Seconds between retries to update PT
+ * @brief Seconds between retries to update PT
*/
std::vector<int> retry_sequence_seconds_;
/**
- * Current index trying of retry sequence
+ * @brief Current index trying of retry sequence
*/
uint32_t retry_sequence_index_;
/**
- * Lock for guarding retry sequence
+ * @brief Lock for guarding retry sequence
*/
sync_primitives::Lock retry_sequence_lock_;
@@ -486,8 +1031,14 @@ class PolicyManagerImpl : public PolicyManager {
*/
mutable std::string last_device_id_;
+ /**
+ * @brief Flag for checking first ignition cycle
+ */
bool ignition_check;
+ /**
+ * @brief Pointer to current policy settings structure
+ */
const PolicySettings* settings_;
friend struct CheckAppPolicy;
@@ -498,8 +1049,19 @@ class PolicyManagerImpl : public PolicyManager {
RetrySequenceURL retry_sequence_url_;
friend struct ProccessAppGroups;
+ /**
+ * @brief Flag for notifying that invalid PTU was received
+ */
bool wrong_ptu_update_received_;
+
+ /**
+ * @brief Flag for notifying that PTU was started
+ */
bool send_on_update_sent_out_;
+
+ /**
+ * @brief Flag for notifying that invalid PTU should be triggered
+ */
bool trigger_ptu_;
};
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 45fad03dae..4f8ae5c98d 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
@@ -119,7 +119,9 @@ enum AppHMIType {
AHT_SOCIAL,
AHT_BACKGROUND_PROCESS,
AHT_TESTING,
- AHT_SYSTEM
+ AHT_SYSTEM,
+ AHT_PROJECTION,
+ AHT_REMOTE_CONTROL,
};
bool IsValidEnum(AppHMIType val);
const char* EnumToJsonString(AppHMIType val);
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 774ef3ee59..a460db32db 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
@@ -69,9 +69,9 @@ typedef Array<Enum<HmiLevel>, 0, 4> HmiLevels;
typedef Array<Enum<Parameter>, 0, 100> Parameters;
-typedef Map<RpcParameters, 0, 65535> Rpc;
+typedef Map<RpcParameters, 0, UINT_MAX> Rpc;
-typedef Array<String<10, 65535>, 1, 3> URL;
+typedef Array<String<10, 255>, 1, 3> URL;
typedef Map<URL, 1, 255> URLList;
@@ -102,6 +102,12 @@ typedef Map<DeviceParams, 0, 255> DeviceData;
typedef Array<Enum<RequestType>, 0, 255> RequestsTypeArray;
+#ifdef SDL_REMOTE_CONTROL
+typedef Map<Strings, 0, 255> RemoteRpcs;
+typedef Map<RemoteRpcs, 0, 255> AccessModules;
+typedef Array<Enum<ModuleType>, 0, 255> ModuleTypes;
+#endif // SDL_REMOTE_CONTROL
+
typedef AppHMIType AppHmiType;
typedef std::vector<AppHMIType> AppHmiTypes;
@@ -169,6 +175,9 @@ struct ApplicationParams : PolicyBase {
Optional<RequestTypes> RequestType;
Optional<Integer<uint16_t, 0, 65225> > memory_kb;
Optional<Integer<uint32_t, 0, UINT_MAX> > heart_beat_timeout_ms;
+#ifdef SDL_REMOTE_CONTROL
+ mutable Optional<ModuleTypes> moduleType;
+#endif // SDL_REMOTE_CONTROL
public:
ApplicationParams();
@@ -188,6 +197,9 @@ struct ApplicationParams : PolicyBase {
private:
bool Validate() const;
+#ifdef SDL_REMOTE_CONTROL
+ bool ValidateModuleTypes() const;
+#endif // SDL_REMOTE_CONTROL
};
struct ApplicationPoliciesSection : CompositeType {
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 eff8cfdf7b..9ba1a1cfff 100644
--- a/src/components/policy/policy_external/include/policy/policy_types.h
+++ b/src/components/policy/policy_external/include/policy/policy_types.h
@@ -57,7 +57,6 @@ const std::string kDefaultDeviceConnectionType = "UNKNOWN";
const std::string kPreDataConsentId = "pre_DataConsent";
const std::string kDefaultId = "default";
const std::string kDeviceId = "device";
-const std::string kPrimary = "rc_primaryDevice";
/*
*@brief Policy Services specifies Users of Updates
@@ -401,7 +400,8 @@ struct ExternalConsentStatusItem {
const EntityStatus status)
: entity_type_(type), entity_id_(id), status_(status) {}
- ExternalConsentStatusItem() {}
+ ExternalConsentStatusItem()
+ : entity_type_(0), entity_id_(0), status_(kStatusOff) {}
ExternalConsentStatusItem operator=(const ExternalConsentStatusItem& rhs) {
this->entity_id_ = rhs.entity_id_;
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 685c84742f..a69df20cfc 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
@@ -117,27 +117,15 @@ extern const std::string kSelectApplicationFull;
extern const std::string kUpdatePreloaded;
extern const std::string kUpdateRemoteControlDenied;
extern const std::string kSelectRemoteControlDenied;
-extern const std::string kDeleteAppGroupPrimaryByApplicationId;
-extern const std::string kDeleteAppGroupNonPrimaryByApplicationId;
extern const std::string kCollectFriendlyMsg;
-extern const std::string kSelectAppGroupsPrimary;
-extern const std::string kSelectAppGroupsNonPrimary;
extern const std::string kSelectModuleTypes;
-extern const std::string kInsertAppGroupPrimary;
-extern const std::string kInsertAppGroupNonPrimary;
extern const std::string kInsertModuleType;
-extern const std::string kInsertInteriorZone;
-extern const std::string kCountInteriorZones;
-extern const std::string kSelectInteriorZones;
-extern const std::string kDeleteInteriorZones;
extern const std::string kInsertAccessModule;
extern const std::string kSelectAccessModules;
extern const std::string kDeleteAccessModules;
extern const std::string kInsertRemoteRpc;
extern const std::string kSelectRemoteRpcs;
extern const std::string kDeleteRemoteRpc;
-extern const std::string kDeleteAppGroupPrimary;
-extern const std::string kDeleteAppGroupNonPrimary;
extern const std::string kDeleteModuleTypes;
extern const std::string kDeleteAllDevices;
extern const std::string kSelectDBVersion;
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 b3ce0a69be..54dfb9f0b7 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
@@ -98,6 +98,23 @@ class SQLPTRepresentation : public virtual PTRepresentation {
}
#endif // BUILD_TESTS
protected:
+#ifdef SDL_REMOTE_CONTROL
+ enum TypeAccess { kAllowed, kManual };
+ bool GatherModuleType(const std::string& app_id,
+ policy_table::ModuleTypes* module_types) const;
+ bool GatherRemoteControlDenied(const std::string& app_id, bool* denied) const;
+ bool GatherAccessModule(TypeAccess access,
+ policy_table::AccessModules* modules) const;
+ bool GatherRemoteRpc(int module_id, policy_table::RemoteRpcs* rpcs) const;
+ bool SaveModuleType(const std::string& app_id,
+ const policy_table::ModuleTypes& types);
+ bool SaveRemoteControlDenied(const std::string& app_id, bool deny);
+
+ bool SaveAccessModule(TypeAccess access,
+ const policy_table::AccessModules& modules);
+ bool SaveRemoteRpc(int module_id, const policy_table::RemoteRpcs& rpcs);
+#endif // SDL_REMOTE_CONTROL
+
virtual void GatherModuleMeta(policy_table::ModuleMeta* meta) const;
virtual void GatherModuleConfig(policy_table::ModuleConfig* config) const;
virtual bool GatherUsageAndErrorCounts(
diff --git a/src/components/policy/policy_external/include/policy/status.h b/src/components/policy/policy_external/include/policy/status.h
index 53925c599a..18789ecf99 100644
--- a/src/components/policy/policy_external/include/policy/status.h
+++ b/src/components/policy/policy_external/include/policy/status.h
@@ -53,7 +53,8 @@ enum UpdateEvent {
kOnResetPolicyTableNoUpdate,
kScheduleUpdate,
kScheduleManualUpdate,
- kOnResetRetrySequence
+ kOnResetRetrySequence,
+ kNoEvent
};
const std::string kUpToDate = "UP_TO_DATE";
diff --git a/src/components/policy/policy_external/src/access_remote_impl.cc b/src/components/policy/policy_external/src/access_remote_impl.cc
new file mode 100644
index 0000000000..d042d8c402
--- /dev/null
+++ b/src/components/policy/policy_external/src/access_remote_impl.cc
@@ -0,0 +1,261 @@
+/*
+ * Copyright (c) 2015, 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 "policy/access_remote_impl.h"
+
+#include <algorithm>
+#include <iterator>
+#include "policy/cache_manager.h"
+#include "utils/logger.h"
+
+CREATE_LOGGERPTR_GLOBAL(logger_, "PolicyManagerImpl")
+
+using policy_table::DeviceData;
+using policy_table::FunctionalGroupings;
+using rpc::policy_table_interface_base::EnumFromJsonString;
+
+namespace policy {
+
+struct ToHMIType {
+ policy_table::AppHMITypes::value_type operator()(int item) const {
+ policy_table::AppHMIType type = static_cast<policy_table::AppHMIType>(item);
+ if (!IsValidEnum(type)) {
+ LOG4CXX_WARN(logger_, "HMI type isn't known " << item);
+ type = policy_table::AHT_DEFAULT;
+ }
+ LOG4CXX_DEBUG(logger_,
+ "HMI type: " << item << " - " << EnumToJsonString(type));
+ return policy_table::AppHMITypes::value_type(type);
+ }
+};
+
+struct Contained {
+ private:
+ const policy_table::Strings& params_;
+
+ public:
+ explicit Contained(const policy_table::Strings& params) : params_(params) {}
+ bool operator()(const RemoteControlParams::value_type& item) const {
+ return std::find_if(params_.begin(), params_.end(), CompareString(item)) !=
+ params_.end();
+ }
+ struct CompareString {
+ private:
+ const RemoteControlParams::value_type& value_;
+
+ public:
+ explicit CompareString(const RemoteControlParams::value_type& value)
+ : value_(value) {}
+ bool operator()(const policy_table::Strings::value_type& item) const {
+ return value_ == static_cast<std::string>(item);
+ }
+ };
+};
+
+struct ToModuleType {
+ std::string operator()(policy_table::ModuleTypes::value_type item) const {
+ policy_table::ModuleType type = static_cast<policy_table::ModuleType>(item);
+ return EnumToJsonString(type);
+ }
+};
+
+AccessRemoteImpl::AccessRemoteImpl() : cache_(new CacheManager()) {}
+
+AccessRemoteImpl::AccessRemoteImpl(utils::SharedPtr<CacheManager> cache)
+ : cache_(cache) {}
+
+bool AccessRemoteImpl::CheckModuleType(const PTString& app_id,
+ policy_table::ModuleType module) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (!cache_->IsApplicationRepresented(app_id)) {
+ return false;
+ }
+
+ const policy_table::ApplicationParams& app =
+ cache_->pt_->policy_table.app_policies_section.apps[app_id];
+ if (!app.moduleType.is_initialized()) {
+ return false;
+ }
+
+ const policy_table::ModuleTypes& modules = *app.moduleType;
+ if (modules.empty()) {
+ return true;
+ }
+
+ return std::find(modules.begin(), modules.end(), module) != modules.end();
+}
+
+bool AccessRemoteImpl::IsAllowed(const policy_table::AccessModules& modules,
+ const std::string& module_name,
+ const std::string& rpc_name,
+ RemoteControlParams* input) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ policy_table::AccessModules::const_iterator i = modules.find(module_name);
+ if (i == modules.end()) {
+ LOG4CXX_DEBUG(logger_, "Module " << module_name << " wasn't found");
+ return false;
+ }
+
+ const policy_table::RemoteRpcs& rpcs = i->second;
+ if (rpcs.empty()) {
+ return true;
+ }
+ policy_table::RemoteRpcs::const_iterator j = rpcs.find(rpc_name);
+ if (j != rpcs.end()) {
+ const policy_table::Strings& parameters = j->second;
+ return CompareParameters(parameters, input);
+ }
+ LOG4CXX_DEBUG(logger_, "RPC " << rpc_name << " wasn't found");
+ return false;
+}
+
+bool AccessRemoteImpl::CompareParameters(
+ const policy_table::Strings& parameters, RemoteControlParams* input) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (parameters.empty()) {
+ return true;
+ }
+
+ if (input->empty()) {
+ LOG4CXX_DEBUG(logger_, "Input is empty");
+ return false;
+ }
+
+ input->erase(
+ std::remove_if(input->begin(), input->end(), Contained(parameters)),
+ input->end());
+ return input->empty();
+}
+
+void AccessRemoteImpl::SetDefaultHmiTypes(const ApplicationOnDevice& who,
+ const std::vector<int>& hmi_types) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ HMIList::mapped_type types;
+ std::transform(hmi_types.begin(),
+ hmi_types.end(),
+ std::back_inserter(types),
+ ToHMIType());
+ hmi_types_[who] = types;
+}
+
+const policy_table::AppHMITypes& AccessRemoteImpl::HmiTypes(
+ const ApplicationOnDevice& who) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (cache_->IsDefaultPolicy(who.app_id)) {
+ return hmi_types_[who];
+ } else {
+ return *cache_->pt_->policy_table.app_policies_section.apps[who.app_id]
+ .AppHMIType;
+ }
+}
+
+const policy_table::Strings& AccessRemoteImpl::GetGroups(
+ const ApplicationOnDevice& who) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ return cache_->GetGroups(who.app_id);
+}
+
+bool AccessRemoteImpl::IsAppRemoteControl(const ApplicationOnDevice& who) {
+ const policy_table::AppHMITypes& hmi_types = HmiTypes(who);
+ return std::find(hmi_types.begin(),
+ hmi_types.end(),
+ policy_table::AHT_REMOTE_CONTROL) != hmi_types.end();
+}
+
+bool AccessRemoteImpl::GetPermissionsForApp(const std::string& device_id,
+ const std::string& app_id,
+ FunctionalIdType& group_types) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ GetGroupsIds(device_id, app_id, group_types[kTypeGeneral]);
+ GetGroupsIds(device_id, kDefaultId, group_types[kTypeDefault]);
+ GetGroupsIds(
+ device_id, kPreDataConsentId, group_types[kTypePreDataConsented]);
+
+ cache_->GetPreConsentedGroups(app_id, group_types[kTypePreconsented]);
+
+ cache_->GetConsentedGroups(device_id,
+ app_id,
+ group_types[kTypeAllowed],
+ group_types[kTypeDisallowed]);
+
+ cache_->GetUnconsentedGroups(
+ device_id, app_id, group_types[kTypeUnconsented]);
+
+ cache_->GetAllAppGroups(kDeviceId, group_types[kTypeDevice]);
+ return true;
+}
+
+std::ostream& operator<<(std::ostream& output,
+ const FunctionalGroupIDs& types) {
+ std::copy(types.begin(),
+ types.end(),
+ std::ostream_iterator<FunctionalGroupIDs::value_type>(output, " "));
+ return output;
+}
+
+extern std::ostream& operator<<(std::ostream& output,
+ const policy_table::Strings& groups);
+
+void AccessRemoteImpl::GetGroupsIds(const std::string& device_id,
+ const std::string& app_id,
+ FunctionalGroupIDs& groups_ids) {
+ ApplicationOnDevice who = {device_id, app_id};
+ const policy_table::Strings& groups = GetGroups(who);
+ LOG4CXX_DEBUG(logger_, "Groups Names: " << groups);
+ groups_ids.resize(groups.size());
+ std::transform(groups.begin(),
+ groups.end(),
+ groups_ids.begin(),
+ &CacheManager::GenerateHash);
+ LOG4CXX_DEBUG(logger_, "Groups Ids: " << groups_ids);
+}
+
+bool AccessRemoteImpl::GetModuleTypes(const std::string& application_id,
+ std::vector<std::string>* modules) {
+ DCHECK(modules);
+ policy_table::ApplicationPolicies& apps =
+ cache_->pt_->policy_table.app_policies_section.apps;
+ policy_table::ApplicationPolicies::iterator i = apps.find(application_id);
+ if (i == apps.end()) {
+ return false;
+ }
+ rpc::Optional<policy_table::ModuleTypes> moduleTypes = i->second.moduleType;
+ if (!moduleTypes.is_initialized()) {
+ return false;
+ }
+ std::transform(moduleTypes->begin(),
+ moduleTypes->end(),
+ std::back_inserter(*modules),
+ ToModuleType());
+ return true;
+}
+
+} // namespace policy
diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc
index 7c247f1759..22040c88b2 100644
--- a/src/components/policy/policy_external/src/cache_manager.cc
+++ b/src/components/policy/policy_external/src/cache_manager.cc
@@ -1082,9 +1082,7 @@ bool CacheManager::SetUserPermissionsForApp(
permissions.group_permissions.begin();
std::vector<FunctionalGroupPermission>::const_iterator iter_end =
permissions.group_permissions.end();
- if (out_app_permissions_changed) {
- *out_app_permissions_changed = false;
- }
+ *out_app_permissions_changed = false;
std::string group_name;
for (; iter != iter_end; ++iter) {
diff --git a/src/components/policy/policy_external/src/policy_helper.cc b/src/components/policy/policy_external/src/policy_helper.cc
index 12a02824f2..3041323489 100644
--- a/src/components/policy/policy_external/src/policy_helper.cc
+++ b/src/components/policy/policy_external/src/policy_helper.cc
@@ -575,7 +575,6 @@ void FillNotificationData::UpdateParameters(
}
void FillNotificationData::ExcludeSame(RpcPermissions& rpc) {
- HMIPermissions& rpc_hmi_permissions = rpc.hmi_permissions;
HMIPermissions::const_iterator it_hmi_allowed =
rpc.hmi_permissions.find(kAllowedKey);
HMIPermissions::const_iterator it_hmi_undefined =
@@ -586,29 +585,28 @@ void FillNotificationData::ExcludeSame(RpcPermissions& rpc) {
// There is different logic of processing RPCs with and w/o 'parameters'
if (RpcParametersEmpty(rpc)) {
// First, remove disallowed from other types
- if (rpc_hmi_permissions.end() != it_hmi_user_disallowed) {
- if (rpc_hmi_permissions.end() != it_hmi_allowed) {
- ExcludeSameHMILevels(rpc_hmi_permissions[kAllowedKey],
- rpc_hmi_permissions[kUserDisallowedKey]);
+ if (rpc.hmi_permissions.end() != it_hmi_user_disallowed) {
+ if (rpc.hmi_permissions.end() != it_hmi_allowed) {
+ ExcludeSameHMILevels(rpc.hmi_permissions[kAllowedKey],
+ rpc.hmi_permissions[kUserDisallowedKey]);
}
- if (rpc_hmi_permissions.end() != it_hmi_undefined) {
- ExcludeSameHMILevels(rpc_hmi_permissions[kUndefinedKey],
- rpc_hmi_permissions[kUserDisallowedKey]);
+ if (rpc.hmi_permissions.end() != it_hmi_undefined) {
+ ExcludeSameHMILevels(rpc.hmi_permissions[kUndefinedKey],
+ rpc.hmi_permissions[kUserDisallowedKey]);
}
}
// Then, remove undefined from allowed
- if (rpc_hmi_permissions.end() != it_hmi_undefined) {
- if (rpc_hmi_permissions.end() != it_hmi_allowed) {
- ExcludeSameHMILevels(rpc_hmi_permissions[kAllowedKey],
- rpc_hmi_permissions[kUndefinedKey]);
+ if (rpc.hmi_permissions.end() != it_hmi_undefined) {
+ if (rpc.hmi_permissions.end() != it_hmi_allowed) {
+ ExcludeSameHMILevels(rpc.hmi_permissions[kAllowedKey],
+ rpc.hmi_permissions[kUndefinedKey]);
}
}
return;
}
- ParameterPermissions& rpc_parameter_permissions = rpc.parameter_permissions;
ParameterPermissions::const_iterator it_parameter_allowed =
rpc.parameter_permissions.find(kAllowedKey);
ParameterPermissions::const_iterator it_parameter_undefined =
@@ -619,34 +617,34 @@ void FillNotificationData::ExcludeSame(RpcPermissions& rpc) {
// First, removing allowed HMI levels from other types, permissions will be
// dependent on parameters instead of HMI levels since w/o parameters RPC
// won't passed to HMI
- if (rpc_hmi_permissions.end() != it_hmi_allowed) {
- if (rpc_hmi_permissions.end() != it_hmi_user_disallowed) {
- ExcludeSameHMILevels(rpc_hmi_permissions[kUserDisallowedKey],
- rpc_hmi_permissions[kAllowedKey]);
+ if (rpc.hmi_permissions.end() != it_hmi_allowed) {
+ if (rpc.hmi_permissions.end() != it_hmi_user_disallowed) {
+ ExcludeSameHMILevels(rpc.hmi_permissions[kUserDisallowedKey],
+ rpc.hmi_permissions[kAllowedKey]);
}
if (rpc.hmi_permissions.end() != it_hmi_undefined) {
- ExcludeSameHMILevels(rpc_hmi_permissions[kUndefinedKey],
- rpc_hmi_permissions[kAllowedKey]);
+ ExcludeSameHMILevels(rpc.hmi_permissions[kUndefinedKey],
+ rpc.hmi_permissions[kAllowedKey]);
}
}
// Removing disallowed parameters from allowed and undefined (by user consent)
- if (rpc_parameter_permissions.end() != it_parameter_user_disallowed) {
- if (rpc_parameter_permissions.end() != it_parameter_allowed) {
- ExcludeSameParameters(rpc_parameter_permissions[kAllowedKey],
- rpc_parameter_permissions[kUserDisallowedKey]);
+ if (rpc.parameter_permissions.end() != it_parameter_user_disallowed) {
+ if (rpc.parameter_permissions.end() != it_parameter_allowed) {
+ ExcludeSameParameters(rpc.parameter_permissions[kAllowedKey],
+ rpc.parameter_permissions[kUserDisallowedKey]);
}
- if (rpc_parameter_permissions.end() != it_parameter_undefined) {
- ExcludeSameParameters(rpc_parameter_permissions[kUndefinedKey],
- rpc_parameter_permissions[kUserDisallowedKey]);
+ if (rpc.parameter_permissions.end() != it_parameter_undefined) {
+ ExcludeSameParameters(rpc.parameter_permissions[kUndefinedKey],
+ rpc.parameter_permissions[kUserDisallowedKey]);
}
}
// Removing undefined (by user consent) parameters from allowed
- if (rpc_parameter_permissions.end() != it_parameter_undefined) {
- if (rpc_parameter_permissions.end() != it_parameter_allowed) {
- ExcludeSameParameters(rpc_parameter_permissions[kAllowedKey],
- rpc_parameter_permissions[kUndefinedKey]);
+ if (rpc.parameter_permissions.end() != it_parameter_undefined) {
+ if (rpc.parameter_permissions.end() != it_parameter_allowed) {
+ ExcludeSameParameters(rpc.parameter_permissions[kAllowedKey],
+ rpc.parameter_permissions[kUndefinedKey]);
}
}
}
@@ -867,4 +865,5 @@ bool UnwrapAppPolicies(policy_table::ApplicationPolicies& app_policies) {
return true;
}
-}
+
+} // namespace policy
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 2cc3f833b1..8a80e7755b 100644
--- a/src/components/policy/policy_external/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_external/src/policy_manager_impl.cc
@@ -51,6 +51,11 @@
#include "config_profile/profile.h"
#include "utils/make_shared.h"
+#ifdef SDL_REMOTE_CONTROL
+#include "policy/access_remote.h"
+#include "policy/access_remote_impl.h"
+#endif // SDL_REMOTE_CONTROL
+
policy::PolicyManager* CreateManager() {
return new policy::PolicyManagerImpl();
}
@@ -211,22 +216,32 @@ PolicyManagerImpl::PolicyManagerImpl()
: PolicyManager()
, listener_(NULL)
, cache_(new CacheManager)
+#ifdef SDL_REMOTE_CONTROL
+ , access_remote_(new AccessRemoteImpl(
+ CacheManagerInterfaceSPtr::static_pointer_cast<CacheManager>(cache_)))
+#endif // SDL_REMOTE_CONTROL
, retry_sequence_timeout_(60)
, retry_sequence_index_(0)
, ignition_check(true)
- , retry_sequence_url_(0, 0, "") {}
+ , retry_sequence_url_(0, 0, "") {
+}
PolicyManagerImpl::PolicyManagerImpl(bool in_memory)
: PolicyManager()
, listener_(NULL)
, cache_(new CacheManager(in_memory))
+#ifdef SDL_REMOTE_CONTROL
+ , access_remote_(new AccessRemoteImpl(
+ CacheManagerInterfaceSPtr::static_pointer_cast<CacheManager>(cache_)))
+#endif // SDL_REMOTE_CONTROL
, retry_sequence_timeout_(60)
, retry_sequence_index_(0)
, ignition_check(true)
, retry_sequence_url_(0, 0, "")
, wrong_ptu_update_received_(false)
, send_on_update_sent_out_(false)
- , trigger_ptu_(false) {}
+ , trigger_ptu_(false) {
+}
void PolicyManagerImpl::set_listener(PolicyListener* listener) {
listener_ = listener;
@@ -268,6 +283,9 @@ std::string PolicyManagerImpl::GetLockScreenIconUrl() const {
bool PolicyManagerImpl::LoadPT(const std::string& file,
const BinaryMessage& pt_content) {
LOG4CXX_INFO(logger_, "LoadPT of size " << pt_content.size());
+ LOG4CXX_DEBUG(
+ logger_,
+ "PTU content is: " << std::string(pt_content.begin(), pt_content.end()));
// Parse message into table struct
utils::SharedPtr<policy_table::Table> pt_update = Parse(pt_content);
@@ -578,7 +596,13 @@ void PolicyManagerImpl::CheckPermissions(const PTString& app_id,
policy_table::FunctionalGroupings functional_groupings;
cache_->GetFunctionalGroupings(functional_groupings);
- policy_table::Strings app_groups = GetGroupsNames(app_group_permissions);
+#ifdef SDL_REMOTE_CONTROL
+ ApplicationOnDevice who = {device_id, app_id};
+ const policy_table::Strings app_groups = access_remote_->GetGroups(who);
+#else // SDL_REMOTE_CONTROL
+ const policy_table::Strings app_groups =
+ GetGroupsNames(app_group_permissions);
+#endif // SDL_REMOTE_CONTROL
// Undefined groups (without user consent) disallowed by default, since
// OnPermissionsChange notification has no "undefined" section
@@ -754,6 +778,14 @@ void PolicyManagerImpl::SendNotificationOnPermissionsUpdated(
LOG4CXX_INFO(logger_,
"Send notification for application_id:" << application_id);
+#ifdef SDL_REMOTE_CONTROL
+ const ApplicationOnDevice who = {device_id, application_id};
+ if (access_remote_->IsAppRemoteControl(who)) {
+ listener()->OnPermissionsUpdated(application_id, notification_data);
+ return;
+ }
+#endif // SDL_REMOTE_CONTROL
+
std::string default_hmi;
GetDefaultHmi(application_id, &default_hmi);
@@ -1132,7 +1164,17 @@ void PolicyManagerImpl::GetPermissionsForApp(
}
FunctionalIdType group_types;
- if (!cache_->GetPermissionsForApp(device_id, app_id_to_check, group_types)) {
+
+#ifdef SDL_REMOTE_CONTROL
+ allowed_by_default = false;
+ const bool ret = access_remote_->GetPermissionsForApp(
+ device_id, app_id_to_check, group_types);
+#else
+ const bool ret =
+ cache_->GetPermissionsForApp(device_id, app_id_to_check, group_types);
+#endif // REMOTE_CONTROL
+
+ if (!ret) {
LOG4CXX_WARN(logger_,
"Can't get user permissions for app " << policy_app_id);
return;
@@ -1877,4 +1919,122 @@ void PolicyManagerImpl::set_cache_manager(
cache_ = cache_manager;
}
+std::ostream& operator<<(std::ostream& output,
+ const policy_table::Strings& groups) {
+ for (policy_table::Strings::const_iterator i = groups.begin();
+ i != groups.end();
+ ++i) {
+ output << static_cast<std::string>(*i) << " ";
+ }
+ return output;
+}
+
+#ifdef SDL_REMOTE_CONTROL
+void PolicyManagerImpl::SetDefaultHmiTypes(const std::string& application_id,
+ const std::vector<int>& hmi_types) {
+ LOG4CXX_INFO(logger_, "SetDefaultHmiTypes");
+ const std::string device_id = GetCurrentDeviceId(application_id);
+ ApplicationOnDevice who = {device_id, application_id};
+ access_remote_->SetDefaultHmiTypes(who, hmi_types);
+}
+
+struct HMITypeToInt {
+ int operator()(const policy_table::AppHMITypes::value_type item) {
+ return policy_table::AppHMIType(item);
+ }
+};
+
+bool PolicyManagerImpl::GetHMITypes(const std::string& application_id,
+ std::vector<int>* app_types) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (cache_->IsDefaultPolicy(application_id)) {
+ return false;
+ }
+ const policy_table::AppHMITypes* hmi_types =
+ cache_->GetHMITypes(application_id);
+ if (hmi_types) {
+ std::transform(hmi_types->begin(),
+ hmi_types->end(),
+ std::back_inserter(*app_types),
+ HMITypeToInt());
+ }
+ return hmi_types;
+}
+
+bool PolicyManagerImpl::CheckModule(const PTString& app_id,
+ const PTString& module) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ policy_table::ModuleType module_type;
+ return EnumFromJsonString(module, &module_type) &&
+ access_remote_->CheckModuleType(app_id, module_type);
+}
+
+void PolicyManagerImpl::SendHMILevelChanged(const ApplicationOnDevice& who) {
+ std::string default_hmi("NONE");
+ if (GetDefaultHmi(who.app_id, &default_hmi)) {
+ listener()->OnUpdateHMIStatus(who.dev_id, who.app_id, default_hmi);
+ } else {
+ LOG4CXX_WARN(logger_,
+ "Couldn't get default HMI level for application "
+ << who.app_id);
+ }
+}
+
+void PolicyManagerImpl::GetPermissions(const std::string device_id,
+ const std::string application_id,
+ Permissions* data) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ DCHECK(data);
+ std::vector<FunctionalGroupPermission> app_group_permissions;
+ GetPermissionsForApp(device_id, application_id, app_group_permissions);
+
+ policy_table::FunctionalGroupings functional_groupings;
+ cache_->GetFunctionalGroupings(functional_groupings);
+
+ policy_table::Strings app_groups;
+ std::vector<FunctionalGroupPermission>::const_iterator it =
+ app_group_permissions.begin();
+ std::vector<FunctionalGroupPermission>::const_iterator it_end =
+ app_group_permissions.end();
+ for (; it != it_end; ++it) {
+ app_groups.push_back((*it).group_name);
+ }
+
+ PrepareNotificationData(
+ functional_groupings, app_groups, app_group_permissions, *data);
+}
+
+void PolicyManagerImpl::SendAppPermissionsChanged(
+ const std::string& device_id, const std::string& application_id) {
+ Permissions notification_data;
+ GetPermissions(device_id, application_id, &notification_data);
+ listener()->OnPermissionsUpdated(application_id, notification_data);
+}
+
+void PolicyManagerImpl::OnPrimaryGroupsChanged(
+ const std::string& application_id) {
+ const std::vector<std::string> devices =
+ listener()->GetDevicesIds(application_id);
+ for (std::vector<std::string>::const_iterator i = devices.begin();
+ i != devices.end();
+ ++i) {
+ const ApplicationOnDevice who = {*i, application_id};
+ if (access_remote_->IsAppRemoteControl(who)) {
+ SendAppPermissionsChanged(who.dev_id, who.app_id);
+ }
+ }
+}
+
+bool PolicyManagerImpl::GetModuleTypes(
+ const std::string& application_id,
+ std::vector<std::string>* modules) const {
+ return access_remote_->GetModuleTypes(application_id, modules);
+}
+
+void PolicyManagerImpl::set_access_remote(
+ utils::SharedPtr<AccessRemote> access_remote) {
+ access_remote_ = access_remote;
+}
+#endif // SDL_REMOTE_CONTROL
+
} // namespace policy
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 e70167c94b..168ff86b27 100644
--- a/src/components/policy/policy_external/src/policy_table/enums.cc
+++ b/src/components/policy/policy_external/src/policy_table/enums.cc
@@ -1,4 +1,3 @@
-// This file is generated, do not edit
#include "policy/policy_table/enums.h"
namespace rpc {
@@ -438,6 +437,10 @@ bool IsValidEnum(AppHMIType val) {
return true;
case AHT_SYSTEM:
return true;
+ case AHT_PROJECTION:
+ return true;
+ case AHT_REMOTE_CONTROL:
+ return true;
default:
return false;
}
@@ -464,6 +467,10 @@ const char* EnumToJsonString(AppHMIType val) {
return "TESTING";
case AHT_SYSTEM:
return "SYSTEM";
+ case AHT_PROJECTION:
+ return "PROJECTION";
+ case AHT_REMOTE_CONTROL:
+ return "REMOTE_CONTROL";
default:
return "";
}
@@ -499,6 +506,12 @@ bool EnumFromJsonString(const std::string& literal, AppHMIType* result) {
} 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;
}
@@ -715,6 +728,41 @@ bool EnumFromJsonString(const std::string& literal, RequestType* result) {
}
}
+#ifdef SDL_REMOTE_CONTROL
+bool IsValidEnum(ModuleType val) {
+ switch (val) {
+ case MT_CLIMATE:
+ return true;
+ case MT_RADIO:
+ return true;
+ default:
+ return false;
+ }
+}
+const char* EnumToJsonString(ModuleType val) {
+ switch (val) {
+ case MT_CLIMATE:
+ return "CLIMATE";
+ case MT_RADIO:
+ return "RADIO";
+ 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 {
+ return false;
+ }
+}
+#endif // SDL_REMOTE_CONTROL
+
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 d7dd986abc..e66b2cb561 100644
--- a/src/components/policy/policy_external/src/policy_table/types.cc
+++ b/src/components/policy/policy_external/src/policy_table/types.cc
@@ -239,8 +239,12 @@ ApplicationParams::ApplicationParams(const Json::Value* value__)
, AppHMIType(impl::ValueMember(value__, "AppHMIType"))
, RequestType(impl::ValueMember(value__, "RequestType"))
, memory_kb(impl::ValueMember(value__, "memory_kb"), 0)
- , heart_beat_timeout_ms(
- impl::ValueMember(value__, "heart_beat_timeout_ms")) {}
+ , heart_beat_timeout_ms(impl::ValueMember(value__, "heart_beat_timeout_ms"))
+#ifdef SDL_REMOTE_CONTROL
+ , moduleType(impl::ValueMember(value__, "moduleType"))
+#endif // SDL_REMOTE_CONTROL
+{
+}
Json::Value ApplicationParams::ToJsonValue() const {
Json::Value result__(PolicyBase::ToJsonValue());
@@ -250,6 +254,9 @@ Json::Value ApplicationParams::ToJsonValue() const {
impl::WriteJsonField("memory_kb", memory_kb, &result__);
impl::WriteJsonField(
"heart_beat_timeout_ms", heart_beat_timeout_ms, &result__);
+#ifdef SDL_REMOTE_CONTROL
+ impl::WriteJsonField("moduleType", moduleType, &result__);
+#endif // SDL_REMOTE_CONTROL
return result__;
}
@@ -271,6 +278,11 @@ bool ApplicationParams::is_valid() const {
if (!heart_beat_timeout_ms.is_valid()) {
return false;
}
+#ifdef SDL_REMOTE_CONTROL
+ if (!moduleType.is_valid()) {
+ return false;
+ }
+#endif // SDL_REMOTE_CONTROL
return Validate();
}
@@ -297,6 +309,11 @@ bool ApplicationParams::struct_empty() const {
if (heart_beat_timeout_ms.is_initialized()) {
return false;
}
+#ifdef SDL_REMOTE_CONTROL
+ if (moduleType.is_initialized()) {
+ return false;
+ }
+#endif // SDL_REMOTE_CONTROL
return true;
}
@@ -339,6 +356,12 @@ void ApplicationParams::ReportErrors(rpc::ValidationReport* report__) const {
heart_beat_timeout_ms.ReportErrors(
&report__->ReportSubobject("heart_beat_timeout_ms"));
}
+
+#ifdef SDL_REMOTE_CONTROL
+ if (!moduleType.is_valid()) {
+ moduleType.ReportErrors(&report__->ReportSubobject("moduleType"));
+ }
+#endif // SDL_REMOTE_CONTROL
}
void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) {
@@ -347,6 +370,9 @@ void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) {
RequestType.SetPolicyTableType(pt_type);
memory_kb.SetPolicyTableType(pt_type);
heart_beat_timeout_ms.SetPolicyTableType(pt_type);
+#ifdef SDL_REMOTE_CONTROL
+ moduleType.SetPolicyTableType(pt_type);
+#endif // SDL_REMOTE_CONTROL
}
// RpcParameters methods
@@ -1660,7 +1686,7 @@ void ConsentRecords::ReportErrors(rpc::ValidationReport* report__) const {
if (!consent_groups.is_valid()) {
consent_groups.ReportErrors(&report__->ReportSubobject("consent_groups"));
}
- if (!consent_groups.is_valid()) {
+ if (!external_consent_status_groups.is_valid()) {
external_consent_status_groups.ReportErrors(
&report__->ReportSubobject("external_consent_status_groups"));
}
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 45034c6fe8..48a8578855 100644
--- a/src/components/policy/policy_external/src/policy_table/validation.cc
+++ b/src/components/policy/policy_external/src/policy_table/validation.cc
@@ -135,6 +135,39 @@ bool ApplicationPoliciesSection::Validate() const {
return true;
}
+
+#ifdef SDL_REMOTE_CONTROL
+bool ApplicationParams::ValidateModuleTypes() const {
+ // moduleType is optional so see Optional<T>::is_valid()
+ bool is_initialized = moduleType->is_initialized();
+ if (!is_initialized) {
+ // valid if not initialized
+ return true;
+ }
+ bool is_valid = moduleType->is_valid();
+ if (is_valid) {
+ return true;
+ }
+
+ struct IsInvalid {
+ bool operator()(Enum<ModuleType> item) const {
+ return !item.is_valid();
+ }
+ };
+ // cut invalid items
+ moduleType->erase(
+ std::remove_if(moduleType->begin(), moduleType->end(), IsInvalid()),
+ moduleType->end());
+ bool empty = moduleType->empty();
+ if (empty) {
+ // set non initialized value
+ ModuleTypes non_initialized;
+ moduleType = Optional<ModuleTypes>(non_initialized);
+ }
+ return true;
+}
+#endif // SDL_REMOTE_CONTROL
+
bool ApplicationParams::Validate() const {
if (is_initialized()) {
if (preconsented_groups.is_initialized()) {
@@ -145,8 +178,13 @@ bool ApplicationParams::Validate() const {
}
}
}
+#ifdef SDL_REMOTE_CONTROL
+ return ValidateModuleTypes();
+#else // SDL_REMOTE_CONTROL
return true;
+#endif // SDL_REMOTE_CONTROL
}
+
bool RpcParameters::Validate() const {
return true;
}
@@ -177,6 +215,19 @@ bool ModuleConfig::Validate() const {
default:
break;
}
+
+ for (ServiceEndpoints::const_iterator it_endpoints = endpoints.begin();
+ it_endpoints != endpoints.end();
+ ++it_endpoints) {
+ const URLList& endpoint_list = it_endpoints->second;
+ if (endpoint_list.end() == endpoint_list.find(kDefaultApp)) {
+ LOG4CXX_ERROR(logger_,
+ "Endpoint " << it_endpoints->first
+ << "does not contain default group");
+ return false;
+ }
+ }
+
return true;
}
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 1cd789f00d..e3e1029692 100644
--- a/src/components/policy/policy_external/src/sql_pt_queries.cc
+++ b/src/components/policy/policy_external/src/sql_pt_queries.cc
@@ -76,9 +76,7 @@ const std::string kCreateSchema =
" `vehicle_model` VARCHAR(45), "
" `vehicle_year` VARCHAR(4), "
" `preloaded_date` VARCHAR (10), "
- " `certificate` VARCHAR (45), "
- " `user_consent_passengersRC` BOOL,"
- " `country_consent_passengersRC` BOOL "
+ " `certificate` VARCHAR (45) "
"); "
"CREATE TABLE IF NOT EXISTS `functional_group`( "
" `id` INTEGER PRIMARY KEY NOT NULL, "
@@ -353,70 +351,12 @@ const std::string kCreateSchema =
" REFERENCES `message_type`(`name`) "
"); "
- "CREATE TABLE IF NOT EXISTS `app_group_primary`( "
- " `application_id` VARCHAR(45) NOT NULL, "
- " `functional_group_id` INTEGER NOT NULL, "
- " PRIMARY KEY(`application_id`,`functional_group_id`), "
- " CONSTRAINT `fk_application_has_functional_group_application1` "
- " FOREIGN KEY(`application_id`) "
- " REFERENCES `application`(`id`), "
- " CONSTRAINT `fk_application_has_functional_group_functional_group1` "
- " FOREIGN KEY(`functional_group_id`) "
- " REFERENCES `functional_group`(`id`) "
- "); "
- "CREATE INDEX IF NOT EXISTS "
- "`app_group_primary.fk_application_has_functional_group_functional_group1_"
- "idx` "
- " ON `app_group_primary`(`functional_group_id`); "
- "CREATE INDEX IF NOT EXISTS "
- "`app_group_primary.fk_application_has_functional_group_application1_idx` "
- " ON `app_group_primary`(`application_id`); "
-
- "CREATE TABLE IF NOT EXISTS `app_group_non_primary`( "
- " `application_id` VARCHAR(45) NOT NULL, "
- " `functional_group_id` INTEGER NOT NULL, "
- " PRIMARY KEY(`application_id`,`functional_group_id`), "
- " CONSTRAINT `fk_application_has_functional_group_application1` "
- " FOREIGN KEY(`application_id`) "
- " REFERENCES `application`(`id`), "
- " CONSTRAINT `fk_application_has_functional_group_functional_group1` "
- " FOREIGN KEY(`functional_group_id`) "
- " REFERENCES `functional_group`(`id`) "
- "); "
- "CREATE INDEX IF NOT EXISTS "
- "`app_group_non_primary.fk_application_has_functional_group_functional_"
- "group1_idx` "
- " ON `app_group_non_primary`(`functional_group_id`); "
- "CREATE INDEX IF NOT EXISTS "
- "`app_group_non_primary.fk_application_has_functional_group_application1_"
- "idx` "
- " ON `app_group_non_primary`(`application_id`); "
-
- /* interior_zone */
- "CREATE TABLE `interior_zone`( "
- " `id` INTEGER PRIMARY KEY NOT NULL, "
- " `name` VARCHAR(100) NOT NULL, "
- " `col` INTEGER NOT NULL, "
- " `row` INTEGER NOT NULL, "
- " `level` INTEGER NOT NULL "
- "); "
- "CREATE UNIQUE INDEX `interior_zone.room` ON "
- "`interior_zone`(`col`,`row`,`level`); "
-
/* access_module */
"CREATE TABLE `access_module`( "
" `id` INTEGER PRIMARY KEY NOT NULL, "
" `name` VARCHAR(45) NOT NULL, "
- " `zone_id` INTEGER NOT NULL, "
- " `user_consent_needed` INTEGER NOT NULL, "
- "CONSTRAINT `fk_module_1` "
- " FOREIGN KEY(`zone_id`) "
- " REFERENCES `interior_zone`(`id`) "
+ " `user_consent_needed` INTEGER NOT NULL "
"); "
- "CREATE INDEX `access_module.zone_module` ON "
- "`access_module`(`name`,`zone_id`); "
- "CREATE INDEX `access_module.fk_module_1_idx` ON "
- "`access_module`(`zone_id`); "
/* remote_rpc */
"CREATE TABLE `remote_rpc`( "
@@ -486,71 +426,27 @@ const std::string kInsertInitData =
"INSERT OR IGNORE INTO `_internal_data` (`db_version_hash`) VALUES(0); "
"";
-const std::string kDeleteAppGroupPrimary = "DELETE FROM `app_group_primary`";
-
-const std::string kDeleteAppGroupNonPrimary =
- "DELETE FROM `app_group_non_primary`";
-
const std::string kDeleteModuleTypes = "DELETE FROM `module_type`";
const std::string kDeleteAllDevices = "DELETE FROM `device`;";
-const std::string kSelectAppGroupsPrimary =
- "SELECT `f`.`name` FROM `app_group_primary` AS `a`"
- " LEFT JOIN `functional_group` AS `f` "
- " ON (`f`.`id` = `a`.`functional_group_id`)"
- " WHERE `a`.`application_id` = ?";
-
-const std::string kSelectAppGroupsNonPrimary =
- "SELECT `f`.`name` FROM `app_group_non_primary` AS `a`"
- " LEFT JOIN `functional_group` AS `f` "
- " ON (`f`.`id` = `a`.`functional_group_id`)"
- " WHERE `a`.`application_id` = ?";
-
const std::string kSelectRemoteControlDenied =
"SELECT `remote_control_denied` FROM `application` WHERE `id` = ? LIMIT 1";
-const std::string kInsertAppGroupPrimary =
- "INSERT INTO `app_group_primary` (`application_id`, `functional_group_id`)"
- " SELECT ?, `id` FROM `functional_group` WHERE `name` = ? LIMIT 1";
-
-const std::string kInsertAppGroupNonPrimary =
- "INSERT INTO `app_group_non_primary` (`application_id`, "
- "`functional_group_id`)"
- " SELECT ?, `id` FROM `functional_group` WHERE `name` = ? LIMIT 1";
-
const std::string kUpdateRemoteControlDenied =
"UPDATE `application` SET `remote_control_denied` = ? WHERE `id` = ?";
-const std::string kCountInteriorZones =
- "SELECT COUNT(`id`) FROM `interior_zone`";
-
-const std::string kDeleteInteriorZones = "DELETE FROM `interior_zone`";
-
const std::string kDeleteAccessModules = "DELETE FROM `access_module`";
const std::string kDeleteRemoteRpc = "DELETE FROM `remote_rpc`";
-const std::string kInsertInteriorZone =
- "INSERT INTO `interior_zone` (`name`, `col`, `row`, `level`) "
- " VALUES(?, ?, ?, ?)";
-
-const std::string kSelectInteriorZones =
- "SELECT `id`, `name`, `col`, `row`, `level` FROM `interior_zone`";
-
const std::string kInsertAccessModule =
- "INSERT INTO `access_module` (`name`, `zone_id`, `user_consent_needed`) "
+ "INSERT INTO `access_module` (`name`, `user_consent_needed`) "
" VALUES(?, ?, ?)";
-const std::string kDeleteAppGroupPrimaryByApplicationId =
- "DELETE FROM `app_group_primary` WHERE `application_id` = ?";
-
-const std::string kDeleteAppGroupNonPrimaryByApplicationId =
- "DELETE FROM `app_group_non_primary` WHERE `application_id` = ?";
-
const std::string kSelectAccessModules =
"SELECT `id`, `name` FROM `access_module` "
- " WHERE `zone_id` = ? AND `user_consent_needed` = ?";
+ " WHERE `user_consent_needed` = ?";
const std::string kInsertRemoteRpc =
"INSERT INTO `remote_rpc` (`module_id`, `name`, `parameter`) "
@@ -606,22 +502,7 @@ const std::string kDropSchema =
"`preconsented_group.fk_application_has_functional_group_functional_group2_"
"idx`; "
"DROP TABLE IF EXISTS `preconsented_group`; "
- "DROP INDEX IF EXISTS "
- "`app_group_primary.fk_application_has_functional_group_application1_idx`; "
- "DROP INDEX IF EXISTS "
- "`app_group_primary.fk_application_has_functional_group_functional_group1_"
- "idx`; "
- "DROP TABLE IF EXISTS `app_group_primary`; "
- "DROP INDEX IF EXISTS "
- "`app_group_non_primary.fk_application_has_functional_group_application1_"
- "idx`; "
- "DROP INDEX IF EXISTS "
- "`app_group_non_primary.fk_application_has_functional_group_functional_"
- "group1_idx`; "
- "DROP TABLE IF EXISTS `app_group_non_primary`; "
- "DROP TABLE IF EXISTS `interior_zone`; "
"DROP TABLE IF EXISTS `access_module`; "
- "DROP INDEX IF EXISTS `access_module.zone_module`; "
"DROP INDEX IF EXISTS `access_module.fk_module_1_idx`; "
"DROP INDEX IF EXISTS "
"`app_group.fk_application_has_functional_group_application1_idx`; "
@@ -672,9 +553,6 @@ const std::string kDeleteData =
"DELETE FROM `app_group`; "
"DELETE FROM `application`; "
"DELETE FROM `rpc`; "
- "DELETE FROM `app_group_primary`; "
- "DELETE FROM `app_group_non_primary`; "
- "DELETE FROM `interior_zone`; "
"DELETE FROM `access_module`; "
"DELETE FROM `version`; "
"DELETE FROM `message_type`; "
@@ -776,8 +654,7 @@ const std::string kUpdateModuleConfig =
" `exchange_after_x_kilometers` = ?, `exchange_after_x_days` = ?, "
" `timeout_after_x_seconds` = ?, `vehicle_make` = ?, "
" `vehicle_model` = ?, `vehicle_year` = ?, `preloaded_date` = ?, "
- "`certificate` = ?, `user_consent_passengersRC` = ?, "
- "`country_consent_passengersRC` = ?";
+ " `certificate` = ? ";
const std::string kInsertEndpoint =
"INSERT INTO `endpoint` (`service`, `url`, `application_id`) "
@@ -828,8 +705,7 @@ const std::string kSelectModuleConfig =
"SELECT `preloaded_pt`, `exchange_after_x_ignition_cycles`, "
" `exchange_after_x_kilometers`, `exchange_after_x_days`, "
" `timeout_after_x_seconds`, `vehicle_make`,"
- " `vehicle_model`, `vehicle_year`, `preloaded_date`, `certificate`, "
- " `user_consent_passengersRC` , `country_consent_passengersRC` "
+ " `vehicle_model`, `vehicle_year`, `preloaded_date`, `certificate` "
" FROM `module_config`";
const std::string kSelectEndpoints =
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 48985fa835..7f67ed82f6 100644
--- a/src/components/policy/policy_external/src/sql_pt_representation.cc
+++ b/src/components/policy/policy_external/src/sql_pt_representation.cc
@@ -224,8 +224,7 @@ int SQLPTRepresentation::DaysBeforeExchange(uint16_t current) {
return limit;
}
- if (limit < 0 || last < 0 || current < 0 || current < last ||
- limit < (current - last)) {
+ if (limit < 0 || last < 0 || current < last || limit < (current - last)) {
return 0;
}
@@ -765,6 +764,19 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection(
if (!GatherAppGroup(app_id, &params.groups)) {
return false;
}
+
+#ifdef SDL_REMOTE_CONTROL
+ bool denied = false;
+ if (!GatherRemoteControlDenied(app_id, &denied)) {
+ return false;
+ }
+ if (!denied) {
+ if (!GatherModuleType(app_id, &*params.moduleType)) {
+ return false;
+ }
+ }
+#endif // SDL_REMOTE_CONTROL
+
if (!GatherNickName(app_id, &*params.nicknames)) {
return false;
}
@@ -954,6 +966,7 @@ bool SQLPTRepresentation::SaveApplicationPoliciesSection(
LOG4CXX_WARN(logger_, "Incorrect delete from app_group.");
return false;
}
+
if (!query_delete.Exec(sql_pt::kDeleteApplication)) {
LOG4CXX_WARN(logger_, "Incorrect delete from application.");
return false;
@@ -1034,6 +1047,16 @@ bool SQLPTRepresentation::SaveSpecificAppPolicy(
if (!SaveAppGroup(app.first, app.second.groups)) {
return false;
}
+
+#ifdef SDL_REMOTE_CONTROL
+
+ bool denied = !app.second.moduleType->is_initialized();
+ if (!SaveRemoteControlDenied(app.first, denied) ||
+ !SaveModuleType(app.first, *app.second.moduleType)) {
+ return false;
+ }
+#endif // SDL_REMOTE_CONTROL
+
if (!SaveNickname(app.first, *app.second.nicknames)) {
return false;
}
@@ -1597,6 +1620,199 @@ bool SQLPTRepresentation::GatherAppGroup(
return true;
}
+#ifdef SDL_REMOTE_CONTROL
+
+bool SQLPTRepresentation::GatherRemoteControlDenied(const std::string& app_id,
+ bool* denied) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kSelectRemoteControlDenied)) {
+ LOG4CXX_WARN(logger_, "Incorrect select remote control flag");
+ return false;
+ }
+ query.Bind(0, app_id);
+ if (query.Next()) {
+ *denied = query.GetBoolean(0);
+ } else {
+ return false;
+ }
+ return true;
+}
+
+bool SQLPTRepresentation::GatherModuleType(
+ const std::string& app_id, policy_table::ModuleTypes* app_types) const {
+ dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kSelectModuleTypes)) {
+ LOG4CXX_WARN(logger_, "Incorrect select from app types");
+ return false;
+ }
+
+ query.Bind(0, app_id);
+ while (query.Next()) {
+ policy_table::ModuleType type;
+ if (!policy_table::EnumFromJsonString(query.GetString(0), &type)) {
+ return false;
+ }
+ app_types->push_back(type);
+ }
+ return true;
+}
+
+bool SQLPTRepresentation::SaveRemoteControlDenied(const std::string& app_id,
+ bool deny) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kUpdateRemoteControlDenied)) {
+ LOG4CXX_WARN(logger_, "Incorrect update statement for remote control flag");
+ return false;
+ }
+ LOG4CXX_DEBUG(logger_, "App: " << app_id << std::boolalpha << " - " << deny);
+ query.Bind(0, deny);
+ query.Bind(1, app_id);
+ if (!query.Exec()) {
+ LOG4CXX_WARN(logger_, "Incorrect update remote control flag.");
+ return false;
+ }
+ return true;
+}
+
+bool SQLPTRepresentation::SaveModuleType(
+ const std::string& app_id, const policy_table::ModuleTypes& types) {
+ dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kInsertModuleType)) {
+ LOG4CXX_WARN(logger_, "Incorrect insert statement for module type");
+ return false;
+ }
+
+ policy_table::ModuleTypes::const_iterator it;
+ for (it = types.begin(); it != types.end(); ++it) {
+ query.Bind(0, app_id);
+ std::string module(policy_table::EnumToJsonString(*it));
+ query.Bind(1, module);
+ LOG4CXX_DEBUG(logger_,
+ "Module(app: " << app_id << ", type: " << module << ")");
+ if (!query.Exec() || !query.Reset()) {
+ LOG4CXX_WARN(logger_, "Incorrect insert into module type.");
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool SQLPTRepresentation::SaveAccessModule(
+ TypeAccess access, const policy_table::AccessModules& modules) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kInsertAccessModule)) {
+ LOG4CXX_WARN(logger_, "Incorrect insert statement for access module");
+ return false;
+ }
+
+ policy_table::AccessModules::const_iterator i;
+ for (i = modules.begin(); i != modules.end(); ++i) {
+ const std::string& name = i->first;
+ const policy_table::RemoteRpcs& rpcs = i->second;
+ query.Bind(0, name);
+ query.Bind(1, access);
+ if (!query.Exec()) {
+ LOG4CXX_WARN(logger_, "Incorrect insert into access module.");
+ return false;
+ }
+ int id = query.LastInsertId();
+ if (!query.Reset()) {
+ LOG4CXX_WARN(logger_, "Couldn't reset query access module.");
+ return false;
+ }
+ if (!SaveRemoteRpc(id, rpcs)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+bool SQLPTRepresentation::GatherAccessModule(
+ TypeAccess access, policy_table::AccessModules* modules) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kSelectAccessModules)) {
+ LOG4CXX_WARN(logger_, "Incorrect select from access module");
+ return false;
+ }
+
+ query.Bind(0, access);
+ while (query.Next()) {
+ int id = query.GetInteger(0);
+ std::string name = query.GetString(1);
+ policy_table::RemoteRpcs rpcs;
+ if (!GatherRemoteRpc(id, &rpcs)) {
+ return false;
+ }
+ modules->insert(std::make_pair(name, rpcs));
+ }
+ return true;
+}
+
+bool SQLPTRepresentation::SaveRemoteRpc(int module_id,
+ const policy_table::RemoteRpcs& rpcs) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kInsertRemoteRpc)) {
+ LOG4CXX_WARN(logger_, "Incorrect insert statement for remote rpc");
+ return false;
+ }
+ policy_table::RemoteRpcs::const_iterator i;
+ for (i = rpcs.begin(); i != rpcs.end(); ++i) {
+ const std::string& name = i->first;
+ const policy_table::Strings& params = i->second;
+ policy_table::Strings::const_iterator j;
+ if (params.empty()) {
+ query.Bind(0, module_id);
+ query.Bind(1, name);
+ query.Bind(2);
+ if (!query.Exec() || !query.Reset()) {
+ LOG4CXX_WARN(logger_, "Incorrect insert into remote rpc.");
+ return false;
+ }
+ } else {
+ for (j = params.begin(); j != params.end(); ++j) {
+ const std::string& param = *j;
+ query.Bind(0, module_id);
+ query.Bind(1, name);
+ query.Bind(2, param);
+ if (!query.Exec() || !query.Reset()) {
+ LOG4CXX_WARN(logger_, "Incorrect insert into remote rpc.");
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+}
+
+bool SQLPTRepresentation::GatherRemoteRpc(
+ int module_id, policy_table::RemoteRpcs* rpcs) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kSelectRemoteRpcs)) {
+ LOG4CXX_WARN(logger_, "Incorrect select from remote rpc");
+ return false;
+ }
+
+ query.Bind(0, module_id);
+ while (query.Next()) {
+ std::string name = query.GetString(0);
+ if (!query.IsNull(1)) {
+ std::string parameter = query.GetString(1);
+ (*rpcs)[name].push_back(parameter);
+ } else {
+ rpcs->insert(std::make_pair(name, policy_table::Strings()));
+ }
+ }
+ return true;
+}
+#endif // SDL_REMOTE_CONTROL
+
bool SQLPTRepresentation::SaveApplicationCustomData(const std::string& app_id,
bool is_revoked,
bool is_default,
@@ -1700,8 +1916,9 @@ bool SQLPTRepresentation::SetDefaultPolicy(const std::string& app_id) {
}
policy_table::Strings default_groups;
- if (GatherAppGroup(kDefaultId, &default_groups) &&
- SaveAppGroup(app_id, default_groups)) {
+ bool ret = (GatherAppGroup(kDefaultId, &default_groups) &&
+ SaveAppGroup(app_id, default_groups));
+ if (ret) {
return SetIsDefault(app_id, true);
}
return false;
diff --git a/src/components/policy/policy_external/src/update_status_manager.cc b/src/components/policy/policy_external/src/update_status_manager.cc
index 8b7635c25c..087db1149b 100644
--- a/src/components/policy/policy_external/src/update_status_manager.cc
+++ b/src/components/policy/policy_external/src/update_status_manager.cc
@@ -42,6 +42,7 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "Policy")
UpdateStatusManager::UpdateStatusManager()
: listener_(NULL)
, current_status_(utils::MakeShared<UpToDateStatus>())
+ , last_processed_event_(kNoEvent)
, apps_search_in_progress_(false)
, app_registered_from_non_consented_device_(true) {
update_status_thread_delegate_ = new UpdateThreadDelegate(this);
@@ -62,6 +63,7 @@ UpdateStatusManager::~UpdateStatusManager() {
void UpdateStatusManager::ProcessEvent(UpdateEvent event) {
sync_primitives::AutoLock lock(status_lock_);
current_status_->ProcessEvent(this, event);
+ last_processed_event_ = event;
DoTransition();
}
diff --git a/src/components/policy/policy_external/test/CMakeLists.txt b/src/components/policy/policy_external/test/CMakeLists.txt
index 8b77c90dd2..a455d43b91 100644
--- a/src/components/policy/policy_external/test/CMakeLists.txt
+++ b/src/components/policy/policy_external/test/CMakeLists.txt
@@ -55,6 +55,12 @@ file (GLOB POLICY_TEST_SOURCES
list (REMOVE_ITEM POLICY_TEST_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/policy_manager_impl_stress_test.cc)
+if (REMOTE_CONTROL)
+ list (APPEND testSources
+ access_remote_impl_test.cc
+ )
+endif ()
+
create_test("policy_test" "${POLICY_TEST_SOURCES}" "${testLibraries}")
#Additional test files (json)
diff --git a/src/components/policy/policy_external/test/include/policy/mock_access_remote.h b/src/components/policy/policy_external/test/include/policy/mock_access_remote.h
new file mode 100644
index 0000000000..486c27590d
--- /dev/null
+++ b/src/components/policy/policy_external/test/include/policy/mock_access_remote.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2015, 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_TEST_INCLUDE_POLICY_MOCK_ACCESS_REMOTE_H_
+#define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_TEST_INCLUDE_POLICY_MOCK_ACCESS_REMOTE_H_
+
+#include "gmock/gmock.h"
+#include "policy/access_remote.h"
+
+namespace test {
+namespace components {
+namespace access_remote_test {
+
+class MockAccessRemote : public policy::AccessRemote {
+ public:
+ MOCK_CONST_METHOD3(
+ FindGroup,
+ policy::PTString(const policy::ApplicationOnDevice& who,
+ const policy::PTString& rpc,
+ const policy::RemoteControlParams& params));
+ MOCK_METHOD2(SetDefaultHmiTypes,
+ void(const policy::ApplicationOnDevice& who,
+ const std::vector<int>& hmi_types));
+ MOCK_METHOD1(
+ GetGroups,
+ const policy_table::Strings&(const policy::ApplicationOnDevice& who));
+ MOCK_METHOD3(GetPermissionsForApp,
+ bool(const std::string& device_id,
+ const std::string& app_id,
+ policy::FunctionalIdType& group_types));
+ MOCK_CONST_METHOD2(CheckModuleType,
+ bool(const policy::PTString& app_id,
+ policy_table::ModuleType module));
+ MOCK_METHOD1(IsAppRemoteControl,
+ bool(const policy::ApplicationOnDevice& who));
+ MOCK_METHOD2(GetModuleTypes,
+ bool(const std::string& application_id,
+ std::vector<std::string>* modules));
+};
+
+} // namespace access_remote_test
+} // namespace components
+} // namespace test
+
+#endif // SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_TEST_INCLUDE_POLICY_MOCK_ACCESS_REMOTE_H_
diff --git a/src/components/policy/policy_external/test/include/policy/mock_app_stopwatch.h b/src/components/policy/policy_external/test/include/policy/mock_app_stopwatch.h
new file mode 100644
index 0000000000..397201ce40
--- /dev/null
+++ b/src/components/policy/policy_external/test/include/policy/mock_app_stopwatch.h
@@ -0,0 +1,53 @@
+/* Copyright (c) 2016, 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_TEST_INCLUDE_POLICY_MOCK_APP_STOPWATCH_H_
+#define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_TEST_INCLUDE_POLICY_MOCK_APP_STOPWATCH_H_
+
+#include "gmock/gmock.h"
+#include "policy/usage_statistics/app_stopwatch.h"
+
+namespace test {
+namespace components {
+namespace usage_statistics_test {
+
+class MockAppStopwatch : public usage_statistics::AppStopwatch {
+ public:
+ MOCK_METHOD1(Start, void(usage_statistics::AppStopwatchId stopwatch_type));
+ MOCK_METHOD1(Switch, void(usage_statistics::AppStopwatchId stopwatch_type));
+ MOCK_METHOD0(WriteTime, void());
+};
+
+} // namespace usage_statistics_test
+} // namespace components
+} // namespace test
+
+#endif // SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_TEST_INCLUDE_POLICY_MOCK_APP_STOPWATCH_H_
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 ce34ca4400..0608799535 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
@@ -243,7 +243,7 @@ PolicyManagerImplTest2::PolicyManagerImplTest2()
, device_id_1_("XXX123456789ZZZ")
, device_id_2_("08-00-27-CE-76-FE")
, application_id_("1234")
- , app_storage_folder_("storage1")
+ , app_storage_folder_("storage_PolicyManagerImplTest2")
, preloaded_pt_filename_(kSdlPreloadedPtJson)
, in_memory_(true)
, policy_manager_(NULL)
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 a0a544deeb..a657a01145 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
@@ -85,7 +85,7 @@ class SQLPTRepresentationTest : public SQLPTRepresentation,
policy_settings_;
static void SetUpTestCase() {
- const std::string kAppStorageFolder = "storage1";
+ const std::string kAppStorageFolder = "storage_SQLPTRepresentationTest";
reps = new SQLPTRepresentation(in_memory_);
ASSERT_TRUE(reps != NULL);
policy_settings_ = std::auto_ptr<policy_handler_test::MockPolicySettings>(
@@ -407,7 +407,7 @@ TEST_F(SQLPTRepresentationTest,
query.Prepare(query_select);
query.Next();
- const int policy_tables_number = 35;
+ const int policy_tables_number = 32;
ASSERT_EQ(policy_tables_number, query.GetInteger(0));
const std::string query_select_count_of_iap_buffer_full =
diff --git a/src/components/policy/policy_regular/CMakeLists.txt b/src/components/policy/policy_regular/CMakeLists.txt
index 76e10a58b0..c7b9c068b9 100644
--- a/src/components/policy/policy_regular/CMakeLists.txt
+++ b/src/components/policy/policy_regular/CMakeLists.txt
@@ -65,12 +65,17 @@ set(EXCLUDE_PATHS
)
set(PATHS
- ${CMAKE_CURRENT_SOURCE_DIR}/include/
- ${CMAKE_CURRENT_SOURCE_DIR}/src/
+ ${CMAKE_CURRENT_SOURCE_DIR}/include
+ ${CMAKE_CURRENT_SOURCE_DIR}/src
${COMPONENTS_DIR}/rpc_base/src/rpc_base/rpc_base.cc
)
collect_sources(SOURCES "${PATHS}" "${EXCLUDE_PATHS}")
+if (NOT REMOTE_CONTROL)
+ list(REMOVE_ITEM SOURCES
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/access_remote_impl.cc)
+endif()
+
set(LIBRARIES
ConfigProfile
policy_struct
diff --git a/src/components/policy/policy_regular/include/policy/access_remote.h b/src/components/policy/policy_regular/include/policy/access_remote.h
new file mode 100644
index 0000000000..c4de9b7e1f
--- /dev/null
+++ b/src/components/policy/policy_regular/include/policy/access_remote.h
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2015, 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_ACCESS_REMOTE_H_
+#define SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_ACCESS_REMOTE_H_
+
+#include <vector>
+#include <ostream>
+#include <string>
+#include "policy/policy_table/types.h"
+#include "policy/policy_types.h"
+
+namespace policy_table = ::rpc::policy_table_interface_base;
+
+namespace policy {
+struct ApplicationOnDevice {
+ PTString dev_id;
+ PTString app_id;
+};
+inline bool operator<(const ApplicationOnDevice& x,
+ const ApplicationOnDevice& y) {
+ return x.dev_id < y.dev_id || (x.dev_id == y.dev_id && x.app_id < y.app_id);
+}
+inline bool operator==(const ApplicationOnDevice& x,
+ const ApplicationOnDevice& y) {
+ return x.dev_id == y.dev_id && x.app_id == y.app_id;
+}
+inline std::ostream& operator<<(std::ostream& output,
+ const ApplicationOnDevice& who) {
+ output << "Subject(dev:" << who.dev_id << ", app:" << who.app_id << ")";
+ return output;
+}
+
+typedef std::vector<PTString> RemoteControlParams;
+
+class AccessRemote {
+ public:
+ virtual ~AccessRemote() {}
+ /**
+ * @brief CheckModuleType check if module type is allowed for application
+ * @param app_id application id
+ * @param module module
+ * @return true if allowed, if not - false
+ */
+ virtual bool CheckModuleType(const PTString& app_id,
+ policy_table::ModuleType module) const = 0;
+
+ /**
+ * @brief SetDefaultHmiTypes setup default hmi typed for application
+ * @param who application on specific device
+ * @param hmi_types hmi types list
+ */
+ virtual void SetDefaultHmiTypes(const ApplicationOnDevice& who,
+ const std::vector<int>& hmi_types) = 0;
+
+ /**
+ * @brief GetGroups return list of groups for applicaiton
+ * @param who application on specific device
+ * @return list of groups
+ */
+ virtual const policy_table::Strings& GetGroups(
+ const ApplicationOnDevice& who) = 0;
+
+ /**
+ * @brief GetPermissionsForApp read list of permissions for application
+ * @param device_id device
+ * @param app_id application
+ * @param group_types output parameter for permissions
+ * @return true
+ */
+ virtual bool GetPermissionsForApp(const std::string& device_id,
+ const std::string& app_id,
+ FunctionalIdType& group_types) = 0;
+
+ /**
+ * @brief IsAppRemoteControl check is app is remote controll
+ * @param who application on specific device
+ * @return true is remote controll aotherwise return false
+ */
+ virtual bool IsAppRemoteControl(const ApplicationOnDevice& who) = 0;
+
+ /**
+ * @brief GetModuleTypes get list of module types of application
+ * @param policy_app_id application id
+ * @param modules output parameter for module types
+ * @return true on success otherwise false
+ */
+ virtual bool GetModuleTypes(const std::string& policy_app_id,
+ std::vector<std::string>* modules) = 0;
+};
+
+} // namespace policy
+
+#endif // SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_ACCESS_REMOTE_H_
diff --git a/src/components/policy/policy_regular/include/policy/access_remote_impl.h b/src/components/policy/policy_regular/include/policy/access_remote_impl.h
new file mode 100644
index 0000000000..933690dc49
--- /dev/null
+++ b/src/components/policy/policy_regular/include/policy/access_remote_impl.h
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2015, 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_ACCESS_REMOTE_IMPL_H_
+#define SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_ACCESS_REMOTE_IMPL_H_
+
+#include <map>
+#include "policy/policy_table/types.h"
+#include "utils/macro.h"
+#include "utils/shared_ptr.h"
+#include "policy/access_remote.h"
+#include "policy/cache_manager.h"
+
+using policy_table::FunctionalGroupings;
+
+namespace policy {
+
+class AccessRemoteImpl : public AccessRemote {
+ public:
+ AccessRemoteImpl();
+ explicit AccessRemoteImpl(utils::SharedPtr<CacheManager> cache);
+ /**
+ * @brief CheckModuleType check if module type is allowed for application
+ * @param app_id application id
+ * @param module module
+ * @return true if allowed, if not - false
+ */
+ bool CheckModuleType(const PTString& app_id,
+ policy_table::ModuleType module) const OVERRIDE;
+ /**
+ * @brief SetDefaultHmiTypes setup default hmi typed for application
+ * @param who application on specific device
+ * @param hmi_types hmi types list
+ */
+ void SetDefaultHmiTypes(const ApplicationOnDevice& who,
+ const std::vector<int>& hmi_types) OVERRIDE;
+ /**
+ * @brief GetGroups return list of groups for applicaiton
+ * @param who application on specific device
+ * @return list of groups
+ */
+ const policy_table::Strings& GetGroups(
+ const ApplicationOnDevice& who) OVERRIDE;
+
+ /**
+ * @brief GetPermissionsForApp read list of permissions for application
+ * @param device_id device
+ * @param app_id application
+ * @param group_types output parameter for permissions
+ * @return true
+ */
+ bool GetPermissionsForApp(const std::string& device_id,
+ const std::string& app_id,
+ FunctionalIdType& group_types) OVERRIDE;
+
+ /**
+ * @brief IsAppRemoteControl check is app is remote controll
+ * @param who application on specific device
+ * @return true is remote controll aotherwise return false
+ */
+ bool IsAppRemoteControl(const ApplicationOnDevice& who) OVERRIDE;
+
+ /**
+ * @brief GetModuleTypes get list of module types of application
+ * @param policy_app_id application id
+ * @param modules output parameter for module types
+ * @return true on success otherwise false
+ */
+ bool GetModuleTypes(const std::string& policy_app_id,
+ std::vector<std::string>* modules) OVERRIDE;
+
+ private:
+ /**
+ * @brief HmiTypes get list of hmi types for application
+ * @param who application on specific device
+ * @return list of hmi types
+ */
+ const policy_table::AppHMITypes& HmiTypes(const ApplicationOnDevice& who);
+
+ /**
+ * @brief GetGroupsIds get list of groups for application
+ * @param device_id device id
+ * @param app_id application id
+ * @param grops_ids output parameter for group ids storing
+ */
+ void GetGroupsIds(const std::string& device_id,
+ const std::string& app_id,
+ FunctionalGroupIDs& grops_ids);
+
+ /**
+ * @brief IsAllowed check if modulename and rpc is allowed for application
+ * @param modules list of access modules
+ * @param module_name module name to check
+ * @param rpc_name rpc name to check
+ * @param input list of rpc parameters
+ * @return true if allowed otherwise return false
+ */
+ bool IsAllowed(const policy_table::AccessModules& modules,
+ const std::string& module_name,
+ const std::string& rpc_name,
+ RemoteControlParams* input) const;
+ /**
+ * @brief CompareParameters check if app parameters allowed
+ * @param parameters list of allowed parameters
+ * @param input list of parameters to check
+ * @return true if allowed otherwise return false
+ */
+ bool CompareParameters(const policy_table::Strings& parameters,
+ RemoteControlParams* input) const;
+
+ /**
+ * @brief cache_ contains pointer to cache manager instance
+ */
+ utils::SharedPtr<CacheManager> cache_;
+
+ /**
+ * @brief hmi_types_ contains list of default HMI types for applications
+ */
+ typedef std::map<ApplicationOnDevice, policy_table::AppHMITypes> HMIList;
+ HMIList hmi_types_;
+
+#ifdef BUILD_TESTS
+ FRIEND_TEST(AccessRemoteImplTest, KeyMapTest);
+ FRIEND_TEST(AccessRemoteImplTest, Allow);
+ FRIEND_TEST(AccessRemoteImplTest, Deny);
+ FRIEND_TEST(AccessRemoteImplTest, ChangeAccess);
+ FRIEND_TEST(AccessRemoteImplTest, ResetBySubject);
+ FRIEND_TEST(AccessRemoteImplTest, ResetByObject);
+ FRIEND_TEST(AccessRemoteImplTest, CheckAllowed);
+ FRIEND_TEST(AccessRemoteImplTest, CheckDisallowed);
+ FRIEND_TEST(AccessRemoteImplTest, CheckManual);
+ FRIEND_TEST(AccessRemoteImplTest, CheckModuleType);
+ FRIEND_TEST(AccessRemoteImplTest, EnableDisable);
+ FRIEND_TEST(AccessRemoteImplTest, SetDefaultHmiTypes);
+ FRIEND_TEST(AccessRemoteImplTest, GetGroups);
+#endif // BUILD_TESTS
+};
+
+} // namespace policy
+
+#endif // SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_ACCESS_REMOTE_IMPL_H_
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 73c010ce33..c5d4c848f4 100644
--- a/src/components/policy/policy_regular/include/policy/cache_manager.h
+++ b/src/components/policy/policy_regular/include/policy/cache_manager.h
@@ -325,6 +325,13 @@ class CacheManager : public CacheManagerInterface {
bool GetDefaultHMI(const std::string& app_id, std::string& default_hmi) const;
/**
+ * Gets HMI types from specific policy
+ * @param app_id ID application
+ * @return list of HMI types
+ */
+ const policy_table::AppHMITypes* GetHMITypes(const std::string& app_id);
+
+ /**
* @brief Reset user consent for device data and applications permissions
* @return
*/
@@ -690,11 +697,9 @@ class CacheManager : public CacheManagerInterface {
const PolicySettings& get_settings() const;
-#ifdef BUILD_TESTS
- utils::SharedPtr<policy_table::Table> GetPT() const {
+ utils::SharedPtr<policy_table::Table> pt() const {
return pt_;
}
-#endif
private:
std::string currentDateTime();
@@ -767,6 +772,13 @@ class CacheManager : public CacheManagerInterface {
sync_primitives::Lock backuper_locker_;
BackgroundBackuper* backuper_;
const PolicySettings* settings_;
+
+#ifdef BUILD_TESTS
+ friend class AccessRemoteImpl;
+ FRIEND_TEST(AccessRemoteImplTest, CheckModuleType);
+ FRIEND_TEST(AccessRemoteImplTest, EnableDisable);
+ FRIEND_TEST(AccessRemoteImplTest, GetGroups);
+#endif // BUILD_TESTS
};
} // namespace policy
#endif // SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_CACHE_MANAGER_H_
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 50896bb8f1..9712b799dc 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
@@ -323,6 +323,14 @@ class CacheManagerInterface {
std::string& default_hmi) const = 0;
/**
+ * Gets HMI types from specific policy
+ * @param app_id ID application
+ * @return list of HMI types
+ */
+ virtual const policy_table::AppHMITypes* GetHMITypes(
+ const std::string& app_id) = 0;
+
+ /**
* @brief Reset user consent for device data and applications permissions
* @return
*/
@@ -626,15 +634,13 @@ class CacheManagerInterface {
*/
virtual std::string GetCertificate() const = 0;
-#ifdef BUILD_TESTS
/**
- * @brief GetPT allows to obtain SharedPtr to PT.
+ * @brief pt allows to obtain SharedPtr to PT.
* Used ONLY in Unit tests
* @return SharedPTR to PT
*
*/
- virtual utils::SharedPtr<policy_table::Table> GetPT() const = 0;
-#endif
+ virtual utils::SharedPtr<policy_table::Table> pt() const = 0;
};
typedef utils::SharedPtr<CacheManagerInterface> CacheManagerInterfaceSPtr;
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 3ca9994a8a..1b39392c0c 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
@@ -47,6 +47,10 @@
#include "policy/usage_statistics/statistics_manager.h"
#include "policy/policy_helper.h"
#include "utils/timer.h"
+#ifdef SDL_REMOTE_CONTROL
+#include "policy/access_remote.h"
+#include "policy/access_remote_impl.h"
+#endif // SDL_REMOTE_CONTROL
namespace policy_table = rpc::policy_table_interface_base;
@@ -56,185 +60,626 @@ struct CheckAppPolicy;
class PolicyManagerImpl : public PolicyManager {
public:
PolicyManagerImpl();
- virtual void set_listener(PolicyListener* listener);
+
+ /**
+ * @brief set_listener set new policy listener instance
+ * @param listener new policy listener
+ */
+ void set_listener(PolicyListener* listener) OVERRIDE;
+
+ /**
+ * @brief listener get current policy listener instance
+ * @return current policy listener
+ */
PolicyListener* listener() const {
return listener_;
}
- virtual bool InitPT(const std::string& file_name,
- const PolicySettings* settings);
- virtual bool LoadPT(const std::string& file, const BinaryMessage& pt_content);
- virtual bool ResetPT(const std::string& file_name);
-
- virtual void GetUpdateUrls(const uint32_t service_type,
- EndpointUrls& out_end_points);
- virtual void GetUpdateUrls(const std::string& service_type,
- EndpointUrls& out_end_points);
-
- virtual std::string GetLockScreenIconUrl() const;
- virtual bool RequestPTUpdate();
- virtual void CheckPermissions(const PTString& device_id,
- const PTString& app_id,
- const PTString& hmi_level,
- const PTString& rpc,
- const RPCParams& rpc_params,
- CheckPermissionResult& result) OVERRIDE;
- virtual bool ResetUserConsent();
- virtual void KmsChanged(int kilometers);
- virtual void IncrementIgnitionCycles();
- virtual std::string ForcePTExchange();
- virtual std::string ForcePTExchangeAtUserRequest();
- virtual std::string GetPolicyTableStatus() const;
- virtual void ResetRetrySequence();
- virtual uint32_t NextRetryTimeout();
- virtual uint32_t TimeoutExchangeMSec();
- virtual const std::vector<int> RetrySequenceDelaysSeconds();
- virtual void OnExceededTimeout();
- virtual void OnUpdateStarted();
- virtual void PTUpdatedAt(Counters counter, int value);
-
- /**
- * Refresh data about retry sequence from policy table
+
+ /**
+ * @brief Inits Policy Table
+ * @param file_name path to preloaded PT file
+ * @param settings pointer to policy init settings
+ * @return true if init is successful
+ */
+ bool InitPT(const std::string& file_name,
+ const PolicySettings* settings) OVERRIDE;
+
+ /**
+ * @brief Updates Policy Table from binary message received from
+ * mobile device. Saves to Policy Table diff between Policy Table
+ * sent in snapshot and received Policy Table.
+ * @param file name of file with update policy table
+ * @param pt_content PTU as binary string
+ * @return true if successfully
+ */
+ bool LoadPT(const std::string& file,
+ const BinaryMessage& pt_content) OVERRIDE;
+
+ /**
+ * @brief Resets Policy Table
+ * @param file_name Path to preloaded PT file
+ * @return true if successfully
+ */
+ bool ResetPT(const std::string& file_name) OVERRIDE;
+
+ /**
+ * @brief Gets all URLs for sending PTS to from PT itself.
+ * @param service_type Service specifies user of URL
+ * @param out_end_points output vector of urls
+ */
+ void GetUpdateUrls(const uint32_t service_type,
+ EndpointUrls& out_end_points) OVERRIDE;
+ void GetUpdateUrls(const std::string& service_type,
+ EndpointUrls& out_end_points) OVERRIDE;
+
+ /**
+ * @brief GetLockScreenIcon allows to obtain lock screen icon url;
+ * @return url which point to the resourse where lock screen icon could be
+ *obtained.
+ */
+ std::string GetLockScreenIconUrl() const OVERRIDE;
+
+ /**
+ * @brief PTU is needed, for this PTS has to be formed and sent.
+ */
+ bool RequestPTUpdate() OVERRIDE;
+
+ /**
+ * @brief Check if specified RPC for specified application
+ * has permission to be executed in specified HMI Level
+ * and also its permitted params.
+ * @param device_id Id of device of application
+ * @param app_id Id of application provided during registration
+ * @param hmi_level Current HMI Level of application
+ * @param rpc Name of RPC
+ * @param rpc_params List of RPC params
+ * @param result containing flag if HMI Level is allowed and list of
+ * allowed params.
+ */
+ void CheckPermissions(const PTString& device_id,
+ const PTString& app_id,
+ const PTString& hmi_level,
+ const PTString& rpc,
+ const RPCParams& rpc_params,
+ CheckPermissionResult& result) OVERRIDE;
+
+ /**
+ * @brief Clear all record of user consents. Used during Factory Reset.
+ * @return bool Success of operation
+ */
+ bool ResetUserConsent() OVERRIDE;
+
+ /**
+ * @brief Checks is PT exceeded kilometers
+ * @param kilometers current kilometers at odometer
+ * @return true if exceeded
+ */
+ void KmsChanged(int kilometers) OVERRIDE;
+
+ /**
+ * @brief Increments counter of ignition cycles
+ */
+ void IncrementIgnitionCycles() OVERRIDE;
+
+ /**
+ * @brief Exchange by hmi or mobile request
+ * @return Current status of policy table
+ */
+ std::string ForcePTExchange() OVERRIDE;
+
+ /**
+ * @brief Exchange by user request
+ * @return Current status of policy table
+ */
+ std::string ForcePTExchangeAtUserRequest() OVERRIDE;
+
+ /**
+ * @brief Returns current status of policy table for HMI
+ * @return Current status of policy table
+ */
+ std::string GetPolicyTableStatus() const OVERRIDE;
+
+ /**
+ * @brief Resets retry sequence
+ */
+ void ResetRetrySequence();
+
+ /**
+ * @brief Gets timeout to wait before next retry updating PT
+ * If timeout is less or equal to zero then the retry sequence is not need.
+ * @return timeout in seconds
+ */
+ uint32_t NextRetryTimeout() OVERRIDE;
+
+ /**
+ * @brief Gets timeout to wait until receive response
+ * @return timeout in seconds
+ */
+ uint32_t TimeoutExchangeMSec() OVERRIDE;
+
+ /**
+ * @brief List of timeouts in seconds between retries
+ * when attempt to update PT fails
+ * @return List of delays between attempts.
+ */
+ const std::vector<int> RetrySequenceDelaysSeconds() OVERRIDE;
+
+ /**
+ * @brief Handler of exceeding timeout of exchanging policy table
+ */
+ void OnExceededTimeout() OVERRIDE;
+
+ /**
+ * @brief Handler of PTS sending out
+ */
+ void OnUpdateStarted() OVERRIDE;
+
+ /**
+ * @brief Sets counter value that passed for receiving PT UPdate.
+ */
+ void PTUpdatedAt(Counters counter, int value) OVERRIDE;
+
+ /**
+ * @brief Refresh data about retry sequence from policy table
*/
virtual void RefreshRetrySequence();
- virtual DeviceConsent GetUserConsentForDevice(
+
+ /**
+ * @brief Gets user consent for mobile device data connection
+ * @param device_id Unique device identifier
+ * @return status of device consent
+ */
+ DeviceConsent GetUserConsentForDevice(
const std::string& device_id) const OVERRIDE;
- virtual void GetUserConsentForApp(
+
+ /**
+ * @brief Gets user consent for application
+ * @param device_id Device id
+ * @param policy_app_id Unique application id
+ * @param permissions Array of functional groups permissions
+ */
+ void GetUserConsentForApp(
const std::string& device_id,
const std::string& policy_app_id,
- std::vector<FunctionalGroupPermission>& permissions);
- virtual void SetUserConsentForDevice(const std::string& device_id,
- bool is_allowed);
- virtual bool ReactOnUserDevConsentForApp(const std::string app_id,
- bool is_device_allowed);
- virtual bool GetInitialAppData(const std::string& application_id,
- StringArray* nicknames = NULL,
- StringArray* app_hmi_types = NULL);
+ std::vector<FunctionalGroupPermission>& permissions) OVERRIDE;
- virtual void AddDevice(const std::string& device_id,
- const std::string& connection_type);
+ /**
+ * @brief Set user consent for mobile device data connection
+ * @param device_id Unique device identifier
+ * @param is_allowed User consent for usage device data connection
+ */
+ void SetUserConsentForDevice(const std::string& device_id,
+ const bool is_allowed) OVERRIDE;
- virtual void SetDeviceInfo(const std::string& device_id,
- const DeviceInfo& device_info);
+ /**
+ * @brief Update Application Policies as reaction
+ * on User allowing/disallowing device this app is running on.
+ * @param app_id Unique application id
+ * @param is_device_allowed true if user allowing device otherwise false
+ * @return true if operation was successful
+ */
+ bool ReactOnUserDevConsentForApp(const std::string app_id,
+ const bool is_device_allowed) OVERRIDE;
+
+ /**
+ * @brief Retrieves data from app_policies about app on its registration:
+ * @param application_id - id of registered app
+ * @param nicknames Synonyms for application
+ * @param app_hmi_types Section on HMI where app can appear (Navigation, Phone
+ * etc)
+ */
+ bool GetInitialAppData(const std::string& application_id,
+ StringArray* nicknames = NULL,
+ StringArray* app_hmi_types = NULL) OVERRIDE;
+
+ /**
+ * @brief Add's device to policy table
+ * @param device_id Device mac address
+ * @param connection_type Device connection type
+ */
+ void AddDevice(const std::string& device_id,
+ const std::string& connection_type) OVERRIDE;
+
+ /**
+ * @brief Stores device parameters received during application registration
+ * to policy table
+ * @param device_id Device mac address
+ * @param device_info Received device parameters
+ */
+ void SetDeviceInfo(const std::string& device_id,
+ const DeviceInfo& device_info) OVERRIDE;
- virtual void SetUserConsentForApp(const PermissionConsent& permissions);
+ /**
+ * @brief Set user consent for application functional groups
+ * @param permissions User-defined application group pemissions.
+ * The permissions is not const reference because it may contains
+ * valid data as well as invalid. So we will remove all invalid data
+ * from this structure.
+ */
+ void SetUserConsentForApp(const PermissionConsent& permissions) OVERRIDE;
- virtual bool GetDefaultHmi(const std::string& policy_app_id,
- std::string* default_hmi) const;
+ /**
+ * @brief Get default HMI level for application
+ * @param policy_app_id Unique application id
+ * @param default_hmi Default HMI level for application or empty, if value
+ * was not set
+ * @return true, if succedeed, otherwise - false
+ */
+ bool GetDefaultHmi(const std::string& policy_app_id,
+ std::string* default_hmi) const OVERRIDE;
- virtual bool GetPriority(const std::string& policy_app_id,
- std::string* priority) const;
+ /**
+ * @brief Get priority for application
+ * @param policy_app_id Unique application id
+ * @param priority Priority for application or empty, if value was not set
+ * @return true, if succedeed, otherwise - false
+ */
+ bool GetPriority(const std::string& policy_app_id,
+ std::string* priority) const OVERRIDE;
- virtual std::vector<UserFriendlyMessage> GetUserFriendlyMessages(
+ /**
+ * @brief Get user friendly messages for given RPC messages and language
+ * @param message_codes RPC message codes
+ * @param language Language
+ * @return Array of structs with appropriate message parameters
+ */
+ std::vector<UserFriendlyMessage> GetUserFriendlyMessages(
const std::vector<std::string>& message_code,
- const std::string& language);
+ const std::string& language) OVERRIDE;
- virtual bool IsApplicationRevoked(const std::string& app_id) const;
+ /**
+ * @brief Checks if the application is revoked
+ * @param app_id application id
+ * @return true if application is revoked
+ */
+ bool IsApplicationRevoked(const std::string& app_id) const OVERRIDE;
- virtual void GetPermissionsForApp(
+ /**
+ * @brief Get resulting RPCs permissions for application which started on
+ * specific device
+ * @param device_id Device id
+ * @param policy_app_id Unique application id
+ * @param permissions Array of functional groups permissions
+ */
+ void GetPermissionsForApp(
const std::string& device_id,
const std::string& policy_app_id,
- std::vector<FunctionalGroupPermission>& permissions);
+ std::vector<FunctionalGroupPermission>& permissions) OVERRIDE;
+
+ /**
+ * @brief Return device id, which hosts specific application
+ * @param policy_app_id Application id, which is required to update device id
+ */
+ std::string& GetCurrentDeviceId(
+ const std::string& policy_app_id) const OVERRIDE;
+
+ /**
+ * @brief Set current system language
+ * @param language Language
+ */
+ void SetSystemLanguage(const std::string& language) OVERRIDE;
- virtual std::string& GetCurrentDeviceId(
- const std::string& policy_app_id) const;
+ /**
+ * @brief Set data from GetSystemInfo response to policy table
+ * @param ccpu_version CCPU version
+ * @param wers_country_code WERS country code
+ * @param language System language
+ */
+ void SetSystemInfo(const std::string& ccpu_version,
+ const std::string& wers_country_code,
+ const std::string& language) OVERRIDE;
- virtual void SetSystemLanguage(const std::string& language);
+ /**
+ * @brief Runs necessary operations, which is depends on external system
+ * state, e.g. getting system-specific parameters which are need to be
+ * filled into policy table
+ */
+ void OnSystemReady() OVERRIDE;
- virtual void SetSystemInfo(const std::string& ccpu_version,
- const std::string& wers_country_code,
- const std::string& language);
- virtual void OnSystemReady();
+ /**
+ * @brief Get number of notification by priority
+ * @param priority Specified priority
+ * @return notification number
+ */
+ uint32_t GetNotificationsNumber(const std::string& priority) const OVERRIDE;
- virtual uint32_t GetNotificationsNumber(
- const std::string& priority) const OVERRIDE;
+ /**
+ * @brief Allows to update Vehicle Identification Number in policy table.
+ * @param new value for the parameter.
+ */
+ void SetVINValue(const std::string& value) OVERRIDE;
- virtual void SetVINValue(const std::string& value);
+ /**
+ * @brief Gets specific application permissions changes since last policy
+ * table update
+ * @param policy_app_id Unique application id
+ * @return Permissions changes
+ */
+ AppPermissions GetAppPermissionsChanges(
+ const std::string& policy_app_id) OVERRIDE;
- // Interface StatisticsManager (begin)
- virtual void Increment(usage_statistics::GlobalCounterId type);
- virtual void Increment(const std::string& app_id,
- usage_statistics::AppCounterId type);
- virtual void Set(const std::string& app_id,
- usage_statistics::AppInfoId type,
- const std::string& value);
- virtual void Add(const std::string& app_id,
- usage_statistics::AppStopwatchId type,
- int32_t timespan_seconds);
- // Interface StatisticsManager (end)
+ /**
+ * @brief Removes specific application permissions changes
+ * @param app_id Unique application id
+ */
+ void RemovePendingPermissionChanges(const std::string& app_id) OVERRIDE;
+
+ /**
+ * @brief Send OnPermissionsUpdated for choosen application
+ * @param application_id Unique application id
+ */
+ void SendNotificationOnPermissionsUpdated(
+ const std::string& application_id) OVERRIDE;
- AppPermissions GetAppPermissionsChanges(const std::string& policy_app_id);
- void RemovePendingPermissionChanges(const std::string& app_id);
+ /**
+ * @brief Removes unpaired device records and related records from DB
+ * @return true, if succedeed, otherwise - false
+ */
+ bool CleanupUnpairedDevices() OVERRIDE;
- void SendNotificationOnPermissionsUpdated(const std::string& application_id);
+ /**
+ * @brief Check if app can keep context.
+ * @param app_id Unique application id
+ * @return true if app can keep context, otherwise - false
+ */
+ bool CanAppKeepContext(const std::string& app_id) const OVERRIDE;
- bool CleanupUnpairedDevices();
+ /**
+ * @brief Check if app can steal focus.
+ * @param app_id Unique application id
+ * @return true if app can steal focus, otherwise - false
+ */
+ bool CanAppStealFocus(const std::string& app_id) const OVERRIDE;
- bool CanAppKeepContext(const std::string& app_id) const;
- bool CanAppStealFocus(const std::string& app_id) const;
- void MarkUnpairedDevice(const std::string& device_id);
+ /**
+ * @brief Marks device as upaired
+ * @param device_id id device
+ */
+ void MarkUnpairedDevice(const std::string& device_id) OVERRIDE;
+ /**
+ * @brief Adds, application to the db or update existed one
+ * run PTU if policy update is necessary for application.
+ * @param application_id Unique application id
+ * @param hmi_types application HMI types
+ * @return function that will notify update manager about new application
+ */
StatusNotifier AddApplication(
const std::string& application_id,
- const rpc::policy_table_interface_base::AppHmiTypes& hmi_types);
+ const rpc::policy_table_interface_base::AppHmiTypes& hmi_types) OVERRIDE;
+#ifdef SDL_REMOTE_CONTROL
+ /**
+ * @brief Assigns new HMI types for specified application
+ * @param application_id Unique application id
+ * @param hmi_types new HMI types list
+ */
+ void SetDefaultHmiTypes(const std::string& application_id,
+ const std::vector<int>& hmi_types) OVERRIDE;
+
+ /**
+ * @brief Gets HMI types
+ * @param application_id ID application
+ * @param app_types list to save HMI types
+ * @return true if policy has specific policy for this application
+ */
+ bool GetHMITypes(const std::string& application_id,
+ std::vector<int>* app_types) OVERRIDE;
+
+ /**
+ * @brief Setter for access_remote instance
+ * @param access_remote pointer to new access_remote instance
+ */
+ void set_access_remote(utils::SharedPtr<AccessRemote> access_remote) OVERRIDE;
+
+ /**
+ * @brief Sends notification about application HMI level changed
+ * @param who application information structure
+ */
+ void SendHMILevelChanged(const ApplicationOnDevice& who);
+
+ /**
+ * @brief Sends notification if application permissions were changed
+ * @param application_id Unique id of application
+ */
+ void OnPrimaryGroupsChanged(const std::string& application_id);
+#endif // SDL_REMOTE_CONTROL
+
+ /**
+ * @brief Removes consent for application functional group
+ * @param application_id Unique id of application
+ * @param group_name application functional group name
+ */
virtual void RemoveAppConsentForGroup(const std::string& app_id,
const std::string& group_name);
- virtual uint32_t HeartBeatTimeout(const std::string& app_id) const;
+ /**
+ * @brief Returns heart beat timeout
+ * @param app_id application id
+ * @return if timeout was set then value in milliseconds greater zero
+ * otherwise heart beat for specific application isn't set
+ */
+ uint32_t HeartBeatTimeout(const std::string& app_id) const OVERRIDE;
+
+ /**
+ * @brief SaveUpdateStatusRequired allows to save update status.
+ * @param is_update_needed true if update needed
+ */
+ void SaveUpdateStatusRequired(bool is_update_needed) OVERRIDE;
- virtual void SaveUpdateStatusRequired(bool is_update_needed);
+ /**
+ * @brief Checks, if application has policy assigned w/o data consent
+ * @param policy_app_id Unique application id
+ * @return true, if policy assigned w/o data consent, otherwise -false
+ */
+ bool IsPredataPolicy(const std::string& policy_app_id) const OVERRIDE;
- virtual bool IsPredataPolicy(const std::string& policy_app_id) const OVERRIDE;
+ /**
+ * @brief Setter for cache_manager instance
+ * @param cache_manager pointer to new cache_manager instance
+ */
void set_cache_manager(CacheManagerInterface* cache_manager);
- virtual void OnAppsSearchStarted();
+ /**
+ * @brief Handler on applications search started
+ */
+ void OnAppsSearchStarted() OVERRIDE;
+
+ /**
+ * @brief Handler on applications search completed
+ * @param trigger_ptu contains true if PTU should be triggered
+ */
+ void OnAppsSearchCompleted(const bool trigger_ptu) OVERRIDE;
+
+ /**
+ * @brief Gets request types for application
+ * @param policy_app_id Unique application id
+ * @return request types of application
+ */
+ const std::vector<std::string> GetAppRequestTypes(
+ const std::string policy_app_id) const OVERRIDE;
+
+ /**
+ * @brief Get information about vehicle
+ * @return vehicle information
+ */
+ const VehicleInfo GetVehicleInfo() const OVERRIDE;
+
+ /**
+ * @brief OnAppRegisteredOnMobile allows to handle event when application were
+ * succesfully registered on mobile device.
+ * It will send OnAppPermissionSend notification and will try to start PTU. *
+ * @param application_id registered application.
+ */
+ void OnAppRegisteredOnMobile(const std::string& application_id) OVERRIDE;
- virtual void OnAppsSearchCompleted(const bool trigger_ptu);
+ /**
+ * @brief RetrieveCertificate Allows to obtain certificate in order
+ * to start secure connection.
+ * @return The certificate in PKCS#7 format.
+ */
+ std::string RetrieveCertificate() const OVERRIDE;
+
+ /**
+ * @brief HasCertificate check whether policy table has certificate
+ * int module_config section.
+ * @return true in case certificate exists, false otherwise
+ */
+ bool HasCertificate() const OVERRIDE;
+
+ /**
+ * @brief Finds the next URL that must be sent on OnSystemRequest retry
+ * @param urls vector of vectors that contain urls for each application
+ * @return Pair of policy application id and application url id from the
+ * urls vector
+ */
+ AppIdURL GetNextUpdateUrl(const EndpointUrls& urls) OVERRIDE;
+
+ /**
+ * @brief Checks if there is existing URL in the EndpointUrls vector with
+ * index saved in the policy manager and if not, it moves to the next
+ * application index
+ * @param rs contains the application index and url index from the
+ * urls vector that are to be sent on the next OnSystemRequest
+ * @param urls vector of vectors that contain urls for each application
+ * @return Pair of application index and url index
+ */
+ AppIdURL RetrySequenceUrl(const struct RetrySequenceURL& rs,
+ const EndpointUrls& urls) const OVERRIDE;
#ifdef BUILD_TESTS
+ /**
+ * @brief Getter for cache_manager instance
+ * @return cache_manager instance
+ */
inline CacheManagerInterfaceSPtr GetCache() {
return cache_;
}
+ /**
+ * @brief Setter for send_on_update_sent_out
+ * @param send_on_update_sent_out new value of this flag
+ */
inline void SetSendOnUpdateSentOut(const bool send_on_update_sent_out) {
send_on_update_sent_out_ = send_on_update_sent_out;
}
#endif // BUILD_TESTS
- virtual const std::vector<std::string> GetAppRequestTypes(
- const std::string policy_app_id) const;
- virtual const VehicleInfo GetVehicleInfo() const;
-
- virtual void OnAppRegisteredOnMobile(
- const std::string& application_id) OVERRIDE;
-
- virtual std::string RetrieveCertificate() const OVERRIDE;
+ // Interface StatisticsManager (begin)
+ /**
+ * @brief Increments global counter
+ * @param type counter type
+ */
+ void Increment(usage_statistics::GlobalCounterId type) OVERRIDE;
- virtual bool HasCertificate() const OVERRIDE;
+ /**
+ * @brief Increments specified application counter
+ * @param app_id Unique ID of application
+ * @param type application counter type
+ */
+ void Increment(const std::string& app_id,
+ usage_statistics::AppCounterId type) OVERRIDE;
- AppIdURL GetNextUpdateUrl(const EndpointUrls& urls) OVERRIDE;
+ /**
+ * @brief Sets specified application info value
+ * @param app_id Unique ID of application
+ * @param type application info type
+ * @param value new value for counter
+ */
+ void Set(const std::string& app_id,
+ usage_statistics::AppInfoId type,
+ const std::string& value) OVERRIDE;
- AppIdURL RetrySequenceUrl(const struct RetrySequenceURL& rs,
- const EndpointUrls& urls) const OVERRIDE;
+ /**
+ * @brief Add seconds for specified application stopwatch
+ * @param app_id Unique ID of application
+ * @param type application stopwatch type
+ * @param timespan_seconds seconds to add
+ */
+ void Add(const std::string& app_id,
+ usage_statistics::AppStopwatchId type,
+ int32_t timespan_seconds) OVERRIDE;
+ // Interface StatisticsManager (end)
protected:
#ifdef USE_HMI_PTU_DECRYPTION
+ /**
+ * @brief Parse policy table content and convert to PT object
+ * @param pt_content binary content of PT
+ * @return pointer to converted PT
+ */
virtual utils::SharedPtr<policy_table::Table> Parse(
const BinaryMessage& pt_content);
#else
+ /**
+ * @brief Parse policy table content and convert to PT object
+ * @param pt_content binary content of PT
+ * @return pointer to converted PT
+ */
virtual utils::SharedPtr<policy_table::Table> ParseArray(
const BinaryMessage& pt_content);
#endif
+ /**
+ * @brief Getter for policy settings
+ * @return policy settings instance
+ */
const PolicySettings& get_settings() const OVERRIDE;
private:
+ /**
+ * @brief Checks if PT update should be started and schedules it if needed
+ */
void CheckTriggers();
- /*
- * @brief Checks policy table update along with current data for any changes
- * in assigned functional group list of application
- *
- * @param Policy table update struct
+
+ /**
+ * @brief Compares current applications policies to the updated one and
+ * returns apporopriate result codes per application, which that are being
+ * processed by sending notification to applications registered and to the
+ * system
+ * @param update Shared pointer to policy table udpate
+ * @param snapshot Shared pointer to current copy of policy table
+ * @return Collection per-application results
*/
void CheckPermissionsChanges(
const utils::SharedPtr<policy_table::Table> update,
@@ -310,46 +755,140 @@ class PolicyManagerImpl : public PolicyManager {
const std::string& policy_app_id,
const std::vector<FunctionalGroupPermission>& current_permissions);
- virtual void StartPTExchange();
- virtual bool ExceededDays();
- virtual bool ExceededIgnitionCycles();
+ /**
+ * @brief StartPTExchange allows to start PTU. The function will check
+ * if one is required and starts the update flow in only case when previous
+ * condition is true.
+ */
+ void StartPTExchange() OVERRIDE;
+
+ /**
+ * @brief Checks is PT exceeded days
+ * @return true if exceeded
+ */
+ bool ExceededDays() OVERRIDE;
+
+ /**
+ * @brief Checks is PT exceeded IgnitionCycles
+ * @return true if exceeded
+ */
+ bool ExceededIgnitionCycles() OVERRIDE;
+
+ /**
+ * @brief Checks is specified policy table valid
+ * @param policy_table pointer to policy table to check
+ * @param type policy table type
+ * @return true if policy table valid, otherwise false
+ */
bool IsPTValid(utils::SharedPtr<policy_table::Table> policy_table,
policy_table::PolicyTableType type) const;
+ /**
+ * @brief Starts new retry sequence
+ */
void RetrySequence();
private:
+#ifdef SDL_REMOTE_CONTROL
+ /**
+ * @brief Get resulting RPCs permissions for application which started on
+ * specific device
+ * @param device_id Device id
+ * @param policy_app_id Unique application id
+ * @param permissions Array of RPC param/HMI permissions
+ */
+ void GetPermissions(const std::string device_id,
+ const std::string application_id,
+ Permissions* data);
+
+ /**
+ * @brief Checks if module for application is present in policy table
+ * @param app_id id of application
+ * @param module type
+ * @return true if module is present, otherwise - false
+ */
+ bool CheckModule(const PTString& app_id, const PTString& module) OVERRIDE;
+
+ /**
+ * @brief Send OnPermissionsChange notification to mobile app
+ * when it's permissions are changed.
+ * @param device_id Device on which app is running
+ * @param application_id ID of app whose permissions are changed
+ */
+ void SendAppPermissionsChanged(const std::string& device_id,
+ const std::string& application_id) OVERRIDE;
+
+ /**
+ * @brief Gets all allowed module types
+ * @param policy_app_id unique identifier of application
+ * @param modules list of allowed module types
+ * @return true if application has allowed modules
+ */
+ bool GetModuleTypes(const std::string& policy_app_id,
+ std::vector<std::string>* modules) const OVERRIDE;
+#endif // SDL_REMOTE_CONTROL
+ /**
+ * @brief pointer to policy table listener for callbacks
+ */
PolicyListener* listener_;
+ /**
+ * @brief UpdateStatusManager instance for controlling PT status
+ */
UpdateStatusManager update_status_manager_;
+
+ /**
+ * @brief pointer to CacheManagerInterface instance for getting policy data
+ */
CacheManagerInterfaceSPtr cache_;
+#ifdef SDL_REMOTE_CONTROL
+ /**
+ * @brief pointer to AccessRemote instance for working with RC applications
+ */
+ utils::SharedPtr<AccessRemote> access_remote_;
+#endif
+
+ /**
+ * @brief lock guard for protecting applications list access
+ */
sync_primitives::Lock apps_registration_lock_;
+
+ /**
+ * @brief lock guard for protecting application permissions access
+ */
sync_primitives::Lock app_permissions_diff_lock_;
- std::map<std::string, AppPermissions> app_permissions_diff_;
/**
- * Timeout to wait response with UpdatePT (msec)
+ * @brief Collection of parameters to be reported to the system with
+ * SDL.ActivateApp response or OnAppPermissionsChanged notification
+ * Being set during policy table update processing
+ */
+ typedef std::map<std::string, AppPermissions> PendingPermissions;
+ PendingPermissions app_permissions_diff_;
+
+ /**
+ * @brief Timeout to wait response with UpdatePT
*/
uint32_t retry_sequence_timeout_;
/**
- * Seconds between retries to update PT
+ * @brief Seconds between retries to update PT
*/
std::vector<int> retry_sequence_seconds_;
/**
- * Current index trying of retry sequence
+ * @brief Current index trying of retry sequence
*/
uint32_t retry_sequence_index_;
/**
- * Lock for guarding retry sequence
+ * @brief Lock for guarding retry sequence
*/
sync_primitives::Lock retry_sequence_lock_;
/**
- * Timer to retry UpdatePT
- */
+ * @brief Timer to retry UpdatePT
+ */
timer::Timer timer_retry_sequence_;
/**
@@ -358,8 +897,14 @@ class PolicyManagerImpl : public PolicyManager {
*/
mutable std::string last_device_id_;
+ /**
+ * @brief Flag for checking first ignition cycle
+ */
bool ignition_check;
+ /**
+ * @brief Pointer to current policy settings structure
+ */
const PolicySettings* settings_;
friend struct CheckAppPolicy;
friend struct ProccessAppGroups;
@@ -370,8 +915,19 @@ class PolicyManagerImpl : public PolicyManager {
*/
RetrySequenceURL retry_sequence_url_;
+ /**
+ * @brief Flag for notifying that invalid PTU was received
+ */
bool wrong_ptu_update_received_;
+
+ /**
+ * @brief Flag for notifying that PTU was started
+ */
bool send_on_update_sent_out_;
+
+ /**
+ * @brief Flag for notifying that invalid PTU should be triggered
+ */
bool trigger_ptu_;
};
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 0554e94722..66ab9a1b60 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
@@ -104,7 +104,8 @@ enum AppHMIType {
AHT_BACKGROUND_PROCESS,
AHT_TESTING,
AHT_SYSTEM,
- AHT_REMOTE_CONTROL,
+ AHT_PROJECTION,
+ AHT_REMOTE_CONTROL
};
bool IsValidEnum(AppHMIType val);
const char* EnumToJsonString(AppHMIType val);
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 66fddee592..b1e9dd5401 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
@@ -67,9 +67,9 @@ typedef Array<Enum<HmiLevel>, 0, 4> HmiLevels;
typedef Array<Enum<Parameter>, 0, 24> Parameters;
-typedef Map<RpcParameters, 0, 50> Rpc;
+typedef Map<RpcParameters, 0, UINT_MAX> Rpc;
-typedef Array<String<10, 255>, 1, 255> URL;
+typedef Array<String<10, 255>, 1, 3> URL;
typedef Map<URL, 1, 255> URLList;
@@ -79,7 +79,7 @@ typedef uint8_t NumberOfNotificationsType;
typedef Map<Integer<NumberOfNotificationsType, 0, 255>, 0, 6>
NumberOfNotificationsPerMinute;
-typedef Array<Integer<uint16_t, 1, 1000>, 0, 10> SecondsBetweenRetries;
+typedef Array<Integer<uint16_t, 1, 1000>, 0, 5> SecondsBetweenRetries;
typedef Map<MessageString, 0, 500> Languages;
@@ -96,6 +96,12 @@ typedef Map<DeviceParams, 0, 255> DeviceData;
typedef Array<Enum<RequestType>, 0, 255> RequestTypes;
+#ifdef SDL_REMOTE_CONTROL
+typedef Map<Strings, 0, 255> RemoteRpcs;
+typedef Map<RemoteRpcs, 0, 255> AccessModules;
+typedef Array<Enum<ModuleType>, 0, 255> ModuleTypes;
+#endif // SDL_REMOTE_CONTROL
+
typedef AppHMIType AppHmiType;
typedef std::vector<AppHMIType> AppHmiTypes;
@@ -136,6 +142,9 @@ struct ApplicationParams : PolicyBase {
Optional<Integer<uint16_t, 0, 65225> > memory_kb;
Optional<Integer<uint32_t, 0, UINT_MAX> > heart_beat_timeout_ms;
Optional<String<0, 255> > certificate;
+#ifdef SDL_REMOTE_CONTROL
+ mutable Optional<ModuleTypes> moduleType;
+#endif // SDL_REMOTE_CONTROL
public:
ApplicationParams();
@@ -151,6 +160,9 @@ struct ApplicationParams : PolicyBase {
private:
bool Validate() const;
+#ifdef SDL_REMOTE_CONTROL
+ bool ValidateModuleTypes() const;
+#endif // SDL_REMOTE_CONTROL
};
struct ApplicationPoliciesSection : CompositeType {
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 79a66ba41a..2ded25e456 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
@@ -114,6 +114,19 @@ extern const std::string kInsertApplicationFull;
extern const std::string kDeletePreconsentedGroupsByApplicationId;
extern const std::string kSelectApplicationFull;
extern const std::string kUpdatePreloaded;
+extern const std::string kUpdateRemoteControlDenied;
+extern const std::string kSelectRemoteControlDenied;
+extern const std::string kCollectFriendlyMsg;
+extern const std::string kSelectModuleTypes;
+extern const std::string kInsertModuleType;
+extern const std::string kInsertAccessModule;
+extern const std::string kSelectAccessModules;
+extern const std::string kDeleteAccessModules;
+extern const std::string kInsertRemoteRpc;
+extern const std::string kSelectRemoteRpcs;
+extern const std::string kDeleteRemoteRpc;
+extern const std::string kDeleteModuleTypes;
+extern const std::string kDeleteAllDevices;
extern const std::string kSelectDBVersion;
extern const std::string kUpdateDBVersion;
extern const std::string kSaveModuleMeta;
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 bd867389ab..6b5d6111f1 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
@@ -97,6 +97,23 @@ class SQLPTRepresentation : public virtual PTRepresentation {
}
#endif // BUILD_TESTS
protected:
+#ifdef SDL_REMOTE_CONTROL
+ enum TypeAccess { kAllowed, kManual };
+ bool GatherModuleType(const std::string& app_id,
+ policy_table::ModuleTypes* module_types) const;
+ bool GatherRemoteControlDenied(const std::string& app_id, bool* denied) const;
+ bool GatherAccessModule(TypeAccess access,
+ policy_table::AccessModules* modules) const;
+ bool GatherRemoteRpc(int module_id, policy_table::RemoteRpcs* rpcs) const;
+ bool SaveModuleType(const std::string& app_id,
+ const policy_table::ModuleTypes& types);
+ bool SaveRemoteControlDenied(const std::string& app_id, bool deny);
+
+ bool SaveAccessModule(TypeAccess access,
+ const policy_table::AccessModules& modules);
+ bool SaveRemoteRpc(int module_id, const policy_table::RemoteRpcs& rpcs);
+#endif // SDL_REMOTE_CONTROL
+
virtual void GatherModuleMeta(policy_table::ModuleMeta* meta) const;
virtual void GatherModuleConfig(policy_table::ModuleConfig* config) const;
virtual bool GatherUsageAndErrorCounts(
diff --git a/src/components/policy/policy_regular/include/policy/status.h b/src/components/policy/policy_regular/include/policy/status.h
index 074e3c1eef..c1ea2de4c1 100644
--- a/src/components/policy/policy_regular/include/policy/status.h
+++ b/src/components/policy/policy_regular/include/policy/status.h
@@ -53,7 +53,8 @@ enum UpdateEvent {
kOnResetPolicyTableNoUpdate,
kScheduleUpdate,
kScheduleManualUpdate,
- kOnResetRetrySequence
+ kOnResetRetrySequence,
+ kNoEvent
};
const std::string kUpToDate = "UP_TO_DATE";
diff --git a/src/components/policy/policy_regular/include/policy/update_status_manager.h b/src/components/policy/policy_regular/include/policy/update_status_manager.h
index 89c6b7e7bb..a68d986d10 100644
--- a/src/components/policy/policy_regular/include/policy/update_status_manager.h
+++ b/src/components/policy/policy_regular/include/policy/update_status_manager.h
@@ -83,9 +83,8 @@ class UpdateStatusManager : public UpdateStatusManagerInterface {
/**
* @brief Update status hanlder for PTS sending out
- * @param update_timeout Timeout for waiting of incoming PTU (msec)
*/
- void OnUpdateSentOut(uint32_t update_timeout);
+ void OnUpdateSentOut();
/**
* @brief Update status handler for PTU waiting timeout
@@ -216,24 +215,6 @@ class UpdateStatusManager : public UpdateStatusManagerInterface {
bool apps_search_in_progress_;
bool app_registered_from_non_consented_device_;
sync_primitives::Lock apps_search_in_progress_lock_;
-
- class UpdateThreadDelegate : public threads::ThreadDelegate {
- public:
- UpdateThreadDelegate(UpdateStatusManager* update_status_manager);
- ~UpdateThreadDelegate();
- virtual void threadMain();
- virtual void exitThreadMain();
- void updateTimeOut(const uint32_t timeout_ms);
-
- volatile uint32_t timeout_;
- volatile bool stop_flag_;
- sync_primitives::Lock state_lock_;
- sync_primitives::ConditionalVariable termination_condition_;
- UpdateStatusManager* update_status_manager_;
- };
-
- UpdateThreadDelegate* update_status_thread_delegate_;
- threads::Thread* thread_;
};
}
diff --git a/src/components/policy/policy_regular/include/policy/update_status_manager_interface.h b/src/components/policy/policy_regular/include/policy/update_status_manager_interface.h
index e8da7b9b69..e118f9974f 100644
--- a/src/components/policy/policy_regular/include/policy/update_status_manager_interface.h
+++ b/src/components/policy/policy_regular/include/policy/update_status_manager_interface.h
@@ -71,9 +71,8 @@ class UpdateStatusManagerInterface {
/**
* @brief Update status hanlder for PTS sending out
- * @param update_timeout Timeout for waiting of incoming PTU
*/
- virtual void OnUpdateSentOut(uint32_t update_timeout) = 0;
+ virtual void OnUpdateSentOut() = 0;
/**
* @brief Update status handler for PTU waiting timeout
diff --git a/src/components/policy/policy_regular/src/access_remote_impl.cc b/src/components/policy/policy_regular/src/access_remote_impl.cc
new file mode 100644
index 0000000000..f99b226f2e
--- /dev/null
+++ b/src/components/policy/policy_regular/src/access_remote_impl.cc
@@ -0,0 +1,247 @@
+/*
+ * Copyright (c) 2015, 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 "policy/access_remote_impl.h"
+
+#include <algorithm>
+#include <iterator>
+#include "policy/cache_manager.h"
+#include "utils/logger.h"
+
+CREATE_LOGGERPTR_GLOBAL(logger_, "PolicyManagerImpl")
+
+using policy_table::DeviceData;
+using policy_table::FunctionalGroupings;
+using rpc::policy_table_interface_base::EnumFromJsonString;
+
+namespace policy {
+
+struct ToHMIType {
+ policy_table::AppHMITypes::value_type operator()(int item) const {
+ policy_table::AppHMIType type = static_cast<policy_table::AppHMIType>(item);
+ if (!IsValidEnum(type)) {
+ LOG4CXX_WARN(logger_, "HMI type isn't known " << item);
+ type = policy_table::AHT_DEFAULT;
+ }
+ LOG4CXX_DEBUG(logger_,
+ "HMI type: " << item << " - " << EnumToJsonString(type));
+ return policy_table::AppHMITypes::value_type(type);
+ }
+};
+
+struct Contained {
+ private:
+ const policy_table::Strings& params_;
+
+ public:
+ explicit Contained(const policy_table::Strings& params) : params_(params) {}
+ bool operator()(const RemoteControlParams::value_type& item) const {
+ return std::find_if(params_.begin(), params_.end(), CompareString(item)) !=
+ params_.end();
+ }
+ struct CompareString {
+ private:
+ const RemoteControlParams::value_type& value_;
+
+ public:
+ explicit CompareString(const RemoteControlParams::value_type& value)
+ : value_(value) {}
+ bool operator()(const policy_table::Strings::value_type& item) const {
+ return value_ == static_cast<std::string>(item);
+ }
+ };
+};
+
+struct ToModuleType {
+ std::string operator()(policy_table::ModuleTypes::value_type item) const {
+ policy_table::ModuleType type = static_cast<policy_table::ModuleType>(item);
+ return EnumToJsonString(type);
+ }
+};
+
+AccessRemoteImpl::AccessRemoteImpl() : cache_(new CacheManager()) {}
+
+AccessRemoteImpl::AccessRemoteImpl(utils::SharedPtr<CacheManager> cache)
+ : cache_(cache) {}
+
+bool AccessRemoteImpl::CheckModuleType(const PTString& app_id,
+ policy_table::ModuleType module) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (!cache_->IsApplicationRepresented(app_id)) {
+ return false;
+ }
+
+ const policy_table::ApplicationParams& app =
+ cache_->pt()->policy_table.app_policies_section.apps[app_id];
+ if (!app.moduleType.is_initialized()) {
+ return false;
+ }
+
+ const policy_table::ModuleTypes& modules = *app.moduleType;
+ if (modules.empty()) {
+ return true;
+ }
+
+ return std::find(modules.begin(), modules.end(), module) != modules.end();
+}
+
+bool AccessRemoteImpl::IsAllowed(const policy_table::AccessModules& modules,
+ const std::string& module_name,
+ const std::string& rpc_name,
+ RemoteControlParams* input) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ policy_table::AccessModules::const_iterator i = modules.find(module_name);
+ if (i == modules.end()) {
+ LOG4CXX_DEBUG(logger_, "Module " << module_name << " wasn't found");
+ return false;
+ }
+
+ const policy_table::RemoteRpcs& rpcs = i->second;
+ if (rpcs.empty()) {
+ return true;
+ }
+ policy_table::RemoteRpcs::const_iterator j = rpcs.find(rpc_name);
+ if (j != rpcs.end()) {
+ const policy_table::Strings& parameters = j->second;
+ return CompareParameters(parameters, input);
+ }
+ LOG4CXX_DEBUG(logger_, "RPC " << rpc_name << " wasn't found");
+ return false;
+}
+
+bool AccessRemoteImpl::CompareParameters(
+ const policy_table::Strings& parameters, RemoteControlParams* input) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (parameters.empty()) {
+ return true;
+ }
+
+ if (input->empty()) {
+ LOG4CXX_DEBUG(logger_, "Input is empty");
+ return false;
+ }
+
+ input->erase(
+ std::remove_if(input->begin(), input->end(), Contained(parameters)),
+ input->end());
+ return input->empty();
+}
+
+void AccessRemoteImpl::SetDefaultHmiTypes(const ApplicationOnDevice& who,
+ const std::vector<int>& hmi_types) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ HMIList::mapped_type types;
+ std::transform(hmi_types.begin(),
+ hmi_types.end(),
+ std::back_inserter(types),
+ ToHMIType());
+ hmi_types_[who] = types;
+}
+
+const policy_table::AppHMITypes& AccessRemoteImpl::HmiTypes(
+ const ApplicationOnDevice& who) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (cache_->IsDefaultPolicy(who.app_id)) {
+ return hmi_types_[who];
+ } else {
+ return *cache_->pt()
+ ->policy_table.app_policies_section.apps[who.app_id]
+ .AppHMIType;
+ }
+}
+
+const policy_table::Strings& AccessRemoteImpl::GetGroups(
+ const ApplicationOnDevice& who) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ return cache_->GetGroups(who.app_id);
+}
+
+bool AccessRemoteImpl::IsAppRemoteControl(const ApplicationOnDevice& who) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ const policy_table::AppHMITypes& hmi_types = HmiTypes(who);
+ return std::find(hmi_types.begin(),
+ hmi_types.end(),
+ policy_table::AHT_REMOTE_CONTROL) != hmi_types.end();
+}
+
+bool AccessRemoteImpl::GetPermissionsForApp(const std::string& device_id,
+ const std::string& app_id,
+ FunctionalIdType& group_types) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ GetGroupsIds(device_id, app_id, group_types[kTypeGeneral]);
+ GetGroupsIds(device_id, kDefaultId, group_types[kTypeDefault]);
+ GetGroupsIds(
+ device_id, kPreDataConsentId, group_types[kTypePreDataConsented]);
+ return true;
+}
+
+std::ostream& operator<<(std::ostream& output,
+ const FunctionalGroupIDs& types) {
+ std::copy(types.begin(),
+ types.end(),
+ std::ostream_iterator<FunctionalGroupIDs::value_type>(output, " "));
+ return output;
+}
+
+void AccessRemoteImpl::GetGroupsIds(const std::string& device_id,
+ const std::string& app_id,
+ FunctionalGroupIDs& groups_ids) {
+ ApplicationOnDevice who = {device_id, app_id};
+ const policy_table::Strings& groups = GetGroups(who);
+ groups_ids.resize(groups.size());
+ std::transform(groups.begin(),
+ groups.end(),
+ groups_ids.begin(),
+ &CacheManager::GenerateHash);
+ LOG4CXX_DEBUG(logger_, "Groups Ids: " << groups_ids);
+}
+
+bool AccessRemoteImpl::GetModuleTypes(const std::string& application_id,
+ std::vector<std::string>* modules) {
+ DCHECK(modules);
+ policy_table::ApplicationPolicies& apps =
+ cache_->pt()->policy_table.app_policies_section.apps;
+ policy_table::ApplicationPolicies::iterator i = apps.find(application_id);
+ if (i == apps.end()) {
+ return false;
+ }
+ rpc::Optional<policy_table::ModuleTypes> moduleTypes = i->second.moduleType;
+ if (!moduleTypes.is_initialized()) {
+ return false;
+ }
+ std::transform(moduleTypes->begin(),
+ moduleTypes->end(),
+ std::back_inserter(*modules),
+ ToModuleType());
+ return true;
+}
+
+} // namespace policy
diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc
index 6184320306..78674c81f3 100644
--- a/src/components/policy/policy_regular/src/cache_manager.cc
+++ b/src/components/policy/policy_regular/src/cache_manager.cc
@@ -127,6 +127,17 @@ uint32_t CacheManager::HeartBeatTimeout(const std::string& app_id) const {
return result;
}
+const policy_table::AppHMITypes* CacheManager::GetHMITypes(
+ const std::string& app_id) {
+ const policy_table::ApplicationPolicies& apps =
+ pt_->policy_table.app_policies_section.apps;
+ policy_table::ApplicationPolicies::const_iterator i = apps.find(app_id);
+ if (i != apps.end()) {
+ return &(*i->second.AppHMIType);
+ }
+ return NULL;
+}
+
bool CacheManager::CanAppStealFocus(const std::string& app_id) const {
CACHE_MANAGER_CHECK(false);
bool result = true;
@@ -136,8 +147,8 @@ bool CacheManager::CanAppStealFocus(const std::string& app_id) const {
bool CacheManager::GetDefaultHMI(const std::string& app_id,
std::string& default_hmi) const {
CACHE_MANAGER_CHECK(false);
- bool result = true;
- return result;
+ default_hmi = "NONE";
+ return true;
}
bool CacheManager::ResetUserConsent() {
@@ -222,6 +233,8 @@ bool CacheManager::ApplyUpdate(const policy_table::Table& update_pt) {
for (; iter != iter_end; ++iter) {
if (iter->second.is_null()) {
+ pt_->policy_table.app_policies_section.apps[iter->first] =
+ policy_table::ApplicationParams();
pt_->policy_table.app_policies_section.apps[iter->first].set_to_null();
pt_->policy_table.app_policies_section.apps[iter->first].set_to_string(
"");
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 e1dd7cc5e0..640b9c1457 100644
--- a/src/components/policy/policy_regular/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc
@@ -51,6 +51,11 @@
#include "utils/timer_task_impl.h"
#include "utils/make_shared.h"
+#ifdef SDL_REMOTE_CONTROL
+#include "policy/access_remote.h"
+#include "policy/access_remote_impl.h"
+#endif // SDL_REMOTE_CONTROL
+
policy::PolicyManager* CreateManager() {
return new policy::PolicyManagerImpl();
}
@@ -71,6 +76,10 @@ PolicyManagerImpl::PolicyManagerImpl()
: PolicyManager()
, listener_(NULL)
, cache_(new CacheManager)
+#ifdef SDL_REMOTE_CONTROL
+ , access_remote_(new AccessRemoteImpl(
+ CacheManagerInterfaceSPtr::static_pointer_cast<CacheManager>(cache_)))
+#endif // SDL_REMOTE_CONTROL
, retry_sequence_timeout_(kDefaultRetryTimeoutInMSec)
, retry_sequence_index_(0)
, timer_retry_sequence_("Retry sequence timer",
@@ -80,7 +89,8 @@ PolicyManagerImpl::PolicyManagerImpl()
, retry_sequence_url_(0, 0, "")
, wrong_ptu_update_received_(false)
, send_on_update_sent_out_(false)
- , trigger_ptu_(false) {}
+ , trigger_ptu_(false) {
+}
void PolicyManagerImpl::set_listener(PolicyListener* listener) {
listener_ = listener;
@@ -142,6 +152,9 @@ void PolicyManagerImpl::CheckTriggers() {
bool PolicyManagerImpl::LoadPT(const std::string& file,
const BinaryMessage& pt_content) {
LOG4CXX_INFO(logger_, "LoadPT of size " << pt_content.size());
+ LOG4CXX_DEBUG(
+ logger_,
+ "PTU content is: " << std::string(pt_content.begin(), pt_content.end()));
#ifdef USE_HMI_PTU_DECRYPTION
// Assuemes Policy Table was parsed, formatted, and/or decrypted by
@@ -319,10 +332,13 @@ void PolicyManagerImpl::StartPTExchange() {
if (update_status_manager_.IsUpdateRequired()) {
if (RequestPTUpdate() && !timer_retry_sequence_.is_running()) {
// Start retry sequency
- const int timeout_sec = NextRetryTimeout();
- LOG4CXX_DEBUG(logger_,
- "Start retry sequence timeout = " << timeout_sec);
- timer_retry_sequence_.Start(timeout_sec, timer::kPeriodic);
+ const uint32_t timeout_msec = NextRetryTimeout();
+
+ if (timeout_msec) {
+ LOG4CXX_DEBUG(logger_,
+ "Start retry sequence timeout = " << timeout_msec);
+ timer_retry_sequence_.Start(timeout_msec, timer::kPeriodic);
+ }
}
}
}
@@ -378,7 +394,13 @@ void PolicyManagerImpl::CheckPermissions(const PTString& device_id,
"CheckPermissions for " << app_id << " and rpc " << rpc
<< " for " << hmi_level << " level.");
+#ifdef SDL_REMOTE_CONTROL
+ ApplicationOnDevice who = {device_id, app_id};
+ const policy_table::Strings& groups = access_remote_->GetGroups(who);
+#else // SDL_REMOTE_CONTROL
const policy_table::Strings& groups = cache_->GetGroups(app_id);
+#endif // SDL_REMOTE_CONTROL
+
cache_->CheckPermissions(groups, hmi_level, rpc, result);
if (cache_->IsApplicationRevoked(app_id)) {
// SDL must be able to notify mobile side with its status after app has
@@ -433,6 +455,14 @@ void PolicyManagerImpl::SendNotificationOnPermissionsUpdated(
std::string default_hmi;
default_hmi = "NONE";
+#ifdef SDL_REMOTE_CONTROL
+ const ApplicationOnDevice who = {device_id, application_id};
+ if (access_remote_->IsAppRemoteControl(who)) {
+ listener()->OnPermissionsUpdated(application_id, notification_data);
+ return;
+ }
+#endif // SDL_REMOTE_CONTROL
+
listener()->OnPermissionsUpdated(
application_id, notification_data, default_hmi);
}
@@ -669,7 +699,16 @@ void PolicyManagerImpl::GetPermissionsForApp(
}
FunctionalIdType group_types;
- if (!cache_->GetPermissionsForApp(device_id, app_id_to_check, group_types)) {
+#ifdef SDL_REMOTE_CONTROL
+ allowed_by_default = false;
+ bool ret = access_remote_->GetPermissionsForApp(
+ device_id, policy_app_id, group_types);
+#else
+ bool ret =
+ cache_->GetPermissionsForApp(device_id, app_id_to_check, group_types);
+#endif // REMOTE_CONTROL
+
+ if (!ret) {
LOG4CXX_WARN(logger_,
"Can't get user permissions for app " << policy_app_id);
return;
@@ -803,7 +842,7 @@ uint32_t PolicyManagerImpl::NextRetryTimeout() {
LOG4CXX_DEBUG(logger_, "Index: " << retry_sequence_index_);
uint32_t next = 0u;
if (retry_sequence_seconds_.empty() ||
- retry_sequence_index_ >= retry_sequence_seconds_.size()) {
+ retry_sequence_index_ > retry_sequence_seconds_.size()) {
return next;
}
@@ -851,16 +890,7 @@ void PolicyManagerImpl::OnExceededTimeout() {
}
void PolicyManagerImpl::OnUpdateStarted() {
- uint32_t update_timeout = TimeoutExchangeMSec();
- LOG4CXX_DEBUG(logger_,
- "Update timeout will be set to (milisec): " << update_timeout);
-
- send_on_update_sent_out_ =
- !wrong_ptu_update_received_ && !update_status_manager_.IsUpdatePending();
-
- if (send_on_update_sent_out_) {
- update_status_manager_.OnUpdateSentOut(update_timeout);
- }
+ update_status_manager_.OnUpdateSentOut();
cache_->SaveUpdateRequired(true);
}
@@ -1024,6 +1054,7 @@ StatusNotifier PolicyManagerImpl::AddApplication(
return utils::MakeShared<utils::CallNothing>();
}
}
+
void PolicyManagerImpl::RemoveAppConsentForGroup(
const std::string& app_id, const std::string& group_name) {
cache_->RemoveAppConsentForGroup(app_id, group_name);
@@ -1116,15 +1147,127 @@ void PolicyManagerImpl::set_cache_manager(
void PolicyManagerImpl::RetrySequence() {
LOG4CXX_INFO(logger_, "Start new retry sequence");
+ update_status_manager_.OnUpdateTimeoutOccurs();
+
+ const uint32_t timeout_msec = NextRetryTimeout();
+ LOG4CXX_DEBUG(logger_, "New retry sequence timeout = " << timeout_msec);
+ if (!timeout_msec) {
+ if (timer_retry_sequence_.is_running()) {
+ timer_retry_sequence_.Stop();
+ }
+ return;
+ }
+
RequestPTUpdate();
+ timer_retry_sequence_.Start(timeout_msec, timer::kPeriodic);
+}
- uint32_t timeout = NextRetryTimeout();
+#ifdef SDL_REMOTE_CONTROL
+void PolicyManagerImpl::SetDefaultHmiTypes(const std::string& application_id,
+ const std::vector<int>& hmi_types) {
+ LOG4CXX_INFO(logger_, "SetDefaultHmiTypes");
+ const std::string device_id = GetCurrentDeviceId(application_id);
+ ApplicationOnDevice who = {device_id, application_id};
+ access_remote_->SetDefaultHmiTypes(who, hmi_types);
+}
- if (!timeout && timer_retry_sequence_.is_running()) {
- timer_retry_sequence_.Stop();
- return;
+struct HMITypeToInt {
+ int operator()(const policy_table::AppHMITypes::value_type item) {
+ return policy_table::AppHMIType(item);
+ }
+};
+
+bool PolicyManagerImpl::GetHMITypes(const std::string& application_id,
+ std::vector<int>* app_types) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (cache_->IsDefaultPolicy(application_id)) {
+ return false;
+ }
+ const policy_table::AppHMITypes* hmi_types =
+ cache_->GetHMITypes(application_id);
+ if (hmi_types) {
+ std::transform(hmi_types->begin(),
+ hmi_types->end(),
+ std::back_inserter(*app_types),
+ HMITypeToInt());
}
- timer_retry_sequence_.Start(timeout, timer::kPeriodic);
+ return hmi_types;
+}
+
+bool PolicyManagerImpl::CheckModule(const PTString& app_id,
+ const PTString& module) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ policy_table::ModuleType module_type;
+ return EnumFromJsonString(module, &module_type) &&
+ access_remote_->CheckModuleType(app_id, module_type);
+}
+
+void PolicyManagerImpl::SendHMILevelChanged(const ApplicationOnDevice& who) {
+ std::string default_hmi("NONE");
+ if (GetDefaultHmi(who.app_id, &default_hmi)) {
+ listener()->OnUpdateHMIStatus(who.dev_id, who.app_id, default_hmi);
+ } else {
+ LOG4CXX_WARN(logger_,
+ "Couldn't get default HMI level for application "
+ << who.app_id);
+ }
+}
+
+void PolicyManagerImpl::GetPermissions(const std::string device_id,
+ const std::string application_id,
+ Permissions* data) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ DCHECK(data);
+ std::vector<FunctionalGroupPermission> app_group_permissions;
+ GetPermissionsForApp(device_id, application_id, app_group_permissions);
+
+ policy_table::FunctionalGroupings functional_groupings;
+ cache_->GetFunctionalGroupings(functional_groupings);
+
+ policy_table::Strings app_groups;
+ std::vector<FunctionalGroupPermission>::const_iterator it =
+ app_group_permissions.begin();
+ std::vector<FunctionalGroupPermission>::const_iterator it_end =
+ app_group_permissions.end();
+ for (; it != it_end; ++it) {
+ app_groups.push_back((*it).group_name);
+ }
+
+ PrepareNotificationData(
+ functional_groupings, app_groups, app_group_permissions, *data);
+}
+
+void PolicyManagerImpl::SendAppPermissionsChanged(
+ const std::string& device_id, const std::string& application_id) {
+ Permissions notification_data;
+ GetPermissions(device_id, application_id, &notification_data);
+ listener()->OnPermissionsUpdated(application_id, notification_data);
+}
+
+void PolicyManagerImpl::OnPrimaryGroupsChanged(
+ const std::string& application_id) {
+ const std::vector<std::string> devices =
+ listener()->GetDevicesIds(application_id);
+ for (std::vector<std::string>::const_iterator i = devices.begin();
+ i != devices.end();
+ ++i) {
+ const ApplicationOnDevice who = {*i, application_id};
+ if (access_remote_->IsAppRemoteControl(who)) {
+ SendAppPermissionsChanged(who.dev_id, who.app_id);
+ }
+ }
+}
+
+bool PolicyManagerImpl::GetModuleTypes(
+ const std::string& application_id,
+ std::vector<std::string>* modules) const {
+ return access_remote_->GetModuleTypes(application_id, modules);
+}
+
+void PolicyManagerImpl::set_access_remote(
+ utils::SharedPtr<AccessRemote> access_remote) {
+ access_remote_ = access_remote;
}
+#endif // SDL_REMOTE_CONTROL
} // namespace policy
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 26c7b96b32..e0f77be989 100644
--- a/src/components/policy/policy_regular/src/policy_table/enums.cc
+++ b/src/components/policy/policy_regular/src/policy_table/enums.cc
@@ -324,6 +324,10 @@ bool IsValidEnum(AppHMIType val) {
return true;
case AHT_SYSTEM:
return true;
+ case AHT_PROJECTION:
+ return true;
+ case AHT_REMOTE_CONTROL:
+ return true;
default:
return false;
}
@@ -350,6 +354,10 @@ const char* EnumToJsonString(AppHMIType val) {
return "TESTING";
case AHT_SYSTEM:
return "SYSTEM";
+ case AHT_PROJECTION:
+ return "PROJECTION";
+ case AHT_REMOTE_CONTROL:
+ return "REMOTE_CONTROL";
default:
return "";
}
@@ -385,6 +393,12 @@ bool EnumFromJsonString(const std::string& literal, AppHMIType* result) {
} 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;
}
@@ -569,6 +583,41 @@ bool EnumFromJsonString(const std::string& literal, RequestType* result) {
}
}
+#ifdef SDL_REMOTE_CONTROL
+bool IsValidEnum(ModuleType val) {
+ switch (val) {
+ case MT_CLIMATE:
+ return true;
+ case MT_RADIO:
+ return true;
+ default:
+ return false;
+ }
+}
+const char* EnumToJsonString(ModuleType val) {
+ switch (val) {
+ case MT_CLIMATE:
+ return "CLIMATE";
+ case MT_RADIO:
+ return "RADIO";
+ 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 {
+ return false;
+ }
+}
+#endif // SDL_REMOTE_CONTROL
+
const std::string kDefaultApp = "default";
const std::string kPreDataConsentApp = "pre_DataConsent";
const std::string kDeviceApp = "device";
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 7928973919..45afd91419 100644
--- a/src/components/policy/policy_regular/src/policy_table/types.cc
+++ b/src/components/policy/policy_regular/src/policy_table/types.cc
@@ -166,7 +166,12 @@ ApplicationParams::ApplicationParams(const Json::Value* value__)
, RequestType(impl::ValueMember(value__, "RequestType"))
, memory_kb(impl::ValueMember(value__, "memory_kb"), 0)
, heart_beat_timeout_ms(impl::ValueMember(value__, "heart_beat_timeout_ms"))
- , certificate(impl::ValueMember(value__, "certificate"), "not_specified") {}
+ , certificate(impl::ValueMember(value__, "certificate"), "not_specified")
+#ifdef SDL_REMOTE_CONTROL
+ , moduleType(impl::ValueMember(value__, "moduleType"))
+#endif // SDL_REMOTE_CONTROL
+{
+}
Json::Value ApplicationParams::ToJsonValue() const {
Json::Value result__(PolicyBase::ToJsonValue());
@@ -177,6 +182,9 @@ Json::Value ApplicationParams::ToJsonValue() const {
impl::WriteJsonField("memory_kb", memory_kb, &result__);
impl::WriteJsonField(
"heart_beat_timeout_ms", heart_beat_timeout_ms, &result__);
+#ifdef SDL_REMOTE_CONTROL
+ impl::WriteJsonField("moduleType", moduleType, &result__);
+#endif // SDL_REMOTE_CONTROL
return result__;
}
@@ -204,6 +212,11 @@ bool ApplicationParams::is_valid() const {
if (!certificate.is_valid()) {
return false;
}
+#ifdef SDL_REMOTE_CONTROL
+ if (!moduleType.is_valid()) {
+ return false;
+ }
+#endif // SDL_REMOTE_CONTROL
return Validate();
}
@@ -236,6 +249,11 @@ bool ApplicationParams::struct_empty() const {
if (certificate.is_initialized()) {
return false;
}
+#ifdef SDL_REMOTE_CONTROL
+ if (moduleType.is_initialized()) {
+ return false;
+ }
+#endif // SDL_REMOTE_CONTROL
return true;
}
@@ -268,6 +286,11 @@ void ApplicationParams::ReportErrors(rpc::ValidationReport* report__) const {
if (!certificate.is_valid()) {
certificate.ReportErrors(&report__->ReportSubobject("certificate"));
}
+#ifdef SDL_REMOTE_CONTROL
+ if (!moduleType.is_valid()) {
+ moduleType.ReportErrors(&report__->ReportSubobject("moduleType"));
+ }
+#endif // SDL_REMOTE_CONTROL
}
void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) {
@@ -278,6 +301,9 @@ void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) {
memory_kb.SetPolicyTableType(pt_type);
heart_beat_timeout_ms.SetPolicyTableType(pt_type);
certificate.SetPolicyTableType(pt_type);
+#ifdef SDL_REMOTE_CONTROL
+ moduleType.SetPolicyTableType(pt_type);
+#endif // SDL_REMOTE_CONTROL
}
// RpcParameters methods
@@ -559,7 +585,6 @@ bool ModuleConfig::struct_empty() const {
if (vehicle_year.is_initialized()) {
return false;
}
-
return true;
}
void ModuleConfig::ReportErrors(rpc::ValidationReport* report__) const {
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 e7a981e559..10b8e4bf7c 100644
--- a/src/components/policy/policy_regular/src/policy_table/validation.cc
+++ b/src/components/policy/policy_regular/src/policy_table/validation.cc
@@ -114,9 +114,46 @@ bool ApplicationPoliciesSection::Validate() const {
return true;
}
+#ifdef SDL_REMOTE_CONTROL
+bool ApplicationParams::ValidateModuleTypes() const {
+ // moduleType is optional so see Optional<T>::is_valid()
+ bool is_initialized = moduleType->is_initialized();
+ if (!is_initialized) {
+ // valid if not initialized
+ return true;
+ }
+ bool is_valid = moduleType->is_valid();
+ if (is_valid) {
+ return true;
+ }
+
+ struct IsInvalid {
+ bool operator()(Enum<ModuleType> item) const {
+ return !item.is_valid();
+ }
+ };
+ // cut invalid items
+ moduleType->erase(
+ std::remove_if(moduleType->begin(), moduleType->end(), IsInvalid()),
+ moduleType->end());
+ bool empty = moduleType->empty();
+ if (empty) {
+ // set non initialized value
+ ModuleTypes non_initialized;
+ moduleType = Optional<ModuleTypes>(non_initialized);
+ }
+ return true;
+}
+
+bool ApplicationParams::Validate() const {
+ return ValidateModuleTypes();
+}
+#else // SDL_REMOTE_CONTROL
bool ApplicationParams::Validate() const {
return true;
}
+#endif // SDL_REMOTE_CONTROL
+
bool RpcParameters::Validate() const {
return true;
}
@@ -136,6 +173,19 @@ bool ModuleConfig::Validate() const {
return false;
}
}
+
+ for (ServiceEndpoints::const_iterator it_endpoints = endpoints.begin();
+ it_endpoints != endpoints.end();
+ ++it_endpoints) {
+ const URLList& endpoint_list = it_endpoints->second;
+ if (endpoint_list.end() == endpoint_list.find(kDefaultApp)) {
+ LOG4CXX_ERROR(logger_,
+ "Endpoint " << it_endpoints->first
+ << "does not contain default group");
+ return false;
+ }
+ }
+
return true;
}
@@ -178,20 +228,40 @@ bool UsageAndErrorCounts::Validate() const {
}
return true;
}
+
bool DeviceParams::Validate() const {
return true;
}
+
bool PolicyTable::Validate() const {
- if (PT_PRELOADED == GetPolicyTableType() ||
- PT_UPDATE == GetPolicyTableType()) {
+ const PolicyTableType policy_table_type = GetPolicyTableType();
+
+ if (PT_PRELOADED == policy_table_type || PT_UPDATE == policy_table_type) {
if (device_data.is_initialized()) {
return false;
}
}
+
+ if (PT_PRELOADED == policy_table_type || PT_SNAPSHOT == policy_table_type) {
+ // Check upper bound of each "groups" sub section in the app policies
+ const FunctionalGroupings::size_type functional_groupings_count =
+ functional_groupings.size();
+ for (ApplicationPolicies::const_iterator app_policiies_it =
+ app_policies_section.apps.begin();
+ app_policies_section.apps.end() != app_policiies_it;
+ ++app_policiies_it) {
+ if (app_policiies_it->second.groups.size() > functional_groupings_count) {
+ return false;
+ }
+ }
+ }
+
return true;
}
+
bool Table::Validate() const {
return true;
}
+
} // namespace policy_table_interface_base
} // namespace rpc
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 df4bc74cc2..7938eb4085 100644
--- a/src/components/policy/policy_regular/src/sql_pt_queries.cc
+++ b/src/components/policy/policy_regular/src/sql_pt_queries.cc
@@ -134,6 +134,7 @@ const std::string kCreateSchema =
" `memory_kb` INTEGER NOT NULL, "
" `heart_beat_timeout_ms` INTEGER NOT NULL, "
" `certificate` VARCHAR(45), "
+ " `remote_control_denied` BOOLEAN NOT NULL DEFAULT 0, "
" CONSTRAINT `fk_application_hmi_level1` "
" FOREIGN KEY(`default_hmi`) "
" REFERENCES `hmi_level`(`value`), "
@@ -316,6 +317,39 @@ const std::string kCreateSchema =
" FOREIGN KEY(`message_type_name`) "
" REFERENCES `message_type`(`name`) "
"); "
+
+ /* access_module */
+ "CREATE TABLE `access_module`( "
+ " `id` INTEGER PRIMARY KEY NOT NULL, "
+ " `name` VARCHAR(45) NOT NULL, "
+ " `user_consent_needed` INTEGER NOT NULL "
+ "); "
+
+ /* remote_rpc */
+ "CREATE TABLE `remote_rpc`( "
+ " `id` INTEGER PRIMARY KEY NOT NULL, "
+ " `name` VARCHAR(255) NOT NULL, "
+ " `parameter` VARCHAR(45), "
+ " `module_id` INTEGER NOT NULL, "
+ "CONSTRAINT `fk_remote_rpc_1` "
+ " FOREIGN KEY(`module_id`) "
+ " REFERENCES `access_module`(`id`) "
+ "); "
+ "CREATE INDEX `remote_rpc.fk_remote_rpc_1_idx` ON "
+ "`remote_rpc`(`module_id`); "
+
+ /* module type */
+ "CREATE TABLE IF NOT EXISTS `module_type`( "
+ " `name` VARCHAR(50) NOT NULL, "
+ " `application_id` VARCHAR(45) NOT NULL, "
+ " PRIMARY KEY(`name`,`application_id`), "
+ " CONSTRAINT `fk_module_type_application1` "
+ " FOREIGN KEY(`application_id`) "
+ " REFERENCES `application`(`id`) "
+ "); "
+ "CREATE INDEX IF NOT EXISTS `module_type.fk_module_type_application1_idx` "
+ " ON `module_type`(`application_id`); "
+
"CREATE INDEX IF NOT EXISTS `message.fk_messages_languages1_idx` "
" ON `message`(`language_code`);"
"CREATE INDEX IF NOT EXISTS "
@@ -353,8 +387,47 @@ const std::string kInsertInitData =
"INSERT OR IGNORE INTO `_internal_data` (`db_version_hash`) VALUES(0); "
"";
+const std::string kDeleteModuleTypes = "DELETE FROM `module_type`";
+
+const std::string kDeleteAllDevices = "DELETE FROM `device`;";
+
+const std::string kSelectRemoteControlDenied =
+ "SELECT `remote_control_denied` FROM `application` WHERE `id` = ? LIMIT 1";
+
+const std::string kUpdateRemoteControlDenied =
+ "UPDATE `application` SET `remote_control_denied` = ? WHERE `id` = ?";
+
+const std::string kDeleteAccessModules = "DELETE FROM `access_module`";
+
+const std::string kDeleteRemoteRpc = "DELETE FROM `remote_rpc`";
+
+const std::string kInsertAccessModule =
+ "INSERT INTO `access_module` (`name`, `user_consent_needed`) "
+ " VALUES(?, ?, ?)";
+
+const std::string kSelectAccessModules =
+ "SELECT `id`, `name` FROM `access_module` "
+ " WHERE `user_consent_needed` = ?";
+
+const std::string kInsertRemoteRpc =
+ "INSERT INTO `remote_rpc` (`module_id`, `name`, `parameter`) "
+ " VALUES(?, ?, ?)";
+
+const std::string kSelectRemoteRpcs =
+ "SELECT `name`, `parameter` FROM `remote_rpc` "
+ " WHERE `module_id` = ?";
+
+const std::string kInsertModuleType =
+ "INSERT OR IGNORE INTO `module_type` (`application_id`, `name`) VALUES (?, "
+ "?)";
+
+const std::string kSelectModuleTypes =
+ "SELECT DISTINCT `name` FROM `module_type` WHERE `application_id` = ?";
+
const std::string kDropSchema =
"BEGIN; "
+ "DROP INDEX IF EXISTS `module_type.fk_module_type_application1_idx`; "
+ "DROP TABLE IF EXISTS `module_type`; "
"DROP INDEX IF EXISTS `message.fk_messages_languages1_idx`; "
"DROP INDEX IF EXISTS "
"`message.fk_message_consumer_friendly_messages1_idx`; "
@@ -387,6 +460,8 @@ const std::string kDropSchema =
"`preconsented_group.fk_application_has_functional_group_functional_group2_"
"idx`; "
"DROP TABLE IF EXISTS `preconsented_group`; "
+ "DROP TABLE IF EXISTS `access_module`; "
+ "DROP INDEX IF EXISTS `access_module.fk_module_1_idx`; "
"DROP INDEX IF EXISTS "
"`app_group.fk_application_has_functional_group_application1_idx`; "
"DROP INDEX IF EXISTS "
@@ -409,6 +484,8 @@ const std::string kDropSchema =
"DROP TABLE IF EXISTS `priority`; "
"DROP TABLE IF EXISTS `functional_group`; "
"DROP TABLE IF EXISTS `module_config`; "
+ "DROP TABLE IF EXISTS `remote_rpc`; "
+ "DROP INDEX IF EXISTS `remote_rpc.fk_remote_rpc_1_idx`; "
"DROP TABLE IF EXISTS `module_meta`; "
"DROP TABLE IF EXISTS `usage_and_error_count`; "
"DROP TABLE IF EXISTS `device`; "
@@ -419,6 +496,7 @@ const std::string kDropSchema =
const std::string kDeleteData =
"BEGIN; "
"DELETE FROM `message`; "
+ "DELETE FROM `module_type`; "
"DELETE FROM `endpoint`; "
"DELETE FROM `consent_group`; "
"DELETE FROM `app_type`; "
@@ -430,6 +508,7 @@ const std::string kDeleteData =
"DELETE FROM `app_group`; "
"DELETE FROM `application`; "
"DELETE FROM `rpc`; "
+ "DELETE FROM `access_module`; "
"DELETE FROM `version`; "
"DELETE FROM `message_type`; "
"DELETE FROM `language`; "
@@ -439,6 +518,7 @@ const std::string kDeleteData =
"DELETE FROM `functional_group`; "
"DELETE FROM `module_config`; "
"DELETE FROM `module_meta`; "
+ "DELETE FROM `remote_rpc`; "
"DELETE FROM `usage_and_error_count`; "
"DELETE FROM `device`; "
"COMMIT; "
@@ -522,7 +602,7 @@ const std::string kUpdateModuleConfig =
" `exchange_after_x_ignition_cycles` = ?,"
" `exchange_after_x_kilometers` = ?, `exchange_after_x_days` = ?, "
" `timeout_after_x_seconds` = ?, `certificate` = ?, `vehicle_make` = ?, "
- " `vehicle_model` = ?, `vehicle_year` = ?";
+ " `vehicle_model` = ?, `vehicle_year` = ? ";
const std::string kInsertEndpoint =
"INSERT INTO `endpoint` (`service`, `url`, `application_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 e94c853414..9f529b7d78 100644
--- a/src/components/policy/policy_regular/src/sql_pt_representation.cc
+++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc
@@ -705,6 +705,17 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection(
if (!GatherAppGroup(app_id, &params.groups)) {
return false;
}
+#ifdef SDL_REMOTE_CONTROL
+ bool denied = false;
+ if (!GatherRemoteControlDenied(app_id, &denied)) {
+ return false;
+ }
+ if (!denied) {
+ if (!GatherModuleType(app_id, &*params.moduleType)) {
+ return false;
+ }
+ }
+#endif // SDL_REMOTE_CONTROL
if (!GatherNickName(app_id, &*params.nicknames)) {
return false;
}
@@ -859,6 +870,12 @@ bool SQLPTRepresentation::SaveApplicationPoliciesSection(
LOG4CXX_WARN(logger_, "Incorrect delete from app_group.");
return false;
}
+#ifdef SDL_REMOTE_CONTROL
+ if (!query_delete.Exec(sql_pt::kDeleteModuleTypes)) {
+ LOG4CXX_WARN(logger_, "Incorrect delete from module_type.");
+ return false;
+ }
+#endif // SDL_REMOTE_CONTROL
if (!query_delete.Exec(sql_pt::kDeleteApplication)) {
LOG4CXX_WARN(logger_, "Incorrect delete from application.");
return false;
@@ -941,6 +958,13 @@ bool SQLPTRepresentation::SaveSpecificAppPolicy(
if (!SaveAppGroup(app.first, app.second.groups)) {
return false;
}
+#ifdef SDL_REMOTE_CONTROL
+ bool denied = !app.second.moduleType->is_initialized();
+ if (!SaveRemoteControlDenied(app.first, denied) ||
+ !SaveModuleType(app.first, *app.second.moduleType)) {
+ return false;
+ }
+#endif // SDL_REMOTE_CONTROL
if (!SaveNickname(app.first, *app.second.nicknames)) {
return false;
}
@@ -1111,7 +1135,6 @@ bool SQLPTRepresentation::SaveModuleConfig(
: query.Bind(7);
config.vehicle_year.is_initialized() ? query.Bind(8, *(config.vehicle_year))
: query.Bind(8);
-
if (!query.Exec()) {
LOG4CXX_WARN(logger_, "Incorrect update module config");
return false;
@@ -1506,6 +1529,199 @@ bool SQLPTRepresentation::GatherAppGroup(
return true;
}
+#ifdef SDL_REMOTE_CONTROL
+
+bool SQLPTRepresentation::GatherRemoteControlDenied(const std::string& app_id,
+ bool* denied) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kSelectRemoteControlDenied)) {
+ LOG4CXX_WARN(logger_, "Incorrect select remote control flag");
+ return false;
+ }
+ query.Bind(0, app_id);
+ if (query.Next()) {
+ *denied = query.GetBoolean(0);
+ } else {
+ return false;
+ }
+ return true;
+}
+
+bool SQLPTRepresentation::GatherModuleType(
+ const std::string& app_id, policy_table::ModuleTypes* app_types) const {
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kSelectModuleTypes)) {
+ LOG4CXX_WARN(logger_, "Incorrect select from app types");
+ return false;
+ }
+
+ query.Bind(0, app_id);
+ while (query.Next()) {
+ policy_table::ModuleType type;
+ if (!policy_table::EnumFromJsonString(query.GetString(0), &type)) {
+ return false;
+ }
+ app_types->push_back(type);
+ }
+ return true;
+}
+
+bool SQLPTRepresentation::SaveRemoteControlDenied(const std::string& app_id,
+ bool deny) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kUpdateRemoteControlDenied)) {
+ LOG4CXX_WARN(logger_, "Incorrect update statement for remote control flag");
+ return false;
+ }
+ LOG4CXX_DEBUG(logger_, "App: " << app_id << std::boolalpha << " - " << deny);
+ query.Bind(0, deny);
+ query.Bind(1, app_id);
+ if (!query.Exec()) {
+ LOG4CXX_WARN(logger_, "Incorrect update remote control flag.");
+ return false;
+ }
+ return true;
+}
+
+bool SQLPTRepresentation::SaveModuleType(
+ const std::string& app_id, const policy_table::ModuleTypes& types) {
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kInsertModuleType)) {
+ LOG4CXX_WARN(logger_, "Incorrect insert statement for module type");
+ return false;
+ }
+
+ policy_table::ModuleTypes::const_iterator it;
+ for (it = types.begin(); it != types.end(); ++it) {
+ query.Bind(0, app_id);
+ std::string module(policy_table::EnumToJsonString(*it));
+ query.Bind(1, module);
+ LOG4CXX_DEBUG(logger_,
+ "Module(app: " << app_id << ", type: " << module << ")");
+ if (!query.Exec() || !query.Reset()) {
+ LOG4CXX_WARN(logger_, "Incorrect insert into module type.");
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool SQLPTRepresentation::SaveAccessModule(
+ TypeAccess access, const policy_table::AccessModules& modules) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kInsertAccessModule)) {
+ LOG4CXX_WARN(logger_, "Incorrect insert statement for access module");
+ return false;
+ }
+
+ policy_table::AccessModules::const_iterator i;
+ for (i = modules.begin(); i != modules.end(); ++i) {
+ const std::string& name = i->first;
+ const policy_table::RemoteRpcs& rpcs = i->second;
+ query.Bind(0, name);
+ query.Bind(1, access);
+ if (!query.Exec()) {
+ LOG4CXX_WARN(logger_, "Incorrect insert into access module.");
+ return false;
+ }
+ int id = query.LastInsertId();
+ if (!query.Reset()) {
+ LOG4CXX_WARN(logger_, "Couldn't reset query access module.");
+ return false;
+ }
+ if (!SaveRemoteRpc(id, rpcs)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+bool SQLPTRepresentation::GatherAccessModule(
+ TypeAccess access, policy_table::AccessModules* modules) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kSelectAccessModules)) {
+ LOG4CXX_WARN(logger_, "Incorrect select from access module");
+ return false;
+ }
+
+ query.Bind(0, access);
+ while (query.Next()) {
+ int id = query.GetInteger(0);
+ std::string name = query.GetString(1);
+ policy_table::RemoteRpcs rpcs;
+ if (!GatherRemoteRpc(id, &rpcs)) {
+ return false;
+ }
+ modules->insert(std::make_pair(name, rpcs));
+ }
+ return true;
+}
+
+bool SQLPTRepresentation::SaveRemoteRpc(int module_id,
+ const policy_table::RemoteRpcs& rpcs) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kInsertRemoteRpc)) {
+ LOG4CXX_WARN(logger_, "Incorrect insert statement for remote rpc");
+ return false;
+ }
+ policy_table::RemoteRpcs::const_iterator i;
+ for (i = rpcs.begin(); i != rpcs.end(); ++i) {
+ const std::string& name = i->first;
+ const policy_table::Strings& params = i->second;
+ policy_table::Strings::const_iterator j;
+ if (params.empty()) {
+ query.Bind(0, module_id);
+ query.Bind(1, name);
+ query.Bind(2);
+ if (!query.Exec() || !query.Reset()) {
+ LOG4CXX_WARN(logger_, "Incorrect insert into remote rpc.");
+ return false;
+ }
+ } else {
+ for (j = params.begin(); j != params.end(); ++j) {
+ const std::string& param = *j;
+ query.Bind(0, module_id);
+ query.Bind(1, name);
+ query.Bind(2, param);
+ if (!query.Exec() || !query.Reset()) {
+ LOG4CXX_WARN(logger_, "Incorrect insert into remote rpc.");
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+}
+
+bool SQLPTRepresentation::GatherRemoteRpc(
+ int module_id, policy_table::RemoteRpcs* rpcs) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kSelectRemoteRpcs)) {
+ LOG4CXX_WARN(logger_, "Incorrect select from remote rpc");
+ return false;
+ }
+
+ query.Bind(0, module_id);
+ while (query.Next()) {
+ std::string name = query.GetString(0);
+ if (!query.IsNull(1)) {
+ std::string parameter = query.GetString(1);
+ (*rpcs)[name].push_back(parameter);
+ } else {
+ rpcs->insert(std::make_pair(name, policy_table::Strings()));
+ }
+ }
+ return true;
+}
+#endif // SDL_REMOTE_CONTROL
+
bool SQLPTRepresentation::SaveApplicationCustomData(const std::string& app_id,
bool is_revoked,
bool is_default,
@@ -1612,7 +1828,13 @@ bool SQLPTRepresentation::SetDefaultPolicy(const std::string& app_id) {
!SaveAppType(app_id, app_types)) {
return false;
}
- return SetIsDefault(app_id, true);
+
+ bool ret = (GatherAppGroup(kDefaultId, &default_groups) &&
+ SaveAppGroup(app_id, default_groups));
+ if (ret) {
+ return SetIsDefault(app_id, true);
+ }
+ return false;
}
bool SQLPTRepresentation::SetIsDefault(const std::string& app_id,
diff --git a/src/components/policy/policy_regular/src/update_status_manager.cc b/src/components/policy/policy_regular/src/update_status_manager.cc
index d683249718..941113c753 100644
--- a/src/components/policy/policy_regular/src/update_status_manager.cc
+++ b/src/components/policy/policy_regular/src/update_status_manager.cc
@@ -42,22 +42,11 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "Policy")
UpdateStatusManager::UpdateStatusManager()
: listener_(NULL)
, current_status_(utils::MakeShared<UpToDateStatus>())
+ , last_processed_event_(kNoEvent)
, apps_search_in_progress_(false)
- , app_registered_from_non_consented_device_(true) {
- update_status_thread_delegate_ = new UpdateThreadDelegate(this);
- thread_ = threads::CreateThread("UpdateStatusThread",
- update_status_thread_delegate_);
- thread_->start();
-}
+ , app_registered_from_non_consented_device_(true) {}
-UpdateStatusManager::~UpdateStatusManager() {
- LOG4CXX_AUTO_TRACE(logger_);
- DCHECK(update_status_thread_delegate_);
- DCHECK(thread_);
- thread_->join();
- delete update_status_thread_delegate_;
- threads::DeleteThread(thread_);
-}
+UpdateStatusManager::~UpdateStatusManager() {}
void UpdateStatusManager::ProcessEvent(UpdateEvent event) {
sync_primitives::AutoLock lock(status_lock_);
@@ -78,29 +67,23 @@ void UpdateStatusManager::set_listener(PolicyListener* listener) {
listener_ = listener;
}
-void UpdateStatusManager::OnUpdateSentOut(uint32_t update_timeout) {
+void UpdateStatusManager::OnUpdateSentOut() {
LOG4CXX_AUTO_TRACE(logger_);
- DCHECK(update_status_thread_delegate_);
- update_status_thread_delegate_->updateTimeOut(update_timeout);
ProcessEvent(kOnUpdateSentOut);
}
void UpdateStatusManager::OnUpdateTimeoutOccurs() {
LOG4CXX_AUTO_TRACE(logger_);
ProcessEvent(kOnUpdateTimeout);
- DCHECK(update_status_thread_delegate_);
- update_status_thread_delegate_->updateTimeOut(0); // Stop Timer
}
void UpdateStatusManager::OnValidUpdateReceived() {
LOG4CXX_AUTO_TRACE(logger_);
- update_status_thread_delegate_->updateTimeOut(0); // Stop Timer
ProcessEvent(kOnValidUpdateReceived);
}
void UpdateStatusManager::OnWrongUpdateReceived() {
LOG4CXX_AUTO_TRACE(logger_);
- update_status_thread_delegate_->updateTimeOut(0); // Stop Timer
ProcessEvent(kOnWrongUpdateReceived);
}
@@ -204,57 +187,4 @@ void UpdateStatusManager::DoTransition() {
postponed_status_.reset();
}
-UpdateStatusManager::UpdateThreadDelegate::UpdateThreadDelegate(
- UpdateStatusManager* update_status_manager)
- : timeout_(0)
- , stop_flag_(false)
- , state_lock_(true)
- , update_status_manager_(update_status_manager) {
- LOG4CXX_AUTO_TRACE(logger_);
- LOG4CXX_DEBUG(logger_, "Create UpdateThreadDelegate");
-}
-
-UpdateStatusManager::UpdateThreadDelegate::~UpdateThreadDelegate() {
- LOG4CXX_AUTO_TRACE(logger_);
- LOG4CXX_DEBUG(logger_, "Delete UpdateThreadDelegate");
-}
-
-void UpdateStatusManager::UpdateThreadDelegate::threadMain() {
- LOG4CXX_AUTO_TRACE(logger_);
- LOG4CXX_DEBUG(logger_, "UpdateStatusManager thread started (started normal)");
- sync_primitives::AutoLock auto_lock(state_lock_);
- while (false == stop_flag_) {
- if (timeout_ > 0) {
- LOG4CXX_DEBUG(logger_, "Timeout is greater then 0");
- sync_primitives::ConditionalVariable::WaitStatus wait_status =
- termination_condition_.WaitFor(auto_lock, timeout_);
- if (sync_primitives::ConditionalVariable::kTimeout == wait_status) {
- if (update_status_manager_) {
- update_status_manager_->OnUpdateTimeoutOccurs();
- }
- }
- } else {
- // Time is not active, wait until timeout will be set,
- // or UpdateStatusManager will be deleted
- termination_condition_.Wait(auto_lock);
- }
- }
-}
-
-void UpdateStatusManager::UpdateThreadDelegate::exitThreadMain() {
- LOG4CXX_AUTO_TRACE(logger_);
- sync_primitives::AutoLock auto_lock(state_lock_);
- stop_flag_ = true;
- LOG4CXX_DEBUG(logger_, "before notify");
- termination_condition_.NotifyOne();
-}
-
-void UpdateStatusManager::UpdateThreadDelegate::updateTimeOut(
- const uint32_t timeout_ms) {
- LOG4CXX_AUTO_TRACE(logger_);
- sync_primitives::AutoLock auto_lock(state_lock_);
- timeout_ = timeout_ms;
- termination_condition_.NotifyOne();
-}
-
} // namespace policy
diff --git a/src/components/policy/policy_regular/test/CMakeLists.txt b/src/components/policy/policy_regular/test/CMakeLists.txt
index 997c3637e8..62ff691f83 100644
--- a/src/components/policy/policy_regular/test/CMakeLists.txt
+++ b/src/components/policy/policy_regular/test/CMakeLists.txt
@@ -39,11 +39,17 @@ include_directories(
${COMPONENTS_DIR}/rpc_base/include
${COMPONENTS_DIR}/config_profile/include
${COMPONENTS_DIR}/utils/include/
+ ${COMPONENTS_DIR}/include/test/policy/policy_regular/
${POLICY_PATH}/test/include/
${POLICY_MOCK_INCLUDE_PATH}/
)
collect_sources(SOURCES "${CMAKE_CURRENT_SOURCE_DIR}")
+if (NOT REMOTE_CONTROL)
+ list (REMOVE_ITEM SOURCES
+ ${CMAKE_CURRENT_SOURCE_DIR}/access_remote_impl_test.cc
+ )
+endif ()
set(LIBRARIES
gmock
diff --git a/src/components/policy/policy_regular/test/access_remote_impl_test.cc b/src/components/policy/policy_regular/test/access_remote_impl_test.cc
new file mode 100644
index 0000000000..d086144d86
--- /dev/null
+++ b/src/components/policy/policy_regular/test/access_remote_impl_test.cc
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2015, 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 "policy/access_remote_impl.h"
+
+namespace policy {
+
+TEST(AccessRemoteImplTest, CheckModuleType) {
+ AccessRemoteImpl access_remote;
+ access_remote.cache_->pt_ = new policy_table::Table();
+
+ // No application
+ EXPECT_FALSE(access_remote.CheckModuleType("1234", policy_table::MT_RADIO));
+
+ // No modules
+ policy_table::ApplicationPolicies& apps =
+ access_remote.cache_->pt_->policy_table.app_policies_section.apps;
+ apps["1234"];
+ EXPECT_FALSE(access_remote.CheckModuleType("1234", policy_table::MT_RADIO));
+
+ // Empty modules
+ policy_table::ModuleTypes& modules = *apps["1234"].moduleType;
+ modules.mark_initialized();
+ EXPECT_TRUE(access_remote.CheckModuleType("1234", policy_table::MT_RADIO));
+ EXPECT_TRUE(access_remote.CheckModuleType("1234", policy_table::MT_CLIMATE));
+
+ // Specific modules
+ modules.push_back(policy_table::MT_RADIO);
+ EXPECT_TRUE(access_remote.CheckModuleType("1234", policy_table::MT_RADIO));
+ EXPECT_FALSE(access_remote.CheckModuleType("1234", policy_table::MT_CLIMATE));
+}
+
+TEST(AccessRemoteImplTest, SetDefaultHmiTypes) {
+ AccessRemoteImpl access_remote;
+
+ std::vector<int> hmi_expected;
+ hmi_expected.push_back(2);
+ hmi_expected.push_back(6);
+ ApplicationOnDevice who = {"dev1", "1234"};
+ access_remote.SetDefaultHmiTypes(who, hmi_expected);
+
+ EXPECT_NE(access_remote.hmi_types_.end(), access_remote.hmi_types_.find(who));
+ policy_table::AppHMITypes& hmi_output = access_remote.hmi_types_[who];
+ EXPECT_EQ(2u, hmi_output.size());
+ EXPECT_EQ(policy_table::AHT_MEDIA, hmi_output[0]);
+ EXPECT_EQ(policy_table::AHT_SOCIAL, hmi_output[1]);
+}
+
+TEST(AccessRemoteImplTest, GetGroups) {
+ AccessRemoteImpl access_remote;
+ ApplicationOnDevice who = {"dev1", "1234"};
+ access_remote.hmi_types_[who].push_back(policy_table::AHT_REMOTE_CONTROL);
+
+ access_remote.cache_->pt_ = new policy_table::Table();
+ policy_table::ApplicationPolicies& apps =
+ access_remote.cache_->pt_->policy_table.app_policies_section.apps;
+ apps["1234"].groups.push_back("group_default");
+ apps["1234"].AppHMIType->push_back(policy_table::AHT_MEDIA);
+
+ // Default groups
+ const policy_table::Strings& groups1 = access_remote.GetGroups(who);
+ EXPECT_EQ(std::string("group_default"), std::string(groups1[0]));
+}
+
+} // namespace policy
diff --git a/src/components/policy/policy_regular/test/include/policy/mock_access_remote.h b/src/components/policy/policy_regular/test/include/policy/mock_access_remote.h
new file mode 100644
index 0000000000..0b64ff645e
--- /dev/null
+++ b/src/components/policy/policy_regular/test/include/policy/mock_access_remote.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2015, 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_TEST_INCLUDE_POLICY_MOCK_ACCESS_REMOTE_H_
+#define SRC_COMPONENTS_POLICY_POLICY_REGULAR_TEST_INCLUDE_POLICY_MOCK_ACCESS_REMOTE_H_
+
+#include "gmock/gmock.h"
+#include "policy/access_remote.h"
+
+namespace test {
+namespace components {
+namespace access_remote_test {
+
+class MockAccessRemote : public policy::AccessRemote {
+ public:
+ MOCK_CONST_METHOD3(
+ FindGroup,
+ policy::PTString(const policy::ApplicationOnDevice& who,
+ const policy::PTString& rpc,
+ const policy::RemoteControlParams& params));
+ MOCK_METHOD2(SetDefaultHmiTypes,
+ void(const policy::ApplicationOnDevice& who,
+ const std::vector<int>& hmi_types));
+ MOCK_METHOD1(
+ GetGroups,
+ const policy_table::Strings&(const policy::ApplicationOnDevice& who));
+ MOCK_METHOD3(GetPermissionsForApp,
+ bool(const std::string& device_id,
+ const std::string& app_id,
+ policy::FunctionalIdType& group_types));
+ MOCK_CONST_METHOD2(CheckModuleType,
+ bool(const policy::PTString& app_id,
+ policy_table::ModuleType module));
+ MOCK_METHOD1(IsAppRemoteControl,
+ bool(const policy::ApplicationOnDevice& who));
+ MOCK_METHOD2(GetModuleTypes,
+ bool(const std::string& application_id,
+ std::vector<std::string>* modules));
+};
+
+} // namespace access_remote_test
+} // namespace components
+} // namespace test
+
+#endif // SRC_COMPONENTS_POLICY_POLICY_REGULAR_TEST_INCLUDE_POLICY_MOCK_ACCESS_REMOTE_H_
diff --git a/src/components/policy/policy_regular/test/include/policy/mock_policy_manager.h b/src/components/policy/policy_regular/test/include/policy/mock_policy_manager.h
deleted file mode 100644
index 7ab4b518cd..0000000000
--- a/src/components/policy/policy_regular/test/include/policy/mock_policy_manager.h
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright (c) 2016, 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_TEST_INCLUDE_MOCK_POLICY_MANAGER_H_
-#define SRC_COMPONENTS_POLICY_POLICY_REGULAR_TEST_INCLUDE_MOCK_POLICY_MANAGER_H_
-
-#include <string>
-#include <vector>
-#include "gmock/gmock.h"
-#include "policy/policy_listener.h"
-#include "policy/policy_types.h"
-#include "policy/usage_statistics/statistics_manager.h"
-
-#include "rpc_base/rpc_base.h"
-#include "policy/policy_table/types.h"
-#include "policy/policy_manager.h"
-
-namespace policy_table = ::rpc::policy_table_interface_base;
-
-namespace policy_manager {
-
-using namespace policy;
-
-class MockPolicyManager : public PolicyManager {
- public:
- MOCK_METHOD1(set_listener, void(PolicyListener* listener));
- MOCK_METHOD2(InitPT,
- bool(const std::string& file_name,
- const PolicySettings* settings));
- MOCK_METHOD2(LoadPT,
- bool(const std::string& file, const BinaryMessage& pt_content));
- MOCK_METHOD1(ResetPT, bool(const std::string& file_name));
- MOCK_METHOD2(GetUpdateUrls,
- void(const uint32_t service_type, EndpointUrls& out_end_points));
- MOCK_METHOD2(GetUpdateUrls,
- void(const std::string& service_type,
- EndpointUrls& out_end_points));
- MOCK_METHOD0(RequestPTUpdate, bool());
-
- MOCK_METHOD6(CheckPermissions,
- void(const PTString& device_id,
- const PTString& app_id,
- const PTString& hmi_level,
- const PTString& rpc,
- const RPCParams& rpc_params,
- CheckPermissionResult& result));
- MOCK_METHOD0(ResetUserConsent, bool());
- MOCK_CONST_METHOD0(GetPolicyTableStatus, std::string());
- MOCK_METHOD1(KmsChanged, void(int kilometers));
- MOCK_METHOD0(IncrementIgnitionCycles, void());
- MOCK_METHOD0(ForcePTExchange, std::string());
- MOCK_METHOD0(ResetRetrySequence, void());
- MOCK_METHOD0(NextRetryTimeout, int());
- MOCK_METHOD0(TimeoutExchangeMSec, uint32_t());
- MOCK_METHOD0(RetrySequenceDelaysSeconds, const std::vector<int>());
- MOCK_METHOD0(OnExceededTimeout, void());
- MOCK_METHOD0(OnUpdateStarted, void());
- MOCK_CONST_METHOD1(GetUserConsentForDevice,
- DeviceConsent(const std::string& device_id));
- MOCK_METHOD3(
- GetUserConsentForApp,
- void(const std::string& device_id,
- const std::string& policy_app_id,
- std::vector<policy::FunctionalGroupPermission>& permissions));
- MOCK_METHOD2(SetUserConsentForDevice,
- void(const std::string& device_id, bool is_allowed));
- MOCK_METHOD2(ReactOnUserDevConsentForApp,
- bool(const std::string app_id, bool is_device_allowed));
- MOCK_METHOD2(PTUpdatedAt, void(policy::Counters counter, int value));
-
- MOCK_METHOD3(GetInitialAppData,
- bool(const std::string&,
- policy::StringArray*,
- policy::StringArray*));
-
- MOCK_METHOD2(AddDevice,
- void(const std::string& device_id,
- const std::string& connection_type));
- MOCK_METHOD2(SetDeviceInfo,
- void(const std::string& device_id,
- const policy::DeviceInfo& device_info));
- MOCK_METHOD1(SetUserConsentForApp,
- void(const policy::PermissionConsent& permissions));
- MOCK_CONST_METHOD2(GetDefaultHmi,
- bool(const std::string& policy_app_id,
- std::string* default_hmi));
- MOCK_CONST_METHOD2(GetPriority,
- bool(const std::string& policy_app_id,
- std::string* priority));
- MOCK_METHOD2(GetUserFriendlyMessages,
- std::vector<policy::UserFriendlyMessage>(
- const std::vector<std::string>& message_code,
- const std::string& language));
- MOCK_CONST_METHOD1(IsApplicationRevoked, bool(const std::string& app_id));
- MOCK_METHOD3(
- GetPermissionsForApp,
- void(const std::string& device_id,
- const std::string& policy_app_id,
- std::vector<policy::FunctionalGroupPermission>& permissions));
- MOCK_METHOD1(GetAppPermissionsChanges,
- policy::AppPermissions(const std::string& policy_app_id));
- MOCK_METHOD1(RemovePendingPermissionChanges, void(const std::string& app_id));
- MOCK_CONST_METHOD1(GetCurrentDeviceId,
- std::string&(const std::string& policy_app_id));
- MOCK_METHOD1(SetSystemLanguage, void(const std::string& language));
- MOCK_METHOD3(SetSystemInfo,
- void(const std::string& ccpu_version,
- const std::string& wers_country_code,
- const std::string& language));
- MOCK_METHOD1(SendNotificationOnPermissionsUpdated,
- void(const std::string& application_id));
- MOCK_METHOD1(MarkUnpairedDevice, void(const std::string& device_id));
- MOCK_METHOD1(AddApplication,
- StatusNotifier(const std::string& application_id));
- MOCK_METHOD0(CleanupUnpairedDevices, bool());
- MOCK_CONST_METHOD1(CanAppKeepContext, bool(const std::string& app_id));
- MOCK_CONST_METHOD1(CanAppStealFocus, bool(const std::string& app_id));
- MOCK_METHOD0(OnSystemReady, void());
- MOCK_CONST_METHOD1(GetNotificationsNumber,
- uint32_t(const std::string& priority));
- MOCK_METHOD1(SetVINValue, void(const std::string& value));
- MOCK_CONST_METHOD1(IsPredataPolicy, bool(const std::string& policy_app_id));
- MOCK_CONST_METHOD1(HeartBeatTimeout, uint32_t(const std::string& app_id));
- MOCK_METHOD1(SaveUpdateStatusRequired, void(bool is_update_needed));
- MOCK_METHOD0(OnAppsSearchStarted, void());
- MOCK_METHOD0(OnAppsSearchCompleted, void());
- MOCK_METHOD1(OnAppRegisteredOnMobile,
- void(const std::string& application_id));
- 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(RetrieveCertificate, std::string());
- MOCK_METHOD1(SetDecryptedCertificate, void(const std::string&));
- MOCK_METHOD0(ExceededIgnitionCycles, bool());
- MOCK_METHOD0(ExceededDays, bool());
- MOCK_METHOD0(StartPTExchange, void());
- MOCK_METHOD1(Increment, void(usage_statistics::GlobalCounterId type));
- MOCK_METHOD2(Increment,
- void(const std::string& app_id,
- usage_statistics::AppCounterId type));
- MOCK_METHOD3(Set,
- void(const std::string& app_id,
- usage_statistics::AppInfoId type,
- const std::string& value));
- MOCK_METHOD3(Add,
- void(const std::string& app_id,
- usage_statistics::AppStopwatchId type,
- int32_t timespan_seconds));
- MOCK_CONST_METHOD0(get_settings, const PolicySettings&());
- MOCK_METHOD1(set_settings, void(const PolicySettings* get_settings));
-};
-
-} // namespace policy_manager
-
-#endif // SRC_COMPONENTS_POLICY_POLICY_REGULAR_TEST_INCLUDE_MOCK_POLICY_MANAGER_H_
diff --git a/src/components/policy/policy_regular/test/include/policy/mock_update_status_manager.h b/src/components/policy/policy_regular/test/include/policy/mock_update_status_manager.h
index 981ff1ca9e..924284c8cc 100644
--- a/src/components/policy/policy_regular/test/include/policy/mock_update_status_manager.h
+++ b/src/components/policy/policy_regular/test/include/policy/mock_update_status_manager.h
@@ -41,7 +41,7 @@ namespace policy {
class MockUpdateStatusManager : public UpdateStatusManager {
public:
MOCK_METHOD1(set_listener, void(PolicyListener* listener));
- MOCK_METHOD1(OnUpdateSentOut, void(uint32_t update_timeout));
+ MOCK_METHOD0(OnUpdateSentOut, void());
MOCK_METHOD0(OnUpdateTimeoutOccurs, void());
MOCK_METHOD0(OnValidUpdateReceived, void());
MOCK_METHOD0(OnWrongUpdateReceived, void());
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 e8bca3061f..f76e856cd0 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
@@ -53,7 +53,9 @@
#include "utils/date_time.h"
#include "utils/make_shared.h"
#include "utils/gen_hash.h"
-
+#ifdef SDL_REMOTE_CONTROL
+#include "policy/mock_access_remote.h"
+#endif // SDL_REMOTE_CONTROL
using ::testing::ReturnRef;
using ::testing::DoAll;
using ::testing::SetArgReferee;
@@ -144,12 +146,20 @@ class PolicyManagerImplTest : public ::testing::Test {
MockCacheManagerInterface* cache_manager;
NiceMock<MockPolicyListener> listener;
const std::string device_id;
+#ifdef SDL_REMOTE_CONTROL
+ utils::SharedPtr<access_remote_test::MockAccessRemote> access_remote;
+#endif // SDL_REMOTE_CONTROL
void SetUp() OVERRIDE {
manager = new PolicyManagerImpl();
manager->set_listener(&listener);
cache_manager = new MockCacheManagerInterface();
manager->set_cache_manager(cache_manager);
+
+#ifdef SDL_REMOTE_CONTROL
+ access_remote = new access_remote_test::MockAccessRemote();
+ manager->set_access_remote(access_remote);
+#endif // SDL_REMOTE_CONTROL
}
void TearDown() OVERRIDE {
@@ -189,10 +199,10 @@ class PolicyManagerImplTest2 : public ::testing::Test {
const std::string dev_id2;
Json::Value PTU_request_types;
NiceMock<policy_handler_test::MockPolicySettings> policy_settings_;
- const std::string kAppStorageFolder = "storage1";
+ const std::string kAppStorageFolder = "storage_PolicyManagerImplTest2";
void SetUp() OVERRIDE {
- file_system::CreateDirectory("storage1");
+ file_system::CreateDirectory(kAppStorageFolder);
file_system::DeleteFile("policy.sqlite");
manager = new PolicyManagerImpl();
@@ -231,7 +241,7 @@ class PolicyManagerImplTest2 : public ::testing::Test {
}
void CreateLocalPT(const std::string& file_name) {
- file_system::remove_directory_content("storage1");
+ file_system::remove_directory_content(kAppStorageFolder);
ON_CALL(policy_settings_, app_storage_folder())
.WillByDefault(ReturnRef(kAppStorageFolder));
ASSERT_TRUE(manager->InitPT(file_name, &policy_settings_));
@@ -355,6 +365,8 @@ class PolicyManagerImplTest2 : public ::testing::Test {
void TearDown() OVERRIDE {
delete manager;
+ file_system::remove_directory_content(kAppStorageFolder);
+ file_system::RemoveDirectory(kAppStorageFolder, true);
}
};
@@ -1247,7 +1259,7 @@ TEST_F(PolicyManagerImplTest2,
// Arrange
CreateLocalPT("sdl_preloaded_pt.json");
GetPTU("valid_sdl_pt_update.json");
- utils::SharedPtr<policy_table::Table> pt = (manager->GetCache())->GetPT();
+ utils::SharedPtr<policy_table::Table> pt = (manager->GetCache())->pt();
policy_table::ModuleConfig& module_config = pt->policy_table.module_config;
::policy::VehicleInfo vehicle_info = manager->GetVehicleInfo();
@@ -1328,7 +1340,7 @@ TEST_F(
HertBeatTimeout_AddApp_UpdateAppPolicies_ExpectReceivedHertBeatTimeoutCorrect) {
// Arrange
CreateLocalPT("sdl_preloaded_pt.json");
- utils::SharedPtr<policy_table::Table> pt = (manager->GetCache())->GetPT();
+ utils::SharedPtr<policy_table::Table> pt = (manager->GetCache())->pt();
::policy_table::PolicyTableType type1 =
::policy_table::PolicyTableType::PT_PRELOADED;
pt->SetPolicyTableType(type1);
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 a313ce6d7f..fd83c82b1a 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
@@ -68,22 +68,23 @@ namespace test {
namespace components {
namespace policy_test {
+using policy_handler_test::MockPolicySettings;
+
class SQLPTRepresentationTest : public SQLPTRepresentation,
public ::testing::Test {
protected:
- static DBMS* dbms;
- static SQLPTRepresentation* reps;
+ DBMS* dbms;
+ SQLPTRepresentation* reps;
static const std::string kDatabaseName;
static const std::string kAppStorageFolder;
// Gtest can show message that this object doesn't destroyed
- static std::auto_ptr<policy_handler_test::MockPolicySettings>
- policy_settings_;
+ std::auto_ptr<NiceMock<MockPolicySettings> > policy_settings_;
- static void SetUpTestCase() {
- file_system::DeleteFile(kAppStorageFolder + "/policy.sqlite");
+ void SetUp() OVERRIDE {
+ file_system::CreateDirectory(kAppStorageFolder);
reps = new SQLPTRepresentation;
- policy_settings_ = std::auto_ptr<policy_handler_test::MockPolicySettings>(
- new policy_handler_test::MockPolicySettings());
+ policy_settings_ = std::auto_ptr<NiceMock<MockPolicySettings> >(
+ new NiceMock<MockPolicySettings>());
ON_CALL(*policy_settings_, app_storage_folder())
.WillByDefault(ReturnRef(kAppStorageFolder));
EXPECT_EQ(::policy::SUCCESS, reps->Init(policy_settings_.get()));
@@ -93,15 +94,13 @@ class SQLPTRepresentationTest : public SQLPTRepresentation,
void TearDown() OVERRIDE {
EXPECT_TRUE(reps->Clear());
- }
-
- static void TearDownTestCase() {
EXPECT_TRUE(reps->Drop());
EXPECT_TRUE(reps->Close());
reps->RemoveDB();
delete reps;
dbms->Close();
- file_system::RemoveDirectory(kAppStorageFolder);
+ file_system::remove_directory_content(kAppStorageFolder);
+ file_system::RemoveDirectory(kAppStorageFolder, true);
policy_settings_.reset();
}
@@ -346,12 +345,9 @@ class SQLPTRepresentationTest : public SQLPTRepresentation,
}
};
-DBMS* SQLPTRepresentationTest::dbms = 0;
-SQLPTRepresentation* SQLPTRepresentationTest::reps = 0;
const std::string SQLPTRepresentationTest::kDatabaseName = "policy.sqlite";
-const std::string SQLPTRepresentationTest::kAppStorageFolder = "storage1";
-std::auto_ptr<policy_handler_test::MockPolicySettings>
- SQLPTRepresentationTest::policy_settings_;
+const std::string SQLPTRepresentationTest::kAppStorageFolder =
+ "storage_SQLPTRepresentationTest";
class SQLPTRepresentationTest2 : public ::testing::Test {
protected:
@@ -378,7 +374,7 @@ class SQLPTRepresentationTest2 : public ::testing::Test {
}
SQLPTRepresentation* reps;
- NiceMock<policy_handler_test::MockPolicySettings> policy_settings_;
+ NiceMock<MockPolicySettings> policy_settings_;
const std::string kAppStorageFolder;
const uint16_t kOpenAttemptTimeoutMs;
const uint16_t kAttemptsToOpenPolicyDB;
@@ -399,7 +395,7 @@ class SQLPTRepresentationTest3 : public ::testing::Test {
}
SQLPTRepresentation* reps;
- NiceMock<policy_handler_test::MockPolicySettings> policy_settings_;
+ NiceMock<MockPolicySettings> policy_settings_;
const std::string kAppStorageFolder;
};
@@ -424,7 +420,8 @@ TEST_F(SQLPTRepresentationTest,
ASSERT_EQ(0, dbms->FetchOneInt(query_select));
ASSERT_TRUE(reps->RefreshDB());
// Check PT structure destroyed and tables number is 0
- ASSERT_EQ(25, dbms->FetchOneInt(query_select));
+ const int32_t total_tables_number = 28;
+ 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`";
const char* query_select_count_sync_out_of_memory =
@@ -1102,7 +1099,7 @@ TEST_F(SQLPTRepresentationTest,
GetInitialAppData_SetData_ExpectCorrectValuesReceived) {
// Arrange
const char* query_insert =
- "INSERT INTO `nickname` (`application_id`, `name`)"
+ "INSERT INTO `nickname` (`application_id`, `name`) "
"VALUES ('1111', 'first_app') , "
"('2222', 'second_app'), ('3333', 'third_app')";
ASSERT_TRUE(dbms->Exec(query_insert));
diff --git a/src/components/policy/policy_regular/test/update_status_manager_test.cc b/src/components/policy/policy_regular/test/update_status_manager_test.cc
index 910494ff0d..9d0326d0be 100644
--- a/src/components/policy/policy_regular/test/update_status_manager_test.cc
+++ b/src/components/policy/policy_regular/test/update_status_manager_test.cc
@@ -47,13 +47,11 @@ using ::testing::Return;
class UpdateStatusManagerTest : public ::testing::Test {
protected:
utils::SharedPtr<UpdateStatusManager> manager_;
- const uint32_t k_timeout_;
utils::SharedPtr<MockPolicyListener> listener_;
public:
UpdateStatusManagerTest()
: manager_(utils::MakeShared<UpdateStatusManager>())
- , k_timeout_(1000)
, listener_(utils::MakeShared<MockPolicyListener>()) {}
void SetUp() OVERRIDE {
@@ -73,7 +71,7 @@ TEST_F(UpdateStatusManagerTest,
manager_->OnPolicyInit(true);
// Check
EXPECT_EQ("UPDATE_NEEDED", manager_->StringifiedUpdateStatus());
- manager_->OnUpdateSentOut(k_timeout_);
+ manager_->OnUpdateSentOut();
// Check
EXPECT_EQ("UPDATING", manager_->StringifiedUpdateStatus());
}
diff --git a/src/components/protocol/src/bson_object_keys.cc b/src/components/protocol/src/bson_object_keys.cc
new file mode 100644
index 0000000000..fb225b1461
--- /dev/null
+++ b/src/components/protocol/src/bson_object_keys.cc
@@ -0,0 +1,18 @@
+#include <protocol/bson_object_keys.h>
+
+namespace protocol_handler {
+
+namespace strings {
+
+const char* hash_id = "hashId";
+const char* protocol_version = "protocolVersion";
+const char* mtu = "mtu";
+const char* rejected_params = "rejectedParams";
+const char* height = "height";
+const char* width = "width";
+const char* video_protocol = "videoProtocol";
+const char* video_codec = "videoCodec";
+
+} // namespace strings
+
+} // namespace protocol_handler
diff --git a/src/components/protocol_handler/CMakeLists.txt b/src/components/protocol_handler/CMakeLists.txt
index c1dd9b2769..ebecff2402 100644
--- a/src/components/protocol_handler/CMakeLists.txt
+++ b/src/components/protocol_handler/CMakeLists.txt
@@ -35,6 +35,7 @@ include_directories(
${COMPONENTS_DIR}/protocol_handler/include/
${COMPONENTS_DIR}/connection_handler/include/
${LOG4CXX_INCLUDE_DIRECTORY}
+ ${BSON_INCLUDE_DIRECTORY}
)
set(PATHS
@@ -46,6 +47,8 @@ collect_sources(SOURCES "${PATHS}")
set(LIBRARIES
ProtocolLibrary
Utils
+ bson -L${BSON_LIBS_DIRECTORY}
+ emhashmap -L${EMHASHMAP_LIBS_DIRECTORY}
)
get_property(dirs DIRECTORY "" PROPERTY LIBRARIES)
@@ -55,6 +58,7 @@ endforeach()
add_library(ProtocolHandler ${SOURCES})
+add_dependencies(ProtocolHandler libbson)
target_link_libraries(ProtocolHandler ${LIBRARIES})
if(BUILD_TESTS)
diff --git a/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h b/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h
index b18ee07d4d..7521137d5a 100644
--- a/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h
+++ b/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h
@@ -84,6 +84,8 @@ class MessagesToMobileAppHandler;
using transport_manager::TransportManagerListenerEmpty;
typedef std::multimap<int32_t, RawMessagePtr> MessagesOverNaviMap;
+typedef std::map<std::pair<ConnectionID, uint8_t>, ProtocolFramePtr>
+ StartSessionFrameMap;
typedef std::set<ProtocolObserver*> ProtocolObservers;
typedef transport_manager::ConnectionUID ConnectionID;
@@ -250,6 +252,54 @@ class ProtocolHandlerImpl
uint8_t service_type,
bool protection);
+ /**
+ * \brief Sends acknowledgement of starting session to mobile application
+ * with session number and hash code for second version of protocol
+ * was started
+ * \param connection_id Identifier of connection within which session
+ * \param session_id ID of session to be sent to mobile application
+ * \param protocol_version Version of protocol used for communication
+ * \param hash_code For second version of protocol: identifier of session
+ * to be sent to
+ * mobile app for using when ending session
+ * \param service_type Type of session: RPC or BULK Data. RPC by default
+ * \param protection Protection flag
+ * \param full_version full protocol version (major.minor.patch) used by the
+ * mobile proxy
+ */
+ void SendStartSessionAck(ConnectionID connection_id,
+ uint8_t session_id,
+ uint8_t protocol_version,
+ uint32_t hash_code,
+ uint8_t service_type,
+ bool protection,
+ ProtocolPacket::ProtocolVersion& full_version);
+
+ /**
+ * \brief Sends acknowledgement of starting session to mobile application
+ * with session number and hash code for second version of protocol
+ * was started
+ * \param connection_id Identifier of connection within which session
+ * \param session_id ID of session to be sent to mobile application
+ * \param protocol_version Version of protocol used for communication
+ * \param hash_code For second version of protocol: identifier of session
+ * to be sent to
+ * mobile app for using when ending session
+ * \param service_type Type of session: RPC or BULK Data. RPC by default
+ * \param protection Protection flag
+ * \param full_version full protocol version (major.minor.patch) used by the
+ * mobile proxy
+ * \param params Parameters added in the payload
+ */
+ void SendStartSessionAck(ConnectionID connection_id,
+ uint8_t session_id,
+ uint8_t protocol_version,
+ uint32_t hash_code,
+ uint8_t service_type,
+ bool protection,
+ ProtocolPacket::ProtocolVersion& full_version,
+ BsonObject& params);
+
const ProtocolHandlerSettings& get_settings() const OVERRIDE {
return settings_;
}
@@ -267,6 +317,20 @@ class ProtocolHandlerImpl
uint8_t service_type);
/**
+ * \brief Sends fail of starting session to mobile application
+ * \param connection_id Identifier of connection within which session
+ * \param session_id ID of session to be sent to mobile application
+ * \param protocol_version Version of protocol used for communication
+ * \param service_type Type of session: RPC or BULK Data. RPC by default
+ * \param rejected_params List of rejected params to send in payload
+ */
+ void SendStartSessionNAck(ConnectionID connection_id,
+ uint8_t session_id,
+ uint8_t protocol_version,
+ uint8_t service_type,
+ std::vector<std::string>& rejectedParams);
+
+ /**
* \brief Sends acknowledgement of end session/service to mobile application
* with session number for second version of protocol.
* \param connection_id Identifier of connection
@@ -294,9 +358,45 @@ class ProtocolHandlerImpl
uint32_t session_id,
uint8_t protocol_version,
uint8_t service_type);
+ /**
+ * \brief Sends fail of ending session to mobile application (variant for
+ * Protocol v5)
+ * \param connection_id Identifier of connection within which
+ * session exists
+ * \param session_id ID of session ment to be ended
+ * \param protocol_version Version of protocol used for communication
+ * \param service_type Type of session: RPC or BULK Data. RPC by default
+ * \param rejected_params List of rejected params to send in payload
+ */
+ void SendEndSessionNAck(ConnectionID connection_id,
+ uint32_t session_id,
+ uint8_t protocol_version,
+ uint8_t service_type,
+ std::vector<std::string>& rejected_params);
SessionObserver& get_session_observer() OVERRIDE;
+ /**
+ * \brief Called by connection handler to notify the result of
+ * OnSessionStartedCallback().
+ * \param connection_id Identifier of connection within which session exists
+ * \param session_id session ID passed to OnSessionStartedCallback()
+ * \param generated_session_id Generated session ID, will be 0 if session is
+ * not started
+ * \param hash_id Generated Hash ID
+ * \param protection whether the service will be protected
+ * \param rejected_params list of parameters' name that are rejected.
+ * Only valid when generated_session_id is 0. Note, even if
+ * generated_session_id is 0, the list may be empty.
+ */
+ void NotifySessionStartedResult(
+ int32_t connection_id,
+ uint8_t session_id,
+ uint8_t generated_session_id,
+ uint32_t hash_id,
+ bool protection,
+ std::vector<std::string>& rejected_params) OVERRIDE;
+
#ifdef BUILD_TESTS
const impl::FromMobileQueue& get_from_mobile_queue() const {
return raw_ford_messages_from_mobile_;
@@ -453,8 +553,11 @@ class ProtocolHandlerImpl
RESULT_CODE HandleControlMessageEndServiceACK(const ProtocolPacket& packet);
+ // DEPRECATED
RESULT_CODE HandleControlMessageStartSession(const ProtocolPacket& packet);
+ RESULT_CODE HandleControlMessageStartSession(const ProtocolFramePtr packet);
+
RESULT_CODE HandleControlMessageHeartBeat(const ProtocolPacket& packet);
void PopValideAndExpirateMultiframes();
@@ -566,6 +669,9 @@ class ProtocolHandlerImpl
sync_primitives::Lock protocol_observers_lock_;
+ sync_primitives::Lock start_session_frame_map_lock_;
+ StartSessionFrameMap start_session_frame_map_;
+
#ifdef TELEMETRY_MONITOR
PHTelemetryObserver* metric_observer_;
#endif // TELEMETRY_MONITOR
diff --git a/src/components/protocol_handler/include/protocol_handler/protocol_packet.h b/src/components/protocol_handler/include/protocol_handler/protocol_packet.h
index f8696c46a0..31b4c12ea6 100644
--- a/src/components/protocol_handler/include/protocol_handler/protocol_packet.h
+++ b/src/components/protocol_handler/include/protocol_handler/protocol_packet.h
@@ -64,6 +64,55 @@ class ProtocolPacket {
};
/**
+ * \class ProtocolVersion
+ * \brief Used for storing the full protocol version of a service
+ * (major.minor.patch).
+ */
+ class ProtocolVersion {
+ public:
+ ProtocolVersion();
+ ProtocolVersion(uint8_t majorVersion,
+ uint8_t minorVersion,
+ uint8_t patchVersion);
+ ProtocolVersion(ProtocolVersion& other);
+ ProtocolVersion(std::string versionString);
+ uint8_t majorVersion;
+ uint8_t minorVersion;
+ uint8_t patchVersion;
+ static inline uint8_t cmp(const ProtocolVersion& version1,
+ const ProtocolVersion& version2) {
+ uint8_t diff = version1.majorVersion - version2.majorVersion;
+ if (diff == 0) {
+ diff = version1.minorVersion - version2.minorVersion;
+ if (diff == 0) {
+ diff = version1.minorVersion - version2.minorVersion;
+ }
+ }
+ return diff;
+ }
+ inline bool operator==(const ProtocolVersion& other) {
+ return ProtocolVersion::cmp(*this, other) == 0;
+ }
+ inline bool operator<(const ProtocolVersion& other) {
+ return ProtocolVersion::cmp(*this, other) < 0;
+ }
+ bool operator>(const ProtocolVersion& other) {
+ return ProtocolVersion::cmp(*this, other) > 0;
+ }
+ inline bool operator<=(const ProtocolVersion& other) {
+ return ProtocolVersion::cmp(*this, other) <= 0;
+ }
+ bool operator>=(const ProtocolVersion& other) {
+ return ProtocolVersion::cmp(*this, other) >= 0;
+ }
+ static inline ProtocolVersion* min(ProtocolVersion& version1,
+ ProtocolVersion& version2) {
+ return (version1 < version2) ? &version1 : &version2;
+ }
+ std::string to_string();
+ };
+
+ /**
* \class ProtocolHeader
* \brief Used for storing protocol header of a message.
*/
@@ -99,7 +148,19 @@ class ProtocolPacket {
* \brief Setter/getter maximum payload size of packets
*/
void set_max_payload_size(const size_t max_payload_size);
+ void set_max_control_payload_size(const size_t max_payload_size);
+ void set_max_rpc_payload_size(const size_t max_payload_size);
+ void set_max_audio_payload_size(const size_t max_payload_size);
+ void set_max_video_payload_size(const size_t max_payload_size);
+
size_t max_payload_size() const;
+ size_t max_control_payload_size() const;
+ size_t max_rpc_payload_size() const;
+ size_t max_audio_payload_size() const;
+ size_t max_video_payload_size() const;
+
+ size_t max_payload_size_by_service_type(const ServiceType type) const;
+
/**
* \brief Check ProtocolHeader according to protocol requiements
*/
@@ -107,6 +168,10 @@ class ProtocolPacket {
private:
size_t max_payload_size_;
+ size_t max_control_payload_size_;
+ size_t max_rpc_payload_size_;
+ size_t max_audio_payload_size_;
+ size_t max_video_payload_size_;
};
/**
diff --git a/src/components/protocol_handler/src/incoming_data_handler.cc b/src/components/protocol_handler/src/incoming_data_handler.cc
index e1d08a6ada..4944ea9cc7 100644
--- a/src/components/protocol_handler/src/incoming_data_handler.cc
+++ b/src/components/protocol_handler/src/incoming_data_handler.cc
@@ -126,6 +126,7 @@ uint32_t IncomingDataHandler::GetPacketSize(
case PROTOCOL_VERSION_2:
case PROTOCOL_VERSION_3:
case PROTOCOL_VERSION_4:
+ case PROTOCOL_VERSION_5:
return header.dataSize + PROTOCOL_HEADER_V2_SIZE;
default:
LOG4CXX_WARN(logger_,
diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc
index aa2910722d..125e033147 100644
--- a/src/components/protocol_handler/src/protocol_handler_impl.cc
+++ b/src/components/protocol_handler/src/protocol_handler_impl.cc
@@ -33,6 +33,8 @@
#include "protocol_handler/protocol_handler_impl.h"
#include <memory.h>
#include <algorithm> // std::find
+#include <bson_object.h>
+#include <protocol/bson_object_keys.h>
#include "connection_handler/connection_handler_impl.h"
#include "protocol_handler/session_observer.h"
@@ -55,7 +57,9 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "ProtocolHandler")
std::string ConvertPacketDataToString(const uint8_t* data,
const size_t data_size);
-const size_t kStackSize = 32768;
+const size_t kStackSize = 65536;
+
+ProtocolPacket::ProtocolVersion defaultProtocolVersion(5, 0, 0);
ProtocolHandlerImpl::ProtocolHandlerImpl(
const ProtocolHandlerSettings& settings,
@@ -77,6 +81,8 @@ ProtocolHandlerImpl::ProtocolHandlerImpl(
"PH FromMobile", this, threads::ThreadOptions(kStackSize))
, raw_ford_messages_to_mobile_(
"PH ToMobile", this, threads::ThreadOptions(kStackSize))
+ , start_session_frame_map_lock_()
+ , start_session_frame_map_()
#ifdef TELEMETRY_MONITOR
, metric_observer_(NULL)
#endif // TELEMETRY_MONITOR
@@ -85,6 +91,14 @@ ProtocolHandlerImpl::ProtocolHandlerImpl(
LOG4CXX_AUTO_TRACE(logger_);
protocol_header_validator_.set_max_payload_size(
get_settings().maximum_payload_size());
+ protocol_header_validator_.set_max_control_payload_size(
+ get_settings().maximum_control_payload_size());
+ protocol_header_validator_.set_max_rpc_payload_size(
+ get_settings().maximum_rpc_payload_size());
+ protocol_header_validator_.set_max_audio_payload_size(
+ get_settings().maximum_audio_payload_size());
+ protocol_header_validator_.set_max_video_payload_size(
+ get_settings().maximum_video_payload_size());
incoming_data_handler_.set_validator(&protocol_header_validator_);
const size_t& message_frequency_count =
@@ -176,17 +190,73 @@ void set_hash_id(uint32_t hash_id, protocol_handler::ProtocolPacket& packet) {
void ProtocolHandlerImpl::SendStartSessionAck(ConnectionID connection_id,
uint8_t session_id,
- uint8_t,
+ uint8_t protocol_version,
uint32_t hash_id,
uint8_t service_type,
bool protection) {
LOG4CXX_AUTO_TRACE(logger_);
+ ProtocolPacket::ProtocolVersion fullVersion;
+ SendStartSessionAck(connection_id,
+ session_id,
+ protocol_version,
+ hash_id,
+ service_type,
+ protection,
+ fullVersion);
+}
+
+void ProtocolHandlerImpl::SendStartSessionAck(
+ ConnectionID connection_id,
+ uint8_t session_id,
+ uint8_t protocol_version,
+ uint32_t hash_id,
+ uint8_t service_type,
+ bool protection,
+ ProtocolPacket::ProtocolVersion& full_version) {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ BsonObject empty_param;
+ bson_object_initialize_default(&empty_param);
+
+ SendStartSessionAck(connection_id,
+ session_id,
+ protocol_version,
+ hash_id,
+ service_type,
+ protection,
+ full_version,
+ empty_param);
+
+ bson_object_deinitialize(&empty_param);
+}
+
+void ProtocolHandlerImpl::SendStartSessionAck(
+ ConnectionID connection_id,
+ uint8_t session_id,
+ uint8_t protocol_version,
+ uint32_t hash_id,
+ uint8_t service_type,
+ bool protection,
+ ProtocolPacket::ProtocolVersion& full_version,
+ BsonObject& params) {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ uint8_t maxProtocolVersion = SupportedSDLProtocolVersion();
- uint8_t protocolVersion = SupportedSDLProtocolVersion();
+ const bool proxy_supports_v5_protocol =
+ protocol_version >= PROTOCOL_VERSION_5 ||
+ (ServiceTypeFromByte(service_type) == kRpc &&
+ full_version.majorVersion >= PROTOCOL_VERSION_5);
+
+ // We can't send a V5+ packet if the proxy doesn't support it,
+ // so we manually set a maximum of V4 in that case
+ if (!proxy_supports_v5_protocol && maxProtocolVersion >= PROTOCOL_VERSION_5) {
+ maxProtocolVersion = PROTOCOL_VERSION_4;
+ }
ProtocolFramePtr ptr(
new protocol_handler::ProtocolPacket(connection_id,
- protocolVersion,
+ maxProtocolVersion,
protection,
FRAME_TYPE_CONTROL,
service_type,
@@ -195,7 +265,37 @@ void ProtocolHandlerImpl::SendStartSessionAck(ConnectionID connection_id,
0u,
message_counters_[session_id]++));
- set_hash_id(hash_id, *ptr);
+ // Cannot include a constructed payload if either side doesn't support it
+ if (maxProtocolVersion >= PROTOCOL_VERSION_5) {
+ ServiceType serviceTypeValue = ServiceTypeFromByte(service_type);
+
+ bson_object_put_int64(
+ &params,
+ strings::mtu,
+ static_cast<int64_t>(
+ protocol_header_validator_.max_payload_size_by_service_type(
+ serviceTypeValue)));
+ if (serviceTypeValue == kRpc) {
+ // Hash ID is only used in RPC case
+ bson_object_put_int32(
+ &params, strings::hash_id, static_cast<int32_t>(hash_id));
+ // Minimum protocol version supported by both
+ ProtocolPacket::ProtocolVersion* minVersion =
+ (full_version.majorVersion < PROTOCOL_VERSION_5)
+ ? &defaultProtocolVersion
+ : ProtocolPacket::ProtocolVersion::min(full_version,
+ defaultProtocolVersion);
+ char protocolVersionString[255];
+ strncpy(protocolVersionString, (*minVersion).to_string().c_str(), 255);
+ bson_object_put_string(
+ &params, strings::protocol_version, protocolVersionString);
+ }
+ uint8_t* payloadBytes = bson_object_to_bytes(&params);
+ ptr->set_data(payloadBytes, bson_object_size(&params));
+ free(payloadBytes);
+ } else {
+ set_hash_id(hash_id, *ptr);
+ }
raw_ford_messages_to_mobile_.PostMessage(
impl::RawFordMessageToMobile(ptr, false));
@@ -212,6 +312,20 @@ void ProtocolHandlerImpl::SendStartSessionNAck(ConnectionID connection_id,
uint8_t session_id,
uint8_t protocol_version,
uint8_t service_type) {
+ std::vector<std::string> rejectedParams;
+ SendStartSessionNAck(connection_id,
+ session_id,
+ protocol_version,
+ service_type,
+ rejectedParams);
+}
+
+void ProtocolHandlerImpl::SendStartSessionNAck(
+ ConnectionID connection_id,
+ uint8_t session_id,
+ uint8_t protocol_version,
+ uint8_t service_type,
+ std::vector<std::string>& rejectedParams) {
LOG4CXX_AUTO_TRACE(logger_);
ProtocolFramePtr ptr(
@@ -225,6 +339,27 @@ void ProtocolHandlerImpl::SendStartSessionNAck(ConnectionID connection_id,
0u,
message_counters_[session_id]++));
+ uint8_t maxProtocolVersion = SupportedSDLProtocolVersion();
+
+ if (protocol_version >= PROTOCOL_VERSION_5 &&
+ maxProtocolVersion >= PROTOCOL_VERSION_5 && rejectedParams.size() > 0) {
+ BsonObject payloadObj;
+ bson_object_initialize_default(&payloadObj);
+ BsonArray rejectedParamsArr;
+ bson_array_initialize(&rejectedParamsArr, rejectedParams.size());
+ for (std::string param : rejectedParams) {
+ char paramPtr[255];
+ strncpy(paramPtr, param.c_str(), 255);
+ bson_array_add_string(&rejectedParamsArr, paramPtr);
+ }
+ bson_object_put_array(
+ &payloadObj, strings::rejected_params, &rejectedParamsArr);
+ uint8_t* payloadBytes = bson_object_to_bytes(&payloadObj);
+ ptr->set_data(payloadBytes, bson_object_size(&payloadObj));
+ free(payloadBytes);
+ bson_object_deinitialize(&payloadObj);
+ }
+
raw_ford_messages_to_mobile_.PostMessage(
impl::RawFordMessageToMobile(ptr, false));
@@ -239,6 +374,20 @@ void ProtocolHandlerImpl::SendEndSessionNAck(ConnectionID connection_id,
uint32_t session_id,
uint8_t protocol_version,
uint8_t service_type) {
+ std::vector<std::string> rejectedParams;
+ SendEndSessionNAck(connection_id,
+ session_id,
+ protocol_version,
+ service_type,
+ rejectedParams);
+}
+
+void ProtocolHandlerImpl::SendEndSessionNAck(
+ ConnectionID connection_id,
+ uint32_t session_id,
+ uint8_t protocol_version,
+ uint8_t service_type,
+ std::vector<std::string>& rejectedParams) {
LOG4CXX_AUTO_TRACE(logger_);
ProtocolFramePtr ptr(
@@ -252,6 +401,27 @@ void ProtocolHandlerImpl::SendEndSessionNAck(ConnectionID connection_id,
0u,
message_counters_[session_id]++));
+ uint8_t maxProtocolVersion = SupportedSDLProtocolVersion();
+
+ if (protocol_version >= PROTOCOL_VERSION_5 &&
+ maxProtocolVersion >= PROTOCOL_VERSION_5 && rejectedParams.size() > 0) {
+ BsonObject payloadObj;
+ bson_object_initialize_default(&payloadObj);
+ BsonArray rejectedParamsArr;
+ bson_array_initialize(&rejectedParamsArr, rejectedParams.size());
+ for (std::string param : rejectedParams) {
+ char paramPtr[255];
+ strncpy(paramPtr, param.c_str(), 255);
+ bson_array_add_string(&rejectedParamsArr, paramPtr);
+ }
+ bson_object_put_array(
+ &payloadObj, strings::rejected_params, &rejectedParamsArr);
+ uint8_t* payloadBytes = bson_object_to_bytes(&payloadObj);
+ ptr->set_data(payloadBytes, bson_object_size(&payloadObj));
+ free(payloadBytes);
+ bson_object_deinitialize(&payloadObj);
+ }
+
raw_ford_messages_to_mobile_.PostMessage(
impl::RawFordMessageToMobile(ptr, false));
@@ -413,7 +583,7 @@ void ProtocolHandlerImpl::SendMessageToMobileApp(const RawMessagePtr message,
metric_observer_->StartMessageProcess(message_id, start_time);
}
#endif // TELEMETRY_MONITOR
- const size_t max_frame_size = get_settings().maximum_payload_size();
+ size_t max_frame_size = get_settings().maximum_payload_size();
size_t frame_size = MAXIMUM_FRAME_DATA_V2_SIZE;
switch (message->protocol_version()) {
case PROTOCOL_VERSION_3:
@@ -422,6 +592,13 @@ void ProtocolHandlerImpl::SendMessageToMobileApp(const RawMessagePtr message,
? max_frame_size
: MAXIMUM_FRAME_DATA_V2_SIZE;
break;
+ case PROTOCOL_VERSION_5:
+ max_frame_size =
+ protocol_header_validator_.max_payload_size_by_service_type(
+ ServiceTypeFromByte(message->service_type()));
+ frame_size = max_frame_size > MAXIMUM_FRAME_DATA_V2_SIZE
+ ? max_frame_size
+ : MAXIMUM_FRAME_DATA_V2_SIZE;
default:
break;
}
@@ -883,7 +1060,7 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessage(
switch (packet->frame_data()) {
case FRAME_DATA_START_SERVICE: {
LOG4CXX_TRACE(logger_, "FrameData: StartService");
- return HandleControlMessageStartSession(*packet);
+ return HandleControlMessageStartSession(packet);
}
case FRAME_DATA_END_SERVICE: {
LOG4CXX_TRACE(logger_, "FrameData: StopService");
@@ -924,10 +1101,19 @@ uint32_t get_hash_id(const ProtocolPacket& packet) {
LOG4CXX_WARN(logger_, "Packet without hash data (data size less 4)");
return HASH_ID_WRONG;
}
- const uint32_t hash_be = *(reinterpret_cast<uint32_t*>(packet.data()));
- const uint32_t hash_le = BE_TO_LE32(hash_be);
- // null hash is wrong hash value
- return hash_le == HASH_ID_NOT_SUPPORTED ? HASH_ID_WRONG : hash_le;
+ if (packet.protocol_version() >= PROTOCOL_VERSION_5) {
+ BsonObject obj = bson_object_from_bytes(packet.data());
+ const uint32_t hash_id =
+ (uint32_t)bson_object_get_int32(&obj, strings::hash_id);
+ bson_object_deinitialize(&obj);
+ return hash_id;
+ } else {
+ const uint32_t hash_be = *(reinterpret_cast<uint32_t*>(packet.data()));
+ const uint32_t hash_le = BE_TO_LE32(hash_be);
+
+ // null hash is wrong hash value
+ return hash_le == HASH_ID_NOT_SUPPORTED ? HASH_ID_WRONG : hash_le;
+ }
}
RESULT_CODE ProtocolHandlerImpl::HandleControlMessageEndSession(
@@ -935,12 +1121,12 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessageEndSession(
LOG4CXX_AUTO_TRACE(logger_);
const uint8_t current_session_id = packet.session_id();
- const uint32_t hash_id = get_hash_id(packet);
+ uint32_t hash_id = get_hash_id(packet);
const ServiceType service_type = ServiceTypeFromByte(packet.service_type());
const ConnectionID connection_id = packet.connection_id();
const uint32_t session_key = session_observer_.OnSessionEndedCallback(
- connection_id, current_session_id, hash_id, service_type);
+ connection_id, current_session_id, &hash_id, service_type);
// TODO(EZamakhov): add clean up output queue (for removed service)
if (session_key != 0) {
@@ -953,10 +1139,22 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessageEndSession(
LOG4CXX_WARN(logger_,
"Refused to end session " << static_cast<int>(service_type)
<< " type.");
- SendEndSessionNAck(connection_id,
- current_session_id,
- packet.protocol_version(),
- service_type);
+ if (packet.protocol_version() >= PROTOCOL_VERSION_5) {
+ std::vector<std::string> rejectedParams;
+ if (hash_id == protocol_handler::HASH_ID_WRONG) {
+ rejectedParams.push_back(std::string(strings::hash_id));
+ }
+ SendEndSessionNAck(connection_id,
+ current_session_id,
+ packet.protocol_version(),
+ service_type,
+ rejectedParams);
+ } else {
+ SendEndSessionNAck(connection_id,
+ current_session_id,
+ packet.protocol_version(),
+ service_type);
+ }
}
return RESULT_OK;
}
@@ -1006,12 +1204,36 @@ class StartSessionHandler : public security_manager::SecurityManagerListener {
, protocol_version_(protocol_version)
, hash_id_(hash_id)
, service_type_(service_type)
- , force_protected_service_(force_protected_service) {}
+ , force_protected_service_(force_protected_service)
+ , full_version_() {}
+ StartSessionHandler(uint32_t connection_key,
+ ProtocolHandlerImpl* protocol_handler,
+ SessionObserver& session_observer,
+ ConnectionID connection_id,
+ int32_t session_id,
+ uint8_t protocol_version,
+ uint32_t hash_id,
+ ServiceType service_type,
+ const std::vector<int>& force_protected_service,
+ ProtocolPacket::ProtocolVersion& full_version,
+ uint8_t* payload)
+ : connection_key_(connection_key)
+ , protocol_handler_(protocol_handler)
+ , session_observer_(session_observer)
+ , connection_id_(connection_id)
+ , session_id_(session_id)
+ , protocol_version_(protocol_version)
+ , hash_id_(hash_id)
+ , service_type_(service_type)
+ , force_protected_service_(force_protected_service)
+ , full_version_(full_version)
+ , payload_(payload) {}
bool OnHandshakeDone(
const uint32_t connection_key,
security_manager::SSLContext::HandshakeResult result) OVERRIDE {
if (connection_key != connection_key_) {
+ delete[] payload_;
return false;
}
const bool success =
@@ -1031,13 +1253,23 @@ class StartSessionHandler : public security_manager::SecurityManagerListener {
if (success) {
session_observer_.SetProtectionFlag(connection_key_, service_type_);
}
+ BsonObject params;
+ if (payload_ != NULL) {
+ params = bson_object_from_bytes(payload_);
+ } else {
+ bson_object_initialize_default(&params);
+ }
protocol_handler_->SendStartSessionAck(connection_id_,
session_id_,
protocol_version_,
hash_id_,
service_type_,
- success);
+ success,
+ full_version_,
+ params);
+ bson_object_deinitialize(&params);
}
+ delete[] payload_;
delete this;
return true;
}
@@ -1059,10 +1291,13 @@ class StartSessionHandler : public security_manager::SecurityManagerListener {
const uint32_t hash_id_;
const ServiceType service_type_;
const std::vector<int> force_protected_service_;
+ ProtocolPacket::ProtocolVersion full_version_;
+ uint8_t* payload_;
};
} // namespace
#endif // ENABLE_SECURITY
+// DEPRECATED
RESULT_CODE ProtocolHandlerImpl::HandleControlMessageStartSession(
const ProtocolPacket& packet) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -1121,7 +1356,30 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessageStartSession(
PROTECTION_OFF);
return RESULT_OK;
}
- if (ssl_context->IsInitCompleted()) {
+ ProtocolPacket::ProtocolVersion* fullVersion;
+ std::vector<std::string> rejectedParams(0, std::string(""));
+ // Can't check protocol_version because the first packet is v1, but there
+ // could still be a payload, in which case we can get the real protocol
+ // version
+ if (packet.service_type() == kRpc && packet.data_size() != 0) {
+ BsonObject obj = bson_object_from_bytes(packet.data());
+ fullVersion = new ProtocolPacket::ProtocolVersion(
+ std::string(bson_object_get_string(&obj, "protocolVersion")));
+ bson_object_deinitialize(&obj);
+ // Constructed payloads added in Protocol v5
+ if (fullVersion->majorVersion < PROTOCOL_VERSION_5) {
+ rejectedParams.push_back(std::string("protocolVersion"));
+ }
+ } else {
+ fullVersion = new ProtocolPacket::ProtocolVersion();
+ }
+ if (!rejectedParams.empty()) {
+ SendStartSessionNAck(connection_id,
+ packet.session_id(),
+ protocol_version,
+ packet.service_type(),
+ rejectedParams);
+ } else if (ssl_context->IsInitCompleted()) {
// mark service as protected
session_observer_.SetProtectionFlag(connection_key, service_type);
// Start service as protected with current SSLContext
@@ -1130,7 +1388,8 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessageStartSession(
packet.protocol_version(),
hash_id,
packet.service_type(),
- PROTECTION_ON);
+ PROTECTION_ON,
+ *fullVersion);
} else {
security_manager_->AddListener(
new StartSessionHandler(connection_key,
@@ -1141,28 +1400,257 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessageStartSession(
packet.protocol_version(),
hash_id,
service_type,
- get_settings().force_protected_service()));
+ get_settings().force_protected_service(),
+ *fullVersion,
+ NULL));
if (!ssl_context->IsHandshakePending()) {
// Start handshake process
security_manager_->StartHandshake(connection_key);
}
}
+ delete fullVersion;
LOG4CXX_DEBUG(logger_,
"Protection establishing for connection "
<< connection_key << " is in progress");
return RESULT_OK;
}
#endif // ENABLE_SECURITY
- // Start service without protection
- SendStartSessionAck(connection_id,
- session_id,
- packet.protocol_version(),
- hash_id,
- packet.service_type(),
- PROTECTION_OFF);
+ if (packet.service_type() == kRpc && packet.data_size() != 0) {
+ BsonObject obj = bson_object_from_bytes(packet.data());
+ ProtocolPacket::ProtocolVersion fullVersion(
+ bson_object_get_string(&obj, "protocolVersion"));
+ bson_object_deinitialize(&obj);
+
+ if (fullVersion.majorVersion >= PROTOCOL_VERSION_5) {
+ // Start service without protection
+ SendStartSessionAck(connection_id,
+ session_id,
+ packet.protocol_version(),
+ hash_id,
+ packet.service_type(),
+ PROTECTION_OFF,
+ fullVersion);
+ } else {
+ std::vector<std::string> rejectedParams(1,
+ std::string("protocolVersion"));
+ SendStartSessionNAck(connection_id,
+ packet.session_id(),
+ protocol_version,
+ packet.service_type(),
+ rejectedParams);
+ }
+
+ } else {
+ // Start service without protection
+ SendStartSessionAck(connection_id,
+ session_id,
+ packet.protocol_version(),
+ hash_id,
+ packet.service_type(),
+ PROTECTION_OFF);
+ }
return RESULT_OK;
}
+RESULT_CODE ProtocolHandlerImpl::HandleControlMessageStartSession(
+ const ProtocolFramePtr packet) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ LOG4CXX_DEBUG(
+ logger_,
+ "Protocol version:" << static_cast<int>(packet->protocol_version()));
+ const ServiceType service_type = ServiceTypeFromByte(packet->service_type());
+ const uint8_t protocol_version = packet->protocol_version();
+ BsonObject bson_obj;
+ if (packet->data() != NULL) {
+ bson_obj = bson_object_from_bytes(packet->data());
+ } else {
+ bson_object_initialize_default(&bson_obj);
+ }
+
+#ifdef ENABLE_SECURITY
+ const bool protection =
+ // Protocolo version 1 is not support protection
+ (protocol_version > PROTOCOL_VERSION_1) ? packet->protection_flag()
+ : false;
+#else
+ const bool protection = false;
+#endif // ENABLE_SECURITY
+
+ const ConnectionID connection_id = packet->connection_id();
+ const uint8_t session_id = packet->session_id();
+
+ {
+ sync_primitives::AutoLock auto_lock(start_session_frame_map_lock_);
+ start_session_frame_map_[std::make_pair(connection_id, session_id)] =
+ packet;
+ }
+
+ session_observer_.OnSessionStartedCallback(
+ connection_id, packet->session_id(), service_type, protection, &bson_obj);
+ bson_object_deinitialize(&bson_obj);
+
+ return RESULT_OK;
+}
+
+void ProtocolHandlerImpl::NotifySessionStartedResult(
+ int32_t connection_id,
+ uint8_t session_id,
+ uint8_t generated_session_id,
+ uint32_t hash_id,
+ bool protection,
+ std::vector<std::string>& rejected_params) {
+ ProtocolFramePtr packet;
+ {
+ sync_primitives::AutoLock auto_lock(start_session_frame_map_lock_);
+ StartSessionFrameMap::iterator it = start_session_frame_map_.find(
+ std::make_pair(connection_id, session_id));
+ if (it == start_session_frame_map_.end()) {
+ LOG4CXX_ERROR(logger_, "Cannot find Session Started packet");
+ return;
+ }
+ packet = it->second;
+ start_session_frame_map_.erase(it);
+ }
+
+ const ServiceType service_type = ServiceTypeFromByte(packet->service_type());
+ const uint8_t protocol_version = packet->protocol_version();
+
+ if (0 == generated_session_id) {
+ LOG4CXX_WARN(logger_,
+ "Refused by session_observer to create service "
+ << static_cast<int32_t>(service_type) << " type.");
+ SendStartSessionNAck(connection_id,
+ packet->session_id(),
+ protocol_version,
+ packet->service_type(),
+ rejected_params);
+ return;
+ }
+
+ BsonObject start_session_ack_params;
+ // when video service is successfully started, copy input parameters
+ // ("width", "height", "videoProtocol", "videoCodec") to the ACK packet
+ if (packet->service_type() == kMobileNav && packet->data() != NULL) {
+ start_session_ack_params = bson_object_from_bytes(packet->data());
+ } else {
+ bson_object_initialize_default(&start_session_ack_params);
+ }
+
+ ProtocolPacket::ProtocolVersion* fullVersion;
+
+ // Can't check protocol_version because the first packet is v1, but there
+ // could still be a payload, in which case we can get the real protocol
+ // version
+ if (packet->service_type() == kRpc && packet->data() != NULL) {
+ BsonObject request_params = bson_object_from_bytes(packet->data());
+ char* version_param =
+ bson_object_get_string(&request_params, strings::protocol_version);
+ std::string version_string(version_param == NULL ? "" : version_param);
+ fullVersion = new ProtocolPacket::ProtocolVersion(version_string);
+ // Constructed payloads added in Protocol v5
+ if (fullVersion->majorVersion < PROTOCOL_VERSION_5) {
+ rejected_params.push_back(std::string(strings::protocol_version));
+ }
+ bson_object_deinitialize(&request_params);
+ } else {
+ fullVersion = new ProtocolPacket::ProtocolVersion();
+ }
+
+#ifdef ENABLE_SECURITY
+ // for packet is encrypted and security plugin is enable
+ if (protection && security_manager_) {
+ const uint32_t connection_key =
+ session_observer_.KeyFromPair(connection_id, generated_session_id);
+
+ security_manager::SSLContext* ssl_context =
+ security_manager_->CreateSSLContext(connection_key);
+ if (!ssl_context) {
+ const std::string error("CreateSSLContext failed");
+ LOG4CXX_ERROR(logger_, error);
+ security_manager_->SendInternalError(
+ connection_key,
+ security_manager::SecurityManager::ERROR_INTERNAL,
+ error);
+ // Start service without protection
+ SendStartSessionAck(connection_id,
+ generated_session_id,
+ packet->protocol_version(),
+ hash_id,
+ packet->service_type(),
+ PROTECTION_OFF,
+ *fullVersion,
+ start_session_ack_params);
+ delete fullVersion;
+ bson_object_deinitialize(&start_session_ack_params);
+ return;
+ }
+
+ if (!rejected_params.empty()) {
+ SendStartSessionNAck(connection_id,
+ packet->session_id(),
+ protocol_version,
+ packet->service_type(),
+ rejected_params);
+ } else if (ssl_context->IsInitCompleted()) {
+ // mark service as protected
+ session_observer_.SetProtectionFlag(connection_key, service_type);
+ // Start service as protected with current SSLContext
+ SendStartSessionAck(connection_id,
+ generated_session_id,
+ packet->protocol_version(),
+ hash_id,
+ packet->service_type(),
+ PROTECTION_ON,
+ *fullVersion,
+ start_session_ack_params);
+ } else {
+ // Need a copy because fullVersion will be deleted
+ ProtocolPacket::ProtocolVersion fullVersionCopy(*fullVersion);
+ security_manager_->AddListener(new StartSessionHandler(
+ connection_key,
+ this,
+ session_observer_,
+ connection_id,
+ generated_session_id,
+ packet->protocol_version(),
+ hash_id,
+ service_type,
+ get_settings().force_protected_service(),
+ fullVersionCopy,
+ bson_object_to_bytes(&start_session_ack_params)));
+ if (!ssl_context->IsHandshakePending()) {
+ // Start handshake process
+ security_manager_->StartHandshake(connection_key);
+ }
+ }
+ delete fullVersion;
+ bson_object_deinitialize(&start_session_ack_params);
+ LOG4CXX_DEBUG(logger_,
+ "Protection establishing for connection "
+ << connection_key << " is in progress");
+ return;
+ }
+#endif // ENABLE_SECURITY
+ if (rejected_params.empty()) {
+ SendStartSessionAck(connection_id,
+ generated_session_id,
+ packet->protocol_version(),
+ hash_id,
+ packet->service_type(),
+ PROTECTION_OFF,
+ *fullVersion,
+ start_session_ack_params);
+ } else {
+ SendStartSessionNAck(connection_id,
+ packet->session_id(),
+ protocol_version,
+ packet->service_type(),
+ rejected_params);
+ }
+ delete fullVersion;
+ bson_object_deinitialize(&start_session_ack_params);
+}
+
RESULT_CODE ProtocolHandlerImpl::HandleControlMessageHeartBeat(
const ProtocolPacket& packet) {
const ConnectionID connection_id = packet.connection_id();
@@ -1173,8 +1661,8 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessageHeartBeat(
if (session_observer_.ProtocolVersionUsed(
connection_id, packet.session_id(), protocol_version)) {
// TODO(EZamakhov): investigate message_id for HeartBeatAck
- if (PROTOCOL_VERSION_3 == protocol_version ||
- PROTOCOL_VERSION_4 == protocol_version) {
+ if (protocol_version >= PROTOCOL_VERSION_3 &&
+ protocol_version <= PROTOCOL_VERSION_5) {
return SendHeartBeatAck(
connection_id, packet.session_id(), packet.message_id());
} else {
@@ -1329,6 +1817,9 @@ void ProtocolHandlerImpl::Handle(const impl::RawFordMessageToMobile message) {
void ProtocolHandlerImpl::Stop() {
raw_ford_messages_from_mobile_.Shutdown();
raw_ford_messages_to_mobile_.Shutdown();
+
+ sync_primitives::AutoLock auto_lock(start_session_frame_map_lock_);
+ start_session_frame_map_.clear();
}
#ifdef ENABLE_SECURITY
@@ -1504,17 +1995,6 @@ std::string ConvertPacketDataToString(const uint8_t* data,
uint8_t ProtocolHandlerImpl::SupportedSDLProtocolVersion() const {
LOG4CXX_AUTO_TRACE(logger_);
-
- bool heart_beat_support = (0 != get_settings().heart_beat_timeout());
-
- bool sdl4_support = get_settings().enable_protocol_4();
-
- if (sdl4_support) {
- return PROTOCOL_VERSION_4;
- }
- if (heart_beat_support) {
- return PROTOCOL_VERSION_3;
- }
- return PROTOCOL_VERSION_2;
+ return get_settings().max_supported_protocol_version();
}
} // namespace protocol_handler
diff --git a/src/components/protocol_handler/src/protocol_packet.cc b/src/components/protocol_handler/src/protocol_packet.cc
index d766cf18c4..39871d5bae 100644
--- a/src/components/protocol_handler/src/protocol_packet.cc
+++ b/src/components/protocol_handler/src/protocol_packet.cc
@@ -52,6 +52,48 @@ ProtocolPacket::ProtocolData::~ProtocolData() {
delete[] data;
}
+ProtocolPacket::ProtocolVersion::ProtocolVersion()
+ : majorVersion(0), minorVersion(0), patchVersion(0) {}
+
+ProtocolPacket::ProtocolVersion::ProtocolVersion(uint8_t majorVersion,
+ uint8_t minorVersion,
+ uint8_t patchVersion)
+ : majorVersion(majorVersion)
+ , minorVersion(minorVersion)
+ , patchVersion(patchVersion) {}
+
+ProtocolPacket::ProtocolVersion::ProtocolVersion(ProtocolVersion& other) {
+ this->majorVersion = other.majorVersion;
+ this->minorVersion = other.minorVersion;
+ this->patchVersion = other.patchVersion;
+}
+
+ProtocolPacket::ProtocolVersion::ProtocolVersion(std::string versionString)
+ : majorVersion(0), minorVersion(0), patchVersion(0) {
+ unsigned int majorInt, minorInt, patchInt;
+ int readElements = sscanf(
+ versionString.c_str(), "%u.%u.%u", &majorInt, &minorInt, &patchInt);
+ if (readElements != 3) {
+ LOG4CXX_WARN(logger_,
+ "Error while parsing version string: " << versionString);
+ } else {
+ majorVersion = static_cast<uint8_t>(majorInt);
+ minorVersion = static_cast<uint8_t>(minorInt);
+ patchVersion = static_cast<uint8_t>(patchInt);
+ }
+}
+
+std::string ProtocolPacket::ProtocolVersion::to_string() {
+ char versionString[255];
+ snprintf(versionString,
+ 255,
+ "%u.%u.%u",
+ static_cast<unsigned int>(majorVersion),
+ static_cast<unsigned int>(minorVersion),
+ static_cast<unsigned int>(patchVersion));
+ return std::string(versionString);
+}
+
ProtocolPacket::ProtocolHeader::ProtocolHeader()
: version(0x00)
, protection_flag(PROTECTION_OFF)
@@ -114,7 +156,8 @@ void ProtocolPacket::ProtocolHeader::deserialize(const uint8_t* message,
switch (version) {
case PROTOCOL_VERSION_2:
case PROTOCOL_VERSION_3:
- case PROTOCOL_VERSION_4: {
+ case PROTOCOL_VERSION_4:
+ case PROTOCOL_VERSION_5: {
if (messageSize < PROTOCOL_HEADER_V2_SIZE) {
LOG4CXX_DEBUG(logger_,
"Message size less " << PROTOCOL_HEADER_V2_SIZE
@@ -131,7 +174,11 @@ void ProtocolPacket::ProtocolHeader::deserialize(const uint8_t* message,
}
ProtocolPacket::ProtocolHeaderValidator::ProtocolHeaderValidator()
- : max_payload_size_(std::numeric_limits<size_t>::max()) {}
+ : max_payload_size_(std::numeric_limits<size_t>::max())
+ , max_control_payload_size_(0)
+ , max_rpc_payload_size_(0)
+ , max_audio_payload_size_(0)
+ , max_video_payload_size_(0) {}
void ProtocolPacket::ProtocolHeaderValidator::set_max_payload_size(
const size_t max_payload_size) {
@@ -139,15 +186,92 @@ void ProtocolPacket::ProtocolHeaderValidator::set_max_payload_size(
max_payload_size_ = max_payload_size;
}
+void ProtocolPacket::ProtocolHeaderValidator::set_max_control_payload_size(
+ const size_t max_payload_size) {
+ LOG4CXX_DEBUG(logger_,
+ "New maximum Control payload size is " << max_payload_size);
+ max_control_payload_size_ = max_payload_size;
+}
+
+void ProtocolPacket::ProtocolHeaderValidator::set_max_rpc_payload_size(
+ const size_t max_payload_size) {
+ LOG4CXX_DEBUG(logger_,
+ "New maximum RPC payload size is " << max_payload_size);
+ max_rpc_payload_size_ = max_payload_size;
+}
+
+void ProtocolPacket::ProtocolHeaderValidator::set_max_audio_payload_size(
+ const size_t max_payload_size) {
+ LOG4CXX_DEBUG(logger_,
+ "New maximum audio payload size is " << max_payload_size);
+ max_audio_payload_size_ = max_payload_size;
+}
+
+void ProtocolPacket::ProtocolHeaderValidator::set_max_video_payload_size(
+ const size_t max_payload_size) {
+ LOG4CXX_DEBUG(logger_,
+ "New maximum video payload size is " << max_payload_size);
+ max_video_payload_size_ = max_payload_size;
+}
+
size_t ProtocolPacket::ProtocolHeaderValidator::max_payload_size() const {
return max_payload_size_;
}
+size_t ProtocolPacket::ProtocolHeaderValidator::max_control_payload_size()
+ const {
+ return max_control_payload_size_;
+}
+
+size_t ProtocolPacket::ProtocolHeaderValidator::max_rpc_payload_size() const {
+ return max_rpc_payload_size_;
+}
+
+size_t ProtocolPacket::ProtocolHeaderValidator::max_audio_payload_size() const {
+ return max_audio_payload_size_;
+}
+
+size_t ProtocolPacket::ProtocolHeaderValidator::max_video_payload_size() const {
+ return max_video_payload_size_;
+}
+
+size_t
+ProtocolPacket::ProtocolHeaderValidator::max_payload_size_by_service_type(
+ const ServiceType type) const {
+ size_t payload_size = 0;
+ switch (type) {
+ case kControl:
+ // Default to the generic MTU if specific MTU is not set
+ payload_size = max_control_payload_size_ == 0 ? max_payload_size_
+ : max_control_payload_size_;
+ break;
+ case kBulk:
+ case kRpc:
+ // Default to the generic MTU if specific MTU is not set
+ payload_size = max_rpc_payload_size_ == 0 ? max_payload_size_
+ : max_rpc_payload_size_;
+ break;
+ case kAudio:
+ // Default to the generic MTU if specific MTU is not set
+ payload_size = max_audio_payload_size_ == 0 ? max_payload_size_
+ : max_audio_payload_size_;
+ break;
+ case kMobileNav:
+ // Default to the generic MTU if specific MTU is not set
+ payload_size = max_video_payload_size_ == 0 ? max_payload_size_
+ : max_video_payload_size_;
+ break;
+ case kInvalidServiceType:
+ LOG4CXX_WARN(logger_, "Invalid service type: " << static_cast<int>(type));
+ }
+ return payload_size;
+}
+
RESULT_CODE ProtocolPacket::ProtocolHeaderValidator::validate(
const ProtocolHeader& header) const {
LOG4CXX_DEBUG(logger_, "Validating header - " << header);
// expected payload size will be calculated depending
- // on used protocol version
+ // on used protocol version and service type
size_t payload_size = MAXIMUM_FRAME_DATA_V2_SIZE;
// Protocol version shall be from 1 to 4
switch (header.version) {
@@ -160,6 +284,10 @@ RESULT_CODE ProtocolPacket::ProtocolHeaderValidator::validate(
? max_payload_size_
: MAXIMUM_FRAME_DATA_V2_SIZE;
break;
+ case PROTOCOL_VERSION_5:
+ payload_size = max_payload_size_by_service_type(
+ ServiceTypeFromByte(header.serviceType));
+ break;
default:
LOG4CXX_WARN(logger_,
"Unknown version:" << static_cast<int>(header.version));
diff --git a/src/components/protocol_handler/test/incoming_data_handler_test.cc b/src/components/protocol_handler/test/incoming_data_handler_test.cc
index 66f5aea712..d0a311583c 100644
--- a/src/components/protocol_handler/test/incoming_data_handler_test.cc
+++ b/src/components/protocol_handler/test/incoming_data_handler_test.cc
@@ -262,7 +262,7 @@ TEST_F(IncomingDataHandlerTest, MalformedPacket_Version) {
FrameList malformed_packets;
std::vector<uint8_t> malformed_versions;
malformed_versions.push_back(0);
- for (uint8_t version = PROTOCOL_VERSION_4 + 1;
+ for (uint8_t version = PROTOCOL_VERSION_5 + 1;
version <= PROTOCOL_VERSION_MAX;
++version) {
malformed_versions.push_back(version);
diff --git a/src/components/protocol_handler/test/protocol_handler_tm_test.cc b/src/components/protocol_handler/test/protocol_handler_tm_test.cc
index 308901e013..89b9faedaa 100644
--- a/src/components/protocol_handler/test/protocol_handler_tm_test.cc
+++ b/src/components/protocol_handler/test/protocol_handler_tm_test.cc
@@ -33,6 +33,7 @@
#include <string>
#include "protocol_handler/protocol_handler.h"
#include "protocol_handler/protocol_handler_impl.h"
+#include "protocol/bson_object_keys.h"
#include "protocol/common.h"
#include "protocol_handler/control_message_matcher.h"
#include "protocol_handler/mock_protocol_handler.h"
@@ -45,6 +46,7 @@
#include "transport_manager/mock_transport_manager.h"
#include "utils/make_shared.h"
#include "utils/test_async_waiter.h"
+#include <bson_object.h>
namespace test {
namespace components {
@@ -96,8 +98,11 @@ using connection_handler::DeviceHandle;
using ::testing::Return;
using ::testing::ReturnRefOfCopy;
using ::testing::ReturnNull;
+using ::testing::An;
using ::testing::AnyOf;
+using ::testing::ByRef;
using ::testing::DoAll;
+using ::testing::Eq;
using ::testing::_;
using ::testing::Invoke;
using ::testing::SetArgReferee;
@@ -105,6 +110,11 @@ using ::testing::SetArgPointee;
typedef std::vector<uint8_t> UCharDataVector;
+// custom action to call a member function with 6 arguments
+ACTION_P8(InvokeMemberFuncWithArg6, ptr, memberFunc, a, b, c, d, e, f) {
+ (ptr->*memberFunc)(a, b, c, d, e, f);
+}
+
namespace {
const uint32_t kAsyncExpectationsTimeout = 10000u;
}
@@ -178,6 +188,7 @@ class ProtocolHandlerImplTest : public ::testing::Test {
void AddSession(const ::utils::SharedPtr<TestAsyncWaiter>& waiter,
uint32_t& times) {
+ using namespace protocol_handler;
ASSERT_TRUE(NULL != waiter.get());
AddConnection();
@@ -198,10 +209,19 @@ class ProtocolHandlerImplTest : public ::testing::Test {
NEW_SESSION_ID,
start_service,
callback_protection_flag,
- _))
+ An<const BsonObject*>()))
.
// Return sessions start success
- WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(session_id)));
+ WillOnce(DoAll(NotifyTestAsyncWaiter(waiter),
+ InvokeMemberFuncWithArg6(
+ protocol_handler_impl.get(),
+ &ProtocolHandler::NotifySessionStartedResult,
+ connection_id,
+ NEW_SESSION_ID,
+ session_id,
+ HASH_ID_WRONG,
+ callback_protection_flag,
+ ByRef(empty_rejected_param_))));
times++;
// Expect send Ack with PROTECTION_OFF (on no Security Manager)
@@ -294,6 +314,7 @@ class ProtocolHandlerImplTest : public ::testing::Test {
security_manager_mock;
testing::NiceMock<security_manager_test::MockSSLContext> ssl_context_mock;
#endif // ENABLE_SECURITY
+ std::vector<std::string> empty_rejected_param_;
};
#ifdef ENABLE_SECURITY
@@ -341,6 +362,7 @@ TEST_F(ProtocolHandlerImplTest, RecieveOnUnknownConnection) {
*/
TEST_F(ProtocolHandlerImplTest,
StartSession_Unprotected_SessionObserverReject) {
+ using namespace protocol_handler;
const int call_times = 5;
AddConnection();
@@ -353,12 +375,20 @@ TEST_F(ProtocolHandlerImplTest,
NEW_SESSION_ID,
AnyOf(kControl, kRpc, kAudio, kMobileNav, kBulk),
PROTECTION_OFF,
- _))
+ An<const BsonObject*>()))
.Times(call_times)
.
// Return sessions start rejection
- WillRepeatedly(
- DoAll(NotifyTestAsyncWaiter(&waiter), Return(SESSION_START_REJECT)));
+ WillRepeatedly(DoAll(
+ NotifyTestAsyncWaiter(&waiter),
+ InvokeMemberFuncWithArg6(protocol_handler_impl.get(),
+ &ProtocolHandler::NotifySessionStartedResult,
+ connection_id,
+ NEW_SESSION_ID,
+ SESSION_START_REJECT,
+ HASH_ID_WRONG,
+ PROTECTION_OFF,
+ ByRef(empty_rejected_param_))));
times += call_times;
// Expect send NAck
@@ -389,6 +419,7 @@ TEST_F(ProtocolHandlerImplTest,
* OFF
*/
TEST_F(ProtocolHandlerImplTest, StartSession_Protected_SessionObserverReject) {
+ using namespace protocol_handler;
const int call_times = 5;
AddConnection();
#ifdef ENABLE_SECURITY
@@ -409,12 +440,20 @@ TEST_F(ProtocolHandlerImplTest, StartSession_Protected_SessionObserverReject) {
NEW_SESSION_ID,
AnyOf(kControl, kRpc, kAudio, kMobileNav, kBulk),
callback_protection_flag,
- _))
+ An<const BsonObject*>()))
.Times(call_times)
.
// Return sessions start rejection
- WillRepeatedly(
- DoAll(NotifyTestAsyncWaiter(&waiter), Return(SESSION_START_REJECT)));
+ WillRepeatedly(DoAll(
+ NotifyTestAsyncWaiter(&waiter),
+ InvokeMemberFuncWithArg6(protocol_handler_impl.get(),
+ &ProtocolHandler::NotifySessionStartedResult,
+ connection_id,
+ NEW_SESSION_ID,
+ SESSION_START_REJECT,
+ HASH_ID_WRONG,
+ callback_protection_flag,
+ ByRef(empty_rejected_param_))));
times += call_times;
// Expect send NAck with encryption OFF
@@ -444,19 +483,31 @@ TEST_F(ProtocolHandlerImplTest, StartSession_Protected_SessionObserverReject) {
*/
TEST_F(ProtocolHandlerImplTest,
StartSession_Unprotected_SessionObserverAccept) {
+ using namespace protocol_handler;
AddConnection();
const ServiceType start_service = kRpc;
TestAsyncWaiter waiter;
uint32_t times = 0;
// Expect ConnectionHandler check
- EXPECT_CALL(
- session_observer_mock,
- OnSessionStartedCallback(
- connection_id, NEW_SESSION_ID, start_service, PROTECTION_OFF, _))
+ EXPECT_CALL(session_observer_mock,
+ OnSessionStartedCallback(connection_id,
+ NEW_SESSION_ID,
+ start_service,
+ PROTECTION_OFF,
+ An<const BsonObject*>()))
.
// Return sessions start success
- WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(session_id)));
+ WillOnce(DoAll(
+ NotifyTestAsyncWaiter(&waiter),
+ InvokeMemberFuncWithArg6(protocol_handler_impl.get(),
+ &ProtocolHandler::NotifySessionStartedResult,
+ connection_id,
+ NEW_SESSION_ID,
+ session_id,
+ HASH_ID_WRONG,
+ PROTECTION_OFF,
+ ByRef(empty_rejected_param_))));
times++;
SetProtocolVersion2();
@@ -489,6 +540,193 @@ TEST_F(ProtocolHandlerImplTest, StartSession_Protected_SessionObserverAccept) {
EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout));
}
+
+static std::vector<uint8_t> CreateVectorFromBsonObject(const BsonObject* bo) {
+ std::vector<uint8_t> output;
+ if (bo != NULL) {
+ size_t len = bson_object_size(const_cast<BsonObject*>(bo));
+ uint8_t* bytes = bson_object_to_bytes(const_cast<BsonObject*>(bo));
+ output.assign(bytes, bytes + len);
+ free(bytes);
+ }
+ return output;
+}
+
+/*
+ * Simulate two StartService messages of video service from mobile.
+ * Session observer accepts the first message with delay, while rejects the
+ * second message immediately.
+ */
+TEST_F(ProtocolHandlerImplTest,
+ StartSession_Unprotected_Multiple_SessionObserverAcceptAndReject) {
+ using namespace protocol_handler;
+
+ ON_CALL(protocol_handler_settings_mock, max_supported_protocol_version())
+ .WillByDefault(Return(PROTOCOL_VERSION_5));
+
+ const size_t maximum_payload_size = 1000;
+ InitProtocolHandlerImpl(0u, 0u, false, 0u, 0u, 0, maximum_payload_size);
+
+ const ServiceType start_service = kMobileNav;
+ const ::transport_manager::ConnectionUID connection_id1 = 0xAu;
+ const uint8_t session_id1 = 1u;
+ const ::transport_manager::ConnectionUID connection_id2 = 0xBu;
+ const uint8_t session_id2 = 2u;
+
+ EXPECT_CALL(session_observer_mock, IsHeartBeatSupported(connection_id1, _))
+ .WillRepeatedly(Return(false));
+ EXPECT_CALL(session_observer_mock, IsHeartBeatSupported(connection_id2, _))
+ .WillRepeatedly(Return(false));
+
+ // Add two connections
+ tm_listener->OnConnectionEstablished(DeviceInfo(DeviceHandle(1u),
+ std::string("mac"),
+ std::string("name"),
+ std::string("BTMAC")),
+ connection_id1);
+ tm_listener->OnConnectionEstablished(DeviceInfo(DeviceHandle(2u),
+ std::string("mac"),
+ std::string("name"),
+ std::string("BTMAC")),
+ connection_id2);
+
+ TestAsyncWaiter waiter;
+ uint32_t times = 0;
+
+ BsonObject bson_params1;
+ bson_object_initialize_default(&bson_params1);
+ bson_object_put_string(&bson_params1,
+ protocol_handler::strings::video_protocol,
+ const_cast<char*>("RAW"));
+ bson_object_put_string(&bson_params1,
+ protocol_handler::strings::video_codec,
+ const_cast<char*>("H264"));
+ std::vector<uint8_t> params1 = CreateVectorFromBsonObject(&bson_params1);
+
+ uint8_t generated_session_id1 = 100;
+
+ EXPECT_CALL(session_observer_mock,
+ OnSessionStartedCallback(connection_id1,
+ session_id1,
+ start_service,
+ PROTECTION_OFF,
+ An<const BsonObject*>()))
+ // don't call NotifySessionStartedResult() immediately, instead call it
+ // after second OnSessionStartedCallback()
+ .WillOnce(NotifyTestAsyncWaiter(&waiter));
+ times++;
+
+ BsonObject bson_params2;
+ bson_object_initialize_default(&bson_params2);
+ bson_object_put_string(&bson_params2,
+ protocol_handler::strings::video_protocol,
+ const_cast<char*>("RTP"));
+ bson_object_put_string(&bson_params2,
+ protocol_handler::strings::video_codec,
+ const_cast<char*>("H265"));
+ std::vector<uint8_t> params2 = CreateVectorFromBsonObject(&bson_params2);
+
+ std::vector<std::string> rejected_param_list;
+ rejected_param_list.push_back(protocol_handler::strings::video_codec);
+
+ EXPECT_CALL(session_observer_mock,
+ OnSessionStartedCallback(connection_id2,
+ session_id2,
+ start_service,
+ PROTECTION_OFF,
+ An<const BsonObject*>()))
+ .WillOnce(DoAll(
+ NotifyTestAsyncWaiter(&waiter),
+ InvokeMemberFuncWithArg6(protocol_handler_impl.get(),
+ &ProtocolHandler::NotifySessionStartedResult,
+ connection_id2,
+ session_id2,
+ SESSION_START_REJECT,
+ HASH_ID_WRONG,
+ PROTECTION_OFF,
+ ByRef(rejected_param_list)),
+ InvokeMemberFuncWithArg6(protocol_handler_impl.get(),
+ &ProtocolHandler::NotifySessionStartedResult,
+ connection_id1,
+ session_id1,
+ generated_session_id1,
+ HASH_ID_WRONG,
+ PROTECTION_OFF,
+ ByRef(empty_rejected_param_))));
+ times++;
+
+ BsonObject bson_ack_params;
+ bson_object_initialize_default(&bson_ack_params);
+ bson_object_put_int64(
+ &bson_ack_params, protocol_handler::strings::mtu, maximum_payload_size);
+ bson_object_put_string(&bson_ack_params,
+ protocol_handler::strings::video_protocol,
+ const_cast<char*>("RAW"));
+ bson_object_put_string(&bson_ack_params,
+ protocol_handler::strings::video_codec,
+ const_cast<char*>("H264"));
+ std::vector<uint8_t> ack_params =
+ CreateVectorFromBsonObject(&bson_ack_params);
+ bson_object_deinitialize(&bson_ack_params);
+
+ EXPECT_CALL(transport_manager_mock,
+ SendMessageToDevice(ControlMessage(FRAME_DATA_START_SERVICE_ACK,
+ PROTECTION_OFF,
+ connection_id1,
+ Eq(ack_params))))
+ .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS)));
+ times++;
+
+ BsonArray bson_arr;
+ bson_array_initialize(&bson_arr, rejected_param_list.size());
+ for (unsigned int i = 0; i < rejected_param_list.size(); i++) {
+ bson_array_add_string(&bson_arr,
+ const_cast<char*>(rejected_param_list[i].c_str()));
+ }
+ BsonObject bson_nack_params;
+ bson_object_initialize_default(&bson_nack_params);
+ bson_object_put_array(
+ &bson_nack_params, protocol_handler::strings::rejected_params, &bson_arr);
+ std::vector<uint8_t> nack_params =
+ CreateVectorFromBsonObject(&bson_nack_params);
+ bson_object_deinitialize(&bson_nack_params);
+
+ EXPECT_CALL(transport_manager_mock,
+ SendMessageToDevice(ControlMessage(FRAME_DATA_START_SERVICE_NACK,
+ PROTECTION_OFF,
+ connection_id2,
+ Eq(nack_params))))
+ .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS)));
+ times++;
+
+ SendTMMessage(connection_id1,
+ PROTOCOL_VERSION_5,
+ PROTECTION_OFF,
+ FRAME_TYPE_CONTROL,
+ start_service,
+ FRAME_DATA_START_SERVICE,
+ session_id1,
+ params1.size(),
+ message_id,
+ params1.size() > 0 ? &params1[0] : NULL);
+
+ SendTMMessage(connection_id2,
+ PROTOCOL_VERSION_5,
+ PROTECTION_OFF,
+ FRAME_TYPE_CONTROL,
+ start_service,
+ FRAME_DATA_START_SERVICE,
+ session_id2,
+ params2.size(),
+ message_id,
+ params2.size() > 0 ? &params2[0] : NULL);
+
+ EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout));
+
+ bson_object_deinitialize(&bson_params1);
+ bson_object_deinitialize(&bson_params2);
+}
+
// TODO(EZamakhov): add test for get_hash_id/set_hash_id from
// protocol_handler_impl.cc
/*
@@ -500,12 +738,12 @@ TEST_F(ProtocolHandlerImplTest, EndSession_SessionObserverReject) {
uint32_t times = 0;
AddSession(waiter, times);
-
const ServiceType service = kRpc;
// Expect ConnectionHandler check
EXPECT_CALL(session_observer_mock,
- OnSessionEndedCallback(connection_id, session_id, _, service))
+ OnSessionEndedCallback(
+ connection_id, session_id, An<uint32_t*>(), service))
.
// reject session start
WillOnce(
@@ -539,7 +777,8 @@ TEST_F(ProtocolHandlerImplTest, EndSession_Success) {
// Expect ConnectionHandler check
EXPECT_CALL(session_observer_mock,
- OnSessionEndedCallback(connection_id, session_id, _, service))
+ OnSessionEndedCallback(
+ connection_id, session_id, An<uint32_t*>(), service))
.
// return sessions start success
WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(connection_key)));
@@ -565,6 +804,7 @@ TEST_F(ProtocolHandlerImplTest, EndSession_Success) {
* Check session_observer with PROTECTION_OFF and Ack with PROTECTION_OFF
*/
TEST_F(ProtocolHandlerImplTest, SecurityEnable_StartSessionProtocoloV1) {
+ using namespace protocol_handler;
::utils::SharedPtr<TestAsyncWaiter> waiter =
utils::MakeShared<TestAsyncWaiter>();
uint32_t times = 0;
@@ -575,13 +815,24 @@ TEST_F(ProtocolHandlerImplTest, SecurityEnable_StartSessionProtocoloV1) {
AddSecurityManager();
const ServiceType start_service = kRpc;
// Expect ConnectionHandler check
- EXPECT_CALL(
- session_observer_mock,
- OnSessionStartedCallback(
- connection_id, NEW_SESSION_ID, start_service, PROTECTION_OFF, _))
+ EXPECT_CALL(session_observer_mock,
+ OnSessionStartedCallback(connection_id,
+ NEW_SESSION_ID,
+ start_service,
+ PROTECTION_OFF,
+ An<const BsonObject*>()))
.
// Return sessions start success
- WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(session_id)));
+ WillOnce(DoAll(
+ NotifyTestAsyncWaiter(waiter),
+ InvokeMemberFuncWithArg6(protocol_handler_impl.get(),
+ &ProtocolHandler::NotifySessionStartedResult,
+ connection_id,
+ NEW_SESSION_ID,
+ session_id,
+ HASH_ID_WRONG,
+ PROTECTION_OFF,
+ ByRef(empty_rejected_param_))));
times++;
SetProtocolVersion2();
@@ -610,6 +861,7 @@ TEST_F(ProtocolHandlerImplTest, SecurityEnable_StartSessionProtocoloV1) {
* PROTECTION_OFF
*/
TEST_F(ProtocolHandlerImplTest, SecurityEnable_StartSessionUnprotected) {
+ using namespace protocol_handler;
AddConnection();
// Add security manager
AddSecurityManager();
@@ -618,13 +870,24 @@ TEST_F(ProtocolHandlerImplTest, SecurityEnable_StartSessionUnprotected) {
TestAsyncWaiter waiter;
uint32_t times = 0;
// Expect ConnectionHandler check
- EXPECT_CALL(
- session_observer_mock,
- OnSessionStartedCallback(
- connection_id, NEW_SESSION_ID, start_service, PROTECTION_OFF, _))
+ EXPECT_CALL(session_observer_mock,
+ OnSessionStartedCallback(connection_id,
+ NEW_SESSION_ID,
+ start_service,
+ PROTECTION_OFF,
+ An<const BsonObject*>()))
.
// Return sessions start success
- WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(session_id)));
+ WillOnce(DoAll(
+ NotifyTestAsyncWaiter(&waiter),
+ InvokeMemberFuncWithArg6(protocol_handler_impl.get(),
+ &ProtocolHandler::NotifySessionStartedResult,
+ connection_id,
+ NEW_SESSION_ID,
+ session_id,
+ HASH_ID_WRONG,
+ PROTECTION_OFF,
+ ByRef(empty_rejected_param_))));
times++;
SetProtocolVersion2();
@@ -644,6 +907,7 @@ TEST_F(ProtocolHandlerImplTest, SecurityEnable_StartSessionUnprotected) {
* ProtocolHandler shall send Ack with PROTECTION_OFF on fail SLL creation
*/
TEST_F(ProtocolHandlerImplTest, SecurityEnable_StartSessionProtected_Fail) {
+ using namespace protocol_handler;
AddConnection();
AddSecurityManager();
const ServiceType start_service = kRpc;
@@ -651,13 +915,24 @@ TEST_F(ProtocolHandlerImplTest, SecurityEnable_StartSessionProtected_Fail) {
TestAsyncWaiter waiter;
uint32_t times = 0;
// Expect ConnectionHandler check
- EXPECT_CALL(
- session_observer_mock,
- OnSessionStartedCallback(
- connection_id, NEW_SESSION_ID, start_service, PROTECTION_ON, _))
+ EXPECT_CALL(session_observer_mock,
+ OnSessionStartedCallback(connection_id,
+ NEW_SESSION_ID,
+ start_service,
+ PROTECTION_ON,
+ An<const BsonObject*>()))
.
// Return sessions start success
- WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(session_id)));
+ WillOnce(DoAll(
+ NotifyTestAsyncWaiter(&waiter),
+ InvokeMemberFuncWithArg6(protocol_handler_impl.get(),
+ &ProtocolHandler::NotifySessionStartedResult,
+ connection_id,
+ NEW_SESSION_ID,
+ session_id,
+ HASH_ID_WRONG,
+ PROTECTION_ON,
+ ByRef(empty_rejected_param_))));
times++;
SetProtocolVersion2();
@@ -686,6 +961,7 @@ TEST_F(ProtocolHandlerImplTest, SecurityEnable_StartSessionProtected_Fail) {
*/
TEST_F(ProtocolHandlerImplTest,
SecurityEnable_StartSessionProtected_SSLInitialized) {
+ using namespace protocol_handler;
AddConnection();
AddSecurityManager();
const ServiceType start_service = kRpc;
@@ -693,13 +969,24 @@ TEST_F(ProtocolHandlerImplTest,
TestAsyncWaiter waiter;
uint32_t times = 0;
// Expect ConnectionHandler check
- EXPECT_CALL(
- session_observer_mock,
- OnSessionStartedCallback(
- connection_id, NEW_SESSION_ID, start_service, PROTECTION_ON, _))
+ EXPECT_CALL(session_observer_mock,
+ OnSessionStartedCallback(connection_id,
+ NEW_SESSION_ID,
+ start_service,
+ PROTECTION_ON,
+ An<const BsonObject*>()))
.
// Return sessions start success
- WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(session_id)));
+ WillOnce(DoAll(
+ NotifyTestAsyncWaiter(&waiter),
+ InvokeMemberFuncWithArg6(protocol_handler_impl.get(),
+ &ProtocolHandler::NotifySessionStartedResult,
+ connection_id,
+ NEW_SESSION_ID,
+ session_id,
+ HASH_ID_WRONG,
+ PROTECTION_ON,
+ ByRef(empty_rejected_param_))));
times++;
SetProtocolVersion2();
@@ -741,6 +1028,7 @@ TEST_F(ProtocolHandlerImplTest,
*/
TEST_F(ProtocolHandlerImplTest,
SecurityEnable_StartSessionProtected_HandshakeFail) {
+ using namespace protocol_handler;
AddConnection();
AddSecurityManager();
const ServiceType start_service = kRpc;
@@ -748,13 +1036,24 @@ TEST_F(ProtocolHandlerImplTest,
TestAsyncWaiter waiter;
uint32_t times = 0;
// Expect ConnectionHandler check
- EXPECT_CALL(
- session_observer_mock,
- OnSessionStartedCallback(
- connection_id, NEW_SESSION_ID, start_service, PROTECTION_ON, _))
+ EXPECT_CALL(session_observer_mock,
+ OnSessionStartedCallback(connection_id,
+ NEW_SESSION_ID,
+ start_service,
+ PROTECTION_ON,
+ An<const BsonObject*>()))
.
// Return sessions start success
- WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(session_id)));
+ WillOnce(DoAll(
+ NotifyTestAsyncWaiter(&waiter),
+ InvokeMemberFuncWithArg6(protocol_handler_impl.get(),
+ &ProtocolHandler::NotifySessionStartedResult,
+ connection_id,
+ NEW_SESSION_ID,
+ session_id,
+ HASH_ID_WRONG,
+ PROTECTION_ON,
+ ByRef(empty_rejected_param_))));
times++;
std::vector<int> services;
@@ -816,6 +1115,7 @@ TEST_F(ProtocolHandlerImplTest,
*/
TEST_F(ProtocolHandlerImplTest,
SecurityEnable_StartSessionProtected_HandshakeSuccess) {
+ using namespace protocol_handler;
AddConnection();
AddSecurityManager();
const ServiceType start_service = kRpc;
@@ -828,13 +1128,24 @@ TEST_F(ProtocolHandlerImplTest,
TestAsyncWaiter waiter;
uint32_t times = 0;
// Expect ConnectionHandler check
- EXPECT_CALL(
- session_observer_mock,
- OnSessionStartedCallback(
- connection_id, NEW_SESSION_ID, start_service, PROTECTION_ON, _))
+ EXPECT_CALL(session_observer_mock,
+ OnSessionStartedCallback(connection_id,
+ NEW_SESSION_ID,
+ start_service,
+ PROTECTION_ON,
+ An<const BsonObject*>()))
.
// Return sessions start success
- WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(session_id)));
+ WillOnce(DoAll(
+ NotifyTestAsyncWaiter(&waiter),
+ InvokeMemberFuncWithArg6(protocol_handler_impl.get(),
+ &ProtocolHandler::NotifySessionStartedResult,
+ connection_id,
+ NEW_SESSION_ID,
+ session_id,
+ HASH_ID_WRONG,
+ PROTECTION_ON,
+ ByRef(empty_rejected_param_))));
times++;
// call new SSLContext creation
@@ -902,6 +1213,7 @@ TEST_F(ProtocolHandlerImplTest,
TEST_F(
ProtocolHandlerImplTest,
SecurityEnable_StartSessionProtected_HandshakeSuccess_ServiceProtectedBefore) {
+ using namespace protocol_handler;
AddConnection();
AddSecurityManager();
const ServiceType start_service = kRpc;
@@ -913,13 +1225,24 @@ TEST_F(
TestAsyncWaiter waiter;
uint32_t times = 0;
// Expect ConnectionHandler check
- EXPECT_CALL(
- session_observer_mock,
- OnSessionStartedCallback(
- connection_id, NEW_SESSION_ID, start_service, PROTECTION_ON, _))
+ EXPECT_CALL(session_observer_mock,
+ OnSessionStartedCallback(connection_id,
+ NEW_SESSION_ID,
+ start_service,
+ PROTECTION_ON,
+ An<const BsonObject*>()))
.
// Return sessions start success
- WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(session_id)));
+ WillOnce(DoAll(
+ NotifyTestAsyncWaiter(&waiter),
+ InvokeMemberFuncWithArg6(protocol_handler_impl.get(),
+ &ProtocolHandler::NotifySessionStartedResult,
+ connection_id,
+ NEW_SESSION_ID,
+ session_id,
+ HASH_ID_WRONG,
+ PROTECTION_ON,
+ ByRef(empty_rejected_param_))));
times++;
// call new SSLContext creation
@@ -985,6 +1308,7 @@ TEST_F(
*/
TEST_F(ProtocolHandlerImplTest,
SecurityEnable_StartSessionProtected_HandshakeSuccess_SSLIsNotPending) {
+ using namespace protocol_handler;
AddConnection();
AddSecurityManager();
const ServiceType start_service = kRpc;
@@ -996,13 +1320,24 @@ TEST_F(ProtocolHandlerImplTest,
TestAsyncWaiter waiter;
uint32_t times = 0;
// Expect ConnectionHandler check
- EXPECT_CALL(
- session_observer_mock,
- OnSessionStartedCallback(
- connection_id, NEW_SESSION_ID, start_service, PROTECTION_ON, _))
+ EXPECT_CALL(session_observer_mock,
+ OnSessionStartedCallback(connection_id,
+ NEW_SESSION_ID,
+ start_service,
+ PROTECTION_ON,
+ An<const BsonObject*>()))
.
// Return sessions start success
- WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(session_id)));
+ WillOnce(DoAll(
+ NotifyTestAsyncWaiter(&waiter),
+ InvokeMemberFuncWithArg6(protocol_handler_impl.get(),
+ &ProtocolHandler::NotifySessionStartedResult,
+ connection_id,
+ NEW_SESSION_ID,
+ session_id,
+ HASH_ID_WRONG,
+ PROTECTION_ON,
+ ByRef(empty_rejected_param_))));
times++;
// call new SSLContext creation
diff --git a/src/components/protocol_handler/test/protocol_header_validator_test.cc b/src/components/protocol_handler/test/protocol_header_validator_test.cc
index 40b0f34846..e42ba96251 100644
--- a/src/components/protocol_handler/test/protocol_header_validator_test.cc
+++ b/src/components/protocol_handler/test/protocol_header_validator_test.cc
@@ -57,7 +57,7 @@ class ProtocolHeaderValidatorTest : public ::testing::Test {
uint32_t some_session_id;
};
-// Protocol version shall be from 1 to 3
+// Protocol version shall be from 1 to 5
TEST_F(ProtocolHeaderValidatorTest, MaxPayloadSizeSetGet) {
EXPECT_EQ(std::numeric_limits<size_t>::max(),
header_validator.max_payload_size());
@@ -67,11 +67,96 @@ TEST_F(ProtocolHeaderValidatorTest, MaxPayloadSizeSetGet) {
}
}
-// Protocol version shall be from 1 to 4
+TEST_F(ProtocolHeaderValidatorTest, MaxControlPayloadSizeSetGet) {
+ EXPECT_EQ(0u, header_validator.max_control_payload_size());
+ for (size_t value = 0; value < MAXIMUM_FRAME_DATA_V3_SIZE * 2; ++value) {
+ header_validator.set_max_control_payload_size(value);
+ EXPECT_EQ(value, header_validator.max_control_payload_size());
+ }
+}
+
+TEST_F(ProtocolHeaderValidatorTest, MaxRpcPayloadSizeSetGet) {
+ EXPECT_EQ(0u, header_validator.max_rpc_payload_size());
+ for (size_t value = 0; value < MAXIMUM_FRAME_DATA_V3_SIZE * 2; ++value) {
+ header_validator.set_max_rpc_payload_size(value);
+ EXPECT_EQ(value, header_validator.max_rpc_payload_size());
+ }
+}
+
+TEST_F(ProtocolHeaderValidatorTest, MaxAudioPayloadSizeSetGet) {
+ EXPECT_EQ(0u, header_validator.max_audio_payload_size());
+ for (size_t value = 0; value < MAXIMUM_FRAME_DATA_V3_SIZE * 2; ++value) {
+ header_validator.set_max_audio_payload_size(value);
+ EXPECT_EQ(value, header_validator.max_audio_payload_size());
+ }
+}
+
+TEST_F(ProtocolHeaderValidatorTest, MaxVideoPayloadSizeSetGet) {
+ EXPECT_EQ(0u, header_validator.max_video_payload_size());
+ for (size_t value = 0; value < MAXIMUM_FRAME_DATA_V3_SIZE * 2; ++value) {
+ header_validator.set_max_video_payload_size(value);
+ EXPECT_EQ(value, header_validator.max_video_payload_size());
+ }
+}
+
+TEST_F(ProtocolHeaderValidatorTest, GetMaxPayloadSizeByServiceType_Control) {
+ size_t payload_size = MAXIMUM_FRAME_DATA_V2_SIZE;
+ header_validator.set_max_payload_size(payload_size);
+ // Default to max_payload_size if a specific MTU is not set
+ EXPECT_EQ(payload_size,
+ header_validator.max_payload_size_by_service_type(kControl));
+ for (size_t value = 1; value < MAXIMUM_FRAME_DATA_V3_SIZE * 2; ++value) {
+ header_validator.set_max_control_payload_size(value);
+ EXPECT_EQ(value,
+ header_validator.max_payload_size_by_service_type(kControl));
+ }
+}
+
+TEST_F(ProtocolHeaderValidatorTest, GetMaxPayloadSizeByServiceType_Rpc) {
+ size_t payload_size = MAXIMUM_FRAME_DATA_V2_SIZE;
+ header_validator.set_max_payload_size(payload_size);
+ // Default to max_payload_size if a specific MTU is not set
+ EXPECT_EQ(payload_size,
+ header_validator.max_payload_size_by_service_type(kRpc));
+ EXPECT_EQ(payload_size,
+ header_validator.max_payload_size_by_service_type(kBulk));
+ for (size_t value = 1; value < MAXIMUM_FRAME_DATA_V3_SIZE * 2; ++value) {
+ header_validator.set_max_rpc_payload_size(value);
+ EXPECT_EQ(value, header_validator.max_payload_size_by_service_type(kRpc));
+ EXPECT_EQ(value, header_validator.max_payload_size_by_service_type(kBulk));
+ }
+}
+
+TEST_F(ProtocolHeaderValidatorTest, GetMaxPayloadSizeByServiceType_Audio) {
+ size_t payload_size = MAXIMUM_FRAME_DATA_V2_SIZE;
+ header_validator.set_max_payload_size(payload_size);
+ // Default to max_payload_size if a specific MTU is not set
+ EXPECT_EQ(payload_size,
+ header_validator.max_payload_size_by_service_type(kAudio));
+ for (size_t value = 1; value < MAXIMUM_FRAME_DATA_V3_SIZE * 2; ++value) {
+ header_validator.set_max_audio_payload_size(value);
+ EXPECT_EQ(value, header_validator.max_payload_size_by_service_type(kAudio));
+ }
+}
+
+TEST_F(ProtocolHeaderValidatorTest, GetMaxPayloadSizeByServiceType_Video) {
+ size_t payload_size = MAXIMUM_FRAME_DATA_V2_SIZE;
+ header_validator.set_max_payload_size(payload_size);
+ // Default to max_payload_size if a specific MTU is not set
+ EXPECT_EQ(payload_size,
+ header_validator.max_payload_size_by_service_type(kMobileNav));
+ for (size_t value = 1; value < MAXIMUM_FRAME_DATA_V3_SIZE * 2; ++value) {
+ header_validator.set_max_video_payload_size(value);
+ EXPECT_EQ(value,
+ header_validator.max_payload_size_by_service_type(kMobileNav));
+ }
+}
+
+// Protocol version shall be from 1 to 5
TEST_F(ProtocolHeaderValidatorTest, Malformed_Version) {
std::vector<uint8_t> malformed_versions;
malformed_versions.push_back(0);
- for (uint8_t version = PROTOCOL_VERSION_4 + 1;
+ for (uint8_t version = PROTOCOL_VERSION_5 + 1;
version <= PROTOCOL_VERSION_MAX;
++version) {
malformed_versions.push_back(version);
diff --git a/src/components/protocol_handler/test/protocol_packet_test.cc b/src/components/protocol_handler/test/protocol_packet_test.cc
index 7819c4b5b0..71c7726243 100644
--- a/src/components/protocol_handler/test/protocol_packet_test.cc
+++ b/src/components/protocol_handler/test/protocol_packet_test.cc
@@ -125,7 +125,9 @@ TEST_F(ProtocolPacketTest, SerializePacketWithDiffServiceType) {
for (size_t i = 0; i < serv_types.size(); ++i) {
RawMessagePtr res =
GetRawMessage(PROTOCOL_VERSION_3, FRAME_TYPE_CONTROL, serv_types[i]);
- EXPECT_EQ(PROTOCOL_VERSION_3, res->protocol_version());
+ EXPECT_EQ(PROTOCOL_VERSION_3,
+ static_cast< ::protocol_handler::MajorProtocolVersion>(
+ res->protocol_version()));
EXPECT_EQ(serv_types[i], res->service_type());
EXPECT_EQ(PROTOCOL_HEADER_V2_SIZE, res->data_size());
}
@@ -146,7 +148,9 @@ TEST_F(ProtocolPacketTest, SerializePacketWithWrongServiceType) {
for (size_t i = 0; i < serv_types.size(); ++i) {
RawMessagePtr res =
GetRawMessage(PROTOCOL_VERSION_3, FRAME_TYPE_CONTROL, serv_types[i]);
- EXPECT_EQ(PROTOCOL_VERSION_3, res->protocol_version());
+ EXPECT_EQ(PROTOCOL_VERSION_3,
+ static_cast< ::protocol_handler::MajorProtocolVersion>(
+ res->protocol_version()));
EXPECT_EQ(kInvalidServiceType, res->service_type());
}
}
@@ -156,7 +160,9 @@ TEST_F(ProtocolPacketTest, SetPacketWithDiffFrameType) {
for (frame_type = FRAME_TYPE_CONTROL + 1; frame_type <= FRAME_TYPE_MAX_VALUE;
++frame_type) {
RawMessagePtr res = GetRawMessage(PROTOCOL_VERSION_3, frame_type, kControl);
- EXPECT_EQ(PROTOCOL_VERSION_3, res->protocol_version());
+ EXPECT_EQ(PROTOCOL_VERSION_3,
+ static_cast< ::protocol_handler::MajorProtocolVersion>(
+ res->protocol_version()));
EXPECT_EQ(kControl, res->service_type());
}
}
diff --git a/src/components/remote_control/CMakeLists.txt b/src/components/remote_control/CMakeLists.txt
new file mode 100644
index 0000000000..a320273a1e
--- /dev/null
+++ b/src/components/remote_control/CMakeLists.txt
@@ -0,0 +1,83 @@
+set(target "RemoteControlModule")
+set(install_destination ${CMAKE_BINARY_DIR}/bin/plugins)
+if (ENABLE_GCOV)
+ set(GCOV_FLAGS "-ftest-coverage -fprofile-arcs")
+else()
+ set(GCOV_FLAGS "")
+endif()
+
+if (CMAKE_BUILD_TYPE)
+ if (${CMAKE_BUILD_TYPE} STREQUAL "Release")
+ set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
+ set(CMAKE_CXX_FLAGS_DEBUG "")
+ else ()
+ set(CMAKE_CXX_FLAGS_RELEASE "")
+ set(CMAKE_CXX_FLAGS_DEBUG "-g3 -ggdb3 -DDEBUG")
+ endif()
+endif()
+
+include_directories (
+ ${COMPONENTS_DIR}/include/
+ ${COMPONENTS_DIR}/application_manager/include
+ ${COMPONENTS_DIR}/remote_control/include/
+ ${COMPONENTS_DIR}/connection_handler/include/
+ ${COMPONENTS_DIR}/protocol_handler/include/
+ ${COMPONENTS_DIR}/functional_module/include/
+ ${COMPONENTS_DIR}/config_profile/include/
+
+ ${COMPONENTS_DIR}/hmi_message_handler/include/
+ ${COMPONENTS_DIR}/formatters/include/
+ ${POLICY_PATH}/include/
+ ${POLICY_GLOBAL_INCLUDE_PATH}/
+ ${COMPONENTS_DIR}/rpc_base/include/
+ ${COMPONENTS_DIR}/application_manager/test/include/
+
+ ${COMPONENTS_DIR}/smart_objects/include/
+ ${COMPONENTS_DIR}/utils/include/
+ ${JSONCPP_INCLUDE_DIRECTORY}
+ ${LOG4CXX_INCLUDE_DIRECTORY}
+ ${CMAKE_BINARY_DIR}/src/components/
+)
+
+set (RC_SOURCE_DIR ${COMPONENTS_DIR}/remote_control/src)
+set (RC_TEST_DIR ${COMPONENTS_DIR}/remote_control/test)
+set (RC_COMMANDS_DIR ${RC_SOURCE_DIR}/commands)
+
+collect_sources(RC_SOURCES "${RC_SOURCE_DIR}")
+collect_sources(RC_COMMANDS_SOURCES "${RC_COMMANDS_DIR}")
+
+set (SOURCES
+ ${RC_SOURCES}
+ ${RC_COMMANDS_SOURCES}
+)
+
+set (LIBRARIES
+ jsoncpp
+ FunctionalModule
+ Utils
+ ConfigProfile
+)
+
+add_library(${target} SHARED ${SOURCES})
+target_link_libraries(${target} ${LIBRARIES} )
+
+if(ENABLE_LOG)
+ target_link_libraries(${target} log4cxx -L${LOG4CXX_LIBS_DIRECTORY})
+endif()
+
+
+install(TARGETS ${target}
+ DESTINATION ${install_destination}
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
+ GROUP_READ GROUP_EXECUTE
+ WORLD_READ WORLD_EXECUTE
+)
+
+install(
+ FILES ${FILES_FOR_COPY}
+ DESTINATION ${install_destination}
+)
+
+if(BUILD_TESTS)
+ add_subdirectory(test)
+endif()
diff --git a/src/components/remote_control/include/remote_control/commands/base_command_notification.h b/src/components/remote_control/include/remote_control/commands/base_command_notification.h
new file mode 100644
index 0000000000..578afad67b
--- /dev/null
+++ b/src/components/remote_control/include/remote_control/commands/base_command_notification.h
@@ -0,0 +1,110 @@
+/*
+ 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_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_COMMANDS_BASE_COMMAND_NOTIFICATION_H_
+#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_COMMANDS_BASE_COMMAND_NOTIFICATION_H_
+
+#include "remote_control/commands/command.h"
+#include "application_manager/message.h"
+#include "application_manager/service.h"
+#include "remote_control/rc_app_extension.h"
+#include "remote_control/remote_plugin_interface.h"
+#include "utils/logger.h"
+
+namespace Json {
+class Value;
+}
+
+namespace remote_control {
+
+namespace commands {
+
+/**
+ * @brief Base command class for notifications
+ */
+class BaseCommandNotification : public Command {
+ public:
+ /**
+ * @brief BaseCommandNotification class constructor
+ *
+ * @param message Message from mobile
+ **/
+ BaseCommandNotification(const application_manager::MessagePtr& message,
+ RemotePluginInterface& rc_module);
+
+ /**
+ * @brief BaseCommandNotification class destructor
+ */
+ virtual ~BaseCommandNotification();
+
+ /**
+ * \brief BaseCommandNotification on timeout reaction
+ */
+ virtual void OnTimeout() {}
+
+ void Run();
+
+ protected:
+ application_manager::MessagePtr message() {
+ return message_;
+ }
+ application_manager::ServicePtr service_;
+
+ RCAppExtensionPtr GetAppExtension(
+ application_manager::ApplicationSharedPtr app) const;
+
+ /**
+ * @brief executes specific logic of children classes
+ */
+ virtual void Execute() = 0;
+
+ /**
+ * @brief Validates notification by xml schema
+ */
+ virtual bool Validate();
+
+ virtual std::string ModuleType(const Json::Value& message);
+ virtual std::vector<std::string> ControlData(const Json::Value& message);
+
+ void NotifyOneApplication(application_manager::MessagePtr message);
+
+ private:
+ void NotifyApplications();
+ bool CheckPolicy(application_manager::MessagePtr message);
+ application_manager::MessagePtr message_;
+};
+
+} // namespace commands
+
+} // namespace remote_control
+
+#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_COMMANDS_BASE_COMMAND_NOTIFICATION_H_
diff --git a/src/components/remote_control/include/remote_control/commands/base_command_request.h b/src/components/remote_control/include/remote_control/commands/base_command_request.h
new file mode 100644
index 0000000000..64128b971e
--- /dev/null
+++ b/src/components/remote_control/include/remote_control/commands/base_command_request.h
@@ -0,0 +1,293 @@
+/*
+ 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_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_COMMANDS_BASE_COMMAND_REQUEST_H_
+#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_COMMANDS_BASE_COMMAND_REQUEST_H_
+
+#include "remote_control/commands/command.h"
+#include "remote_control/event_engine/event_observer.h"
+#include "application_manager/message.h"
+#include "application_manager/service.h"
+#include "utils/logger.h"
+#include "interfaces/HMI_API.h"
+#include "remote_control/rc_app_extension.h"
+#include "json/json.h"
+#include "remote_control/remote_plugin_interface.h"
+
+namespace remote_control {
+
+namespace commands {
+
+// Forward declaration to make this struct friend to BaseCommandRequest
+struct OnDriverAnswerCallback;
+
+/**
+ * @brief Base command class for requests
+ */
+class BaseCommandRequest
+ : public Command,
+ public rc_event_engine::EventObserver<application_manager::MessagePtr,
+ std::string> {
+ public:
+ /**
+ * @brief BaseCommandRequest class constructor
+ *
+ * @param message Message from mobile
+ **/
+ BaseCommandRequest(const application_manager::MessagePtr& message,
+ RemotePluginInterface& rc_module);
+
+ /**
+ * @brief BaseCommandRequest class destructor
+ */
+ virtual ~BaseCommandRequest();
+
+ /**
+ * @brief BaseCommandRequest on timeout reaction
+ */
+ virtual void OnTimeout();
+
+ void Run();
+ void on_event(const rc_event_engine::Event<application_manager::MessagePtr,
+ std::string>& event);
+
+ /**
+ * @brief Generates correct request to HMI
+ * @param function_id request ID
+ * @param msg_params json with message params
+ * @return generated request shared ptr
+ */
+ application_manager::MessagePtr CreateHmiRequest(
+ const char* function_id, const Json::Value& message_params);
+
+ /**
+ * @brief Prepares response for sending to mobile
+ * Adds necessary fields to message
+ * @param success true if successful; false, if failed
+ * @param result_code Mobile result code in string ("SUCCESS", "INVALID_DATA",
+ * e.t.c)
+ * @param info Provides additional human readable info regarding the
+ *result(may be empty)
+ */
+ void PrepareResponse(const bool success,
+ const char* result_code,
+ const std::string& info);
+
+ protected:
+ application_manager::MessagePtr message_;
+ Json::Value response_params_;
+
+ /**
+ * @brief AcquireResource try to allocate resource for application
+ * In case if allocation of resource is not required, return ALLOWED by
+ * default.
+ * This method should be overrided in RPCs that requires resource allocation
+ * @return result of resource allocation, in case if allocation os not
+ * required, return ALLOWED
+ */
+ virtual AcquireResult::eType AcquireResource(const Json::Value&) {
+ return AcquireResult::ALLOWED;
+ }
+
+ /**
+ * @brief IsResourceFree check resource state
+ * This is default implementation which has to be redefined for RPCs which
+ * need to manage the resources
+ * @param module_type Resource name
+ * @return True if free, otherwise - false
+ */
+ virtual bool IsResourceFree(const std::string& module_type) const {
+ UNUSED(module_type);
+ return true;
+ }
+
+ /**
+ * @brief SetResourceState changes state of resource
+ * This is default implementation which has to be redefined for RPCs which
+ * need to manage the resources
+ * @param Message containing type of module to extract
+ * @param State to set for resource
+ */
+ virtual void SetResourceState(const Json::Value&,
+ const ResourceState::eType) {}
+
+ /**
+ * @brief Get extension for specified application. If extension doesn't exist,
+ * it will be created
+ * @param app pointer to application
+ * @return pointer to extension
+ */
+ RCAppExtensionPtr GetAppExtension(
+ application_manager::ApplicationSharedPtr app) const;
+
+ /**
+ * @brief Converts HMI result code to string with mobile result code
+ *
+ * @param hmi_code HMI result code
+ * @return String with mobile result code
+ */
+ const char* GetMobileResultCode(
+ const hmi_apis::Common_Result::eType& hmi_code) const;
+
+ /**
+ * @brief Sends Mobile response
+ * @param success true if successful; false, if failed
+ * @param result_code Mobile result code in string ("SUCCESS", "INVALID_DATA",
+ *e.t.c)
+ * @param info Provides additional human readable info regarding the
+ *result(may be empty)
+ */
+ void SendResponse(const bool success,
+ const char* result_code,
+ const std::string& info);
+
+ /**
+ * @brief Parse result code from response
+ *
+ * @param message Response from HMI or Can
+ * @param result_code Outgoing param with mobile result code in string
+ *("SUCCESS", "INVALID_DATA", e.t.c)
+ * @param info Outgoing param with additional human readable info regarding
+ *the result(may be empty)
+ * @return true if it is success response? otherwise false
+ */
+ bool ParseResultCode(const Json::Value& value,
+ std::string& result_code,
+ std::string& info);
+
+ /**
+ * @brief Sends request to HMI
+ * @param message_to_send to send
+ */
+ void SendMessageToHMI(const application_manager::MessagePtr& message_to_send);
+
+ /**
+ * @brief Sends request to CAN or HMI
+ * @param function_id request ID
+ * @param msg_params json with message params
+ */
+ void SendRequest(const char* function_id, const Json::Value& message_params);
+
+ application_manager::ApplicationSharedPtr app() {
+ DCHECK(app_);
+ return app_;
+ }
+
+ /**
+ * @brief executes specific logic of children classes
+ */
+ void virtual Execute() = 0;
+
+ /**
+ * @brief Validates request by xml schema
+ */
+ bool Validate();
+
+ /*
+ * @brief Parses incoming string into Json
+ * @param parsed_mgs Resulting json object (must be valid pointer)
+ * @returns True if json string was valid false otherwise.
+ */
+ virtual bool ParseJsonString(Json::Value* parsed_msg);
+
+ /**
+ * @brief Interface method that is called whenever new event received
+ * @param event The received event
+ */
+ void virtual OnEvent(
+ const rc_event_engine::Event<application_manager::MessagePtr,
+ std::string>& event) = 0;
+
+ virtual std::string ModuleType(const Json::Value& message);
+ virtual std::vector<std::string> ControlData(const Json::Value& message);
+ virtual application_manager::TypeAccess CheckModule(
+ const Json::Value& message);
+
+ bool auto_allowed() const {
+ return auto_allowed_;
+ }
+
+ void set_auto_allowed(bool value) {
+ auto_allowed_ = value;
+ }
+
+ application_manager::ServicePtr service() {
+ return service_;
+ }
+
+ void set_disallowed_info(const std::string& info) {
+ disallowed_info_ = info;
+ }
+
+ private:
+ /**
+ * @brief CheckPolicyPermissions checks RPC permissions defined in policy
+ * table
+ * @return True if RPC is allowed, otherwise - false
+ */
+ bool CheckPolicyPermissions();
+
+ /**
+ * @brief CheckDriverConsent checks driver consent defined in policy table
+ * @return True if no consent is required, otherwise - false
+ */
+ bool CheckDriverConsent();
+
+ /**
+ * @brief AcquireResources checks whether resource status is busy or not and
+ * then tries to acquire this resource. In case driver consent is required -
+ * sends consent request to HMI.
+ * @return True in case of resource is free and successfully acquired,
+ * otherwise false
+ */
+ bool AcquireResources();
+ inline bool IsAutoAllowed(application_manager::TypeAccess access) const;
+ void SendDisallowed(application_manager::TypeAccess access);
+ void SendGetUserConsent(const Json::Value& value);
+ void ProcessAccessResponse(
+ const rc_event_engine::Event<application_manager::MessagePtr,
+ std::string>& event);
+
+ const Json::Value msg_json_;
+ application_manager::ApplicationSharedPtr app_;
+ application_manager::ServicePtr service_;
+ bool auto_allowed_;
+ std::string disallowed_info_;
+
+ friend struct OnDriverAnswerCallback;
+};
+
+} // namespace commands
+
+} // namespace remote_control
+
+#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_COMMANDS_BASE_COMMAND_REQUEST_H_
diff --git a/src/components/remote_control/include/remote_control/commands/button_press_request.h b/src/components/remote_control/include/remote_control/commands/button_press_request.h
new file mode 100644
index 0000000000..945f98bdc8
--- /dev/null
+++ b/src/components/remote_control/include/remote_control/commands/button_press_request.h
@@ -0,0 +1,104 @@
+/*
+ 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_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_COMMANDS_BUTTON_PRESS_REQUEST_H_
+#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_COMMANDS_BUTTON_PRESS_REQUEST_H_
+
+#include "remote_control/commands/base_command_request.h"
+#include "remote_control/event_engine/event.h"
+#include "utils/macro.h"
+
+namespace remote_control {
+
+namespace commands {
+
+/**
+ * @brief ButtonPressRequest command class
+ */
+class ButtonPressRequest : public BaseCommandRequest {
+ public:
+ /**
+ * @brief ButtonPressRequest class constructor
+ *
+ * @param message Message from mobile
+ **/
+ ButtonPressRequest(const application_manager::MessagePtr& message,
+ RemotePluginInterface& rc_module);
+ /**
+ * @brief Execute command
+ */
+ void Execute() FINAL;
+
+ /**
+ * @brief AcquireResource Tries to acquire specific resource
+ * @param message Incoming message containg the resource name
+ * @return Acquire result
+ */
+ AcquireResult::eType AcquireResource(
+ const Json::Value& message) OVERRIDE FINAL;
+
+ /**
+ * @brief IsResourceFree check resource state
+ * @param module_type Resource name
+ * @return True if free, otherwise - false
+ */
+ bool IsResourceFree(const std::string& module_type) const FINAL;
+
+ /**
+ * @brief SetResourceState changes state of resource
+ * @param state State to set for resource
+ */
+ void SetResourceState(const Json::Value& message,
+ const ResourceState::eType state) FINAL;
+
+ /**
+ * @brief Interface method that is called whenever new event received
+ *
+ * @param event The received event
+ */
+ void OnEvent(const rc_event_engine::Event<application_manager::MessagePtr,
+ std::string>& event);
+
+ /**
+ * @brief ButtonPressRequest class destructor
+ */
+ virtual ~ButtonPressRequest();
+
+ protected:
+ std::string ModuleType(const Json::Value& message) FINAL;
+};
+
+} // namespace commands
+
+} // namespace remote_control
+
+#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_COMMANDS_BUTTON_PRESS_REQUEST_H_
diff --git a/src/components/remote_control/include/remote_control/commands/command.h b/src/components/remote_control/include/remote_control/commands/command.h
new file mode 100644
index 0000000000..0e03f8b330
--- /dev/null
+++ b/src/components/remote_control/include/remote_control/commands/command.h
@@ -0,0 +1,84 @@
+/*
+ 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_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_COMMANDS_COMMAND_H_
+#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_COMMANDS_COMMAND_H_
+
+#include "utils/shared_ptr.h"
+#include "remote_control/remote_plugin_interface.h"
+#include "remote_control/event_engine/event.h"
+
+namespace remote_control {
+
+class RemotePluginInterface;
+
+namespace commands {
+
+/**
+ * @brief Command interface
+ **/
+class Command {
+ public:
+ /**
+ * @brief Execute command
+ */
+ virtual void Run() = 0;
+
+ /**
+ * \brief Command class destructor
+ */
+ virtual ~Command() {}
+
+ /**
+ * \brief Command on timeout reaction
+ */
+ virtual void OnTimeout() = 0;
+
+ /**
+ * @brief Interface method that is called whenever new event received
+ * @param event The received event
+ */
+ virtual void on_event(
+ const rc_event_engine::Event<application_manager::MessagePtr,
+ std::string>& event) {}
+
+ protected:
+ Command(RemotePluginInterface& rc_module) : rc_module_(rc_module) {}
+
+ RemotePluginInterface& rc_module_;
+};
+
+} // namespace commands
+
+} // namespace remote_control
+
+#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_COMMANDS_COMMAND_H_
diff --git a/src/components/remote_control/include/remote_control/commands/get_interior_vehicle_data_request.h b/src/components/remote_control/include/remote_control/commands/get_interior_vehicle_data_request.h
new file mode 100644
index 0000000000..220f7da979
--- /dev/null
+++ b/src/components/remote_control/include/remote_control/commands/get_interior_vehicle_data_request.h
@@ -0,0 +1,101 @@
+/*
+ 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_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_COMMANDS_GET_INTERIOR_VEHICLE_DATA_REQUEST_H_
+#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_COMMANDS_GET_INTERIOR_VEHICLE_DATA_REQUEST_H_
+
+#include "remote_control/commands/base_command_request.h"
+#include "remote_control/event_engine/event.h"
+#include "utils/macro.h"
+
+namespace remote_control {
+
+namespace commands {
+
+/**
+ * @brief GetInteriorVehicleDataRequest command class
+ */
+class GetInteriorVehicleDataRequest : public BaseCommandRequest {
+ public:
+ /**
+ * @brief GetInteriorVehicleDataRequest class constructor
+ *
+ * @param message Message from mobile
+ **/
+ explicit GetInteriorVehicleDataRequest(
+ const application_manager::MessagePtr& message,
+ RemotePluginInterface& rc_module);
+
+ /**
+ * @brief Execute command
+ */
+ void Execute() FINAL;
+
+ /**
+ * @brief Interface method that is called whenever new event received
+ *
+ * @param event The received event
+ */
+ void OnEvent(const rc_event_engine::Event<application_manager::MessagePtr,
+ std::string>& event);
+
+ /**
+ * @brief Check if app wants to proceed with already setup subscription
+ * @param request_params request parameters to check
+ * @return true if app already subscribed(unsubsribed) for module type but
+ * wants to subscribe(unsubscribe) for the same module again
+ * otherwise - false
+ */
+ bool HasRequestExcessiveSubscription(const Json::Value& request_params);
+
+ protected:
+ virtual std::string ModuleType(const Json::Value& message);
+
+ private:
+ /**
+ * @brief Handle subscription to vehicle data
+ * @param hmi_response json message with response from HMI
+ */
+ void ProccessSubscription(const Json::Value& hmi_response);
+
+ /**
+ * @brief Cuts off subscribe parameter
+ * @param request_params request parameters to handle
+ */
+ void RemoveExcessiveSubscription(Json::Value& request_params);
+};
+
+} // namespace commands
+
+} // namespace remote_control
+
+#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_COMMANDS_GET_INTERIOR_VEHICLE_DATA_REQUEST_H_
diff --git a/src/components/remote_control/include/remote_control/commands/on_interior_vehicle_data_notification.h b/src/components/remote_control/include/remote_control/commands/on_interior_vehicle_data_notification.h
new file mode 100644
index 0000000000..4ee9ce4709
--- /dev/null
+++ b/src/components/remote_control/include/remote_control/commands/on_interior_vehicle_data_notification.h
@@ -0,0 +1,75 @@
+/*
+ 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_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_COMMANDS_ON_INTERIOR_VEHICLE_DATA_NOTIFICATION_H_
+#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_COMMANDS_ON_INTERIOR_VEHICLE_DATA_NOTIFICATION_H_
+
+#include "utils/macro.h"
+#include "remote_control/commands/base_command_notification.h"
+
+namespace remote_control {
+
+namespace commands {
+
+/**
+ * @brief OnInteriorVehicleDataNotification command class
+ */
+class OnInteriorVehicleDataNotification : public BaseCommandNotification {
+ public:
+ /**
+ * @brief OnInteriorVehicleDataNotification class constructor
+ *
+ * @param message Message with notification
+ **/
+ OnInteriorVehicleDataNotification(
+ const application_manager::MessagePtr& message,
+ RemotePluginInterface& rc_module);
+
+ /**
+ * @brief Execute command
+ */
+ void Execute() FINAL;
+
+ /**
+ * @brief OnInteriorVehicleDataNotification class destructor
+ */
+ virtual ~OnInteriorVehicleDataNotification();
+
+ protected:
+ std::string ModuleType(const Json::Value& message) FINAL;
+};
+
+} // namespace commands
+
+} // namespace remote_control
+
+#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_COMMANDS_ON_INTERIOR_VEHICLE_DATA_NOTIFICATION_H_
diff --git a/src/components/remote_control/include/remote_control/commands/on_remote_control_settings_notification.h b/src/components/remote_control/include/remote_control/commands/on_remote_control_settings_notification.h
new file mode 100644
index 0000000000..ef248a2b38
--- /dev/null
+++ b/src/components/remote_control/include/remote_control/commands/on_remote_control_settings_notification.h
@@ -0,0 +1,79 @@
+/*
+ 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_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_COMMANDS_ON_REMOTE_CONTROL_SETTINGS_NOTIFICATION_H_
+#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_COMMANDS_ON_REMOTE_CONTROL_SETTINGS_NOTIFICATION_H_
+
+#include "utils/macro.h"
+#include "remote_control/commands/base_command_notification.h"
+
+namespace remote_control {
+
+namespace commands {
+
+/**
+ * @brief OnRemoteControlSettingsNotification command class
+ */
+class OnRemoteControlSettingsNotification : public BaseCommandNotification {
+ public:
+ /**
+ * @brief OnRemoteControlSettingsNotification class constructor
+ *
+ * @param message Message with notification
+ * @param rc_module Module used for handling RC functionality
+ **/
+ OnRemoteControlSettingsNotification(
+ const application_manager::MessagePtr& message,
+ RemotePluginInterface& rc_module);
+
+ /**
+ * @brief Execute command
+ */
+ void Execute() FINAL;
+
+ private:
+ /**
+ * @brief Disalows RC functionality for all RC apps
+ * All registered apps with appHMIType REMOTE_CONTROL will be put to NONE hmi
+ * level
+ * OnHMIStatus (NONE) will be send to such apps
+ * All registered apps will be unsubsribed from OnInteriorVehicleData
+ * notifications
+ */
+ void DisallowRCFunctionality();
+};
+
+} // namespace commands
+
+} // namespace remote_control
+
+#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_COMMANDS_ON_REMOTE_CONTROL_SETTINGS_NOTIFICATION_H_
diff --git a/src/components/remote_control/include/remote_control/commands/set_interior_vehicle_data_request.h b/src/components/remote_control/include/remote_control/commands/set_interior_vehicle_data_request.h
new file mode 100644
index 0000000000..bc1e3942e5
--- /dev/null
+++ b/src/components/remote_control/include/remote_control/commands/set_interior_vehicle_data_request.h
@@ -0,0 +1,127 @@
+/*
+ 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_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_COMMANDS_SET_INTERIOR_VEHICLE_DATA_REQUEST_H_
+#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_COMMANDS_SET_INTERIOR_VEHICLE_DATA_REQUEST_H_
+
+#include "remote_control/commands/base_command_request.h"
+#include "remote_control/event_engine/event.h"
+#include "utils/macro.h"
+
+namespace remote_control {
+
+namespace commands {
+
+/**
+ * @brief SetInteriorVehicleDataRequest command class
+ */
+class SetInteriorVehicleDataRequest : public BaseCommandRequest {
+ public:
+ /**
+ * @brief SetInteriorVehicleDataRequest class constructor
+ *
+ * @param message Message from mobile
+ * @param rc_module Module used for handling RC functionality
+ **/
+ SetInteriorVehicleDataRequest(const application_manager::MessagePtr& message,
+ RemotePluginInterface& rc_module);
+
+ /**
+ * @brief Execute command
+ */
+ void Execute() FINAL;
+
+ /**
+ * @brief AcquireResource proxy AcquireResource to Resource allocation manager
+ * @param message message of requires contatin module types
+ * @return result of acauiring resources
+ */
+ AcquireResult::eType AcquireResource(
+ const Json::Value& message) OVERRIDE FINAL;
+
+ /**
+ * @brief IsResourceFree check resource state
+ * @param module_type Resource name
+ * @return True if free, otherwise - false
+ */
+ bool IsResourceFree(const std::string& module_type) const FINAL;
+
+ /**
+ * @brief SetResourceState changes state of resource
+ * @param state State to set for resource
+ */
+ void SetResourceState(const Json::Value& message,
+ const ResourceState::eType state) FINAL;
+
+ /**
+ * @brief Interface method that is called whenever new event received
+ *
+ * @param event The received event
+ */
+ void OnEvent(const rc_event_engine::Event<application_manager::MessagePtr,
+ std::string>& event) OVERRIDE;
+ /**
+ * @brief Method that check if READ_ONLY parameters present
+ * @param request_params params from received message
+ * @return true if present , false - otherwise
+ */
+ bool AreReadOnlyParamsPresent(const Json::Value& request_params);
+
+ /**
+ * @brief Method that check if all request parameters are READ_ONLY
+ * @param request_params params from received message
+ * @return true if all are read only , false - otherwise
+ */
+ bool AreAllParamsReadOnly(const Json::Value& request_params);
+
+ /**
+ * @brief Method that cuts-off READ_ONLY parameters
+ * @param request_params params to handle
+ */
+ void CutOffReadOnlyParams(Json::Value& request_params);
+
+ /**
+ * @brief SetInteriorVehicleDataRequest class destructor
+ */
+ virtual ~SetInteriorVehicleDataRequest();
+
+ protected:
+ virtual std::string ModuleType(const Json::Value& message) FINAL;
+ virtual std::vector<std::string> ControlData(
+ const Json::Value& message) FINAL;
+};
+
+} // namespace commands
+
+} // namespace remote_control
+
+#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_COMMANDS_SET_INTERIOR_VEHICLE_DATA_REQUEST_H_
diff --git a/src/components/remote_control/include/remote_control/event_engine/event.h b/src/components/remote_control/include/remote_control/event_engine/event.h
new file mode 100644
index 0000000000..0da248e5a7
--- /dev/null
+++ b/src/components/remote_control/include/remote_control/event_engine/event.h
@@ -0,0 +1,127 @@
+/*
+ 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_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_EVENT_ENGINE_EVENT_H_
+#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_EVENT_ENGINE_EVENT_H_
+
+#include <string>
+#include "remote_control/event_engine/event_dispatcher.h"
+#include "utils/shared_ptr.h"
+#include "application_manager/message.h"
+
+namespace rc_event_engine {
+
+template <typename EventMessage, typename EventID>
+class EventDispatcher;
+
+template <typename EventMessage, typename EventID>
+class Event {
+ public:
+ /*
+ * @brief Constructor with parameters
+ *
+ * @param id Event ID.
+ * @param message Message received in event
+ */
+ Event(EventMessage& message, const EventID& id);
+
+ /*
+ * @brief Destructor
+ */
+ virtual ~Event() {}
+
+ /*
+ * @brief Provides event ID
+ */
+ inline const EventID& id() const;
+
+ /*
+ * @brief Sets event message
+ *
+ * @param message The message received in event
+ */
+ void set_event_message(EventMessage& message);
+
+ /*
+ * @brief Retrieves event message
+ *
+ * @return The message received in event
+ */
+ inline const EventMessage& event_message() const;
+
+ /*
+ * @brief Retrieves event message request ID
+ */
+ virtual int32_t event_message_function_id() const = 0;
+
+ /*
+ * @brief Retrieves event message correlation ID
+ */
+ virtual int32_t event_message_correlation_id() const = 0;
+
+ /*
+ * @brief Retrieves event message response type
+ */
+ virtual int32_t event_message_type() const = 0;
+
+ void raise(EventDispatcher<EventMessage, EventID>& event_dispatcher);
+
+ protected:
+ EventMessage event_message_;
+
+ private:
+ EventID id_;
+};
+
+template <typename EventMessage, typename EventID>
+const EventID& Event<EventMessage, EventID>::id() const {
+ return id_;
+}
+
+template <typename EventMessage, typename EventID>
+const EventMessage& Event<EventMessage, EventID>::event_message() const {
+ return event_message_;
+}
+
+template <typename EventMessage, typename EventID>
+Event<EventMessage, EventID>::Event(EventMessage& message, const EventID& id)
+ : event_message_(message), id_(id) {}
+
+template <typename EventMessage, typename EventID>
+void Event<EventMessage, EventID>::raise(
+ EventDispatcher<EventMessage, EventID>& event_dispatcher) {
+ event_dispatcher.raise_event(*this);
+}
+
+} // namespace event_engine
+
+#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_EVENT_ENGINE_EVENT_H_
diff --git a/src/components/remote_control/include/remote_control/event_engine/event_dispatcher.h b/src/components/remote_control/include/remote_control/event_engine/event_dispatcher.h
new file mode 100644
index 0000000000..ddee6caccc
--- /dev/null
+++ b/src/components/remote_control/include/remote_control/event_engine/event_dispatcher.h
@@ -0,0 +1,203 @@
+/*
+ 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_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_EVENT_ENGINE_EVENT_DISPATCHER_H_
+#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_EVENT_ENGINE_EVENT_DISPATCHER_H_
+
+#include <list>
+#include <map>
+
+#include "utils/lock.h"
+
+#include "remote_control/event_engine/event.h"
+#include "remote_control/event_engine/event_observer.h"
+
+#include "interfaces/HMI_API.h"
+
+namespace rc_event_engine {
+
+template <typename EventMessage, typename EventID>
+class Event;
+
+template <typename EventMessage, typename EventID>
+class EventObserver;
+
+template <typename EventMessage, typename EventID>
+class EventDispatcher {
+ public:
+ /**
+ * @brief Default constructor
+ */
+ EventDispatcher();
+
+ /**
+ * @brief Destructor
+ */
+ virtual ~EventDispatcher();
+
+ /*
+ * @brief Delivers the event to all subscribers
+ *
+ * @param event Received event
+ */
+ void raise_event(const Event<EventMessage, EventID>& event);
+
+ /*
+ * @brief Subscribe the observer to event
+ *
+ * @param event_id The event ID to subscribe for
+ * @param hmi_correlation_id The event HMI correlation ID
+ * @param observer The observer to subscribe for event
+ */
+ void add_observer(const EventID& event_id,
+ int32_t hmi_correlation_id,
+ EventObserver<EventMessage, EventID>* const observer);
+
+ /*
+ * @brief Unsubscribes the observer from specific event
+ *
+ * @param event_id The event ID to unsubscribe from
+ * @param observer The observer to be unsubscribed
+ */
+ void remove_observer(
+ const EventID& event_id,
+ const EventObserver<EventMessage, EventID>* const observer);
+
+ /*
+ * @brief Unsubscribes the observer from all events
+ *
+ * @param observer The observer to be unsubscribed
+ */
+ void remove_observer(
+ const EventObserver<EventMessage, EventID>* const observer);
+
+ protected:
+ private:
+ DISALLOW_COPY_AND_ASSIGN(EventDispatcher);
+
+ // Data types section
+ typedef std::list<EventObserver<EventMessage, EventID>*> ObserverList;
+ typedef std::map<int32_t, ObserverList> ObserversMap;
+ typedef std::map<EventID, ObserversMap> EventObserverMap;
+
+ // Members section
+ sync_primitives::Lock state_lock_;
+ EventObserverMap observers_;
+};
+
+template <typename EventMessage, typename EventID>
+EventDispatcher<EventMessage, EventID>::EventDispatcher()
+ : observers_() {}
+
+template <typename EventMessage, typename EventID>
+EventDispatcher<EventMessage, EventID>::~EventDispatcher() {}
+
+template <typename EventMessage, typename EventID>
+void EventDispatcher<EventMessage, EventID>::raise_event(
+ const Event<EventMessage, EventID>& event) {
+ // create local list
+ ObserverList list;
+ {
+ sync_primitives::AutoLock auto_lock(state_lock_);
+ // check if event is notification
+ if (hmi_apis::messageType::notification == event.event_message_type()) {
+ // ObserversMap iterator
+ typename ObserversMap::iterator it = observers_[event.id()].begin();
+ for (; observers_[event.id()].end() != it; ++it) {
+ list = it->second;
+ }
+ }
+
+ if ((hmi_apis::messageType::response == event.event_message_type()) ||
+ (hmi_apis::messageType::error_response == event.event_message_type())) {
+ list = observers_[event.id()][event.event_message_correlation_id()];
+ }
+ }
+
+ // Call observers
+ typename ObserverList::iterator observers = list.begin();
+ for (; list.end() != observers; ++observers) {
+ (*observers)->on_event(event);
+ }
+}
+
+template <typename EventMessage, typename EventID>
+void EventDispatcher<EventMessage, EventID>::add_observer(
+ const EventID& event_id,
+ int32_t hmi_correlation_id,
+ EventObserver<EventMessage, EventID>* const observer) {
+ sync_primitives::AutoLock auto_lock(state_lock_);
+ observers_[event_id][hmi_correlation_id].push_back(observer);
+}
+
+template <typename EventMessage, typename EventID>
+void EventDispatcher<EventMessage, EventID>::remove_observer(
+ const EventID& event_id,
+ const EventObserver<EventMessage, EventID>* const observer) {
+ sync_primitives::AutoLock auto_lock(state_lock_);
+ typename ObserversMap::iterator it = observers_[event_id].begin();
+ for (; observers_[event_id].end() != it; ++it) {
+ // ObserverList iterator
+ typename ObserverList::iterator observer_it = it->second.begin();
+ while (it->second.end() != observer_it) {
+ if (observer->id() == (*observer_it)->id()) {
+ observer_it = it->second.erase(observer_it);
+ } else {
+ ++observer_it;
+ }
+ }
+ }
+}
+
+template <typename EventMessage, typename EventID>
+void EventDispatcher<EventMessage, EventID>::remove_observer(
+ const EventObserver<EventMessage, EventID>* const observer) {
+ sync_primitives::AutoLock auto_lock(state_lock_);
+ typename EventObserverMap::iterator event_map = observers_.begin();
+ for (; observers_.end() != event_map; ++event_map) {
+ typename ObserversMap::iterator it = event_map->second.begin();
+ for (; event_map->second.end() != it; ++it) {
+ // ObserverList iterator
+ typename ObserverList::iterator observer_it = it->second.begin();
+ while (it->second.end() != observer_it) {
+ if (observer->id() == (*observer_it)->id()) {
+ observer_it = it->second.erase(observer_it);
+ } else {
+ ++observer_it;
+ }
+ }
+ }
+ }
+}
+}
+
+#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_EVENT_ENGINE_EVENT_DISPATCHER_H_
diff --git a/src/components/remote_control/include/remote_control/event_engine/event_observer.h b/src/components/remote_control/include/remote_control/event_engine/event_observer.h
new file mode 100644
index 0000000000..66a38da88b
--- /dev/null
+++ b/src/components/remote_control/include/remote_control/event_engine/event_observer.h
@@ -0,0 +1,96 @@
+/*
+ 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_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_EVENT_ENGINE_EVENT_OBSERVER_H_
+#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_EVENT_ENGINE_EVENT_OBSERVER_H_
+
+#include <string>
+#include "remote_control/event_engine/event.h"
+
+namespace rc_event_engine {
+
+template <typename EventMessage, typename EventID>
+class Event;
+
+template <typename EventMessage, typename EventID>
+class EventObserver {
+ public:
+ // Typedef for possible Observer ID's from mobile_apis functionID enum
+ typedef unsigned long ObserverID;
+
+ /*
+ * @brief Constructor
+ *
+ */
+ EventObserver();
+
+ /*
+ * @brief Destructor
+ */
+ virtual ~EventObserver();
+
+ /**
+ * @brief Retrieves observer unique id
+ *
+ * @return Unique Observer id
+ */
+ const ObserverID& id() const {
+ return id_;
+ }
+
+ /**
+ * @brief Interface method that is called whenever new event received
+ *
+ * @param event The received event
+ */
+ virtual void on_event(const Event<EventMessage, EventID>& event) = 0;
+
+ private:
+ ObserverID id_;
+
+ DISALLOW_COPY_AND_ASSIGN(EventObserver);
+};
+
+template <typename EventMessage, typename EventID>
+EventObserver<EventMessage, EventID>::EventObserver()
+ : id_(0) {
+ // Get unique id based on this
+ id_ = reinterpret_cast<unsigned long>(this);
+}
+
+template <typename EventMessage, typename EventID>
+EventObserver<EventMessage, EventID>::~EventObserver() {
+ // unsubscribe_from_all_events();
+}
+}
+
+#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_EVENT_ENGINE_EVENT_OBSERVER_H_
diff --git a/src/components/remote_control/include/remote_control/message_helper.h b/src/components/remote_control/include/remote_control/message_helper.h
new file mode 100644
index 0000000000..6358459da7
--- /dev/null
+++ b/src/components/remote_control/include/remote_control/message_helper.h
@@ -0,0 +1,122 @@
+/*
+ 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_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_MESSAGE_HELPER_H_
+#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_MESSAGE_HELPER_H_
+
+#include <stdint.h>
+#include <string>
+#include <map>
+
+#include "utils/macro.h"
+#include "json/json.h"
+#include "interfaces/HMI_API.h"
+#include "functional_module/function_ids.h"
+#include "remote_control/remote_plugin_interface.h"
+#include "application_manager/message.h"
+
+namespace remote_control {
+
+/**
+ * @brief MessageHelper class
+ **/
+class MessageHelper {
+ public:
+ static const std::string GetMobileAPIName(
+ functional_modules::RCFunctionID func_id);
+
+ /**
+ * @brief Convert Json::Value to std::string
+ *
+ * @param value Value with json
+ *
+ * @return string with json
+ */
+ static std::string ValueToString(const Json::Value& value);
+
+ /**
+ * @brief Convert std::string to Json::Value
+ *
+ * @param string string with json
+ *
+ * @return Value created from string with json
+ */
+ static Json::Value StringToValue(const std::string& string);
+
+ /**
+ * Creates hmi request
+ * @param function_id - API function we create request for
+ * @param message_params - params in request
+ * @param rc_module - used module for requests handling
+ * @param hmi_app_id - app is used between SDL & HMI
+ * @return creted request - reqdy to be sent to hmi
+ */
+ static application_manager::MessagePtr CreateHmiRequest(
+ const char* function_id,
+ const uint32_t hmi_app_id,
+ const Json::Value& message_params,
+ RemotePluginInterface& rc_module);
+
+ /** @brief Converts string to hmi AccessMode enum value
+ * @param access_mode stringified value
+ * @return hmi AccessMode enum value if succedeed, otherwise - INVALID_ENUM
+ * value
+ */
+ static hmi_apis::Common_RCAccessMode::eType AccessModeFromString(
+ const std::string& access_mode);
+
+ /**
+ * @brief AccessModeToString converts enum values to string
+ * @param access_mode Access mode enum value
+ * @return Appropriate string value
+ */
+ static std::string AccessModeToString(
+ const hmi_apis::Common_RCAccessMode::eType access_mode);
+
+ private:
+ MessageHelper();
+
+ static const std::map<functional_modules::RCFunctionID, std::string>
+ kMobileAPINames;
+ DISALLOW_COPY_AND_ASSIGN(MessageHelper);
+};
+
+/** @brief Check for existence of specified key in Json::Value
+ * @param value Value with json
+ * @param key string with key name
+ * @return true if key exist
+ */
+bool IsMember(const Json::Value& value, const std::string& key);
+
+} // namespace remote_control
+
+#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_MESSAGE_HELPER_H_
diff --git a/src/components/remote_control/include/remote_control/module_helper.h b/src/components/remote_control/include/remote_control/module_helper.h
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/src/components/remote_control/include/remote_control/module_helper.h
diff --git a/src/components/remote_control/include/remote_control/rc_app_extension.h b/src/components/remote_control/include/remote_control/rc_app_extension.h
new file mode 100644
index 0000000000..485514faba
--- /dev/null
+++ b/src/components/remote_control/include/remote_control/rc_app_extension.h
@@ -0,0 +1,82 @@
+/*
+ * 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_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_APP_EXTENSION_H_
+#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_APP_EXTENSION_H_
+
+#include <string>
+#include <set>
+#include "application_manager/service.h"
+#include "application_manager/app_extension.h"
+#include "remote_control/remote_control_plugin.h"
+#include "json/json.h"
+
+namespace remote_control {
+
+class RCAppExtension : public application_manager::AppExtension {
+ public:
+ explicit RCAppExtension(application_manager::AppExtensionUID uid);
+ ~RCAppExtension();
+
+ /**
+ * @brief Subscribe to OnInteriorVehicleDataNotification
+ * @param module interior data specification(zone, data type)
+ */
+ void SubscribeToInteriorVehicleData(const Json::Value& module_type);
+
+ /**
+ * @brief Unsubscribe from OnInteriorVehicleDataNotification
+ * @param module interior data specification(zone, data type)
+ */
+ void UnsubscribeFromInteriorVehicleData(const Json::Value& module_type);
+
+ /**
+ * @brief UnsubscribeFromInteriorVehicleData removes all subscriptions for
+ * interior data
+ */
+ void UnsubscribeFromInteriorVehicleData();
+
+ /**
+ * @brief Check if application subscribed to OnInteriorVehicleDataNotification
+ * @param module interior data specification(zone, data type)
+ */
+ bool IsSubscibedToInteriorVehicleData(const Json::Value& module_type);
+
+ private:
+ std::set<Json::Value> subscribed_interior_vehicle_data_;
+};
+
+typedef utils::SharedPtr<RCAppExtension> RCAppExtensionPtr;
+
+} // namespace remote_control
+
+#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_APP_EXTENSION_H_
diff --git a/src/components/remote_control/include/remote_control/rc_command_factory.h b/src/components/remote_control/include/remote_control/rc_command_factory.h
new file mode 100644
index 0000000000..9463c4b1ef
--- /dev/null
+++ b/src/components/remote_control/include/remote_control/rc_command_factory.h
@@ -0,0 +1,66 @@
+/*
+ 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_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_COMMAND_FACTORY_H_
+#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_COMMAND_FACTORY_H_
+
+#include "utils/shared_ptr.h"
+#include "remote_control/commands/command.h"
+#include "remote_control/remote_control_plugin.h"
+#include "application_manager/message.h"
+#include "utils/macro.h"
+
+namespace remote_control {
+
+/**
+ * @brief Factory class for command creation
+ **/
+class RCCommandFactory {
+ public:
+ /**
+ * @brief Create command object and return pointer to it
+ *
+ * @param message Message shared pointer.
+ * @return Pointer to created command object.
+ **/
+ static utils::SharedPtr<commands::Command> CreateCommand(
+ const application_manager::MessagePtr& msg,
+ RemotePluginInterface& rc_module);
+
+ private:
+ RCCommandFactory();
+ DISALLOW_COPY_AND_ASSIGN(RCCommandFactory);
+};
+
+} // namespace can_cooperaion
+
+#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_COMMAND_FACTORY_H_
diff --git a/src/components/remote_control/include/remote_control/rc_module_constants.h b/src/components/remote_control/include/remote_control/rc_module_constants.h
new file mode 100644
index 0000000000..021e3cd6f0
--- /dev/null
+++ b/src/components/remote_control/include/remote_control/rc_module_constants.h
@@ -0,0 +1,233 @@
+/*
+ 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_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_MODULE_CONSTANTS_H_
+#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_MODULE_CONSTANTS_H_
+
+namespace remote_control {
+
+namespace strings {
+// RemoteControlCapabilities constants
+const char kclimateControlCapabilities[] = "climateControlCapabilities";
+const char kradioControlCapabilities[] = "radioControlCapabilities";
+const char kbuttonCapabilities[] = "buttonCapabilities";
+// RemoteControlCapabilities constants
+
+const char kRadioControlData[] = "radioControlData";
+const char kClimateControlData[] = "climateControlData";
+} // strings
+
+namespace result_codes {
+const char kSuccess[] = "SUCCESS";
+const char kUnsupportedRequest[] = "UNSUPPORTED_REQUEST";
+const char kUnsupportedResource[] = "UNSUPPORTED_RESOURCE";
+const char kDisallowed[] = "DISALLOWED";
+const char kRejected[] = "REJECTED";
+const char kAborted[] = "ABORTED";
+const char kIgnored[] = "IGNORED";
+const char kRetry[] = "RETRY";
+const char kInUse[] = "IN_USE";
+const char kVehicleDataNotAvailable[] = "VEHICLE_DATA_NOT_AVAILABLE";
+const char kTimedOut[] = "TIMED_OUT";
+const char kInvalidData[] = "INVALID_DATA";
+const char kCharLimitExceeded[] = "CHAR_LIMIT_EXCEEDED";
+const char kInvalidId[] = "INVALID_ID";
+const char kDuplicateName[] = "DUPLICATE_NAME";
+const char kApplicationNotRegistered[] = "APPLICATION_NOT_REGISTERED";
+const char kOutOfMemory[] = "OUT_OF_MEMORY";
+const char kTooManyPendingRequests[] = "TOO_MANY_PENDING_REQUESTS";
+const char kWarnings[] = "WARNINGS";
+const char kWrongLanguage[] = "WRONG_LANGUAGE";
+const char kGenericError[] = "GENERIC_ERROR";
+const char kUserDisallowed[] = "USER_DISALLOWED";
+const char kReadOnly[] = "READ_ONLY";
+} // result_codes
+
+namespace json_keys {
+const char kParams[] = "params";
+const char kSuccess[] = "success";
+const char kResultCode[] = "resultCode";
+const char kResult[] = "result";
+const char kInfo[] = "info";
+const char kId[] = "id";
+const char kJsonrpc[] = "jsonrpc";
+const char kMethod[] = "method";
+const char kError[] = "error";
+const char kMessage[] = "message";
+const char kData[] = "data";
+const char kAppId[] = "appID";
+const char kCode[] = "code";
+} // json_keys
+
+namespace message_params {
+const char kName[] = "name";
+
+// SetInteriorVehicleData request
+const char kModuleData[] = "moduleData";
+// SetInteriorVehicleData request
+
+// GetInteriorVehicleData request
+const char kSubscribe[] = "subscribe";
+// GetInteriorVehicleData request
+
+// GetInteriorVehicleData response
+const char kIsSubscribed[] = "isSubscribed";
+// GetInteriorVehicleData response
+
+// OnRemoteControlSettings notification
+const char kAccessMode[] = "accessMode";
+const char kAllowed[] = "allowed";
+// OnRemoteControlSettings notification
+
+// ButtonPress request
+const char kModuleType[] = "moduleType";
+const char kButtonName[] = "buttonName";
+const char kButtonPressMode[] = "buttonPressMode";
+// ButtonPress request
+
+// RdsData struct
+const char kPS[] = "PS";
+const char kRT[] = "RT";
+const char kCT[] = "CT";
+const char kPI[] = "PI";
+const char kPTY[] = "PTY";
+const char kTA[] = "TA";
+const char kTP[] = "TP";
+const char kREG[] = "REG";
+// RdsData struct
+
+// RadioControlData struct
+const char kFrequencyInteger[] = "frequencyInteger";
+const char kFrequencyFraction[] = "frequencyFraction";
+const char kBand[] = "band";
+const char kRdsData[] = "rdsData";
+const char kAvailableHDs[] = "availableHDs";
+const char kHdChannel[] = "hdChannel";
+const char kSignalStrength[] = "signalStrength";
+const char kSignalChangeThreshold[] = "signalChangeThreshold";
+const char kRadioEnable[] = "radioEnable";
+const char kState[] = "state";
+// RadioControlData struct
+
+// ClimateControlData struct
+const char kFanSpeed[] = "fanSpeed";
+const char kCurrentTemperature[] = "currentTemperature";
+const char kDesiredTemperature[] = "desiredTemperature";
+const char kTemperatureUnit[] = "temperatureUnit";
+const char kACEnable[] = "acEnable";
+const char kCirculateAirEnable[] = "circulateAirEnable";
+const char kAutoModeEnable[] = "autoModeEnable";
+const char kDefrostZone[] = "defrostZone";
+const char kDualModeEnable[] = "dualModeEnable";
+const char kACMaxEnable[] = "acMaxEnable";
+const char kVentilationMode[] = "ventilationMode";
+// ClimateControlData struct
+
+// ModuleData struct
+const char kRadioControlData[] = "radioControlData";
+const char kClimateControlData[] = "climateControlData";
+// ModuleData struct
+
+const char kHMIAppID[] = "appID";
+const char kHmiLevel[] = "hmiLevel";
+const char kSysContext[] = "systemContext";
+const char kAudioState[] = "audioStreamingState";
+} // namespace message_params
+
+namespace enums_value {
+
+// ModuleType enum
+const char kClimate[] = "CLIMATE";
+const char kRadio[] = "RADIO";
+// ModuleType enum
+
+// RadioBand enum
+const char kAM[] = "AM";
+const char kFM[] = "FM";
+const char kXM[] = "XM";
+// RadioBand enum
+
+// RadioState enum
+const char kAcquiring[] = "ACQUIRING";
+const char kAcquired[] = "ACQUIRED";
+const char kMulticast[] = "MULTICAST";
+const char kNotFound[] = "NOT_FOUND";
+// RadioState enum
+
+// DefrostZone enum
+const char kFront[] = "FRONT";
+const char kRear[] = "REAR";
+const char kAll[] = "ALL";
+// DefrostZone enum
+
+// TemperatureUnit enum
+const char kFahrenheit[] = "FAHRENHEIT";
+const char kCelsius[] = "CELSIUS";
+// TemperatureUnit enum
+
+// ButtonName enum
+const char kACMax[] = "AC_MAX";
+const char kAC[] = "AC";
+const char kRecirculate[] = "RECIRCULATE";
+const char kFanUp[] = "FAN_UP";
+const char kFanDown[] = "FAN_DOWN";
+const char kTempUp[] = "TEMP_UP";
+const char kTempDown[] = "TEMP_DOWN";
+const char kDefrostMax[] = "DEFROST_MAX";
+const char kDefrost[] = "DEFROST";
+const char kDefrostRear[] = "DEFROST_REAR";
+const char kUpperVent[] = "UPPER_VENT";
+const char kLowerVent[] = "LOWER_VENT";
+const char kVolumeUp[] = "VOLUME_UP";
+const char kVolumeDown[] = "VOLUME_DOWN";
+const char kEject[] = "EJECT";
+const char kSource[] = "SOURCE";
+const char kShuffle[] = "SHUFFLE";
+const char kRepeat[] = "REPEAT";
+// ButtonName enum
+
+// ButtonPressMode enum
+const char kLong[] = "LONG";
+const char kShort[] = "SHORT";
+// ButtonPressMode enum
+
+// Access mode enum
+const char kAutoAllow[] = "AUTO_ALLOW";
+const char kAutoDeny[] = "AUTO_DENY";
+const char kAskDriver[] = "ASK_DRIVER";
+// Access mode enum
+
+} // namespace enums_value
+
+} // namespace remote_control
+
+#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_MODULE_CONSTANTS_H_
diff --git a/src/components/remote_control/include/remote_control/rc_module_timer.h b/src/components/remote_control/include/remote_control/rc_module_timer.h
new file mode 100644
index 0000000000..813f26a885
--- /dev/null
+++ b/src/components/remote_control/include/remote_control/rc_module_timer.h
@@ -0,0 +1,70 @@
+/*
+ * 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_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_MODULE_TIMER_H_
+#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_MODULE_TIMER_H_
+
+#include "functional_module/timer/module_timer.h"
+
+namespace remote_control {
+
+class TrackableMessage : public functional_modules::Trackable {
+ public:
+ TrackableMessage(uint32_t app_id, uint32_t correlation_id)
+ : custom_interval_(0), app_id_(app_id), correlation_id_(correlation_id) {}
+
+ functional_modules::TimeUnit custom_interval() const {
+ return custom_interval_;
+ }
+
+ uint32_t app_id() const {
+ return app_id_;
+ }
+
+ uint32_t correlation_id() const {
+ return correlation_id_;
+ }
+
+ bool operator==(const TrackableMessage& other) const {
+ return (other.app_id_ == app_id_ &&
+ other.correlation_id_ == correlation_id_);
+ }
+
+ private:
+ functional_modules::TimeUnit custom_interval_;
+ uint32_t app_id_;
+ uint32_t correlation_id_;
+};
+
+} // namesapce remote_control
+
+#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_MODULE_TIMER_H_
diff --git a/src/components/remote_control/include/remote_control/remote_control_event.h b/src/components/remote_control/include/remote_control/remote_control_event.h
new file mode 100644
index 0000000000..3c98f971ac
--- /dev/null
+++ b/src/components/remote_control/include/remote_control/remote_control_event.h
@@ -0,0 +1,82 @@
+/*
+ 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_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_REMOTE_CONTROL_EVENT_H_
+#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_REMOTE_CONTROL_EVENT_H_
+
+#include <string>
+
+#include "application_manager/message.h"
+
+#include "remote_control/event_engine/event.h"
+
+namespace remote_control {
+
+class RCPluginEvent
+ : public rc_event_engine::Event<application_manager::MessagePtr,
+ std::string> {
+ public:
+ /*
+ * @brief Constructor with parameters
+ *
+ * @param id Event ID. (HMI or CAN function name)
+ * @param message Message received in HMI or CAN response
+ */
+ RCPluginEvent(application_manager::MessagePtr& message,
+ const std::string& id);
+
+ /*
+ * @brief Destructor
+ */
+ virtual ~RCPluginEvent();
+
+ /*
+ * @brief Retrieves event message request ID
+ */
+ virtual int32_t event_message_function_id() const;
+
+ /*
+ * @brief Retrieves event message correlation ID
+ */
+ virtual int32_t event_message_correlation_id() const;
+
+ /*
+ * @brief Retrieves event message response type
+ */
+ virtual int32_t event_message_type() const;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(RCPluginEvent);
+};
+}
+
+#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_REMOTE_CONTROL_EVENT_H_
diff --git a/src/components/remote_control/include/remote_control/remote_control_plugin.h b/src/components/remote_control/include/remote_control/remote_control_plugin.h
new file mode 100644
index 0000000000..6e36470b06
--- /dev/null
+++ b/src/components/remote_control/include/remote_control/remote_control_plugin.h
@@ -0,0 +1,163 @@
+/*
+ * 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_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_REMOTE_CONTROL_PLUGIN_H_
+#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_REMOTE_CONTROL_PLUGIN_H_
+
+#include <queue>
+#include <string>
+
+#include "remote_control/remote_plugin_interface.h"
+#include "functional_module/generic_module.h"
+#include "remote_control/request_controller.h"
+#include "utils/threads/message_loop_thread.h"
+#include "remote_control/event_engine/event_dispatcher.h"
+#include "remote_control/resource_allocation_manager_impl.h"
+
+namespace remote_control {
+typedef rc_event_engine::EventDispatcher<application_manager::MessagePtr,
+ std::string> RCEventDispatcher;
+
+class RemoteControlPlugin : public RemotePluginInterface {
+ public:
+ RemoteControlPlugin();
+ ~RemoteControlPlugin();
+
+ functional_modules::PluginInfo GetPluginInfo() const;
+ virtual functional_modules::ProcessResult ProcessMessage(
+ application_manager::MessagePtr msg);
+ virtual functional_modules::ProcessResult ProcessHMIMessage(
+ application_manager::MessagePtr msg);
+
+ /**
+ * @brief Sends response to mobile application
+ * @param msg response mesage
+ */
+ void SendResponseToMobile(application_manager::MessagePtr msg);
+
+ /**
+ * @brief Sends timeout response to mobile application
+ * @param msg response mesage
+ */
+ void SendTimeoutResponseToMobile(application_manager::MessagePtr msg);
+
+ /**
+ * @brief Remove extension created for specified application
+ * @param app_id application id
+ */
+ virtual void RemoveAppExtension(uint32_t app_id);
+
+ /**
+ * @brief Check registering app can be handled by plugin
+ * @param msg Registration message
+ * @param app Application basis already create by Core
+ */
+ bool IsAppForPlugin(application_manager::ApplicationSharedPtr app);
+
+ /**
+ * @brief Notify about change of HMILevel of plugin's app
+ * @param app App with new HMILevel
+ * @param old_level Old HMILevel of app
+ */
+ void OnAppHMILevelChanged(application_manager::ApplicationSharedPtr app,
+ mobile_apis::HMILevel::eType old_level);
+
+ /**
+ * @brief Sends HMI status notification to mobile
+ * @param app application with changed HMI status
+ **/
+ void SendHmiStatusNotification(
+ application_manager::ApplicationSharedPtr app) OVERRIDE;
+
+ /**
+ * @brief Getter for event_dispatcher
+ * @return reference to RCEventDispatcher instance
+ */
+ RCEventDispatcher& event_dispatcher() OVERRIDE;
+
+ /**
+ * @brief Getter for resource_allocation_manager
+ * @return reference to ResourceAllocationManager instance
+ */
+ ResourceAllocationManager& resource_allocation_manager() OVERRIDE;
+
+ /**
+ * @brief Overriden setter for service
+ * @param service pointer to new service instance
+ */
+ void set_service(application_manager::ServicePtr service) OVERRIDE;
+
+ /*
+ * @brief OnApplicationEvent Processes application related events
+ * @param event Event
+ * @param application_id Application id
+ */
+ void OnApplicationEvent(functional_modules::ApplicationEvent event,
+ const uint32_t application_id) OVERRIDE;
+
+ /**
+ * @brief OnPolicyEvent Processes policy related events
+ * @param event Policy event
+ */
+ void OnPolicyEvent(functional_modules::PolicyEvent event) OVERRIDE;
+
+ protected:
+ /**
+ * @brief Remove extension for all applications
+ */
+ virtual void RemoveAppExtensions() OVERRIDE;
+
+ private:
+ /**
+ * @brief Trigger actions which should be done after plugin service instance
+ * have been changed
+ */
+ void OnPluginServiceChanged();
+
+ /**
+ * @brief Subscribes on all RC related functions
+ */
+ void SubscribeOnFunctions();
+
+ functional_modules::PluginInfo plugin_info_;
+ bool is_scan_started_;
+ request_controller::RequestController request_controller_;
+
+ RCEventDispatcher event_dispatcher_;
+
+ ResourceAllocationManagerImpl resource_allocation_manager_;
+ DISALLOW_COPY_AND_ASSIGN(RemoteControlPlugin);
+};
+
+} // namespace remote_control
+
+#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_REMOTE_CONTROL_PLUGIN_H_
diff --git a/src/components/remote_control/include/remote_control/remote_plugin_interface.h b/src/components/remote_control/include/remote_control/remote_plugin_interface.h
new file mode 100644
index 0000000000..51135d8a8a
--- /dev/null
+++ b/src/components/remote_control/include/remote_control/remote_plugin_interface.h
@@ -0,0 +1,118 @@
+/*
+ * 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_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_REMOTE_PLUGIN_INTERFACE_H_
+#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_REMOTE_PLUGIN_INTERFACE_H_
+
+#include <queue>
+#include <string>
+#include "functional_module/generic_module.h"
+#include "remote_control/request_controller.h"
+#include "remote_control/event_engine/event_dispatcher.h"
+#include "utils/threads/message_loop_thread.h"
+#include "utils/shared_ptr.h"
+
+namespace remote_control {
+
+class RCAppExtension;
+class ResourceAllocationManager;
+
+typedef utils::SharedPtr<RCAppExtension> RCAppExtensionPtr;
+
+class RemotePluginInterface : public functional_modules::GenericModule {
+ public:
+ RemotePluginInterface() : GenericModule(kCANModuleID) {}
+ virtual ~RemotePluginInterface() {}
+ virtual functional_modules::PluginInfo GetPluginInfo() const = 0;
+ virtual functional_modules::ProcessResult ProcessMessage(
+ application_manager::MessagePtr msg) = 0;
+ virtual functional_modules::ProcessResult ProcessHMIMessage(
+ application_manager::MessagePtr msg) = 0;
+
+ /**
+ * @brief Sends response to mobile application
+ * @param msg response mesage
+ */
+ virtual void SendResponseToMobile(application_manager::MessagePtr msg) = 0;
+
+ /**
+ * @brief Sends timeout response to mobile application
+ * @param msg response mesage
+ */
+ virtual void SendTimeoutResponseToMobile(
+ application_manager::MessagePtr msg) = 0;
+
+ /**
+ * @brief Remove extension created for specified application
+ * @param app_id application id
+ */
+ virtual void RemoveAppExtension(uint32_t app_id) = 0;
+
+ /**
+ * @brief Check registering app can be handled by plugin
+ * @param msg Registration message
+ * @param app Application basis already create by Core
+ */
+ virtual bool IsAppForPlugin(
+ application_manager::ApplicationSharedPtr app) = 0;
+
+ /**
+ * @brief Notify about change of HMILevel of plugin's app
+ * @param app App with new HMILevel
+ * @param old_level Old HMILevel of app
+ */
+ virtual void OnAppHMILevelChanged(
+ application_manager::ApplicationSharedPtr app,
+ mobile_apis::HMILevel::eType old_level) = 0;
+
+ virtual void SendHmiStatusNotification(
+ application_manager::ApplicationSharedPtr app) = 0;
+
+ typedef rc_event_engine::EventDispatcher<application_manager::MessagePtr,
+ std::string> RCPluginEventDispatcher;
+
+ virtual RCPluginEventDispatcher& event_dispatcher() = 0;
+
+ virtual ResourceAllocationManager& resource_allocation_manager() = 0;
+
+ protected:
+ /**
+ * @brief Remove extension for all applications
+ */
+ virtual void RemoveAppExtensions() = 0;
+
+ static const functional_modules::ModuleID kCANModuleID = 153;
+};
+
+} // namespace remote_control
+
+#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_REMOTE_PLUGIN_INTERFACE_H_
diff --git a/src/components/remote_control/include/remote_control/request_controller.h b/src/components/remote_control/include/remote_control/request_controller.h
new file mode 100644
index 0000000000..8a79d9ebc4
--- /dev/null
+++ b/src/components/remote_control/include/remote_control/request_controller.h
@@ -0,0 +1,110 @@
+/**
+ * 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_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_REQUEST_CONTROLLER_H_
+#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_REQUEST_CONTROLLER_H_
+
+#include <map>
+
+#include "remote_control/commands/command.h"
+#include "remote_control/rc_module_timer.h"
+#include "functional_module/timer/timer_director.h"
+#include "utils/lock.h"
+
+namespace remote_control {
+
+namespace commands {
+class Command;
+}
+
+namespace request_controller {
+
+typedef utils::SharedPtr<commands::Command> MobileRequestPtr;
+typedef uint32_t correlation_id;
+
+/**
+ * @brief RequestController class is used to manage mobile requests lifetime.
+ */
+class RequestController
+ : public functional_modules::TimerObserver<TrackableMessage> {
+ public:
+ /**
+ * @brief Class constructor
+ *
+ */
+ RequestController();
+
+ /**
+ * @brief Class destructor
+ *
+ */
+ virtual ~RequestController();
+
+ /**
+ * @brief Adds pointer to request.
+ * @param mobile_correlation_id mobile request correlation id
+ * @param command pointer to request created in mobile factory
+ */
+ void AddRequest(const uint32_t mobile_correlation_id,
+ MobileRequestPtr request);
+
+ /**
+ * @brief Removes request
+ * @param mobile_corellation_id mobile request correlation id
+ */
+ void DeleteRequest(const uint32_t& mobile_correlation_id);
+
+ /**
+ * @brief Sets timeout value for RC requests
+ * @param timeout_seconds new timeout value in seconds
+ */
+ void SetRequestTimeout(const functional_modules::TimeUnit timeout_seconds);
+
+ /**
+ * @brief Triggers actions when timeout for some request is expired
+ * @param expired reference to request which timeout was expired
+ */
+ void OnTimeoutTriggered(const TrackableMessage& expired) OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(RequestController);
+
+ std::map<correlation_id, MobileRequestPtr> mobile_request_list_;
+ functional_modules::ModuleTimer<TrackableMessage> timer_;
+ functional_modules::TimerDirector time_director_;
+ sync_primitives::Lock mobile_request_lock_;
+};
+
+} // namespace request_controller
+} // namespace remote_control
+
+#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_REQUEST_CONTROLLER_H_
diff --git a/src/components/remote_control/include/remote_control/resource_allocation_manager.h b/src/components/remote_control/include/remote_control/resource_allocation_manager.h
new file mode 100644
index 0000000000..e9712370d9
--- /dev/null
+++ b/src/components/remote_control/include/remote_control/resource_allocation_manager.h
@@ -0,0 +1,114 @@
+#ifndef SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RESOURCE_ALLOCATION_H
+#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RESOURCE_ALLOCATION_H
+#include <string>
+#include "utils/macro.h"
+#include "utils/shared_ptr.h"
+#include "interfaces/HMI_API.h"
+#include "remote_control/event_engine/event.h"
+#include "functional_module/generic_module.h"
+
+namespace remote_control {
+
+/**
+ * Enum for list of results of allocation resources
+ */
+namespace AcquireResult {
+enum eType { ALLOWED = 0, IN_USE, ASK_DRIVER, REJECTED };
+}
+
+/**
+ * Defines states of acquired resource
+ */
+namespace ResourceState {
+enum eType { FREE = 0, BUSY };
+}
+
+/**
+ * @brief Resources defines list of resources
+ */
+typedef std::vector<std::string> Resources;
+
+class ResourceAllocationManager {
+ public:
+ /**
+ * @brief AcquireResource acquires resource by application
+ * @param module_type resource to acquire
+ * @param app_id application that acquire resource
+ * @return ALLOWED if resource acquired \
+ * IN_USE if subscription is not allowed
+ * ASK_DRIVER if driver confirmation is required
+ */
+ virtual AcquireResult::eType AcquireResource(const std::string& module_type,
+ const uint32_t app_id) = 0;
+
+ /**
+ * @brief SetResourceState changes resource state. Resource must be acquired
+ * beforehand.
+ * @param module_type Resource to change its state
+ * @param app_id Application aquired resource before
+ * @param state State to set for resource
+ */
+ virtual void SetResourceState(const std::string& module_type,
+ const uint32_t app_id,
+ const ResourceState::eType state) = 0;
+
+ /**
+ * @brief IsResourceFree check resource state
+ * @param module_type Resource name
+ * @return True if free, otherwise - false
+ */
+ virtual bool IsResourceFree(const std::string& module_type) const = 0;
+
+ /**
+ * @brief AcquireResource forces acquiring resource by application
+ * @param module_type resource to acquire
+ * @param app_id application that acquire resource
+ */
+ virtual void ForceAcquireResource(const std::string& module_type,
+ const uint32_t app_id) = 0;
+
+ /**
+ * @brief OnDriverDisallowed callback for rejecting acquiring resource
+ * @param module_type resource type
+ * @param app_id application id
+ */
+ virtual void OnDriverDisallowed(const std::string& module_type,
+ const uint32_t app_id) = 0;
+
+ /**
+ * @brief OnApplicationEvent Processes application related events
+ * @param event Event
+ * @param application_id Application id
+ */
+ virtual void OnApplicationEvent(functional_modules::ApplicationEvent event,
+ const uint32_t application_id) = 0;
+
+ /**
+ * @brief OnPolicyEvent Processes policy related events
+ * @param event Policy event
+ */
+ virtual void OnPolicyEvent(functional_modules::PolicyEvent event) = 0;
+
+ /**
+ * @brief Set current access mode for acquiring resource
+ * @param access_mode
+ */
+ virtual void SetAccessMode(
+ const hmi_apis::Common_RCAccessMode::eType access_mode) = 0;
+
+ /**
+ * @brief Get last set access mode for acquiring resource
+ * @param access_mode
+ */
+ virtual hmi_apis::Common_RCAccessMode::eType GetAccessMode() const = 0;
+
+ /**
+ * @brief Remove all information about all allocations
+ */
+ virtual void ResetAllAllocations() = 0;
+
+ virtual ~ResourceAllocationManager() {}
+};
+
+} // namespace remote_control
+#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RESOURCE_ALLOCATION_H
diff --git a/src/components/remote_control/include/remote_control/resource_allocation_manager_impl.h b/src/components/remote_control/include/remote_control/resource_allocation_manager_impl.h
new file mode 100644
index 0000000000..a62d1b091c
--- /dev/null
+++ b/src/components/remote_control/include/remote_control/resource_allocation_manager_impl.h
@@ -0,0 +1,136 @@
+#ifndef SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RESOURCE_ALLOCATION_IMPL_H
+#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RESOURCE_ALLOCATION_IMPL_H
+#include "remote_control/resource_allocation_manager.h"
+#include "remote_control/remote_plugin_interface.h"
+#include "utils/macro.h"
+#include "utils/lock.h"
+
+namespace remote_control {
+
+typedef rc_event_engine::EventDispatcher<application_manager::MessagePtr,
+ std::string> RCEventDispatcher;
+
+class ResourceAllocationManagerImpl : public ResourceAllocationManager {
+ public:
+ ResourceAllocationManagerImpl(RemotePluginInterface& rc_plugin);
+
+ ~ResourceAllocationManagerImpl();
+
+ AcquireResult::eType AcquireResource(const std::string& module_type,
+ const uint32_t app_id) OVERRIDE FINAL;
+
+ void SetResourceState(const std::string& module_type,
+ const uint32_t app_id,
+ const ResourceState::eType state) FINAL;
+
+ bool IsResourceFree(const std::string& module_type) const FINAL;
+
+ void SetAccessMode(
+ const hmi_apis::Common_RCAccessMode::eType access_mode) FINAL;
+
+ hmi_apis::Common_RCAccessMode::eType GetAccessMode() const FINAL;
+
+ void ForceAcquireResource(const std::string& module_type,
+ const uint32_t app_id) FINAL;
+
+ void OnDriverDisallowed(const std::string& module_type,
+ const uint32_t app_id) FINAL;
+
+ /**
+ * @brief OnApplicationEvent Processes application related events
+ * @param event Event
+ * @param application_id Application id
+ */
+ void OnApplicationEvent(functional_modules::ApplicationEvent event,
+ const uint32_t application_id) FINAL;
+
+ /**
+ * @brief OnPolicyEvent Processes policy related events
+ * @param event Policy event
+ */
+ void OnPolicyEvent(functional_modules::PolicyEvent event) FINAL;
+
+ void ResetAllAllocations() FINAL;
+
+ private:
+ typedef std::vector<application_manager::ApplicationSharedPtr> Apps;
+
+ /**
+ * @brief IsModuleTypeRejected check if current resource was rejected by
+ * driver for current application
+ * @param module_type resource to check
+ * @param app_id application id
+ * @return true if current resource was rejected by driver for current
+ * application, otherwise - false
+ */
+ bool IsModuleTypeRejected(const std::string& module_type,
+ const uint32_t app_id);
+
+ /**
+ * @brief ReleaseResource Releases resource acquired by application
+ * @param module_type Module name
+ * @param application_id Application id
+ */
+ void ReleaseResource(const std::string& module_type,
+ const uint32_t application_id);
+
+ /**
+ * @brief GetAcquiredResources Provides resources acquired by particular
+ * application currently
+ * @param application_id Application id
+ * @return List of acquired resources by specific application
+ */
+ Resources GetAcquiredResources(const uint32_t application_id) const;
+
+ /**
+ * @brief ProcessApplicationPolicyUpdate Checks if allowed modules list is
+ * changed for registered RC applications and releases in case some modules
+ * now out of the list
+ */
+ void ProcessApplicationPolicyUpdate();
+
+ /**
+ * @brief GetApplicationExtention Provides access to application RC extention
+ * @param application Application
+ * @return Pointer to RC extention of application or NULL if not available
+ */
+ RCAppExtensionPtr GetApplicationExtention(
+ application_manager::ApplicationSharedPtr application);
+
+ /**
+ * @brief RemoveAppsSubscriptions Removes subscriptions for interior data for
+ * applications in the list
+ * @param apps Application list
+ */
+ void RemoveAppsSubscriptions(const Apps& apps);
+
+ /**
+ * @brief AllocatedResources contains link between resource and application
+ * owning that resource
+ */
+ typedef std::map<std::string, uint32_t> AllocatedResources;
+ AllocatedResources allocated_resources_;
+ mutable sync_primitives::Lock allocated_resources_lock_;
+
+ /**
+ * @brief ResourcesState contains states of ALLOCATED resources
+ */
+ typedef std::map<std::string, ResourceState::eType> ResourcesState;
+ ResourcesState resources_state_;
+ mutable sync_primitives::Lock resources_state_lock_;
+
+ /**
+ * @brief RejectedResources type for connecting list of resources rejected by
+ * driver for application
+ * application_id : [vector of rejected resources]
+ */
+ typedef std::map<uint32_t, std::vector<std::string> > RejectedResources;
+ RejectedResources rejected_resources_for_application_;
+ mutable sync_primitives::Lock rejected_resources_for_application_lock_;
+
+ hmi_apis::Common_RCAccessMode::eType current_access_mode_;
+ RemotePluginInterface& rc_plugin_;
+};
+} // remote_control
+
+#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RESOURCE_ALLOCATION_IMPL_H
diff --git a/src/components/remote_control/src/commands/base_command_notification.cc b/src/components/remote_control/src/commands/base_command_notification.cc
new file mode 100644
index 0000000000..2de82abdef
--- /dev/null
+++ b/src/components/remote_control/src/commands/base_command_notification.cc
@@ -0,0 +1,154 @@
+/*
+ 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.
+ */
+
+#include "remote_control/commands/base_command_notification.h"
+#include "json/json.h"
+#include "remote_control/remote_control_plugin.h"
+#include "remote_control/rc_module_constants.h"
+#include "application_manager/application_manager.h"
+
+namespace remote_control {
+
+namespace commands {
+
+CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule")
+
+BaseCommandNotification::BaseCommandNotification(
+ const application_manager::MessagePtr& message,
+ RemotePluginInterface& rc_module)
+ : Command(rc_module), service_(rc_module_.service()), message_(message) {
+ Json::Value value;
+ Json::Reader reader;
+ reader.parse(message_->json_message(), value);
+ if (value.isMember(json_keys::kParams)) {
+ Json::FastWriter writer;
+ message_->set_json_message(writer.write(value[json_keys::kParams]));
+ } else {
+ message_->set_json_message("");
+ }
+}
+
+BaseCommandNotification::~BaseCommandNotification() {}
+
+RCAppExtensionPtr BaseCommandNotification::GetAppExtension(
+ application_manager::ApplicationSharedPtr app) const {
+ if (!app) {
+ return NULL;
+ }
+
+ functional_modules::ModuleID id = rc_module_.GetModuleID();
+
+ RCAppExtensionPtr rc_app_extension;
+ application_manager::AppExtensionPtr app_extension = app->QueryInterface(id);
+ if (!app_extension) {
+ return NULL;
+ }
+
+ rc_app_extension =
+ application_manager::AppExtensionPtr::static_pointer_cast<RCAppExtension>(
+ app_extension);
+
+ return rc_app_extension;
+}
+
+void BaseCommandNotification::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ Execute();
+}
+
+void BaseCommandNotification::NotifyApplications() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ typedef std::vector<application_manager::ApplicationSharedPtr> AppList;
+ AppList applications = service_->GetApplications(rc_module_.GetModuleID());
+ for (AppList::iterator i = applications.begin(); i != applications.end();
+ ++i) {
+ application_manager::MessagePtr message(
+ new application_manager::Message(*message_));
+ message->set_connection_key((*i)->app_id());
+ NotifyOneApplication(message);
+ }
+}
+
+void BaseCommandNotification::NotifyOneApplication(
+ application_manager::MessagePtr message) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (CheckPolicy(message)) {
+ service_->SendMessageToMobile(message);
+ } else {
+ LOG4CXX_WARN(logger_,
+ "Function \"" << message->function_name() << "\" (#"
+ << message->function_id()
+ << ") not allowed by policy");
+ }
+}
+
+bool BaseCommandNotification::CheckPolicy(
+ application_manager::MessagePtr message) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ application_manager::ApplicationSharedPtr app =
+ service_->GetApplication(message->connection_key());
+
+ if (!app) {
+ LOG4CXX_WARN(logger_,
+ "Application " << message->connection_key()
+ << "isn't registered");
+ return false;
+ }
+
+ mobile_apis::Result::eType permission =
+ service_->CheckPolicyPermissions(message);
+
+ Json::Value value;
+ Json::Reader reader;
+ LOG4CXX_DEBUG(logger_, "Notification: " << message->json_message());
+ reader.parse(message->json_message(), value);
+
+ return permission == mobile_apis::Result::eType::SUCCESS &&
+ service_->CheckModule(app->app_id(), ModuleType(value));
+}
+
+std::string BaseCommandNotification::ModuleType(const Json::Value& message) {
+ return "";
+}
+
+bool BaseCommandNotification::Validate() {
+ return true;
+}
+
+std::vector<std::string> BaseCommandNotification::ControlData(
+ const Json::Value& message) {
+ return std::vector<std::string>();
+}
+
+} // namespace commands
+
+} // namespace remote_control
diff --git a/src/components/remote_control/src/commands/base_command_request.cc b/src/components/remote_control/src/commands/base_command_request.cc
new file mode 100644
index 0000000000..bc6202d2a8
--- /dev/null
+++ b/src/components/remote_control/src/commands/base_command_request.cc
@@ -0,0 +1,564 @@
+/*
+ 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.
+ */
+
+#include "remote_control/commands/base_command_request.h"
+#include <cstring>
+#include "utils/make_shared.h"
+#include "remote_control/event_engine/event_dispatcher.h"
+#include "remote_control/message_helper.h"
+#include "remote_control/remote_control_plugin.h"
+#include "remote_control/rc_module_constants.h"
+#include "application_manager/application_manager_impl.h"
+
+namespace remote_control {
+
+namespace commands {
+
+using rc_event_engine::EventDispatcher;
+
+CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule")
+
+BaseCommandRequest::BaseCommandRequest(
+ const application_manager::MessagePtr& message,
+ RemotePluginInterface& rc_module)
+ : Command(rc_module)
+ , message_(message)
+ , msg_json_(MessageHelper::StringToValue(message->json_message()))
+ , auto_allowed_(false) {
+ service_ = rc_module_.service();
+ app_ = service_->GetApplication(message_->connection_key());
+}
+
+BaseCommandRequest::~BaseCommandRequest() {
+ rc_module_.event_dispatcher().remove_observer(this);
+}
+
+void BaseCommandRequest::OnTimeout() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ SetResourceState(msg_json_, ResourceState::FREE);
+
+ PrepareResponse(
+ false, result_codes::kGenericError, "Request timeout expired.");
+ rc_module_.SendTimeoutResponseToMobile(message_);
+}
+
+void BaseCommandRequest::PrepareResponse(const bool success,
+ const char* result_code,
+ const std::string& info) {
+ message_->set_message_type(application_manager::MessageType::kResponse);
+ Json::Value msg_params;
+
+ if (!response_params_.isNull()) {
+ msg_params = response_params_;
+ }
+
+ msg_params[json_keys::kSuccess] = success;
+ msg_params[json_keys::kResultCode] = result_code;
+ if (!info.empty()) {
+ msg_params[json_keys::kInfo] = info;
+ }
+
+ Json::FastWriter writer;
+ std::string params = writer.write(msg_params);
+ message_->set_json_message(params);
+}
+
+void BaseCommandRequest::SendResponse(const bool success,
+ const char* result_code,
+ const std::string& info) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ SetResourceState(msg_json_, ResourceState::FREE);
+ PrepareResponse(success, result_code, info);
+ rc_module_.SendResponseToMobile(message_);
+}
+
+void BaseCommandRequest::SendMessageToHMI(
+ const application_manager::MessagePtr& message_to_send) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ using application_manager::HmiInterfaces;
+
+ const bool is_rc_available =
+ service_->IsInterfaceAvailable(HmiInterfaces::HMI_INTERFACE_RC);
+ LOG4CXX_DEBUG(logger_, "HMI interface RC is available: " << is_rc_available);
+ if (!is_rc_available) {
+ const bool success = false;
+ const char* result_code = result_codes::kUnsupportedResource;
+ const std::string info = "Remote control is not supported by system";
+
+ SendResponse(success, result_code, info);
+ return;
+ }
+
+ const std::string function_name = message_to_send->function_name();
+ const int32_t correlation_id = message_to_send->correlation_id();
+ LOG4CXX_DEBUG(logger_,
+ "Subsribing to response for function: "
+ << function_name
+ << " and correlation id: " << correlation_id);
+
+ rc_module_.event_dispatcher().add_observer(
+ function_name, correlation_id, this);
+
+ LOG4CXX_DEBUG(logger_, "HMI Request:\n " << message_to_send->json_message());
+
+ service_->SendMessageToHMI(message_to_send);
+}
+
+void BaseCommandRequest::SendRequest(const char* function_id,
+ const Json::Value& message_params) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ application_manager::MessagePtr message_to_send =
+ CreateHmiRequest(function_id, message_params);
+ SendMessageToHMI(message_to_send);
+}
+
+application_manager::MessagePtr BaseCommandRequest::CreateHmiRequest(
+ const char* function_id, const Json::Value& message_params) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ const uint32_t hmi_app_id = app_->hmi_app_id();
+ return MessageHelper::CreateHmiRequest(
+ function_id, hmi_app_id, message_params, rc_module_);
+}
+
+bool BaseCommandRequest::Validate() {
+ return application_manager::MessageValidationResult::SUCCESS ==
+ service_->ValidateMessageBySchema(*message_);
+}
+
+bool BaseCommandRequest::ParseJsonString(Json::Value* parsed_msg) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ DCHECK(parsed_msg);
+ if (!parsed_msg)
+ return false;
+
+ (*parsed_msg) = MessageHelper::StringToValue(message_->json_message());
+ if (Json::ValueType::nullValue == parsed_msg->type()) {
+ LOG4CXX_ERROR(logger_,
+ "Invalid JSON received in " << message_->json_message());
+ SendResponse(
+ false, result_codes::kInvalidData, "Mobile request validation failed!");
+ return false;
+ }
+ return true;
+}
+
+const char* BaseCommandRequest::GetMobileResultCode(
+ const hmi_apis::Common_Result::eType& hmi_code) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ switch (hmi_code) {
+ case hmi_apis::Common_Result::SUCCESS: {
+ return result_codes::kSuccess;
+ }
+ case hmi_apis::Common_Result::UNSUPPORTED_REQUEST: {
+ return result_codes::kUnsupportedRequest;
+ }
+ case hmi_apis::Common_Result::UNSUPPORTED_RESOURCE: {
+ return result_codes::kUnsupportedResource;
+ }
+ case hmi_apis::Common_Result::DISALLOWED: {
+ return result_codes::kDisallowed;
+ }
+ case hmi_apis::Common_Result::REJECTED: {
+ return result_codes::kRejected;
+ }
+ case hmi_apis::Common_Result::ABORTED: {
+ return result_codes::kAborted;
+ }
+ case hmi_apis::Common_Result::IGNORED: {
+ return result_codes::kIgnored;
+ }
+ case hmi_apis::Common_Result::RETRY: {
+ return result_codes::kRetry;
+ }
+ case hmi_apis::Common_Result::IN_USE: {
+ return result_codes::kInUse;
+ }
+ case hmi_apis::Common_Result::DATA_NOT_AVAILABLE: {
+ return result_codes::kVehicleDataNotAvailable;
+ }
+ case hmi_apis::Common_Result::TIMED_OUT: {
+ return result_codes::kTimedOut;
+ }
+ case hmi_apis::Common_Result::INVALID_DATA: {
+ return result_codes::kInvalidData;
+ }
+ case hmi_apis::Common_Result::CHAR_LIMIT_EXCEEDED: {
+ return result_codes::kCharLimitExceeded;
+ }
+ case hmi_apis::Common_Result::INVALID_ID: {
+ return result_codes::kInvalidId;
+ }
+ case hmi_apis::Common_Result::DUPLICATE_NAME: {
+ return result_codes::kDuplicateName;
+ }
+ case hmi_apis::Common_Result::APPLICATION_NOT_REGISTERED: {
+ return result_codes::kApplicationNotRegistered;
+ }
+ case hmi_apis::Common_Result::WRONG_LANGUAGE: {
+ return result_codes::kWrongLanguage;
+ }
+ case hmi_apis::Common_Result::OUT_OF_MEMORY: {
+ return result_codes::kOutOfMemory;
+ }
+ case hmi_apis::Common_Result::TOO_MANY_PENDING_REQUESTS: {
+ return result_codes::kTooManyPendingRequests;
+ }
+ case hmi_apis::Common_Result::NO_APPS_REGISTERED: {
+ return result_codes::kApplicationNotRegistered;
+ }
+ case hmi_apis::Common_Result::NO_DEVICES_CONNECTED: {
+ return result_codes::kApplicationNotRegistered;
+ }
+ case hmi_apis::Common_Result::WARNINGS: {
+ return result_codes::kWarnings;
+ }
+ case hmi_apis::Common_Result::GENERIC_ERROR: {
+ return result_codes::kGenericError;
+ }
+ case hmi_apis::Common_Result::USER_DISALLOWED: {
+ return result_codes::kUserDisallowed;
+ }
+ case hmi_apis::Common_Result::READ_ONLY: {
+ return result_codes::kReadOnly;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_, "Unknown HMI result code " << hmi_code);
+ return result_codes::kGenericError;
+ }
+ }
+}
+
+RCAppExtensionPtr BaseCommandRequest::GetAppExtension(
+ application_manager::ApplicationSharedPtr app) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (!app) {
+ return NULL;
+ }
+
+ functional_modules::ModuleID id = rc_module_.GetModuleID();
+
+ RCAppExtensionPtr rc_app_extension;
+ application_manager::AppExtensionPtr app_extension = app->QueryInterface(id);
+ if (!app_extension) {
+ LOG4CXX_DEBUG(logger_, "New app extension will be created");
+ app_extension = new RCAppExtension(id);
+ app->AddExtension(app_extension);
+ }
+
+ rc_app_extension =
+ application_manager::AppExtensionPtr::static_pointer_cast<RCAppExtension>(
+ app_extension);
+
+ return rc_app_extension;
+}
+
+bool BaseCommandRequest::ParseResultCode(const Json::Value& value,
+ std::string& result_code,
+ std::string& info) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ result_code = result_codes::kInvalidData;
+ info = "";
+
+ if (IsMember(value, json_keys::kResult) &&
+ IsMember(value[json_keys::kResult], json_keys::kCode)) {
+ result_code =
+ GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
+ value[json_keys::kResult][json_keys::kCode].asInt()));
+ } else if (IsMember(value, json_keys::kError) &&
+ IsMember(value[json_keys::kError], json_keys::kCode)) {
+ result_code =
+ GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
+ value[json_keys::kError][json_keys::kCode].asInt()));
+
+ if (IsMember(value[json_keys::kError], json_keys::kMessage)) {
+ info = value[json_keys::kError][json_keys::kMessage].asCString();
+ }
+ }
+
+ if ((result_codes::kSuccess == result_code) ||
+ (result_codes::kWarnings == result_code)) {
+ return true;
+ }
+
+ return false;
+}
+
+void BaseCommandRequest::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (!Validate()) {
+ LOG4CXX_WARN(logger_, "Request message validation failed !");
+ SendResponse(
+ false, result_codes::kInvalidData, "Validation by schema failed");
+ return;
+ }
+ LOG4CXX_TRACE(logger_, "Request message validated successfully!");
+ using application_manager::HmiInterfaces;
+ if (!service_->IsInterfaceAvailable(HmiInterfaces::HMI_INTERFACE_RC)) {
+ LOG4CXX_WARN(logger_, "HMI interface RC is not available");
+ SendResponse(false,
+ result_codes::kUnsupportedResource,
+ "Remote control is not supported by system");
+ return;
+ }
+ LOG4CXX_TRACE(logger_, "RC interface is available!");
+ if (CheckPolicyPermissions() && CheckDriverConsent()) {
+ if (AcquireResources()) {
+ Execute(); // run child's logic
+ }
+ // If resource is not aqcuired, AcquireResources method will either
+ // send response to mobile or
+ // send additional request to HMI to ask driver consent
+ }
+}
+
+bool BaseCommandRequest::CheckPolicyPermissions() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (!app_) {
+ LOG4CXX_ERROR(logger_, "Application doesn't registered!");
+ SendResponse(false, result_codes::kApplicationNotRegistered, "");
+ return false;
+ }
+
+ if (!service_->IsRemoteControlApplication(app_)) {
+ LOG4CXX_WARN(logger_, "Application has no remote control functions");
+ SendResponse(false, result_codes::kDisallowed, "");
+ return false;
+ }
+
+ mobile_apis::Result::eType ret = service_->CheckPolicyPermissions(message_);
+ if (ret != mobile_apis::Result::eType::SUCCESS) {
+ LOG4CXX_WARN(logger_,
+ "Function \"" << message_->function_name() << "\" (#"
+ << message_->function_id()
+ << ") not allowed by policy");
+
+ SendResponse(false, result_codes::kDisallowed, "");
+ return false;
+ }
+
+ return true;
+}
+
+application_manager::TypeAccess BaseCommandRequest::CheckModule(
+ const Json::Value& message) {
+ const std::string& module = ModuleType(message);
+ return service_->CheckModule(app_->app_id(), module)
+ ? application_manager::TypeAccess::kAllowed
+ : application_manager::TypeAccess::kDisallowed;
+}
+
+bool BaseCommandRequest::CheckDriverConsent() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ RCAppExtensionPtr extension = GetAppExtension(app_);
+ if (!extension) {
+ return false;
+ }
+ Json::Value value;
+ Json::Reader reader;
+ LOG4CXX_DEBUG(logger_, "Request: " << message_->json_message());
+ reader.parse(message_->json_message(), value);
+
+ application_manager::TypeAccess access = CheckModule(value);
+
+ if (IsAutoAllowed(access)) {
+ set_auto_allowed(true);
+ return true;
+ } else {
+ SendDisallowed(access);
+ }
+ return false;
+}
+
+bool BaseCommandRequest::AcquireResources() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ const Json::Value message_params =
+ MessageHelper::StringToValue(message_->json_message());
+
+ if (!IsResourceFree(ModuleType(message_params))) {
+ LOG4CXX_WARN(logger_, "Resource is busy.");
+ SendResponse(false, result_codes::kInUse, "");
+ return false;
+ }
+
+ AcquireResult::eType acquire_result = AcquireResource(message_params);
+ switch (acquire_result) {
+ case AcquireResult::ALLOWED: {
+ SetResourceState(msg_json_, ResourceState::BUSY);
+ return true;
+ }
+ case AcquireResult::IN_USE: {
+ SendResponse(false, result_codes::kInUse, "");
+ return false;
+ }
+ case AcquireResult::ASK_DRIVER: {
+ SetResourceState(msg_json_, ResourceState::BUSY);
+
+ Json::Value value;
+ Json::Reader reader;
+ LOG4CXX_DEBUG(logger_, "Request: " << message_->json_message());
+ reader.parse(message_->json_message(), value);
+
+ SendGetUserConsent(value);
+
+ return false;
+ }
+ case AcquireResult::REJECTED: {
+ SendResponse(false, result_codes::kRejected, "");
+ return false;
+ }
+ }
+
+ return false;
+}
+
+bool BaseCommandRequest::IsAutoAllowed(
+ application_manager::TypeAccess access) const {
+ return access == application_manager::kAllowed;
+}
+
+void BaseCommandRequest::SendDisallowed(
+ application_manager::TypeAccess access) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ std::string info;
+ switch (access) {
+ case application_manager::kAllowed:
+ return;
+ case application_manager::kDisallowed:
+ info = disallowed_info_.empty()
+ ? "The RPC is disallowed by vehicle settings"
+ : disallowed_info_;
+ break;
+ default:
+ info = "Unknown issue";
+ }
+ LOG4CXX_ERROR(logger_, info);
+ SendResponse(false, result_codes::kDisallowed, info);
+}
+
+void BaseCommandRequest::SendGetUserConsent(const Json::Value& value) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ DCHECK(app_);
+ Json::Value params;
+ params[json_keys::kAppId] = app_->hmi_app_id();
+ params[message_params::kModuleType] = ModuleType(value);
+ SendRequest(functional_modules::hmi_api::get_user_consent, params);
+}
+
+std::string BaseCommandRequest::ModuleType(const Json::Value& message) {
+ return "";
+}
+
+std::vector<std::string> BaseCommandRequest::ControlData(
+ const Json::Value& message) {
+ return std::vector<std::string>();
+}
+
+void BaseCommandRequest::on_event(
+ const rc_event_engine::Event<application_manager::MessagePtr, std::string>&
+ event) {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ SetResourceState(msg_json_, ResourceState::FREE);
+
+ if (event.id() == functional_modules::hmi_api::get_user_consent) {
+ ProcessAccessResponse(event);
+ } else {
+ OnEvent(event); // run child's logic
+ }
+}
+
+void BaseCommandRequest::ProcessAccessResponse(
+ const rc_event_engine::Event<application_manager::MessagePtr, std::string>&
+ event) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (!app_) {
+ LOG4CXX_ERROR(logger_, "Application doesn't registered!");
+ SendResponse(false, result_codes::kApplicationNotRegistered, "");
+ return;
+ }
+
+ application_manager::Message& hmi_response = *(event.event_message());
+ const application_manager::MessageValidationResult validate_result =
+ service_->ValidateMessageBySchema(hmi_response);
+ LOG4CXX_DEBUG(logger_,
+ "HMI response validation result is " << validate_result);
+
+ if (validate_result !=
+ application_manager::MessageValidationResult::SUCCESS) {
+ SendResponse(
+ false, result_codes::kGenericError, "HMI has sent invalid parameters");
+ return;
+ }
+
+ Json::Value value;
+ Json::Reader reader;
+ reader.parse(event.event_message()->json_message(), value);
+
+ std::string result_code;
+ std::string info;
+ const bool is_succeeded = ParseResultCode(value, result_code, info);
+
+ bool is_allowed = false;
+ if (is_succeeded) {
+ if (IsMember(value[json_keys::kResult], message_params::kAllowed) &&
+ value[json_keys::kResult][message_params::kAllowed].isBool()) {
+ is_allowed = value[json_keys::kResult][message_params::kAllowed].asBool();
+ }
+
+ const std::string module = ModuleType(msg_json_);
+
+ // Check the actual User's answer.
+ LOG4CXX_DEBUG(logger_,
+ "Setting allowed access for " << app_->app_id() << " for "
+ << module);
+ if (is_allowed) {
+ rc_module_.resource_allocation_manager().ForceAcquireResource(
+ module, app_->app_id());
+
+ Execute(); // run child's logic
+ } else {
+ rc_module_.resource_allocation_manager().OnDriverDisallowed(
+ module, app_->app_id());
+
+ SendResponse(
+ false,
+ result_codes::kRejected,
+ "The resource is in use and the driver disallows this remote "
+ "control RPC");
+ }
+ } else {
+ SendResponse(false, result_code.c_str(), info);
+ }
+}
+
+} // namespace commands
+} // namespace remote_control
diff --git a/src/components/remote_control/src/commands/button_press_request.cc b/src/components/remote_control/src/commands/button_press_request.cc
new file mode 100644
index 0000000000..1e5eef1e64
--- /dev/null
+++ b/src/components/remote_control/src/commands/button_press_request.cc
@@ -0,0 +1,264 @@
+/*
+ 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.
+ */
+
+#include "remote_control/commands/button_press_request.h"
+#include "remote_control/message_helper.h"
+#include "remote_control/rc_module_constants.h"
+#include "functional_module/function_ids.h"
+#include "json/json.h"
+#include "utils/helpers.h"
+#include "interfaces/MOBILE_API.h"
+
+namespace remote_control {
+
+namespace commands {
+
+using namespace json_keys;
+using namespace message_params;
+
+typedef std::map<std::string, mobile_apis::ButtonName::eType> ButtonsMap;
+
+CREATE_LOGGERPTR_GLOBAL(logger_, "ButtonPressRequest")
+
+ButtonPressRequest::ButtonPressRequest(
+ const application_manager::MessagePtr& message,
+ RemotePluginInterface& rc_module)
+ : BaseCommandRequest(message, rc_module) {}
+
+ButtonPressRequest::~ButtonPressRequest() {}
+
+const std::vector<std::string> buttons_climate() {
+ std::vector<std::string> data;
+ data.push_back(enums_value::kACMax);
+ data.push_back(enums_value::kAC);
+ data.push_back(enums_value::kRecirculate);
+ data.push_back(enums_value::kFanUp);
+ data.push_back(enums_value::kFanDown);
+ data.push_back(enums_value::kTempUp);
+ data.push_back(enums_value::kTempDown);
+ data.push_back(enums_value::kDefrostMax);
+ data.push_back(enums_value::kDefrost);
+ data.push_back(enums_value::kDefrostRear);
+ data.push_back(enums_value::kUpperVent);
+ data.push_back(enums_value::kLowerVent);
+ return data;
+}
+
+const std::vector<std::string> buttons_radio() {
+ std::vector<std::string> data;
+ data.push_back(enums_value::kVolumeUp);
+ data.push_back(enums_value::kVolumeDown);
+ data.push_back(enums_value::kEject);
+ data.push_back(enums_value::kSource);
+ data.push_back(enums_value::kShuffle);
+ data.push_back(enums_value::kRepeat);
+ return data;
+}
+
+const ButtonsMap buttons_map() {
+ using namespace mobile_apis;
+
+ ButtonsMap buttons_map;
+ buttons_map[enums_value::kACMax] = ButtonName::AC_MAX;
+ buttons_map[enums_value::kAC] = ButtonName::AC;
+ buttons_map[enums_value::kRecirculate] = ButtonName::RECIRCULATE;
+ buttons_map[enums_value::kFanUp] = ButtonName::FAN_UP;
+ buttons_map[enums_value::kFanDown] = ButtonName::FAN_DOWN;
+ buttons_map[enums_value::kTempUp] = ButtonName::TEMP_UP;
+ buttons_map[enums_value::kTempDown] = ButtonName::TEMP_DOWN;
+ buttons_map[enums_value::kDefrostMax] = ButtonName::DEFROST_MAX;
+ buttons_map[enums_value::kDefrost] = ButtonName::DEFROST;
+ buttons_map[enums_value::kDefrostRear] = ButtonName::DEFROST_REAR;
+ buttons_map[enums_value::kUpperVent] = ButtonName::UPPER_VENT;
+ buttons_map[enums_value::kLowerVent] = ButtonName::LOWER_VENT;
+ buttons_map[enums_value::kVolumeUp] = ButtonName::VOLUME_UP;
+ buttons_map[enums_value::kVolumeDown] = ButtonName::VOLUME_DOWN;
+ buttons_map[enums_value::kEject] = ButtonName::EJECT;
+ buttons_map[enums_value::kSource] = ButtonName::SOURCE;
+ buttons_map[enums_value::kShuffle] = ButtonName::SHUFFLE;
+ buttons_map[enums_value::kRepeat] = ButtonName::REPEAT;
+
+ return buttons_map;
+}
+
+bool CheckIfButtonExistInRCCaps(
+ const smart_objects::SmartObject& rc_capabilities,
+ const mobile_apis::ButtonName::eType button) {
+ if (rc_capabilities.keyExists(strings::kbuttonCapabilities)) {
+ const smart_objects::SmartObject& button_caps =
+ rc_capabilities[strings::kbuttonCapabilities];
+ smart_objects::SmartArray::iterator it = button_caps.asArray()->begin();
+ for (; it != button_caps.asArray()->end(); ++it) {
+ smart_objects::SmartObject& so = *it;
+ int64_t current_id = so[message_params::kName].asInt();
+ if (-1 == current_id) {
+ // capabilities received from HMI contains enum values
+ // capabilities loaded from file contains string values
+ // TODO : unificate capabilities storing
+ const std::string& bt_name = so[message_params::kName].asString();
+ static ButtonsMap btn_map = buttons_map();
+ current_id = btn_map[bt_name];
+ }
+ const mobile_apis::ButtonName::eType current_button =
+ static_cast<mobile_apis::ButtonName::eType>(current_id);
+ if (current_button == button) {
+ LOG4CXX_TRACE(logger_,
+ "Button id " << current_button
+ << " exist in capabilities");
+ return true;
+ }
+ }
+ }
+ LOG4CXX_TRACE(logger_,
+ "Button id " << button << " do not exist in capabilities");
+ return false;
+}
+
+bool CheckButtonName(const std::string& module_type,
+ const std::string& button_name,
+ const smart_objects::SmartObject* rc_capabilities) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (rc_capabilities == NULL) {
+ LOG4CXX_ERROR(logger_, "No remote controll capabilities available");
+ return false;
+ }
+
+ if (enums_value::kRadio == module_type) {
+ if (!helpers::in_range(buttons_radio(), button_name)) {
+ LOG4CXX_WARN(logger_,
+ "Trying to acceess climate button with module type radio");
+ return false;
+ }
+ }
+
+ if (enums_value::kClimate == module_type) {
+ if (!helpers::in_range(buttons_climate(), button_name)) {
+ LOG4CXX_WARN(logger_,
+ "Trying to acceess radio button with module type climate");
+ return false;
+ }
+ }
+ return true;
+}
+
+void ButtonPressRequest::Execute() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ const Json::Value request_params =
+ MessageHelper::StringToValue(message_->json_message());
+
+ const std::string button_name = request_params[kButtonName].asString();
+ const std::string module_type = request_params[kModuleType].asString();
+
+ static ButtonsMap btn_map = buttons_map();
+ mobile_apis::ButtonName::eType button_id =
+ mobile_apis::ButtonName::INVALID_ENUM;
+ if (btn_map.end() != btn_map.find(button_name)) {
+ button_id = btn_map[button_name];
+ }
+
+ const smart_objects::SmartObject* rc_capabilities =
+ service()->GetRCCapabilities();
+ const bool button_name_matches_module_type =
+ CheckButtonName(module_type, button_name, rc_capabilities);
+ const bool button_id_exist_in_caps =
+ rc_capabilities &&
+ CheckIfButtonExistInRCCaps(*rc_capabilities, button_id);
+
+ if (button_name_matches_module_type && button_id_exist_in_caps) {
+ SendRequest(functional_modules::hmi_api::button_press, request_params);
+ } else if (!button_name_matches_module_type) {
+ LOG4CXX_WARN(logger_, "Request module type and button name mismatch!");
+ SendResponse(false,
+ result_codes::kInvalidData,
+ "Request module type and button name mismatch!");
+ } else {
+ LOG4CXX_WARN(logger_, "Requested button is not exists in capabilities!");
+ SendResponse(false,
+ result_codes::kUnsupportedResource,
+ "Requested button is not exists in capabilities!");
+ }
+}
+
+AcquireResult::eType ButtonPressRequest::AcquireResource(
+ const Json::Value& message) {
+ ResourceAllocationManager& allocation_manager =
+ rc_module_.resource_allocation_manager();
+ const std::string& module_type = ModuleType(message);
+ const uint32_t app_id = app()->app_id();
+ return allocation_manager.AcquireResource(module_type, app_id);
+}
+
+bool ButtonPressRequest::IsResourceFree(const std::string& module_type) const {
+ return rc_module_.resource_allocation_manager().IsResourceFree(module_type);
+}
+
+void ButtonPressRequest::SetResourceState(const Json::Value& message,
+ const ResourceState::eType state) {
+ const std::string& module_type = ModuleType(message);
+ const uint32_t app_id = app()->app_id();
+
+ ResourceAllocationManager& allocation_manager =
+ rc_module_.resource_allocation_manager();
+ allocation_manager.SetResourceState(module_type, app_id, state);
+}
+
+void ButtonPressRequest::OnEvent(
+ const rc_event_engine::Event<application_manager::MessagePtr, std::string>&
+ event) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ DCHECK_OR_RETURN_VOID(
+ (functional_modules::hmi_api::button_press == event.id()));
+
+ application_manager::Message& hmi_response = *(event.event_message());
+ const Json::Value value =
+ MessageHelper::StringToValue(hmi_response.json_message());
+
+ std::string result_code;
+ std::string info;
+
+ bool is_response_successful = ParseResultCode(value, result_code, info);
+
+ if (remote_control::result_codes::kReadOnly == result_code) {
+ is_response_successful = false;
+ result_code = result_codes::kGenericError;
+ }
+ SendResponse(is_response_successful, result_code.c_str(), info);
+}
+
+std::string ButtonPressRequest::ModuleType(const Json::Value& message) {
+ return message.get(message_params::kModuleType, Json::Value("")).asString();
+}
+
+} // namespace commands
+
+} // namespace remote_control
diff --git a/src/components/remote_control/src/commands/get_interior_vehicle_data_request.cc b/src/components/remote_control/src/commands/get_interior_vehicle_data_request.cc
new file mode 100644
index 0000000000..6a7e746aa5
--- /dev/null
+++ b/src/components/remote_control/src/commands/get_interior_vehicle_data_request.cc
@@ -0,0 +1,224 @@
+/*
+ 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.
+ */
+
+#include <map>
+
+#include "remote_control/commands/get_interior_vehicle_data_request.h"
+#include "remote_control/rc_module_constants.h"
+#include "remote_control/message_helper.h"
+#include "remote_control/remote_control_plugin.h"
+#include "functional_module/function_ids.h"
+#include "json/json.h"
+
+namespace remote_control {
+
+namespace commands {
+
+using namespace enums_value;
+using namespace json_keys;
+using namespace message_params;
+
+CREATE_LOGGERPTR_GLOBAL(logger_, "GetInteriorVehicleDataRequest")
+
+GetInteriorVehicleDataRequest::GetInteriorVehicleDataRequest(
+ const application_manager::MessagePtr& message,
+ RemotePluginInterface& rc_module)
+ : BaseCommandRequest(message, rc_module) {}
+
+bool CheckIfModuleTypeExistInCapabilities(
+ const smart_objects::SmartObject& rc_capabilities,
+ const std::string& module_type) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (enums_value::kRadio == module_type &&
+ !rc_capabilities.keyExists(strings::kradioControlCapabilities)) {
+ LOG4CXX_DEBUG(logger_, " Radio control capabilities not present");
+ return false;
+ }
+ if (enums_value::kClimate == module_type &&
+ !rc_capabilities.keyExists(strings::kclimateControlCapabilities)) {
+ LOG4CXX_DEBUG(logger_, " Climate control capabilities not present");
+ return false;
+ }
+
+ return true;
+}
+
+void GetInteriorVehicleDataRequest::Execute() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ Json::Value request_params =
+ MessageHelper::StringToValue(message_->json_message());
+
+ const smart_objects::SmartObject* capabilities =
+ service()->GetRCCapabilities();
+ if (capabilities &&
+ !CheckIfModuleTypeExistInCapabilities(*capabilities,
+ ModuleType(request_params))) {
+ LOG4CXX_WARN(logger_, "Accessing not supported module data");
+ SendResponse(false,
+ result_codes::kUnsupportedResource,
+ "Accessing not supported module data");
+ return;
+ }
+ if (HasRequestExcessiveSubscription(request_params)) {
+ RemoveExcessiveSubscription(request_params);
+ }
+
+ SendRequest(functional_modules::hmi_api::get_interior_vehicle_data,
+ request_params);
+}
+
+void GetInteriorVehicleDataRequest::OnEvent(
+ const rc_event_engine::Event<application_manager::MessagePtr, std::string>&
+ event) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ DCHECK_OR_RETURN_VOID(
+ (functional_modules::hmi_api::get_interior_vehicle_data == event.id()));
+
+ application_manager::Message& hmi_response = *(event.event_message());
+ const bool validate_result =
+ application_manager::MessageValidationResult::SUCCESS ==
+ service()->ValidateMessageBySchema(hmi_response);
+ LOG4CXX_DEBUG(logger_,
+ "HMI response validation result is " << validate_result);
+ const Json::Value value =
+ MessageHelper::StringToValue(hmi_response.json_message());
+ std::string result_code;
+ std::string info;
+ bool success = validate_result && ParseResultCode(value, result_code, info);
+
+ if (!validate_result ||
+ remote_control::result_codes::kReadOnly == result_code) {
+ success = false;
+ result_code = result_codes::kGenericError;
+ }
+
+ if (success) {
+ ProccessSubscription(value);
+ response_params_[kModuleData] =
+ value[json_keys::kResult][message_params::kModuleData];
+ }
+ SendResponse(success, result_code.c_str(), info);
+}
+
+void GetInteriorVehicleDataRequest::ProccessSubscription(
+ const Json::Value& hmi_response) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ Json::Value request_params;
+ Json::Reader reader;
+ reader.parse(message_->json_message(), request_params);
+
+ const bool is_subscribe_present_in_request =
+ IsMember(request_params, kSubscribe);
+ const bool isSubscribed_present_in_response =
+ IsMember(hmi_response[json_keys::kResult], message_params::kIsSubscribed);
+
+ if (!is_subscribe_present_in_request && !isSubscribed_present_in_response) {
+ return;
+ }
+
+ RCAppExtensionPtr extension = GetAppExtension(app());
+ if (is_subscribe_present_in_request && !isSubscribed_present_in_response) {
+ LOG4CXX_WARN(logger_,
+ "conditional mandatory parameter "
+ << kIsSubscribed << " missed in hmi response");
+ response_params_[kIsSubscribed] =
+ extension->IsSubscibedToInteriorVehicleData(
+ request_params[kModuleType]);
+ return;
+ }
+
+ if (!is_subscribe_present_in_request && isSubscribed_present_in_response) {
+ LOG4CXX_WARN(logger_,
+ "Parameter " << message_params::kIsSubscribed
+ << " is ignored due to absence '"
+ << message_params::kSubscribe
+ << "' parameter in request");
+ return;
+ }
+
+ const bool request_subscribe = request_params[kSubscribe].asBool();
+ const bool response_subscribe =
+ hmi_response[json_keys::kResult][message_params::kIsSubscribed].asBool();
+ response_params_[message_params::kIsSubscribed] = response_subscribe;
+ LOG4CXX_TRACE(logger_, "request_subscribe = " << request_subscribe);
+ LOG4CXX_TRACE(logger_, "response_subscribe = " << response_subscribe);
+ if (request_subscribe == response_subscribe) {
+ if (response_subscribe) {
+ LOG4CXX_DEBUG(logger_,
+ "SubscribeToInteriorVehicleData "
+ << app()->app_id() << " "
+ << request_params[kModuleType].asString());
+ extension->SubscribeToInteriorVehicleData(request_params[kModuleType]);
+ } else {
+ LOG4CXX_DEBUG(logger_,
+ "UnsubscribeFromInteriorVehicleData "
+ << app()->app_id() << " "
+ << request_params[kModuleType].asString());
+ extension->UnsubscribeFromInteriorVehicleData(
+ request_params[kModuleType]);
+ }
+ }
+}
+
+bool GetInteriorVehicleDataRequest::HasRequestExcessiveSubscription(
+ const Json::Value& request_params) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ const bool is_subscribe_present_in_request =
+ IsMember(request_params, kSubscribe);
+ if (is_subscribe_present_in_request) {
+ RCAppExtensionPtr extension = GetAppExtension(app());
+ const bool is_app_already_subscribed =
+ extension->IsSubscibedToInteriorVehicleData(
+ request_params[kModuleType]);
+ const bool app_wants_to_subscribe = request_params[kSubscribe].asBool();
+ if (!app_wants_to_subscribe && !is_app_already_subscribed) {
+ return true;
+ }
+ return app_wants_to_subscribe && is_app_already_subscribed;
+ }
+ return false;
+}
+
+void GetInteriorVehicleDataRequest::RemoveExcessiveSubscription(
+ Json::Value& request_params) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ request_params.removeMember(kSubscribe);
+}
+
+std::string GetInteriorVehicleDataRequest::ModuleType(
+ const Json::Value& message) {
+ return message.get(message_params::kModuleType, "").asString();
+}
+
+} // namespace commands
+
+} // namespace remote_control
diff --git a/src/components/remote_control/src/commands/on_interior_vehicle_data_notification.cc b/src/components/remote_control/src/commands/on_interior_vehicle_data_notification.cc
new file mode 100644
index 0000000000..fccd8392c7
--- /dev/null
+++ b/src/components/remote_control/src/commands/on_interior_vehicle_data_notification.cc
@@ -0,0 +1,103 @@
+/*
+ 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.
+ */
+
+#include "remote_control/commands/on_interior_vehicle_data_notification.h"
+#include <algorithm>
+#include <vector>
+#include "json/json.h"
+#include "utils/make_shared.h"
+#include "remote_control/rc_module_constants.h"
+#include "remote_control/message_helper.h"
+#include "remote_control/remote_control_plugin.h"
+#include "remote_control/rc_app_extension.h"
+
+namespace remote_control {
+
+namespace commands {
+
+CREATE_LOGGERPTR_GLOBAL(logger_, "OnInteriorVehicleDataNotification")
+
+OnInteriorVehicleDataNotification::OnInteriorVehicleDataNotification(
+ const application_manager::MessagePtr& message,
+ RemotePluginInterface& rc_module)
+ : BaseCommandNotification(message, rc_module) {}
+
+OnInteriorVehicleDataNotification::~OnInteriorVehicleDataNotification() {}
+
+void OnInteriorVehicleDataNotification::Execute() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ Json::Value json;
+
+ application_manager::MessagePtr msg = message();
+
+ json = MessageHelper::StringToValue(msg->json_message());
+
+ Json::Value module_type = ModuleType(json);
+
+ typedef std::vector<application_manager::ApplicationSharedPtr> AppPtrs;
+ AppPtrs apps = service_->GetApplications(rc_module_.GetModuleID());
+
+ for (AppPtrs::iterator it = apps.begin(); it != apps.end(); ++it) {
+ DCHECK(*it);
+ application_manager::Application& app = **it;
+
+ RCAppExtensionPtr extension =
+ application_manager::AppExtensionPtr::static_pointer_cast<
+ RCAppExtension>(app.QueryInterface(rc_module_.GetModuleID()));
+ DCHECK(extension);
+ LOG4CXX_TRACE(logger_, "Check subscription for " << app.app_id());
+ if (extension->IsSubscibedToInteriorVehicleData(module_type)) {
+ application_manager::MessagePtr message =
+ utils::MakeShared<application_manager::Message>(*msg);
+ message->set_message_type(
+ application_manager::MessageType::kNotification);
+ message->set_protocol_version(app.protocol_version());
+ message->set_function_id(functional_modules::ON_INTERIOR_VEHICLE_DATA);
+ message->set_function_name(MessageHelper::GetMobileAPIName(
+ functional_modules::ON_INTERIOR_VEHICLE_DATA));
+ message->set_connection_key(app.app_id());
+ NotifyOneApplication(message);
+ }
+ }
+}
+
+std::string OnInteriorVehicleDataNotification::ModuleType(
+ const Json::Value& message) {
+ const Json::Value& module_data =
+ message.get(message_params::kModuleData, Json::Value(Json::objectValue));
+ return module_data.get(message_params::kModuleType, "").asString();
+}
+
+} // namespace commands
+
+} // namespace remote_control
diff --git a/src/components/remote_control/src/commands/on_remote_control_settings_notification.cc b/src/components/remote_control/src/commands/on_remote_control_settings_notification.cc
new file mode 100644
index 0000000000..f18180aa21
--- /dev/null
+++ b/src/components/remote_control/src/commands/on_remote_control_settings_notification.cc
@@ -0,0 +1,122 @@
+/*
+ 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.
+ */
+
+#include "remote_control/commands/on_remote_control_settings_notification.h"
+#include <algorithm>
+#include <vector>
+#include "json/json.h"
+#include "remote_control/rc_module_constants.h"
+#include "remote_control/message_helper.h"
+#include "remote_control/remote_control_plugin.h"
+#include "remote_control/rc_app_extension.h"
+#include "functional_module/function_ids.h"
+
+namespace remote_control {
+
+namespace commands {
+
+CREATE_LOGGERPTR_GLOBAL(logger_, "OnRemoteControlSettingsNotification");
+
+OnRemoteControlSettingsNotification::OnRemoteControlSettingsNotification(
+ const application_manager::MessagePtr& message,
+ RemotePluginInterface& rc_module)
+ : BaseCommandNotification(message, rc_module) {}
+
+void UnsubscribeFromInteriorVehicleDataForAllModules(
+ RCAppExtensionPtr extension) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ const Json::Value climate(enums_value::kClimate);
+ extension->UnsubscribeFromInteriorVehicleData(climate);
+ const Json::Value radio(enums_value::kRadio);
+ extension->UnsubscribeFromInteriorVehicleData(radio);
+}
+
+void OnRemoteControlSettingsNotification::DisallowRCFunctionality() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ typedef std::vector<application_manager::ApplicationSharedPtr> Apps;
+ Apps apps = service_->GetApplications(rc_module_.GetModuleID());
+ for (Apps::iterator it = apps.begin(); it != apps.end(); ++it) {
+ application_manager::ApplicationSharedPtr app = *it;
+ DCHECK(app);
+ service_->ChangeNotifyHMILevel(app, mobile_apis::HMILevel::eType::HMI_NONE);
+
+ const RCAppExtensionPtr extension =
+ application_manager::AppExtensionPtr::static_pointer_cast<
+ RCAppExtension>(app->QueryInterface(rc_module_.GetModuleID()));
+ if (extension) {
+ UnsubscribeFromInteriorVehicleDataForAllModules(extension);
+ }
+ }
+}
+
+void OnRemoteControlSettingsNotification::Execute() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ const Json::Value value =
+ MessageHelper::StringToValue(message()->json_message());
+
+ if (!value.isMember(message_params::kAllowed)) {
+ LOG4CXX_DEBUG(logger_,
+ "Notification is ignored due to \"allow\" parameter absense");
+ LOG4CXX_DEBUG(logger_, "RC Functionality remains unchanged");
+ return;
+ }
+ ResourceAllocationManager& allocation_manager =
+ rc_module_.resource_allocation_manager();
+ const bool is_allowed = value[message_params::kAllowed].asBool();
+ if (is_allowed) {
+ hmi_apis::Common_RCAccessMode::eType access_mode =
+ hmi_apis::Common_RCAccessMode::INVALID_ENUM;
+ LOG4CXX_DEBUG(logger_, "Allowing RC Functionality");
+ if (value.isMember(message_params::kAccessMode)) {
+ const std::string access_mode_str =
+ value.get(message_params::kAccessMode, enums_value::kAutoAllow)
+ .asString();
+
+ access_mode = MessageHelper::AccessModeFromString(access_mode_str);
+ LOG4CXX_DEBUG(logger_, "Setting up access mode : " << access_mode_str);
+ } else {
+ access_mode = allocation_manager.GetAccessMode();
+ LOG4CXX_DEBUG(logger_,
+ "No access mode received. Using last known: "
+ << MessageHelper::AccessModeToString(access_mode));
+ }
+ allocation_manager.SetAccessMode(access_mode);
+ } else {
+ LOG4CXX_DEBUG(logger_, "Disallowing RC Functionality");
+ DisallowRCFunctionality();
+ allocation_manager.ResetAllAllocations();
+ }
+}
+
+} // namespace commands
+
+} // namespace remote_control
diff --git a/src/components/remote_control/src/commands/set_interior_vehicle_data_request.cc b/src/components/remote_control/src/commands/set_interior_vehicle_data_request.cc
new file mode 100644
index 0000000000..70fbd9280e
--- /dev/null
+++ b/src/components/remote_control/src/commands/set_interior_vehicle_data_request.cc
@@ -0,0 +1,350 @@
+/*
+ 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.
+ */
+
+#include "remote_control/commands/set_interior_vehicle_data_request.h"
+#include <algorithm>
+#include "remote_control/rc_module_constants.h"
+#include "remote_control/message_helper.h"
+#include "functional_module/function_ids.h"
+#include "json/json.h"
+#include "utils/helpers.h"
+
+namespace remote_control {
+
+namespace commands {
+
+using namespace json_keys;
+using namespace message_params;
+
+namespace {
+std::vector<std::string> GetModuleReadOnlyParams(
+ const std::string& module_type) {
+ std::vector<std::string> module_ro_params;
+ if (enums_value::kClimate == module_type) {
+ module_ro_params.push_back(kCurrentTemperature);
+ } else if (enums_value::kRadio == module_type) {
+ module_ro_params.push_back(kRdsData);
+ module_ro_params.push_back(kAvailableHDs);
+ module_ro_params.push_back(kSignalStrength);
+ module_ro_params.push_back(kSignalChangeThreshold);
+ module_ro_params.push_back(kState);
+ }
+ return module_ro_params;
+}
+
+const std::map<std::string, std::string> GetModuleDataToCapabilitiesMapping() {
+ std::map<std::string, std::string> mapping;
+ // climate
+ mapping["fanSpeed"] = "fanSpeedAvailable";
+ mapping["currentTemperature"] = "currentTemperatureAvailable";
+ mapping["desiredTemperature"] = "desiredTemperatureAvailable";
+ mapping["acEnable"] = "acEnableAvailable";
+ mapping["circulateAirEnable"] = "circulateAirEnableAvailable";
+ mapping["autoModeEnable"] = "autoModeEnableAvailable";
+ mapping["defrostZone"] = "defrostZoneAvailable";
+ mapping["dualModeEnable"] = "dualModeEnableAvailable";
+ mapping["acMaxEnable"] = "acMaxEnableAvailable";
+ mapping["ventilationMode"] = "ventilationModeAvailable";
+
+ // radio
+ mapping["band"] = "radioBandAvailable";
+ mapping["frequencyInteger"] = "radioFrequencyAvailable";
+ mapping["frequencyFraction"] = "radioFrequencyAvailable";
+ mapping["rdsData"] = "rdsDataAvailable";
+ mapping["availableHDs"] = "availableHDsAvailable";
+ mapping["hdChannel"] = "availableHDsAvailable";
+ mapping["signalStrength"] = "signalStrengthAvailable";
+ mapping["signalChangeThreshold"] = "signalChangeThresholdAvailable";
+ mapping["radioEnable"] = "radioEnableAvailable";
+ mapping["state"] = "stateAvailable";
+
+ return mapping;
+}
+} // namespace
+
+CREATE_LOGGERPTR_GLOBAL(logger_, "SetInteriorVehicleDataRequest")
+
+SetInteriorVehicleDataRequest::SetInteriorVehicleDataRequest(
+ const application_manager::MessagePtr& message,
+ RemotePluginInterface& rc_module)
+ : BaseCommandRequest(message, rc_module) {}
+
+SetInteriorVehicleDataRequest::~SetInteriorVehicleDataRequest() {}
+
+bool CheckControlDataByCapabilities(
+ const smart_objects::SmartObject& module_caps,
+ const Json::Value& control_data) {
+ std::map<std::string, std::string> mapping =
+ GetModuleDataToCapabilitiesMapping();
+ Json::Value::Members control_data_keys = control_data.getMemberNames();
+
+ Json::Value::Members::const_iterator it = control_data_keys.begin();
+ for (; it != control_data_keys.end(); ++it) {
+ const std::string& request_parameter = *it;
+ const std::string& caps_key = mapping[request_parameter];
+ const smart_objects::SmartObject& capabilities_status = module_caps[0];
+ LOG4CXX_DEBUG(logger_,
+ "Checking request parameter "
+ << request_parameter
+ << " with capabilities. Appropriate key is " << caps_key);
+ if (!capabilities_status.keyExists(caps_key)) {
+ LOG4CXX_DEBUG(logger_,
+ "Capability "
+ << caps_key
+ << " is missed in RemoteControl capabilities");
+ return false;
+ }
+ if (!capabilities_status[caps_key].asBool()) {
+ LOG4CXX_DEBUG(logger_,
+ "Capability "
+ << caps_key
+ << " is switched off in RemoteControl capabilities");
+ return false;
+ }
+ }
+ return true;
+}
+
+bool CheckIfModuleDataExistInCapabilities(
+ const smart_objects::SmartObject& rc_capabilities,
+ const Json::Value& module_data) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ bool is_radio_data_valid = true;
+ bool is_climate_data_valid = true;
+ if (IsMember(module_data, kRadioControlData)) {
+ if (!rc_capabilities.keyExists(strings::kradioControlCapabilities)) {
+ LOG4CXX_DEBUG(logger_, " Radio control capabilities not present");
+ return false;
+ }
+ const smart_objects::SmartObject& radio_caps =
+ rc_capabilities[strings::kradioControlCapabilities];
+ is_radio_data_valid = CheckControlDataByCapabilities(
+ radio_caps, module_data[strings::kRadioControlData]);
+ }
+ if (IsMember(module_data, kClimateControlData)) {
+ if (!rc_capabilities.keyExists(strings::kclimateControlCapabilities)) {
+ LOG4CXX_DEBUG(logger_, " Climate control capabilities not present");
+ return false;
+ }
+ const smart_objects::SmartObject& climate_caps =
+ rc_capabilities[strings::kclimateControlCapabilities];
+ is_climate_data_valid = CheckControlDataByCapabilities(
+ climate_caps, module_data[strings::kClimateControlData]);
+ }
+
+ return is_radio_data_valid && is_climate_data_valid;
+}
+
+void SetInteriorVehicleDataRequest::Execute() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ Json::Value request_params =
+ MessageHelper::StringToValue(message_->json_message());
+ const Json::Value module_data = request_params[kModuleData];
+ const std::string module_type = module_data[kModuleType].asString();
+ bool module_type_and_data_match = true;
+
+ if (enums_value::kRadio == module_type) {
+ module_type_and_data_match = !IsMember(module_data, kClimateControlData);
+ }
+
+ if (enums_value::kClimate == module_type) {
+ module_type_and_data_match = !IsMember(module_data, kRadioControlData);
+ }
+
+ if (module_type_and_data_match) {
+ const smart_objects::SmartObject* capabilities =
+ service()->GetRCCapabilities();
+ if (capabilities &&
+ !CheckIfModuleDataExistInCapabilities(*capabilities, module_data)) {
+ LOG4CXX_WARN(logger_, "Accessing not supported module data");
+ SendResponse(false,
+ result_codes::kUnsupportedResource,
+ "Accessing not supported module data");
+ return;
+ }
+ if (AreAllParamsReadOnly(request_params)) {
+ LOG4CXX_WARN(logger_, "All request params in module type are READ ONLY!");
+ SendResponse(false,
+ result_codes::kReadOnly,
+ "All request params in module type are READ ONLY!");
+ return;
+ }
+ if (AreReadOnlyParamsPresent(request_params)) {
+ LOG4CXX_DEBUG(logger_, "Request module type has READ ONLY parameters");
+ LOG4CXX_DEBUG(logger_, "Cutting-off READ ONLY parameters... ");
+ CutOffReadOnlyParams(request_params);
+ }
+ application_manager::MessagePtr hmi_request = CreateHmiRequest(
+ functional_modules::hmi_api::set_interior_vehicle_data, request_params);
+ service()->RemoveHMIFakeParameters(hmi_request);
+ SendMessageToHMI(hmi_request);
+ } else {
+ LOG4CXX_WARN(logger_, "Request module type & data mismatch!");
+ SendResponse(false,
+ result_codes::kInvalidData,
+ "Request module type & data mismatch!");
+ }
+}
+
+AcquireResult::eType SetInteriorVehicleDataRequest::AcquireResource(
+ const Json::Value& message) {
+ return rc_module_.resource_allocation_manager().AcquireResource(
+ ModuleType(message), app()->app_id());
+}
+
+bool SetInteriorVehicleDataRequest::IsResourceFree(
+ const std::string& module_type) const {
+ return rc_module_.resource_allocation_manager().IsResourceFree(module_type);
+}
+
+void SetInteriorVehicleDataRequest::SetResourceState(
+ const Json::Value& message, const ResourceState::eType state) {
+ const std::string& module_type = ModuleType(message);
+ const uint32_t app_id = app()->app_id();
+
+ ResourceAllocationManager& allocation_manager =
+ rc_module_.resource_allocation_manager();
+
+ allocation_manager.SetResourceState(module_type, app_id, state);
+}
+
+bool SetInteriorVehicleDataRequest::AreReadOnlyParamsPresent(
+ const Json::Value& request_params) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ std::vector<std::string> module_type_params = ControlData(request_params);
+ std::vector<std::string>::iterator it = module_type_params.begin();
+ std::vector<std::string> ro_params =
+ GetModuleReadOnlyParams(ModuleType(request_params));
+ for (; it != module_type_params.end(); ++it) {
+ if (helpers::in_range(ro_params, *it)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+void SetInteriorVehicleDataRequest::CutOffReadOnlyParams(
+ Json::Value& request_params) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ std::vector<std::string> module_type_params = ControlData(request_params);
+ std::vector<std::string>::iterator it = module_type_params.begin();
+ const std::string module_type = ModuleType(request_params);
+ std::vector<std::string> ro_params = GetModuleReadOnlyParams(module_type);
+ for (; it != module_type_params.end(); ++it) {
+ if (helpers::in_range(ro_params, *it)) {
+ if (enums_value::kClimate == module_type) {
+ request_params[message_params::kModuleData]
+ [message_params::kClimateControlData].removeMember(*it);
+ LOG4CXX_DEBUG(logger_, "Cutting-off READ ONLY parameter: " << *it);
+ } else if (enums_value::kRadio == module_type) {
+ request_params[message_params::kModuleData]
+ [message_params::kRadioControlData].removeMember(*it);
+ LOG4CXX_DEBUG(logger_, "Cutting-off READ ONLY parameter: " << *it);
+ }
+ }
+ }
+}
+
+bool SetInteriorVehicleDataRequest::AreAllParamsReadOnly(
+ const Json::Value& request_params) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ std::vector<std::string> module_type_params = ControlData(request_params);
+ std::vector<std::string>::iterator it = module_type_params.begin();
+ std::vector<std::string> ro_params =
+ GetModuleReadOnlyParams(ModuleType(request_params));
+ for (; it != module_type_params.end(); ++it) {
+ if (!helpers::in_range(ro_params, *it)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+void SetInteriorVehicleDataRequest::OnEvent(
+ const rc_event_engine::Event<application_manager::MessagePtr, std::string>&
+ event) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ DCHECK_OR_RETURN_VOID(
+ (functional_modules::hmi_api::set_interior_vehicle_data == event.id()));
+
+ application_manager::Message& hmi_response = *(event.event_message());
+ if (application_manager::MessageValidationResult::SUCCESS !=
+ service()->ValidateMessageBySchema(hmi_response)) {
+ SendResponse(false, result_codes::kGenericError, "");
+ return;
+ }
+
+ LOG4CXX_DEBUG(logger_, "HMI response is valid");
+ const Json::Value value =
+ MessageHelper::StringToValue(hmi_response.json_message());
+
+ std::string result_code;
+ std::string info;
+
+ const bool is_response_successful = ParseResultCode(value, result_code, info);
+
+ if (is_response_successful) {
+ response_params_[message_params::kModuleData] =
+ value[json_keys::kResult][message_params::kModuleData];
+ }
+
+ SendResponse(is_response_successful, result_code.c_str(), info);
+}
+
+std::string SetInteriorVehicleDataRequest::ModuleType(
+ const Json::Value& message) {
+ const Json::Value& module_data =
+ message.get(message_params::kModuleData, Json::Value(Json::objectValue));
+ return module_data.get(message_params::kModuleType, "").asString();
+}
+
+std::vector<std::string> SetInteriorVehicleDataRequest::ControlData(
+ const Json::Value& message) {
+ Json::Value data =
+ message.get(message_params::kModuleData, Json::Value(Json::objectValue));
+ std::string module = ModuleType(message);
+ Json::Value params;
+ if (module == enums_value::kRadio) {
+ params = data.get(message_params::kRadioControlData,
+ Json::Value(Json::objectValue));
+ }
+ if (module == enums_value::kClimate) {
+ params = data.get(message_params::kClimateControlData,
+ Json::Value(Json::objectValue));
+ }
+ return params.getMemberNames();
+}
+
+} // namespace commands
+
+} // namespace remote_control
diff --git a/src/components/remote_control/src/message_helper.cc b/src/components/remote_control/src/message_helper.cc
new file mode 100644
index 0000000000..140e0a977a
--- /dev/null
+++ b/src/components/remote_control/src/message_helper.cc
@@ -0,0 +1,154 @@
+/*
+ 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.
+ */
+
+#include <string>
+#include "remote_control/message_helper.h"
+#include "remote_control/rc_module_constants.h"
+#include "utils/make_shared.h"
+
+namespace remote_control {
+using functional_modules::RCFunctionID;
+namespace {
+std::map<RCFunctionID, std::string> GenerateAPINames() {
+ std::map<RCFunctionID, std::string> result;
+ result.insert(std::make_pair<RCFunctionID, std::string>(
+ RCFunctionID::BUTTON_PRESS, "ButtonPress"));
+ result.insert(std::make_pair<RCFunctionID, std::string>(
+ RCFunctionID::GET_INTERIOR_VEHICLE_DATA, "GetInteriorVehicleData"));
+ result.insert(std::make_pair<RCFunctionID, std::string>(
+ RCFunctionID::SET_INTERIOR_VEHICLE_DATA, "SetInteriorVehicleData"));
+ result.insert(std::make_pair<RCFunctionID, std::string>(
+ RCFunctionID::ON_INTERIOR_VEHICLE_DATA, "OnInteriorVehicleData"));
+ result.insert(std::make_pair<RCFunctionID, std::string>(
+ RCFunctionID::ON_REMOTE_CONTROL_SETTINGS, "OnRemoteControlSettings"));
+ return result;
+}
+
+std::map<std::string, hmi_apis::Common_RCAccessMode::eType> access_modes{
+ {enums_value::kAutoAllow, hmi_apis::Common_RCAccessMode::AUTO_ALLOW},
+ {enums_value::kAutoDeny, hmi_apis::Common_RCAccessMode::AUTO_DENY},
+ {enums_value::kAskDriver, hmi_apis::Common_RCAccessMode::ASK_DRIVER}};
+}
+
+const std::map<RCFunctionID, std::string> MessageHelper::kMobileAPINames =
+ GenerateAPINames();
+
+const std::string MessageHelper::GetMobileAPIName(RCFunctionID func_id) {
+ std::map<RCFunctionID, std::string>::const_iterator it =
+ kMobileAPINames.find(func_id);
+ if (kMobileAPINames.end() != it) {
+ return it->second;
+ } else {
+ return "";
+ }
+}
+
+std::string MessageHelper::ValueToString(const Json::Value& value) {
+ Json::FastWriter writer;
+
+ return writer.write(value);
+}
+
+Json::Value MessageHelper::StringToValue(const std::string& string) {
+ Json::Reader reader;
+ Json::Value json;
+
+ return reader.parse(string, json) ? json
+ : Json::Value(Json::ValueType::nullValue);
+}
+
+bool IsMember(const Json::Value& value, const std::string& key) {
+ if (!value.isObject()) {
+ return false;
+ }
+
+ return value.isMember(key);
+}
+
+application_manager::MessagePtr MessageHelper::CreateHmiRequest(
+ const char* function_id,
+ const uint32_t hmi_app_id,
+ const Json::Value& message_params,
+ RemotePluginInterface& rc_module) {
+ using namespace json_keys;
+ Json::Value msg;
+
+ msg[json_keys::kId] = rc_module.service()->GetNextCorrelationID();
+
+ msg[json_keys::kJsonrpc] = "2.0";
+ msg[json_keys::kMethod] = function_id;
+ if (!message_params.isNull()) {
+ msg[json_keys::kParams] = message_params;
+ }
+
+ msg[json_keys::kParams][json_keys::kAppId] = hmi_app_id;
+
+ Json::FastWriter writer;
+ application_manager::MessagePtr message_to_send =
+ utils::MakeShared<application_manager::Message>(
+ application_manager::Message(
+ protocol_handler::MessagePriority::kDefault));
+ message_to_send->set_protocol_version(
+ protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_HMI);
+ message_to_send->set_correlation_id(msg[json_keys::kId].asInt());
+ message_to_send->set_function_name(msg[json_keys::kMethod].asString());
+ std::string json_msg = writer.write(msg);
+ message_to_send->set_json_message(json_msg);
+ message_to_send->set_message_type(application_manager::MessageType::kRequest);
+
+ return message_to_send;
+}
+
+hmi_apis::Common_RCAccessMode::eType MessageHelper::AccessModeFromString(
+ const std::string& access_mode) {
+ std::map<std::string, hmi_apis::Common_RCAccessMode::eType>::const_iterator
+ mode = access_modes.find(access_mode);
+ return access_modes.end() != mode
+ ? mode->second
+ : hmi_apis::Common_RCAccessMode::INVALID_ENUM;
+}
+
+std::string MessageHelper::AccessModeToString(
+ const hmi_apis::Common_RCAccessMode::eType access_mode) {
+ std::map<std::string, hmi_apis::Common_RCAccessMode::eType>::const_iterator
+ it = access_modes.begin();
+ for (; access_modes.end() != it; ++it) {
+ if (access_mode == it->second) {
+ return it->first;
+ }
+ }
+ const std::string error = "UNKNOW_ACCESS_MODE";
+ DCHECK_OR_RETURN(false, error);
+ return error;
+}
+
+} // namespace remote_control
diff --git a/src/components/remote_control/src/module_helper.cc b/src/components/remote_control/src/module_helper.cc
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/src/components/remote_control/src/module_helper.cc
diff --git a/src/components/remote_control/src/rc_app_extension.cc b/src/components/remote_control/src/rc_app_extension.cc
new file mode 100644
index 0000000000..3431a713f9
--- /dev/null
+++ b/src/components/remote_control/src/rc_app_extension.cc
@@ -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.
+ */
+
+#include "remote_control/rc_app_extension.h"
+
+namespace remote_control {
+RCAppExtension::RCAppExtension(application_manager::AppExtensionUID uid)
+ : AppExtension(uid) {}
+
+void RCAppExtension::SubscribeToInteriorVehicleData(
+ const Json::Value& module_type) {
+ subscribed_interior_vehicle_data_.insert(module_type);
+}
+
+void RCAppExtension::UnsubscribeFromInteriorVehicleData(
+ const Json::Value& module_type) {
+ subscribed_interior_vehicle_data_.erase(module_type);
+}
+
+void RCAppExtension::UnsubscribeFromInteriorVehicleData() {
+ subscribed_interior_vehicle_data_.clear();
+}
+
+bool RCAppExtension::IsSubscibedToInteriorVehicleData(
+ const Json::Value& module_type) {
+ std::set<Json::Value>::iterator it =
+ subscribed_interior_vehicle_data_.find(module_type);
+
+ return (it != subscribed_interior_vehicle_data_.end());
+}
+
+RCAppExtension::~RCAppExtension() {}
+} // namespace remote_control
diff --git a/src/components/remote_control/src/rc_command_factory.cc b/src/components/remote_control/src/rc_command_factory.cc
new file mode 100644
index 0000000000..93b90b64ac
--- /dev/null
+++ b/src/components/remote_control/src/rc_command_factory.cc
@@ -0,0 +1,86 @@
+/*
+ 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.
+ */
+
+#include "utils/shared_ptr.h"
+#include "utils/make_shared.h"
+#include "remote_control/rc_command_factory.h"
+#include "functional_module/function_ids.h"
+#include "remote_control/commands/get_interior_vehicle_data_request.h"
+#include "remote_control/commands/set_interior_vehicle_data_request.h"
+#include "remote_control/commands/button_press_request.h"
+#include "remote_control/commands/on_interior_vehicle_data_notification.h"
+#include "remote_control/commands/on_remote_control_settings_notification.h"
+
+namespace remote_control {
+
+CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControl")
+
+using functional_modules::RCFunctionID;
+
+utils::SharedPtr<commands::Command> RCCommandFactory::CreateCommand(
+ const application_manager::MessagePtr& msg,
+ RemotePluginInterface& rc_module) {
+ switch (msg->function_id()) {
+ case RCFunctionID::GET_INTERIOR_VEHICLE_DATA: {
+ return utils::MakeShared<commands::GetInteriorVehicleDataRequest>(
+ msg, rc_module);
+ break;
+ }
+ case RCFunctionID::SET_INTERIOR_VEHICLE_DATA: {
+ return utils::MakeShared<commands::SetInteriorVehicleDataRequest>(
+ msg, rc_module);
+ break;
+ }
+ case RCFunctionID::BUTTON_PRESS: {
+ return utils::MakeShared<commands::ButtonPressRequest>(msg, rc_module);
+ break;
+ }
+ case RCFunctionID::ON_INTERIOR_VEHICLE_DATA: {
+ return utils::MakeShared<commands::OnInteriorVehicleDataNotification>(
+ msg, rc_module);
+ break;
+ }
+ case RCFunctionID::ON_REMOTE_CONTROL_SETTINGS: {
+ return utils::MakeShared<commands::OnRemoteControlSettingsNotification>(
+ msg, rc_module);
+ break;
+ }
+ default: {
+ utils::SharedPtr<commands::Command> invalid_command;
+ LOG4CXX_DEBUG(logger_,
+ "RSDL unable to proces function " << msg->function_id());
+ return invalid_command;
+ }
+ }
+}
+
+} // namespace remote_control
diff --git a/src/components/remote_control/src/remote_control_event.cc b/src/components/remote_control/src/remote_control_event.cc
new file mode 100644
index 0000000000..e4f887ffc6
--- /dev/null
+++ b/src/components/remote_control/src/remote_control_event.cc
@@ -0,0 +1,56 @@
+/*
+ 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.
+ */
+
+#include "remote_control/remote_control_event.h"
+
+namespace remote_control {
+
+RCPluginEvent::RCPluginEvent(application_manager::MessagePtr& message,
+ const std::string& id)
+ : rc_event_engine::Event<application_manager::MessagePtr, std::string>(
+ message, id) {}
+
+RCPluginEvent::~RCPluginEvent() {}
+
+int32_t RCPluginEvent::event_message_function_id() const {
+ return event_message_->function_id();
+}
+
+int32_t RCPluginEvent::event_message_correlation_id() const {
+ return event_message_->correlation_id();
+}
+
+int32_t RCPluginEvent::event_message_type() const {
+ return event_message_->type();
+}
+
+} // namespace remote_control
diff --git a/src/components/remote_control/src/remote_control_plugin.cc b/src/components/remote_control/src/remote_control_plugin.cc
new file mode 100644
index 0000000000..e5a073d15e
--- /dev/null
+++ b/src/components/remote_control/src/remote_control_plugin.cc
@@ -0,0 +1,334 @@
+/*
+ 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.
+ */
+
+#include "remote_control/remote_control_plugin.h"
+#include "remote_control/rc_command_factory.h"
+#include "remote_control/remote_control_event.h"
+#include "remote_control/rc_module_constants.h"
+#include "remote_control/rc_app_extension.h"
+#include "remote_control/message_helper.h"
+#include "utils/logger.h"
+#include "interfaces/MOBILE_API.h"
+#include "utils/macro.h"
+#include "utils/make_shared.h"
+#include "application_manager/smart_object_keys.h"
+
+namespace remote_control {
+
+using functional_modules::ProcessResult;
+using functional_modules::GenericModule;
+using functional_modules::PluginInfo;
+using functional_modules::RCFunctionID;
+namespace hmi_api = functional_modules::hmi_api;
+
+using namespace json_keys;
+
+CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControl");
+
+EXPORT_FUNCTION_IMPL(remote_control::RemoteControlPlugin);
+
+RemoteControlPlugin::RemoteControlPlugin()
+ : is_scan_started_(false), resource_allocation_manager_(*this) {
+ plugin_info_.name = "RemoteControlPlugin";
+ plugin_info_.version = 1;
+ SubscribeOnFunctions();
+}
+
+void RemoteControlPlugin::SubscribeOnFunctions() {
+ plugin_info_.rc_function_list.push_back(RCFunctionID::BUTTON_PRESS);
+ plugin_info_.rc_function_list.push_back(
+ RCFunctionID::GET_INTERIOR_VEHICLE_DATA);
+ plugin_info_.rc_function_list.push_back(
+ RCFunctionID::SET_INTERIOR_VEHICLE_DATA);
+ plugin_info_.rc_function_list.push_back(
+ RCFunctionID::ON_INTERIOR_VEHICLE_DATA);
+
+ plugin_info_.hmi_function_list.push_back(hmi_api::get_interior_vehicle_data);
+ plugin_info_.hmi_function_list.push_back(hmi_api::set_interior_vehicle_data);
+ plugin_info_.hmi_function_list.push_back(hmi_api::on_interior_vehicle_data);
+ plugin_info_.hmi_function_list.push_back(hmi_api::button_press);
+ plugin_info_.hmi_function_list.push_back(hmi_api::get_user_consent);
+ plugin_info_.hmi_function_list.push_back(hmi_api::on_remote_control_settings);
+}
+
+RemoteControlPlugin::~RemoteControlPlugin() {
+ RemoveAppExtensions();
+}
+
+functional_modules::PluginInfo RemoteControlPlugin::GetPluginInfo() const {
+ return plugin_info_;
+}
+
+const std::string ExtractFunctionAndAddMetadata(
+ const Json::Value& value, application_manager::Message& out_msg) {
+ if (value.isMember(json_keys::kMethod)) {
+ const std::string& function_name =
+ value.get(json_keys::kMethod, "").asCString();
+
+ // Existence of method name must be guaranteed by plugin manager
+ DCHECK_OR_RETURN(!function_name.empty(), "");
+
+ if (value.isMember(json_keys::kId)) {
+ out_msg.set_correlation_id(value.get(json_keys::kId, "").asInt());
+ out_msg.set_message_type(application_manager::MessageType::kRequest);
+ } else {
+ out_msg.set_message_type(application_manager::MessageType::kNotification);
+ }
+ return function_name;
+ }
+
+ if (value.isMember(json_keys::kResult)) {
+ const Json::Value& result = value.get(json_keys::kResult, Json::Value());
+ const std::string& function_name =
+ result.get(json_keys::kMethod, "").asCString();
+ out_msg.set_correlation_id(value.get(json_keys::kId, "").asInt());
+
+ // Existence of method name must be guaranteed by plugin manager
+ DCHECK_OR_RETURN(!function_name.empty(), "");
+
+ out_msg.set_message_type(application_manager::MessageType::kResponse);
+ return function_name;
+ }
+
+ if (value.isMember(json_keys::kError)) {
+ const Json::Value& error = value.get(json_keys::kError, Json::Value());
+ const Json::Value& data = error.get(json_keys::kData, Json::Value());
+ const std::string& function_name =
+ data.get(json_keys::kMethod, "").asCString();
+
+ // Existence of method name must be guaranteed by plugin manager
+ DCHECK_OR_RETURN(!function_name.empty(), "");
+
+ out_msg.set_message_type(application_manager::MessageType::kErrorResponse);
+ out_msg.set_correlation_id(value.get(json_keys::kId, "").asInt());
+ return function_name;
+ }
+ return std::string();
+}
+
+ProcessResult RemoteControlPlugin::ProcessMessage(
+ application_manager::MessagePtr msg) {
+ DCHECK_OR_RETURN(msg, ProcessResult::FAILED);
+
+ const std::string& function_name = MessageHelper::GetMobileAPIName(
+ static_cast<functional_modules::RCFunctionID>(msg->function_id()));
+
+ LOG4CXX_DEBUG(logger_, "Function name to set : " << function_name);
+ msg->set_function_name(function_name);
+
+ LOG4CXX_DEBUG(logger_, "Mobile message: " << msg->json_message());
+
+ request_controller::MobileRequestPtr command(
+ RCCommandFactory::CreateCommand(msg, *this));
+ if (command) {
+ request_controller_.AddRequest(msg->correlation_id(), command);
+ command->Run();
+ } else {
+ return ProcessResult::CANNOT_PROCESS;
+ }
+
+ return ProcessResult::PROCESSED;
+}
+
+ProcessResult RemoteControlPlugin::ProcessHMIMessage(
+ application_manager::MessagePtr msg) {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ Json::Value value;
+ Json::Reader reader;
+ reader.parse(msg->json_message(), value);
+ LOG4CXX_TRACE(logger_, "Process " << msg->json_message());
+ const std::string& function_name = ExtractFunctionAndAddMetadata(value, *msg);
+
+ // Existence of method name must be guaranteed by plugin manager
+ DCHECK_OR_RETURN(!function_name.empty(), ProcessResult::FAILED);
+
+ LOG4CXX_DEBUG(logger_, "Process " << function_name);
+
+ switch (msg->type()) {
+ case application_manager::MessageType::kResponse:
+ case application_manager::MessageType::kErrorResponse: {
+ RCPluginEvent event(msg, function_name);
+ LOG4CXX_DEBUG(logger_, "Response received");
+ event_dispatcher_.raise_event(event);
+ return ProcessResult::PROCESSED;
+ }
+ case application_manager::MessageType::kRequest:
+ case application_manager::MessageType::kNotification: {
+ if (hmi_api::on_interior_vehicle_data == function_name) {
+ msg->set_function_id(functional_modules::ON_INTERIOR_VEHICLE_DATA);
+ }
+ if (hmi_api::on_remote_control_settings == function_name) {
+ msg->set_function_id(functional_modules::ON_REMOTE_CONTROL_SETTINGS);
+ }
+ const application_manager::MessageValidationResult validation_result =
+ service()->ValidateMessageBySchema(*msg);
+ utils::SharedPtr<commands::Command> command =
+ RCCommandFactory::CreateCommand(msg, *this);
+ if ((validation_result ==
+ application_manager::MessageValidationResult::SUCCESS) &&
+ command) {
+ command->Run();
+ return ProcessResult::PROCESSED;
+ }
+ LOG4CXX_DEBUG(logger_, "Message validation failed");
+ break;
+ }
+ default: { LOG4CXX_DEBUG(logger_, "Unknown message type"); }
+ }
+ return ProcessResult::CANNOT_PROCESS;
+}
+
+void RemoteControlPlugin::SendHmiStatusNotification(
+ application_manager::ApplicationSharedPtr app) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ application_manager::MessagePtr msg = new application_manager::Message(
+ protocol_handler::MessagePriority::kDefault);
+ Json::Value msg_params;
+
+ msg->set_function_id(mobile_apis::FunctionID::OnHMIStatusID);
+ msg->set_message_type(application_manager::MessageType::kNotification);
+
+ msg->set_connection_key(app->app_id());
+ msg->set_protocol_version(app->protocol_version());
+
+ msg_params["hmiLevel"] = static_cast<uint32_t>(app->hmi_level());
+
+ msg_params["audioStreamingState"] =
+ static_cast<uint32_t>(app->audio_streaming_state());
+
+ msg_params["systemContext"] = static_cast<uint32_t>(app->system_context());
+
+ msg->set_json_message(MessageHelper::ValueToString(msg_params));
+
+ service()->SendMessageToMobile(msg);
+}
+
+void RemoteControlPlugin::SendResponseToMobile(
+ application_manager::MessagePtr msg) {
+ LOG4CXX_DEBUG(logger_, "Response to mobile: " << msg->json_message());
+ service()->SendMessageToMobile(msg);
+ request_controller_.DeleteRequest(msg->correlation_id());
+}
+
+void RemoteControlPlugin::SendTimeoutResponseToMobile(
+ application_manager::MessagePtr msg) {
+ LOG4CXX_DEBUG(
+ logger_,
+ "Timeout is expired. Response to mobile: " << msg->json_message());
+ service()->SendMessageToMobile(msg);
+}
+
+void RemoteControlPlugin::RemoveAppExtensions() {
+ std::vector<application_manager::ApplicationSharedPtr> applications =
+ service()->GetApplications(GetModuleID());
+
+ std::vector<application_manager::ApplicationSharedPtr>::iterator it =
+ applications.begin();
+
+ for (; it != applications.end(); ++it) {
+ application_manager::ApplicationSharedPtr app = *it;
+ if (app) {
+ app->RemoveExtension(GetModuleID());
+ }
+ }
+}
+
+void RemoteControlPlugin::RemoveAppExtension(uint32_t app_id) {
+ application_manager::ApplicationSharedPtr app =
+ service()->GetApplication(app_id);
+
+ if (app) {
+ app->RemoveExtension(GetModuleID());
+ }
+}
+
+bool RemoteControlPlugin::IsAppForPlugin(
+ application_manager::ApplicationSharedPtr app) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ application_manager::AppExtensionPtr app_extension =
+ app->QueryInterface(GetModuleID());
+ if (app_extension) {
+ return true;
+ }
+
+ if (service()->IsRemoteControlApplication(app)) {
+ RCAppExtensionPtr rc_app_extension = new RCAppExtension(GetModuleID());
+ app->AddExtension(rc_app_extension);
+ service()->NotifyHMIAboutHMILevel(app, app->hmi_level());
+ return true;
+ }
+ return false;
+}
+
+void RemoteControlPlugin::OnAppHMILevelChanged(
+ application_manager::ApplicationSharedPtr app,
+ mobile_apis::HMILevel::eType) {
+ LOG4CXX_DEBUG(logger_,
+ "RSDL application " << app->name().AsMBString()
+ << " has changed hmi level to "
+ << app->hmi_level());
+ service()->NotifyHMIAboutHMILevel(app, app->hmi_level());
+}
+
+void RemoteControlPlugin::OnPluginServiceChanged() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ const functional_modules::TimeUnit timeout_msec =
+ service()->GetSettings().default_timeout();
+ request_controller_.SetRequestTimeout(timeout_msec / 1000);
+}
+
+void RemoteControlPlugin::set_service(application_manager::ServicePtr service) {
+ RemotePluginInterface::set_service(service);
+ OnPluginServiceChanged();
+}
+
+RCEventDispatcher& RemoteControlPlugin::event_dispatcher() {
+ return event_dispatcher_;
+}
+
+ResourceAllocationManager& RemoteControlPlugin::resource_allocation_manager() {
+ return resource_allocation_manager_;
+}
+
+void RemoteControlPlugin::OnApplicationEvent(
+ functional_modules::ApplicationEvent event, const uint32_t application_id) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ resource_allocation_manager_.OnApplicationEvent(event, application_id);
+}
+
+void RemoteControlPlugin::OnPolicyEvent(functional_modules::PolicyEvent event) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ resource_allocation_manager_.OnPolicyEvent(event);
+}
+
+} // namespace remote_control
diff --git a/src/components/remote_control/src/request_controller.cc b/src/components/remote_control/src/request_controller.cc
new file mode 100644
index 0000000000..9ffc639898
--- /dev/null
+++ b/src/components/remote_control/src/request_controller.cc
@@ -0,0 +1,96 @@
+/*
+ * 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.
+ */
+
+#include "remote_control/request_controller.h"
+#include "json/json.h"
+#include "utils/logger.h"
+
+namespace remote_control {
+namespace request_controller {
+
+CREATE_LOGGERPTR_GLOBAL(logger_, "RCRequestController")
+
+RequestController::RequestController() {
+ timer_.AddObserver(this);
+ time_director_.RegisterTimer(timer_);
+}
+
+RequestController::~RequestController() {
+ time_director_.UnregisterTimer(timer_);
+ timer_.RemoveObserver(this);
+}
+
+void RequestController::AddRequest(const uint32_t mobile_correlation_id,
+ MobileRequestPtr request) {
+ // TODO(VS) Research and fix be problem with overlap correlation ids from two
+ // different apllications(on two different mobile devices)
+ sync_primitives::AutoLock lock(mobile_request_lock_);
+ LOG4CXX_DEBUG(logger_,
+ "Add request with correlation_id: " << mobile_correlation_id);
+ mobile_request_list_[mobile_correlation_id] = request;
+ // TODO(VS): add app id
+ timer_.AddTrackable(TrackableMessage(0, mobile_correlation_id));
+ time_director_.ResetTimer(timer_);
+}
+
+void RequestController::DeleteRequest(const uint32_t& mobile_correlation_id) {
+ sync_primitives::AutoLock lock(mobile_request_lock_);
+ LOG4CXX_DEBUG(
+ logger_, "Delete request with correlation_id: " << mobile_correlation_id);
+ mobile_request_list_.erase(mobile_correlation_id);
+ // TODO(VS): add app id
+ timer_.RemoveTrackable(TrackableMessage(0, mobile_correlation_id));
+}
+
+void RequestController::OnTimeoutTriggered(const TrackableMessage& expired) {
+ sync_primitives::AutoLock lock(mobile_request_lock_);
+ LOG4CXX_DEBUG(logger_,
+ "Timeout is expired for request with correlation_id: "
+ << expired.correlation_id());
+ std::map<correlation_id, MobileRequestPtr>::iterator it =
+ mobile_request_list_.find(expired.correlation_id());
+ if (mobile_request_list_.end() == it) {
+ // no corresponding request found, error.
+ return;
+ }
+ it->second->OnTimeout();
+ mobile_request_list_.erase(it);
+}
+
+void RequestController::SetRequestTimeout(
+ const functional_modules::TimeUnit timeout_seconds) {
+ LOG4CXX_DEBUG(logger_, "RC request timeout is set to " << timeout_seconds);
+ timer_.set_period(timeout_seconds);
+}
+
+} // namespace request_controller
+} // namespace remote_control
diff --git a/src/components/remote_control/src/resource_allocation_manager_impl.cc b/src/components/remote_control/src/resource_allocation_manager_impl.cc
new file mode 100644
index 0000000000..fd6c2d8fb8
--- /dev/null
+++ b/src/components/remote_control/src/resource_allocation_manager_impl.cc
@@ -0,0 +1,373 @@
+#include "remote_control/resource_allocation_manager_impl.h"
+#include "application_manager/application.h"
+#include "application_manager/message_helper.h"
+#include "remote_control/rc_module_constants.h"
+#include "json/json.h"
+#include "utils/helpers.h"
+#include "utils/make_shared.h"
+#include "remote_control/message_helper.h"
+#include "remote_control/rc_app_extension.h"
+
+namespace remote_control {
+
+CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule")
+
+ResourceAllocationManagerImpl::ResourceAllocationManagerImpl(
+ RemotePluginInterface& rc_plugin)
+ : current_access_mode_(hmi_apis::Common_RCAccessMode::AUTO_ALLOW)
+ , rc_plugin_(rc_plugin) {}
+
+ResourceAllocationManagerImpl::~ResourceAllocationManagerImpl() {}
+
+AcquireResult::eType ResourceAllocationManagerImpl::AcquireResource(
+ const std::string& module_type, const uint32_t app_id) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ const application_manager::ApplicationSharedPtr acquiring_app =
+ rc_plugin_.service()->GetApplication(app_id);
+ if (!acquiring_app) {
+ LOG4CXX_WARN(logger_, "App with app_id: " << app_id << "does not exist!");
+ return AcquireResult::IN_USE;
+ }
+
+ sync_primitives::AutoLock lock(allocated_resources_lock_);
+ const AllocatedResources::const_iterator allocated_it =
+ allocated_resources_.find(module_type);
+ if (allocated_resources_.end() == allocated_it) {
+ allocated_resources_[module_type] = app_id;
+ LOG4CXX_DEBUG(logger_,
+ "Resource is not acquired yet. "
+ << "App: " << app_id << " is allowed to acquire "
+ << module_type);
+ return AcquireResult::ALLOWED;
+ }
+
+ if (app_id == allocated_resources_[module_type]) {
+ LOG4CXX_DEBUG(logger_,
+ "App: " << app_id << " is already acquired resource "
+ << module_type);
+ return AcquireResult::ALLOWED;
+ }
+
+ if (IsModuleTypeRejected(module_type, app_id)) {
+ LOG4CXX_DEBUG(logger_,
+ "Driver disallowed app: " << app_id << " to acquire "
+ << module_type);
+ return AcquireResult::REJECTED;
+ }
+
+ const mobile_apis::HMILevel::eType acquiring_app_hmi_level =
+ acquiring_app->hmi_level();
+
+ if (mobile_apis::HMILevel::HMI_FULL != acquiring_app_hmi_level) {
+ LOG4CXX_DEBUG(
+ logger_,
+ "Aquiring resources is not allowed in HMI level: "
+ << application_manager::MessageHelper::StringifiedHMILevel(
+ acquiring_app_hmi_level) << ". App: " << app_id
+ << " is disallowed to acquire " << module_type);
+ return AcquireResult::REJECTED;
+ }
+
+ switch (current_access_mode_) {
+ case hmi_apis::Common_RCAccessMode::AUTO_DENY: {
+ LOG4CXX_DEBUG(logger_,
+ "Current access_mode is AUTO_DENY. "
+ << "App: " << app_id << " is disallowed to acquire "
+ << module_type);
+ return AcquireResult::IN_USE;
+ }
+ case hmi_apis::Common_RCAccessMode::ASK_DRIVER: {
+ LOG4CXX_DEBUG(logger_,
+ "Current access_mode is ASK_DRIVER. "
+ "Driver confirmation is required for app: "
+ << app_id << " to acquire " << module_type);
+ return AcquireResult::ASK_DRIVER;
+ }
+ case hmi_apis::Common_RCAccessMode::AUTO_ALLOW: {
+ LOG4CXX_DEBUG(logger_,
+ "Current access_mode is AUTO_ALLOW. "
+ << "App: " << app_id << " is allowed to acquire "
+ << module_type);
+
+ allocated_resources_[module_type] = app_id;
+ return AcquireResult::ALLOWED;
+ }
+ default: { DCHECK_OR_RETURN(false, AcquireResult::IN_USE); }
+ }
+}
+
+void ResourceAllocationManagerImpl::ReleaseResource(
+ const std::string& module_type, const uint32_t application_id) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ LOG4CXX_DEBUG(logger_, "Release " << module_type << " by " << application_id);
+ AllocatedResources::const_iterator allocation =
+ allocated_resources_.find(module_type);
+ if (allocated_resources_.end() == allocation) {
+ LOG4CXX_DEBUG(logger_, "Resource " << module_type << " is not allocated.");
+ return;
+ }
+
+ if (application_id != allocation->second) {
+ LOG4CXX_DEBUG(logger_,
+ "Resource " << module_type
+ << " is allocated by different application "
+ << allocation->second);
+ return;
+ }
+
+ allocated_resources_.erase(allocation);
+ LOG4CXX_DEBUG(logger_, "Resource " << module_type << " is released.");
+ return;
+}
+
+void ResourceAllocationManagerImpl::ProcessApplicationPolicyUpdate() {
+ typedef std::vector<application_manager::ApplicationSharedPtr> Apps;
+ Apps app_list =
+ rc_plugin_.service()->GetApplications(rc_plugin_.GetModuleID());
+ Apps::const_iterator app = app_list.begin();
+ for (; app_list.end() != app; ++app) {
+ application_manager::ApplicationSharedPtr app_ptr = *app;
+ const uint32_t application_id = app_ptr->app_id();
+ Resources acquired_modules = GetAcquiredResources(application_id);
+ std::sort(acquired_modules.begin(), acquired_modules.end());
+
+ Resources allowed_modules;
+ rc_plugin_.service()->GetModuleTypes((*app)->policy_app_id(),
+ &allowed_modules);
+ std::sort(allowed_modules.begin(), allowed_modules.end());
+
+ LOG4CXX_DEBUG(logger_,
+ "Acquired modules: " << acquired_modules.size()
+ << " , allowed modules: "
+ << allowed_modules.size());
+
+ Resources disallowed_modules;
+ std::set_difference(acquired_modules.begin(),
+ acquired_modules.end(),
+ allowed_modules.begin(),
+ allowed_modules.end(),
+ std::back_inserter(disallowed_modules));
+
+ RCAppExtensionPtr rc_extention = GetApplicationExtention(app_ptr);
+ Resources::const_iterator module = disallowed_modules.begin();
+ for (; disallowed_modules.end() != module; ++module) {
+ ReleaseResource(*module, application_id);
+ if (rc_extention) {
+ rc_extention->UnsubscribeFromInteriorVehicleData(Json::Value(*module));
+ }
+ }
+ }
+}
+
+RCAppExtensionPtr ResourceAllocationManagerImpl::GetApplicationExtention(
+ application_manager::ApplicationSharedPtr application) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (!application) {
+ return NULL;
+ }
+
+ RCAppExtensionPtr rc_app_extension;
+ application_manager::AppExtensionPtr app_extension =
+ application->QueryInterface(rc_plugin_.GetModuleID());
+ if (!app_extension) {
+ return NULL;
+ }
+
+ rc_app_extension =
+ application_manager::AppExtensionPtr::static_pointer_cast<RCAppExtension>(
+ app_extension);
+
+ return rc_app_extension;
+}
+
+void ResourceAllocationManagerImpl::RemoveAppsSubscriptions(const Apps& apps) {
+ Apps::const_iterator app = apps.begin();
+ for (; apps.end() != app; ++app) {
+ application_manager::ApplicationSharedPtr app_ptr = *app;
+ if (!app_ptr) {
+ continue;
+ }
+ RCAppExtensionPtr rc_extention = GetApplicationExtention(app_ptr);
+ if (rc_extention) {
+ rc_extention->UnsubscribeFromInteriorVehicleData();
+ }
+ }
+}
+
+std::vector<std::string> ResourceAllocationManagerImpl::GetAcquiredResources(
+ const uint32_t application_id) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ Resources allocated_resources;
+ AllocatedResources::const_iterator allocation = allocated_resources_.begin();
+ for (; allocated_resources_.end() != allocation; ++allocation) {
+ if (application_id == allocation->second) {
+ allocated_resources.push_back(allocation->first);
+ }
+ }
+
+ LOG4CXX_DEBUG(logger_,
+ "Application " << application_id << " acquired "
+ << allocated_resources.size()
+ << " resource(s).");
+
+ return allocated_resources;
+}
+
+void ResourceAllocationManagerImpl::SetResourceState(
+ const std::string& module_type,
+ const uint32_t app_id,
+ const ResourceState::eType state) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ LOG4CXX_DEBUG(logger_,
+ "Setting state for " << module_type << " by app_id " << app_id
+ << " to state " << state);
+ {
+ sync_primitives::AutoLock lock(allocated_resources_lock_);
+ const AllocatedResources::const_iterator allocated_it =
+ allocated_resources_.find(module_type);
+
+ const bool acquired = allocated_resources_.end() != allocated_it;
+ if (acquired) {
+ LOG4CXX_DEBUG(logger_,
+ "Resource " << module_type << " is already acquired."
+ << " Owner application id is "
+ << allocated_it->second
+ << " Changing application id is " << app_id);
+ } else {
+ LOG4CXX_DEBUG(logger_,
+ "Resource " << module_type << " is not acquired yet");
+ }
+ }
+
+ sync_primitives::AutoLock lock(resources_state_lock_);
+ resources_state_[module_type] = state;
+ LOG4CXX_DEBUG(logger_, "Resource " << module_type << " got state " << state);
+}
+
+bool ResourceAllocationManagerImpl::IsResourceFree(
+ const std::string& module_type) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ sync_primitives::AutoLock lock(resources_state_lock_);
+ const ResourcesState::const_iterator resource =
+ resources_state_.find(module_type);
+
+ if (resources_state_.end() == resource) {
+ LOG4CXX_DEBUG(logger_, "Resource " << module_type << " is free.");
+ return true;
+ }
+
+ LOG4CXX_DEBUG(logger_,
+ "Resource " << module_type << " state is " << resource->second);
+
+ return ResourceState::FREE == resource->second;
+}
+
+void ResourceAllocationManagerImpl::SetAccessMode(
+ const hmi_apis::Common_RCAccessMode::eType access_mode) {
+ if (hmi_apis::Common_RCAccessMode::ASK_DRIVER != access_mode) {
+ sync_primitives::AutoLock lock(rejected_resources_for_application_lock_);
+ rejected_resources_for_application_.clear();
+ }
+ current_access_mode_ = access_mode;
+}
+
+hmi_apis::Common_RCAccessMode::eType
+ResourceAllocationManagerImpl::GetAccessMode() const {
+ return current_access_mode_;
+}
+
+void ResourceAllocationManagerImpl::ForceAcquireResource(
+ const std::string& module_type, const uint32_t app_id) {
+ LOG4CXX_DEBUG(logger_, "Force " << app_id << " acquiring " << module_type);
+ sync_primitives::AutoLock lock(allocated_resources_lock_);
+ allocated_resources_[module_type] = app_id;
+}
+
+bool ResourceAllocationManagerImpl::IsModuleTypeRejected(
+ const std::string& module_type, const uint32_t app_id) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock lock(rejected_resources_for_application_lock_);
+ RejectedResources::iterator it =
+ rejected_resources_for_application_.find(app_id);
+
+ if (rejected_resources_for_application_.end() == it) {
+ return false;
+ }
+
+ const std::vector<std::string>& list_of_rejected_resources =
+ rejected_resources_for_application_[app_id];
+
+ return helpers::in_range(list_of_rejected_resources, module_type);
+}
+
+void ResourceAllocationManagerImpl::OnDriverDisallowed(
+ const std::string& module_type, const uint32_t app_id) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock lock(rejected_resources_for_application_lock_);
+ RejectedResources::iterator it =
+ rejected_resources_for_application_.find(app_id);
+
+ if (rejected_resources_for_application_.end() == it) {
+ rejected_resources_for_application_[app_id] = std::vector<std::string>();
+ }
+ std::vector<std::string>& list_of_rejected_resources =
+ rejected_resources_for_application_[app_id];
+ list_of_rejected_resources.push_back(module_type);
+}
+
+void ResourceAllocationManagerImpl::OnApplicationEvent(
+ functional_modules::ApplicationEvent event, const uint32_t application_id) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ LOG4CXX_DEBUG(logger_, "Event " << event << " came for " << application_id);
+
+ if (functional_modules::ApplicationEvent::kApplicationExit == event ||
+ functional_modules::ApplicationEvent::kApplicationUnregistered == event) {
+ Resources acquired_modules = GetAcquiredResources(application_id);
+ Resources::const_iterator module = acquired_modules.begin();
+ for (; acquired_modules.end() != module; ++module) {
+ ReleaseResource(*module, application_id);
+ }
+
+ Apps app_list;
+ app_list.push_back(rc_plugin_.service()->GetApplication(application_id));
+ RemoveAppsSubscriptions(app_list);
+ }
+}
+
+void ResourceAllocationManagerImpl::OnPolicyEvent(
+ functional_modules::PolicyEvent event) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ LOG4CXX_DEBUG(logger_, "Event " << event);
+
+ if (functional_modules::PolicyEvent::kApplicationPolicyUpdated == event) {
+ ProcessApplicationPolicyUpdate();
+ return;
+ }
+
+ if (functional_modules::PolicyEvent::kApplicationsDisabled == event) {
+ ResetAllAllocations();
+ application_manager::ServicePtr s = rc_plugin_.service();
+ Apps app_list = s->GetApplications(rc_plugin_.GetModuleID());
+ RemoveAppsSubscriptions(app_list);
+ return;
+ }
+}
+
+void ResourceAllocationManagerImpl::ResetAllAllocations() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ {
+ sync_primitives::AutoLock lock(resources_state_lock_);
+ resources_state_.clear();
+ }
+ {
+ sync_primitives::AutoLock lock(allocated_resources_lock_);
+ allocated_resources_.clear();
+ }
+ {
+ sync_primitives::AutoLock lock(rejected_resources_for_application_lock_);
+ rejected_resources_for_application_.clear();
+ }
+}
+
+} // namespace remote_control
diff --git a/src/components/remote_control/test/CMakeLists.txt b/src/components/remote_control/test/CMakeLists.txt
new file mode 100644
index 0000000000..6457b56397
--- /dev/null
+++ b/src/components/remote_control/test/CMakeLists.txt
@@ -0,0 +1,67 @@
+include_directories (
+ ${LOG4CXX_INCLUDE_DIRECTORY}
+ ${GMOCK_INCLUDE_DIRECTORY}
+ ${CMAKE_SOURCE_DIR}/src/components/functional_module/include/
+ ${CMAKE_SOURCE_DIR}/src/components/functional_module/test/
+ ${CMAKE_SOURCE_DIR}/src/components/remote_control/include/
+ ${CMAKE_SOURCE_DIR}/src/components/remote_control/test/include/
+ ${CMAKE_SOURCE_DIR}/src/components/include/
+ ${CMAKE_SOURCE_DIR}/src/components/application_manager/test/include/
+ ${CMAKE_SOURCE_DIR}/src/components/connection_handler/include/
+ ${CMAKE_SOURCE_DIR}/src/components/smart_objects/include/
+ ${CMAKE_SOURCE_DIR}/src/components/policy/src/policy/usage_statistics/include/
+ ${JSONCPP_INCLUDE_DIRECTORY}
+ ${CMAKE_BINARY_DIR}/src/components/
+ include/
+)
+
+set (SOURCES
+ src/rc_module_test.cc
+ src/rc_app_extension_test.cc
+ src/resource_allocation_manager_impl_test.cc
+ ${CMAKE_SOURCE_DIR}/src/components/application_manager/test/mock_message_helper.cc
+)
+
+set (LIBRARIES
+ gtest
+ gmock
+ gmock_main
+ RemoteControlModule
+ SmartObjects
+ gcov
+ Policy
+)
+
+if (ENABLE_TEST_COV_COUNT)
+ set(GCOV_FLAGS "-ftest-coverage -fprofile-arcs")
+else()
+ set(GCOV_FLAGS "")
+endif()
+
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCOV_FLAGS}")
+
+# use, i.e. don't skip the full RPATH for the build tree
+#SET(CMAKE_SKIP_BUILD_RPATH FALSE)
+
+# when building, don't use the install RPATH already
+# (but later on when installing)
+#SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
+
+#SET(RPATH_DIRECTORIES
+# ${CMAKE_BINARY_DIR}/src/components/remote_control/
+# /usr/local/lib
+# /usr/local
+# ${CMAKE_BINARY_DIR}/src/components/utils
+#)
+
+#SET(CMAKE_INSTALL_RPATH "${RPATH_DIRECTORIES}")
+
+add_custom_command(
+OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/libPolicy.so
+ COMMAND ${CMAKE_COMMAND} -E
+ copy ${COMPONENTS_DIR}/policy/libPolicy.so ${CMAKE_CURRENT_BINARY_DIR})
+ set(CMAKE_EXE_LINKER_FLAGS
+ "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath=${CMAKE_CURRENT_BINARY_DIR}")
+
+create_test("remote_control_test" "${SOURCES}" "${LIBRARIES}")
+add_subdirectory(commands)
diff --git a/src/components/remote_control/test/commands/CMakeLists.txt b/src/components/remote_control/test/commands/CMakeLists.txt
new file mode 100644
index 0000000000..09c706fc2f
--- /dev/null
+++ b/src/components/remote_control/test/commands/CMakeLists.txt
@@ -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.
+
+include(${CMAKE_SOURCE_DIR}/tools/cmake/helpers/sources.cmake)
+
+include_directories(
+ ${GMOCK_INCLUDE_DIRECTORY}
+ ${COMPONENTS_DIR}/remote_control/include/
+ ${COMPONENTS_DIR}/remote_control/include/remote_control/
+ ${COMPONENTS_DIR}/remote_control/include/remote_control/commands/
+ ${COMPONENTS_DIR}/remote_control/test/include
+)
+
+set(RC_COMMANDS_TEST_DIR ${RC_TEST_DIR}/commands)
+
+file(GLOB SOURCES
+ ${COMPONENTS_DIR}/application_manager/test/mock_message_helper.cc
+ ${RC_COMMANDS_TEST_DIR}/*
+)
+
+set(LIBRARIES
+ gmock
+ RemoteControlModule
+ Utils
+ SmartObjects
+ jsoncpp
+ HMI_API
+ MOBILE_API
+ ApplicationManager
+ AMHMICommandsLibrary
+ AMMobileCommandsLibrary
+ connectionHandler
+)
+
+create_test("rc_commands_test" "${SOURCES}" "${LIBRARIES}" )
diff --git a/src/components/remote_control/test/commands/button_press_request_test.cc b/src/components/remote_control/test/commands/button_press_request_test.cc
new file mode 100644
index 0000000000..06a48fc077
--- /dev/null
+++ b/src/components/remote_control/test/commands/button_press_request_test.cc
@@ -0,0 +1,344 @@
+/*
+ * 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.
+ */
+
+#include "remote_control/commands/button_press_request.h"
+#include "gtest/gtest.h"
+#include "mock_remote_control_plugin.h"
+#include "mock_application.h"
+#include "mock_resource_allocation_manager.h"
+#include "remote_control/rc_app_extension.h"
+#include "remote_control/remote_control_event.h"
+#include "remote_control/rc_module_constants.h"
+#include "remote_control/message_helper.h"
+#include "remote_control/rc_command_factory.h"
+#include "remote_control/event_engine/event_dispatcher.h"
+#include "remote_control/rc_module_constants.h"
+#include "functional_module/function_ids.h"
+#include "include/mock_service.h"
+#include "utils/shared_ptr.h"
+#include "utils/make_shared.h"
+
+using functional_modules::RCFunctionID;
+using application_manager::ServicePtr;
+
+using application_manager::MockService;
+using test::components::remote_control_test::MockApplication;
+
+using ::testing::_;
+using ::testing::Mock;
+using ::testing::NiceMock;
+using ::testing::Return;
+using ::testing::ReturnRef;
+using ::testing::SaveArg;
+using ::application_manager::Message;
+using ::application_manager::MessageType;
+using ::protocol_handler::MessagePriority;
+using remote_control::RemotePluginInterface;
+using remote_control::MessageHelper;
+
+namespace {
+const int kModuleId = 153;
+
+const std::string kCorrectMobileRequest =
+ "{\"moduleType\":\"CLIMATE\",\"buttonName\":\"AC\",\"buttonPressMode\":"
+ "\"SHORT\"}";
+const std::string kWrongMobileRequest =
+ "{\"moduleType\":\"RADIO\",\"buttonName\":\"AC\",\"buttonPressMode\":"
+ "\"SHORT\"}";
+const std::string kValidHmiResponse =
+ "{\"result\":{\"code\":0,\"method\":\"Buttons.ButtonPress\"},\"id\":31,"
+ "\"jsonrpc\":\"2.0\"} ";
+const std::string KReadOnlyHmiResponse =
+ "{\"jsonrpc\":\"2.0\",\"error\":{\"code\":26,\"data\":{\"method\":"
+ "\"Buttons.ButtonPress\"},\"message\":\"Read only parameters "
+ "received\"},\"id\":31}";
+const uint32_t kAppId = 11u;
+}
+
+namespace test {
+namespace components {
+namespace remote_control_test {
+namespace button_press_request_test {
+
+class ButtonPressRequestTest : public ::testing::Test {
+ public:
+ ButtonPressRequestTest()
+ : rc_capabilities_(smart_objects::SmartType_Map)
+ , mock_service_(utils::MakeShared<NiceMock<MockService> >())
+ , mock_app_(utils::MakeShared<NiceMock<MockApplication> >())
+ , rc_app_extention_(
+ utils::MakeShared<remote_control::RCAppExtension>(kModuleId)) {
+ ON_CALL(mock_module_, service()).WillByDefault(Return(mock_service_));
+ ON_CALL(mock_module_, resource_allocation_manager())
+ .WillByDefault(ReturnRef(mock_allocation_manager_));
+ ON_CALL(*mock_service_, GetApplication(kAppId))
+ .WillByDefault(Return(mock_app_));
+ EXPECT_CALL(mock_module_, event_dispatcher())
+ .WillRepeatedly(ReturnRef(event_dispatcher_));
+ ServicePtr exp_service(mock_service_);
+ mock_module_.set_service(exp_service);
+ }
+
+ smart_objects::SmartObject ButtonCapability(
+ const mobile_apis::ButtonName::eType button_name) {
+ smart_objects::SmartObject button(smart_objects::SmartType_Map);
+ button["name"] = button_name;
+ return button;
+ }
+
+ void SetUp() OVERRIDE {
+ using namespace remote_control;
+ using namespace mobile_apis;
+
+ std::vector<ButtonName::eType> button_names;
+ button_names.push_back(ButtonName::AC_MAX);
+ button_names.push_back(ButtonName::AC);
+ button_names.push_back(ButtonName::RECIRCULATE);
+ button_names.push_back(ButtonName::FAN_UP);
+ button_names.push_back(ButtonName::FAN_DOWN);
+ button_names.push_back(ButtonName::TEMP_UP);
+ button_names.push_back(ButtonName::TEMP_DOWN);
+ button_names.push_back(ButtonName::DEFROST_MAX);
+ button_names.push_back(ButtonName::DEFROST);
+ button_names.push_back(ButtonName::DEFROST_REAR);
+ button_names.push_back(ButtonName::UPPER_VENT);
+ button_names.push_back(ButtonName::LOWER_VENT);
+ button_names.push_back(ButtonName::VOLUME_UP);
+ button_names.push_back(ButtonName::VOLUME_DOWN);
+ button_names.push_back(ButtonName::EJECT);
+ button_names.push_back(ButtonName::SOURCE);
+ button_names.push_back(ButtonName::SHUFFLE);
+ button_names.push_back(ButtonName::REPEAT);
+
+ smart_objects::SmartObject button_caps(smart_objects::SmartType_Array);
+ for (size_t i = 0; i < button_names.size(); i++) {
+ button_caps[i] = ButtonCapability(button_names[i]);
+ }
+ rc_capabilities_[strings::kbuttonCapabilities] = button_caps;
+ ON_CALL(*mock_service_, GetRCCapabilities())
+ .WillByDefault(Return(&rc_capabilities_));
+ ON_CALL(*mock_service_, IsInterfaceAvailable(_))
+ .WillByDefault(Return(true));
+ ON_CALL(*mock_service_, IsRemoteControlApplication(_))
+ .WillByDefault(Return(true));
+ }
+
+ remote_control::request_controller::MobileRequestPtr CreateCommand(
+ application_manager::MessagePtr msg) {
+ return remote_control::RCCommandFactory::CreateCommand(msg, mock_module_);
+ }
+
+ application_manager::MessagePtr CreateBasicMessage() {
+ application_manager::MessagePtr message = utils::MakeShared<Message>(
+ MessagePriority::FromServiceType(protocol_handler::ServiceType::kRpc));
+ message->set_function_id(RCFunctionID::BUTTON_PRESS);
+ message->set_function_name(
+ MessageHelper::GetMobileAPIName(functional_modules::BUTTON_PRESS));
+ message->set_connection_key(kAppId);
+ return message;
+ }
+
+ protected:
+ smart_objects::SmartObject rc_capabilities_;
+ utils::SharedPtr<NiceMock<application_manager::MockService> > mock_service_;
+ utils::SharedPtr<NiceMock<MockApplication> > mock_app_;
+ utils::SharedPtr<remote_control::RCAppExtension> rc_app_extention_;
+ testing::NiceMock<remote_control_test::MockRemotePluginInterface>
+ mock_module_;
+ testing::NiceMock<remote_control_test::MockResourceAllocationManager>
+ mock_allocation_manager_;
+ RemotePluginInterface::RCPluginEventDispatcher event_dispatcher_;
+};
+
+TEST_F(ButtonPressRequestTest,
+ Execute_ButtonNameMatchesModuleType_ExpectCorrectMessageSentToHMI) {
+ namespace json_keys = remote_control::json_keys;
+ // Arrange
+ application_manager::MessagePtr mobile_message = CreateBasicMessage();
+ mobile_message->set_json_message(kCorrectMobileRequest);
+ // Expectations
+ ON_CALL(*mock_app_, app_id())
+ .WillByDefault(Return(mobile_message->connection_key()));
+ EXPECT_CALL(*mock_service_, GetApplication(mobile_message->connection_key()))
+ .WillOnce(Return(mock_app_));
+ EXPECT_CALL(*mock_service_, ValidateMessageBySchema(*mobile_message))
+ .WillOnce(Return(application_manager::MessageValidationResult::SUCCESS));
+ EXPECT_CALL(*mock_service_, CheckPolicyPermissions(mobile_message))
+ .WillOnce(Return(mobile_apis::Result::eType::SUCCESS));
+ application_manager::AppExtensionPtr invalid_ext;
+ EXPECT_CALL(*mock_app_, QueryInterface(kModuleId))
+ .WillOnce(Return(invalid_ext))
+ .WillRepeatedly(Return(rc_app_extention_));
+ application_manager::AppExtensionPtr app_extension;
+ EXPECT_CALL(*mock_app_, AddExtension(_))
+ .WillOnce(DoAll(SaveArg<0>(&app_extension), Return(true)));
+ EXPECT_CALL(*mock_service_, CheckModule(_, _)).WillOnce(Return(true));
+ EXPECT_CALL(*mock_service_, GetNextCorrelationID()).WillOnce(Return(1));
+
+ const std::string resource = "CLIMATE";
+
+ EXPECT_CALL(mock_allocation_manager_, IsResourceFree(resource))
+ .WillOnce(Return(true));
+ EXPECT_CALL(mock_allocation_manager_, AcquireResource(resource, kAppId))
+ .WillOnce(Return(remote_control::AcquireResult::ALLOWED));
+ EXPECT_CALL(
+ mock_allocation_manager_,
+ SetResourceState(resource, kAppId, remote_control::ResourceState::BUSY));
+
+ application_manager::MessagePtr result_msg;
+ EXPECT_CALL(*mock_service_, SendMessageToHMI(_))
+ .WillOnce(SaveArg<0>(&result_msg));
+
+ // Act
+ remote_control::request_controller::MobileRequestPtr command =
+ CreateCommand(mobile_message);
+ command->Run();
+ // Assertions
+ EXPECT_EQ(kModuleId, app_extension->uid());
+ EXPECT_EQ(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_HMI,
+ result_msg->protocol_version());
+ EXPECT_EQ(1, result_msg->correlation_id());
+ EXPECT_EQ(application_manager::MessageType::kRequest, result_msg->type());
+ const Json::Value& hmi_request_params =
+ MessageHelper::StringToValue(result_msg->json_message());
+ EXPECT_EQ(functional_modules::hmi_api::button_press,
+ hmi_request_params[json_keys::kMethod].asString());
+}
+
+TEST_F(
+ ButtonPressRequestTest,
+ Execute_ButtonNameDoesNotMatchModuleType_ExpectMessageNotSentToHMI_AndFalseSentToMobile) {
+ namespace json_keys = remote_control::json_keys;
+ namespace result_codes = remote_control::result_codes;
+ // Arrange
+ application_manager::MessagePtr mobile_message = CreateBasicMessage();
+ mobile_message->set_json_message(kWrongMobileRequest);
+ // Expectations
+ EXPECT_CALL(*mock_service_, GetApplication(mobile_message->connection_key()))
+ .WillOnce(Return(mock_app_));
+ EXPECT_CALL(*mock_service_, ValidateMessageBySchema(*mobile_message))
+ .WillOnce(Return(application_manager::MessageValidationResult::SUCCESS));
+ EXPECT_CALL(*mock_service_, CheckPolicyPermissions(mobile_message))
+ .WillOnce(Return(mobile_apis::Result::eType::SUCCESS));
+ application_manager::AppExtensionPtr invalid_ext;
+ EXPECT_CALL(*mock_app_, QueryInterface(kModuleId))
+ .WillOnce(Return(invalid_ext))
+ .WillRepeatedly(Return(rc_app_extention_));
+ application_manager::AppExtensionPtr app_extension;
+ EXPECT_CALL(*mock_app_, AddExtension(_))
+ .WillOnce(DoAll(SaveArg<0>(&app_extension), Return(true)));
+ EXPECT_CALL(*mock_service_, CheckModule(_, _)).WillOnce(Return(true));
+ EXPECT_CALL(mock_allocation_manager_, IsResourceFree(_))
+ .WillOnce(Return(true));
+ EXPECT_CALL(mock_allocation_manager_, AcquireResource(_, _))
+ .WillOnce(Return(::remote_control::AcquireResult::ALLOWED));
+ EXPECT_CALL(*mock_service_, SendMessageToHMI(_)).Times(0);
+ application_manager::MessagePtr result_msg;
+ EXPECT_CALL(mock_module_, SendResponseToMobile(_))
+ .WillOnce(SaveArg<0>(&result_msg));
+ // Act
+ remote_control::request_controller::MobileRequestPtr command =
+ CreateCommand(mobile_message);
+ command->Run();
+ // Assertions
+ const Json::Value& response_params =
+ MessageHelper::StringToValue(result_msg->json_message());
+ EXPECT_FALSE(response_params[result_codes::kSuccess].asBool());
+ EXPECT_EQ(result_codes::kInvalidData,
+ response_params[json_keys::kResultCode].asString());
+}
+
+TEST_F(ButtonPressRequestTest, OnEvent_ExpectSuccessfullResponseSentToMobile) {
+ namespace json_keys = remote_control::json_keys;
+ namespace result_codes = remote_control::result_codes;
+ // Arrange
+ application_manager::MessagePtr mobile_message = CreateBasicMessage();
+ mobile_message->set_json_message(kCorrectMobileRequest);
+
+ application_manager::MessagePtr hmi_message = CreateBasicMessage();
+ hmi_message->set_json_message(kValidHmiResponse);
+ hmi_message->set_message_type(application_manager::MessageType::kResponse);
+ // Expectations
+ EXPECT_CALL(*mock_service_, GetApplication(mobile_message->connection_key()))
+ .WillOnce(Return(mock_app_));
+ application_manager::MessagePtr result_msg;
+ EXPECT_CALL(mock_module_, SendResponseToMobile(_))
+ .WillOnce(SaveArg<0>(&result_msg));
+ // Act
+ remote_control::RCPluginEvent event(
+ hmi_message, functional_modules::hmi_api::button_press);
+ remote_control::request_controller::MobileRequestPtr command =
+ CreateCommand(mobile_message);
+ command->on_event(event);
+ // Assertions
+ const Json::Value& response_params =
+ MessageHelper::StringToValue(result_msg->json_message());
+ EXPECT_TRUE(response_params[json_keys::kSuccess].asBool());
+ EXPECT_EQ(result_codes::kSuccess,
+ response_params[json_keys::kResultCode].asString());
+}
+
+TEST_F(ButtonPressRequestTest,
+ OnEvent_ReadOnlyParamFromHMI_ExpectFalseSentToMobile) {
+ namespace json_keys = remote_control::json_keys;
+ namespace result_codes = remote_control::result_codes;
+ // Arrange
+ application_manager::MessagePtr mobile_message = CreateBasicMessage();
+ mobile_message->set_json_message(kCorrectMobileRequest);
+
+ application_manager::MessagePtr hmi_message = CreateBasicMessage();
+ hmi_message->set_json_message(KReadOnlyHmiResponse);
+ hmi_message->set_message_type(application_manager::MessageType::kResponse);
+ // Expectations
+ EXPECT_CALL(*mock_service_, GetApplication(mobile_message->connection_key()))
+ .WillOnce(Return(mock_app_));
+ application_manager::MessagePtr result_msg;
+ EXPECT_CALL(mock_module_, SendResponseToMobile(_))
+ .WillOnce(SaveArg<0>(&result_msg));
+ // Act
+ remote_control::RCPluginEvent event(
+ hmi_message, functional_modules::hmi_api::button_press);
+ remote_control::request_controller::MobileRequestPtr command =
+ CreateCommand(mobile_message);
+ command->on_event(event);
+ // Assertions
+ const Json::Value& response_params =
+ MessageHelper::StringToValue(result_msg->json_message());
+ EXPECT_FALSE(response_params[json_keys::kSuccess].asBool());
+ EXPECT_EQ(result_codes::kGenericError,
+ response_params[json_keys::kResultCode].asString());
+}
+
+} // namespace button_press_request_test
+} // namespace remote_control_test
+} // namespace components
+} // namespace test
diff --git a/src/components/remote_control/test/commands/get_interior_vehicle_data_request_test.cc b/src/components/remote_control/test/commands/get_interior_vehicle_data_request_test.cc
new file mode 100644
index 0000000000..4ad833aa60
--- /dev/null
+++ b/src/components/remote_control/test/commands/get_interior_vehicle_data_request_test.cc
@@ -0,0 +1,291 @@
+/*
+ * 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.
+ */
+
+#include "remote_control/commands/get_interior_vehicle_data_request.h"
+#include "gtest/gtest.h"
+#include "mock_remote_control_plugin.h"
+#include "mock_application.h"
+#include "remote_control/rc_app_extension.h"
+#include "remote_control/remote_control_event.h"
+#include "remote_control/rc_module_constants.h"
+#include "remote_control/message_helper.h"
+#include "remote_control/rc_command_factory.h"
+#include "remote_control/event_engine/event_dispatcher.h"
+#include "functional_module/function_ids.h"
+#include "include/mock_service.h"
+#include "utils/shared_ptr.h"
+#include "utils/make_shared.h"
+
+using functional_modules::RCFunctionID;
+using application_manager::ServicePtr;
+
+using application_manager::MockService;
+using test::components::remote_control_test::MockApplication;
+
+using ::testing::_;
+using ::testing::Mock;
+using ::testing::NiceMock;
+using ::testing::StrictMock;
+using ::testing::Return;
+using ::testing::ReturnRef;
+using ::testing::SaveArg;
+using ::application_manager::Message;
+using ::application_manager::MessageType;
+using ::application_manager::ApplicationSharedPtr;
+using ::protocol_handler::MessagePriority;
+using remote_control::RemotePluginInterface;
+using remote_control::MessageHelper;
+using namespace remote_control;
+
+namespace {
+const int32_t kConnectionKey = 5;
+const int kModuleId = 153;
+const std::string kInvalidMobileRequest = "{{\"moduleTip\":\"LUXOFT\"}}";
+const std::string kValidMobileRequest =
+ "{\"subscribe\":true,\"moduleDescription\":{\"moduleType\":\"CLIMATE\"}}";
+const std::string kValidHmiResponse =
+ "{\"jsonrpc\":\"2.0\",\"id\":51,\"result\":{\"code\":0,\"method\":\"RC."
+ "GetInteriorVehicleData\",\"moduleData\":{\"moduleType\":\"CLIMATE\","
+ "\"climateControlData\":{\"fanSpeed\":0,\"currentTemperature\":{\"unit\":"
+ "\"CELSIUS\",\"value\":20},\"desiredTemperature\":{\"unit\":\"CELSIUS\","
+ "\"value\":25},\"acEnable\":true,\"circulateAirEnable\":true,"
+ "\"autoModeEnable\":true,\"defrostZone\":\"ALL\",\"dualModeEnable\":true,"
+ "\"acMaxEnable\":true,\"ventilationMode\":\"BOTH\"}},\"isSubscribed\":"
+ "true}}";
+const std::string kInvalidHmiResponse =
+ "{\"jsonrpc\":\"2.0\",\"id\":51,\"result\":{\"code\":21,\"method\":\"RC."
+ "GetInteriorVehicleData\",\"moduleData\":{\"moduleType\":\"CLIMATE\","
+ "\"ControlData\":{\"Speed\":0,\"outsideTemperature\":{\"unit\":"
+ "\"CELSIUS\",\"value\":\"high\"},\"desiredTemperature\":{\"unit\":"
+ "\"CELSIUS\","
+ "\"value\":25},\"acEnable\":true,\"circulateAirEnable\":true,"
+ "\"autoModeEnable\":true,\"defrostZone\":\"ALL\",\"dualModeEnable\":true,"
+ "\"acMaxEnable\":true,\"ventilationMode\":\"BOTH\"}},\"isSubscribed\":"
+ "false}}";
+}
+
+namespace test {
+namespace components {
+namespace remote_control_test {
+namespace get_interior_vehicle_data_request_test {
+
+class GetInteriorVehicleDataRequestTest : public ::testing::Test {
+ public:
+ typedef utils::SharedPtr<remote_control::commands::BaseCommandRequest>
+ GIVDRequestPtr;
+ typedef rc_event_engine::Event<application_manager::MessagePtr, std::string>
+ GIVD_HMI_Response;
+ GetInteriorVehicleDataRequestTest()
+ : mock_service_(utils::MakeShared<NiceMock<MockService> >())
+ , mock_app_(utils::MakeShared<NiceMock<MockApplication> >())
+ , rc_app_extention_(
+ utils::MakeShared<remote_control::RCAppExtension>(kModuleId)) {
+ ON_CALL(*mock_app_, app_id()).WillByDefault(Return(app_id_));
+ ON_CALL(mock_module_, service()).WillByDefault(Return(mock_service_));
+ ON_CALL(*mock_service_, GetApplication(app_id_))
+ .WillByDefault(Return(mock_app_));
+ ON_CALL(*mock_service_, IsInterfaceAvailable(_))
+ .WillByDefault(Return(true));
+ ON_CALL(*mock_service_, IsRemoteControlApplication(_))
+ .WillByDefault(Return(true));
+ EXPECT_CALL(mock_module_, event_dispatcher())
+ .WillRepeatedly(ReturnRef(event_dispatcher_));
+ ServicePtr exp_service(mock_service_);
+ mock_module_.set_service(exp_service);
+ }
+
+ remote_control::request_controller::MobileRequestPtr CreateCommand(
+ application_manager::MessagePtr msg) {
+ return remote_control::RCCommandFactory::CreateCommand(msg, mock_module_);
+ }
+
+ application_manager::MessagePtr CreateBasicMessage() {
+ application_manager::MessagePtr message = utils::MakeShared<Message>(
+ MessagePriority::FromServiceType(protocol_handler::ServiceType::kRpc));
+ message->set_connection_key(kConnectionKey);
+ message->set_function_id(RCFunctionID::GET_INTERIOR_VEHICLE_DATA);
+ message->set_function_name("GetInteriorVehicleData");
+ return message;
+ }
+
+ protected:
+ utils::SharedPtr<NiceMock<application_manager::MockService> > mock_service_;
+ utils::SharedPtr<NiceMock<MockApplication> > mock_app_;
+ utils::SharedPtr<remote_control::RCAppExtension> rc_app_extention_;
+ remote_control_test::MockRemotePluginInterface mock_module_;
+ RemotePluginInterface::RCPluginEventDispatcher event_dispatcher_;
+ const uint32_t app_id_ = 11u;
+};
+
+TEST_F(GetInteriorVehicleDataRequestTest,
+ Execute_MessageValidationOk_ExpectCorrectMessageSentToHMI) {
+ // Arrange
+ application_manager::MessagePtr mobile_message = CreateBasicMessage();
+ mobile_message->set_json_message(kValidMobileRequest);
+ // Expectations
+ EXPECT_CALL(mock_module_, service()).Times(2).WillOnce(Return(mock_service_));
+ EXPECT_CALL(*mock_service_, GetApplication(mobile_message->connection_key()))
+ .WillOnce(Return(mock_app_));
+ EXPECT_CALL(*mock_service_, ValidateMessageBySchema(*mobile_message))
+ .WillOnce(Return(application_manager::MessageValidationResult::SUCCESS));
+ EXPECT_CALL(*mock_service_, CheckPolicyPermissions(mobile_message))
+ .WillOnce(Return(mobile_apis::Result::eType::SUCCESS));
+ application_manager::AppExtensionPtr invalid_ext;
+ EXPECT_CALL(*mock_app_, QueryInterface(kModuleId))
+ .WillOnce(Return(invalid_ext))
+ .WillRepeatedly(Return(rc_app_extention_));
+ application_manager::AppExtensionPtr app_extension;
+ EXPECT_CALL(*mock_app_, AddExtension(_))
+ .WillOnce(DoAll(SaveArg<0>(&app_extension), Return(true)));
+ EXPECT_CALL(*mock_service_, CheckModule(_, _)).WillOnce(Return(true));
+ EXPECT_CALL(*mock_service_, GetNextCorrelationID()).WillOnce(Return(1));
+ application_manager::MessagePtr result_msg;
+ EXPECT_CALL(*mock_service_, SendMessageToHMI(_))
+ .WillOnce(SaveArg<0>(&result_msg));
+ // Act
+ remote_control::request_controller::MobileRequestPtr command =
+ CreateCommand(mobile_message);
+ command->Run();
+ // Assertions
+ EXPECT_EQ(kModuleId, app_extension->uid());
+ EXPECT_EQ(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_HMI,
+ result_msg->protocol_version());
+ EXPECT_EQ(1, result_msg->correlation_id());
+ EXPECT_EQ(application_manager::MessageType::kRequest, result_msg->type());
+ const Json::Value hmi_request_params =
+ MessageHelper::StringToValue(result_msg->json_message());
+ EXPECT_EQ(functional_modules::hmi_api::get_interior_vehicle_data,
+ hmi_request_params[json_keys::kMethod].asString());
+}
+
+TEST_F(
+ GetInteriorVehicleDataRequestTest,
+ Execute_MessageValidationFailed_ExpectMessageNotSentToHMI_AndFalseSentToMobile) {
+ // Arrange
+ application_manager::MessagePtr mobile_message = CreateBasicMessage();
+ mobile_message->set_json_message(kInvalidMobileRequest);
+ // Expectations
+ EXPECT_CALL(mock_module_, service()).WillOnce(Return(mock_service_));
+ EXPECT_CALL(*mock_service_, GetApplication(mobile_message->connection_key()))
+ .WillOnce(Return(mock_app_));
+ EXPECT_CALL(*mock_service_, ValidateMessageBySchema(*mobile_message))
+ .WillOnce(
+ Return(application_manager::MessageValidationResult::INVALID_JSON));
+ EXPECT_CALL(*mock_service_, SendMessageToHMI(_)).Times(0);
+ application_manager::MessagePtr result_msg;
+ EXPECT_CALL(mock_module_, SendResponseToMobile(_))
+ .WillOnce(SaveArg<0>(&result_msg));
+ // Act
+ remote_control::request_controller::MobileRequestPtr command =
+ CreateCommand(mobile_message);
+ command->Run();
+ // Assertions
+ const Json::Value response_params =
+ MessageHelper::StringToValue(result_msg->json_message());
+ EXPECT_FALSE(response_params[result_codes::kSuccess].asBool());
+ EXPECT_EQ(result_codes::kInvalidData,
+ response_params[json_keys::kResultCode].asString());
+}
+
+TEST_F(GetInteriorVehicleDataRequestTest,
+ OnEvent_ValidHmiResponse_ExpectSuccessfullResponseSentToMobile) {
+ // Arrange
+ application_manager::MessagePtr mobile_message = CreateBasicMessage();
+ mobile_message->set_json_message(kValidMobileRequest);
+
+ application_manager::MessagePtr hmi_message = CreateBasicMessage();
+ hmi_message->set_json_message(kValidHmiResponse);
+ hmi_message->set_message_type(application_manager::MessageType::kResponse);
+ // Expectations
+ EXPECT_CALL(mock_module_, service()).WillOnce(Return(mock_service_));
+ EXPECT_CALL(*mock_service_, GetApplication(mobile_message->connection_key()))
+ .WillOnce(Return(mock_app_));
+ EXPECT_CALL(*mock_service_, ValidateMessageBySchema(*hmi_message))
+ .WillOnce(Return(application_manager::MessageValidationResult::SUCCESS));
+ EXPECT_CALL(*mock_app_, QueryInterface(kModuleId))
+ .WillOnce(Return(rc_app_extention_));
+ application_manager::MessagePtr result_msg;
+ EXPECT_CALL(mock_module_, SendResponseToMobile(_))
+ .WillOnce(SaveArg<0>(&result_msg));
+ // Act
+ remote_control::RCPluginEvent event(
+ hmi_message, functional_modules::hmi_api::get_interior_vehicle_data);
+ remote_control::request_controller::MobileRequestPtr command =
+ CreateCommand(mobile_message);
+ command->on_event(event);
+ // Assertions
+ const Json::Value response_params =
+ MessageHelper::StringToValue(result_msg->json_message());
+ EXPECT_TRUE(response_params[json_keys::kSuccess].asBool());
+ EXPECT_EQ(result_codes::kSuccess,
+ response_params[json_keys::kResultCode].asString());
+}
+
+TEST_F(GetInteriorVehicleDataRequestTest,
+ OnEvent_InvalidHmiResponse_ExpectGenericErrorResponseSentToMobile) {
+ // Arrange
+ application_manager::MessagePtr mobile_message = CreateBasicMessage();
+ mobile_message->set_json_message(kValidMobileRequest);
+ application_manager::MessagePtr hmi_message = CreateBasicMessage();
+ hmi_message->set_json_message(kInvalidHmiResponse);
+ hmi_message->set_message_type(application_manager::MessageType::kResponse);
+ // Expectations
+ EXPECT_CALL(mock_module_, service()).WillOnce(Return(mock_service_));
+ EXPECT_CALL(*mock_service_, GetApplication(mobile_message->connection_key()))
+ .WillOnce(Return(mock_app_));
+ EXPECT_CALL(*mock_service_, ValidateMessageBySchema(*hmi_message))
+ .WillOnce(
+ Return(application_manager::MessageValidationResult::INVALID_JSON));
+ application_manager::MessagePtr result_msg;
+ EXPECT_CALL(mock_module_, SendResponseToMobile(_))
+ .WillOnce(SaveArg<0>(&result_msg));
+ // Act
+ remote_control::request_controller::MobileRequestPtr command =
+ CreateCommand(mobile_message);
+ remote_control::RCPluginEvent event(
+ hmi_message, functional_modules::hmi_api::get_interior_vehicle_data);
+ command->on_event(event);
+ const Json::Value response_params =
+ MessageHelper::StringToValue(result_msg->json_message());
+ EXPECT_FALSE(response_params[json_keys::kSuccess].asBool());
+ EXPECT_EQ(result_codes::kGenericError,
+ response_params[json_keys::kResultCode].asString());
+ const Json::Value hmi_response =
+ MessageHelper::StringToValue(hmi_message->json_message());
+ EXPECT_EQ(hmi_response[json_keys::kInfo].asString(),
+ response_params[json_keys::kInfo].asString());
+}
+
+} // namespace get_interior_vehicle_data_request_test
+} // namespace remote_control_test
+} // namespace components
+} // namespace test
diff --git a/src/components/remote_control/test/commands/on_interior_vehicle_data_notification_test.cc b/src/components/remote_control/test/commands/on_interior_vehicle_data_notification_test.cc
new file mode 100644
index 0000000000..7329890e94
--- /dev/null
+++ b/src/components/remote_control/test/commands/on_interior_vehicle_data_notification_test.cc
@@ -0,0 +1,182 @@
+/*
+ * 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.
+ */
+
+#include "remote_control/commands/on_interior_vehicle_data_notification.h"
+#include "gtest/gtest.h"
+#include "mock_remote_control_plugin.h"
+#include "mock_application.h"
+#include "remote_control/rc_app_extension.h"
+#include "remote_control/remote_control_event.h"
+#include "remote_control/rc_module_constants.h"
+#include "remote_control/message_helper.h"
+#include "remote_control/rc_command_factory.h"
+#include "remote_control/event_engine/event_dispatcher.h"
+#include "functional_module/function_ids.h"
+#include "include/mock_service.h"
+#include "utils/shared_ptr.h"
+#include "utils/make_shared.h"
+
+using functional_modules::RCFunctionID;
+using application_manager::ServicePtr;
+
+using application_manager::MockService;
+using test::components::remote_control_test::MockApplication;
+
+using ::testing::_;
+using ::testing::Mock;
+using ::testing::NiceMock;
+using ::testing::Return;
+using ::testing::SaveArg;
+using ::application_manager::Message;
+using ::application_manager::MessageType;
+using ::application_manager::ApplicationSharedPtr;
+using ::protocol_handler::MessagePriority;
+using remote_control::RemotePluginInterface;
+using remote_control::MessageHelper;
+using namespace remote_control;
+
+namespace {
+const int kModuleId = 153;
+const std::string kJson =
+ "{ \"jsonrpc\": \"2.0\",\"method\": \"RC.OnInteriorVehicleData\",\
+ \"params\":{\"moduleData\":{\
+ \"moduleType\": \"CLIMATE\",\"climateControlData\": {\"fanSpeed\": 100}}}}";
+const uint32_t kAppId_ = 11u;
+}
+
+namespace test {
+namespace components {
+namespace remote_control_test {
+namespace on_interior_vehicle_data_notification_test {
+
+class OnInteriorVehicleDataNotificationTest : public ::testing::Test {
+ public:
+ OnInteriorVehicleDataNotificationTest()
+ : mock_service_(utils::MakeShared<NiceMock<MockService> >())
+ , mock_app_(utils::MakeShared<NiceMock<MockApplication> >())
+ , rc_app_extention_(
+ utils::MakeShared<remote_control::RCAppExtension>(kModuleId)) {
+ ON_CALL(mock_module_, service()).WillByDefault(Return(mock_service_));
+ ServicePtr exp_service(mock_service_);
+ mock_module_.set_service(exp_service);
+ }
+
+ remote_control::request_controller::MobileRequestPtr CreateCommand(
+ application_manager::MessagePtr msg) {
+ return remote_control::RCCommandFactory::CreateCommand(msg, mock_module_);
+ }
+
+ application_manager::MessagePtr CreateBasicMessage() {
+ application_manager::MessagePtr message = utils::MakeShared<Message>(
+ MessagePriority::FromServiceType(protocol_handler::ServiceType::kRpc));
+ message->set_function_id(RCFunctionID::ON_INTERIOR_VEHICLE_DATA);
+ message->set_function_name("OnInteriorVehicleData");
+ message->set_json_message(kJson);
+ return message;
+ }
+
+ protected:
+ utils::SharedPtr<NiceMock<application_manager::MockService> > mock_service_;
+ utils::SharedPtr<NiceMock<MockApplication> > mock_app_;
+ utils::SharedPtr<remote_control::RCAppExtension> rc_app_extention_;
+ remote_control_test::MockRemotePluginInterface mock_module_;
+ std::vector<ApplicationSharedPtr> apps_;
+};
+
+TEST_F(OnInteriorVehicleDataNotificationTest,
+ Execute_SendMessageToMobile_IfAppIsSubscribed) {
+ // Arrange
+ application_manager::MessagePtr message = CreateBasicMessage();
+ Json::Value json_value = MessageHelper::StringToValue(kJson);
+ Json::Value module_type =
+ json_value[json_keys::kParams][message_params::kModuleData]
+ [message_params::kModuleType];
+ rc_app_extention_->SubscribeToInteriorVehicleData(module_type);
+ apps_.push_back(mock_app_);
+ // Expectations
+ EXPECT_CALL(mock_module_, service()).WillOnce(Return(mock_service_));
+ EXPECT_CALL(*mock_service_, GetApplications(kModuleId))
+ .WillOnce(Return(apps_));
+ EXPECT_CALL(*mock_app_, QueryInterface(kModuleId))
+ .WillOnce(Return(rc_app_extention_));
+
+ ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId_));
+ EXPECT_CALL(*mock_app_, protocol_version())
+ .WillRepeatedly(
+ Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_3));
+ EXPECT_CALL(*mock_service_, GetApplication(kAppId_))
+ .WillOnce(Return(mock_app_));
+ EXPECT_CALL(*mock_service_, CheckPolicyPermissions(_))
+ .WillOnce(Return(mobile_apis::Result::eType::SUCCESS));
+ EXPECT_CALL(*mock_service_, CheckModule(kAppId_, enums_value::kClimate))
+ .WillOnce(Return(true));
+ application_manager::MessagePtr result_msg;
+ EXPECT_CALL(*mock_service_, SendMessageToMobile(_))
+ .WillOnce(SaveArg<0>(&result_msg));
+ // Act
+ remote_control::request_controller::MobileRequestPtr command =
+ CreateCommand(message);
+ command->Run();
+ // Assertions
+ EXPECT_EQ(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_3,
+ result_msg->protocol_version());
+ EXPECT_EQ(application_manager::MessageType::kNotification,
+ result_msg->type());
+ EXPECT_EQ(functional_modules::ON_INTERIOR_VEHICLE_DATA,
+ result_msg->function_id());
+ EXPECT_EQ(MessageHelper::GetMobileAPIName(
+ functional_modules::ON_INTERIOR_VEHICLE_DATA),
+ result_msg->function_name());
+}
+
+TEST_F(OnInteriorVehicleDataNotificationTest,
+ Execute_NotSendMessageToMobile_IfAppUnsubscribed) {
+ // Arrange
+ application_manager::MessagePtr message = CreateBasicMessage();
+ apps_.push_back(mock_app_);
+ // Expectations
+ EXPECT_CALL(mock_module_, service()).WillOnce(Return(mock_service_));
+ EXPECT_CALL(*mock_service_, GetApplications(kModuleId))
+ .WillOnce(Return(apps_));
+ EXPECT_CALL(*mock_app_, QueryInterface(kModuleId))
+ .WillOnce(Return(rc_app_extention_));
+ EXPECT_CALL(*mock_service_, SendMessageToMobile(_)).Times(0);
+ // Act
+ remote_control::request_controller::MobileRequestPtr command =
+ CreateCommand(message);
+ command->Run();
+}
+
+} // namespace on_interior_vehicle_data_notification_test
+} // namespace remote_control_test
+} // namespace components
+} // namespace test
diff --git a/src/components/remote_control/test/commands/on_remote_control_settings_test.cc b/src/components/remote_control/test/commands/on_remote_control_settings_test.cc
new file mode 100644
index 0000000000..5c13ea63d5
--- /dev/null
+++ b/src/components/remote_control/test/commands/on_remote_control_settings_test.cc
@@ -0,0 +1,326 @@
+/*
+ * 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.
+ */
+
+#include "remote_control/commands/on_remote_control_settings_notification.h"
+#include "gtest/gtest.h"
+#include "mock_remote_control_plugin.h"
+#include "mock_application.h"
+#include "mock_resource_allocation_manager.h"
+#include "remote_control/rc_app_extension.h"
+#include "remote_control/remote_control_event.h"
+#include "remote_control/rc_module_constants.h"
+#include "remote_control/message_helper.h"
+#include "remote_control/rc_command_factory.h"
+#include "remote_control/event_engine/event_dispatcher.h"
+#include "functional_module/function_ids.h"
+#include "include/mock_service.h"
+#include "utils/shared_ptr.h"
+#include "utils/make_shared.h"
+
+using functional_modules::RCFunctionID;
+using application_manager::ServicePtr;
+
+using application_manager::MockService;
+using test::components::remote_control_test::MockApplication;
+
+using ::testing::_;
+using ::testing::Mock;
+using ::testing::NiceMock;
+using ::testing::Return;
+using ::testing::ReturnRef;
+using ::testing::SaveArg;
+using ::application_manager::Message;
+using ::application_manager::MessageType;
+using ::application_manager::ApplicationSharedPtr;
+using ::protocol_handler::MessagePriority;
+using remote_control::RemotePluginInterface;
+using remote_control::MessageHelper;
+using namespace remote_control;
+
+namespace {
+const int kModuleId = 153;
+const std::string kAllowedTrueAUTO_ALLOWJson =
+ "{ \"jsonrpc\": \"2.0\",\"method\": \"RC.OnRemoteControlSettings\",\
+ \"params\":{\"accessMode\": \"AUTO_ALLOW\", \"allowed\":true}}";
+const std::string kAllowedTrueASK_DRIVERJson =
+ "{ \"jsonrpc\": \"2.0\",\"method\": \"RC.OnRemoteControlSettings\",\
+ \"params\":{\"accessMode\": \"ASK_DRIVER\", \"allowed\":true}}";
+const std::string kAllowedTrueAUTO_DENYJson =
+ "{ \"jsonrpc\": \"2.0\",\"method\": \"RC.OnRemoteControlSettings\",\
+ \"params\":{\"accessMode\": \"AUTO_DENY\", \"allowed\":true}}";
+const std::string kAllowedFalseAUTO_ALLOWJson =
+ "{ \"jsonrpc\": \"2.0\",\"method\": \"RC.OnRemoteControlSettings\",\
+ \"params\":{\"accessMode\": \"AUTO_ALLOW\", \"allowed\":false}}";
+const std::string kAllowedFalseASK_DRIVERJson =
+ "{ \"jsonrpc\": \"2.0\",\"method\": \"RC.OnRemoteControlSettings\",\
+ \"params\":{\"accessMode\": \"ASK_DRIVER\", \"allowed\":false}}";
+const std::string kAllowedFalseAUTO_DENYJson =
+ "{ \"jsonrpc\": \"2.0\",\"method\": \"RC.OnRemoteControlSettings\",\
+ \"params\":{\"accessMode\": \"AUTO_DENY\", \"allowed\":false}}";
+const std::string kWithoutParamsJson =
+ "{ \"jsonrpc\": \"2.0\",\"method\": \"RC.OnRemoteControlSettings\"}";
+}
+
+namespace test {
+namespace components {
+namespace remote_control_test {
+namespace on_remote_control_settings_notification_test {
+
+class OnRemoteControlSettingsNotificationTest : public ::testing::Test {
+ public:
+ OnRemoteControlSettingsNotificationTest()
+ : mock_service_(utils::MakeShared<NiceMock<MockService> >())
+ , mock_app_(utils::MakeShared<NiceMock<MockApplication> >())
+ , rc_app_extention_(
+ utils::MakeShared<remote_control::RCAppExtension>(kModuleId)) {
+ ON_CALL(mock_module_, resource_allocation_manager())
+ .WillByDefault(ReturnRef(mock_allocation_manager_));
+ ON_CALL(*mock_service_, IsInterfaceAvailable(_))
+ .WillByDefault(Return(true));
+ ON_CALL(*mock_service_, IsRemoteControlApplication(_))
+ .WillByDefault(Return(true));
+ apps_.push_back(mock_app_);
+ }
+
+ remote_control::request_controller::MobileRequestPtr CreateCommand(
+ application_manager::MessagePtr msg) {
+ return remote_control::RCCommandFactory::CreateCommand(msg, mock_module_);
+ }
+
+ application_manager::MessagePtr CreateBasicMessage(
+ const std::string& json_message) {
+ application_manager::MessagePtr message = utils::MakeShared<Message>(
+ MessagePriority::FromServiceType(protocol_handler::ServiceType::kRpc));
+ message->set_function_id(RCFunctionID::ON_REMOTE_CONTROL_SETTINGS);
+ message->set_function_name(
+ MessageHelper::GetMobileAPIName(functional_modules::BUTTON_PRESS));
+ message->set_json_message(json_message);
+ return message;
+ }
+
+ protected:
+ utils::SharedPtr<NiceMock<application_manager::MockService> > mock_service_;
+ utils::SharedPtr<NiceMock<MockApplication> > mock_app_;
+ utils::SharedPtr<remote_control::RCAppExtension> rc_app_extention_;
+ remote_control_test::MockRemotePluginInterface mock_module_;
+ std::vector<ApplicationSharedPtr> apps_;
+ testing::NiceMock<remote_control_test::MockResourceAllocationManager>
+ mock_allocation_manager_;
+};
+
+TEST_F(OnRemoteControlSettingsNotificationTest,
+ Execute_SetAccessModeAUTO_ALLOW_IfAllowedTrue) {
+ // Arrange
+ const Json::Value value =
+ MessageHelper::StringToValue(kAllowedTrueAUTO_ALLOWJson);
+ const std::string access_mode =
+ value[json_keys::kParams][message_params::kAccessMode].asString();
+ const hmi_apis::Common_RCAccessMode::eType access_mode_ =
+ MessageHelper::AccessModeFromString(access_mode);
+ // Expectations
+ EXPECT_CALL(mock_module_, service()).WillOnce(Return(mock_service_));
+ EXPECT_CALL(mock_allocation_manager_, SetAccessMode(access_mode_));
+
+ application_manager::MessagePtr message =
+ CreateBasicMessage(kAllowedTrueAUTO_ALLOWJson);
+ // Act
+ remote_control::request_controller::MobileRequestPtr command =
+ CreateCommand(message);
+ command->Run();
+}
+
+TEST_F(OnRemoteControlSettingsNotificationTest,
+ Execute_SetAccessModeAUTO_DENY_IfAllowedTrue) {
+ // Arrange
+ const Json::Value value =
+ MessageHelper::StringToValue(kAllowedTrueAUTO_DENYJson);
+ const std::string access_mode =
+ value[json_keys::kParams][message_params::kAccessMode].asString();
+ const hmi_apis::Common_RCAccessMode::eType access_mode_ =
+ MessageHelper::AccessModeFromString(access_mode);
+ // Expectations
+ EXPECT_CALL(mock_module_, service()).WillOnce(Return(mock_service_));
+ EXPECT_CALL(mock_allocation_manager_, SetAccessMode(access_mode_));
+
+ application_manager::MessagePtr message =
+ CreateBasicMessage(kAllowedTrueAUTO_DENYJson);
+ // Act
+ remote_control::request_controller::MobileRequestPtr command =
+ CreateCommand(message);
+ command->Run();
+}
+
+TEST_F(OnRemoteControlSettingsNotificationTest,
+ Execute_SetAccessModeASK_DRIVER_IfAllowedTrue) {
+ // Arrange
+ const Json::Value value =
+ MessageHelper::StringToValue(kAllowedTrueASK_DRIVERJson);
+ const std::string access_mode =
+ value[json_keys::kParams][message_params::kAccessMode].asString();
+ const hmi_apis::Common_RCAccessMode::eType access_mode_ =
+ MessageHelper::AccessModeFromString(access_mode);
+ // Expectations
+ EXPECT_CALL(mock_module_, service()).WillOnce(Return(mock_service_));
+ EXPECT_CALL(mock_allocation_manager_, SetAccessMode(access_mode_));
+ application_manager::MessagePtr message =
+ CreateBasicMessage(kAllowedTrueASK_DRIVERJson);
+ // Act
+ remote_control::request_controller::MobileRequestPtr command =
+ CreateCommand(message);
+ command->Run();
+}
+
+TEST_F(OnRemoteControlSettingsNotificationTest,
+ Execute_DisallowRCFunctionality_IfAllowedFalseAccessModeAUTO_ALLOW) {
+ // Arrange
+ const Json::Value module_type(enums_value::kClimate);
+ rc_app_extention_->SubscribeToInteriorVehicleData(module_type);
+ const Json::Value value =
+ MessageHelper::StringToValue(kAllowedFalseAUTO_ALLOWJson);
+ const std::string access_mode =
+ value[json_keys::kParams][message_params::kAccessMode].asString();
+ const hmi_apis::Common_RCAccessMode::eType access_mode_ =
+ MessageHelper::AccessModeFromString(access_mode);
+ // Expectations
+ EXPECT_CALL(mock_module_, service()).WillOnce(Return(mock_service_));
+ EXPECT_CALL(mock_allocation_manager_, SetAccessMode(access_mode_)).Times(0);
+ EXPECT_CALL(*mock_service_, GetApplications(kModuleId))
+ .WillOnce(Return(apps_));
+ EXPECT_CALL(
+ *mock_service_,
+ ChangeNotifyHMILevel(apps_[0], mobile_apis::HMILevel::eType::HMI_NONE));
+ EXPECT_CALL(*mock_app_, QueryInterface(kModuleId))
+ .WillOnce(Return(rc_app_extention_));
+ EXPECT_EQ(rc_app_extention_->IsSubscibedToInteriorVehicleData(module_type),
+ true);
+ application_manager::MessagePtr message =
+ CreateBasicMessage(kAllowedFalseAUTO_ALLOWJson);
+ // Act
+ remote_control::request_controller::MobileRequestPtr command =
+ CreateCommand(message);
+ command->Run();
+ // Assertions
+ EXPECT_EQ(rc_app_extention_->IsSubscibedToInteriorVehicleData(module_type),
+ false);
+}
+
+TEST_F(OnRemoteControlSettingsNotificationTest,
+ Execute_DisallowRCFunctionality_IfAllowedFalseAccessModeASK_DRIVER) {
+ // Arrange
+ const Json::Value module_type(enums_value::kRadio);
+ rc_app_extention_->SubscribeToInteriorVehicleData(module_type);
+ const Json::Value value =
+ MessageHelper::StringToValue(kAllowedFalseASK_DRIVERJson);
+ const std::string access_mode =
+ value[json_keys::kParams][message_params::kAccessMode].asString();
+ const hmi_apis::Common_RCAccessMode::eType access_mode_ =
+ MessageHelper::AccessModeFromString(access_mode);
+ // Expectations
+ EXPECT_CALL(mock_module_, service()).WillOnce(Return(mock_service_));
+ EXPECT_CALL(mock_allocation_manager_, SetAccessMode(access_mode_)).Times(0);
+ EXPECT_CALL(*mock_service_, GetApplications(kModuleId))
+ .WillOnce(Return(apps_));
+ EXPECT_CALL(
+ *mock_service_,
+ ChangeNotifyHMILevel(apps_[0], mobile_apis::HMILevel::eType::HMI_NONE));
+ EXPECT_CALL(*mock_app_, QueryInterface(kModuleId))
+ .WillOnce(Return(rc_app_extention_));
+ EXPECT_EQ(rc_app_extention_->IsSubscibedToInteriorVehicleData(module_type),
+ true);
+ application_manager::MessagePtr message =
+ CreateBasicMessage(kAllowedFalseASK_DRIVERJson);
+ // Act
+ remote_control::request_controller::MobileRequestPtr command =
+ CreateCommand(message);
+ command->Run();
+ // Assertions
+ EXPECT_EQ(rc_app_extention_->IsSubscibedToInteriorVehicleData(module_type),
+ false);
+}
+
+TEST_F(OnRemoteControlSettingsNotificationTest,
+ Execute_DisallowRCFunctionality_IfAllowedFalseAccessModeAUTO_DENY) {
+ // Arrange
+ const Json::Value module_type(enums_value::kClimate);
+ rc_app_extention_->SubscribeToInteriorVehicleData(module_type);
+ const Json::Value value =
+ MessageHelper::StringToValue(kAllowedFalseAUTO_DENYJson);
+ const std::string access_mode =
+ value[json_keys::kParams][message_params::kAccessMode].asString();
+ const hmi_apis::Common_RCAccessMode::eType access_mode_ =
+ MessageHelper::AccessModeFromString(access_mode);
+ // Expectations
+ EXPECT_CALL(mock_module_, service()).WillOnce(Return(mock_service_));
+ EXPECT_CALL(mock_allocation_manager_, SetAccessMode(access_mode_)).Times(0);
+ EXPECT_CALL(*mock_service_, GetApplications(kModuleId))
+ .WillOnce(Return(apps_));
+ EXPECT_CALL(
+ *mock_service_,
+ ChangeNotifyHMILevel(apps_[0], mobile_apis::HMILevel::eType::HMI_NONE));
+ EXPECT_CALL(*mock_app_, QueryInterface(kModuleId))
+ .WillOnce(Return(rc_app_extention_));
+ EXPECT_EQ(rc_app_extention_->IsSubscibedToInteriorVehicleData(module_type),
+ true);
+ application_manager::MessagePtr message =
+ CreateBasicMessage(kAllowedFalseAUTO_DENYJson);
+ // Act
+ remote_control::request_controller::MobileRequestPtr command =
+ CreateCommand(message);
+ command->Run();
+ // Assertions
+ EXPECT_EQ(rc_app_extention_->IsSubscibedToInteriorVehicleData(module_type),
+ false);
+}
+
+TEST_F(OnRemoteControlSettingsNotificationTest,
+ Execute_NothingHappens_IfParamsOmitted) {
+ // Expectations
+ EXPECT_CALL(mock_module_, service()).WillOnce(Return(mock_service_));
+ EXPECT_CALL(mock_allocation_manager_, SetAccessMode(_)).Times(0);
+ EXPECT_CALL(*mock_service_, GetApplications(kModuleId)).Times(0);
+ EXPECT_CALL(*mock_app_, QueryInterface(kModuleId)).Times(0);
+ EXPECT_CALL(*mock_service_,
+ ChangeNotifyHMILevel(
+ apps_[0], mobile_apis::HMILevel::eType::HMI_NONE)).Times(0);
+
+ application_manager::MessagePtr message =
+ CreateBasicMessage(kWithoutParamsJson);
+ // Act
+ remote_control::request_controller::MobileRequestPtr command =
+ CreateCommand(message);
+ command->Run();
+}
+
+} // namespace on_remote_control_settings_notification_test
+} // namespace remote_control_test
+} // namespace components
+} // namespace test
diff --git a/src/components/remote_control/test/commands/set_interior_vehicle_data_request_test.cc b/src/components/remote_control/test/commands/set_interior_vehicle_data_request_test.cc
new file mode 100644
index 0000000000..a219bc086d
--- /dev/null
+++ b/src/components/remote_control/test/commands/set_interior_vehicle_data_request_test.cc
@@ -0,0 +1,433 @@
+/*
+ * 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.
+ */
+
+#include "remote_control/commands/set_interior_vehicle_data_request.h"
+#include "gtest/gtest.h"
+#include "mock_remote_control_plugin.h"
+#include "mock_application.h"
+#include "mock_resource_allocation_manager.h"
+#include "remote_control/rc_app_extension.h"
+#include "remote_control/remote_control_event.h"
+#include "remote_control/rc_module_constants.h"
+#include "remote_control/message_helper.h"
+#include "remote_control/rc_command_factory.h"
+#include "remote_control/event_engine/event_dispatcher.h"
+#include "functional_module/function_ids.h"
+#include "include/mock_service.h"
+#include "utils/shared_ptr.h"
+#include "utils/make_shared.h"
+
+using functional_modules::RCFunctionID;
+using application_manager::ServicePtr;
+
+using application_manager::MockService;
+using test::components::remote_control_test::MockApplication;
+
+using ::testing::_;
+using ::testing::Mock;
+using ::testing::NiceMock;
+using ::testing::StrictMock;
+using ::testing::Return;
+using ::testing::ReturnRef;
+using ::testing::SaveArg;
+using ::application_manager::Message;
+using ::application_manager::MessageType;
+using ::application_manager::ApplicationSharedPtr;
+using ::protocol_handler::MessagePriority;
+using remote_control::RemotePluginInterface;
+using remote_control::MessageHelper;
+using namespace remote_control;
+
+namespace {
+const uint32_t kAppId = 11u;
+const int32_t kConnectionKey = 5;
+const int kModuleId = 153;
+const uint32_t kCorrelationId = 1u;
+const std::string kValidMobileRequestWithOnlySettableParams =
+ "{\"moduleData\":{\"moduleType\":\"CLIMATE\", "
+ "\"climateControlData\":{\"defrostZone\":"
+ "\"FRONT\", \"fanSpeed\":10}}}";
+const std::string kValidMobileRequestWithSettableAndReadOnlyParams =
+ "{\"moduleData\":{\"moduleType\":\"CLIMATE\", "
+ "\"climateControlData\":{\"defrostZone\":"
+ "\"FRONT\", \"fanSpeed\":10, \"currentTemperature\":{\"unit\":\"CELSIUS\", "
+ "\"value\":17.5}}}}";
+const std::string kValidMobileRequestWithoutSettableAndWithReadOnlyParams =
+ "{\"moduleData\":{\"moduleType\":\"CLIMATE\", \"climateControlData\":"
+ "{\"currentTemperature\":{\"unit\":\"CELSIUS\", \"value\":17.5}}}}";
+const std::string kInvalidMobileRequest = "{{\"moduleTip\":\"LUXOFT\"}}";
+const std::string kValidHmiResponse =
+ "{\"jsonrpc\":\"2.0\",\"id\":51,\"result\":{\"code\":0,\"method\":\"RC."
+ "SetInteriorVehicleData\",\"moduleData\":{\"moduleType\":\"CLIMATE\","
+ "\"climateControlData\":{\"fanSpeed\":0,\"desiredTemperature\":{\"unit\":"
+ "\"CELSIUS\","
+ "\"value\":25},\"acEnable\":true,\"circulateAirEnable\":true,"
+ "\"autoModeEnable\":true,\"defrostZone\":\"ALL\",\"dualModeEnable\":true,"
+ "\"acMaxEnable\":true,\"ventilationMode\":\"BOTH\"}}}}";
+const std::string kInvalidHmiResponse =
+ "{\"jsonrpc\":\"2.0\",\"id\":51,\"result\":{\"code\":21,\"method\":\"RC."
+ "SetInteriorVehicleData\",\"moduleData\":{\"moduleType\":\"CLIMATE\","
+ "\"ControlData\":{\"Speed\":0,\"outsideTemperature\":{\"unit\":"
+ "\"CELSIUS\",\"value\":\"high\"},\"desiredTemperature\":{\"unit\":"
+ "\"CELSIUS\","
+ "\"value\":25},\"acEnable\":true,\"circulateAirEnable\":true,"
+ "\"autoModeEnable\":true,\"defrostZone\":\"ALL\",\"dualModeEnable\":true,"
+ "\"acMaxEnable\":true,\"ventilationMode\":\"BOTH\"}},\"isSubscribed\":"
+ "false}}";
+}
+
+namespace test {
+namespace components {
+namespace remote_control_test {
+namespace set_interior_vehicle_data_request_test {
+
+class SetInteriorVehicleDataRequestTest : public ::testing::Test {
+ public:
+ SetInteriorVehicleDataRequestTest()
+ : mock_service_(utils::MakeShared<NiceMock<MockService> >())
+ , mock_app_(utils::MakeShared<NiceMock<MockApplication> >())
+ , rc_app_extention_(
+ utils::MakeShared<remote_control::RCAppExtension>(kModuleId)) {
+ ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId));
+ ON_CALL(mock_module_, resource_allocation_manager())
+ .WillByDefault(ReturnRef(mock_allocation_manager_));
+ ON_CALL(mock_module_, service()).WillByDefault(Return(mock_service_));
+ ON_CALL(*mock_service_, GetApplication(_)).WillByDefault(Return(mock_app_));
+ ON_CALL(*mock_service_, IsInterfaceAvailable(_))
+ .WillByDefault(Return(true));
+ ON_CALL(*mock_service_, IsRemoteControlApplication(_))
+ .WillByDefault(Return(true));
+ ON_CALL(mock_module_, event_dispatcher())
+ .WillByDefault(ReturnRef(event_dispatcher_));
+ ServicePtr exp_service(mock_service_);
+ }
+
+ remote_control::request_controller::MobileRequestPtr CreateCommand(
+ application_manager::MessagePtr msg) {
+ return remote_control::RCCommandFactory::CreateCommand(msg, mock_module_);
+ }
+
+ application_manager::MessagePtr CreateBasicMessage() {
+ application_manager::MessagePtr message = utils::MakeShared<Message>(
+ MessagePriority::FromServiceType(protocol_handler::ServiceType::kRpc));
+ message->set_connection_key(kConnectionKey);
+ message->set_function_id(RCFunctionID::SET_INTERIOR_VEHICLE_DATA);
+ message->set_function_name(MessageHelper::GetMobileAPIName(
+ functional_modules::SET_INTERIOR_VEHICLE_DATA));
+ return message;
+ }
+
+ protected:
+ utils::SharedPtr<NiceMock<application_manager::MockService> > mock_service_;
+ utils::SharedPtr<NiceMock<MockApplication> > mock_app_;
+ utils::SharedPtr<remote_control::RCAppExtension> rc_app_extention_;
+ testing::NiceMock<remote_control_test::MockRemotePluginInterface>
+ mock_module_;
+ testing::NiceMock<remote_control_test::MockResourceAllocationManager>
+ mock_allocation_manager_;
+ RemotePluginInterface::RCPluginEventDispatcher event_dispatcher_;
+};
+
+TEST_F(SetInteriorVehicleDataRequestTest,
+ Execute_ValidWithoutReadOnlyParams_ExpectResendToHMI) {
+ // Arrange
+ application_manager::MessagePtr mobile_message = CreateBasicMessage();
+ mobile_message->set_json_message(kValidMobileRequestWithOnlySettableParams);
+
+ // Expectations
+ EXPECT_CALL(*mock_service_, ValidateMessageBySchema(*mobile_message))
+ .WillOnce(Return(application_manager::MessageValidationResult::SUCCESS));
+ EXPECT_CALL(*mock_service_, CheckPolicyPermissions(mobile_message))
+ .WillOnce(Return(mobile_apis::Result::eType::SUCCESS));
+ application_manager::AppExtensionPtr invalid_ext;
+ EXPECT_CALL(*mock_app_, QueryInterface(kModuleId))
+ .WillOnce(Return(invalid_ext))
+ .WillRepeatedly(Return(rc_app_extention_));
+
+ application_manager::AppExtensionPtr app_extension;
+ EXPECT_CALL(*mock_app_, AddExtension(_))
+ .WillOnce(DoAll(SaveArg<0>(&app_extension), Return(true)));
+ EXPECT_CALL(*mock_service_, CheckModule(_, _)).WillOnce(Return(true));
+ EXPECT_CALL(*mock_service_, GetNextCorrelationID())
+ .WillOnce(Return(kCorrelationId));
+
+ const std::string resource = "CLIMATE";
+
+ EXPECT_CALL(mock_allocation_manager_, IsResourceFree(resource))
+ .WillOnce(Return(true));
+ EXPECT_CALL(mock_allocation_manager_, AcquireResource(resource, kAppId))
+ .WillOnce(Return(remote_control::AcquireResult::ALLOWED));
+ EXPECT_CALL(
+ mock_allocation_manager_,
+ SetResourceState(resource, kAppId, remote_control::ResourceState::BUSY));
+
+ application_manager::MessagePtr result_msg;
+ EXPECT_CALL(*mock_service_, SendMessageToHMI(_))
+ .WillOnce(SaveArg<0>(&result_msg));
+
+ // Act
+ remote_control::request_controller::MobileRequestPtr command =
+ CreateCommand(mobile_message);
+ command->Run();
+
+ // Assertions
+ EXPECT_EQ(kModuleId, app_extension->uid());
+ EXPECT_EQ(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_HMI,
+ result_msg->protocol_version());
+ EXPECT_EQ(1, result_msg->correlation_id());
+ EXPECT_EQ(application_manager::MessageType::kRequest, result_msg->type());
+ const Json::Value hmi_request_params =
+ MessageHelper::StringToValue(result_msg->json_message());
+ EXPECT_EQ(functional_modules::hmi_api::set_interior_vehicle_data,
+ hmi_request_params[json_keys::kMethod].asString());
+ const Json::Value hmi_request_climate_control_data =
+ hmi_request_params[json_keys::kParams][message_params::kModuleData]
+ [message_params::kClimateControlData];
+ EXPECT_EQ(2u, hmi_request_climate_control_data.size());
+ const Json::Value hmi_request_module_data_fan_speed =
+ hmi_request_climate_control_data[message_params::kFanSpeed];
+ const Json::Value hmi_request_module_data_defrost_zone =
+ hmi_request_climate_control_data[message_params::kDefrostZone];
+ EXPECT_EQ("FRONT", hmi_request_module_data_defrost_zone.asString());
+ EXPECT_EQ(10, hmi_request_module_data_fan_speed.asInt());
+}
+
+TEST_F(
+ SetInteriorVehicleDataRequestTest,
+ Execute_ValidWithSettableAndReadOnlyParams_ExpectCutReadOnlyAndResendToHMI) {
+ // Arrange
+ application_manager::MessagePtr mobile_message = CreateBasicMessage();
+ mobile_message->set_json_message(
+ kValidMobileRequestWithSettableAndReadOnlyParams);
+
+ // Expectations
+ EXPECT_CALL(*mock_service_, ValidateMessageBySchema(*mobile_message))
+ .WillOnce(Return(application_manager::MessageValidationResult::SUCCESS));
+ EXPECT_CALL(*mock_service_, CheckPolicyPermissions(mobile_message))
+ .WillOnce(Return(mobile_apis::Result::eType::SUCCESS));
+
+ application_manager::AppExtensionPtr invalid_ext;
+ EXPECT_CALL(*mock_app_, QueryInterface(kModuleId))
+ .WillOnce(Return(invalid_ext))
+ .WillRepeatedly(Return(rc_app_extention_));
+
+ application_manager::AppExtensionPtr app_extension;
+ EXPECT_CALL(*mock_app_, AddExtension(_))
+ .WillOnce(DoAll(SaveArg<0>(&app_extension), Return(true)));
+ EXPECT_CALL(*mock_service_, CheckModule(_, _)).WillOnce(Return(true));
+ EXPECT_CALL(*mock_service_, GetNextCorrelationID())
+ .WillOnce(Return(kCorrelationId));
+
+ const std::string resource = "CLIMATE";
+
+ EXPECT_CALL(mock_allocation_manager_, IsResourceFree(resource))
+ .WillOnce(Return(true));
+ EXPECT_CALL(mock_allocation_manager_, AcquireResource(resource, kAppId))
+ .WillOnce(Return(remote_control::AcquireResult::ALLOWED));
+ EXPECT_CALL(
+ mock_allocation_manager_,
+ SetResourceState(resource, kAppId, remote_control::ResourceState::BUSY));
+
+ application_manager::MessagePtr result_msg;
+ EXPECT_CALL(*mock_service_, SendMessageToHMI(_))
+ .WillOnce(SaveArg<0>(&result_msg));
+
+ // Act
+ remote_control::request_controller::MobileRequestPtr command =
+ CreateCommand(mobile_message);
+ command->Run();
+
+ // Assertions
+ EXPECT_EQ(kModuleId, app_extension->uid());
+ EXPECT_EQ(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_HMI,
+ result_msg->protocol_version());
+ EXPECT_EQ(1, result_msg->correlation_id());
+ EXPECT_EQ(application_manager::MessageType::kRequest, result_msg->type());
+ const Json::Value hmi_request_params =
+ MessageHelper::StringToValue(result_msg->json_message());
+ EXPECT_EQ(functional_modules::hmi_api::set_interior_vehicle_data,
+ hmi_request_params[json_keys::kMethod].asString());
+ const Json::Value hmi_request_climate_control_data =
+ hmi_request_params[json_keys::kParams][message_params::kModuleData]
+ [message_params::kClimateControlData];
+ EXPECT_EQ(2u, hmi_request_climate_control_data.size());
+ const Json::Value hmi_request_module_data_fan_speed =
+ hmi_request_climate_control_data[message_params::kFanSpeed];
+ const Json::Value hmi_request_module_data_defrost_zone =
+ hmi_request_climate_control_data[message_params::kDefrostZone];
+ EXPECT_EQ("FRONT", hmi_request_module_data_defrost_zone.asString());
+ EXPECT_EQ(10, hmi_request_module_data_fan_speed.asInt());
+}
+
+TEST_F(SetInteriorVehicleDataRequestTest,
+ Execute_ValidWithOnlyParamsReadOnly_ExpectResponseReadOnly) {
+ // Arrange
+ application_manager::MessagePtr mobile_message = CreateBasicMessage();
+ mobile_message->set_json_message(
+ kValidMobileRequestWithoutSettableAndWithReadOnlyParams);
+
+ // Expectations
+ EXPECT_CALL(*mock_service_, ValidateMessageBySchema(*mobile_message))
+ .WillOnce(Return(application_manager::MessageValidationResult::SUCCESS));
+ EXPECT_CALL(*mock_service_, CheckPolicyPermissions(mobile_message))
+ .WillOnce(Return(mobile_apis::Result::eType::SUCCESS));
+ EXPECT_CALL(mock_allocation_manager_, IsResourceFree(_))
+ .WillOnce(Return(true));
+ EXPECT_CALL(mock_allocation_manager_, AcquireResource(_, _))
+ .WillOnce(Return(::remote_control::AcquireResult::ALLOWED));
+ application_manager::AppExtensionPtr invalid_ext;
+ EXPECT_CALL(*mock_app_, QueryInterface(kModuleId))
+ .WillOnce(Return(invalid_ext))
+ .WillRepeatedly(Return(rc_app_extention_));
+
+ application_manager::AppExtensionPtr app_extension;
+ EXPECT_CALL(*mock_app_, AddExtension(_))
+ .WillOnce(DoAll(SaveArg<0>(&app_extension), Return(true)));
+ EXPECT_CALL(*mock_service_, CheckModule(_, _)).WillOnce(Return(true));
+ EXPECT_CALL(*mock_service_, SendMessageToHMI(_)).Times(0);
+
+ application_manager::MessagePtr result_msg;
+ EXPECT_CALL(mock_module_, SendResponseToMobile(_))
+ .WillOnce(SaveArg<0>(&result_msg));
+
+ // Act
+ remote_control::request_controller::MobileRequestPtr command =
+ CreateCommand(mobile_message);
+ command->Run();
+
+ // Assertions
+ const Json::Value response_params =
+ MessageHelper::StringToValue(result_msg->json_message());
+ EXPECT_FALSE(response_params[result_codes::kSuccess].asBool());
+ EXPECT_EQ(result_codes::kReadOnly,
+ response_params[json_keys::kResultCode].asString());
+}
+
+TEST_F(
+ SetInteriorVehicleDataRequestTest,
+ Execute_MessageValidationFailed_ExpectMessageNotSentToHMI_AndFalseSentToMobile) {
+ // Arrange
+ application_manager::MessagePtr mobile_message = CreateBasicMessage();
+ mobile_message->set_json_message(kInvalidMobileRequest);
+
+ // Expectations
+ EXPECT_CALL(*mock_service_, ValidateMessageBySchema(*mobile_message))
+ .WillOnce(
+ Return(application_manager::MessageValidationResult::INVALID_JSON));
+ EXPECT_CALL(*mock_service_, SendMessageToHMI(_)).Times(0);
+ application_manager::MessagePtr result_msg;
+ EXPECT_CALL(mock_module_, SendResponseToMobile(_))
+ .WillOnce(SaveArg<0>(&result_msg));
+
+ // Act
+ remote_control::request_controller::MobileRequestPtr command =
+ CreateCommand(mobile_message);
+ command->Run();
+
+ // Assertions
+ const Json::Value response_params =
+ MessageHelper::StringToValue(result_msg->json_message());
+ EXPECT_FALSE(response_params[result_codes::kSuccess].asBool());
+ EXPECT_EQ(result_codes::kInvalidData,
+ response_params[json_keys::kResultCode].asString());
+}
+
+TEST_F(SetInteriorVehicleDataRequestTest,
+ OnEvent_ValidHmiResponse_ExpectSuccessfulResponseSentToMobile) {
+ // Arrange
+ application_manager::MessagePtr mobile_message = CreateBasicMessage();
+ mobile_message->set_json_message(kValidMobileRequestWithOnlySettableParams);
+
+ application_manager::MessagePtr hmi_message = CreateBasicMessage();
+ hmi_message->set_json_message(kValidHmiResponse);
+ hmi_message->set_message_type(application_manager::MessageType::kResponse);
+
+ // Expectations
+ EXPECT_CALL(*mock_service_, ValidateMessageBySchema(*hmi_message))
+ .WillOnce(Return(application_manager::MessageValidationResult::SUCCESS));
+ application_manager::MessagePtr result_msg;
+ EXPECT_CALL(mock_module_, SendResponseToMobile(_))
+ .WillOnce(SaveArg<0>(&result_msg));
+
+ // Act
+ remote_control::RCPluginEvent event(
+ hmi_message, functional_modules::hmi_api::set_interior_vehicle_data);
+ remote_control::request_controller::MobileRequestPtr command =
+ CreateCommand(mobile_message);
+ command->on_event(event);
+
+ // Assertions
+ const Json::Value response_params =
+ MessageHelper::StringToValue(result_msg->json_message());
+ EXPECT_TRUE(response_params[json_keys::kSuccess].asBool());
+ EXPECT_EQ(result_codes::kSuccess,
+ response_params[json_keys::kResultCode].asString());
+}
+
+TEST_F(SetInteriorVehicleDataRequestTest,
+ OnEvent_InvalidHmiResponse_ExpectGenericErrorResponseSentToMobile) {
+ // Arrange
+ application_manager::MessagePtr mobile_message = CreateBasicMessage();
+ mobile_message->set_json_message(kValidMobileRequestWithOnlySettableParams);
+ application_manager::MessagePtr hmi_message = CreateBasicMessage();
+ hmi_message->set_json_message(kInvalidHmiResponse);
+ hmi_message->set_message_type(application_manager::MessageType::kResponse);
+
+ // Expectations
+ EXPECT_CALL(*mock_service_, ValidateMessageBySchema(*hmi_message))
+ .WillOnce(
+ Return(application_manager::MessageValidationResult::INVALID_JSON));
+ application_manager::MessagePtr result_msg;
+ EXPECT_CALL(mock_module_, SendResponseToMobile(_))
+ .WillOnce(SaveArg<0>(&result_msg));
+
+ // Act
+ remote_control::request_controller::MobileRequestPtr command =
+ CreateCommand(mobile_message);
+ remote_control::RCPluginEvent event(
+ hmi_message, functional_modules::hmi_api::set_interior_vehicle_data);
+ command->on_event(event);
+ const Json::Value response_params =
+ MessageHelper::StringToValue(result_msg->json_message());
+ EXPECT_FALSE(response_params[json_keys::kSuccess].asBool());
+ EXPECT_EQ(result_codes::kGenericError,
+ response_params[json_keys::kResultCode].asString());
+ const Json::Value hmi_response =
+ MessageHelper::StringToValue(hmi_message->json_message());
+ EXPECT_EQ(hmi_response[json_keys::kInfo].asString(),
+ response_params[json_keys::kInfo].asString());
+}
+
+} // namespace set_interior_vehicle_data_request_test
+} // namespace remote_control_test
+} // namespace components
+} // namespace test
diff --git a/src/components/remote_control/test/include/mock_application.h b/src/components/remote_control/test/include/mock_application.h
new file mode 100644
index 0000000000..2c4ce641ee
--- /dev/null
+++ b/src/components/remote_control/test/include/mock_application.h
@@ -0,0 +1,335 @@
+/*
+ * 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_REMOTE_CONTROL_TEST_INCLUDE_MOCK_APPLICATION_H_
+#define SRC_COMPONENTS_REMOTE_CONTROL_TEST_INCLUDE_MOCK_APPLICATION_H_
+
+#include <string>
+
+#include <string>
+#include "gmock/gmock.h"
+#include "application_manager/application.h"
+#include "interfaces/MOBILE_API.h"
+#include "application_manager/app_extension.h"
+#include "smart_objects/smart_object.h"
+#include "utils/custom_string.h"
+#include "application_manager/usage_statistics.h"
+
+namespace test {
+namespace components {
+namespace remote_control_test {
+
+namespace am = application_manager;
+namespace mobile_api = mobile_apis;
+namespace custom_str = utils::custom_string;
+
+namespace custom_str = utils::custom_string;
+class MockApplication : public ::application_manager::Application {
+ public:
+ MockApplication() {}
+ MOCK_CONST_METHOD0(active_message, const smart_objects::SmartObject*());
+ MOCK_CONST_METHOD0(curHash, const std::string&());
+ MOCK_METHOD0(UpdateHash, void());
+ MOCK_CONST_METHOD0(flag_sending_hash_change_after_awake, bool());
+ MOCK_METHOD1(set_flag_sending_hash_change_after_awake, void(bool flag));
+ MOCK_CONST_METHOD0(is_application_data_changed, bool());
+ MOCK_METHOD1(set_is_application_data_changed,
+ void(bool state_application_data));
+ MOCK_METHOD0(CloseActiveMessage, void());
+ MOCK_CONST_METHOD0(IsFullscreen, bool());
+ MOCK_METHOD0(ChangeSupportingAppHMIType, void());
+ MOCK_CONST_METHOD0(is_navi, bool());
+ MOCK_METHOD1(set_is_navi, void(bool allow));
+ MOCK_CONST_METHOD0(video_streaming_approved, bool());
+ MOCK_METHOD1(set_video_streaming_approved, void(bool state));
+ MOCK_CONST_METHOD0(audio_streaming_approved, bool());
+ MOCK_METHOD1(set_audio_streaming_approved, void(bool state));
+ MOCK_CONST_METHOD0(video_streaming_allowed, bool());
+ MOCK_METHOD1(set_video_streaming_allowed, void(bool state));
+ MOCK_CONST_METHOD0(audio_streaming_allowed, bool());
+ MOCK_METHOD1(set_audio_streaming_allowed, void(bool state));
+ MOCK_CONST_METHOD0(is_audio, bool());
+ MOCK_METHOD2(SetVideoConfig,
+ bool(protocol_handler::ServiceType service_type,
+ const smart_objects::SmartObject& params));
+ MOCK_METHOD1(StartStreaming,
+ void(protocol_handler::ServiceType service_type));
+ MOCK_METHOD1(StopStreaming, void(protocol_handler::ServiceType service_type));
+ MOCK_METHOD1(StopStreamingForce,
+ void(protocol_handler::ServiceType service_type));
+ MOCK_METHOD1(SuspendStreaming,
+ void(protocol_handler::ServiceType service_type));
+ MOCK_METHOD1(WakeUpStreaming,
+ void(protocol_handler::ServiceType service_type));
+ MOCK_CONST_METHOD0(is_voice_communication_supported, bool());
+ MOCK_METHOD1(set_voice_communication_supported,
+ void(bool is_voice_communication_supported));
+ MOCK_CONST_METHOD0(app_allowed, bool());
+ MOCK_CONST_METHOD0(has_been_activated, bool());
+ MOCK_METHOD1(set_activated, bool(bool is_active));
+ MOCK_CONST_METHOD0(version, const ::application_manager::Version&());
+ MOCK_METHOD1(set_hmi_application_id, void(uint32_t hmi_app_id));
+ MOCK_CONST_METHOD0(hmi_app_id, uint32_t());
+ MOCK_CONST_METHOD0(name, const custom_str::CustomString&());
+ MOCK_METHOD1(set_folder_name, void(const std::string& folder_name));
+ MOCK_CONST_METHOD0(folder_name, const std::string());
+ MOCK_CONST_METHOD0(is_media_application, bool());
+ MOCK_CONST_METHOD0(hmi_level, const mobile_apis::HMILevel::eType());
+ MOCK_CONST_METHOD0(put_file_in_none_count, const uint32_t());
+ MOCK_CONST_METHOD0(delete_file_in_none_count, const uint32_t());
+ MOCK_CONST_METHOD0(list_files_in_none_count, const uint32_t());
+ MOCK_CONST_METHOD0(system_context, const mobile_apis::SystemContext::eType());
+ MOCK_CONST_METHOD0(audio_streaming_state,
+ const mobile_apis::AudioStreamingState::eType());
+ MOCK_CONST_METHOD0(app_icon_path, const std::string&());
+ MOCK_CONST_METHOD0(device, connection_handler::DeviceHandle());
+ MOCK_CONST_METHOD0(CurrentHmiState, const application_manager::HmiStatePtr());
+ MOCK_CONST_METHOD0(RegularHmiState, const application_manager::HmiStatePtr());
+ MOCK_CONST_METHOD0(PostponedHmiState,
+ const application_manager::HmiStatePtr());
+ MOCK_METHOD1(set_tts_properties_in_none, void(bool active));
+ MOCK_METHOD0(tts_properties_in_none, bool());
+ MOCK_METHOD1(set_tts_properties_in_full, void(bool active));
+ MOCK_METHOD0(tts_properties_in_full, bool());
+ MOCK_METHOD1(set_version,
+ void(const ::application_manager::Version& version));
+ MOCK_METHOD1(set_name, void(const custom_str::CustomString& name));
+ MOCK_METHOD1(set_is_media_application, void(bool is_media));
+ MOCK_METHOD0(increment_put_file_in_none_count, void());
+ MOCK_METHOD0(increment_delete_file_in_none_count, void());
+ MOCK_METHOD0(increment_list_files_in_none_count, void());
+ MOCK_METHOD1(set_app_icon_path, bool(const std::string& file_name));
+ MOCK_METHOD1(set_app_allowed, void(const bool allowed));
+ MOCK_METHOD1(set_device, void(connection_handler::DeviceHandle device));
+ MOCK_CONST_METHOD0(get_grammar_id, uint32_t());
+ MOCK_METHOD1(set_grammar_id, void(uint32_t value));
+ MOCK_METHOD1(
+ set_protocol_version,
+ void(const ::protocol_handler::MajorProtocolVersion& protocol_version));
+ MOCK_CONST_METHOD0(protocol_version,
+ ::protocol_handler::MajorProtocolVersion());
+ MOCK_METHOD1(set_is_resuming, void(bool));
+ MOCK_CONST_METHOD0(is_resuming, bool());
+ MOCK_METHOD1(AddFile, bool(const ::application_manager::AppFile& file));
+ MOCK_CONST_METHOD0(getAppFiles, const ::application_manager::AppFilesMap&());
+ MOCK_METHOD1(UpdateFile, bool(const ::application_manager::AppFile& file));
+ MOCK_METHOD1(DeleteFile, bool(const std::string& file_name));
+ MOCK_METHOD1(
+ GetFile,
+ const ::application_manager::AppFile*(const std::string& file_name));
+ MOCK_METHOD1(SubscribeToButton,
+ bool(mobile_apis::ButtonName::eType btn_name));
+ MOCK_METHOD1(IsSubscribedToButton,
+ bool(mobile_apis::ButtonName::eType btn_name));
+ MOCK_METHOD1(UnsubscribeFromButton,
+ bool(mobile_apis::ButtonName::eType btn_name));
+ MOCK_METHOD1(SubscribeToIVI, bool(uint32_t vehicle_info_type));
+ MOCK_CONST_METHOD1(IsSubscribedToIVI, bool(uint32_t vehicle_info_type));
+ MOCK_METHOD1(UnsubscribeFromIVI, bool(uint32_t vehicle_info_type));
+ MOCK_METHOD0(ResetDataInNone, void());
+ MOCK_METHOD2(AreCommandLimitsExceeded,
+ bool(mobile_apis::FunctionID::eType cmd_id,
+ ::application_manager::TLimitSource source));
+ MOCK_METHOD0(usage_report, ::application_manager::UsageStatistics&());
+ MOCK_METHOD1(SetRegularState, void(::application_manager::HmiStatePtr state));
+ MOCK_METHOD1(SetPostponedState,
+ void(::application_manager::HmiStatePtr state));
+ MOCK_METHOD0(RemovePostponedState, void());
+ MOCK_METHOD1(AddHMIState, void(::application_manager::HmiStatePtr state));
+ MOCK_METHOD1(RemoveHMIState,
+ void(::application_manager::HmiState::StateID state_id));
+ MOCK_METHOD2(SubscribeToSoftButtons,
+ void(int32_t cmd_id,
+ const ::application_manager::SoftButtonID& softbuttons_id));
+ MOCK_METHOD1(IsSubscribedToSoftButton, bool(const uint32_t softbutton_id));
+ MOCK_METHOD1(UnsubscribeFromSoftButtons, void(int32_t cmd_id));
+ MOCK_CONST_METHOD0(IsAudioApplication, bool());
+ MOCK_METHOD0(LoadPersistentFiles, void());
+ // InitialApplicationData methods
+ MOCK_CONST_METHOD0(app_types, const smart_objects::SmartObject*());
+ MOCK_CONST_METHOD0(vr_synonyms, const smart_objects::SmartObject*());
+ MOCK_CONST_METHOD0(policy_app_id, std::string());
+ MOCK_CONST_METHOD0(tts_name, const smart_objects::SmartObject*());
+ MOCK_CONST_METHOD0(ngn_media_screen_name,
+ const smart_objects::SmartObject*());
+ MOCK_CONST_METHOD0(language, const mobile_apis::Language::eType&());
+ MOCK_CONST_METHOD0(ui_language, const mobile_apis::Language::eType&());
+ MOCK_METHOD1(set_app_types,
+ void(const smart_objects::SmartObject& app_types));
+ MOCK_METHOD1(set_vr_synonyms,
+ void(const smart_objects::SmartObject& vr_synonyms));
+ MOCK_METHOD1(set_policy_app_id, void(const std::string& policy_app_id));
+ MOCK_METHOD1(set_tts_name, void(const smart_objects::SmartObject& tts_name));
+ MOCK_METHOD1(set_ngn_media_screen_name,
+ void(const smart_objects::SmartObject& ngn_name));
+ MOCK_METHOD1(set_language,
+ void(const mobile_apis::Language::eType& language));
+ MOCK_METHOD1(set_ui_language,
+ void(const mobile_apis::Language::eType& ui_language));
+ // DynamicApplicationData methods
+ MOCK_CONST_METHOD0(help_prompt, const smart_objects::SmartObject*());
+ MOCK_CONST_METHOD0(timeout_prompt, const smart_objects::SmartObject*());
+ MOCK_CONST_METHOD0(vr_help_title, const smart_objects::SmartObject*());
+ MOCK_CONST_METHOD0(vr_help, const smart_objects::SmartObject*());
+ MOCK_CONST_METHOD0(tbt_state, const mobile_apis::TBTState::eType&());
+ MOCK_CONST_METHOD0(show_command, const smart_objects::SmartObject*());
+ MOCK_CONST_METHOD0(tbt_show_command, const smart_objects::SmartObject*());
+ MOCK_CONST_METHOD0(
+ SubscribedButtons,
+ DataAccessor< ::application_manager::ButtonSubscriptions>());
+ MOCK_CONST_METHOD0(
+ SubscribedIVI,
+ DataAccessor< ::application_manager::VehicleInfoSubscriptions>());
+ MOCK_CONST_METHOD0(keyboard_props, const smart_objects::SmartObject*());
+ MOCK_CONST_METHOD0(menu_title, const smart_objects::SmartObject*());
+ MOCK_CONST_METHOD0(menu_icon, const smart_objects::SmartObject*());
+ MOCK_METHOD1(load_global_properties,
+ void(const smart_objects::SmartObject& so));
+ MOCK_METHOD1(set_help_prompt,
+ void(const smart_objects::SmartObject& help_prompt));
+ MOCK_METHOD1(set_timeout_prompt,
+ void(const smart_objects::SmartObject& timeout_prompt));
+ MOCK_METHOD1(set_vr_help_title,
+ void(const smart_objects::SmartObject& vr_help_title));
+ MOCK_METHOD0(reset_vr_help_title, void());
+ MOCK_METHOD1(set_vr_help, void(const smart_objects::SmartObject& vr_help));
+ MOCK_METHOD0(reset_vr_help, void());
+ MOCK_METHOD1(set_tbt_state,
+ void(const mobile_apis::TBTState::eType& tbt_state));
+ MOCK_METHOD1(set_show_command,
+ void(const smart_objects::SmartObject& show_command));
+ MOCK_METHOD1(set_tbt_show_command,
+ void(const smart_objects::SmartObject& tbt_show));
+ MOCK_METHOD1(set_keyboard_props,
+ void(const smart_objects::SmartObject& keyboard_props));
+ MOCK_METHOD1(set_menu_title,
+ void(const smart_objects::SmartObject& menu_title));
+ MOCK_METHOD1(set_menu_icon,
+ void(const smart_objects::SmartObject& menu_icon));
+ MOCK_CONST_METHOD0(audio_stream_retry_number, uint32_t());
+ MOCK_METHOD1(set_audio_stream_retry_number,
+ void(const uint32_t& audio_stream_retry_number));
+ MOCK_CONST_METHOD0(video_stream_retry_number, uint32_t());
+ MOCK_METHOD1(set_video_stream_retry_number,
+ void(const uint32_t& video_stream_retry_number));
+ MOCK_METHOD2(AddCommand,
+ void(uint32_t cmd_id,
+ const smart_objects::SmartObject& command));
+ MOCK_METHOD1(RemoveCommand, void(uint32_t cmd_id));
+ MOCK_METHOD1(FindCommand, smart_objects::SmartObject*(uint32_t cmd_id));
+ MOCK_METHOD2(AddSubMenu,
+ void(uint32_t menu_id, const smart_objects::SmartObject& menu));
+ MOCK_METHOD1(RemoveSubMenu, void(uint32_t menu_id));
+ MOCK_CONST_METHOD1(FindSubMenu,
+ smart_objects::SmartObject*(uint32_t menu_id));
+ MOCK_METHOD1(IsSubMenuNameAlreadyExist, bool(const std::string& name));
+ MOCK_METHOD2(AddChoiceSet,
+ void(uint32_t choice_set_id,
+ const smart_objects::SmartObject& choice_set));
+ MOCK_METHOD1(RemoveChoiceSet, void(uint32_t choice_set_id));
+ MOCK_METHOD1(FindChoiceSet,
+ smart_objects::SmartObject*(uint32_t choice_set_id));
+ MOCK_METHOD3(AddPerformInteractionChoiceSet,
+ void(uint32_t correlation_id,
+ uint32_t choice_set_id,
+ const smart_objects::SmartObject& choice_set));
+ MOCK_METHOD1(DeletePerformInteractionChoiceSet,
+ void(uint32_t correlation_id));
+ MOCK_CONST_METHOD0(
+ performinteraction_choice_set_map,
+ DataAccessor< ::application_manager::PerformChoiceSetMap>());
+ MOCK_CONST_METHOD0(commands_map,
+ DataAccessor< ::application_manager::CommandsMap>());
+ MOCK_CONST_METHOD0(sub_menu_map,
+ DataAccessor< ::application_manager::SubMenuMap>());
+ MOCK_CONST_METHOD0(choice_set_map,
+ DataAccessor< ::application_manager::ChoiceSetMap>());
+ MOCK_METHOD1(set_perform_interaction_active, void(uint32_t active));
+ MOCK_CONST_METHOD0(is_perform_interaction_active, uint32_t());
+ MOCK_METHOD1(set_perform_interaction_mode, void(int32_t mode));
+ MOCK_CONST_METHOD0(perform_interaction_mode, int32_t());
+ MOCK_METHOD1(set_perform_interaction_layout,
+ void(mobile_apis::LayoutMode::eType mode));
+ MOCK_CONST_METHOD0(perform_interaction_layout,
+ mobile_apis::LayoutMode::eType());
+ MOCK_METHOD1(set_reset_global_properties_active, void(bool active));
+ MOCK_CONST_METHOD0(is_reset_global_properties_active, bool());
+ MOCK_CONST_METHOD0(app_id, uint32_t());
+ MOCK_CONST_METHOD0(mac_address, const std::string&());
+ MOCK_CONST_METHOD0(bundle_id, const std::string&());
+ MOCK_METHOD1(set_bundle_id, void(const std::string& bundle_id));
+ MOCK_METHOD0(GetAvailableDiskSpace, uint32_t());
+
+ MOCK_METHOD1(set_mobile_projection_enabled, void(bool));
+ MOCK_CONST_METHOD0(mobile_projection_enabled, bool());
+
+ MOCK_METHOD1(set_mobile_app_id, void(const std::string& policy_app_id));
+ MOCK_CONST_METHOD0(is_foreground, bool());
+ MOCK_METHOD1(set_foreground, void(bool is_foreground));
+ MOCK_CONST_METHOD0(IsRegistered, bool());
+ MOCK_CONST_METHOD0(SchemaUrl, std::string());
+ MOCK_CONST_METHOD0(PackageName, std::string());
+
+#ifdef SDL_REMOTE_CONTROL
+ MOCK_METHOD1(
+ set_system_context,
+ void(const application_manager::mobile_api::SystemContext::eType&));
+ MOCK_METHOD1(
+ set_audio_streaming_state,
+ void(const application_manager::mobile_api::AudioStreamingState::eType&
+ state));
+ MOCK_METHOD1(IsSubscribedToInteriorVehicleData,
+ bool(smart_objects::SmartObject module));
+ MOCK_METHOD1(SubscribeToInteriorVehicleData,
+ bool(smart_objects::SmartObject module));
+ MOCK_METHOD1(UnsubscribeFromInteriorVehicleData,
+ bool(smart_objects::SmartObject module));
+ MOCK_METHOD1(
+ set_hmi_level,
+ void(const application_manager::mobile_api::HMILevel::eType& hmi_level));
+ MOCK_METHOD1(QueryInterface,
+ application_manager::AppExtensionPtr(
+ application_manager::AppExtensionUID uid));
+ MOCK_METHOD1(AddExtension,
+ bool(application_manager::AppExtensionPtr extention));
+ MOCK_METHOD1(RemoveExtension, bool(application_manager::AppExtensionUID uid));
+ MOCK_METHOD0(RemoveExtensions, void());
+ MOCK_CONST_METHOD0(SubscribesIVI, const std::set<uint32_t>&());
+
+#endif // SDL_REMOTE_CONTROL
+};
+
+} // namespace remote_control_test
+} // namespace components
+} // namespace test
+
+#endif // SRC_COMPONENTS_REMOTE_CONTROL_TEST_INCLUDE_MOCK_APPLICATION_H_
diff --git a/src/components/remote_control/test/include/mock_remote_control_plugin.h b/src/components/remote_control/test/include/mock_remote_control_plugin.h
new file mode 100644
index 0000000000..2e221ca75d
--- /dev/null
+++ b/src/components/remote_control/test/include/mock_remote_control_plugin.h
@@ -0,0 +1,54 @@
+#ifndef SRC_COMPONENTS_REMOTE_CONTROL_TEST_INCLUDE_MOCK_REMOTE_CONTROL_PLUGIN_H_
+#define SRC_COMPONENTS_REMOTE_CONTROL_TEST_INCLUDE_MOCK_REMOTE_CONTROL_PLUGIN_H_
+
+#include <stdint.h>
+#include "remote_control/remote_plugin_interface.h"
+#include "remote_control/resource_allocation_manager.h"
+#include "application_manager/message.h"
+#include "mock_application.h"
+
+namespace test {
+namespace components {
+namespace remote_control_test {
+
+class RCAppExtension;
+typedef utils::SharedPtr<RCAppExtension> RCAppExtensionPtr;
+
+class MockRemotePluginInterface : public remote_control::RemotePluginInterface {
+ public:
+ MOCK_CONST_METHOD0(GetPluginInfo, functional_modules::PluginInfo());
+ MOCK_METHOD1(
+ ProcessMessage,
+ functional_modules::ProcessResult(application_manager::MessagePtr msg));
+ MOCK_METHOD1(
+ ProcessHMIMessage,
+ functional_modules::ProcessResult(application_manager::MessagePtr msg));
+ MOCK_METHOD1(SendResponseToMobile, void(application_manager::MessagePtr msg));
+ MOCK_METHOD1(SendTimeoutResponseToMobile,
+ void(application_manager::MessagePtr msg));
+ MOCK_METHOD1(RemoveAppExtension, void(uint32_t app_id));
+ MOCK_METHOD1(IsAppForPlugin,
+ bool(application_manager::ApplicationSharedPtr app));
+ MOCK_METHOD2(OnAppHMILevelChanged,
+ void(application_manager::ApplicationSharedPtr app,
+ mobile_apis::HMILevel::eType old_level));
+ MOCK_METHOD1(OnUnregisterApplication, void(const uint32_t app_id));
+ MOCK_METHOD1(SendHmiStatusNotification,
+ void(application_manager::ApplicationSharedPtr app));
+ MOCK_METHOD0(event_dispatcher, RCPluginEventDispatcher&());
+ MOCK_METHOD0(RemoveAppExtensions, void());
+ MOCK_METHOD0(service, application_manager::ServicePtr());
+ MOCK_CONST_METHOD0(GetModuleID, functional_modules::ModuleID());
+ MOCK_METHOD0(resource_allocation_manager,
+ remote_control::ResourceAllocationManager&());
+ MOCK_METHOD2(OnApplicationEvent,
+ void(functional_modules::ApplicationEvent event,
+ const uint32_t application_id));
+ MOCK_METHOD1(OnPolicyEvent, void(functional_modules::PolicyEvent event));
+};
+
+} // namespace remote_control_test
+} // namespace components
+} // namespace test
+
+#endif // SRC_COMPONENTS_REMOTE_CONTROL_TEST_INCLUDE_MOCK_REMOTE_CONTROL_PLUGIN_H_
diff --git a/src/components/remote_control/test/include/mock_resource_allocation_manager.h b/src/components/remote_control/test/include/mock_resource_allocation_manager.h
new file mode 100644
index 0000000000..d55af2b00d
--- /dev/null
+++ b/src/components/remote_control/test/include/mock_resource_allocation_manager.h
@@ -0,0 +1,40 @@
+#ifndef SRC_COMPONENTS_REMOTE_CONTROL_TEST_INCLUDE_MOCK_RESOURCE_ALLOCATION_MANAGER_H_
+#define SRC_COMPONENTS_REMOTE_CONTROL_TEST_INCLUDE_MOCK_RESOURCE_ALLOCATION_MANAGER_H_
+
+#include "gmock/gmock.h"
+#include "remote_control/resource_allocation_manager.h"
+
+namespace test {
+namespace components {
+namespace remote_control_test {
+
+class MockResourceAllocationManager
+ : public remote_control::ResourceAllocationManager {
+ public:
+ MOCK_METHOD2(AcquireResource,
+ remote_control::AcquireResult::eType(
+ const std::string& module_type, const uint32_t app_id));
+ MOCK_METHOD2(ForceAcquireResource,
+ void(const std::string& module_type, const uint32_t app_id));
+ MOCK_METHOD2(OnDriverDisallowed,
+ void(const std::string& module_type, const uint32_t app_id));
+ MOCK_METHOD2(OnApplicationEvent,
+ void(functional_modules::ApplicationEvent event,
+ const uint32_t application_id));
+ MOCK_METHOD1(OnPolicyEvent, void(functional_modules::PolicyEvent event));
+ MOCK_METHOD1(SetAccessMode,
+ void(const hmi_apis::Common_RCAccessMode::eType access_mode));
+ MOCK_CONST_METHOD0(GetAccessMode, hmi_apis::Common_RCAccessMode::eType());
+ MOCK_METHOD3(SetResourceState,
+ void(const std::string& module_type,
+ const uint32_t app_id,
+ const remote_control::ResourceState::eType state));
+ MOCK_CONST_METHOD1(IsResourceFree, bool(const std::string& module_type));
+ MOCK_METHOD0(ResetAllAllocations, void());
+};
+
+} // namespace remote_control_test
+} // namespace components
+} // namespace test
+
+#endif // SRC_COMPONENTS_REMOTE_CONTROL_TEST_INCLUDE_MOCK_RESOURCE_ALLOCATION_MANAGER_H_
diff --git a/src/components/remote_control/test/src/rc_app_extension_test.cc b/src/components/remote_control/test/src/rc_app_extension_test.cc
new file mode 100644
index 0000000000..78388ccbf1
--- /dev/null
+++ b/src/components/remote_control/test/src/rc_app_extension_test.cc
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2015, 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 "remote_control/rc_app_extension.h"
+
+namespace remote_control {
+
+TEST(CanAppExtensionTest, Create) {
+ RCAppExtension extension(7);
+ ASSERT_TRUE(extension.uid() == 7);
+}
+
+} // namespace remote_control
diff --git a/src/components/remote_control/test/src/rc_library_test.cc b/src/components/remote_control/test/src/rc_library_test.cc
new file mode 100644
index 0000000000..77a57c4c3f
--- /dev/null
+++ b/src/components/remote_control/test/src/rc_library_test.cc
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2015, 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 <dlfcn.h>
+#include "gtest/gtest.h"
+#include "remote_control/remote_control_plugin.h"
+#include "mock_service.h"
+
+using functional_modules::PluginInfo;
+using application_manager::MockService;
+
+using ::testing::Return;
+
+namespace remote_control {
+
+::testing::AssertionResult IsError(void* error) {
+ if (error) {
+ return ::testing::AssertionSuccess() << static_cast<const char*>(error);
+ } else {
+ return ::testing::AssertionFailure() << error;
+ }
+}
+
+TEST(CanLibraryTest, Load) {
+ const std::string kLibraryPath = "libRemoteControlModule.so";
+
+ void* handle = dlopen(kLibraryPath.c_str(), RTLD_LAZY);
+ EXPECT_FALSE(IsError(dlerror()));
+ ASSERT_TRUE(handle != NULL);
+
+ const std::string kSymbol = "Create";
+ void* symbol = dlsym(handle, kSymbol.c_str());
+ EXPECT_FALSE(IsError(dlerror()));
+ ASSERT_TRUE(symbol != NULL);
+
+ typedef CANModule* (*Create)();
+ Create create_manager = reinterpret_cast<Create>(symbol);
+ CANModule* module = create_manager();
+ ASSERT_TRUE(module != NULL);
+
+ PluginInfo plugin = module->GetPluginInfo();
+ EXPECT_EQ(plugin.name, "RemoteControlPlugin");
+ EXPECT_EQ(plugin.version, 1);
+
+ MockService* service = new MockService();
+ module->set_service(service);
+ std::vector<application_manager::ApplicationSharedPtr> apps;
+ EXPECT_CALL(*service, GetApplications(module->GetModuleID()))
+ .Times(1)
+ .WillOnce(Return(apps));
+
+ // in order for all sub-threads to start before shutting them down
+ // The logic conditions must be chosen to insure that the "signal" is
+ // executed if the "wait" is ever processed.
+ // (see http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html)
+ sleep(3);
+ // CANModule::destroy();
+ int ret = dlclose(handle);
+ EXPECT_FALSE(ret);
+ EXPECT_FALSE(IsError(dlerror()));
+}
+
+} // namespace remote_control
diff --git a/src/components/remote_control/test/src/rc_module_test.cc b/src/components/remote_control/test/src/rc_module_test.cc
new file mode 100644
index 0000000000..57efb90551
--- /dev/null
+++ b/src/components/remote_control/test/src/rc_module_test.cc
@@ -0,0 +1,263 @@
+/*
+ * Copyright (c) 2015, 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 "remote_control/remote_control_plugin.h"
+#include "remote_control/rc_app_extension.h"
+#include "remote_control/rc_module_constants.h"
+#include "remote_control/message_helper.h"
+#include "functional_module/module_observer.h"
+#include "application_manager/mock_application.h"
+#include "include/mock_service.h"
+#include "utils/shared_ptr.h"
+#include "utils/make_shared.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/mock_application_manager_settings.h"
+
+using functional_modules::PluginInfo;
+using functional_modules::ProcessResult;
+using functional_modules::RCFunctionID;
+using application_manager::ServicePtr;
+
+using application_manager::MockService;
+using application_manager::MockMessageHelper;
+using test::components::application_manager_test::MockApplication;
+using test::components::application_manager_test::
+ MockApplicationManagerSettings;
+
+using ::testing::_;
+using ::testing::Mock;
+using ::testing::NiceMock;
+using ::testing::StrictMock;
+using ::testing::Return;
+using ::testing::ReturnRef;
+using ::testing::Eq;
+using ::application_manager::Message;
+using ::application_manager::MessageType;
+using ::application_manager::ApplicationSharedPtr;
+using ::protocol_handler::MessagePriority;
+
+namespace {
+const bool kDeviceHandle = 1u;
+const std::string kDeviceId = "1";
+const std::string kDeviceName = "1";
+const uint32_t kDefaultTimeout = 10000;
+}
+
+namespace remote_control {
+
+class RCModuleTest : public ::testing::Test {
+ public:
+ RCModuleTest()
+ : mock_service_(utils::MakeShared<NiceMock<MockService> >())
+ , mock_settings_(
+ utils::MakeShared<NiceMock<MockApplicationManagerSettings> >())
+ , mock_message_helper_(*MockMessageHelper::message_helper_mock())
+ , app0_(utils::MakeShared<NiceMock<MockApplication> >())
+ , app1_(utils::MakeShared<NiceMock<MockApplication> >())
+ , message_(utils::MakeShared<Message>(MessagePriority::FromServiceType(
+ protocol_handler::ServiceType::kRpc)))
+ , rc_app_extention_(
+ utils::MakeShared<RCAppExtension>(module_.GetModuleID())) {}
+
+ void HandleMessage() {
+ module_.ProcessHMIMessage(message_);
+ }
+
+ protected:
+ RemoteControlPlugin module_;
+ utils::SharedPtr<NiceMock<MockService> > mock_service_;
+ utils::SharedPtr<NiceMock<MockApplicationManagerSettings> > mock_settings_;
+ MockMessageHelper& mock_message_helper_;
+ std::vector<ApplicationSharedPtr> apps_;
+ utils::SharedPtr<NiceMock<MockApplication> > app0_;
+ utils::SharedPtr<NiceMock<MockApplication> > app1_;
+ application_manager::MessagePtr message_;
+ utils::SharedPtr<RCAppExtension> rc_app_extention_;
+
+ void SetUp() OVERRIDE {
+ Mock::VerifyAndClearExpectations(&mock_message_helper_);
+ ON_CALL(*mock_service_, GetSettings())
+ .WillByDefault(ReturnRef(*mock_settings_));
+ ON_CALL(*mock_settings_, default_timeout())
+ .WillByDefault(ReturnRef(kDefaultTimeout));
+ ServicePtr exp_service(mock_service_);
+ module_.set_service(exp_service);
+ ServicePtr out_service = module_.service();
+ EXPECT_EQ(exp_service.get(), out_service.get());
+ }
+
+ void TearDown() OVERRIDE {
+ Mock::VerifyAndClearExpectations(&mock_message_helper_);
+ EXPECT_CALL(*mock_service_, GetApplications(module_.GetModuleID()))
+ .WillOnce(Return(apps_));
+ }
+};
+
+TEST_F(RCModuleTest, Create) {
+ EXPECT_EQ(153, module_.GetModuleID());
+ PluginInfo plugin = module_.GetPluginInfo();
+ EXPECT_EQ(plugin.name, "RemoteControlPlugin");
+ EXPECT_EQ(plugin.version, 1);
+}
+
+TEST_F(RCModuleTest, ProcessMessageWrongMessage) {
+ message_->set_function_id(-1);
+ EXPECT_CALL(*mock_service_, SendMessageToMobile(_)).Times(0);
+ EXPECT_EQ(ProcessResult::CANNOT_PROCESS, module_.ProcessMessage(message_));
+}
+
+TEST_F(RCModuleTest, ProcessMessageEmptyapps_List) {
+ message_->set_function_id(RCFunctionID::ON_INTERIOR_VEHICLE_DATA);
+ message_->set_function_name("OnInteriorVehicleData");
+
+ std::string json =
+ "{\"jsonrpc\": \"2.0\", \"method\": \"RC.OnInteriorVehicleData\",\
+ \"params\": {\"moduleData\": {\"moduleType\": \"CLIMATE\",\
+ \"climateControlData\": {\"fanSpeed\": 100} }}}";
+ message_->set_json_message(json);
+
+ EXPECT_CALL(*mock_service_, ValidateMessageBySchema(_))
+ .WillOnce(Return(
+ application_manager::MessageValidationResult::SCHEMA_MISMATCH));
+ EXPECT_CALL(*mock_service_, SendMessageToMobile(_)).Times(0);
+
+ // EXPECT_EQ(ProcessResult::PROCESSED, module_.ProcessMessage(message_));
+ EXPECT_EQ(ProcessResult::CANNOT_PROCESS, module_.ProcessHMIMessage(message_));
+}
+
+TEST_F(RCModuleTest, ProcessMessagePass) {
+ message_->set_function_id(RCFunctionID::ON_INTERIOR_VEHICLE_DATA);
+
+ std::string json =
+ "{ \"jsonrpc\": \"2.0\",\"method\": \"RC.OnInteriorVehicleData\",\
+ \"params\":{\"moduleData\":{\
+ \"moduleType\": \"CLIMATE\",\"climateControlData\": {\"fanSpeed\": 100}}}}";
+
+ message_->set_json_message(json);
+
+ application_manager::BinaryData buf;
+ application_manager::BinaryData* data = &buf;
+ data->push_back(1);
+
+ message_->set_binary_data(data);
+
+ Json::Value json_value = MessageHelper::StringToValue(json);
+ Json::Value module_type =
+ json_value[json_keys::kParams][message_params::kModuleData]
+ [message_params::kModuleType];
+ apps_.push_back(app0_);
+ rc_app_extention_->SubscribeToInteriorVehicleData(module_type);
+ EXPECT_CALL(*mock_service_, ValidateMessageBySchema(_))
+ .WillOnce(Return(application_manager::MessageValidationResult::SUCCESS));
+ EXPECT_CALL(*app0_, QueryInterface(module_.GetModuleID()))
+ .WillOnce(Return(rc_app_extention_));
+ EXPECT_CALL(*app0_, app_id()).WillRepeatedly(Return(1));
+ EXPECT_CALL(*app0_, protocol_version())
+ .WillRepeatedly(
+ Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_4));
+ EXPECT_CALL(*mock_service_, GetApplications(module_.GetModuleID()))
+ .WillOnce(Return(apps_));
+ EXPECT_CALL(*mock_service_, GetApplication(1)).WillOnce(Return(app0_));
+ EXPECT_CALL(*mock_service_, CheckPolicyPermissions(_))
+ .WillOnce(Return(mobile_apis::Result::eType::SUCCESS));
+ EXPECT_CALL(*mock_service_, CheckModule(1, "CLIMATE")).WillOnce(Return(true));
+ EXPECT_CALL(*mock_service_, SendMessageToMobile(_));
+
+ EXPECT_EQ(ProcessResult::PROCESSED, module_.ProcessHMIMessage(message_));
+}
+
+TEST_F(RCModuleTest, RemoveAppExtensionPassWay) {
+ EXPECT_CALL(*mock_service_, GetApplication(1)).WillOnce(Return(app0_));
+ EXPECT_CALL(*app0_, RemoveExtension(module_.GetModuleID()));
+
+ module_.RemoveAppExtension(1);
+}
+
+TEST_F(RCModuleTest, RemoveAppExtensionIfAppNoExist) {
+ ApplicationSharedPtr invalid_app;
+
+ EXPECT_CALL(*mock_service_, GetApplication(_)).WillOnce(Return(invalid_app));
+
+ module_.RemoveAppExtension(1);
+}
+
+TEST_F(RCModuleTest, SendResponseToMobile) {
+ EXPECT_CALL(*mock_service_, SendMessageToMobile(message_));
+
+ module_.SendResponseToMobile(message_);
+}
+
+TEST_F(RCModuleTest, IsAppForPluginSuccess) {
+ application_manager::AppExtensionPtr invalid_ext;
+ EXPECT_CALL(*app0_, QueryInterface(module_.GetModuleID()))
+ .WillOnce(Return(invalid_ext))
+ .WillRepeatedly(Return(rc_app_extention_));
+ EXPECT_CALL(*app0_, AddExtension(_)).WillOnce(Return(true));
+ mobile_apis::HMILevel::eType hmi = mobile_apis::HMILevel::eType::HMI_FULL;
+ EXPECT_CALL(*app0_, hmi_level()).WillRepeatedly(Return(hmi));
+ ON_CALL(*app0_, device()).WillByDefault(Return(1));
+ EXPECT_CALL(*mock_service_, NotifyHMIAboutHMILevel(Eq(app0_), _));
+ EXPECT_CALL(*mock_service_, IsRemoteControlApplication(Eq(app0_)))
+ .WillOnce(Return(true));
+ ASSERT_TRUE(module_.IsAppForPlugin(app0_));
+}
+
+TEST_F(RCModuleTest, IsAppForPluginNotNew) {
+ EXPECT_CALL(*app0_, QueryInterface(module_.GetModuleID()))
+ .WillOnce(Return(rc_app_extention_));
+ EXPECT_CALL(*mock_service_, NotifyHMIAboutHMILevel(Eq(app0_), _)).Times(0);
+ ASSERT_TRUE(module_.IsAppForPlugin(app0_));
+}
+
+TEST_F(RCModuleTest, IsAppForPluginFail) {
+ application_manager::AppExtensionPtr invalid_ext;
+ EXPECT_CALL(*app0_, QueryInterface(module_.GetModuleID()))
+ .WillOnce(Return(invalid_ext));
+ EXPECT_CALL(*mock_service_, IsRemoteControlApplication(Eq(app0_)))
+ .Times(1)
+ .WillOnce(Return(false));
+ ASSERT_FALSE(module_.IsAppForPlugin(app0_));
+}
+
+TEST_F(RCModuleTest, OnAppHMILevelChanged) {
+ const application_manager::custom_str::CustomString name("name");
+ ON_CALL(*app0_, name()).WillByDefault(ReturnRef(name));
+ mobile_apis::HMILevel::eType hmi = mobile_apis::HMILevel::eType::HMI_NONE;
+ EXPECT_CALL(*app0_, hmi_level()).WillRepeatedly(Return(hmi));
+ EXPECT_CALL(*mock_service_,
+ NotifyHMIAboutHMILevel(Eq(app0_),
+ mobile_apis::HMILevel::eType::HMI_NONE));
+ module_.OnAppHMILevelChanged(app0_, mobile_apis::HMILevel::eType::HMI_FULL);
+}
+
+} // namespace remote_control
diff --git a/src/components/remote_control/test/src/resource_allocation_manager_impl_test.cc b/src/components/remote_control/test/src/resource_allocation_manager_impl_test.cc
new file mode 100644
index 0000000000..4d1b399add
--- /dev/null
+++ b/src/components/remote_control/test/src/resource_allocation_manager_impl_test.cc
@@ -0,0 +1,470 @@
+/*
+ * 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. */
+
+#include "gtest/gtest.h"
+#include <algorithm>
+#include "remote_control/resource_allocation_manager_impl.h"
+#include "mock_resource_allocation_manager.h"
+#include "mock_remote_control_plugin.h"
+#include "remote_control/rc_app_extension.h"
+#include "remote_control/rc_module_constants.h"
+#include "remote_control/message_helper.h"
+#include "functional_module/module_observer.h"
+#include "application_manager/mock_application.h"
+#include "include/mock_service.h"
+#include "utils/shared_ptr.h"
+#include "utils/make_shared.h"
+#include "interfaces/HMI_API.h"
+#include "interfaces/MOBILE_API.h"
+
+using functional_modules::PluginInfo;
+using functional_modules::ProcessResult;
+using functional_modules::RCFunctionID;
+using application_manager::ServicePtr;
+
+using application_manager::MockService;
+using namespace test::components;
+using application_manager_test::MockApplication;
+
+using ::testing::_;
+using ::testing::Mock;
+using ::testing::NiceMock;
+using ::testing::StrictMock;
+using ::testing::Return;
+using ::testing::ReturnRef;
+using ::testing::SaveArg;
+using ::testing::Eq;
+using ::testing::DoAll;
+using ::testing::SetArgPointee;
+using ::application_manager::Message;
+using ::application_manager::MessageType;
+using ::application_manager::ApplicationSharedPtr;
+using ::protocol_handler::MessagePriority;
+
+namespace {
+const bool kDeviceHandle = 1u;
+const std::string kModuleType1 = "CLIMATE";
+const std::string kModuleType2 = "RADIO";
+const int32_t kConnectionKey = 5;
+const int32_t kCorrelationId = 5;
+const uint32_t kAppId1 = 11u;
+const uint32_t kAppId2 = 22u;
+const std::string policy_app_id_1_ = "policy_id_1";
+const functional_modules::ModuleID kDefaultModuleID = 0;
+}
+
+namespace remote_control {
+
+class RAManagerTest : public ::testing::Test {
+ public:
+ RAManagerTest()
+ : mock_service_(utils::MakeShared<NiceMock<MockService> >())
+ , mock_app_1_(utils::MakeShared<NiceMock<MockApplication> >())
+ , mock_app_2_(utils::MakeShared<NiceMock<MockApplication> >())
+ , message_(utils::MakeShared<Message>(MessagePriority::FromServiceType(
+ protocol_handler::ServiceType::kRpc))) {
+ EXPECT_CALL(mock_module_, service()).WillRepeatedly(Return(mock_service_));
+ EXPECT_CALL(mock_module_, GetModuleID())
+ .WillRepeatedly(Return(kDefaultModuleID));
+ }
+
+ void CheckResultWithHMILevelAndAccessMode(
+ ResourceAllocationManagerImpl& ra_manager,
+ mobile_apis::HMILevel::eType app_level,
+ const remote_control::AcquireResult::eType expected_result,
+ const hmi_apis::Common_RCAccessMode::eType access_mode) {
+ // Arrange
+ EXPECT_CALL(*mock_service_, GetApplication(kAppId1))
+ .WillOnce(Return(mock_app_1_));
+ ra_manager.SetAccessMode(access_mode);
+ EXPECT_EQ(remote_control::AcquireResult::ALLOWED,
+ ra_manager.AcquireResource(kModuleType1, kAppId1));
+ EXPECT_CALL(*mock_service_, GetApplication(kAppId2))
+ .WillOnce(Return(mock_app_2_));
+ EXPECT_CALL(*mock_app_2_, hmi_level()).WillOnce(Return(app_level));
+ // Second app tries to get already acquired resource by 1st app
+ EXPECT_EQ(expected_result,
+ ra_manager.AcquireResource(kModuleType1, kAppId2));
+ }
+
+ protected:
+ utils::SharedPtr<NiceMock<MockService> > mock_service_;
+ utils::SharedPtr<NiceMock<MockApplication> > mock_app_1_;
+ utils::SharedPtr<NiceMock<MockApplication> > mock_app_2_;
+ application_manager::MessagePtr message_;
+ remote_control_test::MockRemotePluginInterface mock_module_;
+ RemotePluginInterface::RCPluginEventDispatcher event_dispatcher_;
+};
+
+TEST_F(RAManagerTest, AcquireResource_NoAppRegistered_Expect_InUse) {
+ // Arrange
+ EXPECT_CALL(*mock_service_, GetApplication(kAppId1))
+ .WillOnce(Return(ApplicationSharedPtr()));
+ ResourceAllocationManagerImpl ra_manager(mock_module_);
+ // Act & Assert
+ EXPECT_EQ(remote_control::AcquireResult::IN_USE,
+ ra_manager.AcquireResource(kModuleType1, kAppId1));
+}
+
+TEST_F(RAManagerTest,
+ AcquireResource_AppRegisteredAnyHmiLevelResourceFree_Expect_Allowed) {
+ // Arrange
+ EXPECT_CALL(*mock_service_, GetApplication(kAppId1))
+ .WillOnce(Return(mock_app_1_));
+ ResourceAllocationManagerImpl ra_manager(mock_module_);
+ // Act & Assert
+ EXPECT_EQ(remote_control::AcquireResult::ALLOWED,
+ ra_manager.AcquireResource(kModuleType1, kAppId1));
+}
+
+TEST_F(
+ RAManagerTest,
+ AcquireResource_AppInAnyHmiLevelWantsToAcquireSameResourceTwice_Expect_Allowed) {
+ // Arrange
+ EXPECT_CALL(*mock_service_, GetApplication(kAppId1))
+ .WillOnce(Return(mock_app_1_));
+ ResourceAllocationManagerImpl ra_manager(mock_module_);
+ EXPECT_EQ(remote_control::AcquireResult::ALLOWED,
+ ra_manager.AcquireResource(kModuleType1, kAppId1));
+ EXPECT_CALL(*mock_service_, GetApplication(kAppId1))
+ .WillOnce(Return(mock_app_1_));
+ // Same app tries to get already acquired resource
+ EXPECT_EQ(remote_control::AcquireResult::ALLOWED,
+ ra_manager.AcquireResource(kModuleType1, kAppId1));
+}
+
+TEST_F(
+ RAManagerTest,
+ AcquireResource_App2_NotInFULLWantsToGetAcquiredResource_Expect_Rejected) {
+ using namespace mobile_apis;
+ using namespace hmi_apis;
+ using namespace remote_control;
+ const HMILevel::eType app_level = HMILevel::eType::HMI_BACKGROUND;
+ const AcquireResult::eType expected_result = AcquireResult::REJECTED;
+ const Common_RCAccessMode::eType access_mode =
+ Common_RCAccessMode::eType::AUTO_ALLOW;
+ ResourceAllocationManagerImpl ra_manager(mock_module_);
+ CheckResultWithHMILevelAndAccessMode(
+ ra_manager, app_level, expected_result, access_mode);
+}
+
+TEST_F(
+ RAManagerTest,
+ AcquireResource_App2_InFULLWantsToGetAcquiredResource_AUTO_DENY_Expect_InUse) {
+ using namespace mobile_apis;
+ using namespace hmi_apis;
+ using namespace remote_control;
+ const HMILevel::eType app_level = HMILevel::eType::HMI_FULL;
+ const AcquireResult::eType expected_result = AcquireResult::IN_USE;
+ const Common_RCAccessMode::eType access_mode =
+ Common_RCAccessMode::eType::AUTO_DENY;
+ ResourceAllocationManagerImpl ra_manager(mock_module_);
+ CheckResultWithHMILevelAndAccessMode(
+ ra_manager, app_level, expected_result, access_mode);
+}
+
+TEST_F(
+ RAManagerTest,
+ AcquireResource_App2_InFULLWantsToGetAcquiredResource_AUTO_ALLOW_Expect_Allowed) {
+ using namespace mobile_apis;
+ using namespace hmi_apis;
+ using namespace remote_control;
+ const HMILevel::eType app_level = HMILevel::eType::HMI_FULL;
+ const AcquireResult::eType expected_result = AcquireResult::ALLOWED;
+ const Common_RCAccessMode::eType access_mode =
+ Common_RCAccessMode::eType::AUTO_ALLOW;
+ ResourceAllocationManagerImpl ra_manager(mock_module_);
+ CheckResultWithHMILevelAndAccessMode(
+ ra_manager, app_level, expected_result, access_mode);
+}
+
+TEST_F(
+ RAManagerTest,
+ AcquireResource_App2_InFULLWantsToGetAcquiredResource_ASK_DRIVER_Expect_AskDriver) {
+ using namespace mobile_apis;
+ using namespace hmi_apis;
+ using namespace remote_control;
+ const HMILevel::eType app_level = HMILevel::eType::HMI_FULL;
+ const AcquireResult::eType expected_result = AcquireResult::ASK_DRIVER;
+ const Common_RCAccessMode::eType access_mode =
+ Common_RCAccessMode::eType::ASK_DRIVER;
+ ResourceAllocationManagerImpl ra_manager(mock_module_);
+ CheckResultWithHMILevelAndAccessMode(
+ ra_manager, app_level, expected_result, access_mode);
+}
+
+TEST_F(RAManagerTest,
+ AcquireResource_AcquiredModuleIsRejectedForApp2_ExpectApp2Rejected) {
+ // Arrange
+ ResourceAllocationManagerImpl ra_manager(mock_module_);
+ EXPECT_CALL(*mock_service_, GetApplication(kAppId1))
+ .WillOnce(Return(mock_app_1_));
+ EXPECT_EQ(AcquireResult::ALLOWED,
+ ra_manager.AcquireResource(kModuleType1, kAppId1));
+
+ // Act
+ ra_manager.OnDriverDisallowed(kModuleType1, kAppId2);
+
+ // Assert
+ EXPECT_CALL(*mock_service_, GetApplication(kAppId2))
+ .WillOnce(Return(mock_app_2_));
+ EXPECT_EQ(AcquireResult::REJECTED,
+ ra_manager.AcquireResource(kModuleType1, kAppId2));
+}
+
+TEST_F(RAManagerTest, AppExit_ReleaseResource) {
+ // Arrange
+ ResourceAllocationManagerImpl ra_manager(mock_module_);
+ ra_manager.SetAccessMode(hmi_apis::Common_RCAccessMode::eType::AUTO_DENY);
+
+ EXPECT_CALL(*mock_service_, GetApplication(kAppId1))
+ .WillRepeatedly(Return(mock_app_1_));
+
+ RCAppExtensionPtr rc_extention_ptr = utils::MakeShared<RCAppExtension>(
+ application_manager::AppExtensionUID(kDefaultModuleID));
+
+ EXPECT_CALL(*mock_app_1_, QueryInterface(_))
+ .WillOnce(Return(rc_extention_ptr));
+
+ EXPECT_EQ(remote_control::AcquireResult::ALLOWED,
+ ra_manager.AcquireResource(kModuleType1, kAppId1));
+
+ // Act
+ ra_manager.OnApplicationEvent(
+ functional_modules::ApplicationEvent::kApplicationExit, kAppId1);
+
+ EXPECT_CALL(*mock_service_, GetApplication(kAppId2))
+ .WillRepeatedly(Return(mock_app_2_));
+
+ EXPECT_EQ(remote_control::AcquireResult::ALLOWED,
+ ra_manager.AcquireResource(kModuleType1, kAppId2));
+}
+
+TEST_F(RAManagerTest, AnotherAppExit_NoReleaseResource) {
+ // Arrange
+ ResourceAllocationManagerImpl ra_manager(mock_module_);
+ ra_manager.SetAccessMode(hmi_apis::Common_RCAccessMode::eType::AUTO_DENY);
+
+ EXPECT_CALL(*mock_service_, GetApplication(kAppId1))
+ .WillOnce(Return(mock_app_1_));
+
+ EXPECT_EQ(remote_control::AcquireResult::ALLOWED,
+ ra_manager.AcquireResource(kModuleType1, kAppId1));
+
+ EXPECT_CALL(*mock_service_, GetApplication(kAppId2))
+ .WillRepeatedly(Return(mock_app_2_));
+
+ RCAppExtensionPtr rc_extention_ptr = utils::MakeShared<RCAppExtension>(
+ application_manager::AppExtensionUID(kDefaultModuleID));
+
+ EXPECT_CALL(*mock_app_2_, QueryInterface(_))
+ .WillOnce(Return(rc_extention_ptr));
+
+ // Act
+ ra_manager.OnApplicationEvent(
+ functional_modules::ApplicationEvent::kApplicationExit, kAppId2);
+
+ EXPECT_CALL(*mock_service_, GetApplication(kAppId2))
+ .WillOnce(Return(mock_app_2_));
+ EXPECT_CALL(*mock_app_2_, hmi_level())
+ .WillOnce(Return(mobile_apis::HMILevel::HMI_FULL));
+ EXPECT_EQ(remote_control::AcquireResult::IN_USE,
+ ra_manager.AcquireResource(kModuleType1, kAppId2));
+}
+
+TEST_F(RAManagerTest, AppUnregistered_ReleaseResource) {
+ // Arrange
+ ResourceAllocationManagerImpl ra_manager(mock_module_);
+ ra_manager.SetAccessMode(hmi_apis::Common_RCAccessMode::eType::AUTO_DENY);
+
+ RCAppExtensionPtr rc_extention_ptr = utils::MakeShared<RCAppExtension>(
+ application_manager::AppExtensionUID(kDefaultModuleID));
+
+ EXPECT_CALL(*mock_app_1_, QueryInterface(_))
+ .WillOnce(Return(rc_extention_ptr));
+
+ EXPECT_CALL(*mock_service_, GetApplication(kAppId1))
+ .WillRepeatedly(Return(mock_app_1_));
+
+ EXPECT_EQ(remote_control::AcquireResult::ALLOWED,
+ ra_manager.AcquireResource(kModuleType1, kAppId1));
+
+ // Act
+ ra_manager.OnApplicationEvent(
+ functional_modules::ApplicationEvent::kApplicationUnregistered, kAppId1);
+
+ EXPECT_CALL(*mock_service_, GetApplication(kAppId2))
+ .WillOnce(Return(mock_app_2_));
+
+ EXPECT_EQ(remote_control::AcquireResult::ALLOWED,
+ ra_manager.AcquireResource(kModuleType1, kAppId2));
+}
+
+TEST_F(RAManagerTest, AnotherAppUnregistered_NoReleaseResource) {
+ // Arrange
+ ResourceAllocationManagerImpl ra_manager(mock_module_);
+ ra_manager.SetAccessMode(hmi_apis::Common_RCAccessMode::eType::AUTO_DENY);
+
+ EXPECT_CALL(*mock_service_, GetApplication(kAppId1))
+ .WillOnce(Return(mock_app_1_));
+ EXPECT_EQ(remote_control::AcquireResult::ALLOWED,
+ ra_manager.AcquireResource(kModuleType1, kAppId1));
+
+ EXPECT_CALL(*mock_service_, GetApplication(kAppId2))
+ .WillRepeatedly(Return(mock_app_2_));
+
+ RCAppExtensionPtr rc_extention_ptr = utils::MakeShared<RCAppExtension>(
+ application_manager::AppExtensionUID(kDefaultModuleID));
+
+ EXPECT_CALL(*mock_app_2_, QueryInterface(_))
+ .WillOnce(Return(rc_extention_ptr));
+
+ // Act
+ ra_manager.OnApplicationEvent(
+ functional_modules::ApplicationEvent::kApplicationUnregistered, kAppId2);
+
+ EXPECT_CALL(*mock_service_, GetApplication(kAppId2))
+ .WillOnce(Return(mock_app_2_));
+ EXPECT_CALL(*mock_app_2_, hmi_level())
+ .WillOnce(Return(mobile_apis::HMILevel::HMI_FULL));
+ EXPECT_EQ(remote_control::AcquireResult::IN_USE,
+ ra_manager.AcquireResource(kModuleType1, kAppId2));
+}
+
+TEST_F(RAManagerTest, AppsDisallowed_ReleaseAllResources) {
+ // Arrange
+ ResourceAllocationManagerImpl ra_manager(mock_module_);
+ ra_manager.SetAccessMode(hmi_apis::Common_RCAccessMode::eType::AUTO_DENY);
+
+ EXPECT_CALL(*mock_service_, GetApplication(kAppId1))
+ .WillRepeatedly(Return(mock_app_1_));
+
+ EXPECT_EQ(remote_control::AcquireResult::ALLOWED,
+ ra_manager.AcquireResource(kModuleType1, kAppId1));
+ EXPECT_EQ(remote_control::AcquireResult::ALLOWED,
+ ra_manager.AcquireResource(kModuleType2, kAppId1));
+
+ std::vector<ApplicationSharedPtr> apps;
+ apps.push_back(mock_app_1_);
+ EXPECT_CALL(*mock_service_, GetApplications(_)).WillRepeatedly(Return(apps));
+
+ RCAppExtensionPtr rc_extention_ptr = utils::MakeShared<RCAppExtension>(
+ application_manager::AppExtensionUID(kDefaultModuleID));
+
+ EXPECT_CALL(*mock_app_1_, QueryInterface(_))
+ .WillOnce(Return(rc_extention_ptr));
+
+ // Act
+ ra_manager.OnPolicyEvent(
+ functional_modules::PolicyEvent::kApplicationsDisabled);
+
+ EXPECT_CALL(*mock_service_, GetApplication(kAppId2))
+ .WillRepeatedly(Return(mock_app_2_));
+ EXPECT_CALL(*mock_app_2_, hmi_level())
+ .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL));
+ EXPECT_EQ(remote_control::AcquireResult::ALLOWED,
+ ra_manager.AcquireResource(kModuleType1, kAppId2));
+ EXPECT_EQ(remote_control::AcquireResult::ALLOWED,
+ ra_manager.AcquireResource(kModuleType2, kAppId2));
+}
+
+TEST_F(RAManagerTest, AppGotRevokedModulesWithPTU_ReleaseRevokedResource) {
+ // Arrange
+ ResourceAllocationManagerImpl ra_manager(mock_module_);
+ ra_manager.SetAccessMode(hmi_apis::Common_RCAccessMode::eType::AUTO_DENY);
+
+ EXPECT_CALL(*mock_service_, GetApplication(kAppId1))
+ .WillRepeatedly(Return(mock_app_1_));
+
+ RCAppExtensionPtr rc_extention_ptr = utils::MakeShared<RCAppExtension>(
+ application_manager::AppExtensionUID(kDefaultModuleID));
+
+ EXPECT_CALL(*mock_app_1_, QueryInterface(_))
+ .WillOnce(Return(rc_extention_ptr));
+
+ EXPECT_CALL(*mock_service_, GetApplication(kAppId1))
+ .WillRepeatedly(Return(mock_app_1_));
+
+ EXPECT_CALL(*mock_app_1_, app_id()).WillRepeatedly(Return(kAppId1));
+
+ EXPECT_CALL(*mock_app_1_, policy_app_id())
+ .WillRepeatedly(Return(policy_app_id_1_));
+
+ EXPECT_EQ(remote_control::AcquireResult::ALLOWED,
+ ra_manager.AcquireResource(kModuleType1, kAppId1));
+ EXPECT_EQ(remote_control::AcquireResult::ALLOWED,
+ ra_manager.AcquireResource(kModuleType2, kAppId1));
+
+ std::vector<application_manager::ApplicationSharedPtr> apps;
+ apps.push_back(mock_app_1_);
+ EXPECT_CALL(*mock_service_, GetApplications(_)).WillOnce(Return(apps));
+
+ Resources allowed_modules;
+ allowed_modules.push_back(kModuleType1);
+
+ EXPECT_CALL(*mock_service_, GetModuleTypes(policy_app_id_1_, _))
+ .WillOnce(DoAll(SetArgPointee<1>(allowed_modules), Return(true)));
+
+ // Act
+ ra_manager.OnPolicyEvent(
+ functional_modules::PolicyEvent::kApplicationPolicyUpdated);
+
+ EXPECT_CALL(*mock_service_, GetApplication(kAppId2))
+ .WillRepeatedly(Return(mock_app_2_));
+ EXPECT_CALL(*mock_app_2_, hmi_level())
+ .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL));
+ EXPECT_EQ(remote_control::AcquireResult::IN_USE,
+ ra_manager.AcquireResource(kModuleType1, kAppId2));
+ EXPECT_EQ(remote_control::AcquireResult::ALLOWED,
+ ra_manager.AcquireResource(kModuleType2, kAppId2));
+}
+
+TEST_F(RAManagerTest, GetAccessMode_ExpectedSameAsHadSet) {
+ ResourceAllocationManagerImpl ra_manager(mock_module_);
+
+ ra_manager.SetAccessMode(hmi_apis::Common_RCAccessMode::AUTO_DENY);
+ EXPECT_EQ(hmi_apis::Common_RCAccessMode::AUTO_DENY,
+ ra_manager.GetAccessMode());
+
+ ra_manager.SetAccessMode(hmi_apis::Common_RCAccessMode::ASK_DRIVER);
+ EXPECT_EQ(hmi_apis::Common_RCAccessMode::ASK_DRIVER,
+ ra_manager.GetAccessMode());
+
+ ra_manager.SetAccessMode(hmi_apis::Common_RCAccessMode::AUTO_ALLOW);
+ EXPECT_EQ(hmi_apis::Common_RCAccessMode::AUTO_ALLOW,
+ ra_manager.GetAccessMode());
+
+ ra_manager.SetAccessMode(hmi_apis::Common_RCAccessMode::INVALID_ENUM);
+ EXPECT_EQ(hmi_apis::Common_RCAccessMode::INVALID_ENUM,
+ ra_manager.GetAccessMode());
+}
+
+} // namespace remote_control
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 6070f5d757..b6b47c2ed8 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
@@ -547,12 +547,14 @@ void Nullable<T>::ReportErrors(ValidationReport* report) const {
* Optional class
*/
template <typename T>
-Optional<T>::Optional() {}
+Optional<T>::Optional()
+ : policy_table_type_(policy_table_interface_base::INVALID_PT_TYPE) {}
template <typename T>
template <typename U>
Optional<T>::Optional(const U& value)
- : value_(value) {}
+ : policy_table_type_(policy_table_interface_base::INVALID_PT_TYPE)
+ , value_(value) {}
template <typename T>
T& Optional<T>::operator*() {
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 05e9406317..6c8bb359af 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
@@ -350,7 +350,8 @@ inline Json::Value Nullable<T>::ToJsonValue() const {
template <typename T>
template <typename U>
Optional<T>::Optional(const Json::Value* value, const U& def_value)
- : value_(value, def_value) {}
+ : policy_table_type_(policy_table_interface_base::INVALID_PT_TYPE)
+ , value_(value, def_value) {}
template <typename T>
inline Json::Value Optional<T>::ToJsonValue() const {
diff --git a/src/components/security_manager/include/security_manager/crypto_manager_impl.h b/src/components/security_manager/include/security_manager/crypto_manager_impl.h
index 6aea2e28b1..4daf58b004 100644
--- a/src/components/security_manager/include/security_manager/crypto_manager_impl.h
+++ b/src/components/security_manager/include/security_manager/crypto_manager_impl.h
@@ -80,6 +80,15 @@ class CryptoManagerImpl : public CryptoManager {
private:
void PrintCertInfo();
+
+ /**
+ * @brief Removes disallowed for printing certificate information from input
+ * data
+ * @param in_data input data with certificate information
+ * @return filtered string with allowed for printing information
+ */
+ const std::string RemoveDisallowedInfo(X509_NAME* in_data) const;
+
HandshakeResult CheckCertContext();
bool ReadHandshakeData(const uint8_t** const out_data,
size_t* out_data_size);
diff --git a/src/components/security_manager/src/crypto_manager_impl.cc b/src/components/security_manager/src/crypto_manager_impl.cc
index f44198953b..00fcb1385a 100644
--- a/src/components/security_manager/src/crypto_manager_impl.cc
+++ b/src/components/security_manager/src/crypto_manager_impl.cc
@@ -300,36 +300,23 @@ bool CryptoManagerImpl::set_certificate(const std::string& cert_data) {
return false;
}
- BIO* bio = BIO_new(BIO_f_base64());
- BIO* bmem = BIO_new_mem_buf((char*)cert_data.c_str(), cert_data.length());
- bmem = BIO_push(bio, bmem);
-
- char* buf = new char[cert_data.length()];
- int len = BIO_read(bmem, buf, cert_data.length());
-
- BIO* bio_cert = BIO_new(BIO_s_mem());
- if (NULL == bio_cert) {
- LOG4CXX_WARN(logger_, "Unable to update certificate. BIO not created");
- return false;
- }
+ BIO* bio_cert =
+ BIO_new_mem_buf(const_cast<char*>(cert_data.c_str()), cert_data.length());
utils::ScopeGuard bio_guard = utils::MakeGuard(BIO_free, bio_cert);
UNUSED(bio_guard)
- int k = 0;
- if ((k = BIO_write(bio_cert, buf, len)) <= 0) {
- LOG4CXX_WARN(logger_, "Unable to write into BIO");
- return false;
- }
- PKCS12* p12 = d2i_PKCS12_bio(bio_cert, NULL);
- if (NULL == p12) {
- LOG4CXX_ERROR(logger_, "Unable to parse certificate");
- return false;
- }
+ X509* cert = NULL;
+ PEM_read_bio_X509(bio_cert, &cert, 0, 0);
EVP_PKEY* pkey = NULL;
- X509* cert = NULL;
- PKCS12_parse(p12, NULL, &pkey, &cert, NULL);
+ if (1 == BIO_reset(bio_cert)) {
+ PEM_read_bio_PrivateKey(bio_cert, &pkey, 0, 0);
+ } else {
+ LOG4CXX_WARN(logger_,
+ "Unabled to reset BIO in order to read private key, "
+ << LastError());
+ }
if (NULL == cert || NULL == pkey) {
LOG4CXX_WARN(logger_, "Either certificate or key not valid.");
diff --git a/src/components/security_manager/src/ssl_context_impl.cc b/src/components/security_manager/src/ssl_context_impl.cc
index 6f53234867..5be5ff8363 100644
--- a/src/components/security_manager/src/ssl_context_impl.cc
+++ b/src/components/security_manager/src/ssl_context_impl.cc
@@ -32,12 +32,14 @@
#include "security_manager/crypto_manager_impl.h"
#include <assert.h>
-#include <openssl/bio.h>
-#include <openssl/ssl.h>
-#include <openssl/err.h>
#include <memory.h>
#include <map>
#include <algorithm>
+#include <vector>
+
+#include <openssl/bio.h>
+#include <openssl/ssl.h>
+#include <openssl/err.h>
#include "utils/macro.h"
@@ -55,7 +57,8 @@ CryptoManagerImpl::SSLContextImpl::SSLContextImpl(SSL* conn,
, buffer_size_(maximum_payload_size)
, buffer_(new uint8_t[buffer_size_])
, is_handshake_pending_(false)
- , mode_(mode) {
+ , mode_(mode)
+ , max_block_size_(0) {
SSL_set_bio(connection_, bioIn_, bioOut_);
}
@@ -136,32 +139,69 @@ std::map<std::string, CryptoManagerImpl::SSLContextImpl::BlockSizeGetter>
CryptoManagerImpl::SSLContextImpl::max_block_sizes =
CryptoManagerImpl::SSLContextImpl::create_max_block_sizes();
+const std::string CryptoManagerImpl::SSLContextImpl::RemoveDisallowedInfo(
+ X509_NAME* in_data) const {
+ if (!in_data) {
+ return std::string();
+ }
+
+ char* tmp_char_str = X509_NAME_oneline(in_data, NULL, 0);
+ std::string out_str(tmp_char_str);
+ OPENSSL_free(tmp_char_str);
+
+ typedef std::vector<std::string> StringVector;
+ StringVector disallowed_params;
+ disallowed_params.push_back("CN");
+ disallowed_params.push_back("serialNumber");
+
+ const char str_delimiter = '/', param_delimiter = '=';
+ for (StringVector::const_iterator it = disallowed_params.begin();
+ it != disallowed_params.end();
+ ++it) {
+ const std::string search_str = str_delimiter + (*it) + param_delimiter;
+ const size_t occurence_start = out_str.find(search_str);
+ if (std::string::npos == occurence_start) {
+ continue;
+ }
+
+ const size_t occurence_end =
+ out_str.find(str_delimiter, occurence_start + 1);
+ out_str.erase(occurence_start, occurence_end - occurence_start);
+ }
+
+ return out_str;
+}
+
void CryptoManagerImpl::SSLContextImpl::PrintCertData(
X509* cert, const std::string& cert_owner) {
- if (cert) {
- X509_NAME* subj_name = X509_get_subject_name(cert);
- char* subj = X509_NAME_oneline(subj_name, NULL, 0);
- if (subj) {
- std::replace(subj, subj + strlen(subj), '/', ' ');
- LOG4CXX_DEBUG(logger_, cert_owner << " subject:" << subj);
- OPENSSL_free(subj);
- }
- char* issuer = X509_NAME_oneline(X509_get_issuer_name(cert), NULL, 0);
- if (issuer) {
- std::replace(issuer, issuer + strlen(issuer), '/', ' ');
- LOG4CXX_DEBUG(logger_, cert_owner << " issuer:" << issuer);
- OPENSSL_free(issuer);
- }
+ if (!cert) {
+ LOG4CXX_DEBUG(logger_, "Empty certificate data");
+ return;
+ }
- ASN1_TIME* notBefore = X509_get_notBefore(cert);
- ASN1_TIME* notAfter = X509_get_notAfter(cert);
+ std::string subj = RemoveDisallowedInfo(X509_get_subject_name(cert));
+ if (!subj.empty()) {
+ std::replace(subj.begin(), subj.end(), '/', ' ');
+ LOG4CXX_DEBUG(logger_, cert_owner << " subject:" << subj);
+ }
- if (notBefore) {
- LOG4CXX_DEBUG(logger_, " Start date: " << (char*)notBefore->data);
- }
- if (notAfter) {
- LOG4CXX_DEBUG(logger_, " End date: " << (char*)notAfter->data);
- }
+ std::string issuer = RemoveDisallowedInfo(X509_get_issuer_name(cert));
+ if (!issuer.empty()) {
+ std::replace(issuer.begin(), issuer.end(), '/', ' ');
+ LOG4CXX_DEBUG(logger_, cert_owner << " issuer:" << issuer);
+ }
+
+ ASN1_TIME* not_before = X509_get_notBefore(cert);
+ if (not_before) {
+ LOG4CXX_DEBUG(
+ logger_,
+ "Start date: " << static_cast<unsigned char*>(not_before->data));
+ }
+
+ ASN1_TIME* not_after = X509_get_notAfter(cert);
+ if (not_after) {
+ LOG4CXX_DEBUG(logger_,
+ "End date: " << static_cast<unsigned char*>(not_after->data));
}
}
diff --git a/src/components/security_manager/test/crypto_manager_impl_test.cc b/src/components/security_manager/test/crypto_manager_impl_test.cc
index 7fef33f1df..b30684e5f6 100644
--- a/src/components/security_manager/test/crypto_manager_impl_test.cc
+++ b/src/components/security_manager/test/crypto_manager_impl_test.cc
@@ -39,6 +39,7 @@
#include <fstream>
#include <sstream>
+#include "utils/make_shared.h"
#include "gtest/gtest.h"
#include "security_manager/crypto_manager_impl.h"
#include "security_manager/mock_security_manager_settings.h"
@@ -64,10 +65,14 @@ namespace test {
namespace components {
namespace crypto_manager_test {
+using security_manager::CryptoManagerImpl;
+
class CryptoManagerTest : public testing::Test {
protected:
+ typedef NiceMock<security_manager_test::MockCryptoManagerSettings>
+ MockCryptoManagerSettings;
static void SetUpTestCase() {
- std::ifstream certificate_file("server/spt_credential.p12.enc");
+ std::ifstream certificate_file("server/spt_credential.pem");
ASSERT_TRUE(certificate_file.is_open())
<< "Could not open certificate data file";
@@ -81,16 +86,9 @@ class CryptoManagerTest : public testing::Test {
void SetUp() OVERRIDE {
ASSERT_FALSE(certificate_data_base64_.empty());
mock_security_manager_settings_ =
- new NiceMock<security_manager_test::MockCryptoManagerSettings>();
- utils::SharedPtr<security_manager::CryptoManagerSettings> scrypto =
- utils::SharedPtr<security_manager::CryptoManagerSettings>::
- static_pointer_cast<security_manager::CryptoManagerSettings>(
- mock_security_manager_settings_);
- crypto_manager_ = new security_manager::CryptoManagerImpl(scrypto);
- }
-
- void TearDown() OVERRIDE {
- delete mock_security_manager_settings_;
+ utils::MakeShared<MockCryptoManagerSettings>();
+ crypto_manager_ =
+ utils::MakeShared<CryptoManagerImpl>(mock_security_manager_settings_);
}
void InitSecurityManager() {
@@ -117,11 +115,9 @@ class CryptoManagerTest : public testing::Test {
.WillByDefault(Return(false));
}
- security_manager::CryptoManager* crypto_manager_;
+ utils::SharedPtr<CryptoManagerImpl> crypto_manager_;
+ utils::SharedPtr<MockCryptoManagerSettings> mock_security_manager_settings_;
static std::string certificate_data_base64_;
-
- NiceMock<security_manager_test::MockCryptoManagerSettings>*
- mock_security_manager_settings_;
};
std::string CryptoManagerTest::certificate_data_base64_;
diff --git a/src/components/security_manager/test/ssl_certificate_handshake_test.cc b/src/components/security_manager/test/ssl_certificate_handshake_test.cc
index 3d62dd5d6a..9375d6cc32 100644
--- a/src/components/security_manager/test/ssl_certificate_handshake_test.cc
+++ b/src/components/security_manager/test/ssl_certificate_handshake_test.cc
@@ -56,12 +56,12 @@ namespace custom_str = utils::custom_string;
namespace {
const std::string server_ca_cert_filename = "server";
const std::string client_ca_cert_filename = "client";
-const std::string client_certificate = "client/client_credential.p12.enc";
-const std::string server_certificate = "server/spt_credential.p12.enc";
+const std::string client_certificate = "client/client_credential.pem";
+const std::string server_certificate = "server/spt_credential.pem";
const std::string server_unsigned_cert_file =
- "server/spt_credential_unsigned.p12.enc";
+ "server/spt_credential_unsigned.pem";
const std::string server_expired_cert_file =
- "server/spt_credential_expired.p12.enc";
+ "server/spt_credential_expired.pem";
const bool verify_peer = true;
const bool skip_peer_verification = false;
diff --git a/src/components/security_manager/test/ssl_context_test.cc b/src/components/security_manager/test/ssl_context_test.cc
index 9223a74505..945059e58c 100644
--- a/src/components/security_manager/test/ssl_context_test.cc
+++ b/src/components/security_manager/test/ssl_context_test.cc
@@ -88,9 +88,9 @@ struct ProtocolAndCipher {
class SSLTest : public testing::Test {
protected:
static void SetUpTestCase() {
- SetCertificate("server/spt_credential_unsigned.p12.enc",
+ SetCertificate("server/spt_credential_unsigned.pem",
server_certificate_data_base64_);
- SetCertificate("client/client_credential_unsigned.p12.enc",
+ SetCertificate("client/client_credential_unsigned.pem",
client_certificate_data_base64_);
}
diff --git a/src/components/telemetry_monitor/CMakeLists.txt b/src/components/telemetry_monitor/CMakeLists.txt
index bb33857ecd..bb419a92e9 100644
--- a/src/components/telemetry_monitor/CMakeLists.txt
+++ b/src/components/telemetry_monitor/CMakeLists.txt
@@ -39,9 +39,11 @@ include_directories (
${COMPONENTS_DIR}/connection_handler/include/
${COMPONENTS_DIR}/transport_manager/include/
${COMPONENTS_DIR}/application_manager/include/
+ ${COMPONENTS_DIR}/remote_control/include/
${POLICY_PATH}/include/
${POLICY_GLOBAL_INCLUDE_PATH}/
${COMPONENTS_DIR}/rpc_base/include/
+ ${COMPONENTS_DIR}/functional_module/include/
${COMPONENTS_DIR}/hmi_message_handler/include/
${COMPONENTS_DIR}/formatters/include/
${COMPONENTS_DIR}/media_manager/include/
diff --git a/src/components/telemetry_monitor/include/telemetry_monitor/telemetry_monitor.h b/src/components/telemetry_monitor/include/telemetry_monitor/telemetry_monitor.h
index ba8cbceb23..80338804ee 100644
--- a/src/components/telemetry_monitor/include/telemetry_monitor/telemetry_monitor.h
+++ b/src/components/telemetry_monitor/include/telemetry_monitor/telemetry_monitor.h
@@ -95,7 +95,6 @@ class TelemetryMonitor {
private:
std::string server_address_;
int16_t port_;
- bool is_ready_;
threads::Thread* thread_;
Streamer* streamer_;
ApplicationManagerObserver app_observer;
diff --git a/src/components/telemetry_monitor/src/telemetry_monitor.cc b/src/components/telemetry_monitor/src/telemetry_monitor.cc
index 759b843961..88c484ffd4 100644
--- a/src/components/telemetry_monitor/src/telemetry_monitor.cc
+++ b/src/components/telemetry_monitor/src/telemetry_monitor.cc
@@ -1,34 +1,34 @@
/*
- * Copyright (c) 2014, 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.
- */
+* Copyright (c) 2014, 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 "telemetry_monitor/telemetry_monitor.h"
@@ -59,7 +59,7 @@ TelemetryMonitor::TelemetryMonitor(const std::string& server_address,
, ph_observer(this) {}
void TelemetryMonitor::Start() {
- streamer_ = new Streamer(this);
+ streamer_ = streamer_ ? streamer_ : new Streamer(this);
thread_ = threads::CreateThread("TelemetryMonitor", streamer_);
}
@@ -86,6 +86,7 @@ int16_t TelemetryMonitor::port() const {
TelemetryMonitor::~TelemetryMonitor() {
Stop();
+ delete streamer_;
}
void TelemetryMonitor::Init(
@@ -170,6 +171,7 @@ void Streamer::exitThreadMain() {
LOG4CXX_AUTO_TRACE(logger_);
Stop();
messages_.Shutdown();
+ ThreadDelegate::exitThreadMain();
}
void Streamer::Start() {
diff --git a/src/components/telemetry_monitor/test/telemetry_monitor_test.cc b/src/components/telemetry_monitor/test/telemetry_monitor_test.cc
index 5043524a06..090c7ab5b7 100644
--- a/src/components/telemetry_monitor/test/telemetry_monitor_test.cc
+++ b/src/components/telemetry_monitor/test/telemetry_monitor_test.cc
@@ -90,14 +90,14 @@ TEST(TelemetryMonitorTest, MessageProcess) {
EXPECT_CALL(am_observeble, SetTelemetryObserver(_));
EXPECT_CALL(transport_manager_mock, SetTelemetryObserver(_));
telemetry_monitor::TelemetryMonitor telemetry_monitor(server_address, port);
- StreamerMock streamer_mock(&telemetry_monitor);
+ StreamerMock* streamer_mock = new StreamerMock(&telemetry_monitor);
+ // streamer_mock will be freed by telemetry_monitor on destruction
telemetry_monitor.Start();
-
- telemetry_monitor.set_streamer(&streamer_mock);
+ telemetry_monitor.set_streamer(streamer_mock);
telemetry_monitor.Init(
&protocol_handler_mock, &am_observeble, &transport_manager_mock);
utils::SharedPtr<telemetry_monitor::MetricWrapper> test_metric;
- EXPECT_CALL(streamer_mock, PushMessage(test_metric));
+ EXPECT_CALL(*streamer_mock, PushMessage(test_metric));
telemetry_monitor.SendMetric(test_metric);
}
diff --git a/src/components/transport_manager/src/bluetooth/bluetooth_device_scanner.cc b/src/components/transport_manager/src/bluetooth/bluetooth_device_scanner.cc
index 85e6dc3f96..743c95f2e6 100644
--- a/src/components/transport_manager/src/bluetooth/bluetooth_device_scanner.cc
+++ b/src/components/transport_manager/src/bluetooth/bluetooth_device_scanner.cc
@@ -255,9 +255,11 @@ void BluetoothDeviceScanner::CheckSDLServiceOnDevices(
if (hci_read_remote_name_ret != 0) {
LOG4CXX_ERROR_WITH_ERRNO(logger_, "hci_read_remote_name failed");
+ int name_len = sizeof(deviceName) / sizeof(deviceName[0]);
strncpy(deviceName,
BluetoothDevice::GetUniqueDeviceId(bd_address).c_str(),
- sizeof(deviceName) / sizeof(deviceName[0]));
+ name_len - 1);
+ deviceName[name_len - 1] = '\0';
}
Device* bluetooth_device =
diff --git a/src/components/transport_manager/src/bluetooth/bluetooth_socket_connection.cc b/src/components/transport_manager/src/bluetooth/bluetooth_socket_connection.cc
index 16960aa1d4..b4370e4b12 100644
--- a/src/components/transport_manager/src/bluetooth/bluetooth_socket_connection.cc
+++ b/src/components/transport_manager/src/bluetooth/bluetooth_socket_connection.cc
@@ -106,14 +106,12 @@ bool BluetoothSocketConnection::Establish(ConnectError** error) {
if (0 == connect_status) {
LOG4CXX_DEBUG(logger_, "rfcomm Connect ok");
break;
- }
- if (errno != 111 && errno != 104) {
- LOG4CXX_DEBUG(logger_, "rfcomm Connect errno " << errno);
- break;
- }
- if (errno) {
- LOG4CXX_DEBUG(logger_, "rfcomm Connect errno " << errno);
- close(rfcomm_socket);
+ } else { // If connect_status is not 0, an errno is returned
+ LOG4CXX_WARN_WITH_ERRNO(logger_, "rfcomm Connect failed");
+ close(rfcomm_socket); // Always close the socket upon error
+ if (errno != ECONNREFUSED && errno != ECONNRESET) {
+ break;
+ }
}
sleep(2);
} while (--attempts > 0);
diff --git a/src/components/transport_manager/src/tcp/tcp_client_listener.cc b/src/components/transport_manager/src/tcp/tcp_client_listener.cc
index 48f5dbd613..52a566c5ff 100644
--- a/src/components/transport_manager/src/tcp/tcp_client_listener.cc
+++ b/src/components/transport_manager/src/tcp/tcp_client_listener.cc
@@ -93,7 +93,10 @@ TransportAdapter::Error TcpClientListener::Init() {
server_address.sin_addr.s_addr = INADDR_ANY;
int optval = 1;
- setsockopt(socket_, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval));
+ if (0 !=
+ setsockopt(socket_, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval))) {
+ LOG4CXX_WARN_WITH_ERRNO(logger_, "setsockopt SO_REUSEADDR failed");
+ }
if (bind(socket_,
reinterpret_cast<sockaddr*>(&server_address),
@@ -146,12 +149,28 @@ void SetKeepaliveOptions(const int fd) {
int keepintvl = 1;
#ifdef __linux__
int user_timeout = 7000; // milliseconds
- setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &yes, sizeof(yes));
- setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &keepidle, sizeof(keepidle));
- setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT, &keepcnt, sizeof(keepcnt));
- setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL, &keepintvl, sizeof(keepintvl));
- setsockopt(
- fd, IPPROTO_TCP, TCP_USER_TIMEOUT, &user_timeout, sizeof(user_timeout));
+ if (0 != setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &yes, sizeof(yes))) {
+ LOG4CXX_WARN_WITH_ERRNO(logger_, "setsockopt SO_KEEPALIVE failed");
+ }
+ if (0 !=
+ setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &keepidle, sizeof(keepidle))) {
+ LOG4CXX_WARN_WITH_ERRNO(logger_, "setsockopt TCP_KEEPIDLE failed");
+ }
+ if (0 !=
+ setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT, &keepcnt, sizeof(keepcnt))) {
+ LOG4CXX_WARN_WITH_ERRNO(logger_, "setsockopt TCP_KEEPCNT failed");
+ }
+ if (0 != setsockopt(
+ fd, IPPROTO_TCP, TCP_KEEPINTVL, &keepintvl, sizeof(keepintvl))) {
+ LOG4CXX_WARN_WITH_ERRNO(logger_, "setsockopt TCP_KEEPINTVL failed");
+ }
+ if (0 != setsockopt(fd,
+ IPPROTO_TCP,
+ TCP_USER_TIMEOUT,
+ &user_timeout,
+ sizeof(user_timeout))) {
+ LOG4CXX_WARN_WITH_ERRNO(logger_, "setsockopt TCP_USER_TIMEOUT failed");
+ }
#elif defined(__QNX__) // __linux__
// TODO(KKolodiy): Out of order!
const int kMidLength = 4;
@@ -246,10 +265,16 @@ void TcpClientListener::StopLoop() {
server_address.sin_family = AF_INET;
server_address.sin_port = htons(port_);
server_address.sin_addr.s_addr = INADDR_ANY;
- connect(byesocket,
- reinterpret_cast<sockaddr*>(&server_address),
- sizeof(server_address));
- shutdown(byesocket, SHUT_RDWR);
+ if (0 != connect(byesocket,
+ reinterpret_cast<sockaddr*>(&server_address),
+ sizeof(server_address))) {
+ LOG4CXX_WARN_WITH_ERRNO(logger_, "Failed to connect byesocket");
+ } else {
+ // Can only shutdown socket if connected
+ if (0 != shutdown(byesocket, SHUT_RDWR)) {
+ LOG4CXX_WARN_WITH_ERRNO(logger_, "Failed to shutdown byesocket");
+ }
+ }
close(byesocket);
}
diff --git a/src/components/transport_manager/src/transport_adapter/threaded_socket_connection.cc b/src/components/transport_manager/src/transport_adapter/threaded_socket_connection.cc
index 081caec50a..135babdeb0 100644
--- a/src/components/transport_manager/src/transport_adapter/threaded_socket_connection.cc
+++ b/src/components/transport_manager/src/transport_adapter/threaded_socket_connection.cc
@@ -267,7 +267,7 @@ void ThreadedSocketConnection::Transmit() {
const bool is_queue_empty = IsFramesToSendQueueEmpty();
// Send data if possible
- if (!is_queue_empty && (poll_fds[0].revents | POLLOUT)) {
+ if (!is_queue_empty && (poll_fds[0].revents & POLLOUT)) {
LOG4CXX_DEBUG(logger_, "frames_to_send_ not empty() ");
// send data
diff --git a/src/components/transport_manager/test/transport_manager_impl_test.cc b/src/components/transport_manager/test/transport_manager_impl_test.cc
index 14362050a2..c7cf3b2cb2 100644
--- a/src/components/transport_manager/test/transport_manager_impl_test.cc
+++ b/src/components/transport_manager/test/transport_manager_impl_test.cc
@@ -70,10 +70,10 @@ const uint32_t kAsyncExpectationsTimeout = 10000u;
class TransportManagerImplTest : public ::testing::Test {
protected:
TransportManagerImplTest()
- : tm_(settings)
- , device_handle_(1)
+ : device_handle_(1)
, mac_address_("MA:CA:DR:ES:S")
- , dev_info_(device_handle_, mac_address_, "TestDeviceName", "BTMAC") {}
+ , dev_info_(device_handle_, mac_address_, "TestDeviceName", "BTMAC")
+ , tm_(settings) {}
void SetUp() OVERRIDE {
resumption::LastStateImpl last_state_("app_storage_folder",
@@ -313,7 +313,6 @@ class TransportManagerImplTest : public ::testing::Test {
ASSERT_EQ(E_SUCCESS, tm_.Stop());
}
MockTransportManagerSettings settings;
- MockTransportManagerImpl tm_;
#ifdef TELEMETRY_MONITOR
MockTMTelemetryObserver mock_metric_observer_;
#endif // TELEMETRY_MONITOR
@@ -329,6 +328,7 @@ class TransportManagerImplTest : public ::testing::Test {
const DeviceInfo dev_info_;
DeviceList device_list_;
BaseErrorPtr error_;
+ MockTransportManagerImpl tm_;
};
TEST_F(TransportManagerImplTest, SearchDevices_AdaptersNotAdded) {
diff --git a/src/components/utils/include/utils/file_system.h b/src/components/utils/include/utils/file_system.h
index 5862241c9c..22c200934f 100644
--- a/src/components/utils/include/utils/file_system.h
+++ b/src/components/utils/include/utils/file_system.h
@@ -38,6 +38,7 @@
#include <string>
#include <vector>
#include <iostream>
+#include <fstream>
namespace file_system {
@@ -153,6 +154,14 @@ std::string CurrentWorkingDirectory();
std::string GetAbsolutePath(const std::string& path);
/**
+ * @brief Checks if file name contains invalid symbols e.g. '/'
+ * @param file_name file name to check
+ * @return true if file name does not contain any invalid symbol otherwise
+ * returns false
+ */
+bool IsFileNameValid(const std::string& file_name);
+
+/**
* @brief Removes file
*
* @param name path to file
diff --git a/src/components/utils/include/utils/log_message_loop_thread.h b/src/components/utils/include/utils/log_message_loop_thread.h
index deea1a07c0..d6a9edd072 100644
--- a/src/components/utils/include/utils/log_message_loop_thread.h
+++ b/src/components/utils/include/utils/log_message_loop_thread.h
@@ -66,6 +66,8 @@ class LogMessageLoopThread : public LogMessageLoopThreadTemplate {
LogMessageLoopThread();
~LogMessageLoopThread();
+ private:
+ LogMessageHandler* handler_;
DISALLOW_COPY_AND_ASSIGN(LogMessageLoopThread);
};
diff --git a/src/components/utils/src/file_system.cc b/src/components/utils/src/file_system.cc
index 91ff0c3b07..62a91ad1f3 100644
--- a/src/components/utils/src/file_system.cc
+++ b/src/components/utils/src/file_system.cc
@@ -60,8 +60,11 @@ uint64_t file_system::GetAvailableDiskSpace(const std::string& path) {
int64_t file_system::FileSize(const std::string& path) {
if (file_system::FileExists(path)) {
struct stat file_info = {0};
- stat(path.c_str(), &file_info);
- return file_info.st_size;
+ if (0 != stat(path.c_str(), &file_info)) {
+ LOG4CXX_WARN_WITH_ERRNO(logger_, "Could not get file size: " << path);
+ } else {
+ return file_info.st_size;
+ }
}
return 0;
}
@@ -70,15 +73,8 @@ size_t file_system::DirectorySize(const std::string& path) {
size_t size = 0;
int32_t return_code = 0;
DIR* directory = NULL;
-
-#ifndef __QNXNTO__
struct dirent dir_element_;
struct dirent* dir_element = &dir_element_;
-#else
- char* direntbuffer = new char[offsetof(struct dirent, d_name) +
- pathconf(path.c_str(), _PC_NAME_MAX) + 1];
- struct dirent* dir_element = new (direntbuffer) dirent;
-#endif
struct dirent* result = NULL;
struct stat file_info = {0};
directory = opendir(path.c_str());
@@ -100,15 +96,14 @@ size_t file_system::DirectorySize(const std::string& path) {
}
}
closedir(directory);
-#ifdef __QNXNTO__
- delete[] direntbuffer;
-#endif
return size;
}
std::string file_system::CreateDirectory(const std::string& name) {
if (!DirectoryExists(name)) {
- mkdir(name.c_str(), S_IRWXU);
+ if (0 != mkdir(name.c_str(), S_IRWXU)) {
+ LOG4CXX_WARN_WITH_ERRNO(logger_, "Unable to create directory: " << name);
+ }
}
return name;
@@ -222,6 +217,10 @@ std::string file_system::GetAbsolutePath(const std::string& path) {
return std::string(abs_path);
}
+bool file_system::IsFileNameValid(const std::string& file_name) {
+ return file_name.end() == std::find(file_name.begin(), file_name.end(), '/');
+}
+
bool file_system::DeleteFile(const std::string& name) {
if (FileExists(name) && IsAccessible(name, W_OK)) {
return !remove(name.c_str());
@@ -232,15 +231,8 @@ bool file_system::DeleteFile(const std::string& name) {
void file_system::remove_directory_content(const std::string& directory_name) {
int32_t return_code = 0;
DIR* directory = NULL;
-#ifndef __QNXNTO__
struct dirent dir_element_;
struct dirent* dir_element = &dir_element_;
-#else
- char* direntbuffer =
- new char[offsetof(struct dirent, d_name) +
- pathconf(directory_name.c_str(), _PC_NAME_MAX) + 1];
- struct dirent* dir_element = new (direntbuffer) dirent;
-#endif
struct dirent* result = NULL;
directory = opendir(directory_name.c_str());
@@ -261,15 +253,15 @@ void file_system::remove_directory_content(const std::string& directory_name) {
remove_directory_content(full_element_path);
rmdir(full_element_path.c_str());
} else {
- remove(full_element_path.c_str());
+ if (0 != remove(full_element_path.c_str())) {
+ LOG4CXX_WARN_WITH_ERRNO(
+ logger_, "Unable to remove file: " << full_element_path);
+ }
}
}
}
closedir(directory);
-#ifdef __QNXNTO__
- delete[] direntbuffer;
-#endif
}
bool file_system::RemoveDirectory(const std::string& directory_name,
@@ -305,15 +297,8 @@ std::vector<std::string> file_system::ListFiles(
int32_t return_code = 0;
DIR* directory = NULL;
-#ifndef __QNXNTO__
struct dirent dir_element_;
struct dirent* dir_element = &dir_element_;
-#else
- char* direntbuffer =
- new char[offsetof(struct dirent, d_name) +
- pathconf(directory_name.c_str(), _PC_NAME_MAX) + 1];
- struct dirent* dir_element = new (direntbuffer) dirent;
-#endif
struct dirent* result = NULL;
directory = opendir(directory_name.c_str());
@@ -333,10 +318,6 @@ std::vector<std::string> file_system::ListFiles(
closedir(directory);
}
-#ifdef __QNXNTO__
- delete[] direntbuffer;
-#endif
-
return listFiles;
}
@@ -411,12 +392,10 @@ bool file_system::CreateFile(const std::string& path) {
uint64_t file_system::GetFileModificationTime(const std::string& path) {
struct stat info;
- stat(path.c_str(), &info);
-#ifndef __QNXNTO__
+ if (0 != stat(path.c_str(), &info)) {
+ LOG4CXX_WARN_WITH_ERRNO(logger_, "Could not get file mod time: " << path);
+ }
return static_cast<uint64_t>(info.st_mtim.tv_nsec);
-#else
- return static_cast<uint64_t>(info.st_mtime);
-#endif
}
bool file_system::CopyFile(const std::string& src, const std::string& dst) {
diff --git a/src/components/utils/src/log_message_loop_thread.cc b/src/components/utils/src/log_message_loop_thread.cc
index 77bc8107eb..2b7f28fbfd 100644
--- a/src/components/utils/src/log_message_loop_thread.cc
+++ b/src/components/utils/src/log_message_loop_thread.cc
@@ -44,12 +44,14 @@ void LogMessageHandler::Handle(const LogMessage message) {
}
LogMessageLoopThread::LogMessageLoopThread()
- : LogMessageLoopThreadTemplate("Logger", new LogMessageHandler()) {}
+ : LogMessageLoopThreadTemplate("Logger",
+ handler_ = new LogMessageHandler()) {}
LogMessageLoopThread::~LogMessageLoopThread() {
// we'll have to drop messages
// while deleting logger thread
logger_status = DeletingLoggerThread;
+ delete handler_;
}
} // namespace logger
diff --git a/src/components/utils/src/threads/thread_delegate.cc b/src/components/utils/src/threads/thread_delegate.cc
index 7bdce000da..917603f92c 100644
--- a/src/components/utils/src/threads/thread_delegate.cc
+++ b/src/components/utils/src/threads/thread_delegate.cc
@@ -52,6 +52,7 @@ void ThreadDelegate::exitThreadMain() {
} else {
pthread_cancel(thread_->thread_handle());
}
+ thread_ = NULL;
}
}
diff --git a/src/components/utils/src/timer.cc b/src/components/utils/src/timer.cc
index 642f16e574..b819b56f54 100644
--- a/src/components/utils/src/timer.cc
+++ b/src/components/utils/src/timer.cc
@@ -64,7 +64,7 @@ timer::Timer::~Timer() {
StopDelegate();
single_shot_ = true;
- delegate_.release();
+ delegate_.reset();
DeleteThread(thread_);
DCHECK(task_);
delete task_;
diff --git a/src/components/utils/test/async_runner_test.cc b/src/components/utils/test/async_runner_test.cc
index 3dd6383588..65abad65c2 100644
--- a/src/components/utils/test/async_runner_test.cc
+++ b/src/components/utils/test/async_runner_test.cc
@@ -30,57 +30,72 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <ctime>
#include <stdlib.h>
-
-#include "gtest/gtest.h"
-
+#include <ctime>
+#include <memory>
#include "utils/lock.h"
-#include "utils/conditional_variable.h"
#include "utils/threads/async_runner.h"
+#include "utils/conditional_variable.h"
+#include "utils/shared_ptr.h"
+#include "utils/make_shared.h"
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
namespace test {
namespace components {
-namespace utils_test {
+namespace utils {
-using namespace sync_primitives;
using namespace threads;
namespace {
-uint32_t check_value = 0;
+size_t kCheckValue = 0u;
+const size_t kDelegatesAmount = 4u;
}
// ThreadDelegate successor
class TestThreadDelegate : public ThreadDelegate {
public:
+ TestThreadDelegate(sync_primitives::ConditionalVariable& cond_var,
+ sync_primitives::Lock& test_lock)
+ : cond_var_(cond_var), test_lock_(test_lock) {}
+
void threadMain() {
- ++check_value;
+ sync_primitives::AutoLock lock(test_lock_);
+ ++kCheckValue;
+ cond_var_.NotifyOne();
}
+
+ protected:
+ sync_primitives::ConditionalVariable& cond_var_;
+ sync_primitives::Lock& test_lock_;
+};
+
+class MockThreadDelegate : public ThreadDelegate {
+ public:
+ MOCK_METHOD0(threadMain, void());
+ MOCK_METHOD0(exitThreadMain, void());
};
class AsyncRunnerTest : public ::testing::Test {
public:
- AsyncRunnerTest() : kDelegatesNum_(1), asr_pt_(NULL) {
+ AsyncRunnerTest() {
+ // Clear global value before test execution
+ kCheckValue = 0;
CreateAsyncRunner();
CreateThreadsArray();
}
~AsyncRunnerTest() {
- DeleteAsyncRunner();
DeleteThreadsArray();
}
protected:
- Lock test_lock_;
- uint32_t kDelegatesNum_;
- ConditionalVariable cond_var_;
- TestThreadDelegate** delegates_;
- AsyncRunner* asr_pt_;
+ ThreadDelegate** delegates_;
+ ::utils::SharedPtr<AsyncRunner> async_runner_;
void CreateThreadsArray() {
- srand(std::time(NULL));
- kDelegatesNum_ = (rand() % 20 + 1);
- delegates_ = new TestThreadDelegate* [kDelegatesNum_];
+ delegates_ = new ThreadDelegate* [kDelegatesAmount];
}
void DeleteThreadsArray() {
@@ -88,53 +103,38 @@ class AsyncRunnerTest : public ::testing::Test {
}
void CreateAsyncRunner() {
- asr_pt_ = new AsyncRunner("test");
- }
- void DeleteAsyncRunner() {
- delete asr_pt_;
+ async_runner_ = ::utils::MakeShared<AsyncRunner>("test");
}
};
TEST_F(AsyncRunnerTest, ASyncRunManyDelegates_ExpectSuccessfulAllDelegatesRun) {
- AutoLock lock(test_lock_);
- // Clear global value before test
- check_value = 0;
// Create Delegates and run
- for (unsigned int i = 0; i < kDelegatesNum_; ++i) {
- delegates_[i] = new TestThreadDelegate();
- asr_pt_->AsyncRun(delegates_[i]);
+ sync_primitives::ConditionalVariable cond_var;
+ sync_primitives::Lock test_lock;
+ for (size_t i = 0; i < kDelegatesAmount; ++i) {
+ sync_primitives::AutoLock lock(test_lock);
+ delegates_[i] = new TestThreadDelegate(cond_var, test_lock);
+ async_runner_->AsyncRun(delegates_[i]);
+ // Wait for delegate to be run
+ cond_var.WaitFor(lock, 1500);
}
- // Wait for 2 secs. Give this time to delegates to be run
- cond_var_.WaitFor(lock, 2000);
- // Expect all delegates run successfully
- EXPECT_EQ(kDelegatesNum_, check_value);
+ // Expect all delegates started successfully
+ EXPECT_EQ(kDelegatesAmount, kCheckValue);
}
-// TODO(VVeremjova) APPLINK-12834 Sometimes delegates do not run
-TEST_F(AsyncRunnerTest,
- DISABLED_RunManyDelegatesAndStop_ExpectSuccessfulDelegatesStop) {
- AutoLock lock(test_lock_);
- // Clear global value before test
- check_value = 0;
- // Create Delegates
- for (unsigned int i = 0; i < kDelegatesNum_; ++i) {
- delegates_[i] = new TestThreadDelegate();
- }
- // Wait for 2 secs
- cond_var_.WaitFor(lock, 2000);
- // Run created delegates
- for (unsigned int i = 0; i < kDelegatesNum_; ++i) {
- if (kDelegatesNum_ > 1) {
- if (i == kDelegatesNum_ / 2) {
- asr_pt_->Stop();
- }
- }
- asr_pt_->AsyncRun(delegates_[i]);
+TEST_F(AsyncRunnerTest, StopThenRun_ExpectDelegateNotStarted) {
+ // Create Delegate mock
+ MockThreadDelegate mock_thread_delegate;
+ // Check that delegate was not started due to Stop() called before AsyncRun()
+ EXPECT_CALL(mock_thread_delegate, threadMain()).Times(0);
+ {
+ ::utils::SharedPtr<AsyncRunner> async_runner =
+ ::utils::MakeShared<AsyncRunner>("test");
+ async_runner->Stop();
+ async_runner->AsyncRun(&mock_thread_delegate);
}
- // Expect 3 delegates run successlully. The other stopped.
- EXPECT_EQ(kDelegatesNum_ / 2, check_value);
}
-} // namespace utils_test
+} // namespace utils
} // namespace components
} // namespace test
diff --git a/src/components/utils/test/conditional_variable_test.cc b/src/components/utils/test/conditional_variable_test.cc
index 86c9dfa2e0..524d53cafa 100644
--- a/src/components/utils/test/conditional_variable_test.cc
+++ b/src/components/utils/test/conditional_variable_test.cc
@@ -123,7 +123,7 @@ TEST_F(
CheckWaitForWithTimeout1sec_ThreadBlockedForTimeout_ExpectSuccessfulWakeUp) {
sync_primitives::AutoLock test_lock(test_mutex_);
sync_primitives::ConditionalVariable::WaitStatus wait_st =
- cond_var_.WaitFor(test_lock, 1000);
+ cond_var_.WaitFor(test_lock, 10);
EXPECT_EQ(sync_primitives::ConditionalVariable::kTimeout, wait_st);
}
diff --git a/src/components/utils/test/messagemeter_test.cc b/src/components/utils/test/messagemeter_test.cc
index efaaa41252..4ec14ac1cc 100644
--- a/src/components/utils/test/messagemeter_test.cc
+++ b/src/components/utils/test/messagemeter_test.cc
@@ -126,7 +126,8 @@ TEST(MessageMeterTest, AddingWithNullTimeRange) {
}
}
-TEST_P(MessageMeterTest, TrackMessage_AddingOverPeriod_CorrectCountOfMessages) {
+TEST_P(MessageMeterTest,
+ DISABLED_TrackMessage_AddingOverPeriod_CorrectCountOfMessages) {
size_t messages = 0;
const TimevalStruct start_time = date_time::DateTime::getCurrentTime();
// Add messages for less range period
@@ -150,7 +151,7 @@ TEST_P(MessageMeterTest, TrackMessage_AddingOverPeriod_CorrectCountOfMessages) {
}
TEST_P(MessageMeterTest,
- TrackMessage_AddingOverPeriodMultiIds_CorrectCountOfMessages) {
+ DISABLED_TrackMessage_AddingOverPeriodMultiIds_CorrectCountOfMessages) {
size_t messages = 0;
const TimevalStruct start_time = date_time::DateTime::getCurrentTime();
// Add messages for less range period
@@ -184,7 +185,8 @@ TEST_P(MessageMeterTest,
}
}
-TEST_P(MessageMeterTest, Frequency_CountingOverPeriod_CorrectCountOfMessages) {
+TEST_P(MessageMeterTest,
+ DISABLED_Frequency_CountingOverPeriod_CorrectCountOfMessages) {
const size_t one_message = 1;
const TimevalStruct start_time = date_time::DateTime::getCurrentTime();
EXPECT_EQ(one_message, meter.TrackMessage(id1));
@@ -206,7 +208,7 @@ TEST_P(MessageMeterTest, Frequency_CountingOverPeriod_CorrectCountOfMessages) {
}
}
-TEST_P(MessageMeterTest, CountingOutOfPeriod) {
+TEST_P(MessageMeterTest, DISABLED_CountingOutOfPeriod) {
const size_t one_message = 1;
EXPECT_EQ(one_message, meter.TrackMessage(id1));
EXPECT_EQ(one_message, meter.TrackMessage(id2));
diff --git a/src/components/utils/test/scope_guard_test.cc b/src/components/utils/test/scope_guard_test.cc
index 85abbd90de..5e685d6aba 100644
--- a/src/components/utils/test/scope_guard_test.cc
+++ b/src/components/utils/test/scope_guard_test.cc
@@ -43,7 +43,7 @@ using ::utils::MakeGuard;
using ::utils::MakeObjGuard;
using ::testing::Mock;
-class TestObject {
+class TestCalleeObject {
public:
MOCK_METHOD0(function_to_call, void());
MOCK_METHOD1(function_to_call_with_param, void(void*));
@@ -68,21 +68,21 @@ TEST(ScopeGuardTest, CallFreeFunctionWithParam) {
}
TEST(ScopeGuardTest, CallObjectFunction) {
- TestObject obj;
+ TestCalleeObject obj;
Mock::AllowLeak(&obj); // Google tests bug
EXPECT_CALL(obj, function_to_call()).Times(1);
{
- ScopeGuard guard = MakeObjGuard(obj, &TestObject::function_to_call);
+ ScopeGuard guard = MakeObjGuard(obj, &TestCalleeObject::function_to_call);
UNUSED(guard);
}
}
TEST(ScopeGuardTest, CallObjectFunctionWithParam) {
- TestObject obj;
+ TestCalleeObject obj;
EXPECT_CALL(obj, function_to_call_with_param(&obj)).Times(1);
{
ScopeGuard guard =
- MakeObjGuard(obj, &TestObject::function_to_call_with_param, &obj);
+ MakeObjGuard(obj, &TestCalleeObject::function_to_call_with_param, &obj);
UNUSED(guard);
}
}
@@ -98,20 +98,20 @@ TEST(ScopeGuardTest, DismissCallFreeFunctionWithParam) {
}
TEST(ScopeGuardTest, DismissCallObjectFunction) {
- TestObject obj;
+ TestCalleeObject obj;
EXPECT_CALL(obj, function_to_call()).Times(0);
{
- ScopeGuard guard = MakeObjGuard(obj, &TestObject::function_to_call);
+ ScopeGuard guard = MakeObjGuard(obj, &TestCalleeObject::function_to_call);
guard.Dismiss();
}
}
TEST(ScopeGuardTest, DismissCallObjectFunctionWithParam) {
- TestObject obj;
+ TestCalleeObject obj;
EXPECT_CALL(obj, function_to_call_with_param(&obj)).Times(0);
{
ScopeGuard guard =
- MakeObjGuard(obj, &TestObject::function_to_call_with_param, &obj);
+ MakeObjGuard(obj, &TestCalleeObject::function_to_call_with_param, &obj);
guard.Dismiss();
}
}
diff --git a/src/components/utils/test/shared_ptr_test.cc b/src/components/utils/test/shared_ptr_test.cc
index a30f2f66eb..99fe4f7dd7 100644
--- a/src/components/utils/test/shared_ptr_test.cc
+++ b/src/components/utils/test/shared_ptr_test.cc
@@ -507,7 +507,7 @@ TEST(SharedPtrTest, ValidMethodTest_ExpectCorrectValidation) {
ASSERT_FALSE(p2.valid());
}
-TEST(SharedPtrTest, StressTest) {
+TEST(SharedPtrTest, DISABLED_StressTest) {
// Arrange
const size_t kNumIterations = 1024U * 1024U;
diff --git a/src/components/utils/test/sqlite_wrapper/sql_query_test.cc b/src/components/utils/test/sqlite_wrapper/sql_query_test.cc
index b481e45fd3..c10c26a2c7 100644
--- a/src/components/utils/test/sqlite_wrapper/sql_query_test.cc
+++ b/src/components/utils/test/sqlite_wrapper/sql_query_test.cc
@@ -97,7 +97,9 @@ class SQLQueryTest : public ::testing::Test {
};
sqlite3* SQLQueryTest::conn = 0;
-const std::string SQLQueryTest::kDatabaseName = "test-query";
+
+// mounting /tmp as tmpfs will descrease utils unit tests runing time
+const std::string SQLQueryTest::kDatabaseName = "/tmp/test-query";
TEST_F(SQLQueryTest, Query_CreateQuery_QueryInDBEqualCreated) {
// arrange